mirror of
https://github.com/encounter/decomp-toolkit.git
synced 2025-07-03 19:55:51 +00:00
Changed: Detect bitness from .elf header.
This commit is contained in:
parent
3e14b2f287
commit
24c8dce0a8
@ -50,9 +50,6 @@ pub struct DumpArgs {
|
|||||||
#[argp(switch)]
|
#[argp(switch)]
|
||||||
/// Disable color output.
|
/// Disable color output.
|
||||||
no_color: bool,
|
no_color: bool,
|
||||||
/// Whether to use Little Endian for DWARF parsing.
|
|
||||||
#[argp(switch)]
|
|
||||||
little_endian: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(args: Args) -> Result<()> {
|
pub fn run(args: Args) -> Result<()> {
|
||||||
@ -72,10 +69,6 @@ fn dump(args: DumpArgs) -> Result<()> {
|
|||||||
let syntax = syntax_set.find_syntax_by_name("C++").context("Failed to find syntax")?.clone();
|
let syntax = syntax_set.find_syntax_by_name("C++").context("Failed to find syntax")?.clone();
|
||||||
|
|
||||||
// Set Endian
|
// Set Endian
|
||||||
if args.little_endian {
|
|
||||||
unsafe { ENDIAN = Endian::Little };
|
|
||||||
}
|
|
||||||
|
|
||||||
let file = map_file(&args.in_file)?;
|
let file = map_file(&args.in_file)?;
|
||||||
let buf = file.as_slice();
|
let buf = file.as_slice();
|
||||||
if buf.starts_with(b"!<arch>\n") {
|
if buf.starts_with(b"!<arch>\n") {
|
||||||
@ -117,6 +110,12 @@ fn dump(args: DumpArgs) -> Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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)?;
|
let obj_file = object::read::File::parse(buf)?;
|
||||||
let debug_section = obj_file
|
let debug_section = obj_file
|
||||||
.section_by_name(".debug")
|
.section_by_name(".debug")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user