diff --git a/crates/examples/testfiles/xcoff/base.o.objdump b/crates/examples/testfiles/xcoff/base.o.objdump index ae2a86af..99ece666 100644 --- a/crates/examples/testfiles/xcoff/base.o.objdump +++ b/crates/examples/testfiles/xcoff/base.o.objdump @@ -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 diff --git a/crates/examples/testfiles/xcoff/base.xcoff.objdump b/crates/examples/testfiles/xcoff/base.xcoff.objdump index da9b459a..614012ff 100644 --- a/crates/examples/testfiles/xcoff/base.xcoff.objdump +++ b/crates/examples/testfiles/xcoff/base.xcoff.objdump @@ -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 diff --git a/crates/examples/testfiles/xcoff/base32.o.objdump b/crates/examples/testfiles/xcoff/base32.o.objdump index 8d64b87e..f1094080 100644 --- a/crates/examples/testfiles/xcoff/base32.o.objdump +++ b/crates/examples/testfiles/xcoff/base32.o.objdump @@ -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 diff --git a/crates/examples/testfiles/xcoff/base32.xcoff.objdump b/crates/examples/testfiles/xcoff/base32.xcoff.objdump index 37c01a52..8d45ba8a 100644 --- a/crates/examples/testfiles/xcoff/base32.xcoff.objdump +++ b/crates/examples/testfiles/xcoff/base32.xcoff.objdump @@ -88,4 +88,72 @@ Symbols 148: Symbol { name: ".printf", address: 100005bc, size: 0, kind: Text, section: Section(SectionIndex(1)), scope: Dynamic, weak: false, flags: None } 150: Symbol { name: ".printf", address: 100005bc, size: 0, kind: Text, section: Section(SectionIndex(1)), scope: Dynamic, weak: false, flags: None } +.text relocations +(1000012a, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(42)), addend: 0, implicit_addend: true }) +(1000012e, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true }) +(10000146, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(16)), addend: 0, implicit_addend: true }) +(1000014a, Relocation { kind: Xcoff(13), encoding: Generic, size: 40, target: Symbol(SymbolIndex(18)), addend: 0, implicit_addend: true }) +(1000014e, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(3a)), addend: 0, implicit_addend: true }) +(10000152, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(3c)), addend: 0, implicit_addend: true }) +(10000162, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(28)), addend: 0, implicit_addend: true }) +(10000182, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(2a)), addend: 0, implicit_addend: true }) +(10000190, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(7b)), addend: fffffffffffffffc, implicit_addend: true }) +(1000019a, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(3e)), addend: 0, implicit_addend: true }) +(100001a6, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(40)), addend: 0, implicit_addend: true }) +(100001a8, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(82)), addend: fffffffffffffffc, implicit_addend: true }) +(100001e2, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(52)), addend: 0, implicit_addend: true }) +(1000022a, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(52)), addend: 0, implicit_addend: true }) +(1000024e, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(54)), addend: 0, implicit_addend: true }) +(10000272, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(56)), addend: 0, implicit_addend: true }) +(10000296, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(58)), addend: 0, implicit_addend: true }) +(100002ba, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(5a)), addend: 0, implicit_addend: true }) +(100002ee, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(58)), addend: 0, implicit_addend: true }) +(10000328, Relocation { kind: Xcoff(f), encoding: Generic, size: 0, target: Symbol(SymbolIndex(4e)), addend: 0, implicit_addend: true }) +(10000374, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(87)), addend: fffffffffffffffc, implicit_addend: true }) +(100003c2, Relocation { kind: Xcoff(13), encoding: Generic, size: 40, target: Symbol(SymbolIndex(1c)), addend: 0, implicit_addend: true }) +(100003ca, Relocation { kind: Xcoff(13), encoding: Generic, size: 40, target: Symbol(SymbolIndex(1e)), addend: 0, implicit_addend: true }) +(100003ec, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(8c)), addend: fffffffffffffffc, implicit_addend: true }) +(100003f6, Relocation { kind: Xcoff(13), encoding: Generic, size: 40, target: Symbol(SymbolIndex(22)), addend: 0, implicit_addend: true }) +(100003f8, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(91)), addend: fffffffffffffffc, implicit_addend: true }) +(10000460, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(87)), addend: fffffffffffffffc, implicit_addend: true }) +(1000046c, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(82)), addend: fffffffffffffffc, implicit_addend: true }) +(100004ba, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(1a)), addend: 0, implicit_addend: true }) +(100004e2, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(20)), addend: 0, implicit_addend: true }) +(1000050a, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(24)), addend: 0, implicit_addend: true }) +(10000532, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(26)), addend: 0, implicit_addend: true }) +(10000582, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(2c)), addend: 0, implicit_addend: true }) +(10000584, Relocation { kind: Relative, encoding: Generic, size: 0, target: Symbol(SymbolIndex(96)), addend: fffffffffffffffc, implicit_addend: true }) +(100005be, Relocation { kind: Got, encoding: Generic, size: 0, target: Symbol(SymbolIndex(2e)), addend: 0, implicit_addend: true }) + +.data relocations +(200005f4, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(3a)), addend: 0, implicit_addend: true }) +(200005f8, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(50)), addend: 0, implicit_addend: true }) +(20000600, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(74)), addend: 0, implicit_addend: true }) +(2000067c, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(70)), addend: 0, implicit_addend: true }) +(2000068c, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(6c)), addend: 0, implicit_addend: true }) +(20000710, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(32)), addend: 0, implicit_addend: true }) +(20000714, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true }) +(20000718, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(4a)), addend: 0, implicit_addend: true }) +(2000071c, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true }) +(20000724, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(66)), addend: 0, implicit_addend: true }) +(20000728, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true }) +(20000730, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(68)), addend: 0, implicit_addend: true }) +(20000734, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true }) +(2000073c, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(64)), addend: 0, implicit_addend: true }) +(20000740, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true }) +(20000770, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(e)), addend: 0, implicit_addend: true }) +(20000774, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(c)), addend: 0, implicit_addend: true }) +(20000778, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(38)), addend: 0, implicit_addend: true }) +(2000077c, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(8)), addend: 0, implicit_addend: true }) +(20000780, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(6a)), addend: 0, implicit_addend: true }) +(20000784, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(6e)), addend: 0, implicit_addend: true }) +(20000788, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true }) +(2000078c, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(72)), addend: 0, implicit_addend: true }) +(20000790, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(a)), addend: 0, implicit_addend: true }) +(20000794, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(2)), addend: 0, implicit_addend: true }) +(20000798, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(10)), addend: 0, implicit_addend: true }) +(2000079c, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(0)), addend: 0, implicit_addend: true }) +(200007a0, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(7d)), addend: 0, implicit_addend: true }) +(200007a4, Relocation { kind: Absolute, encoding: Generic, size: 0, target: Symbol(SymbolIndex(6)), addend: 0, implicit_addend: true }) + Dynamic symbols diff --git a/src/common.rs b/src/common.rs index d39271d4..026b0be9 100644 --- a/src/common.rs +++ b/src/common.rs @@ -306,6 +306,8 @@ pub enum RelocationKind { }, /// Some other COFF relocation. The value is dependent on the architecture. Coff(u16), + /// Some other XCOFF relocation. + Xcoff(u8), } /// Information about how the result of the relocation operation is encoded in the place. diff --git a/src/read/xcoff/file.rs b/src/read/xcoff/file.rs index 834e29e7..9631cce3 100644 --- a/src/read/xcoff/file.rs +++ b/src/read/xcoff/file.rs @@ -11,7 +11,7 @@ use crate::{ }; use super::{ - Rel, SectionHeader, SectionTable, Symbol, SymbolTable, XcoffComdat, XcoffComdatIterator, + SectionHeader, SectionTable, Symbol, SymbolTable, XcoffComdat, XcoffComdatIterator, XcoffSection, XcoffSectionIterator, XcoffSegment, XcoffSegmentIterator, XcoffSymbol, XcoffSymbolIterator, XcoffSymbolTable, }; @@ -49,6 +49,7 @@ where let aux_header = header.aux_header(data, &mut offset)?; let sections = header.sections(data, &mut offset)?; let symbols = header.symbols(data)?; + Ok(XcoffFile { data, header, @@ -247,7 +248,6 @@ pub trait FileHeader: Debug + Pod { type AuxHeader: AuxHeader; type SectionHeader: SectionHeader; type Symbol: Symbol; - type Rel: Rel; /// Return true if this type is a 64-bit header. fn is_type_64(&self) -> bool; @@ -328,7 +328,6 @@ impl FileHeader for xcoff::FileHeader32 { type AuxHeader = xcoff::AuxHeader32; type SectionHeader = xcoff::SectionHeader32; type Symbol = xcoff::Symbol32; - type Rel = xcoff::Rel32; fn is_type_64(&self) -> bool { false @@ -368,7 +367,6 @@ impl FileHeader for xcoff::FileHeader64 { type AuxHeader = xcoff::AuxHeader64; type SectionHeader = xcoff::SectionHeader64; type Symbol = xcoff::Symbol64; - type Rel = xcoff::Rel64; fn is_type_64(&self) -> bool { true diff --git a/src/read/xcoff/relocation.rs b/src/read/xcoff/relocation.rs index c227b71a..013bdf6d 100644 --- a/src/read/xcoff/relocation.rs +++ b/src/read/xcoff/relocation.rs @@ -1,12 +1,13 @@ use alloc::fmt; use core::fmt::Debug; +use core::slice; use crate::pod::Pod; -use crate::{xcoff, Relocation}; +use crate::{xcoff, BigEndian as BE, Relocation}; -use crate::read::ReadRef; +use crate::read::{ReadRef, RelocationEncoding, RelocationKind, RelocationTarget, SymbolIndex}; -use super::{FileHeader, XcoffFile}; +use super::{FileHeader, SectionHeader, XcoffFile}; /// An iterator over the relocations in a `XcoffSection32`. pub type XcoffRelocationIterator32<'data, 'file, R = &'data [u8]> = @@ -24,6 +25,8 @@ where { #[allow(unused)] pub(super) file: &'file XcoffFile<'data, Xcoff, R>, + pub(super) relocations: + slice::Iter<'data, <::SectionHeader as SectionHeader>::Rel>, } impl<'data, 'file, Xcoff, R> Iterator for XcoffRelocationIterator<'data, 'file, Xcoff, R> @@ -34,8 +37,33 @@ where type Item = (u64, Relocation); fn next(&mut self) -> Option { - // TODO: return the relocations in the section. - None + self.relocations.next().map(|relocation| { + let encoding = RelocationEncoding::Generic; + let (kind, addend) = match relocation.r_rtype() { + xcoff::R_POS + | xcoff::R_RL + | xcoff::R_RLA + | xcoff::R_BA + | xcoff::R_RBA + | xcoff::R_TLS => (RelocationKind::Absolute, 0), + xcoff::R_REL | xcoff::R_BR | xcoff::R_RBR => (RelocationKind::Relative, -4), + xcoff::R_TOC | xcoff::R_TOCL | xcoff::R_TOCU => (RelocationKind::Got, 0), + r_type => (RelocationKind::Xcoff(r_type), 0), + }; + let size = relocation.r_rsize() & 0x3F + 1; + let target = RelocationTarget::Symbol(SymbolIndex(relocation.r_symndx() as usize)); + ( + u64::from(relocation.r_vaddr().into()), + Relocation { + kind, + encoding, + size, + target, + addend, + implicit_addend: true, + }, + ) + }) } } @@ -53,12 +81,48 @@ where #[allow(missing_docs)] pub trait Rel: Debug + Pod { type Word: Into; + fn r_vaddr(&self) -> Self::Word; + fn r_symndx(&self) -> u32; + fn r_rsize(&self) -> u8; + fn r_rtype(&self) -> u8; } impl Rel for xcoff::Rel32 { type Word = u32; + + fn r_vaddr(&self) -> Self::Word { + self.r_vaddr.get(BE) + } + + fn r_symndx(&self) -> u32 { + self.r_symndx.get(BE) + } + + fn r_rsize(&self) -> u8 { + self.r_rsize + } + + fn r_rtype(&self) -> u8 { + self.r_rtype + } } impl Rel for xcoff::Rel64 { type Word = u64; + + fn r_vaddr(&self) -> Self::Word { + self.r_vaddr.get(BE) + } + + fn r_symndx(&self) -> u32 { + self.r_symndx.get(BE) + } + + fn r_rsize(&self) -> u8 { + self.r_rsize + } + + fn r_rtype(&self) -> u8 { + self.r_rtype + } } diff --git a/src/read/xcoff/section.rs b/src/read/xcoff/section.rs index fe134d42..4d1707e5 100644 --- a/src/read/xcoff/section.rs +++ b/src/read/xcoff/section.rs @@ -5,9 +5,9 @@ use crate::{ xcoff, BigEndian as BE, CompressedData, CompressedFileRange, Pod, SectionFlags, SectionKind, }; -use crate::read::{self, ObjectSection, ReadError, ReadRef, Result, SectionIndex}; +use crate::read::{self, Error, ObjectSection, ReadError, ReadRef, Result, SectionIndex}; -use super::{AuxHeader, FileHeader, XcoffFile, XcoffRelocationIterator}; +use super::{AuxHeader, FileHeader, Rel, XcoffFile, XcoffRelocationIterator}; /// An iterator over the sections of an `XcoffFile32`. pub type XcoffSectionIterator32<'data, 'file, R = &'data [u8]> = @@ -181,7 +181,11 @@ where } fn relocations(&self) -> Self::RelocationIterator { - XcoffRelocationIterator { file: self.file } + let rel = self.section.relocations(self.file.data).unwrap_or(&[]); + XcoffRelocationIterator { + file: self.file, + relocations: rel.iter(), + } } fn flags(&self) -> SectionFlags { @@ -261,6 +265,7 @@ pub trait SectionHeader: Debug + Pod { type Word: Into; type HalfWord: Into; type Xcoff: FileHeader; + type Rel: Rel; fn s_name(&self) -> &[u8; 8]; fn s_paddr(&self) -> Self::Word; @@ -298,12 +303,16 @@ pub trait SectionHeader: Debug + Pod { Ok(&[]) } } + + /// Read the relocations. + fn relocations<'data, R: ReadRef<'data>>(&self, data: R) -> read::Result<&'data [Self::Rel]>; } impl SectionHeader for xcoff::SectionHeader32 { type Word = u32; type HalfWord = u16; type Xcoff = xcoff::FileHeader32; + type Rel = xcoff::Rel32; fn s_name(&self) -> &[u8; 8] { &self.s_name @@ -344,12 +353,28 @@ impl SectionHeader for xcoff::SectionHeader32 { fn s_flags(&self) -> u32 { self.s_flags.get(BE) } + + /// Read the relocations in a XCOFF32 file. + /// + /// `data` must be the entire file data. + fn relocations<'data, R: ReadRef<'data>>(&self, data: R) -> read::Result<&'data [Self::Rel]> { + let reloc_num = self.s_nreloc() as usize; + // TODO: If more than 65,534 relocation entries are required, the field value will be 65535, + // and an STYP_OVRFLO section header will contain the actual count of relocation entries in + // the s_paddr field. + if reloc_num == 65535 { + return Err(Error("Overflow section is not supported yet.")); + } + data.read_slice_at(self.s_relptr().into(), reloc_num) + .read_error("Invalid XCOFF relocation offset or number") + } } impl SectionHeader for xcoff::SectionHeader64 { type Word = u64; type HalfWord = u32; type Xcoff = xcoff::FileHeader64; + type Rel = xcoff::Rel64; fn s_name(&self) -> &[u8; 8] { &self.s_name @@ -390,4 +415,12 @@ impl SectionHeader for xcoff::SectionHeader64 { fn s_flags(&self) -> u32 { self.s_flags.get(BE) } + + /// Read the relocations in a XCOFF64 file. + /// + /// `data` must be the entire file data. + fn relocations<'data, R: ReadRef<'data>>(&self, data: R) -> read::Result<&'data [Self::Rel]> { + data.read_slice_at(self.s_relptr().into(), self.s_nreloc() as usize) + .read_error("Invalid XCOFF relocation offset or number") + } }