From a17468b5ab14c4620bf9fa5ca99385ecf5b415f4 Mon Sep 17 00:00:00 2001 From: Philip Craig Date: Mon, 4 Dec 2023 00:00:00 +0000 Subject: [PATCH 1/2] read: restrict is_definition to symbols defined in sections Also for XCOFF, include label definitions, since they sometimes provide names that are not given by the csect definitions, and include common definitions, since they do have addresses. Also for Wasm, include data symbols. --- .../testfiles/coff/import_msvc.lib.objdump | 9 ---- .../testfiles/elf/base-aarch64.objdump | 2 - .../testfiles/pe/base-bigobj.obj.objdump | 2 - .../testfiles/pe/base-gnu.exe.objdump | 19 --------- crates/examples/testfiles/pe/base.obj.objdump | 2 - .../examples/testfiles/wasm/base.wasm.objdump | 1 + .../testfiles/wasm/global-wasm32.objdump | 12 ++++++ .../wasm/global-wasm64-import.objdump | 12 ++++++ .../testfiles/wasm/global-wasm64.objdump | 13 ++++++ .../examples/testfiles/xcoff/base.o.objdump | 3 ++ .../testfiles/xcoff/base.xcoff.objdump | 41 +++++++++++++++++++ .../examples/testfiles/xcoff/base32.o.objdump | 3 ++ .../testfiles/xcoff/base32.xcoff.objdump | 40 ++++++++++++++++++ src/read/coff/symbol.rs | 3 +- src/read/elf/symbol.rs | 3 +- src/read/macho/symbol.rs | 2 +- src/read/wasm.rs | 3 +- src/read/xcoff/symbol.rs | 10 ++--- 18 files changed, 136 insertions(+), 44 deletions(-) diff --git a/crates/examples/testfiles/coff/import_msvc.lib.objdump b/crates/examples/testfiles/coff/import_msvc.lib.objdump index 0ef5e6e6..b748956c 100644 --- a/crates/examples/testfiles/coff/import_msvc.lib.objdump +++ b/crates/examples/testfiles/coff/import_msvc.lib.objdump @@ -53,7 +53,6 @@ Symbols Dynamic symbols Symbol map -0x0 "@comp.id" 0x0 "test_x64_NULL_THUNK_DATA" test_x64.dll: @@ -75,7 +74,6 @@ Symbols Dynamic symbols Symbol map -0x0 "@comp.id" 0x0 "__NULL_IMPORT_DESCRIPTOR" test_x64.dll: @@ -110,7 +108,6 @@ Symbols Dynamic symbols Symbol map -0x0 "@comp.id" 0x0 "__IMPORT_DESCRIPTOR_test_x64" 0x0 ".idata$6" @@ -143,7 +140,6 @@ Symbols Dynamic symbols Symbol map -0x0 "@comp.id" 0x0 "test_x86_NULL_THUNK_DATA" test_x86.dll: @@ -165,7 +161,6 @@ Symbols Dynamic symbols Symbol map -0x0 "@comp.id" 0x0 "__NULL_IMPORT_DESCRIPTOR" test_x86.dll: @@ -200,7 +195,6 @@ Symbols Dynamic symbols Symbol map -0x0 "@comp.id" 0x0 "__IMPORT_DESCRIPTOR_test_x86" 0x0 ".idata$6" @@ -233,7 +227,6 @@ Symbols Dynamic symbols Symbol map -0x0 "@comp.id" 0x0 "test_arm64ec_NULL_THUNK_DATA" test_arm64ec.dll: @@ -255,7 +248,6 @@ Symbols Dynamic symbols Symbol map -0x0 "@comp.id" 0x0 "__NULL_IMPORT_DESCRIPTOR" test_arm64ec.dll: @@ -290,6 +282,5 @@ Symbols Dynamic symbols Symbol map -0x0 "@comp.id" 0x0 "__IMPORT_DESCRIPTOR_test_arm64ec" 0x0 ".idata$6" diff --git a/crates/examples/testfiles/elf/base-aarch64.objdump b/crates/examples/testfiles/elf/base-aarch64.objdump index 080e53be..e50b6b8b 100644 --- a/crates/examples/testfiles/elf/base-aarch64.objdump +++ b/crates/examples/testfiles/elf/base-aarch64.objdump @@ -178,8 +178,6 @@ Symbol map 0x7f8 "__FRAME_END__" 0x10d80 "__frame_dummy_init_array_entry" 0x10d88 "__do_global_dtors_aux_fini_array_entry" -0x10d90 "_DYNAMIC" -0x10fc0 "_GLOBAL_OFFSET_TABLE_" 0x11008 "__dso_handle" 0x11010 "completed.8500" 0x11010 "__TMC_END__" diff --git a/crates/examples/testfiles/pe/base-bigobj.obj.objdump b/crates/examples/testfiles/pe/base-bigobj.obj.objdump index 935e6df5..7554d285 100644 --- a/crates/examples/testfiles/pe/base-bigobj.obj.objdump +++ b/crates/examples/testfiles/pe/base-bigobj.obj.objdump @@ -62,8 +62,6 @@ Symbols Dynamic symbols Symbol map -0x0 "@comp.id" -0x0 "@feat.00" 0x0 "___local_stdio_printf_options" 0x0 "__vfprintf_l" 0x0 "_printf" diff --git a/crates/examples/testfiles/pe/base-gnu.exe.objdump b/crates/examples/testfiles/pe/base-gnu.exe.objdump index 512bd6aa..a7630256 100644 --- a/crates/examples/testfiles/pe/base-gnu.exe.objdump +++ b/crates/examples/testfiles/pe/base-gnu.exe.objdump @@ -1384,25 +1384,6 @@ Import { library: "msvcrt.dll", name: "vfprintf" } Import { library: "msvcrt.dll", name: "wcslen" } Symbol map -0x0 "__ImageBase" -0x0 "__dll_characteristics__" -0x0 "__size_of_stack_commit__" -0x0 "__size_of_stack_reserve__" -0x0 "__major_subsystem_version__" -0x0 "__size_of_heap_commit__" -0x0 "__dll__" -0x0 "__minor_os_version__" -0x0 "__image_base__" -0x0 "__section_alignment__" -0x0 "__rt_psrelocs_size" -0x0 "__file_alignment__" -0x0 "__major_os_version__" -0x0 "__size_of_heap_reserve__" -0x0 "__subsystem__" -0x0 "__major_image_version__" -0x0 "__loader_flags__" -0x0 "__minor_subsystem_version__" -0x0 "__minor_image_version__" 0x140001000 "__mingw_invalidParameterHandler" 0x140001010 "pre_c_init" 0x140001130 "pre_cpp_init" diff --git a/crates/examples/testfiles/pe/base.obj.objdump b/crates/examples/testfiles/pe/base.obj.objdump index 935e6df5..7554d285 100644 --- a/crates/examples/testfiles/pe/base.obj.objdump +++ b/crates/examples/testfiles/pe/base.obj.objdump @@ -62,8 +62,6 @@ Symbols Dynamic symbols Symbol map -0x0 "@comp.id" -0x0 "@feat.00" 0x0 "___local_stdio_printf_options" 0x0 "__vfprintf_l" 0x0 "_printf" diff --git a/crates/examples/testfiles/wasm/base.wasm.objdump b/crates/examples/testfiles/wasm/base.wasm.objdump index 30c72278..2f1e32f1 100644 --- a/crates/examples/testfiles/wasm/base.wasm.objdump +++ b/crates/examples/testfiles/wasm/base.wasm.objdump @@ -66,6 +66,7 @@ Symbols Dynamic symbols Symbol map +0x0 "memory" 0x2 "__wasm_call_ctors" 0x5 "_start" 0x2f "__original_main" diff --git a/crates/examples/testfiles/wasm/global-wasm32.objdump b/crates/examples/testfiles/wasm/global-wasm32.objdump index dab9836e..b7c8fbef 100644 --- a/crates/examples/testfiles/wasm/global-wasm32.objdump +++ b/crates/examples/testfiles/wasm/global-wasm32.objdump @@ -38,5 +38,17 @@ Symbols Dynamic symbols Symbol map +0x0 "memory" +0x0 "__memory_base" +0x1 "__table_base" 0x2 "__wasm_call_ctors" 0x5 "print" +0x400 "global1" +0x400 "__dso_handle" +0x400 "__global_base" +0x404 "global2" +0x408 "__data_end" +0x410 "__stack_low" +0x10410 "__stack_high" +0x10410 "__heap_base" +0x20000 "__heap_end" diff --git a/crates/examples/testfiles/wasm/global-wasm64-import.objdump b/crates/examples/testfiles/wasm/global-wasm64-import.objdump index 5277c058..1220a858 100644 --- a/crates/examples/testfiles/wasm/global-wasm64-import.objdump +++ b/crates/examples/testfiles/wasm/global-wasm64-import.objdump @@ -38,5 +38,17 @@ Symbols Dynamic symbols Symbol map +0x0 "__memory_base" +0x1 "__table_base" +0x1 "__table_base32" 0x2 "__wasm_call_ctors" 0x5 "print" +0x400 "global1" +0x400 "__dso_handle" +0x400 "__global_base" +0x404 "global2" +0x408 "__data_end" +0x410 "__stack_low" +0x10410 "__stack_high" +0x10410 "__heap_base" +0x20000 "__heap_end" diff --git a/crates/examples/testfiles/wasm/global-wasm64.objdump b/crates/examples/testfiles/wasm/global-wasm64.objdump index 7d99c632..fd42876c 100644 --- a/crates/examples/testfiles/wasm/global-wasm64.objdump +++ b/crates/examples/testfiles/wasm/global-wasm64.objdump @@ -39,5 +39,18 @@ Symbols Dynamic symbols Symbol map +0x0 "memory" +0x0 "__memory_base" +0x1 "__table_base" +0x1 "__table_base32" 0x2 "__wasm_call_ctors" 0x5 "print" +0x400 "global1" +0x400 "__dso_handle" +0x400 "__global_base" +0x404 "global2" +0x408 "__data_end" +0x410 "__stack_low" +0x10410 "__stack_high" +0x10410 "__heap_base" +0x20000 "__heap_end" diff --git a/crates/examples/testfiles/xcoff/base.o.objdump b/crates/examples/testfiles/xcoff/base.o.objdump index b3ac199d..93076b0c 100644 --- a/crates/examples/testfiles/xcoff/base.o.objdump +++ b/crates/examples/testfiles/xcoff/base.o.objdump @@ -33,3 +33,6 @@ Symbol map 0x0 ".text" 0x0 ".main" 0x58 ".rodata.str1.1L...str" +0x68 "main" +0x80 "TOC" +0x80 ".rodata.str1.1L...str" diff --git a/crates/examples/testfiles/xcoff/base.xcoff.objdump b/crates/examples/testfiles/xcoff/base.xcoff.objdump index 39fc4398..115f1006 100644 --- a/crates/examples/testfiles/xcoff/base.xcoff.objdump +++ b/crates/examples/testfiles/xcoff/base.xcoff.objdump @@ -175,11 +175,52 @@ Symbol map 0x100000448 ".__C_runtime_termination" 0x100000498 ".__C_runtime_startup" 0x100000520 ".__dftdt__L304e50f8c42_5CatchFv" +0x100000598 ".__run_final_dtors" +0x100000598 ".__run_final_dtors" +0x1000005c0 ".atexit" +0x1000005c0 ".atexit" +0x1000005e8 ".__run_initial_ctors" +0x1000005e8 ".__run_initial_ctors" +0x100000610 ".exit" +0x100000610 ".exit" 0x100000640 ".text" 0x100000640 ".main" +0x100000698 ".printf" +0x100000698 ".printf" 0x1000006c0 ".rodata.str1.1L...str" 0x1100006d0 "crt0_data" 0x110000738 "_$STATIC" 0x110000798 "__C_runtime_pstartup" 0x1100007a0 "_$STATIC" 0x110000838 "_cdtors" +0x110000848 "__start" +0x110000858 "__threads_init" +0x110000870 "__C_runtime_startup" +0x110000888 "__dftdt__L304e50f8c42_5CatchFv" +0x1100008a0 "__C_runtime_termination" +0x1100008b8 "TOC" +0x1100008b8 "_malloc_user_defined_name" +0x1100008c0 "p_xargc" +0x1100008c8 "__pth_init_routine" +0x1100008d0 "_bsd_init_routine" +0x1100008d8 "_xti_tli_init_routine" +0x1100008e0 "_nsl_init_routine" +0x1100008e8 "__dce_compat_init_routine" +0x1100008f0 "p_xargv" +0x1100008f8 "p_xrcfg" +0x1100008fc "p_xrc" +0x110000900 "__crt0v" +0x110000908 "crt0_data" +0x110000910 "__run_final_dtors" +0x110000918 "_$STATIC" +0x110000920 "__C_runtime_termination" +0x110000928 "atexit" +0x110000930 "_cdtors" +0x110000938 "__run_initial_ctors" +0x110000940 "exit" +0x110000948 "__n_pthreads" +0x110000950 "__mod_init" +0x110000958 "__malloc_user_defined_name" +0x110000960 "errno" +0x110000968 ".rodata.str1.1L...str" +0x110000970 "printf" diff --git a/crates/examples/testfiles/xcoff/base32.o.objdump b/crates/examples/testfiles/xcoff/base32.o.objdump index 3c37890c..bc571236 100644 --- a/crates/examples/testfiles/xcoff/base32.o.objdump +++ b/crates/examples/testfiles/xcoff/base32.o.objdump @@ -33,3 +33,6 @@ Symbol map 0x0 ".text" 0x0 ".main" 0x5c ".rodata.str1.1L...str" +0x6c "main" +0x78 "TOC" +0x78 ".rodata.str1.1L...str" diff --git a/crates/examples/testfiles/xcoff/base32.xcoff.objdump b/crates/examples/testfiles/xcoff/base32.xcoff.objdump index 6447003b..73eed8ef 100644 --- a/crates/examples/testfiles/xcoff/base32.xcoff.objdump +++ b/crates/examples/testfiles/xcoff/base32.xcoff.objdump @@ -169,11 +169,51 @@ Symbol map 0x10000368 ".__C_runtime_termination" 0x100003b8 ".__C_runtime_startup" 0x10000440 ".__dftdt__L304e4b28c42_5CatchFv" +0x100004b8 ".__run_final_dtors" +0x100004b8 ".__run_final_dtors" +0x100004e0 ".atexit" +0x100004e0 ".atexit" +0x10000508 ".__run_initial_ctors" +0x10000508 ".__run_initial_ctors" +0x10000530 ".exit" +0x10000530 ".exit" 0x10000560 ".text" 0x10000560 ".main" +0x100005bc ".printf" +0x100005bc ".printf" 0x100005e4 ".rodata.str1.1L...str" 0x200005f4 "crt0_data" 0x20000620 "_$STATIC" 0x2000067c "__C_runtime_pstartup" 0x20000680 "_$STATIC" 0x20000708 "_cdtors" +0x20000710 "__start" +0x20000718 "__threads_init" +0x20000724 "__C_runtime_startup" +0x20000730 "__dftdt__L304e4b28c42_5CatchFv" +0x2000073c "__C_runtime_termination" +0x20000748 "TOC" +0x20000748 "_malloc_user_defined_name" +0x2000074c "p_xargc" +0x20000750 "__pth_init_routine" +0x20000754 "_bsd_init_routine" +0x20000758 "_xti_tli_init_routine" +0x2000075c "_nsl_init_routine" +0x20000760 "__dce_compat_init_routine" +0x20000764 "p_xargv" +0x20000768 "p_xrcfg" +0x2000076c "p_xrc" +0x20000770 "__crt0v" +0x20000774 "__mod_init" +0x20000778 "crt0_data" +0x2000077c "__run_final_dtors" +0x20000780 "_$STATIC" +0x20000784 "__C_runtime_termination" +0x20000788 "atexit" +0x2000078c "_cdtors" +0x20000790 "__run_initial_ctors" +0x20000794 "exit" +0x20000798 "__malloc_user_defined_name" +0x2000079c "errno" +0x200007a0 ".rodata.str1.1L...str" +0x200007a4 "printf" diff --git a/src/read/coff/symbol.rs b/src/read/coff/symbol.rs index 78a77666..8adc4845 100644 --- a/src/read/coff/symbol.rs +++ b/src/read/coff/symbol.rs @@ -542,8 +542,7 @@ pub trait ImageSymbol: Debug + Pod { /// Return true if the symbol is a definition of a function or data object. fn is_definition(&self) -> bool { - let section_number = self.section_number(); - if section_number == pe::IMAGE_SYM_UNDEFINED { + if self.section_number() <= 0 { return false; } match self.storage_class() { diff --git a/src/read/elf/symbol.rs b/src/read/elf/symbol.rs index 73afbf6f..efc1a9f8 100644 --- a/src/read/elf/symbol.rs +++ b/src/read/elf/symbol.rs @@ -478,7 +478,8 @@ pub trait Sym: Debug + Pod { /// Return true if the symbol is a definition of a function or data object. fn is_definition(&self, endian: Self::Endian) -> bool { - if self.st_shndx(endian) == elf::SHN_UNDEF { + let shndx = self.st_shndx(endian); + if shndx == elf::SHN_UNDEF || (shndx >= elf::SHN_LORESERVE && shndx != elf::SHN_XINDEX) { return false; } match self.st_type() { diff --git a/src/read/macho/symbol.rs b/src/read/macho/symbol.rs index ef885214..290b4817 100644 --- a/src/read/macho/symbol.rs +++ b/src/read/macho/symbol.rs @@ -432,7 +432,7 @@ pub trait Nlist: Debug + Pod { /// Return true if the symbol is a definition of a function or data object. fn is_definition(&self) -> bool { let n_type = self.n_type(); - n_type & macho::N_STAB == 0 && n_type & macho::N_TYPE != macho::N_UNDF + n_type & macho::N_STAB == 0 && n_type & macho::N_TYPE == macho::N_SECT } /// Return the library ordinal. diff --git a/src/read/wasm.rs b/src/read/wasm.rs index b950ef2b..05b5cbc7 100644 --- a/src/read/wasm.rs +++ b/src/read/wasm.rs @@ -901,7 +901,8 @@ impl<'data, 'file> ObjectSymbol<'data> for WasmSymbol<'data, 'file> { #[inline] fn is_definition(&self) -> bool { - self.symbol.kind == SymbolKind::Text && self.symbol.section != SymbolSection::Undefined + (self.symbol.kind == SymbolKind::Text || self.symbol.kind == SymbolKind::Data) + && self.symbol.section != SymbolSection::Undefined } #[inline] diff --git a/src/read/xcoff/symbol.rs b/src/read/xcoff/symbol.rs index fd9558dc..b03aec54 100644 --- a/src/read/xcoff/symbol.rs +++ b/src/read/xcoff/symbol.rs @@ -366,16 +366,16 @@ impl<'data, 'file, Xcoff: FileHeader, R: ReadRef<'data>> ObjectSymbol<'data> /// Return true if the symbol is a definition of a function or data object. #[inline] fn is_definition(&self) -> bool { + if self.symbol.n_scnum() <= 0 { + return false; + } if self.symbol.has_aux_csect() { if let Ok(aux_csect) = self .symbols .aux_csect(self.index.0, self.symbol.n_numaux() as usize) { - let smclas = aux_csect.x_smclas(); - self.symbol.n_scnum() != xcoff::N_UNDEF - && (smclas == xcoff::XMC_PR - || smclas == xcoff::XMC_RW - || smclas == xcoff::XMC_RO) + let sym_type = aux_csect.sym_type(); + sym_type == xcoff::XTY_SD || sym_type == xcoff::XTY_LD || sym_type == xcoff::XTY_CM } else { false } From 4013d8cb37f3f68c6cdb836e4658c02c4bc3cdf0 Mon Sep 17 00:00:00 2001 From: Philip Craig Date: Mon, 4 Dec 2023 00:00:00 +0000 Subject: [PATCH 2/2] read: remove duplicate symbol addresses from Object::symbol_map --- .../testfiles/coff/import_msvc.lib.objdump | 3 - .../testfiles/elf/base-aarch64.objdump | 1 - crates/examples/testfiles/elf/base.objdump | 1 - .../macho/base-aarch64-debug.o.objdump | 2 - .../testfiles/macho/base-aarch64.o.objdump | 2 - .../testfiles/macho/reloc-aarch64.o.objdump | 1 - .../testfiles/macho/reloc-arm.o.objdump | 1 - .../testfiles/macho/reloc-i386.o.objdump | 1 - .../testfiles/pe/base-bigobj.obj.objdump | 4 - .../testfiles/pe/base-gnu.exe.objdump | 228 ------------------ crates/examples/testfiles/pe/base.obj.objdump | 4 - .../testfiles/wasm/global-wasm32.objdump | 4 - .../wasm/global-wasm64-import.objdump | 4 - .../testfiles/wasm/global-wasm64.objdump | 5 - .../examples/testfiles/xcoff/base.o.objdump | 2 - .../testfiles/xcoff/base.xcoff.objdump | 10 - .../examples/testfiles/xcoff/base32.o.objdump | 2 - .../testfiles/xcoff/base32.xcoff.objdump | 10 - src/read/mod.rs | 1 - src/read/traits.rs | 48 +++- 20 files changed, 46 insertions(+), 288 deletions(-) diff --git a/crates/examples/testfiles/coff/import_msvc.lib.objdump b/crates/examples/testfiles/coff/import_msvc.lib.objdump index b748956c..4a5d1a01 100644 --- a/crates/examples/testfiles/coff/import_msvc.lib.objdump +++ b/crates/examples/testfiles/coff/import_msvc.lib.objdump @@ -109,7 +109,6 @@ Dynamic symbols Symbol map 0x0 "__IMPORT_DESCRIPTOR_test_x64" -0x0 ".idata$6" test_x86.dll: Format: Short Import File @@ -196,7 +195,6 @@ Dynamic symbols Symbol map 0x0 "__IMPORT_DESCRIPTOR_test_x86" -0x0 ".idata$6" test_arm64ec.dll: Format: Short Import File @@ -283,4 +281,3 @@ Dynamic symbols Symbol map 0x0 "__IMPORT_DESCRIPTOR_test_arm64ec" -0x0 ".idata$6" diff --git a/crates/examples/testfiles/elf/base-aarch64.objdump b/crates/examples/testfiles/elf/base-aarch64.objdump index e50b6b8b..07fdc40d 100644 --- a/crates/examples/testfiles/elf/base-aarch64.objdump +++ b/crates/examples/testfiles/elf/base-aarch64.objdump @@ -179,5 +179,4 @@ Symbol map 0x10d80 "__frame_dummy_init_array_entry" 0x10d88 "__do_global_dtors_aux_fini_array_entry" 0x11008 "__dso_handle" -0x11010 "completed.8500" 0x11010 "__TMC_END__" diff --git a/crates/examples/testfiles/elf/base.objdump b/crates/examples/testfiles/elf/base.objdump index e7ee9a1d..33813335 100644 --- a/crates/examples/testfiles/elf/base.objdump +++ b/crates/examples/testfiles/elf/base.objdump @@ -149,5 +149,4 @@ Symbol map 0x200db8 "_DYNAMIC" 0x200fb8 "_GLOBAL_OFFSET_TABLE_" 0x201008 "__dso_handle" -0x201010 "completed.7698" 0x201010 "__TMC_END__" diff --git a/crates/examples/testfiles/macho/base-aarch64-debug.o.objdump b/crates/examples/testfiles/macho/base-aarch64-debug.o.objdump index e1c64c62..d8254061 100644 --- a/crates/examples/testfiles/macho/base-aarch64-debug.o.objdump +++ b/crates/examples/testfiles/macho/base-aarch64-debug.o.objdump @@ -47,8 +47,6 @@ Import { library: "", name: "_printf" } Export { name: "_main", address: 0 } Symbol map -0x0 "ltmp0" 0x0 "_main" -0x34 "l_.str" 0x34 "ltmp1" 0x268 "ltmp2" diff --git a/crates/examples/testfiles/macho/base-aarch64.o.objdump b/crates/examples/testfiles/macho/base-aarch64.o.objdump index c90914b7..4eb4826e 100644 --- a/crates/examples/testfiles/macho/base-aarch64.o.objdump +++ b/crates/examples/testfiles/macho/base-aarch64.o.objdump @@ -32,8 +32,6 @@ Import { library: "", name: "_printf" } Export { name: "_main", address: 0 } Symbol map -0x0 "ltmp0" 0x0 "_main" -0x34 "l_.str" 0x34 "ltmp1" 0x48 "ltmp2" diff --git a/crates/examples/testfiles/macho/reloc-aarch64.o.objdump b/crates/examples/testfiles/macho/reloc-aarch64.o.objdump index c1ab05e6..4552cc50 100644 --- a/crates/examples/testfiles/macho/reloc-aarch64.o.objdump +++ b/crates/examples/testfiles/macho/reloc-aarch64.o.objdump @@ -43,5 +43,4 @@ Import { library: "", name: "_g1" } Symbol map 0x0 "ltmp0" -0x28 "ltmp1" 0x28 "_data" diff --git a/crates/examples/testfiles/macho/reloc-arm.o.objdump b/crates/examples/testfiles/macho/reloc-arm.o.objdump index 9dd6ea49..61031c21 100644 --- a/crates/examples/testfiles/macho/reloc-arm.o.objdump +++ b/crates/examples/testfiles/macho/reloc-arm.o.objdump @@ -40,5 +40,4 @@ Export { name: "_g2", address: 14 } Symbol map 0x0 "_g1" -0x14 "_g3" 0x14 "_g2" diff --git a/crates/examples/testfiles/macho/reloc-i386.o.objdump b/crates/examples/testfiles/macho/reloc-i386.o.objdump index 7e8a7f79..ca5f017f 100644 --- a/crates/examples/testfiles/macho/reloc-i386.o.objdump +++ b/crates/examples/testfiles/macho/reloc-i386.o.objdump @@ -30,5 +30,4 @@ Export { name: "_g2", address: 10 } Symbol map 0x0 "_g1" -0x10 "_g3" 0x10 "_g2" diff --git a/crates/examples/testfiles/pe/base-bigobj.obj.objdump b/crates/examples/testfiles/pe/base-bigobj.obj.objdump index 7554d285..a7a7a9a1 100644 --- a/crates/examples/testfiles/pe/base-bigobj.obj.objdump +++ b/crates/examples/testfiles/pe/base-bigobj.obj.objdump @@ -62,8 +62,4 @@ Symbols Dynamic symbols Symbol map -0x0 "___local_stdio_printf_options" -0x0 "__vfprintf_l" -0x0 "_printf" 0x0 "_main" -0x0 "$SG9248" diff --git a/crates/examples/testfiles/pe/base-gnu.exe.objdump b/crates/examples/testfiles/pe/base-gnu.exe.objdump index a7630256..64416ded 100644 --- a/crates/examples/testfiles/pe/base-gnu.exe.objdump +++ b/crates/examples/testfiles/pe/base-gnu.exe.objdump @@ -1403,7 +1403,6 @@ Symbol map 0x1400016c0 "__dyn_tls_init" 0x140001750 "__tlregdtor" 0x140001760 "_matherr" -0x140001860 "_fpreset" 0x140001860 "fpreset" 0x140001870 "__report_error" 0x1400018e0 "mark_section_writable" @@ -1465,58 +1464,31 @@ Symbol map 0x140007340 "__strcp_D2A" 0x140007370 "strnlen" 0x1400073a0 "wcsnlen" -0x1400073d0 ".text" 0x1400073d0 "wcslen" -0x1400073d8 ".text" 0x1400073d8 "vfprintf" -0x1400073e0 ".text" 0x1400073e0 "strncmp" -0x1400073e8 ".text" 0x1400073e8 "strlen" -0x1400073f0 ".text" 0x1400073f0 "strerror" -0x1400073f8 ".text" 0x1400073f8 "signal" -0x140007400 ".text" 0x140007400 "memset" -0x140007408 ".text" 0x140007408 "memcpy" -0x140007410 ".text" 0x140007410 "malloc" -0x140007418 ".text" 0x140007418 "localeconv" -0x140007420 ".text" 0x140007420 "fwrite" -0x140007428 ".text" 0x140007428 "free" -0x140007430 ".text" 0x140007430 "fputc" -0x140007438 ".text" 0x140007438 "fprintf" -0x140007440 ".text" 0x140007440 "exit" -0x140007448 ".text" 0x140007448 "calloc" -0x140007450 ".text" 0x140007450 "abort" -0x140007458 ".text" 0x140007458 "_onexit" -0x140007460 ".text" 0x140007460 "_initterm" -0x140007468 ".text" 0x140007468 "_errno" -0x140007470 ".text" 0x140007470 "_cexit" -0x140007478 ".text" 0x140007478 "_amsg_exit" -0x140007480 ".text" 0x140007480 "__setusermatherr" -0x140007488 ".text" 0x140007488 "__set_app_type" -0x140007490 ".text" -0x140007490 ".text" 0x140007490 "__getmainargs" -0x140007498 ".text" 0x140007498 "__C_specific_handler" 0x1400074a0 "__mbrtowc_cp" 0x140007620 "mbrtowc" @@ -1526,62 +1498,35 @@ Symbol map 0x140007890 "wcrtomb" 0x1400078e0 "wcsrtombs" 0x1400079e0 "__acrt_iob_func" -0x140007a00 "mingw_get_invalid_parameter_handler" 0x140007a00 "_get_invalid_parameter_handler" -0x140007a10 "mingw_set_invalid_parameter_handler" 0x140007a10 "_set_invalid_parameter_handler" 0x140007a20 "_lock_file" 0x140007a90 "_unlock_file" 0x140007af0 "__p__acmdln" 0x140007b00 "__p__commode" 0x140007b10 "__p__fmode" -0x140007b20 ".text" 0x140007b20 "_unlock" -0x140007b28 ".text" 0x140007b28 "_lock" -0x140007b30 ".text" -0x140007b30 ".text" 0x140007b30 "__iob_func" -0x140007b38 ".text" 0x140007b38 "___mb_cur_max_func" -0x140007b40 ".text" 0x140007b40 "___lc_codepage_func" -0x140007b50 ".text" 0x140007b50 "WideCharToMultiByte" -0x140007b58 ".text" 0x140007b58 "VirtualQuery" -0x140007b60 ".text" 0x140007b60 "VirtualProtect" -0x140007b68 ".text" 0x140007b68 "TlsGetValue" -0x140007b70 ".text" 0x140007b70 "Sleep" -0x140007b78 ".text" 0x140007b78 "SetUnhandledExceptionFilter" -0x140007b80 ".text" 0x140007b80 "MultiByteToWideChar" -0x140007b88 ".text" 0x140007b88 "LeaveCriticalSection" -0x140007b90 ".text" 0x140007b90 "IsDBCSLeadByteEx" -0x140007b98 ".text" 0x140007b98 "InitializeCriticalSection" -0x140007ba0 ".text" 0x140007ba0 "GetStartupInfoA" -0x140007ba8 ".text" 0x140007ba8 "GetLastError" -0x140007bb0 ".text" 0x140007bb0 "EnterCriticalSection" -0x140007bb8 ".text" 0x140007bb8 "DeleteCriticalSection" -0x140007bc0 ".text" -0x140007bc0 ".text" 0x140007bc0 "register_frame_ctor" -0x140007bd0 "__CTOR_LIST__" 0x140007bd0 "___CTOR_LIST__" -0x140007be8 "___DTOR_LIST__" 0x140007be8 "__DTOR_LIST__" -0x140008000 "__data_start__" 0x140008000 "__mingw_winmain_nShowCmd" 0x140008010 "p.0" 0x140008020 "__native_vcclrit_reason" @@ -1591,33 +1536,6 @@ Symbol map 0x140008050 "_MINGW_INSTALL_DEBUG_MATHERR" 0x140008060 "fpi.0" 0x140008080 "pmem_next" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" -0x140008090 ".data" 0x140008090 "__imp___acrt_iob_func" 0x1400080a0 "__imp__get_invalid_parameter_handler" 0x1400080a8 "__imp__set_invalid_parameter_handler" @@ -1626,28 +1544,6 @@ Symbol map 0x1400080c0 "__imp___p__acmdln" 0x1400080d0 "__imp___p__commode" 0x1400080e0 "__imp___p__fmode" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" -0x1400080f0 ".data" 0x1400080f0 "__data_end__" 0x140009020 "__dyn_tls_init_callback" 0x140009040 "_tls_used" @@ -1684,13 +1580,7 @@ Symbol map 0x140009820 ".refptr._gnu_exception_handler" 0x140009830 ".refptr._matherr" 0x140009840 ".refptr._newmode" -0x14000a000 "___RUNTIME_PSEUDO_RELOC_LIST__" -0x14000a000 "__rt_psrelocs_start" -0x14000a000 "___RUNTIME_PSEUDO_RELOC_LIST_END__" -0x14000a000 "__RUNTIME_PSEUDO_RELOC_LIST__" -0x14000a000 "__rt_psrelocs_end" 0x14000a000 "__RUNTIME_PSEUDO_RELOC_LIST_END__" -0x14000c000 "__mingw_module_is_dll" 0x14000c000 "__bss_start__" 0x14000c008 "__mingw_winmain_lpCmdLine" 0x14000c010 "__mingw_winmain_hInstance" @@ -1725,65 +1615,14 @@ Symbol map 0x14000caa0 "freelist" 0x14000caf0 "dtoa_CS_init" 0x14000cb00 "dtoa_CritSec" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" -0x14000cb60 ".bss" 0x14000cb60 "s_mbstate.0" 0x14000cb64 "internal_mbstate.1" 0x14000cb68 "internal_mbstate.2" 0x14000cb70 "handler" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" -0x14000cb80 ".bss" 0x14000cb80 "__bss_end__" 0x14000d000 "_head_lib64_libkernel32_a" 0x14000d014 "_head_lib64_libmsvcrt_os_a" 0x14000d03c ".idata$4" -0x14000d03c "hname" -0x14000d03c ".idata$4" 0x14000d044 ".idata$4" 0x14000d04c ".idata$4" 0x14000d054 ".idata$4" @@ -1798,8 +1637,6 @@ Symbol map 0x14000d09c ".idata$4" 0x14000d0a4 ".idata$4" 0x14000d0b4 ".idata$4" -0x14000d0b4 "hname" -0x14000d0b4 ".idata$4" 0x14000d0bc ".idata$4" 0x14000d0c4 ".idata$4" 0x14000d0cc ".idata$4" @@ -1834,110 +1671,55 @@ Symbol map 0x14000d1b4 ".idata$4" 0x14000d1bc ".idata$4" 0x14000d1c4 ".idata$4" -0x14000d1d4 ".idata$5" -0x14000d1d4 "fthunk" -0x14000d1d4 ".idata$5" -0x14000d1d4 "__imp_DeleteCriticalSection" 0x14000d1d4 "__IAT_start__" -0x14000d1dc ".idata$5" 0x14000d1dc "__imp_EnterCriticalSection" -0x14000d1e4 ".idata$5" 0x14000d1e4 "__imp_GetLastError" -0x14000d1ec ".idata$5" 0x14000d1ec "__imp_GetStartupInfoA" -0x14000d1f4 ".idata$5" 0x14000d1f4 "__imp_InitializeCriticalSection" -0x14000d1fc ".idata$5" 0x14000d1fc "__imp_IsDBCSLeadByteEx" -0x14000d204 ".idata$5" 0x14000d204 "__imp_LeaveCriticalSection" -0x14000d20c ".idata$5" 0x14000d20c "__imp_MultiByteToWideChar" -0x14000d214 ".idata$5" 0x14000d214 "__imp_SetUnhandledExceptionFilter" -0x14000d21c ".idata$5" 0x14000d21c "__imp_Sleep" -0x14000d224 ".idata$5" 0x14000d224 "__imp_TlsGetValue" -0x14000d22c ".idata$5" 0x14000d22c "__imp_VirtualProtect" -0x14000d234 ".idata$5" 0x14000d234 "__imp_VirtualQuery" -0x14000d23c ".idata$5" 0x14000d23c "__imp_WideCharToMultiByte" -0x14000d24c ".idata$5" -0x14000d24c "fthunk" -0x14000d24c ".idata$5" 0x14000d24c "__imp___C_specific_handler" -0x14000d254 ".idata$5" 0x14000d254 "__imp____lc_codepage_func" -0x14000d25c ".idata$5" 0x14000d25c "__imp____mb_cur_max_func" -0x14000d264 ".idata$5" 0x14000d264 "__imp___getmainargs" -0x14000d26c ".idata$5" 0x14000d26c "__imp___initenv" -0x14000d274 ".idata$5" 0x14000d274 "__imp___iob_func" -0x14000d27c ".idata$5" 0x14000d27c "__imp___set_app_type" -0x14000d284 ".idata$5" 0x14000d284 "__imp___setusermatherr" -0x14000d28c ".idata$5" 0x14000d28c "__imp__acmdln" -0x14000d294 ".idata$5" 0x14000d294 "__imp__amsg_exit" -0x14000d29c ".idata$5" 0x14000d29c "__imp__cexit" -0x14000d2a4 ".idata$5" 0x14000d2a4 "__imp__commode" -0x14000d2ac ".idata$5" 0x14000d2ac "__imp__errno" -0x14000d2b4 ".idata$5" 0x14000d2b4 "__imp__fmode" -0x14000d2bc ".idata$5" 0x14000d2bc "__imp__initterm" -0x14000d2c4 ".idata$5" 0x14000d2c4 "__imp__lock" -0x14000d2cc ".idata$5" 0x14000d2cc "__imp__onexit" -0x14000d2d4 ".idata$5" 0x14000d2d4 "__imp__unlock" -0x14000d2dc ".idata$5" 0x14000d2dc "__imp_abort" -0x14000d2e4 ".idata$5" 0x14000d2e4 "__imp_calloc" -0x14000d2ec ".idata$5" 0x14000d2ec "__imp_exit" -0x14000d2f4 ".idata$5" 0x14000d2f4 "__imp_fprintf" -0x14000d2fc ".idata$5" 0x14000d2fc "__imp_fputc" -0x14000d304 ".idata$5" 0x14000d304 "__imp_free" -0x14000d30c ".idata$5" 0x14000d30c "__imp_fwrite" -0x14000d314 ".idata$5" 0x14000d314 "__imp_localeconv" -0x14000d31c ".idata$5" 0x14000d31c "__imp_malloc" -0x14000d324 ".idata$5" 0x14000d324 "__imp_memcpy" -0x14000d32c ".idata$5" 0x14000d32c "__imp_memset" -0x14000d334 ".idata$5" 0x14000d334 "__imp_signal" -0x14000d33c ".idata$5" 0x14000d33c "__imp_strerror" -0x14000d344 ".idata$5" 0x14000d344 "__imp_strlen" -0x14000d34c ".idata$5" 0x14000d34c "__imp_strncmp" -0x14000d354 ".idata$5" 0x14000d354 "__imp_vfprintf" -0x14000d35c ".idata$5" 0x14000d35c "__imp_wcslen" -0x14000d36c ".idata$6" 0x14000d36c "__IAT_end__" 0x14000d384 ".idata$6" 0x14000d39c ".idata$6" @@ -2038,28 +1820,18 @@ Symbol map 0x14000d6fc ".idata$7" 0x14000d700 ".idata$7" 0x14000d704 "__lib64_libmsvcrt_os_a_iname" -0x14000e000 "___crt_xc_start__" 0x14000e000 "__xc_a" 0x14000e008 "__mingw_pcppinit" 0x14000e010 "__xc_z" -0x14000e018 "___crt_xi_start__" -0x14000e018 "___crt_xc_end__" 0x14000e018 "__xi_a" 0x14000e020 "__mingw_pcinit" 0x14000e028 "__xi_z" -0x14000e030 "__xl_a" -0x14000e030 "___crt_xl_start__" 0x14000e030 "___crt_xi_end__" 0x14000e038 "__xl_c" 0x14000e040 "__xl_d" 0x14000e048 "__xl_z" -0x14000e050 "__xd_a" -0x14000e050 "___crt_xp_start__" -0x14000e050 "___crt_xp_end__" -0x14000e050 "___crt_xt_start__" 0x14000e050 "___crt_xt_end__" 0x14000e058 "__xd_z" -0x14000f000 "___tls_start__" 0x14000f000 "_tls_start" 0x14000f008 "_tls_end" 0x14000f010 "___tls_end__" diff --git a/crates/examples/testfiles/pe/base.obj.objdump b/crates/examples/testfiles/pe/base.obj.objdump index 7554d285..a7a7a9a1 100644 --- a/crates/examples/testfiles/pe/base.obj.objdump +++ b/crates/examples/testfiles/pe/base.obj.objdump @@ -62,8 +62,4 @@ Symbols Dynamic symbols Symbol map -0x0 "___local_stdio_printf_options" -0x0 "__vfprintf_l" -0x0 "_printf" 0x0 "_main" -0x0 "$SG9248" diff --git a/crates/examples/testfiles/wasm/global-wasm32.objdump b/crates/examples/testfiles/wasm/global-wasm32.objdump index b7c8fbef..30468de5 100644 --- a/crates/examples/testfiles/wasm/global-wasm32.objdump +++ b/crates/examples/testfiles/wasm/global-wasm32.objdump @@ -38,17 +38,13 @@ Symbols Dynamic symbols Symbol map -0x0 "memory" 0x0 "__memory_base" 0x1 "__table_base" 0x2 "__wasm_call_ctors" 0x5 "print" -0x400 "global1" -0x400 "__dso_handle" 0x400 "__global_base" 0x404 "global2" 0x408 "__data_end" 0x410 "__stack_low" -0x10410 "__stack_high" 0x10410 "__heap_base" 0x20000 "__heap_end" diff --git a/crates/examples/testfiles/wasm/global-wasm64-import.objdump b/crates/examples/testfiles/wasm/global-wasm64-import.objdump index 1220a858..e718359d 100644 --- a/crates/examples/testfiles/wasm/global-wasm64-import.objdump +++ b/crates/examples/testfiles/wasm/global-wasm64-import.objdump @@ -39,16 +39,12 @@ Dynamic symbols Symbol map 0x0 "__memory_base" -0x1 "__table_base" 0x1 "__table_base32" 0x2 "__wasm_call_ctors" 0x5 "print" -0x400 "global1" -0x400 "__dso_handle" 0x400 "__global_base" 0x404 "global2" 0x408 "__data_end" 0x410 "__stack_low" -0x10410 "__stack_high" 0x10410 "__heap_base" 0x20000 "__heap_end" diff --git a/crates/examples/testfiles/wasm/global-wasm64.objdump b/crates/examples/testfiles/wasm/global-wasm64.objdump index fd42876c..d446e2e7 100644 --- a/crates/examples/testfiles/wasm/global-wasm64.objdump +++ b/crates/examples/testfiles/wasm/global-wasm64.objdump @@ -39,18 +39,13 @@ Symbols Dynamic symbols Symbol map -0x0 "memory" 0x0 "__memory_base" -0x1 "__table_base" 0x1 "__table_base32" 0x2 "__wasm_call_ctors" 0x5 "print" -0x400 "global1" -0x400 "__dso_handle" 0x400 "__global_base" 0x404 "global2" 0x408 "__data_end" 0x410 "__stack_low" -0x10410 "__stack_high" 0x10410 "__heap_base" 0x20000 "__heap_end" diff --git a/crates/examples/testfiles/xcoff/base.o.objdump b/crates/examples/testfiles/xcoff/base.o.objdump index 93076b0c..d02df3ab 100644 --- a/crates/examples/testfiles/xcoff/base.o.objdump +++ b/crates/examples/testfiles/xcoff/base.o.objdump @@ -30,9 +30,7 @@ Symbols Dynamic symbols Symbol map -0x0 ".text" 0x0 ".main" 0x58 ".rodata.str1.1L...str" 0x68 "main" -0x80 "TOC" 0x80 ".rodata.str1.1L...str" diff --git a/crates/examples/testfiles/xcoff/base.xcoff.objdump b/crates/examples/testfiles/xcoff/base.xcoff.objdump index 115f1006..b513b60a 100644 --- a/crates/examples/testfiles/xcoff/base.xcoff.objdump +++ b/crates/examples/testfiles/xcoff/base.xcoff.objdump @@ -166,27 +166,18 @@ Dynamic symbols Symbol map 0x1000001f8 ".__start" -0x1000001f8 ".__start" -0x1000002c0 "" 0x1000002c0 ".__threads_init" 0x100000300 ".__threads_init@AF2_1" -0x100000420 "" 0x100000420 ".__User_sinit_begin" 0x100000448 ".__C_runtime_termination" 0x100000498 ".__C_runtime_startup" 0x100000520 ".__dftdt__L304e50f8c42_5CatchFv" 0x100000598 ".__run_final_dtors" -0x100000598 ".__run_final_dtors" -0x1000005c0 ".atexit" 0x1000005c0 ".atexit" 0x1000005e8 ".__run_initial_ctors" -0x1000005e8 ".__run_initial_ctors" -0x100000610 ".exit" 0x100000610 ".exit" -0x100000640 ".text" 0x100000640 ".main" 0x100000698 ".printf" -0x100000698 ".printf" 0x1000006c0 ".rodata.str1.1L...str" 0x1100006d0 "crt0_data" 0x110000738 "_$STATIC" @@ -198,7 +189,6 @@ Symbol map 0x110000870 "__C_runtime_startup" 0x110000888 "__dftdt__L304e50f8c42_5CatchFv" 0x1100008a0 "__C_runtime_termination" -0x1100008b8 "TOC" 0x1100008b8 "_malloc_user_defined_name" 0x1100008c0 "p_xargc" 0x1100008c8 "__pth_init_routine" diff --git a/crates/examples/testfiles/xcoff/base32.o.objdump b/crates/examples/testfiles/xcoff/base32.o.objdump index bc571236..052e4d2c 100644 --- a/crates/examples/testfiles/xcoff/base32.o.objdump +++ b/crates/examples/testfiles/xcoff/base32.o.objdump @@ -30,9 +30,7 @@ Symbols Dynamic symbols Symbol map -0x0 ".text" 0x0 ".main" 0x5c ".rodata.str1.1L...str" 0x6c "main" -0x78 "TOC" 0x78 ".rodata.str1.1L...str" diff --git a/crates/examples/testfiles/xcoff/base32.xcoff.objdump b/crates/examples/testfiles/xcoff/base32.xcoff.objdump index 73eed8ef..ee1c9fa0 100644 --- a/crates/examples/testfiles/xcoff/base32.xcoff.objdump +++ b/crates/examples/testfiles/xcoff/base32.xcoff.objdump @@ -160,27 +160,18 @@ Dynamic symbols Symbol map 0x10000128 ".__start" -0x10000128 ".__start" -0x100001e0 "" 0x100001e0 ".__threads_init" 0x10000220 ".__threads_init@AF2_1" -0x10000340 "" 0x10000340 ".__User_sinit_begin" 0x10000368 ".__C_runtime_termination" 0x100003b8 ".__C_runtime_startup" 0x10000440 ".__dftdt__L304e4b28c42_5CatchFv" 0x100004b8 ".__run_final_dtors" -0x100004b8 ".__run_final_dtors" -0x100004e0 ".atexit" 0x100004e0 ".atexit" 0x10000508 ".__run_initial_ctors" -0x10000508 ".__run_initial_ctors" -0x10000530 ".exit" 0x10000530 ".exit" -0x10000560 ".text" 0x10000560 ".main" 0x100005bc ".printf" -0x100005bc ".printf" 0x100005e4 ".rodata.str1.1L...str" 0x200005f4 "crt0_data" 0x20000620 "_$STATIC" @@ -192,7 +183,6 @@ Symbol map 0x20000724 "__C_runtime_startup" 0x20000730 "__dftdt__L304e4b28c42_5CatchFv" 0x2000073c "__C_runtime_termination" -0x20000748 "TOC" 0x20000748 "_malloc_user_defined_name" 0x2000074c "p_xargc" 0x20000750 "__pth_init_routine" diff --git a/src/read/mod.rs b/src/read/mod.rs index b5a9dd4c..cd887af1 100644 --- a/src/read/mod.rs +++ b/src/read/mod.rs @@ -349,7 +349,6 @@ impl SymbolMap { /// /// This function will sort the symbols by address. pub fn new(mut symbols: Vec) -> Self { - // TODO: deterministically remove duplicates symbols.sort_by_key(|s| s.address()); SymbolMap { symbols } } diff --git a/src/read/traits.rs b/src/read/traits.rs index 0f533e8e..36ab3e31 100644 --- a/src/read/traits.rs +++ b/src/read/traits.rs @@ -164,12 +164,56 @@ pub trait Object<'data: 'file, 'file>: read::private::Sealed { fn symbol_map(&'file self) -> SymbolMap> { let mut symbols = Vec::new(); if let Some(table) = self.symbol_table().or_else(|| self.dynamic_symbol_table()) { + // Sometimes symbols share addresses. Collect them all then choose the "best". + let mut all_symbols = Vec::new(); for symbol in table.symbols() { + // Must have an address. if !symbol.is_definition() { continue; } - if let Ok(name) = symbol.name() { - symbols.push(SymbolMapName::new(symbol.address(), name)); + // Must have a name. + let name = match symbol.name() { + Ok(name) => name, + _ => continue, + }; + if name.is_empty() { + continue; + } + + // Lower is better. + let mut priority = 0u32; + + // Prefer known kind. + match symbol.kind() { + SymbolKind::Text | SymbolKind::Data => {} + SymbolKind::Unknown => priority += 1, + _ => continue, + } + priority *= 2; + + // Prefer global visibility. + priority += match symbol.scope() { + SymbolScope::Unknown => 3, + SymbolScope::Compilation => 2, + SymbolScope::Linkage => 1, + SymbolScope::Dynamic => 0, + }; + priority *= 4; + + // Prefer later entries (earlier symbol is likely to be less specific). + let index = !0 - symbol.index().0; + + // Tuple is ordered for sort. + all_symbols.push((symbol.address(), priority, index, name)); + } + // Unstable sort is okay because tuple includes index. + all_symbols.sort_unstable(); + + let mut previous_address = !0; + for (address, _priority, _index, name) in all_symbols { + if address != previous_address { + symbols.push(SymbolMapName::new(address, name)); + previous_address = address; } } }