Skip to content

Commit b3dbfab

Browse files
authored
Merge pull request gimli-rs#601 from philipc/elf-def
read/elf: exclude zero sized STT_NOTYPE symbols from is_definitions
2 parents 859e910 + 9f0620e commit b3dbfab

35 files changed

+3893
-4
lines changed

Diff for: crates/examples/src/objdump.rs

+6
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ fn dump_parsed_object<W: Write, E: Write>(w: &mut W, e: &mut E, file: &object::F
248248
Err(err) => writeln!(e, "Failed to parse exports: {}", err)?,
249249
}
250250

251+
writeln!(w)?;
252+
writeln!(w, "Symbol map")?;
253+
for symbol in file.symbol_map().symbols() {
254+
writeln!(w, "0x{:x} \"{}\"", symbol.address(), symbol.name())?;
255+
}
256+
251257
Ok(())
252258
}
253259

Diff for: crates/examples/testfiles/coff/import_msvc.lib.objdump

+39
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Symbols
5252

5353
Dynamic symbols
5454

55+
Symbol map
56+
0x0 "@comp.id"
57+
0x0 "test_x64_NULL_THUNK_DATA"
58+
5559
test_x64.dll:
5660
Format: Coff Little-endian 32-bit
5761
Kind: Relocatable
@@ -70,6 +74,10 @@ Symbols
7074

7175
Dynamic symbols
7276

77+
Symbol map
78+
0x0 "@comp.id"
79+
0x0 "__NULL_IMPORT_DESCRIPTOR"
80+
7381
test_x64.dll:
7482
Format: Coff Little-endian 32-bit
7583
Kind: Relocatable
@@ -101,6 +109,11 @@ Symbols
101109

102110
Dynamic symbols
103111

112+
Symbol map
113+
0x0 "@comp.id"
114+
0x0 "__IMPORT_DESCRIPTOR_test_x64"
115+
0x0 ".idata$6"
116+
104117
test_x86.dll:
105118
Format: Short Import File
106119
Architecture: I386
@@ -129,6 +142,10 @@ Symbols
129142

130143
Dynamic symbols
131144

145+
Symbol map
146+
0x0 "@comp.id"
147+
0x0 "test_x86_NULL_THUNK_DATA"
148+
132149
test_x86.dll:
133150
Format: Coff Little-endian 32-bit
134151
Kind: Relocatable
@@ -147,6 +164,10 @@ Symbols
147164

148165
Dynamic symbols
149166

167+
Symbol map
168+
0x0 "@comp.id"
169+
0x0 "__NULL_IMPORT_DESCRIPTOR"
170+
150171
test_x86.dll:
151172
Format: Coff Little-endian 32-bit
152173
Kind: Relocatable
@@ -178,6 +199,11 @@ Symbols
178199

179200
Dynamic symbols
180201

202+
Symbol map
203+
0x0 "@comp.id"
204+
0x0 "__IMPORT_DESCRIPTOR_test_x86"
205+
0x0 ".idata$6"
206+
181207
test_arm64ec.dll:
182208
Format: Short Import File
183209
Architecture: Unknown
@@ -206,6 +232,10 @@ Symbols
206232

207233
Dynamic symbols
208234

235+
Symbol map
236+
0x0 "@comp.id"
237+
0x0 "test_arm64ec_NULL_THUNK_DATA"
238+
209239
test_arm64ec.dll:
210240
Format: Coff Little-endian 32-bit
211241
Kind: Relocatable
@@ -224,6 +254,10 @@ Symbols
224254

225255
Dynamic symbols
226256

257+
Symbol map
258+
0x0 "@comp.id"
259+
0x0 "__NULL_IMPORT_DESCRIPTOR"
260+
227261
test_arm64ec.dll:
228262
Format: Coff Little-endian 32-bit
229263
Kind: Relocatable
@@ -254,3 +288,8 @@ Symbols
254288
(10, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true })
255289

256290
Dynamic symbols
291+
292+
Symbol map
293+
0x0 "@comp.id"
294+
0x0 "__IMPORT_DESCRIPTOR_test_arm64ec"
295+
0x0 ".idata$6"

Diff for: crates/examples/testfiles/elf/base-aarch64.o.objdump

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Format: Elf Little-endian 64-bit
2+
Kind: Relocatable
3+
Architecture: Aarch64
4+
Flags: Elf { os_abi: 0, abi_version: 0, e_flags: 0 }
5+
Relative Address Base: 0
6+
Entry Address: 0
7+
0: Section { name: "", address: 0, size: 0, align: 0, kind: Metadata, flags: Elf { sh_flags: 0 } }
8+
1: Section { name: ".text", address: 0, size: 20, align: 4, kind: Text, flags: Elf { sh_flags: 6 } }
9+
2: Section { name: ".rela.text", address: 0, size: 48, align: 8, kind: Metadata, flags: Elf { sh_flags: 40 } }
10+
3: Section { name: ".data", address: 0, size: 0, align: 1, kind: Data, flags: Elf { sh_flags: 3 } }
11+
4: Section { name: ".bss", address: 0, size: 0, align: 1, kind: UninitializedData, flags: Elf { sh_flags: 3 } }
12+
5: Section { name: ".rodata", address: 0, size: d, align: 8, kind: ReadOnlyData, flags: Elf { sh_flags: 2 } }
13+
6: Section { name: ".comment", address: 0, size: 31, align: 1, kind: OtherString, flags: Elf { sh_flags: 30 } }
14+
7: Section { name: ".note.GNU-stack", address: 0, size: 0, align: 1, kind: Other, flags: Elf { sh_flags: 0 } }
15+
8: Section { name: ".symtab", address: 0, size: 120, align: 8, kind: Metadata, flags: Elf { sh_flags: 0 } }
16+
9: Section { name: ".strtab", address: 0, size: 1a, align: 1, kind: Metadata, flags: Elf { sh_flags: 0 } }
17+
10: Section { name: ".shstrtab", address: 0, size: 52, align: 1, kind: Metadata, flags: Elf { sh_flags: 0 } }
18+
19+
Symbols
20+
0: Symbol { name: "", address: 0, size: 0, kind: Null, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 0, st_other: 0 } }
21+
1: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } }
22+
2: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } }
23+
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 } }
24+
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 } }
25+
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 } }
26+
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 } }
27+
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 } }
28+
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 } }
29+
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 } }
30+
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 } }
31+
11: Symbol { name: "printf", address: 0, size: 0, kind: Label, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 10, st_other: 0 } }
32+
33+
.text relocations
34+
(8, Relocation { kind: Elf(113), encoding: Generic, size: 0, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: false })
35+
(c, Relocation { kind: Elf(115), encoding: Generic, size: 0, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: false })
36+
(10, Relocation { kind: PltRelative, encoding: AArch64Call, size: 1a, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: false })
37+
38+
Dynamic symbols
39+
40+
Dynamic relocations
41+
42+
Symbol map
43+
0x0 "main"

0 commit comments

Comments
 (0)