lib/tldr/src/formats/elf/relocation/output.zig
daab053ee43316e1809a84551d573ddd1e5bf3d2
1 const std = @import("std");
2 const elf = @import("../root.zig");
3
4 const format = elf.format;
5 const output_section = elf.output_section;
6 const parser = elf.parser;
7
8 const ObjectFile = parser.ObjectFile;
9 const debugOutputIndexForName = output_section.debugOutputIndexForName;
10 const sectionIsAllocated = format.sectionIsAllocated;
11 const sectionNameOrEmpty = parser.sectionNameOrEmpty;
12
13 pub fn sectionRelocationsAffectOutput(object: ObjectFile, section_index: usize) bool {
14 if (section_index >= object.sections.len) return false;
15 const section = object.sections[section_index];
16 if (sectionIsAllocated(section)) return true;
17 if (section.section_type != std.elf.SHT_PROGBITS) return false;
18 return debugOutputIndexForName(sectionNameOrEmpty(object, section_index)) != null;
19 }