Skip to content

Commit

Permalink
read/xcoff: add support for relocation entries (gimli-rs#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
EsmeYi authored Nov 4, 2022
1 parent 789e591 commit 4bfb02c
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 12 deletions.
9 changes: 9 additions & 0 deletions crates/examples/testfiles/xcoff/base.o.objdump
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ Symbols
15: Symbol { name: "TOC", address: 80, size: 0, kind: Data, section: Section(SectionIndex(2)), scope: Dynamic, weak: false, flags: None }
17: Symbol { name: ".rodata.str1.1L...str", address: 80, size: 0, kind: Data, section: Section(SectionIndex(2)), scope: Dynamic, weak: false, flags: None }

.text relocations
(1e, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(11)), addend: 0, implicit_addend: true })
(20, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(3)), addend: fffffffffffffffc, implicit_addend: true })

.data relocations
(68, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(9)), addend: 0, implicit_addend: true })
(70, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(f)), addend: 0, implicit_addend: true })
(80, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true })

Dynamic symbols
72 changes: 72 additions & 0 deletions crates/examples/testfiles/xcoff/base.xcoff.objdump
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,76 @@ Symbols
152: Symbol { name: ".printf", address: 100000698, size: 0, kind: Text, section: Section(SectionIndex(1)), scope: Dynamic, weak: false, flags: None }
154: Symbol { name: ".printf", address: 100000698, size: 0, kind: Text, section: Section(SectionIndex(1)), scope: Dynamic, weak: false, flags: None }

.text relocations
(1000001fa, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(46)), addend: 0, implicit_addend: true })
(1000001fe, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(16)), addend: 0, implicit_addend: true })
(10000020e, Relocation { kind: Xcoff(13), encoding: Generic, size: 40, target: Symbol(SymbolIndex(18)), addend: 0, implicit_addend: true })
(100000212, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(28)), addend: 0, implicit_addend: true })
(100000216, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(2a)), addend: 0, implicit_addend: true })
(10000021a, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(3e)), addend: 0, implicit_addend: true })
(10000021e, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(40)), addend: 0, implicit_addend: true })
(10000022e, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(2c)), addend: 0, implicit_addend: true })
(100000252, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(3e)), addend: 0, implicit_addend: true })
(10000025a, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(2e)), addend: 0, implicit_addend: true })
(100000268, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(7f)), addend: fffffffffffffffc, implicit_addend: true })
(100000272, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(42)), addend: 0, implicit_addend: true })
(10000027e, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(44)), addend: 0, implicit_addend: true })
(100000280, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(86)), addend: fffffffffffffffc, implicit_addend: true })
(1000002c2, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(56)), addend: 0, implicit_addend: true })
(10000030a, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(56)), addend: 0, implicit_addend: true })
(10000032e, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(58)), addend: 0, implicit_addend: true })
(100000352, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(5a)), addend: 0, implicit_addend: true })
(100000376, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(5c)), addend: 0, implicit_addend: true })
(10000039a, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(5e)), addend: 0, implicit_addend: true })
(1000003ce, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(5c)), addend: 0, implicit_addend: true })
(100000408, Relocation { kind: Xcoff(f), encoding: Generic, size: 0, target: Symbol(SymbolIndex(52)), addend: 0, implicit_addend: true })
(100000454, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(8b)), addend: fffffffffffffffc, implicit_addend: true })
(1000004a2, Relocation { kind: Xcoff(13), encoding: Generic, size: 40, target: Symbol(SymbolIndex(1c)), addend: 0, implicit_addend: true })
(1000004aa, Relocation { kind: Xcoff(13), encoding: Generic, size: 40, target: Symbol(SymbolIndex(1e)), addend: 0, implicit_addend: true })
(1000004cc, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(90)), addend: fffffffffffffffc, implicit_addend: true })
(1000004d6, Relocation { kind: Xcoff(13), encoding: Generic, size: 40, target: Symbol(SymbolIndex(22)), addend: 0, implicit_addend: true })
(1000004d8, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(95)), addend: fffffffffffffffc, implicit_addend: true })
(100000540, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(8b)), addend: fffffffffffffffc, implicit_addend: true })
(10000054c, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(86)), addend: fffffffffffffffc, implicit_addend: true })
(10000059a, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(1a)), addend: 0, implicit_addend: true })
(1000005c2, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(20)), addend: 0, implicit_addend: true })
(1000005ea, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(24)), addend: 0, implicit_addend: true })
(100000612, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(26)), addend: 0, implicit_addend: true })
(10000065e, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(30)), addend: 0, implicit_addend: true })
(100000660, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(9a)), addend: fffffffffffffffc, implicit_addend: true })
(10000069a, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(32)), addend: 0, implicit_addend: true })

.data relocations
(1100006d0, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(3e)), addend: 0, implicit_addend: true })
(1100006d8, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(54)), addend: 0, implicit_addend: true })
(1100006e0, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(78)), addend: 0, implicit_addend: true })
(110000728, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true })
(110000798, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(74)), addend: 0, implicit_addend: true })
(1100007b0, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(70)), addend: 0, implicit_addend: true })
(110000848, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(36)), addend: 0, implicit_addend: true })
(110000850, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true })
(110000858, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(4e)), addend: 0, implicit_addend: true })
(110000860, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true })
(110000870, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(6a)), addend: 0, implicit_addend: true })
(110000878, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true })
(110000888, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(6c)), addend: 0, implicit_addend: true })
(110000890, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true })
(1100008a0, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(68)), addend: 0, implicit_addend: true })
(1100008a8, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true })
(110000900, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(10)), addend: 0, implicit_addend: true })
(110000908, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(3c)), addend: 0, implicit_addend: true })
(110000910, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(a)), addend: 0, implicit_addend: true })
(110000918, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(6e)), addend: 0, implicit_addend: true })
(110000920, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(72)), addend: 0, implicit_addend: true })
(110000928, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(6)), addend: 0, implicit_addend: true })
(110000930, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(76)), addend: 0, implicit_addend: true })
(110000938, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(c)), addend: 0, implicit_addend: true })
(110000940, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true })
(110000948, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(e)), addend: 0, implicit_addend: true })
(110000950, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(2)), addend: 0, implicit_addend: true })
(110000958, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true })
(110000960, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(0)), addend: 0, implicit_addend: true })
(110000968, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(81)), addend: 0, implicit_addend: true })
(110000970, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(8)), addend: 0, implicit_addend: true })

Dynamic symbols
9 changes: 9 additions & 0 deletions crates/examples/testfiles/xcoff/base32.o.objdump
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ Symbols
15: Symbol { name: "TOC", address: 78, size: 0, kind: Data, section: Section(SectionIndex(2)), scope: Dynamic, weak: false, flags: None }
17: Symbol { name: ".rodata.str1.1L...str", address: 78, size: 0, kind: Data, section: Section(SectionIndex(2)), scope: Dynamic, weak: false, flags: None }

.text relocations
(22, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(11)), addend: 0, implicit_addend: true })
(24, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(3)), addend: fffffffffffffffc, implicit_addend: true })

.data relocations
(6c, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(9)), addend: 0, implicit_addend: true })
(70, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(f)), addend: 0, implicit_addend: true })
(78, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true })

Dynamic symbols
Loading

0 comments on commit 4bfb02c

Please sign in to comment.