lib/tldr/src/formats/elf/layout/got.zig

daab053ee43316e1809a84551d573ddd1e5bf3d2

 1 const symbol = @import("symbol.zig");
 2 
 3 const SymbolRef = symbol.SymbolRef;
 4 
 5 pub const GotEntry = struct {
 6     ref: SymbolRef,
 7     offset: u64,
 8 };
 9 
10 pub const GotLayout = struct {
11     entries: []GotEntry = &.{},
12 
13     pub fn deinit(self: *GotLayout, allocator: anytype) void {
14         if (self.entries.len != 0) allocator.free(self.entries);
15     }
16 
17     pub fn entryOffset(self: GotLayout, ref: SymbolRef) ?u64 {
18         for (self.entries) |entry| {
19             if (entry.ref.eql(ref)) return entry.offset;
20         }
21         return null;
22     }
23 };