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

daab053ee43316e1809a84551d573ddd1e5bf3d2

 1 const frame = @import("frame.zig");
 2 const merge = @import("merge.zig");
 3 const section = @import("section.zig");
 4 
 5 pub const ObjectLayout = struct {
 6     sections: []section.SectionContribution,
 7     common_symbols: []section.SectionContribution,
 8     merge_sections: []merge.MergeSectionLayout,
 9     eh_frame_sections: []frame.EhFrameSectionLayout,
10 
11     pub fn deinit(self: *ObjectLayout, allocator: anytype) void {
12         if (self.common_symbols.len != 0) allocator.free(self.common_symbols);
13         for (self.merge_sections) |*merge_section| merge_section.deinit(allocator);
14         if (self.merge_sections.len != 0) allocator.free(self.merge_sections);
15         for (self.eh_frame_sections) |*eh_frame_section| eh_frame_section.deinit(allocator);
16         if (self.eh_frame_sections.len != 0) allocator.free(self.eh_frame_sections);
17     }
18 };
19 
20 pub fn mergeSection(object_layout: ObjectLayout, section_index: usize) ?merge.MergeSectionLayout {
21     return merge.sectionAt(object_layout.merge_sections, section_index);
22 }
23 
24 pub fn ehFrameSection(object_layout: ObjectLayout, section_index: usize) ?frame.EhFrameSectionLayout {
25     return frame.sectionAt(object_layout.eh_frame_sections, section_index);
26 }