MCPcopy Index your code
hub / github.com/encounter/objdiff / load_file_section

Function load_file_section

objdiff-core/src/obj/dwarf2.rs:84–104  ·  view source on GitHub ↗
(
    id: gimli::SectionId,
    file: &object::File<'input>,
    endian: Endian,
    arena_data: &'arena Arena<Cow<'input, [u8]>>,
    arena_relocations: &'arena Arena<RelocationMap>,
)

Source from the content-addressed store, hash-verified

82type Relocate<'a, R> = gimli::RelocateReader<R, &'a RelocationMap>;
83
84fn load_file_section<'input, 'arena, Endian: gimli::Endianity>(
85 id: gimli::SectionId,
86 file: &object::File<'input>,
87 endian: Endian,
88 arena_data: &'arena Arena<Cow<'input, [u8]>>,
89 arena_relocations: &'arena Arena<RelocationMap>,
90) -> Result<Relocate<'arena, gimli::EndianSlice<'arena, Endian>>> {
91 let mut relocations = RelocationMap::default();
92 let data = match file.section_by_name(id.name()) {
93 Some(ref section) => {
94 relocations.add(file, section);
95 section.uncompressed_data()?
96 }
97 // Use a non-zero capacity so that `ReaderOffsetId`s are unique.
98 None => Cow::Owned(Vec::with_capacity(1)),
99 };
100 let data_ref = arena_data.alloc(data);
101 let section = gimli::EndianSlice::new(data_ref, endian);
102 let relocations = arena_relocations.alloc(relocations);
103 Ok(Relocate::new(section, relocations))
104}
105
106#[inline]
107fn gimli_error(e: gimli::Error, context: &str) -> anyhow::Error {

Callers 1

parse_line_info_dwarf2Function · 0.85

Calls 2

nameMethod · 0.80
addMethod · 0.80

Tested by

no test coverage detected