From 0a0d21d2cfc067a89f158f5ca1e60249a99778bd Mon Sep 17 00:00:00 2001 From: Philip Craig Date: Mon, 4 Dec 2023 15:20:52 +1000 Subject: [PATCH] read/elf: set STT_NOTYPE symbol kind to Unknown (#604) STT_NOTYPE is not always a label. --- .../testfiles/elf/base-aarch64.o.objdump | 6 +- .../testfiles/elf/base-aarch64.objdump | 70 +++++++++---------- crates/examples/testfiles/elf/base.o.objdump | 4 +- crates/examples/testfiles/elf/base.objdump | 28 ++++---- src/read/elf/symbol.rs | 2 +- 5 files changed, 55 insertions(+), 55 deletions(-) diff --git a/crates/examples/testfiles/elf/base-aarch64.o.objdump b/crates/examples/testfiles/elf/base-aarch64.o.objdump index 06837952..7e104ab9 100644 --- a/crates/examples/testfiles/elf/base-aarch64.o.objdump +++ b/crates/examples/testfiles/elf/base-aarch64.o.objdump @@ -23,12 +23,12 @@ Symbols 3: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(3)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } 4: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(4)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } 5: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(5)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -6: Symbol { name: "$d", address: 0, size: 0, kind: Label, section: Section(SectionIndex(5)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -7: Symbol { name: "$x", address: 0, size: 0, kind: Label, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +6: Symbol { name: "$d", address: 0, size: 0, kind: Unknown, section: Section(SectionIndex(5)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +7: Symbol { name: "$x", address: 0, size: 0, kind: Unknown, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 8: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(7)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } 9: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(6)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } 10: Symbol { name: "main", address: 0, size: 20, kind: Text, section: Section(SectionIndex(1)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -11: Symbol { name: "printf", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +11: Symbol { name: "printf", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 10, st_other: 0 } } .text relocations (8, Relocation { kind: Elf(113), encoding: Generic, size: 0, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: false }) diff --git a/crates/examples/testfiles/elf/base-aarch64.objdump b/crates/examples/testfiles/elf/base-aarch64.objdump index d5735acb..080e53be 100644 --- a/crates/examples/testfiles/elf/base-aarch64.objdump +++ b/crates/examples/testfiles/elf/base-aarch64.objdump @@ -61,67 +61,67 @@ Symbols 22: Symbol { name: "", address: 11010, size: 0, kind: Section, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } 23: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(17)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } 24: Symbol { name: "/usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/lib/../lib/Scrt1.o", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -25: Symbol { name: "$d", address: 21c, size: 0, kind: Label, section: Section(SectionIndex(2)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -26: Symbol { name: "$x", address: 620, size: 0, kind: Label, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -27: Symbol { name: "$d", address: 7e0, size: 0, kind: Label, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +25: Symbol { name: "$d", address: 21c, size: 0, kind: Unknown, section: Section(SectionIndex(2)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +26: Symbol { name: "$x", address: 620, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +27: Symbol { name: "$d", address: 7e0, size: 0, kind: Unknown, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 28: Symbol { name: "/usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/lib/../lib/crti.o", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -29: Symbol { name: "$x", address: 658, size: 0, kind: Label, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +29: Symbol { name: "$x", address: 658, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 30: Symbol { name: "call_weak_fn", address: 658, size: 14, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -31: Symbol { name: "$x", address: 598, size: 0, kind: Label, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -32: Symbol { name: "$x", address: 7cc, size: 0, kind: Label, section: Section(SectionIndex(e)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +31: Symbol { name: "$x", address: 598, size: 0, kind: Unknown, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +32: Symbol { name: "$x", address: 7cc, size: 0, kind: Unknown, section: Section(SectionIndex(e)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 33: Symbol { name: "/usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/lib/../lib/crtn.o", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -34: Symbol { name: "$x", address: 5a4, size: 0, kind: Label, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -35: Symbol { name: "$x", address: 7d4, size: 0, kind: Label, section: Section(SectionIndex(e)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +34: Symbol { name: "$x", address: 5a4, size: 0, kind: Unknown, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +35: Symbol { name: "$x", address: 7d4, size: 0, kind: Unknown, section: Section(SectionIndex(e)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 36: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -37: Symbol { name: "$x", address: 670, size: 0, kind: Label, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +37: Symbol { name: "$x", address: 670, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 38: Symbol { name: "deregister_tm_clones", address: 670, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } 39: Symbol { name: "register_tm_clones", address: 6a0, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -40: Symbol { name: "$d", address: 11008, size: 0, kind: Label, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +40: Symbol { name: "$d", address: 11008, size: 0, kind: Unknown, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 41: Symbol { name: "__do_global_dtors_aux", address: 6d8, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } 42: Symbol { name: "completed.8500", address: 11010, size: 1, kind: Data, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -43: Symbol { name: "$d", address: 10d88, size: 0, kind: Label, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +43: Symbol { name: "$d", address: 10d88, size: 0, kind: Unknown, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 44: Symbol { name: "__do_global_dtors_aux_fini_array_entry", address: 10d88, size: 0, kind: Data, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } 45: Symbol { name: "frame_dummy", address: 720, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -46: Symbol { name: "$d", address: 10d80, size: 0, kind: Label, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +46: Symbol { name: "$d", address: 10d80, size: 0, kind: Unknown, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 47: Symbol { name: "__frame_dummy_init_array_entry", address: 10d80, size: 0, kind: Data, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -48: Symbol { name: "$d", address: 11010, size: 0, kind: Label, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +48: Symbol { name: "$d", address: 11010, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 49: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -50: Symbol { name: "$d", address: 7e8, size: 0, kind: Label, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -51: Symbol { name: "$x", address: 724, size: 0, kind: Label, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +50: Symbol { name: "$d", address: 7e8, size: 0, kind: Unknown, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +51: Symbol { name: "$x", address: 724, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 52: Symbol { name: "elf-init.oS", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -53: Symbol { name: "$x", address: 748, size: 0, kind: Label, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +53: Symbol { name: "$x", address: 748, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 54: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -55: Symbol { name: "$d", address: 7f8, size: 0, kind: Label, section: Section(SectionIndex(10)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +55: Symbol { name: "$d", address: 7f8, size: 0, kind: Unknown, section: Section(SectionIndex(10)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 56: Symbol { name: "__FRAME_END__", address: 7f8, size: 0, kind: Data, section: Section(SectionIndex(10)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } 57: Symbol { name: "", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -58: Symbol { name: "__init_array_end", address: 10d88, size: 0, kind: Label, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +58: Symbol { name: "__init_array_end", address: 10d88, size: 0, kind: Unknown, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 59: Symbol { name: "_DYNAMIC", address: 10d90, size: 0, kind: Data, section: Absolute, scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -60: Symbol { name: "__init_array_start", address: 10d80, size: 0, kind: Label, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +60: Symbol { name: "__init_array_start", address: 10d80, size: 0, kind: Unknown, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 61: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 10fc0, size: 0, kind: Data, section: Absolute, scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -62: Symbol { name: "$x", address: 5b0, size: 0, kind: Label, section: Section(SectionIndex(c)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +62: Symbol { name: "$x", address: 5b0, size: 0, kind: Unknown, section: Section(SectionIndex(c)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 63: Symbol { name: "__libc_csu_fini", address: 7c8, size: 4, kind: Text, section: Section(SectionIndex(d)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -64: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -65: Symbol { name: "data_start", address: 11000, size: 0, kind: Label, section: Section(SectionIndex(15)), scope: Dynamic, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -66: Symbol { name: "__bss_start__", address: 11010, size: 0, kind: Label, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +64: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +65: Symbol { name: "data_start", address: 11000, size: 0, kind: Unknown, section: Section(SectionIndex(15)), scope: Dynamic, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +66: Symbol { name: "__bss_start__", address: 11010, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } 67: Symbol { name: "__cxa_finalize@@GLIBC_2.17", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 22, st_other: 0 } } -68: Symbol { name: "_bss_end__", address: 11018, size: 0, kind: Label, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -69: Symbol { name: "_edata", address: 11010, size: 0, kind: Label, section: Section(SectionIndex(15)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +68: Symbol { name: "_bss_end__", address: 11018, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +69: Symbol { name: "_edata", address: 11010, size: 0, kind: Unknown, section: Section(SectionIndex(15)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } 70: Symbol { name: "_fini", address: 7cc, size: 0, kind: Text, section: Section(SectionIndex(e)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -71: Symbol { name: "__bss_end__", address: 11018, size: 0, kind: Label, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +71: Symbol { name: "__bss_end__", address: 11018, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } 72: Symbol { name: "__libc_start_main@@GLIBC_2.17", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -73: Symbol { name: "__data_start", address: 11000, size: 0, kind: Label, section: Section(SectionIndex(15)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -74: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +73: Symbol { name: "__data_start", address: 11000, size: 0, kind: Unknown, section: Section(SectionIndex(15)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +74: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } 75: Symbol { name: "__dso_handle", address: 11008, size: 0, kind: Data, section: Section(SectionIndex(15)), scope: Linkage, weak: false, flags: Elf { st_info: 11, st_other: 2 } } 76: Symbol { name: "abort@@GLIBC_2.17", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } 77: Symbol { name: "_IO_stdin_used", address: 7e0, size: 4, kind: Data, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: 11, st_other: 0 } } 78: Symbol { name: "__libc_csu_init", address: 748, size: 80, kind: Text, section: Section(SectionIndex(d)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -79: Symbol { name: "_end", address: 11018, size: 0, kind: Label, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +79: Symbol { name: "_end", address: 11018, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } 80: Symbol { name: "_start", address: 620, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -81: Symbol { name: "__end__", address: 11018, size: 0, kind: Label, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -82: Symbol { name: "__bss_start", address: 11010, size: 0, kind: Label, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +81: Symbol { name: "__end__", address: 11018, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +82: Symbol { name: "__bss_start", address: 11010, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } 83: Symbol { name: "main", address: 724, size: 20, kind: Text, section: Section(SectionIndex(d)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } 84: Symbol { name: "__TMC_END__", address: 11010, size: 0, kind: Data, section: Section(SectionIndex(15)), scope: Linkage, weak: false, flags: Elf { st_info: 11, st_other: 2 } } -85: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +85: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } 86: Symbol { name: "printf@@GLIBC_2.17", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } 87: Symbol { name: "_init", address: 598, size: 0, kind: Text, section: Section(SectionIndex(b)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } @@ -129,12 +129,12 @@ Dynamic symbols 0: Symbol { name: "", address: 0, size: 0, kind: Null, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 1: Symbol { name: "", address: 598, size: 0, kind: Section, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } 2: Symbol { name: "", address: 11000, size: 0, kind: Section, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -3: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +3: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } 4: Symbol { name: "__cxa_finalize", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 22, st_other: 0 } } 5: Symbol { name: "__libc_start_main", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -6: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +6: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } 7: Symbol { name: "abort", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -8: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +8: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } 9: Symbol { name: "printf", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } Dynamic relocations diff --git a/crates/examples/testfiles/elf/base.o.objdump b/crates/examples/testfiles/elf/base.o.objdump index 5bff4195..903973d2 100644 --- a/crates/examples/testfiles/elf/base.o.objdump +++ b/crates/examples/testfiles/elf/base.o.objdump @@ -29,8 +29,8 @@ Symbols 7: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(8)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } 8: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(6)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } 9: Symbol { name: "main", address: 0, size: 1c, kind: Text, section: Section(SectionIndex(1)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -10: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -11: Symbol { name: "printf", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +10: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +11: Symbol { name: "printf", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 10, st_other: 0 } } .text relocations (7, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: fffffffffffffffc, implicit_addend: false }) diff --git a/crates/examples/testfiles/elf/base.objdump b/crates/examples/testfiles/elf/base.objdump index 885e1e22..e7ee9a1d 100644 --- a/crates/examples/testfiles/elf/base.objdump +++ b/crates/examples/testfiles/elf/base.objdump @@ -78,39 +78,39 @@ Symbols 36: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } 37: Symbol { name: "__FRAME_END__", address: 874, size: 0, kind: Data, section: Section(SectionIndex(13)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } 38: Symbol { name: "", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -39: Symbol { name: "__init_array_end", address: 200db0, size: 0, kind: Label, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +39: Symbol { name: "__init_array_end", address: 200db0, size: 0, kind: Unknown, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 40: Symbol { name: "_DYNAMIC", address: 200db8, size: 0, kind: Data, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -41: Symbol { name: "__init_array_start", address: 200da8, size: 0, kind: Label, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -42: Symbol { name: "__GNU_EH_FRAME_HDR", address: 734, size: 0, kind: Label, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +41: Symbol { name: "__init_array_start", address: 200da8, size: 0, kind: Unknown, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } +42: Symbol { name: "__GNU_EH_FRAME_HDR", address: 734, size: 0, kind: Unknown, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } 43: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 200fb8, size: 0, kind: Data, section: Section(SectionIndex(17)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } 44: Symbol { name: "__libc_csu_fini", address: 710, size: 2, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -45: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -46: Symbol { name: "data_start", address: 201000, size: 0, kind: Label, section: Section(SectionIndex(18)), scope: Dynamic, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -47: Symbol { name: "_edata", address: 201010, size: 0, kind: Label, section: Section(SectionIndex(18)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +45: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +46: Symbol { name: "data_start", address: 201000, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +47: Symbol { name: "_edata", address: 201010, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } 48: Symbol { name: "_fini", address: 714, size: 0, kind: Text, section: Section(SectionIndex(10)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } 49: Symbol { name: "printf@@GLIBC_2.2.5", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } 50: Symbol { name: "__libc_start_main@@GLIBC_2.2.5", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -51: Symbol { name: "__data_start", address: 201000, size: 0, kind: Label, section: Section(SectionIndex(18)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -52: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +51: Symbol { name: "__data_start", address: 201000, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +52: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } 53: Symbol { name: "__dso_handle", address: 201008, size: 0, kind: Data, section: Section(SectionIndex(18)), scope: Linkage, weak: false, flags: Elf { st_info: 11, st_other: 2 } } 54: Symbol { name: "_IO_stdin_used", address: 720, size: 4, kind: Data, section: Section(SectionIndex(11)), scope: Dynamic, weak: false, flags: Elf { st_info: 11, st_other: 0 } } 55: Symbol { name: "__libc_csu_init", address: 6a0, size: 65, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -56: Symbol { name: "_end", address: 201018, size: 0, kind: Label, section: Section(SectionIndex(19)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +56: Symbol { name: "_end", address: 201018, size: 0, kind: Unknown, section: Section(SectionIndex(19)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } 57: Symbol { name: "_start", address: 570, size: 2b, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -58: Symbol { name: "__bss_start", address: 201010, size: 0, kind: Label, section: Section(SectionIndex(19)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +58: Symbol { name: "__bss_start", address: 201010, size: 0, kind: Unknown, section: Section(SectionIndex(19)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } 59: Symbol { name: "main", address: 67a, size: 1c, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } 60: Symbol { name: "__TMC_END__", address: 201010, size: 0, kind: Data, section: Section(SectionIndex(18)), scope: Linkage, weak: false, flags: Elf { st_info: 11, st_other: 2 } } -61: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +61: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } 62: Symbol { name: "__cxa_finalize@@GLIBC_2.2.5", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 22, st_other: 0 } } 63: Symbol { name: "_init", address: 520, size: 0, kind: Text, section: Section(SectionIndex(c)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } Dynamic symbols 0: Symbol { name: "", address: 0, size: 0, kind: Null, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -1: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +1: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } 2: Symbol { name: "printf", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } 3: Symbol { name: "__libc_start_main", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -4: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -5: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +4: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } +5: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } 6: Symbol { name: "__cxa_finalize", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 22, st_other: 0 } } Dynamic relocations diff --git a/src/read/elf/symbol.rs b/src/read/elf/symbol.rs index 0603c981..73afbf6f 100644 --- a/src/read/elf/symbol.rs +++ b/src/read/elf/symbol.rs @@ -354,7 +354,7 @@ 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 => SymbolKind::Unknown, elf::STT_OBJECT | elf::STT_COMMON => SymbolKind::Data, elf::STT_FUNC | elf::STT_GNU_IFUNC => SymbolKind::Text, elf::STT_SECTION => SymbolKind::Section,