MCPcopy Create free account
hub / github.com/N64Recomp/N64Recomp / get_segment

Function get_segment

src/elf.cpp:209–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207};
208
209std::optional<size_t> get_segment(const std::vector<SegmentEntry>& segments, ELFIO::Elf_Xword section_size, ELFIO::Elf64_Off section_offset) {
210 // A linear search is safest even if the segment list is sorted, as there may be overlapping segments
211 for (size_t i = 0; i < segments.size(); i++) {
212 const auto& segment = segments[i];
213
214 // Check that the section's data in the elf file is within bounds of the segment's data
215 if (section_offset >= segment.data_offset && section_offset + section_size <= segment.data_offset + segment.memory_size) {
216 return i;
217 }
218 }
219
220 return std::nullopt;
221}
222
223ELFIO::section* read_sections(N64Recomp::Context& context, ELFIO::section*& mdebug_section_out, const N64Recomp::ElfParsingConfig& elf_config, const ELFIO::elfio& elf_file) {
224 ELFIO::section* symtab_section = nullptr;

Callers 1

read_sectionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected