Changed: Use Endianness from File API

This commit is contained in:
sewer56 2023-12-07 18:19:34 +00:00
parent 78a20835c5
commit 5f0befc69d
1 changed files with 5 additions and 6 deletions

View File

@ -110,13 +110,12 @@ fn dump(args: DumpArgs) -> Result<()> {
}
}
} else {
// [.elf] e_ident.ei_data == ELFDATA2LSB
// This offset is constant for ELF32.
if buf[5] == 1 {
unsafe { ENDIAN = Endian::Little };
};
let obj_file = object::read::File::parse(buf)?;
// [.elf] e_ident.ei_data == ELFDATA2LSB
if obj_file.endianness() == object::Endianness::Little {
unsafe { ENDIAN = Endian::Little };
}
let debug_section = obj_file
.section_by_name(".debug")
.ok_or_else(|| anyhow!("Failed to locate .debug section"))?;