lib/tldr/src/formats/elf/relocation/model.zig
daab053ee43316e1809a84551d573ddd1e5bf3d2
1 const std = @import("std");
2 const elf = @import("../root.zig");
3
4 const Allocator = std.mem.Allocator;
5 const format = elf.format;
6 const Rela = format.Rela;
7
8 pub const RelocationRange = struct {
9 start: usize,
10 count: usize,
11 };
12
13 pub const ObjectParseOptions = struct {
14 strip_debug: bool = false,
15 };
16
17 pub const ParsedRelocations = struct {
18 relocations: []const Rela,
19 owned: bool,
20 ranges: []RelocationRange,
21
22 pub fn deinit(self: ParsedRelocations, allocator: Allocator) void {
23 if (self.owned and self.relocations.len != 0) allocator.free(@constCast(self.relocations));
24 if (self.ranges.len != 0) allocator.free(self.ranges);
25 }
26 };
27
28 pub const RelocationCounts = struct {
29 counts: []usize = &.{},
30 duplicate_targets: bool = false,
31
32 pub fn deinit(self: *RelocationCounts, allocator: Allocator) void {
33 if (self.counts.len != 0) allocator.free(self.counts);
34 }
35 };
36
37 pub const SectionMetadata = struct {
38 symtab_index: ?usize = null,
39 has_relocation_sections: bool = false,
40 has_group_sections: bool = false,
41 };