diff --git a/crates/examples/testfiles/elf/base-aarch64.o.objdump b/crates/examples/testfiles/elf/base-aarch64.o.objdump index 38dcc3f3..06837952 100644 --- a/crates/examples/testfiles/elf/base-aarch64.o.objdump +++ b/crates/examples/testfiles/elf/base-aarch64.o.objdump @@ -40,6 +40,4 @@ Dynamic symbols Dynamic relocations Symbol map -0x0 "$d" -0x0 "$x" 0x0 "main" diff --git a/crates/examples/testfiles/elf/base-aarch64.objdump b/crates/examples/testfiles/elf/base-aarch64.objdump index 26f6b8ba..d5735acb 100644 --- a/crates/examples/testfiles/elf/base-aarch64.objdump +++ b/crates/examples/testfiles/elf/base-aarch64.objdump @@ -163,52 +163,23 @@ Import { library: "", name: "_ITM_registerTMCloneTable" } Import { library: "", name: "printf" } Symbol map -0x21c "$d" -0x598 "$x" 0x598 "_init" -0x5a4 "$x" -0x5b0 "$x" -0x620 "$x" 0x620 "_start" -0x658 "$x" 0x658 "call_weak_fn" -0x670 "$x" 0x670 "deregister_tm_clones" 0x6a0 "register_tm_clones" 0x6d8 "__do_global_dtors_aux" 0x720 "frame_dummy" -0x724 "$x" 0x724 "main" -0x748 "$x" 0x748 "__libc_csu_init" 0x7c8 "__libc_csu_fini" -0x7cc "$x" 0x7cc "_fini" -0x7d4 "$x" -0x7e0 "$d" 0x7e0 "_IO_stdin_used" -0x7e8 "$d" -0x7f8 "$d" 0x7f8 "__FRAME_END__" -0x10d80 "$d" 0x10d80 "__frame_dummy_init_array_entry" -0x10d80 "__init_array_start" -0x10d88 "$d" 0x10d88 "__do_global_dtors_aux_fini_array_entry" -0x10d88 "__init_array_end" 0x10d90 "_DYNAMIC" 0x10fc0 "_GLOBAL_OFFSET_TABLE_" -0x11000 "data_start" -0x11000 "__data_start" -0x11008 "$d" 0x11008 "__dso_handle" 0x11010 "completed.8500" -0x11010 "$d" -0x11010 "__bss_start__" -0x11010 "_edata" -0x11010 "__bss_start" 0x11010 "__TMC_END__" -0x11018 "_bss_end__" -0x11018 "__bss_end__" -0x11018 "_end" -0x11018 "__end__" diff --git a/crates/examples/testfiles/elf/base.objdump b/crates/examples/testfiles/elf/base.objdump index 3b450171..885e1e22 100644 --- a/crates/examples/testfiles/elf/base.objdump +++ b/crates/examples/testfiles/elf/base.objdump @@ -143,19 +143,11 @@ Symbol map 0x710 "__libc_csu_fini" 0x714 "_fini" 0x720 "_IO_stdin_used" -0x734 "__GNU_EH_FRAME_HDR" 0x874 "__FRAME_END__" 0x200da8 "__frame_dummy_init_array_entry" -0x200da8 "__init_array_start" 0x200db0 "__do_global_dtors_aux_fini_array_entry" -0x200db0 "__init_array_end" 0x200db8 "_DYNAMIC" 0x200fb8 "_GLOBAL_OFFSET_TABLE_" -0x201000 "data_start" -0x201000 "__data_start" 0x201008 "__dso_handle" 0x201010 "completed.7698" -0x201010 "_edata" -0x201010 "__bss_start" 0x201010 "__TMC_END__" -0x201018 "_end" diff --git a/src/read/elf/symbol.rs b/src/read/elf/symbol.rs index ee5aa37f..4f3826ac 100644 --- a/src/read/elf/symbol.rs +++ b/src/read/elf/symbol.rs @@ -354,7 +354,8 @@ impl<'data, 'file, Elf: FileHeader, R: ReadRef<'data>> ObjectSymbol<'data> fn kind(&self) -> SymbolKind { match self.symbol.st_type() { elf::STT_NOTYPE if self.index.0 == 0 => SymbolKind::Null, - elf::STT_NOTYPE => SymbolKind::Label, + elf::STT_NOTYPE if self.size() == 0 => SymbolKind::Label, + elf::STT_NOTYPE => SymbolKind::Unknown, elf::STT_OBJECT | elf::STT_COMMON => SymbolKind::Data, elf::STT_FUNC | elf::STT_GNU_IFUNC => SymbolKind::Text, elf::STT_SECTION => SymbolKind::Section, @@ -478,9 +479,14 @@ 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 { - let st_type = self.st_type(); - (st_type == elf::STT_NOTYPE || st_type == elf::STT_FUNC || st_type == elf::STT_OBJECT) - && self.st_shndx(endian) != elf::SHN_UNDEF + if self.st_shndx(endian) == elf::SHN_UNDEF { + return false; + } + match self.st_type() { + elf::STT_NOTYPE => self.st_size(endian).into() != 0, + elf::STT_FUNC | elf::STT_OBJECT => true, + _ => false, + } } }