diff --git a/crates/examples/src/objcopy.rs b/crates/examples/src/objcopy.rs index 6b1f86cd..48a9cf41 100644 --- a/crates/examples/src/objcopy.rs +++ b/crates/examples/src/objcopy.rs @@ -137,11 +137,9 @@ pub fn copy(in_data: &[u8]) -> Vec { }; let out_relocation = write::Relocation { offset, - size: in_relocation.size(), - kind: in_relocation.kind(), - encoding: in_relocation.encoding(), symbol, addend: in_relocation.addend(), + flags: in_relocation.flags(), }; out_object .add_relocation(out_section, out_relocation) diff --git a/crates/examples/testfiles/coff/import_msvc.lib.objdump b/crates/examples/testfiles/coff/import_msvc.lib.objdump index c94f90e6..ba35d308 100644 --- a/crates/examples/testfiles/coff/import_msvc.lib.objdump +++ b/crates/examples/testfiles/coff/import_msvc.lib.objdump @@ -101,9 +101,9 @@ Symbols 7: Symbol { name: "\u{7f}test_x64_NULL_THUNK_DATA", address: 0, size: 0, kind: Data, section: Undefined, scope: Linkage, weak: false, flags: None } .idata$2 relocations -(c, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(0, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true }) -(10, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true }) +(c, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) +(0, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) +(10, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) Dynamic symbols @@ -187,9 +187,9 @@ Symbols 7: Symbol { name: "\u{7f}test_x86_NULL_THUNK_DATA", address: 0, size: 0, kind: Data, section: Undefined, scope: Linkage, weak: false, flags: None } .idata$2 relocations -(c, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(0, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true }) -(10, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true }) +(c, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: Coff { typ: 7 } }) +(0, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true, flags: Coff { typ: 7 } }) +(10, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true, flags: Coff { typ: 7 } }) Dynamic symbols @@ -274,9 +274,9 @@ Symbols 7: Symbol { name: "\u{7f}test_arm64ec_NULL_THUNK_DATA", address: 0, size: 0, kind: Data, section: Undefined, scope: Linkage, weak: false, flags: None } .idata$2 relocations -(c, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(0, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true }) -(10, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true }) +(c, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: Coff { typ: 2 } }) +(0, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true, flags: Coff { typ: 2 } }) +(10, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true, flags: Coff { typ: 2 } }) Dynamic symbols diff --git a/crates/examples/testfiles/elf/base-aarch64.o.objdump b/crates/examples/testfiles/elf/base-aarch64.o.objdump index 7e104ab9..b865c601 100644 --- a/crates/examples/testfiles/elf/base-aarch64.o.objdump +++ b/crates/examples/testfiles/elf/base-aarch64.o.objdump @@ -31,9 +31,9 @@ Symbols 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 }) -(c, Relocation { kind: Elf(115), encoding: Generic, size: 0, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: false }) -(10, Relocation { kind: PltRelative, encoding: AArch64Call, size: 1a, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: false }) +(8, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: false, flags: Elf { r_type: 113 } }) +(c, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: false, flags: Elf { r_type: 115 } }) +(10, Relocation { kind: PltRelative, encoding: AArch64Call, size: 1a, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: false, flags: Elf { r_type: 11b } }) Dynamic symbols diff --git a/crates/examples/testfiles/elf/base-aarch64.objdump b/crates/examples/testfiles/elf/base-aarch64.objdump index 07fdc40d..949efa7f 100644 --- a/crates/examples/testfiles/elf/base-aarch64.objdump +++ b/crates/examples/testfiles/elf/base-aarch64.objdump @@ -138,21 +138,21 @@ Dynamic symbols 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 -(10d80, Relocation { kind: Elf(403), encoding: Generic, size: 0, target: Absolute, addend: 720, implicit_addend: false }) -(10d88, Relocation { kind: Elf(403), encoding: Generic, size: 0, target: Absolute, addend: 6d8, implicit_addend: false }) -(10fc8, Relocation { kind: Elf(403), encoding: Generic, size: 0, target: Absolute, addend: 7c8, implicit_addend: false }) -(10fe8, Relocation { kind: Elf(403), encoding: Generic, size: 0, target: Absolute, addend: 748, implicit_addend: false }) -(10ff0, Relocation { kind: Elf(403), encoding: Generic, size: 0, target: Absolute, addend: 724, implicit_addend: false }) -(11008, Relocation { kind: Elf(403), encoding: Generic, size: 0, target: Absolute, addend: 11008, implicit_addend: false }) -(10fd0, Relocation { kind: Elf(401), encoding: Generic, size: 0, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: false }) -(10fd8, Relocation { kind: Elf(401), encoding: Generic, size: 0, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: false }) -(10fe0, Relocation { kind: Elf(401), encoding: Generic, size: 0, target: Symbol(SymbolIndex(6)), addend: 0, implicit_addend: false }) -(10ff8, Relocation { kind: Elf(401), encoding: Generic, size: 0, target: Symbol(SymbolIndex(8)), addend: 0, implicit_addend: false }) -(10f98, Relocation { kind: Elf(402), encoding: Generic, size: 0, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: false }) -(10fa0, Relocation { kind: Elf(402), encoding: Generic, size: 0, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: false }) -(10fa8, Relocation { kind: Elf(402), encoding: Generic, size: 0, target: Symbol(SymbolIndex(6)), addend: 0, implicit_addend: false }) -(10fb0, Relocation { kind: Elf(402), encoding: Generic, size: 0, target: Symbol(SymbolIndex(7)), addend: 0, implicit_addend: false }) -(10fb8, Relocation { kind: Elf(402), encoding: Generic, size: 0, target: Symbol(SymbolIndex(9)), addend: 0, implicit_addend: false }) +(10d80, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Absolute, addend: 720, implicit_addend: false, flags: Elf { r_type: 403 } }) +(10d88, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Absolute, addend: 6d8, implicit_addend: false, flags: Elf { r_type: 403 } }) +(10fc8, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Absolute, addend: 7c8, implicit_addend: false, flags: Elf { r_type: 403 } }) +(10fe8, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Absolute, addend: 748, implicit_addend: false, flags: Elf { r_type: 403 } }) +(10ff0, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Absolute, addend: 724, implicit_addend: false, flags: Elf { r_type: 403 } }) +(11008, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Absolute, addend: 11008, implicit_addend: false, flags: Elf { r_type: 403 } }) +(10fd0, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: false, flags: Elf { r_type: 401 } }) +(10fd8, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: false, flags: Elf { r_type: 401 } }) +(10fe0, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(6)), addend: 0, implicit_addend: false, flags: Elf { r_type: 401 } }) +(10ff8, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(8)), addend: 0, implicit_addend: false, flags: Elf { r_type: 401 } }) +(10f98, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: false, flags: Elf { r_type: 402 } }) +(10fa0, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: false, flags: Elf { r_type: 402 } }) +(10fa8, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(6)), addend: 0, implicit_addend: false, flags: Elf { r_type: 402 } }) +(10fb0, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(7)), addend: 0, implicit_addend: false, flags: Elf { r_type: 402 } }) +(10fb8, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(9)), addend: 0, implicit_addend: false, flags: Elf { r_type: 402 } }) Import { library: "", name: "_ITM_deregisterTMCloneTable" } Import { library: "", name: "__cxa_finalize" } diff --git a/crates/examples/testfiles/elf/base.o.objdump b/crates/examples/testfiles/elf/base.o.objdump index 903973d2..b4dc95fb 100644 --- a/crates/examples/testfiles/elf/base.o.objdump +++ b/crates/examples/testfiles/elf/base.o.objdump @@ -33,11 +33,11 @@ Symbols 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 }) -(11, Relocation { kind: PltRelative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(b)), addend: fffffffffffffffc, implicit_addend: false }) +(7, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: fffffffffffffffc, implicit_addend: false, flags: Elf { r_type: 2 } }) +(11, Relocation { kind: PltRelative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(b)), addend: fffffffffffffffc, implicit_addend: false, flags: Elf { r_type: 4 } }) .eh_frame relocations -(20, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(2)), addend: 0, implicit_addend: false }) +(20, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(2)), addend: 0, implicit_addend: false, flags: Elf { r_type: 2 } }) Dynamic symbols diff --git a/crates/examples/testfiles/elf/base.objdump b/crates/examples/testfiles/elf/base.objdump index 33813335..19ffaece 100644 --- a/crates/examples/testfiles/elf/base.objdump +++ b/crates/examples/testfiles/elf/base.objdump @@ -114,15 +114,15 @@ Dynamic symbols 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 -(200da8, Relocation { kind: Elf(8), encoding: Generic, size: 0, target: Absolute, addend: 670, implicit_addend: false }) -(200db0, Relocation { kind: Elf(8), encoding: Generic, size: 0, target: Absolute, addend: 630, implicit_addend: false }) -(201008, Relocation { kind: Elf(8), encoding: Generic, size: 0, target: Absolute, addend: 201008, implicit_addend: false }) -(200fd8, Relocation { kind: Elf(6), encoding: Generic, size: 0, target: Symbol(SymbolIndex(1)), addend: 0, implicit_addend: false }) -(200fe0, Relocation { kind: Elf(6), encoding: Generic, size: 0, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: false }) -(200fe8, Relocation { kind: Elf(6), encoding: Generic, size: 0, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: false }) -(200ff0, Relocation { kind: Elf(6), encoding: Generic, size: 0, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: false }) -(200ff8, Relocation { kind: Elf(6), encoding: Generic, size: 0, target: Symbol(SymbolIndex(6)), addend: 0, implicit_addend: false }) -(200fd0, Relocation { kind: Elf(7), encoding: Generic, size: 0, target: Symbol(SymbolIndex(2)), addend: 0, implicit_addend: false }) +(200da8, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Absolute, addend: 670, implicit_addend: false, flags: Elf { r_type: 8 } }) +(200db0, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Absolute, addend: 630, implicit_addend: false, flags: Elf { r_type: 8 } }) +(201008, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Absolute, addend: 201008, implicit_addend: false, flags: Elf { r_type: 8 } }) +(200fd8, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(1)), addend: 0, implicit_addend: false, flags: Elf { r_type: 6 } }) +(200fe0, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: false, flags: Elf { r_type: 6 } }) +(200fe8, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: false, flags: Elf { r_type: 6 } }) +(200ff0, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: false, flags: Elf { r_type: 6 } }) +(200ff8, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(6)), addend: 0, implicit_addend: false, flags: Elf { r_type: 6 } }) +(200fd0, Relocation { kind: Unknown, encoding: Generic, size: 0, target: Symbol(SymbolIndex(2)), addend: 0, implicit_addend: false, flags: Elf { r_type: 7 } }) Import { library: "", name: "_ITM_deregisterTMCloneTable" } Import { library: "", name: "printf" } diff --git a/crates/examples/testfiles/macho/base-aarch64-debug.o.objdump b/crates/examples/testfiles/macho/base-aarch64-debug.o.objdump index d8254061..51caca89 100644 --- a/crates/examples/testfiles/macho/base-aarch64-debug.o.objdump +++ b/crates/examples/testfiles/macho/base-aarch64-debug.o.objdump @@ -26,19 +26,19 @@ Symbols 5: Symbol { name: "_printf", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: MachO { n_desc: 0 } } __text relocations -(20, Relocation { kind: MachO { value: 2, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true }) -(1c, Relocation { kind: MachO { value: 4, relative: false }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(1)), addend: 0, implicit_addend: true }) -(18, Relocation { kind: MachO { value: 3, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(1)), addend: 0, implicit_addend: true }) +(20, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true, flags: MachO { r_type: 2, r_pcrel: true, r_length: 2 } }) +(1c, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 4, r_pcrel: false, r_length: 2 } }) +(18, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 3, r_pcrel: true, r_length: 2 } }) __debug_info relocations -(33, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true }) -(26, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true }) +(33, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) +(26, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) __compact_unwind relocations -(0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true }) +(0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) __debug_line relocations -(2b, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true }) +(2b, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) Dynamic symbols diff --git a/crates/examples/testfiles/macho/base-aarch64.o.objdump b/crates/examples/testfiles/macho/base-aarch64.o.objdump index 4eb4826e..22330556 100644 --- a/crates/examples/testfiles/macho/base-aarch64.o.objdump +++ b/crates/examples/testfiles/macho/base-aarch64.o.objdump @@ -18,12 +18,12 @@ Symbols 5: Symbol { name: "_printf", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: MachO { n_desc: 0 } } __text relocations -(20, Relocation { kind: MachO { value: 2, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true }) -(1c, Relocation { kind: MachO { value: 4, relative: false }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(1)), addend: 0, implicit_addend: true }) -(18, Relocation { kind: MachO { value: 3, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(1)), addend: 0, implicit_addend: true }) +(20, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true, flags: MachO { r_type: 2, r_pcrel: true, r_length: 2 } }) +(1c, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 4, r_pcrel: false, r_length: 2 } }) +(18, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 3, r_pcrel: true, r_length: 2 } }) __compact_unwind relocations -(0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true }) +(0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) Dynamic symbols diff --git a/crates/examples/testfiles/macho/base-x86_64-debug.o.objdump b/crates/examples/testfiles/macho/base-x86_64-debug.o.objdump index b63c90e1..097909c0 100644 --- a/crates/examples/testfiles/macho/base-x86_64-debug.o.objdump +++ b/crates/examples/testfiles/macho/base-x86_64-debug.o.objdump @@ -23,18 +23,18 @@ Symbols 1: Symbol { name: "_printf", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: MachO { n_desc: 0 } } __text relocations -(19, Relocation { kind: Relative, encoding: X86Branch, size: 20, target: Symbol(SymbolIndex(1)), addend: fffffffffffffffc, implicit_addend: true }) -(12, Relocation { kind: Relative, encoding: X86RipRelative, size: 20, target: Section(SectionIndex(2)), addend: fffffffffffffffc, implicit_addend: true }) +(19, Relocation { kind: Relative, encoding: X86Branch, size: 20, target: Symbol(SymbolIndex(1)), addend: fffffffffffffffc, implicit_addend: true, flags: MachO { r_type: 2, r_pcrel: true, r_length: 2 } }) +(12, Relocation { kind: Relative, encoding: X86RipRelative, size: 20, target: Section(SectionIndex(2)), addend: fffffffffffffffc, implicit_addend: true, flags: MachO { r_type: 1, r_pcrel: true, r_length: 2 } }) __debug_info relocations -(33, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true }) -(26, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true }) +(33, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) +(26, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) __compact_unwind relocations -(0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true }) +(0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) __debug_line relocations -(2b, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true }) +(2b, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) Dynamic symbols diff --git a/crates/examples/testfiles/macho/base-x86_64.o.objdump b/crates/examples/testfiles/macho/base-x86_64.o.objdump index 8472f54f..839840a8 100644 --- a/crates/examples/testfiles/macho/base-x86_64.o.objdump +++ b/crates/examples/testfiles/macho/base-x86_64.o.objdump @@ -15,11 +15,11 @@ Symbols 1: Symbol { name: "_printf", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: MachO { n_desc: 0 } } __text relocations -(19, Relocation { kind: Relative, encoding: X86Branch, size: 20, target: Symbol(SymbolIndex(1)), addend: fffffffffffffffc, implicit_addend: true }) -(12, Relocation { kind: Relative, encoding: X86RipRelative, size: 20, target: Section(SectionIndex(2)), addend: fffffffffffffffc, implicit_addend: true }) +(19, Relocation { kind: Relative, encoding: X86Branch, size: 20, target: Symbol(SymbolIndex(1)), addend: fffffffffffffffc, implicit_addend: true, flags: MachO { r_type: 2, r_pcrel: true, r_length: 2 } }) +(12, Relocation { kind: Relative, encoding: X86RipRelative, size: 20, target: Section(SectionIndex(2)), addend: fffffffffffffffc, implicit_addend: true, flags: MachO { r_type: 1, r_pcrel: true, r_length: 2 } }) __compact_unwind relocations -(0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true }) +(0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) Dynamic symbols diff --git a/crates/examples/testfiles/macho/reloc-aarch64.o.objdump b/crates/examples/testfiles/macho/reloc-aarch64.o.objdump index 4552cc50..08374e29 100644 --- a/crates/examples/testfiles/macho/reloc-aarch64.o.objdump +++ b/crates/examples/testfiles/macho/reloc-aarch64.o.objdump @@ -16,25 +16,25 @@ Symbols 4: Symbol { name: "_g1", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: MachO { n_desc: 0 } } __text relocations -(24, Relocation { kind: MachO { value: 9, relative: false }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(20, Relocation { kind: MachO { value: 8, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(1c, Relocation { kind: MachO { value: 6, relative: false }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(18, Relocation { kind: MachO { value: 5, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(14, Relocation { kind: MachO { value: 4, relative: false }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 14, implicit_addend: false }) -(10, Relocation { kind: MachO { value: 3, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 14, implicit_addend: false }) -(c, Relocation { kind: MachO { value: 4, relative: false }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(8, Relocation { kind: MachO { value: 3, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(4, Relocation { kind: MachO { value: 2, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 14, implicit_addend: false }) -(0, Relocation { kind: MachO { value: 2, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) +(24, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 9, r_pcrel: false, r_length: 2 } }) +(20, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 8, r_pcrel: true, r_length: 2 } }) +(1c, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 6, r_pcrel: false, r_length: 2 } }) +(18, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 5, r_pcrel: true, r_length: 2 } }) +(14, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 14, implicit_addend: false, flags: MachO { r_type: 4, r_pcrel: false, r_length: 2 } }) +(10, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 14, implicit_addend: false, flags: MachO { r_type: 3, r_pcrel: true, r_length: 2 } }) +(c, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 4, r_pcrel: false, r_length: 2 } }) +(8, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 3, r_pcrel: true, r_length: 2 } }) +(4, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 14, implicit_addend: false, flags: MachO { r_type: 2, r_pcrel: true, r_length: 2 } }) +(0, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 2, r_pcrel: true, r_length: 2 } }) __data relocations -(1c, Relocation { kind: MachO { value: 7, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(14, Relocation { kind: MachO { value: 7, relative: false }, encoding: Generic, size: 40, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(10, Relocation { kind: MachO { value: 1, relative: false }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true }) -(10, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(8, Relocation { kind: MachO { value: 1, relative: false }, encoding: Generic, size: 40, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true }) -(8, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) +(1c, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 7, r_pcrel: true, r_length: 2 } }) +(14, Relocation { kind: Unknown, encoding: Generic, size: 40, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 7, r_pcrel: false, r_length: 3 } }) +(10, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true, flags: MachO { r_type: 1, r_pcrel: false, r_length: 2 } }) +(10, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 2 } }) +(8, Relocation { kind: Unknown, encoding: Generic, size: 40, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true, flags: MachO { r_type: 1, r_pcrel: false, r_length: 3 } }) +(8, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) +(0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) Dynamic symbols diff --git a/crates/examples/testfiles/macho/reloc-arm.o.objdump b/crates/examples/testfiles/macho/reloc-arm.o.objdump index 61031c21..85cf1e5e 100644 --- a/crates/examples/testfiles/macho/reloc-arm.o.objdump +++ b/crates/examples/testfiles/macho/reloc-arm.o.objdump @@ -15,22 +15,22 @@ Symbols 3: Symbol { name: "_g0", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: MachO { n_desc: 0 } } __text relocations -(24, Relocation { kind: MachO { value: 8, relative: false }, encoding: Generic, size: 40, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(14, Relocation { kind: MachO { value: 1, relative: false }, encoding: Generic, size: 40, target: Section(SectionIndex(ffffff)), addend: 0, implicit_addend: true }) -(20, Relocation { kind: MachO { value: 8, relative: false }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(0, Relocation { kind: MachO { value: 1, relative: false }, encoding: Generic, size: 20, target: Section(SectionIndex(ffffff)), addend: 0, implicit_addend: true }) -(18, Relocation { kind: MachO { value: 6, relative: true }, encoding: Generic, size: 20, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true }) -(14, Relocation { kind: MachO { value: 6, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(10, Relocation { kind: MachO { value: 8, relative: false }, encoding: Generic, size: 10, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(14, Relocation { kind: MachO { value: 1, relative: false }, encoding: Generic, size: 10, target: Section(SectionIndex(ffffff)), addend: 0, implicit_addend: true }) -(c, Relocation { kind: MachO { value: 8, relative: false }, encoding: Generic, size: 8, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) -(0, Relocation { kind: MachO { value: 1, relative: false }, encoding: Generic, size: 8, target: Section(SectionIndex(ffffff)), addend: 0, implicit_addend: true }) -(4, Relocation { kind: MachO { value: 5, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(2)), addend: 0, implicit_addend: true }) -(0, Relocation { kind: MachO { value: 5, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) +(24, Relocation { kind: Unknown, encoding: Generic, size: 40, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 8, r_pcrel: false, r_length: 3 } }) +(14, Relocation { kind: Unknown, encoding: Generic, size: 40, target: Section(SectionIndex(ffffff)), addend: 0, implicit_addend: true, flags: MachO { r_type: 1, r_pcrel: false, r_length: 3 } }) +(20, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 8, r_pcrel: false, r_length: 2 } }) +(0, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Section(SectionIndex(ffffff)), addend: 0, implicit_addend: true, flags: MachO { r_type: 1, r_pcrel: false, r_length: 2 } }) +(18, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 6, r_pcrel: true, r_length: 2 } }) +(14, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 6, r_pcrel: true, r_length: 2 } }) +(10, Relocation { kind: Unknown, encoding: Generic, size: 10, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 8, r_pcrel: false, r_length: 1 } }) +(14, Relocation { kind: Unknown, encoding: Generic, size: 10, target: Section(SectionIndex(ffffff)), addend: 0, implicit_addend: true, flags: MachO { r_type: 1, r_pcrel: false, r_length: 1 } }) +(c, Relocation { kind: Unknown, encoding: Generic, size: 8, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 8, r_pcrel: false, r_length: 0 } }) +(0, Relocation { kind: Unknown, encoding: Generic, size: 8, target: Section(SectionIndex(ffffff)), addend: 0, implicit_addend: true, flags: MachO { r_type: 1, r_pcrel: false, r_length: 0 } }) +(4, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(2)), addend: 0, implicit_addend: true, flags: MachO { r_type: 5, r_pcrel: true, r_length: 2 } }) +(0, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 5, r_pcrel: true, r_length: 2 } }) __data relocations -(4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true }) -(0, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) +(4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 2 } }) +(0, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 2 } }) Dynamic symbols diff --git a/crates/examples/testfiles/macho/reloc-i386.o.objdump b/crates/examples/testfiles/macho/reloc-i386.o.objdump index ca5f017f..a92c41b6 100644 --- a/crates/examples/testfiles/macho/reloc-i386.o.objdump +++ b/crates/examples/testfiles/macho/reloc-i386.o.objdump @@ -15,12 +15,12 @@ Symbols 3: Symbol { name: "_g0", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: MachO { n_desc: 0 } } __text relocations -(6, Relocation { kind: MachO { value: 0, relative: true }, encoding: Generic, size: 20, target: Section(SectionIndex(1)), addend: fffffffffffffffc, implicit_addend: true }) -(1, Relocation { kind: MachO { value: 0, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: fffffffffffffffc, implicit_addend: true }) +(6, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Section(SectionIndex(1)), addend: fffffffffffffffc, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: true, r_length: 2 } }) +(1, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: fffffffffffffffc, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: true, r_length: 2 } }) __data relocations -(4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true }) -(0, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true }) +(4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Section(SectionIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 2 } }) +(0, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 2 } }) Dynamic symbols diff --git a/crates/examples/testfiles/macho/reloc-x86_64.o.objdump b/crates/examples/testfiles/macho/reloc-x86_64.o.objdump index 5505cff6..99cbf6a2 100644 --- a/crates/examples/testfiles/macho/reloc-x86_64.o.objdump +++ b/crates/examples/testfiles/macho/reloc-x86_64.o.objdump @@ -13,23 +13,23 @@ Symbols 1: Symbol { name: "_g2", address: 5, size: 0, kind: Text, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: MachO { n_desc: 0 } } __text relocations -(4f, Relocation { kind: MachO { value: 9, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffffc, implicit_addend: true }) -(48, Relocation { kind: GotRelative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffffc, implicit_addend: true }) -(42, Relocation { kind: GotRelative, encoding: X86RipRelativeMovq, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffffc, implicit_addend: true }) -(37, Relocation { kind: MachO { value: 8, relative: true }, encoding: Generic, size: 20, target: Section(SectionIndex(2)), addend: fffffffffffffff8, implicit_addend: true }) -(2f, Relocation { kind: MachO { value: 7, relative: true }, encoding: Generic, size: 20, target: Section(SectionIndex(2)), addend: fffffffffffffffa, implicit_addend: true }) -(27, Relocation { kind: MachO { value: 6, relative: true }, encoding: Generic, size: 20, target: Section(SectionIndex(2)), addend: fffffffffffffffb, implicit_addend: true }) -(1d, Relocation { kind: MachO { value: 8, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffff8, implicit_addend: true }) -(15, Relocation { kind: MachO { value: 7, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffffa, implicit_addend: true }) -(d, Relocation { kind: MachO { value: 6, relative: true }, encoding: Generic, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffffb, implicit_addend: true }) -(7, Relocation { kind: Relative, encoding: X86RipRelative, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffffc, implicit_addend: true }) -(1, Relocation { kind: Relative, encoding: X86Branch, size: 20, target: Symbol(SymbolIndex(1)), addend: fffffffffffffffc, implicit_addend: true }) +(4f, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffffc, implicit_addend: true, flags: MachO { r_type: 9, r_pcrel: true, r_length: 2 } }) +(48, Relocation { kind: GotRelative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffffc, implicit_addend: true, flags: MachO { r_type: 4, r_pcrel: true, r_length: 2 } }) +(42, Relocation { kind: GotRelative, encoding: X86RipRelativeMovq, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffffc, implicit_addend: true, flags: MachO { r_type: 3, r_pcrel: true, r_length: 2 } }) +(37, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Section(SectionIndex(2)), addend: fffffffffffffff8, implicit_addend: true, flags: MachO { r_type: 8, r_pcrel: true, r_length: 2 } }) +(2f, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Section(SectionIndex(2)), addend: fffffffffffffffa, implicit_addend: true, flags: MachO { r_type: 7, r_pcrel: true, r_length: 2 } }) +(27, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Section(SectionIndex(2)), addend: fffffffffffffffb, implicit_addend: true, flags: MachO { r_type: 6, r_pcrel: true, r_length: 2 } }) +(1d, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffff8, implicit_addend: true, flags: MachO { r_type: 8, r_pcrel: true, r_length: 2 } }) +(15, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffffa, implicit_addend: true, flags: MachO { r_type: 7, r_pcrel: true, r_length: 2 } }) +(d, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffffb, implicit_addend: true, flags: MachO { r_type: 6, r_pcrel: true, r_length: 2 } }) +(7, Relocation { kind: Relative, encoding: X86RipRelative, size: 20, target: Symbol(SymbolIndex(0)), addend: fffffffffffffffc, implicit_addend: true, flags: MachO { r_type: 1, r_pcrel: true, r_length: 2 } }) +(1, Relocation { kind: Relative, encoding: X86Branch, size: 20, target: Symbol(SymbolIndex(1)), addend: fffffffffffffffc, implicit_addend: true, flags: MachO { r_type: 2, r_pcrel: true, r_length: 2 } }) __data relocations -(10, Relocation { kind: MachO { value: 5, relative: false }, encoding: Generic, size: 40, target: Symbol(SymbolIndex(1)), addend: 0, implicit_addend: true }) -(10, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(0)), addend: 0, implicit_addend: true }) -(8, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(2)), addend: 0, implicit_addend: true }) -(0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(0)), addend: 0, implicit_addend: true }) +(10, Relocation { kind: Unknown, encoding: Generic, size: 40, target: Symbol(SymbolIndex(1)), addend: 0, implicit_addend: true, flags: MachO { r_type: 5, r_pcrel: false, r_length: 3 } }) +(10, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(0)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) +(8, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Section(SectionIndex(2)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) +(0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(0)), addend: 0, implicit_addend: true, flags: MachO { r_type: 0, r_pcrel: false, r_length: 3 } }) Dynamic symbols diff --git a/crates/examples/testfiles/pe/base-bigobj.o.objdump b/crates/examples/testfiles/pe/base-bigobj.o.objdump index 5ddc9f96..26730b06 100644 --- a/crates/examples/testfiles/pe/base-bigobj.o.objdump +++ b/crates/examples/testfiles/pe/base-bigobj.o.objdump @@ -35,18 +35,18 @@ Symbols 21: Symbol { name: "__mingw_vfprintf", address: 0, size: 0, kind: Text, section: Undefined, scope: Linkage, weak: false, flags: None } .text relocations -(2f, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(13)), addend: fffffffffffffffc, implicit_addend: true }) -(40, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(15)), addend: fffffffffffffffc, implicit_addend: true }) -(5a, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(14)), addend: fffffffffffffffc, implicit_addend: true }) -(61, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(f)), addend: fffffffffffffffc, implicit_addend: true }) +(2f, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(13)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 4 } }) +(40, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(15)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 4 } }) +(5a, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(14)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 4 } }) +(61, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(f)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 4 } }) .pdata relocations -(0, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true }) -(4, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true }) -(8, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true }) -(c, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true }) -(10, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true }) -(14, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true }) +(0, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) +(4, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) +(8, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) +(c, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) +(10, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) +(14, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) Dynamic symbols diff --git a/crates/examples/testfiles/pe/base-bigobj.obj.objdump b/crates/examples/testfiles/pe/base-bigobj.obj.objdump index a7a7a9a1..3ad0f95b 100644 --- a/crates/examples/testfiles/pe/base-bigobj.obj.objdump +++ b/crates/examples/testfiles/pe/base-bigobj.obj.objdump @@ -45,19 +45,19 @@ Symbols 24: Symbol { name: ".chks64", address: 0, size: 40, kind: Section, section: Section(SectionIndex(8)), scope: Compilation, weak: false, flags: CoffSection { selection: 0, associative_section: None } } .text$mn relocations -(4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(17)), addend: 0, implicit_addend: true }) -(9, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: fffffffffffffffc, implicit_addend: true }) +(4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(17)), addend: 0, implicit_addend: true, flags: Coff { typ: 6 } }) +(9, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 14 } }) .text$mn relocations -(4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true }) +(4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true, flags: Coff { typ: 6 } }) .text$mn relocations -(14, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(e)), addend: fffffffffffffffc, implicit_addend: true }) -(20, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(10)), addend: fffffffffffffffc, implicit_addend: true }) +(14, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(e)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 14 } }) +(20, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(10)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 14 } }) .text$mn relocations -(19, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(f)), addend: fffffffffffffffc, implicit_addend: true }) -(22, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(11)), addend: fffffffffffffffc, implicit_addend: true }) +(19, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(f)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 14 } }) +(22, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(11)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 14 } }) Dynamic symbols diff --git a/crates/examples/testfiles/pe/base.o.objdump b/crates/examples/testfiles/pe/base.o.objdump index f652bf1b..74af82de 100644 --- a/crates/examples/testfiles/pe/base.o.objdump +++ b/crates/examples/testfiles/pe/base.o.objdump @@ -35,18 +35,18 @@ Symbols 21: Symbol { name: "__mingw_vfprintf", address: 0, size: 0, kind: Text, section: Undefined, scope: Linkage, weak: false, flags: None } .text relocations -(2f, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(13)), addend: fffffffffffffffc, implicit_addend: true }) -(40, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(15)), addend: fffffffffffffffc, implicit_addend: true }) -(5a, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(14)), addend: fffffffffffffffc, implicit_addend: true }) -(61, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(f)), addend: fffffffffffffffc, implicit_addend: true }) +(2f, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(13)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 4 } }) +(40, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(15)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 4 } }) +(5a, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(14)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 4 } }) +(61, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(f)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 4 } }) .pdata relocations -(0, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true }) -(4, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true }) -(8, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true }) -(c, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true }) -(10, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true }) -(14, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true }) +(0, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) +(4, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) +(8, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) +(c, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) +(10, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) +(14, Relocation { kind: ImageOffset, encoding: Generic, size: 20, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true, flags: Coff { typ: 3 } }) Dynamic symbols diff --git a/crates/examples/testfiles/pe/base.obj.objdump b/crates/examples/testfiles/pe/base.obj.objdump index a7a7a9a1..3ad0f95b 100644 --- a/crates/examples/testfiles/pe/base.obj.objdump +++ b/crates/examples/testfiles/pe/base.obj.objdump @@ -45,19 +45,19 @@ Symbols 24: Symbol { name: ".chks64", address: 0, size: 40, kind: Section, section: Section(SectionIndex(8)), scope: Compilation, weak: false, flags: CoffSection { selection: 0, associative_section: None } } .text$mn relocations -(4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(17)), addend: 0, implicit_addend: true }) -(9, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: fffffffffffffffc, implicit_addend: true }) +(4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(17)), addend: 0, implicit_addend: true, flags: Coff { typ: 6 } }) +(9, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 14 } }) .text$mn relocations -(4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true }) +(4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true, flags: Coff { typ: 6 } }) .text$mn relocations -(14, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(e)), addend: fffffffffffffffc, implicit_addend: true }) -(20, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(10)), addend: fffffffffffffffc, implicit_addend: true }) +(14, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(e)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 14 } }) +(20, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(10)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 14 } }) .text$mn relocations -(19, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(f)), addend: fffffffffffffffc, implicit_addend: true }) -(22, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(11)), addend: fffffffffffffffc, implicit_addend: true }) +(19, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(f)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 14 } }) +(22, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(11)), addend: fffffffffffffffc, implicit_addend: true, flags: Coff { typ: 14 } }) Dynamic symbols diff --git a/crates/examples/testfiles/xcoff/base.o.objdump b/crates/examples/testfiles/xcoff/base.o.objdump index d02df3ab..917c4c2e 100644 --- a/crates/examples/testfiles/xcoff/base.o.objdump +++ b/crates/examples/testfiles/xcoff/base.o.objdump @@ -19,13 +19,13 @@ Symbols 17: Symbol { name: ".rodata.str1.1L...str", address: 80, size: 8, kind: Data, section: Section(SectionIndex(2)), scope: Compilation, weak: false, flags: Xcoff { n_sclass: 6b, x_smtyp: 19, x_smclas: 3, containing_csect: None } } .text relocations -(1e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(11)), addend: 0, implicit_addend: true }) -(20, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(3)), addend: fffffffffffffffc, implicit_addend: true }) +(1e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(11)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(20, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(3)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) .data relocations -(68, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(9)), addend: 0, implicit_addend: true }) -(70, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(f)), addend: 0, implicit_addend: true }) -(80, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true }) +(68, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(9)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(70, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(f)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(80, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) Dynamic symbols diff --git a/crates/examples/testfiles/xcoff/base.xcoff.objdump b/crates/examples/testfiles/xcoff/base.xcoff.objdump index b513b60a..af0f68dd 100644 --- a/crates/examples/testfiles/xcoff/base.xcoff.objdump +++ b/crates/examples/testfiles/xcoff/base.xcoff.objdump @@ -91,76 +91,76 @@ Symbols 154: Symbol { name: ".printf", address: 100000698, size: 0, kind: Text, section: Section(SectionIndex(1)), scope: Dynamic, weak: false, flags: Xcoff { n_sclass: 2, x_smtyp: 2, x_smclas: 6, containing_csect: Some(SymbolIndex(98)) } } .text relocations -(1000001fa, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(46)), addend: 0, implicit_addend: true }) -(1000001fe, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(16)), addend: 0, implicit_addend: true }) -(10000020e, Relocation { kind: Xcoff(13), encoding: Generic, size: 10, target: Symbol(SymbolIndex(18)), addend: 0, implicit_addend: true }) -(100000212, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(28)), addend: 0, implicit_addend: true }) -(100000216, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(2a)), addend: 0, implicit_addend: true }) -(10000021a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(3e)), addend: 0, implicit_addend: true }) -(10000021e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(40)), addend: 0, implicit_addend: true }) -(10000022e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(2c)), addend: 0, implicit_addend: true }) -(100000252, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(3e)), addend: 0, implicit_addend: true }) -(10000025a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(2e)), addend: 0, implicit_addend: true }) -(100000268, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(7f)), addend: fffffffffffffffc, implicit_addend: true }) -(100000272, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(42)), addend: 0, implicit_addend: true }) -(10000027e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(44)), addend: 0, implicit_addend: true }) -(100000280, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(86)), addend: fffffffffffffffc, implicit_addend: true }) -(1000002c2, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(56)), addend: 0, implicit_addend: true }) -(10000030a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(56)), addend: 0, implicit_addend: true }) -(10000032e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(58)), addend: 0, implicit_addend: true }) -(100000352, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(5a)), addend: 0, implicit_addend: true }) -(100000376, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(5c)), addend: 0, implicit_addend: true }) -(10000039a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(5e)), addend: 0, implicit_addend: true }) -(1000003ce, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(5c)), addend: 0, implicit_addend: true }) -(100000408, Relocation { kind: Xcoff(f), encoding: Generic, size: 40, target: Symbol(SymbolIndex(52)), addend: 0, implicit_addend: true }) -(100000454, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(8b)), addend: fffffffffffffffc, implicit_addend: true }) -(1000004a2, Relocation { kind: Xcoff(13), encoding: Generic, size: 10, target: Symbol(SymbolIndex(1c)), addend: 0, implicit_addend: true }) -(1000004aa, Relocation { kind: Xcoff(13), encoding: Generic, size: 10, target: Symbol(SymbolIndex(1e)), addend: 0, implicit_addend: true }) -(1000004cc, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(90)), addend: fffffffffffffffc, implicit_addend: true }) -(1000004d6, Relocation { kind: Xcoff(13), encoding: Generic, size: 10, target: Symbol(SymbolIndex(22)), addend: 0, implicit_addend: true }) -(1000004d8, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(95)), addend: fffffffffffffffc, implicit_addend: true }) -(100000540, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(8b)), addend: fffffffffffffffc, implicit_addend: true }) -(10000054c, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(86)), addend: fffffffffffffffc, implicit_addend: true }) -(10000059a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(1a)), addend: 0, implicit_addend: true }) -(1000005c2, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(20)), addend: 0, implicit_addend: true }) -(1000005ea, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(24)), addend: 0, implicit_addend: true }) -(100000612, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(26)), addend: 0, implicit_addend: true }) -(10000065e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(30)), addend: 0, implicit_addend: true }) -(100000660, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(9a)), addend: fffffffffffffffc, implicit_addend: true }) -(10000069a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(32)), addend: 0, implicit_addend: true }) +(1000001fa, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(46)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(1000001fe, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(16)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000020e, Relocation { kind: Unknown, encoding: Generic, size: 10, target: Symbol(SymbolIndex(18)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 13, r_rsize: 4f } }) +(100000212, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(28)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(100000216, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(2a)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000021a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(3e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000021e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(40)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000022e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(2c)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(100000252, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(3e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000025a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(2e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(100000268, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(7f)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(100000272, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(42)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000027e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(44)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(100000280, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(86)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(1000002c2, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(56)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(10000030a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(56)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(10000032e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(58)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(100000352, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(5a)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(100000376, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(5c)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(10000039a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(5e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(1000003ce, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(5c)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(100000408, Relocation { kind: Unknown, encoding: Generic, size: 40, target: Symbol(SymbolIndex(52)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: f, r_rsize: 3f } }) +(100000454, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(8b)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(1000004a2, Relocation { kind: Unknown, encoding: Generic, size: 10, target: Symbol(SymbolIndex(1c)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 13, r_rsize: cf } }) +(1000004aa, Relocation { kind: Unknown, encoding: Generic, size: 10, target: Symbol(SymbolIndex(1e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 13, r_rsize: cf } }) +(1000004cc, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(90)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(1000004d6, Relocation { kind: Unknown, encoding: Generic, size: 10, target: Symbol(SymbolIndex(22)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 13, r_rsize: cf } }) +(1000004d8, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(95)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(100000540, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(8b)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(10000054c, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(86)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(10000059a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(1a)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(1000005c2, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(20)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(1000005ea, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(24)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(100000612, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(26)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000065e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(30)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(100000660, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(9a)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(10000069a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(32)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) .data relocations -(1100006d0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(3e)), addend: 0, implicit_addend: true }) -(1100006d8, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(54)), addend: 0, implicit_addend: true }) -(1100006e0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(78)), addend: 0, implicit_addend: true }) -(110000728, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true }) -(110000798, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(74)), addend: 0, implicit_addend: true }) -(1100007b0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(70)), addend: 0, implicit_addend: true }) -(110000848, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(36)), addend: 0, implicit_addend: true }) -(110000850, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true }) -(110000858, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(4e)), addend: 0, implicit_addend: true }) -(110000860, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true }) -(110000870, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(6a)), addend: 0, implicit_addend: true }) -(110000878, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true }) -(110000888, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(6c)), addend: 0, implicit_addend: true }) -(110000890, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true }) -(1100008a0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(68)), addend: 0, implicit_addend: true }) -(1100008a8, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true }) -(110000900, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(10)), addend: 0, implicit_addend: true }) -(110000908, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(3c)), addend: 0, implicit_addend: true }) -(110000910, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(a)), addend: 0, implicit_addend: true }) -(110000918, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(6e)), addend: 0, implicit_addend: true }) -(110000920, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(72)), addend: 0, implicit_addend: true }) -(110000928, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(6)), addend: 0, implicit_addend: true }) -(110000930, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(76)), addend: 0, implicit_addend: true }) -(110000938, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(c)), addend: 0, implicit_addend: true }) -(110000940, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true }) -(110000948, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(e)), addend: 0, implicit_addend: true }) -(110000950, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(2)), addend: 0, implicit_addend: true }) -(110000958, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true }) -(110000960, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(0)), addend: 0, implicit_addend: true }) -(110000968, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(81)), addend: 0, implicit_addend: true }) -(110000970, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(8)), addend: 0, implicit_addend: true }) +(1100006d0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(3e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(1100006d8, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(54)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(1100006e0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(78)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000728, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000798, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(74)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(1100007b0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(70)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000848, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(36)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000850, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000858, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(4e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000860, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000870, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(6a)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000878, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000888, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(6c)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000890, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(1100008a0, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(68)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(1100008a8, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000900, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(10)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000908, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(3c)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000910, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(a)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000918, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(6e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000920, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(72)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000928, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(6)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000930, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(76)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000938, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(c)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000940, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000948, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000950, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(2)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000958, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000960, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(0)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000968, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(81)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) +(110000970, Relocation { kind: Absolute, encoding: Generic, size: 40, target: Symbol(SymbolIndex(8)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 3f } }) Dynamic symbols diff --git a/crates/examples/testfiles/xcoff/base32.o.objdump b/crates/examples/testfiles/xcoff/base32.o.objdump index 052e4d2c..70f3cfb3 100644 --- a/crates/examples/testfiles/xcoff/base32.o.objdump +++ b/crates/examples/testfiles/xcoff/base32.o.objdump @@ -19,13 +19,13 @@ Symbols 17: Symbol { name: ".rodata.str1.1L...str", address: 78, size: 4, kind: Data, section: Section(SectionIndex(2)), scope: Compilation, weak: false, flags: Xcoff { n_sclass: 6b, x_smtyp: 11, x_smclas: 3, containing_csect: None } } .text relocations -(22, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(11)), addend: 0, implicit_addend: true }) -(24, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(3)), addend: fffffffffffffffc, implicit_addend: true }) +(22, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(11)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(24, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(3)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) .data relocations -(6c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(9)), addend: 0, implicit_addend: true }) -(70, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(f)), addend: 0, implicit_addend: true }) -(78, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true }) +(6c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(9)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(70, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(f)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(78, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(b)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) Dynamic symbols diff --git a/crates/examples/testfiles/xcoff/base32.xcoff.objdump b/crates/examples/testfiles/xcoff/base32.xcoff.objdump index ee1c9fa0..98eda9bc 100644 --- a/crates/examples/testfiles/xcoff/base32.xcoff.objdump +++ b/crates/examples/testfiles/xcoff/base32.xcoff.objdump @@ -89,72 +89,72 @@ Symbols 150: Symbol { name: ".printf", address: 100005bc, size: 0, kind: Text, section: Section(SectionIndex(1)), scope: Dynamic, weak: false, flags: Xcoff { n_sclass: 2, x_smtyp: 2, x_smclas: 6, containing_csect: Some(SymbolIndex(94)) } } .text relocations -(1000012a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(42)), addend: 0, implicit_addend: true }) -(1000012e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true }) -(10000146, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(16)), addend: 0, implicit_addend: true }) -(1000014a, Relocation { kind: Xcoff(13), encoding: Generic, size: 10, target: Symbol(SymbolIndex(18)), addend: 0, implicit_addend: true }) -(1000014e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(3a)), addend: 0, implicit_addend: true }) -(10000152, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(3c)), addend: 0, implicit_addend: true }) -(10000162, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(28)), addend: 0, implicit_addend: true }) -(10000182, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(2a)), addend: 0, implicit_addend: true }) -(10000190, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(7b)), addend: fffffffffffffffc, implicit_addend: true }) -(1000019a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(3e)), addend: 0, implicit_addend: true }) -(100001a6, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(40)), addend: 0, implicit_addend: true }) -(100001a8, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(82)), addend: fffffffffffffffc, implicit_addend: true }) -(100001e2, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(52)), addend: 0, implicit_addend: true }) -(1000022a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(52)), addend: 0, implicit_addend: true }) -(1000024e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(54)), addend: 0, implicit_addend: true }) -(10000272, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(56)), addend: 0, implicit_addend: true }) -(10000296, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(58)), addend: 0, implicit_addend: true }) -(100002ba, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(5a)), addend: 0, implicit_addend: true }) -(100002ee, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(58)), addend: 0, implicit_addend: true }) -(10000328, Relocation { kind: Xcoff(f), encoding: Generic, size: 20, target: Symbol(SymbolIndex(4e)), addend: 0, implicit_addend: true }) -(10000374, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(87)), addend: fffffffffffffffc, implicit_addend: true }) -(100003c2, Relocation { kind: Xcoff(13), encoding: Generic, size: 10, target: Symbol(SymbolIndex(1c)), addend: 0, implicit_addend: true }) -(100003ca, Relocation { kind: Xcoff(13), encoding: Generic, size: 10, target: Symbol(SymbolIndex(1e)), addend: 0, implicit_addend: true }) -(100003ec, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(8c)), addend: fffffffffffffffc, implicit_addend: true }) -(100003f6, Relocation { kind: Xcoff(13), encoding: Generic, size: 10, target: Symbol(SymbolIndex(22)), addend: 0, implicit_addend: true }) -(100003f8, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(91)), addend: fffffffffffffffc, implicit_addend: true }) -(10000460, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(87)), addend: fffffffffffffffc, implicit_addend: true }) -(1000046c, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(82)), addend: fffffffffffffffc, implicit_addend: true }) -(100004ba, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(1a)), addend: 0, implicit_addend: true }) -(100004e2, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(20)), addend: 0, implicit_addend: true }) -(1000050a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(24)), addend: 0, implicit_addend: true }) -(10000532, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(26)), addend: 0, implicit_addend: true }) -(10000582, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(2c)), addend: 0, implicit_addend: true }) -(10000584, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(96)), addend: fffffffffffffffc, implicit_addend: true }) -(100005be, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(2e)), addend: 0, implicit_addend: true }) +(1000012a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(42)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(1000012e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(14)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000146, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(16)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(1000014a, Relocation { kind: Unknown, encoding: Generic, size: 10, target: Symbol(SymbolIndex(18)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 13, r_rsize: 4f } }) +(1000014e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(3a)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000152, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(3c)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000162, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(28)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000182, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(2a)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000190, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(7b)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(1000019a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(3e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(100001a6, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(40)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(100001a8, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(82)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(100001e2, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(52)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(1000022a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(52)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(1000024e, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(54)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(10000272, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(56)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(10000296, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(58)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(100002ba, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(5a)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(100002ee, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(58)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: 8f } }) +(10000328, Relocation { kind: Unknown, encoding: Generic, size: 20, target: Symbol(SymbolIndex(4e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: f, r_rsize: 1f } }) +(10000374, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(87)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(100003c2, Relocation { kind: Unknown, encoding: Generic, size: 10, target: Symbol(SymbolIndex(1c)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 13, r_rsize: cf } }) +(100003ca, Relocation { kind: Unknown, encoding: Generic, size: 10, target: Symbol(SymbolIndex(1e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 13, r_rsize: cf } }) +(100003ec, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(8c)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(100003f6, Relocation { kind: Unknown, encoding: Generic, size: 10, target: Symbol(SymbolIndex(22)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 13, r_rsize: cf } }) +(100003f8, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(91)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(10000460, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(87)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(1000046c, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(82)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(100004ba, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(1a)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(100004e2, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(20)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(1000050a, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(24)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000532, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(26)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000582, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(2c)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) +(10000584, Relocation { kind: Relative, encoding: Generic, size: 1a, target: Symbol(SymbolIndex(96)), addend: fffffffffffffffc, implicit_addend: true, flags: Xcoff { r_rtype: 1a, r_rsize: 99 } }) +(100005be, Relocation { kind: Got, encoding: Generic, size: 10, target: Symbol(SymbolIndex(2e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 3, r_rsize: f } }) .data relocations -(200005f4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3a)), addend: 0, implicit_addend: true }) -(200005f8, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(50)), addend: 0, implicit_addend: true }) -(20000600, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(74)), addend: 0, implicit_addend: true }) -(2000067c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(70)), addend: 0, implicit_addend: true }) -(2000068c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(6c)), addend: 0, implicit_addend: true }) -(20000710, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(32)), addend: 0, implicit_addend: true }) -(20000714, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true }) -(20000718, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(4a)), addend: 0, implicit_addend: true }) -(2000071c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true }) -(20000724, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(66)), addend: 0, implicit_addend: true }) -(20000728, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true }) -(20000730, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(68)), addend: 0, implicit_addend: true }) -(20000734, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true }) -(2000073c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(64)), addend: 0, implicit_addend: true }) -(20000740, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true }) -(20000770, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(e)), addend: 0, implicit_addend: true }) -(20000774, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(c)), addend: 0, implicit_addend: true }) -(20000778, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(38)), addend: 0, implicit_addend: true }) -(2000077c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(8)), addend: 0, implicit_addend: true }) -(20000780, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(6a)), addend: 0, implicit_addend: true }) -(20000784, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(6e)), addend: 0, implicit_addend: true }) -(20000788, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true }) -(2000078c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(72)), addend: 0, implicit_addend: true }) -(20000790, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(a)), addend: 0, implicit_addend: true }) -(20000794, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(2)), addend: 0, implicit_addend: true }) -(20000798, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(10)), addend: 0, implicit_addend: true }) -(2000079c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(0)), addend: 0, implicit_addend: true }) -(200007a0, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(7d)), addend: 0, implicit_addend: true }) -(200007a4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(6)), addend: 0, implicit_addend: true }) +(200005f4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3a)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(200005f8, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(50)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000600, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(74)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(2000067c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(70)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(2000068c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(6c)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000710, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(32)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000714, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000718, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(4a)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(2000071c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000724, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(66)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000728, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000730, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(68)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000734, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(2000073c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(64)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000740, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(12)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000770, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000774, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(c)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000778, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(38)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(2000077c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(8)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000780, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(6a)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000784, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(6e)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000788, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(4)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(2000078c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(72)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000790, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(a)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000794, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(2)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(20000798, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(10)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(2000079c, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(0)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(200007a0, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(7d)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) +(200007a4, Relocation { kind: Absolute, encoding: Generic, size: 20, target: Symbol(SymbolIndex(6)), addend: 0, implicit_addend: true, flags: Xcoff { r_rtype: 0, r_rsize: 1f } }) Dynamic symbols diff --git a/src/common.rs b/src/common.rs index 36f6656f..95dab61f 100644 --- a/src/common.rs +++ b/src/common.rs @@ -302,6 +302,8 @@ pub enum SymbolScope { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum RelocationKind { + /// The operation is unknown. + Unknown, /// S + A Absolute, /// S + A - P @@ -322,19 +324,6 @@ pub enum RelocationKind { SectionOffset, /// The index of the section containing the symbol. SectionIndex, - /// Some other ELF relocation. The value is dependent on the architecture. - Elf(u32), - /// Some other Mach-O relocation. The value is dependent on the architecture. - MachO { - /// The relocation type. - value: u8, - /// Whether the relocation is relative to the place. - relative: bool, - }, - /// 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. @@ -344,6 +333,8 @@ pub enum RelocationKind { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum RelocationEncoding { + /// The relocation encoding is unknown. + Unknown, /// Generic encoding. Generic, @@ -534,3 +525,44 @@ pub enum SymbolFlags { containing_csect: Option, }, } + +/// Relocation fields that are specific to each file format and architecture. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[non_exhaustive] +pub enum RelocationFlags { + /// Format independent representation. + Generic { + /// The operation used to calculate the result of the relocation. + kind: RelocationKind, + /// Information about how the result of the relocation operation is encoded in the place. + encoding: RelocationEncoding, + /// The size in bits of the place of relocation. + size: u8, + }, + /// ELF relocation fields. + Elf { + /// `r_type` field in the ELF relocation. + r_type: u32, + }, + /// Mach-O relocation fields. + MachO { + /// `r_type` field in the Mach-O relocation. + r_type: u8, + /// `r_pcrel` field in the Mach-O relocation. + r_pcrel: bool, + /// `r_length` field in the Mach-O relocation. + r_length: u8, + }, + /// COFF relocation fields. + Coff { + /// `typ` field in the COFF relocation. + typ: u16, + }, + /// XCOFF relocation fields. + Xcoff { + /// `r_rtype` field in the XCOFF relocation. + r_rtype: u8, + /// `r_rsize` field in the XCOFF relocation. + r_rsize: u8, + }, +} diff --git a/src/read/coff/relocation.rs b/src/read/coff/relocation.rs index e9909448..b5265bd7 100644 --- a/src/read/coff/relocation.rs +++ b/src/read/coff/relocation.rs @@ -4,7 +4,8 @@ use core::slice; use crate::endian::LittleEndian as LE; use crate::pe; use crate::read::{ - ReadRef, Relocation, RelocationEncoding, RelocationKind, RelocationTarget, SymbolIndex, + ReadRef, Relocation, RelocationEncoding, RelocationFlags, RelocationKind, RelocationTarget, + SymbolIndex, }; use super::{CoffFile, CoffHeader}; @@ -31,27 +32,27 @@ impl<'data, 'file, R: ReadRef<'data>, Coff: CoffHeader> Iterator fn next(&mut self) -> Option { self.iter.next().map(|relocation| { + let typ = relocation.typ.get(LE); + let flags = RelocationFlags::Coff { typ }; let (kind, size, addend) = match self.file.header.machine() { - pe::IMAGE_FILE_MACHINE_ARMNT => match relocation.typ.get(LE) { + pe::IMAGE_FILE_MACHINE_ARMNT => match typ { pe::IMAGE_REL_ARM_ADDR32 => (RelocationKind::Absolute, 32, 0), pe::IMAGE_REL_ARM_ADDR32NB => (RelocationKind::ImageOffset, 32, 0), pe::IMAGE_REL_ARM_REL32 => (RelocationKind::Relative, 32, -4), pe::IMAGE_REL_ARM_SECTION => (RelocationKind::SectionIndex, 16, 0), pe::IMAGE_REL_ARM_SECREL => (RelocationKind::SectionOffset, 32, 0), - typ => (RelocationKind::Coff(typ), 0, 0), + _ => (RelocationKind::Unknown, 0, 0), }, - pe::IMAGE_FILE_MACHINE_ARM64 | pe::IMAGE_FILE_MACHINE_ARM64EC => { - match relocation.typ.get(LE) { - pe::IMAGE_REL_ARM64_ADDR32 => (RelocationKind::Absolute, 32, 0), - pe::IMAGE_REL_ARM64_ADDR32NB => (RelocationKind::ImageOffset, 32, 0), - pe::IMAGE_REL_ARM64_SECREL => (RelocationKind::SectionOffset, 32, 0), - pe::IMAGE_REL_ARM64_SECTION => (RelocationKind::SectionIndex, 16, 0), - pe::IMAGE_REL_ARM64_ADDR64 => (RelocationKind::Absolute, 64, 0), - pe::IMAGE_REL_ARM64_REL32 => (RelocationKind::Relative, 32, -4), - typ => (RelocationKind::Coff(typ), 0, 0), - } - } - pe::IMAGE_FILE_MACHINE_I386 => match relocation.typ.get(LE) { + pe::IMAGE_FILE_MACHINE_ARM64 | pe::IMAGE_FILE_MACHINE_ARM64EC => match typ { + pe::IMAGE_REL_ARM64_ADDR32 => (RelocationKind::Absolute, 32, 0), + pe::IMAGE_REL_ARM64_ADDR32NB => (RelocationKind::ImageOffset, 32, 0), + pe::IMAGE_REL_ARM64_SECREL => (RelocationKind::SectionOffset, 32, 0), + pe::IMAGE_REL_ARM64_SECTION => (RelocationKind::SectionIndex, 16, 0), + pe::IMAGE_REL_ARM64_ADDR64 => (RelocationKind::Absolute, 64, 0), + pe::IMAGE_REL_ARM64_REL32 => (RelocationKind::Relative, 32, -4), + _ => (RelocationKind::Unknown, 0, 0), + }, + pe::IMAGE_FILE_MACHINE_I386 => match typ { pe::IMAGE_REL_I386_DIR16 => (RelocationKind::Absolute, 16, 0), pe::IMAGE_REL_I386_REL16 => (RelocationKind::Relative, 16, 0), pe::IMAGE_REL_I386_DIR32 => (RelocationKind::Absolute, 32, 0), @@ -60,9 +61,9 @@ impl<'data, 'file, R: ReadRef<'data>, Coff: CoffHeader> Iterator pe::IMAGE_REL_I386_SECREL => (RelocationKind::SectionOffset, 32, 0), pe::IMAGE_REL_I386_SECREL7 => (RelocationKind::SectionOffset, 7, 0), pe::IMAGE_REL_I386_REL32 => (RelocationKind::Relative, 32, -4), - typ => (RelocationKind::Coff(typ), 0, 0), + _ => (RelocationKind::Unknown, 0, 0), }, - pe::IMAGE_FILE_MACHINE_AMD64 => match relocation.typ.get(LE) { + pe::IMAGE_FILE_MACHINE_AMD64 => match typ { pe::IMAGE_REL_AMD64_ADDR64 => (RelocationKind::Absolute, 64, 0), pe::IMAGE_REL_AMD64_ADDR32 => (RelocationKind::Absolute, 32, 0), pe::IMAGE_REL_AMD64_ADDR32NB => (RelocationKind::ImageOffset, 32, 0), @@ -75,9 +76,9 @@ impl<'data, 'file, R: ReadRef<'data>, Coff: CoffHeader> Iterator pe::IMAGE_REL_AMD64_SECTION => (RelocationKind::SectionIndex, 16, 0), pe::IMAGE_REL_AMD64_SECREL => (RelocationKind::SectionOffset, 32, 0), pe::IMAGE_REL_AMD64_SECREL7 => (RelocationKind::SectionOffset, 7, 0), - typ => (RelocationKind::Coff(typ), 0, 0), + _ => (RelocationKind::Unknown, 0, 0), }, - _ => (RelocationKind::Coff(relocation.typ.get(LE)), 0, 0), + _ => (RelocationKind::Unknown, 0, 0), }; let target = RelocationTarget::Symbol(SymbolIndex( relocation.symbol_table_index.get(LE) as usize, @@ -91,6 +92,7 @@ impl<'data, 'file, R: ReadRef<'data>, Coff: CoffHeader> Iterator target, addend, implicit_addend: true, + flags, }, ) }) diff --git a/src/read/elf/relocation.rs b/src/read/elf/relocation.rs index aac1574e..1f43efe5 100644 --- a/src/read/elf/relocation.rs +++ b/src/read/elf/relocation.rs @@ -7,8 +7,8 @@ use crate::elf; use crate::endian::{self, Endianness}; use crate::pod::Pod; use crate::read::{ - self, Error, ReadRef, Relocation, RelocationEncoding, RelocationKind, RelocationTarget, - SectionIndex, SymbolIndex, + self, Error, ReadRef, Relocation, RelocationEncoding, RelocationFlags, RelocationKind, + RelocationTarget, SectionIndex, SymbolIndex, }; use super::{ElfFile, FileHeader, SectionHeader, SectionTable}; @@ -239,10 +239,12 @@ fn parse_relocation( ) -> Relocation { let mut encoding = RelocationEncoding::Generic; let is_mips64el = header.is_mips64el(endian); + let r_type = reloc.r_type(endian, is_mips64el); + let flags = RelocationFlags::Elf { r_type }; let (kind, size) = match header.e_machine(endian) { elf::EM_AARCH64 => { if header.is_type_64() { - match reloc.r_type(endian, false) { + match r_type { elf::R_AARCH64_ABS64 => (RelocationKind::Absolute, 64), elf::R_AARCH64_ABS32 => (RelocationKind::Absolute, 32), elf::R_AARCH64_ABS16 => (RelocationKind::Absolute, 16), @@ -253,35 +255,35 @@ fn parse_relocation( encoding = RelocationEncoding::AArch64Call; (RelocationKind::PltRelative, 26) } - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), } } else { - match reloc.r_type(endian, false) { + match r_type { elf::R_AARCH64_P32_ABS32 => (RelocationKind::Absolute, 32), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), } } } - elf::EM_ARM => match reloc.r_type(endian, false) { + elf::EM_ARM => match r_type { elf::R_ARM_ABS32 => (RelocationKind::Absolute, 32), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_AVR => match reloc.r_type(endian, false) { + elf::EM_AVR => match r_type { elf::R_AVR_32 => (RelocationKind::Absolute, 32), elf::R_AVR_16 => (RelocationKind::Absolute, 16), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_BPF => match reloc.r_type(endian, false) { + elf::EM_BPF => match r_type { elf::R_BPF_64_64 => (RelocationKind::Absolute, 64), elf::R_BPF_64_32 => (RelocationKind::Absolute, 32), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_CSKY => match reloc.r_type(endian, false) { + elf::EM_CSKY => match r_type { elf::R_CKCORE_ADDR32 => (RelocationKind::Absolute, 32), elf::R_CKCORE_PCREL32 => (RelocationKind::Relative, 32), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_386 => match reloc.r_type(endian, false) { + elf::EM_386 => match r_type { elf::R_386_32 => (RelocationKind::Absolute, 32), elf::R_386_PC32 => (RelocationKind::Relative, 32), elf::R_386_GOT32 => (RelocationKind::Got, 32), @@ -292,9 +294,9 @@ fn parse_relocation( elf::R_386_PC16 => (RelocationKind::Relative, 16), elf::R_386_8 => (RelocationKind::Absolute, 8), elf::R_386_PC8 => (RelocationKind::Relative, 8), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_X86_64 => match reloc.r_type(endian, false) { + elf::EM_X86_64 => match r_type { elf::R_X86_64_64 => (RelocationKind::Absolute, 64), elf::R_X86_64_PC32 => (RelocationKind::Relative, 32), elf::R_X86_64_GOT32 => (RelocationKind::Got, 32), @@ -309,13 +311,13 @@ fn parse_relocation( elf::R_X86_64_PC16 => (RelocationKind::Relative, 16), elf::R_X86_64_8 => (RelocationKind::Absolute, 8), elf::R_X86_64_PC8 => (RelocationKind::Relative, 8), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_HEXAGON => match reloc.r_type(endian, false) { + elf::EM_HEXAGON => match r_type { elf::R_HEX_32 => (RelocationKind::Absolute, 32), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_LOONGARCH => match reloc.r_type(endian, false) { + elf::EM_LOONGARCH => match r_type { elf::R_LARCH_32 => (RelocationKind::Absolute, 32), elf::R_LARCH_64 => (RelocationKind::Absolute, 64), elf::R_LARCH_32_PCREL => (RelocationKind::Relative, 32), @@ -332,34 +334,34 @@ fn parse_relocation( encoding = RelocationEncoding::LoongArchBranch; (RelocationKind::Relative, 26) } - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_MIPS => match reloc.r_type(endian, is_mips64el) { + elf::EM_MIPS => match r_type { elf::R_MIPS_16 => (RelocationKind::Absolute, 16), elf::R_MIPS_32 => (RelocationKind::Absolute, 32), elf::R_MIPS_64 => (RelocationKind::Absolute, 64), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_MSP430 => match reloc.r_type(endian, false) { + elf::EM_MSP430 => match r_type { elf::R_MSP430_32 => (RelocationKind::Absolute, 32), elf::R_MSP430_16_BYTE => (RelocationKind::Absolute, 16), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_PPC => match reloc.r_type(endian, false) { + elf::EM_PPC => match r_type { elf::R_PPC_ADDR32 => (RelocationKind::Absolute, 32), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_PPC64 => match reloc.r_type(endian, false) { + elf::EM_PPC64 => match r_type { elf::R_PPC64_ADDR32 => (RelocationKind::Absolute, 32), elf::R_PPC64_ADDR64 => (RelocationKind::Absolute, 64), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_RISCV => match reloc.r_type(endian, false) { + elf::EM_RISCV => match r_type { elf::R_RISCV_32 => (RelocationKind::Absolute, 32), elf::R_RISCV_64 => (RelocationKind::Absolute, 64), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_S390 => match reloc.r_type(endian, false) { + elf::EM_S390 => match r_type { elf::R_390_8 => (RelocationKind::Absolute, 8), elf::R_390_16 => (RelocationKind::Absolute, 16), elf::R_390_32 => (RelocationKind::Absolute, 32), @@ -398,14 +400,14 @@ fn parse_relocation( encoding = RelocationEncoding::S390xDbl; (RelocationKind::GotBaseRelative, 32) } - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_SBF => match reloc.r_type(endian, false) { + elf::EM_SBF => match r_type { elf::R_SBF_64_64 => (RelocationKind::Absolute, 64), elf::R_SBF_64_32 => (RelocationKind::Absolute, 32), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_SHARC => match reloc.r_type(endian, false) { + elf::EM_SHARC => match r_type { elf::R_SHARC_ADDR24_V3 => { encoding = RelocationEncoding::SharcTypeA; (RelocationKind::Absolute, 24) @@ -454,21 +456,19 @@ fn parse_relocation( encoding = RelocationEncoding::Generic; (RelocationKind::Absolute, 16) } - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - elf::EM_SPARC | elf::EM_SPARC32PLUS | elf::EM_SPARCV9 => { - match reloc.r_type(endian, false) { - elf::R_SPARC_32 | elf::R_SPARC_UA32 => (RelocationKind::Absolute, 32), - elf::R_SPARC_64 | elf::R_SPARC_UA64 => (RelocationKind::Absolute, 64), - r_type => (RelocationKind::Elf(r_type), 0), - } - } - elf::EM_XTENSA => match reloc.r_type(endian, false) { + elf::EM_SPARC | elf::EM_SPARC32PLUS | elf::EM_SPARCV9 => match r_type { + elf::R_SPARC_32 | elf::R_SPARC_UA32 => (RelocationKind::Absolute, 32), + elf::R_SPARC_64 | elf::R_SPARC_UA64 => (RelocationKind::Absolute, 64), + _ => (RelocationKind::Unknown, 0), + }, + elf::EM_XTENSA => match r_type { elf::R_XTENSA_32 => (RelocationKind::Absolute, 32), elf::R_XTENSA_32_PCREL => (RelocationKind::Relative, 32), - r_type => (RelocationKind::Elf(r_type), 0), + _ => (RelocationKind::Unknown, 0), }, - _ => (RelocationKind::Elf(reloc.r_type(endian, false)), 0), + _ => (RelocationKind::Unknown, 0), }; let sym = reloc.r_sym(endian, is_mips64el) as usize; let target = if sym == 0 { @@ -483,6 +483,7 @@ fn parse_relocation( target, addend: reloc.r_addend(endian).into(), implicit_addend, + flags, } } diff --git a/src/read/macho/relocation.rs b/src/read/macho/relocation.rs index 709f1a44..30988d69 100644 --- a/src/read/macho/relocation.rs +++ b/src/read/macho/relocation.rs @@ -3,8 +3,8 @@ use core::{fmt, slice}; use crate::endian::Endianness; use crate::macho; use crate::read::{ - ReadRef, Relocation, RelocationEncoding, RelocationKind, RelocationTarget, SectionIndex, - SymbolIndex, + ReadRef, Relocation, RelocationEncoding, RelocationFlags, RelocationKind, RelocationTarget, + SectionIndex, SymbolIndex, }; use super::{MachHeader, MachOFile}; @@ -45,14 +45,16 @@ where continue; } let reloc = reloc.info(self.file.endian); + let flags = RelocationFlags::MachO { + r_type: reloc.r_type, + r_pcrel: reloc.r_pcrel, + r_length: reloc.r_length, + }; let mut encoding = RelocationEncoding::Generic; let kind = match cputype { macho::CPU_TYPE_ARM => match (reloc.r_type, reloc.r_pcrel) { (macho::ARM_RELOC_VANILLA, false) => RelocationKind::Absolute, - _ => RelocationKind::MachO { - value: reloc.r_type, - relative: reloc.r_pcrel, - }, + _ => RelocationKind::Unknown, }, macho::CPU_TYPE_ARM64 | macho::CPU_TYPE_ARM64_32 => { match (reloc.r_type, reloc.r_pcrel) { @@ -63,18 +65,12 @@ where .wrapping_shr(64 - 24); continue; } - _ => RelocationKind::MachO { - value: reloc.r_type, - relative: reloc.r_pcrel, - }, + _ => RelocationKind::Unknown, } } macho::CPU_TYPE_X86 => match (reloc.r_type, reloc.r_pcrel) { (macho::GENERIC_RELOC_VANILLA, false) => RelocationKind::Absolute, - _ => RelocationKind::MachO { - value: reloc.r_type, - relative: reloc.r_pcrel, - }, + _ => RelocationKind::Unknown, }, macho::CPU_TYPE_X86_64 => match (reloc.r_type, reloc.r_pcrel) { (macho::X86_64_RELOC_UNSIGNED, false) => RelocationKind::Absolute, @@ -91,15 +87,9 @@ where encoding = RelocationEncoding::X86RipRelativeMovq; RelocationKind::GotRelative } - _ => RelocationKind::MachO { - value: reloc.r_type, - relative: reloc.r_pcrel, - }, - }, - _ => RelocationKind::MachO { - value: reloc.r_type, - relative: reloc.r_pcrel, + _ => RelocationKind::Unknown, }, + _ => RelocationKind::Unknown, }; let size = 8 << reloc.r_length; let target = if reloc.r_extern { @@ -141,6 +131,7 @@ where target, addend, implicit_addend, + flags, }, )); } diff --git a/src/read/mod.rs b/src/read/mod.rs index c13e3091..10d3ef96 100644 --- a/src/read/mod.rs +++ b/src/read/mod.rs @@ -667,6 +667,7 @@ pub struct Relocation { target: RelocationTarget, addend: i64, implicit_addend: bool, + flags: RelocationFlags, } impl Relocation { @@ -702,18 +703,21 @@ impl Relocation { self.addend } - /// Set the addend to use in the relocation calculation. - #[inline] - pub fn set_addend(&mut self, addend: i64) { - self.addend = addend - } - /// Returns true if there is an implicit addend stored in the data at the offset /// to be relocated. #[inline] pub fn has_implicit_addend(&self) -> bool { self.implicit_addend } + + /// Relocation flags that are specific to each file format. + /// + /// The values returned by `kind`, `encoding` and `size` are derived + /// from these flags. + #[inline] + pub fn flags(&self) -> RelocationFlags { + self.flags + } } /// A data compression format. diff --git a/src/read/xcoff/relocation.rs b/src/read/xcoff/relocation.rs index a655cccf..07b08a03 100644 --- a/src/read/xcoff/relocation.rs +++ b/src/read/xcoff/relocation.rs @@ -5,7 +5,9 @@ use core::slice; use crate::pod::Pod; use crate::{xcoff, BigEndian as BE, Relocation}; -use crate::read::{ReadRef, RelocationEncoding, RelocationKind, RelocationTarget, SymbolIndex}; +use crate::read::{ + ReadRef, RelocationEncoding, RelocationFlags, RelocationKind, RelocationTarget, SymbolIndex, +}; use super::{FileHeader, SectionHeader, XcoffFile}; @@ -37,8 +39,11 @@ where fn next(&mut self) -> Option { self.relocations.next().map(|relocation| { + let r_rtype = relocation.r_rtype(); + let r_rsize = relocation.r_rsize(); + let flags = RelocationFlags::Xcoff { r_rtype, r_rsize }; let encoding = RelocationEncoding::Generic; - let (kind, addend) = match relocation.r_rtype() { + let (kind, addend) = match r_rtype { xcoff::R_POS | xcoff::R_RL | xcoff::R_RLA @@ -47,9 +52,9 @@ where | 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), + _ => (RelocationKind::Unknown, 0), }; - let size = (relocation.r_rsize() & 0x3F) + 1; + let size = (r_rsize & 0x3F) + 1; let target = RelocationTarget::Symbol(SymbolIndex(relocation.r_symndx() as usize)); ( relocation.r_vaddr().into(), @@ -60,6 +65,7 @@ where target, addend, implicit_addend: true, + flags, }, ) }) diff --git a/src/write/coff/object.rs b/src/write/coff/object.rs index 52296659..6f01e508 100644 --- a/src/write/coff/object.rs +++ b/src/write/coff/object.rs @@ -81,49 +81,198 @@ impl<'a> Object<'a> { name } - pub(crate) fn coff_fixup_relocation(&mut self, relocation: &mut Relocation) -> i64 { - if relocation.kind == RelocationKind::GotRelative { + pub(crate) fn coff_translate_relocation(&mut self, reloc: &mut Relocation) -> Result<()> { + let (mut kind, _encoding, size) = if let RelocationFlags::Generic { + kind, + encoding, + size, + } = reloc.flags + { + (kind, encoding, size) + } else { + return Ok(()); + }; + if kind == RelocationKind::GotRelative { // Use a stub symbol for the relocation instead. // This isn't really a GOT, but it's a similar purpose. // TODO: need to handle DLL imports differently? - relocation.kind = RelocationKind::Relative; - relocation.symbol = self.coff_add_stub_symbol(relocation.symbol); - } else if relocation.kind == RelocationKind::PltRelative { + kind = RelocationKind::Relative; + reloc.symbol = self.coff_add_stub_symbol(reloc.symbol)?; + } else if kind == RelocationKind::PltRelative { // Windows doesn't need a separate relocation type for // references to functions in import libraries. // For convenience, treat this the same as Relative. - relocation.kind = RelocationKind::Relative; + kind = RelocationKind::Relative; } - let constant = match self.architecture { - Architecture::I386 | Architecture::Arm | Architecture::Aarch64 => match relocation.kind - { - RelocationKind::Relative => { - // IMAGE_REL_I386_REL32, IMAGE_REL_ARM_REL32, IMAGE_REL_ARM64_REL32 - relocation.addend + 4 + let typ = match self.architecture { + Architecture::I386 => match (kind, size) { + (RelocationKind::Absolute, 16) => coff::IMAGE_REL_I386_DIR16, + (RelocationKind::Relative, 16) => coff::IMAGE_REL_I386_REL16, + (RelocationKind::Absolute, 32) => coff::IMAGE_REL_I386_DIR32, + (RelocationKind::ImageOffset, 32) => coff::IMAGE_REL_I386_DIR32NB, + (RelocationKind::SectionIndex, 16) => coff::IMAGE_REL_I386_SECTION, + (RelocationKind::SectionOffset, 32) => coff::IMAGE_REL_I386_SECREL, + (RelocationKind::SectionOffset, 7) => coff::IMAGE_REL_I386_SECREL7, + (RelocationKind::Relative, 32) => coff::IMAGE_REL_I386_REL32, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); } - _ => relocation.addend, }, - Architecture::X86_64 => match relocation.kind { - RelocationKind::Relative => { - // IMAGE_REL_AMD64_REL32 through to IMAGE_REL_AMD64_REL32_5 - if relocation.addend <= -4 && relocation.addend >= -9 { - 0 - } else { - relocation.addend + 4 - } + Architecture::X86_64 => match (kind, size) { + (RelocationKind::Absolute, 64) => coff::IMAGE_REL_AMD64_ADDR64, + (RelocationKind::Absolute, 32) => coff::IMAGE_REL_AMD64_ADDR32, + (RelocationKind::ImageOffset, 32) => coff::IMAGE_REL_AMD64_ADDR32NB, + (RelocationKind::Relative, 32) => match reloc.addend { + -5 => coff::IMAGE_REL_AMD64_REL32_1, + -6 => coff::IMAGE_REL_AMD64_REL32_2, + -7 => coff::IMAGE_REL_AMD64_REL32_3, + -8 => coff::IMAGE_REL_AMD64_REL32_4, + -9 => coff::IMAGE_REL_AMD64_REL32_5, + _ => coff::IMAGE_REL_AMD64_REL32, + }, + (RelocationKind::SectionIndex, 16) => coff::IMAGE_REL_AMD64_SECTION, + (RelocationKind::SectionOffset, 32) => coff::IMAGE_REL_AMD64_SECREL, + (RelocationKind::SectionOffset, 7) => coff::IMAGE_REL_AMD64_SECREL7, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Arm => match (kind, size) { + (RelocationKind::Absolute, 32) => coff::IMAGE_REL_ARM_ADDR32, + (RelocationKind::ImageOffset, 32) => coff::IMAGE_REL_ARM_ADDR32NB, + (RelocationKind::Relative, 32) => coff::IMAGE_REL_ARM_REL32, + (RelocationKind::SectionIndex, 16) => coff::IMAGE_REL_ARM_SECTION, + (RelocationKind::SectionOffset, 32) => coff::IMAGE_REL_ARM_SECREL, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Aarch64 => match (kind, size) { + (RelocationKind::Absolute, 32) => coff::IMAGE_REL_ARM64_ADDR32, + (RelocationKind::ImageOffset, 32) => coff::IMAGE_REL_ARM64_ADDR32NB, + (RelocationKind::SectionIndex, 16) => coff::IMAGE_REL_ARM64_SECTION, + (RelocationKind::SectionOffset, 32) => coff::IMAGE_REL_ARM64_SECREL, + (RelocationKind::Absolute, 64) => coff::IMAGE_REL_ARM64_ADDR64, + (RelocationKind::Relative, 32) => coff::IMAGE_REL_ARM64_REL32, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); } - _ => relocation.addend, }, - _ => unimplemented!(), + _ => { + return Err(Error(format!( + "unimplemented architecture {:?}", + self.architecture + ))); + } }; - relocation.addend -= constant; - constant + reloc.flags = RelocationFlags::Coff { typ }; + Ok(()) } - fn coff_add_stub_symbol(&mut self, symbol_id: SymbolId) -> SymbolId { + pub(crate) fn coff_adjust_addend(&self, relocation: &mut Relocation) -> Result { + let typ = if let RelocationFlags::Coff { typ } = relocation.flags { + typ + } else { + return Err(Error(format!("invalid relocation flags {:?}", relocation))); + }; + let offset = match self.architecture { + Architecture::Arm => { + if typ == coff::IMAGE_REL_ARM_REL32 { + 4 + } else { + 0 + } + } + Architecture::Aarch64 => { + if typ == coff::IMAGE_REL_ARM64_REL32 { + 4 + } else { + 0 + } + } + Architecture::I386 => { + if typ == coff::IMAGE_REL_I386_REL32 { + 4 + } else { + 0 + } + } + Architecture::X86_64 => match typ { + coff::IMAGE_REL_AMD64_REL32 => 4, + coff::IMAGE_REL_AMD64_REL32_1 => 5, + coff::IMAGE_REL_AMD64_REL32_2 => 6, + coff::IMAGE_REL_AMD64_REL32_3 => 7, + coff::IMAGE_REL_AMD64_REL32_4 => 8, + coff::IMAGE_REL_AMD64_REL32_5 => 9, + _ => 0, + }, + _ => return Err(Error(format!("unimplemented relocation {:?}", relocation))), + }; + relocation.addend += offset; + Ok(true) + } + + pub(crate) fn coff_relocation_size(&self, reloc: &Relocation) -> Result { + let typ = if let RelocationFlags::Coff { typ } = reloc.flags { + typ + } else { + return Err(Error(format!("unexpected relocation for size {:?}", reloc))); + }; + let size = match self.architecture { + Architecture::I386 => match typ { + coff::IMAGE_REL_I386_DIR16 + | coff::IMAGE_REL_I386_REL16 + | coff::IMAGE_REL_I386_SECTION => Some(16), + coff::IMAGE_REL_I386_DIR32 + | coff::IMAGE_REL_I386_DIR32NB + | coff::IMAGE_REL_I386_SECREL + | coff::IMAGE_REL_I386_TOKEN + | coff::IMAGE_REL_I386_REL32 => Some(32), + _ => None, + }, + Architecture::X86_64 => match typ { + coff::IMAGE_REL_AMD64_SECTION => Some(16), + coff::IMAGE_REL_AMD64_ADDR32 + | coff::IMAGE_REL_AMD64_ADDR32NB + | coff::IMAGE_REL_AMD64_REL32 + | coff::IMAGE_REL_AMD64_REL32_1 + | coff::IMAGE_REL_AMD64_REL32_2 + | coff::IMAGE_REL_AMD64_REL32_3 + | coff::IMAGE_REL_AMD64_REL32_4 + | coff::IMAGE_REL_AMD64_REL32_5 + | coff::IMAGE_REL_AMD64_SECREL + | coff::IMAGE_REL_AMD64_TOKEN => Some(32), + coff::IMAGE_REL_AMD64_ADDR64 => Some(64), + _ => None, + }, + Architecture::Arm => match typ { + coff::IMAGE_REL_ARM_SECTION => Some(16), + coff::IMAGE_REL_ARM_ADDR32 + | coff::IMAGE_REL_ARM_ADDR32NB + | coff::IMAGE_REL_ARM_TOKEN + | coff::IMAGE_REL_ARM_REL32 + | coff::IMAGE_REL_ARM_SECREL => Some(32), + _ => None, + }, + Architecture::Aarch64 => match typ { + coff::IMAGE_REL_ARM64_SECTION => Some(16), + coff::IMAGE_REL_ARM64_ADDR32 + | coff::IMAGE_REL_ARM64_ADDR32NB + | coff::IMAGE_REL_ARM64_SECREL + | coff::IMAGE_REL_ARM64_TOKEN + | coff::IMAGE_REL_ARM64_REL32 => Some(32), + coff::IMAGE_REL_ARM64_ADDR64 => Some(64), + _ => None, + }, + _ => None, + }; + size.ok_or_else(|| Error(format!("unsupported relocation for size {:?}", reloc))) + } + + fn coff_add_stub_symbol(&mut self, symbol_id: SymbolId) -> Result { if let Some(stub_id) = self.stub_symbols.get(&symbol_id) { - return *stub_id; + return Ok(*stub_id); } let stub_size = self.architecture.address_size().unwrap().bytes(); @@ -131,14 +280,19 @@ impl<'a> Object<'a> { let section_id = self.add_section(Vec::new(), name, SectionKind::ReadOnlyData); let section = self.section_mut(section_id); section.set_data(vec![0; stub_size as usize], u64::from(stub_size)); - section.relocations = vec![Relocation { - offset: 0, - size: stub_size * 8, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, - symbol: symbol_id, - addend: 0, - }]; + self.add_relocation( + section_id, + Relocation { + offset: 0, + symbol: symbol_id, + addend: 0, + flags: RelocationFlags::Generic { + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: stub_size * 8, + }, + }, + )?; let mut name = b".refptr.".to_vec(); name.extend_from_slice(&self.symbol(symbol_id).name); @@ -154,7 +308,7 @@ impl<'a> Object<'a> { }); self.stub_symbols.insert(symbol_id, stub_id); - stub_id + Ok(stub_id) } /// Appends linker directives to the `.drectve` section to tell the linker @@ -390,69 +544,10 @@ impl<'a> Object<'a> { //debug_assert_eq!(section_offsets[index].reloc_offset, buffer.len()); writer.write_relocations_count(section.relocations.len()); for reloc in §ion.relocations { - //assert!(reloc.implicit_addend); - let typ = match self.architecture { - Architecture::I386 => match (reloc.kind, reloc.size, reloc.addend) { - (RelocationKind::Absolute, 16, 0) => coff::IMAGE_REL_I386_DIR16, - (RelocationKind::Relative, 16, 0) => coff::IMAGE_REL_I386_REL16, - (RelocationKind::Absolute, 32, 0) => coff::IMAGE_REL_I386_DIR32, - (RelocationKind::ImageOffset, 32, 0) => coff::IMAGE_REL_I386_DIR32NB, - (RelocationKind::SectionIndex, 16, 0) => coff::IMAGE_REL_I386_SECTION, - (RelocationKind::SectionOffset, 32, 0) => coff::IMAGE_REL_I386_SECREL, - (RelocationKind::SectionOffset, 7, 0) => coff::IMAGE_REL_I386_SECREL7, - (RelocationKind::Relative, 32, -4) => coff::IMAGE_REL_I386_REL32, - (RelocationKind::Coff(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::X86_64 => match (reloc.kind, reloc.size, reloc.addend) { - (RelocationKind::Absolute, 64, 0) => coff::IMAGE_REL_AMD64_ADDR64, - (RelocationKind::Absolute, 32, 0) => coff::IMAGE_REL_AMD64_ADDR32, - (RelocationKind::ImageOffset, 32, 0) => coff::IMAGE_REL_AMD64_ADDR32NB, - (RelocationKind::Relative, 32, -4) => coff::IMAGE_REL_AMD64_REL32, - (RelocationKind::Relative, 32, -5) => coff::IMAGE_REL_AMD64_REL32_1, - (RelocationKind::Relative, 32, -6) => coff::IMAGE_REL_AMD64_REL32_2, - (RelocationKind::Relative, 32, -7) => coff::IMAGE_REL_AMD64_REL32_3, - (RelocationKind::Relative, 32, -8) => coff::IMAGE_REL_AMD64_REL32_4, - (RelocationKind::Relative, 32, -9) => coff::IMAGE_REL_AMD64_REL32_5, - (RelocationKind::SectionIndex, 16, 0) => coff::IMAGE_REL_AMD64_SECTION, - (RelocationKind::SectionOffset, 32, 0) => coff::IMAGE_REL_AMD64_SECREL, - (RelocationKind::SectionOffset, 7, 0) => coff::IMAGE_REL_AMD64_SECREL7, - (RelocationKind::Coff(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::Arm => match (reloc.kind, reloc.size, reloc.addend) { - (RelocationKind::Absolute, 32, 0) => coff::IMAGE_REL_ARM_ADDR32, - (RelocationKind::ImageOffset, 32, 0) => coff::IMAGE_REL_ARM_ADDR32NB, - (RelocationKind::Relative, 32, -4) => coff::IMAGE_REL_ARM_REL32, - (RelocationKind::SectionIndex, 16, 0) => coff::IMAGE_REL_ARM_SECTION, - (RelocationKind::SectionOffset, 32, 0) => coff::IMAGE_REL_ARM_SECREL, - (RelocationKind::Coff(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::Aarch64 => match (reloc.kind, reloc.size, reloc.addend) { - (RelocationKind::Absolute, 32, 0) => coff::IMAGE_REL_ARM64_ADDR32, - (RelocationKind::ImageOffset, 32, 0) => coff::IMAGE_REL_ARM64_ADDR32NB, - (RelocationKind::SectionIndex, 16, 0) => coff::IMAGE_REL_ARM64_SECTION, - (RelocationKind::SectionOffset, 32, 0) => coff::IMAGE_REL_ARM64_SECREL, - (RelocationKind::Absolute, 64, 0) => coff::IMAGE_REL_ARM64_ADDR64, - (RelocationKind::Relative, 32, -4) => coff::IMAGE_REL_ARM64_REL32, - (RelocationKind::Coff(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - _ => { - return Err(Error(format!( - "unimplemented architecture {:?}", - self.architecture - ))); - } + let typ = if let RelocationFlags::Coff { typ } = reloc.flags { + typ + } else { + return Err(Error("invalid relocation flags".into())); }; writer.write_relocation(writer::Relocation { virtual_address: reloc.offset as u32, diff --git a/src/write/elf/object.rs b/src/write/elf/object.rs index 5d7a93e5..3eec81bd 100644 --- a/src/write/elf/object.rs +++ b/src/write/elf/object.rs @@ -153,15 +153,344 @@ impl<'a> Object<'a> { }) } - pub(crate) fn elf_fixup_relocation(&mut self, relocation: &mut Relocation) -> Result { + pub(crate) fn elf_translate_relocation(&mut self, reloc: &mut Relocation) -> Result<()> { + let (kind, encoding, size) = if let RelocationFlags::Generic { + kind, + encoding, + size, + } = reloc.flags + { + (kind, encoding, size) + } else { + return Ok(()); + }; + + let r_type = match self.architecture { + Architecture::Aarch64 => match (kind, encoding, size) { + (RelocationKind::Absolute, RelocationEncoding::Generic, 64) => elf::R_AARCH64_ABS64, + (RelocationKind::Absolute, RelocationEncoding::Generic, 32) => elf::R_AARCH64_ABS32, + (RelocationKind::Absolute, RelocationEncoding::Generic, 16) => elf::R_AARCH64_ABS16, + (RelocationKind::Relative, RelocationEncoding::Generic, 64) => { + elf::R_AARCH64_PREL64 + } + (RelocationKind::Relative, RelocationEncoding::Generic, 32) => { + elf::R_AARCH64_PREL32 + } + (RelocationKind::Relative, RelocationEncoding::Generic, 16) => { + elf::R_AARCH64_PREL16 + } + (RelocationKind::Relative, RelocationEncoding::AArch64Call, 26) + | (RelocationKind::PltRelative, RelocationEncoding::AArch64Call, 26) => { + elf::R_AARCH64_CALL26 + } + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Aarch64_Ilp32 => match (kind, encoding, size) { + (RelocationKind::Absolute, RelocationEncoding::Generic, 32) => { + elf::R_AARCH64_P32_ABS32 + } + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Arm => match (kind, encoding, size) { + (RelocationKind::Absolute, _, 32) => elf::R_ARM_ABS32, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Avr => match (kind, encoding, size) { + (RelocationKind::Absolute, _, 32) => elf::R_AVR_32, + (RelocationKind::Absolute, _, 16) => elf::R_AVR_16, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Bpf => match (kind, encoding, size) { + (RelocationKind::Absolute, _, 64) => elf::R_BPF_64_64, + (RelocationKind::Absolute, _, 32) => elf::R_BPF_64_32, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Csky => match (kind, encoding, size) { + (RelocationKind::Absolute, _, 32) => elf::R_CKCORE_ADDR32, + (RelocationKind::Relative, RelocationEncoding::Generic, 32) => { + elf::R_CKCORE_PCREL32 + } + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::I386 => match (kind, size) { + (RelocationKind::Absolute, 32) => elf::R_386_32, + (RelocationKind::Relative, 32) => elf::R_386_PC32, + (RelocationKind::Got, 32) => elf::R_386_GOT32, + (RelocationKind::PltRelative, 32) => elf::R_386_PLT32, + (RelocationKind::GotBaseOffset, 32) => elf::R_386_GOTOFF, + (RelocationKind::GotBaseRelative, 32) => elf::R_386_GOTPC, + (RelocationKind::Absolute, 16) => elf::R_386_16, + (RelocationKind::Relative, 16) => elf::R_386_PC16, + (RelocationKind::Absolute, 8) => elf::R_386_8, + (RelocationKind::Relative, 8) => elf::R_386_PC8, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::X86_64 | Architecture::X86_64_X32 => match (kind, encoding, size) { + (RelocationKind::Absolute, RelocationEncoding::Generic, 64) => elf::R_X86_64_64, + (RelocationKind::Relative, RelocationEncoding::X86Branch, 32) => { + elf::R_X86_64_PLT32 + } + (RelocationKind::Relative, _, 32) => elf::R_X86_64_PC32, + (RelocationKind::Got, _, 32) => elf::R_X86_64_GOT32, + (RelocationKind::PltRelative, _, 32) => elf::R_X86_64_PLT32, + (RelocationKind::GotRelative, _, 32) => elf::R_X86_64_GOTPCREL, + (RelocationKind::Absolute, RelocationEncoding::Generic, 32) => elf::R_X86_64_32, + (RelocationKind::Absolute, RelocationEncoding::X86Signed, 32) => elf::R_X86_64_32S, + (RelocationKind::Absolute, _, 16) => elf::R_X86_64_16, + (RelocationKind::Relative, _, 16) => elf::R_X86_64_PC16, + (RelocationKind::Absolute, _, 8) => elf::R_X86_64_8, + (RelocationKind::Relative, _, 8) => elf::R_X86_64_PC8, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Hexagon => match (kind, encoding, size) { + (RelocationKind::Absolute, _, 32) => elf::R_HEX_32, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::LoongArch64 => match (kind, encoding, size) { + (RelocationKind::Absolute, _, 32) => elf::R_LARCH_32, + (RelocationKind::Absolute, _, 64) => elf::R_LARCH_64, + (RelocationKind::Relative, _, 32) => elf::R_LARCH_32_PCREL, + (RelocationKind::Relative, _, 64) => elf::R_LARCH_64_PCREL, + (RelocationKind::Relative, RelocationEncoding::LoongArchBranch, 16) + | (RelocationKind::PltRelative, RelocationEncoding::LoongArchBranch, 16) => { + elf::R_LARCH_B16 + } + (RelocationKind::Relative, RelocationEncoding::LoongArchBranch, 21) + | (RelocationKind::PltRelative, RelocationEncoding::LoongArchBranch, 21) => { + elf::R_LARCH_B21 + } + (RelocationKind::Relative, RelocationEncoding::LoongArchBranch, 26) + | (RelocationKind::PltRelative, RelocationEncoding::LoongArchBranch, 26) => { + elf::R_LARCH_B26 + } + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Mips | Architecture::Mips64 => match (kind, encoding, size) { + (RelocationKind::Absolute, _, 16) => elf::R_MIPS_16, + (RelocationKind::Absolute, _, 32) => elf::R_MIPS_32, + (RelocationKind::Absolute, _, 64) => elf::R_MIPS_64, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Msp430 => match (kind, encoding, size) { + (RelocationKind::Absolute, _, 32) => elf::R_MSP430_32, + (RelocationKind::Absolute, _, 16) => elf::R_MSP430_16_BYTE, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::PowerPc => match (kind, encoding, size) { + (RelocationKind::Absolute, _, 32) => elf::R_PPC_ADDR32, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::PowerPc64 => match (kind, encoding, size) { + (RelocationKind::Absolute, _, 32) => elf::R_PPC64_ADDR32, + (RelocationKind::Absolute, _, 64) => elf::R_PPC64_ADDR64, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Riscv32 | Architecture::Riscv64 => match (kind, encoding, size) { + (RelocationKind::Absolute, _, 32) => elf::R_RISCV_32, + (RelocationKind::Absolute, _, 64) => elf::R_RISCV_64, + (RelocationKind::Relative, RelocationEncoding::Generic, 32) => { + elf::R_RISCV_32_PCREL + } + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::S390x => match (kind, encoding, size) { + (RelocationKind::Absolute, RelocationEncoding::Generic, 8) => elf::R_390_8, + (RelocationKind::Absolute, RelocationEncoding::Generic, 16) => elf::R_390_16, + (RelocationKind::Absolute, RelocationEncoding::Generic, 32) => elf::R_390_32, + (RelocationKind::Absolute, RelocationEncoding::Generic, 64) => elf::R_390_64, + (RelocationKind::Relative, RelocationEncoding::Generic, 16) => elf::R_390_PC16, + (RelocationKind::Relative, RelocationEncoding::Generic, 32) => elf::R_390_PC32, + (RelocationKind::Relative, RelocationEncoding::Generic, 64) => elf::R_390_PC64, + (RelocationKind::Relative, RelocationEncoding::S390xDbl, 16) => elf::R_390_PC16DBL, + (RelocationKind::Relative, RelocationEncoding::S390xDbl, 32) => elf::R_390_PC32DBL, + (RelocationKind::PltRelative, RelocationEncoding::S390xDbl, 16) => { + elf::R_390_PLT16DBL + } + (RelocationKind::PltRelative, RelocationEncoding::S390xDbl, 32) => { + elf::R_390_PLT32DBL + } + (RelocationKind::Got, RelocationEncoding::Generic, 16) => elf::R_390_GOT16, + (RelocationKind::Got, RelocationEncoding::Generic, 32) => elf::R_390_GOT32, + (RelocationKind::Got, RelocationEncoding::Generic, 64) => elf::R_390_GOT64, + (RelocationKind::GotRelative, RelocationEncoding::S390xDbl, 32) => { + elf::R_390_GOTENT + } + (RelocationKind::GotBaseOffset, RelocationEncoding::Generic, 16) => { + elf::R_390_GOTOFF16 + } + (RelocationKind::GotBaseOffset, RelocationEncoding::Generic, 32) => { + elf::R_390_GOTOFF32 + } + (RelocationKind::GotBaseOffset, RelocationEncoding::Generic, 64) => { + elf::R_390_GOTOFF64 + } + (RelocationKind::GotBaseRelative, RelocationEncoding::Generic, 64) => { + elf::R_390_GOTPC + } + (RelocationKind::GotBaseRelative, RelocationEncoding::S390xDbl, 32) => { + elf::R_390_GOTPCDBL + } + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Sbf => match (kind, encoding, size) { + (RelocationKind::Absolute, _, 64) => elf::R_SBF_64_64, + (RelocationKind::Absolute, _, 32) => elf::R_SBF_64_32, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Sharc => match (kind, encoding, size) { + (RelocationKind::Absolute, RelocationEncoding::SharcTypeA, 32) => { + elf::R_SHARC_ADDR32_V3 + } + (RelocationKind::Absolute, RelocationEncoding::Generic, 32) => { + elf::R_SHARC_ADDR_VAR_V3 + } + (RelocationKind::Relative, RelocationEncoding::SharcTypeA, 24) => { + elf::R_SHARC_PCRLONG_V3 + } + (RelocationKind::Relative, RelocationEncoding::SharcTypeA, 6) => { + elf::R_SHARC_PCRSHORT_V3 + } + (RelocationKind::Relative, RelocationEncoding::SharcTypeB, 6) => { + elf::R_SHARC_PCRSHORT_V3 + } + (RelocationKind::Absolute, RelocationEncoding::Generic, 16) => { + elf::R_SHARC_ADDR_VAR16_V3 + } + (RelocationKind::Absolute, RelocationEncoding::SharcTypeA, 16) => { + elf::R_SHARC_DATA16_V3 + } + (RelocationKind::Absolute, RelocationEncoding::SharcTypeB, 16) => { + elf::R_SHARC_DATA16_VISA_V3 + } + (RelocationKind::Absolute, RelocationEncoding::SharcTypeA, 24) => { + elf::R_SHARC_ADDR24_V3 + } + (RelocationKind::Absolute, RelocationEncoding::SharcTypeA, 6) => { + elf::R_SHARC_DATA6_V3 + } + (RelocationKind::Absolute, RelocationEncoding::SharcTypeB, 6) => { + elf::R_SHARC_DATA6_VISA_V3 + } + (RelocationKind::Absolute, RelocationEncoding::SharcTypeB, 7) => { + elf::R_SHARC_DATA7_VISA_V3 + } + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Sparc64 => match (kind, encoding, size) { + // TODO: use R_SPARC_32/R_SPARC_64 if aligned. + (RelocationKind::Absolute, _, 32) => elf::R_SPARC_UA32, + (RelocationKind::Absolute, _, 64) => elf::R_SPARC_UA64, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Xtensa => match (kind, encoding, size) { + (RelocationKind::Absolute, _, 32) => elf::R_XTENSA_32, + (RelocationKind::Relative, RelocationEncoding::Generic, 32) => { + elf::R_XTENSA_32_PCREL + } + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }; + reloc.flags = RelocationFlags::Elf { r_type }; + Ok(()) + } + + pub(crate) fn elf_adjust_addend(&mut self, _relocation: &mut Relocation) -> Result { // Determine whether the addend is stored in the relocation or the data. - if self.elf_has_relocation_addend()? { - Ok(0) + let implicit = !self.elf_has_relocation_addend()?; + Ok(implicit) + } + + pub(crate) fn elf_relocation_size(&self, reloc: &Relocation) -> Result { + let r_type = if let RelocationFlags::Elf { r_type } = reloc.flags { + r_type } else { - let constant = relocation.addend; - relocation.addend = 0; - Ok(constant) - } + return Err(Error("invalid relocation flags".into())); + }; + // This only needs to support architectures that use implicit addends. + let size = match self.architecture { + Architecture::Arm => match r_type { + elf::R_ARM_ABS16 => Some(16), + elf::R_ARM_ABS32 | elf::R_ARM_REL32 => Some(32), + _ => None, + }, + Architecture::Bpf => match r_type { + elf::R_BPF_64_32 => Some(32), + elf::R_BPF_64_64 => Some(64), + _ => None, + }, + Architecture::I386 => match r_type { + elf::R_386_8 | elf::R_386_PC8 => Some(8), + elf::R_386_16 | elf::R_386_PC16 => Some(16), + elf::R_386_32 + | elf::R_386_PC32 + | elf::R_386_GOT32 + | elf::R_386_PLT32 + | elf::R_386_GOTOFF + | elf::R_386_GOTPC => Some(32), + _ => None, + }, + Architecture::Mips => match r_type { + elf::R_MIPS_16 => Some(16), + elf::R_MIPS_32 => Some(32), + elf::R_MIPS_64 => Some(64), + _ => None, + }, + Architecture::Sbf => match r_type { + elf::R_SBF_64_32 => Some(32), + elf::R_SBF_64_64 => Some(64), + _ => None, + }, + _ => { + return Err(Error(format!( + "unimplemented architecture {:?}", + self.architecture + ))); + } + }; + size.ok_or_else(|| Error(format!("unsupported relocation for size {:?}", reloc))) } pub(crate) fn elf_is_64(&self) -> bool { @@ -442,360 +771,10 @@ impl<'a> Object<'a> { writer.write_align_relocation(); debug_assert_eq!(section_offsets[index].reloc_offset, writer.len()); for reloc in §ion.relocations { - let r_type = match self.architecture { - Architecture::Aarch64 => match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, RelocationEncoding::Generic, 64) => { - elf::R_AARCH64_ABS64 - } - (RelocationKind::Absolute, RelocationEncoding::Generic, 32) => { - elf::R_AARCH64_ABS32 - } - (RelocationKind::Absolute, RelocationEncoding::Generic, 16) => { - elf::R_AARCH64_ABS16 - } - (RelocationKind::Relative, RelocationEncoding::Generic, 64) => { - elf::R_AARCH64_PREL64 - } - (RelocationKind::Relative, RelocationEncoding::Generic, 32) => { - elf::R_AARCH64_PREL32 - } - (RelocationKind::Relative, RelocationEncoding::Generic, 16) => { - elf::R_AARCH64_PREL16 - } - (RelocationKind::Relative, RelocationEncoding::AArch64Call, 26) - | (RelocationKind::PltRelative, RelocationEncoding::AArch64Call, 26) => { - elf::R_AARCH64_CALL26 - } - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::Aarch64_Ilp32 => { - match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, RelocationEncoding::Generic, 32) => { - elf::R_AARCH64_P32_ABS32 - } - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!( - "unimplemented relocation {:?}", - reloc - ))); - } - } - } - Architecture::Arm => match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, _, 32) => elf::R_ARM_ABS32, - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::Avr => match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, _, 32) => elf::R_AVR_32, - (RelocationKind::Absolute, _, 16) => elf::R_AVR_16, - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::Bpf => match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, _, 64) => elf::R_BPF_64_64, - (RelocationKind::Absolute, _, 32) => elf::R_BPF_64_32, - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::Csky => match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, _, 32) => elf::R_CKCORE_ADDR32, - (RelocationKind::Relative, RelocationEncoding::Generic, 32) => { - elf::R_CKCORE_PCREL32 - } - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::I386 => match (reloc.kind, reloc.size) { - (RelocationKind::Absolute, 32) => elf::R_386_32, - (RelocationKind::Relative, 32) => elf::R_386_PC32, - (RelocationKind::Got, 32) => elf::R_386_GOT32, - (RelocationKind::PltRelative, 32) => elf::R_386_PLT32, - (RelocationKind::GotBaseOffset, 32) => elf::R_386_GOTOFF, - (RelocationKind::GotBaseRelative, 32) => elf::R_386_GOTPC, - (RelocationKind::Absolute, 16) => elf::R_386_16, - (RelocationKind::Relative, 16) => elf::R_386_PC16, - (RelocationKind::Absolute, 8) => elf::R_386_8, - (RelocationKind::Relative, 8) => elf::R_386_PC8, - (RelocationKind::Elf(x), _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::X86_64 | Architecture::X86_64_X32 => { - match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, RelocationEncoding::Generic, 64) => { - elf::R_X86_64_64 - } - (RelocationKind::Relative, RelocationEncoding::X86Branch, 32) => { - elf::R_X86_64_PLT32 - } - (RelocationKind::Relative, _, 32) => elf::R_X86_64_PC32, - (RelocationKind::Got, _, 32) => elf::R_X86_64_GOT32, - (RelocationKind::PltRelative, _, 32) => elf::R_X86_64_PLT32, - (RelocationKind::GotRelative, _, 32) => elf::R_X86_64_GOTPCREL, - (RelocationKind::Absolute, RelocationEncoding::Generic, 32) => { - elf::R_X86_64_32 - } - (RelocationKind::Absolute, RelocationEncoding::X86Signed, 32) => { - elf::R_X86_64_32S - } - (RelocationKind::Absolute, _, 16) => elf::R_X86_64_16, - (RelocationKind::Relative, _, 16) => elf::R_X86_64_PC16, - (RelocationKind::Absolute, _, 8) => elf::R_X86_64_8, - (RelocationKind::Relative, _, 8) => elf::R_X86_64_PC8, - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!( - "unimplemented relocation {:?}", - reloc - ))); - } - } - } - Architecture::Hexagon => match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, _, 32) => elf::R_HEX_32, - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::LoongArch64 => match (reloc.kind, reloc.encoding, reloc.size) - { - (RelocationKind::Absolute, _, 32) => elf::R_LARCH_32, - (RelocationKind::Absolute, _, 64) => elf::R_LARCH_64, - (RelocationKind::Relative, _, 32) => elf::R_LARCH_32_PCREL, - (RelocationKind::Relative, _, 64) => elf::R_LARCH_64_PCREL, - (RelocationKind::Relative, RelocationEncoding::LoongArchBranch, 16) - | ( - RelocationKind::PltRelative, - RelocationEncoding::LoongArchBranch, - 16, - ) => elf::R_LARCH_B16, - (RelocationKind::Relative, RelocationEncoding::LoongArchBranch, 21) - | ( - RelocationKind::PltRelative, - RelocationEncoding::LoongArchBranch, - 21, - ) => elf::R_LARCH_B21, - (RelocationKind::Relative, RelocationEncoding::LoongArchBranch, 26) - | ( - RelocationKind::PltRelative, - RelocationEncoding::LoongArchBranch, - 26, - ) => elf::R_LARCH_B26, - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::Mips | Architecture::Mips64 => { - match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, _, 16) => elf::R_MIPS_16, - (RelocationKind::Absolute, _, 32) => elf::R_MIPS_32, - (RelocationKind::Absolute, _, 64) => elf::R_MIPS_64, - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!( - "unimplemented relocation {:?}", - reloc - ))); - } - } - } - Architecture::Msp430 => match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, _, 32) => elf::R_MSP430_32, - (RelocationKind::Absolute, _, 16) => elf::R_MSP430_16_BYTE, - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::PowerPc => match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, _, 32) => elf::R_PPC_ADDR32, - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::PowerPc64 => match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, _, 32) => elf::R_PPC64_ADDR32, - (RelocationKind::Absolute, _, 64) => elf::R_PPC64_ADDR64, - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::Riscv32 | Architecture::Riscv64 => { - match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, _, 32) => elf::R_RISCV_32, - (RelocationKind::Absolute, _, 64) => elf::R_RISCV_64, - (RelocationKind::Relative, RelocationEncoding::Generic, 32) => { - elf::R_RISCV_32_PCREL - } - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!( - "unimplemented relocation {:?}", - reloc - ))); - } - } - } - Architecture::S390x => match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, RelocationEncoding::Generic, 8) => { - elf::R_390_8 - } - (RelocationKind::Absolute, RelocationEncoding::Generic, 16) => { - elf::R_390_16 - } - (RelocationKind::Absolute, RelocationEncoding::Generic, 32) => { - elf::R_390_32 - } - (RelocationKind::Absolute, RelocationEncoding::Generic, 64) => { - elf::R_390_64 - } - (RelocationKind::Relative, RelocationEncoding::Generic, 16) => { - elf::R_390_PC16 - } - (RelocationKind::Relative, RelocationEncoding::Generic, 32) => { - elf::R_390_PC32 - } - (RelocationKind::Relative, RelocationEncoding::Generic, 64) => { - elf::R_390_PC64 - } - (RelocationKind::Relative, RelocationEncoding::S390xDbl, 16) => { - elf::R_390_PC16DBL - } - (RelocationKind::Relative, RelocationEncoding::S390xDbl, 32) => { - elf::R_390_PC32DBL - } - (RelocationKind::PltRelative, RelocationEncoding::S390xDbl, 16) => { - elf::R_390_PLT16DBL - } - (RelocationKind::PltRelative, RelocationEncoding::S390xDbl, 32) => { - elf::R_390_PLT32DBL - } - (RelocationKind::Got, RelocationEncoding::Generic, 16) => { - elf::R_390_GOT16 - } - (RelocationKind::Got, RelocationEncoding::Generic, 32) => { - elf::R_390_GOT32 - } - (RelocationKind::Got, RelocationEncoding::Generic, 64) => { - elf::R_390_GOT64 - } - (RelocationKind::GotRelative, RelocationEncoding::S390xDbl, 32) => { - elf::R_390_GOTENT - } - (RelocationKind::GotBaseOffset, RelocationEncoding::Generic, 16) => { - elf::R_390_GOTOFF16 - } - (RelocationKind::GotBaseOffset, RelocationEncoding::Generic, 32) => { - elf::R_390_GOTOFF32 - } - (RelocationKind::GotBaseOffset, RelocationEncoding::Generic, 64) => { - elf::R_390_GOTOFF64 - } - (RelocationKind::GotBaseRelative, RelocationEncoding::Generic, 64) => { - elf::R_390_GOTPC - } - (RelocationKind::GotBaseRelative, RelocationEncoding::S390xDbl, 32) => { - elf::R_390_GOTPCDBL - } - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::Sbf => match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, _, 64) => elf::R_SBF_64_64, - (RelocationKind::Absolute, _, 32) => elf::R_SBF_64_32, - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::Sharc => match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, RelocationEncoding::SharcTypeA, 32) => { - elf::R_SHARC_ADDR32_V3 - } - (RelocationKind::Absolute, RelocationEncoding::Generic, 32) => { - elf::R_SHARC_ADDR_VAR_V3 - } - (RelocationKind::Relative, RelocationEncoding::SharcTypeA, 24) => { - elf::R_SHARC_PCRLONG_V3 - } - (RelocationKind::Relative, RelocationEncoding::SharcTypeA, 6) => { - elf::R_SHARC_PCRSHORT_V3 - } - (RelocationKind::Relative, RelocationEncoding::SharcTypeB, 6) => { - elf::R_SHARC_PCRSHORT_V3 - } - (RelocationKind::Absolute, RelocationEncoding::Generic, 16) => { - elf::R_SHARC_ADDR_VAR16_V3 - } - (RelocationKind::Absolute, RelocationEncoding::SharcTypeA, 16) => { - elf::R_SHARC_DATA16_V3 - } - (RelocationKind::Absolute, RelocationEncoding::SharcTypeB, 16) => { - elf::R_SHARC_DATA16_VISA_V3 - } - (RelocationKind::Absolute, RelocationEncoding::SharcTypeA, 24) => { - elf::R_SHARC_ADDR24_V3 - } - (RelocationKind::Absolute, RelocationEncoding::SharcTypeA, 6) => { - elf::R_SHARC_DATA6_V3 - } - (RelocationKind::Absolute, RelocationEncoding::SharcTypeB, 6) => { - elf::R_SHARC_DATA6_VISA_V3 - } - (RelocationKind::Absolute, RelocationEncoding::SharcTypeB, 7) => { - elf::R_SHARC_DATA7_VISA_V3 - } - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::Sparc64 => match (reloc.kind, reloc.encoding, reloc.size) { - // TODO: use R_SPARC_32/R_SPARC_64 if aligned. - (RelocationKind::Absolute, _, 32) => elf::R_SPARC_UA32, - (RelocationKind::Absolute, _, 64) => elf::R_SPARC_UA64, - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::Xtensa => match (reloc.kind, reloc.encoding, reloc.size) { - (RelocationKind::Absolute, _, 32) => elf::R_XTENSA_32, - (RelocationKind::Relative, RelocationEncoding::Generic, 32) => { - elf::R_XTENSA_32_PCREL - } - (RelocationKind::Elf(x), _, _) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - _ => { - if let RelocationKind::Elf(x) = reloc.kind { - x - } else { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - } + let r_type = if let RelocationFlags::Elf { r_type } = reloc.flags { + r_type + } else { + return Err(Error("invalid relocation flags".into())); }; let r_sym = symbol_offsets[reloc.symbol.0].index.0; writer.write_relocation( diff --git a/src/write/macho.rs b/src/write/macho.rs index 1c615234..09739164 100644 --- a/src/write/macho.rs +++ b/src/write/macho.rs @@ -221,11 +221,13 @@ impl<'a> Object<'a> { section, Relocation { offset, - size: address_size * 8, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, symbol: tlv_bootstrap, addend: 0, + flags: RelocationFlags::Generic { + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: address_size * 8, + }, }, ) .unwrap(); @@ -233,11 +235,13 @@ impl<'a> Object<'a> { section, Relocation { offset: offset + u64::from(address_size) * 2, - size: address_size * 8, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, symbol: init_symbol_id, addend: 0, + flags: RelocationFlags::Generic { + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: address_size * 8, + }, }, ) .unwrap(); @@ -251,15 +255,94 @@ impl<'a> Object<'a> { init_symbol_id } - pub(crate) fn macho_fixup_relocation(&mut self, relocation: &mut Relocation) -> i64 { - let relative = match relocation.kind { - RelocationKind::Relative - | RelocationKind::GotRelative - | RelocationKind::PltRelative - | RelocationKind::MachO { relative: true, .. } => true, - _ => false, + pub(crate) fn macho_translate_relocation(&mut self, reloc: &mut Relocation) -> Result<()> { + let (kind, encoding, mut size) = if let RelocationFlags::Generic { + kind, + encoding, + size, + } = reloc.flags + { + (kind, encoding, size) + } else { + return Ok(()); + }; + // Aarch64 relocs of these sizes act as if they are double-word length + if self.architecture == Architecture::Aarch64 && matches!(size, 12 | 21 | 26) { + size = 32; + } + let r_length = match size { + 8 => 0, + 16 => 1, + 32 => 2, + 64 => 3, + _ => return Err(Error(format!("unimplemented reloc size {:?}", reloc))), + }; + let (r_pcrel, r_type) = match self.architecture { + Architecture::I386 => match kind { + RelocationKind::Absolute => (false, macho::GENERIC_RELOC_VANILLA), + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::X86_64 => match (kind, encoding) { + (RelocationKind::Absolute, RelocationEncoding::Generic) => { + (false, macho::X86_64_RELOC_UNSIGNED) + } + (RelocationKind::Relative, RelocationEncoding::Generic) => { + (true, macho::X86_64_RELOC_SIGNED) + } + (RelocationKind::Relative, RelocationEncoding::X86RipRelative) => { + (true, macho::X86_64_RELOC_SIGNED) + } + (RelocationKind::Relative, RelocationEncoding::X86Branch) => { + (true, macho::X86_64_RELOC_BRANCH) + } + (RelocationKind::PltRelative, RelocationEncoding::X86Branch) => { + (true, macho::X86_64_RELOC_BRANCH) + } + (RelocationKind::GotRelative, RelocationEncoding::Generic) => { + (true, macho::X86_64_RELOC_GOT) + } + (RelocationKind::GotRelative, RelocationEncoding::X86RipRelativeMovq) => { + (true, macho::X86_64_RELOC_GOT_LOAD) + } + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + Architecture::Aarch64 | Architecture::Aarch64_Ilp32 => match (kind, encoding) { + (RelocationKind::Absolute, RelocationEncoding::Generic) => { + (false, macho::ARM64_RELOC_UNSIGNED) + } + (RelocationKind::Relative, RelocationEncoding::AArch64Call) => { + (true, macho::ARM64_RELOC_BRANCH26) + } + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } }; - if relative { + reloc.flags = RelocationFlags::MachO { + r_type, + r_pcrel, + r_length, + }; + Ok(()) + } + + pub(crate) fn macho_adjust_addend(&mut self, relocation: &mut Relocation) -> Result { + let (r_type, r_pcrel) = if let RelocationFlags::MachO { + r_type, r_pcrel, .. + } = relocation.flags + { + (r_type, r_pcrel) + } else { + return Err(Error(format!("invalid relocation flags {:?}", relocation))); + }; + if r_pcrel { // For PC relative relocations on some architectures, the // addend does not include the offset required due to the // PC being different from the place of the relocation. @@ -267,19 +350,10 @@ impl<'a> Object<'a> { // addend here to account for this. let pcrel_offset = match self.architecture { Architecture::I386 => 4, - Architecture::X86_64 => match relocation.kind { - RelocationKind::MachO { - value: macho::X86_64_RELOC_SIGNED_1, - .. - } => 5, - RelocationKind::MachO { - value: macho::X86_64_RELOC_SIGNED_2, - .. - } => 6, - RelocationKind::MachO { - value: macho::X86_64_RELOC_SIGNED_4, - .. - } => 8, + Architecture::X86_64 => match r_type { + macho::X86_64_RELOC_SIGNED_1 => 5, + macho::X86_64_RELOC_SIGNED_2 => 6, + macho::X86_64_RELOC_SIGNED_4 => 8, _ => 4, }, // TODO: maybe missing support for some architectures and relocations @@ -287,28 +361,26 @@ impl<'a> Object<'a> { }; relocation.addend += pcrel_offset; } - // Aarch64 relocs of these sizes act as if they are double-word length - if self.architecture == Architecture::Aarch64 && matches!(relocation.size, 12 | 21 | 26) { - relocation.size = 32; - } - // Check for relocations that use an explicit addend. - if self.architecture == Architecture::Aarch64 { - if relocation.encoding == RelocationEncoding::AArch64Call { - return 0; - } - if let RelocationKind::MachO { value, .. } = relocation.kind { - match value { - macho::ARM64_RELOC_BRANCH26 - | macho::ARM64_RELOC_PAGE21 - | macho::ARM64_RELOC_PAGEOFF12 => return 0, - _ => {} - } + // Determine if addend is implicit. + let implicit = if self.architecture == Architecture::Aarch64 { + match r_type { + macho::ARM64_RELOC_BRANCH26 + | macho::ARM64_RELOC_PAGE21 + | macho::ARM64_RELOC_PAGEOFF12 => false, + _ => true, } + } else { + true + }; + Ok(implicit) + } + + pub(crate) fn macho_relocation_size(&self, reloc: &Relocation) -> Result { + if let RelocationFlags::MachO { r_length, .. } = reloc.flags { + Ok(8 << r_length) + } else { + return Err(Error("invalid relocation flags".into())); } - // Signify implicit addend. - let constant = relocation.addend; - relocation.addend = 0; - constant } pub(crate) fn macho_write(&self, buffer: &mut dyn WritableBuffer) -> Result<()> { @@ -666,12 +738,15 @@ impl<'a> Object<'a> { write_align(buffer, pointer_align); debug_assert_eq!(section_offsets[index].reloc_offset, buffer.len()); for reloc in §ion.relocations { - let r_length = match reloc.size { - 8 => 0, - 16 => 1, - 32 => 2, - 64 => 3, - _ => return Err(Error(format!("unimplemented reloc size {:?}", reloc))), + let (r_type, r_pcrel, r_length) = if let RelocationFlags::MachO { + r_type, + r_pcrel, + r_length, + } = reloc.flags + { + (r_type, r_pcrel, r_length) + } else { + return Err(Error("invalid relocation flags".into())); }; // Write explicit addend. @@ -706,69 +781,7 @@ impl<'a> Object<'a> { r_symbolnum = symbol_offsets[reloc.symbol.0].index as u32; r_extern = true; } - let (r_pcrel, r_type) = match self.architecture { - Architecture::I386 => match reloc.kind { - RelocationKind::Absolute => (false, macho::GENERIC_RELOC_VANILLA), - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::X86_64 => match (reloc.kind, reloc.encoding) { - (RelocationKind::Absolute, RelocationEncoding::Generic) => { - (false, macho::X86_64_RELOC_UNSIGNED) - } - (RelocationKind::Relative, RelocationEncoding::Generic) => { - (true, macho::X86_64_RELOC_SIGNED) - } - (RelocationKind::Relative, RelocationEncoding::X86RipRelative) => { - (true, macho::X86_64_RELOC_SIGNED) - } - (RelocationKind::Relative, RelocationEncoding::X86Branch) => { - (true, macho::X86_64_RELOC_BRANCH) - } - (RelocationKind::PltRelative, RelocationEncoding::X86Branch) => { - (true, macho::X86_64_RELOC_BRANCH) - } - (RelocationKind::GotRelative, RelocationEncoding::Generic) => { - (true, macho::X86_64_RELOC_GOT) - } - ( - RelocationKind::GotRelative, - RelocationEncoding::X86RipRelativeMovq, - ) => (true, macho::X86_64_RELOC_GOT_LOAD), - (RelocationKind::MachO { value, relative }, _) => (relative, value), - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }, - Architecture::Aarch64 | Architecture::Aarch64_Ilp32 => { - match (reloc.kind, reloc.encoding) { - (RelocationKind::Absolute, RelocationEncoding::Generic) => { - (false, macho::ARM64_RELOC_UNSIGNED) - } - (RelocationKind::Relative, RelocationEncoding::AArch64Call) => { - (true, macho::ARM64_RELOC_BRANCH26) - } - ( - RelocationKind::MachO { value, relative }, - RelocationEncoding::Generic, - ) => (relative, value), - _ => { - return Err(Error(format!( - "unimplemented relocation {:?}", - reloc - ))); - } - } - } - _ => { - if let RelocationKind::MachO { value, relative } = reloc.kind { - (relative, value) - } else { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - } - }; + let reloc_info = macho::RelocationInfo { r_address: reloc.offset as u32, r_symbolnum, diff --git a/src/write/mod.rs b/src/write/mod.rs index cea4d2e7..00a9df57 100644 --- a/src/write/mod.rs +++ b/src/write/mod.rs @@ -11,8 +11,9 @@ use std::{boxed::Box, collections::HashMap, error, io}; use crate::endian::{Endianness, U32, U64}; use crate::{ - Architecture, BinaryFormat, ComdatKind, FileFlags, RelocationEncoding, RelocationKind, - SectionFlags, SectionKind, SubArchitecture, SymbolFlags, SymbolKind, SymbolScope, + Architecture, BinaryFormat, ComdatKind, FileFlags, RelocationEncoding, RelocationFlags, + RelocationKind, SectionFlags, SectionKind, SubArchitecture, SymbolFlags, SymbolKind, + SymbolScope, }; #[cfg(feature = "coff")] @@ -532,19 +533,31 @@ impl<'a> Object<'a> { /// Relocations must only be added after the referenced symbols have been added /// and defined (if applicable). pub fn add_relocation(&mut self, section: SectionId, mut relocation: Relocation) -> Result<()> { - let addend = match self.format { + match self.format { + #[cfg(feature = "coff")] + BinaryFormat::Coff => self.coff_translate_relocation(&mut relocation)?, + #[cfg(feature = "elf")] + BinaryFormat::Elf => self.elf_translate_relocation(&mut relocation)?, + #[cfg(feature = "macho")] + BinaryFormat::MachO => self.macho_translate_relocation(&mut relocation)?, + #[cfg(feature = "xcoff")] + BinaryFormat::Xcoff => self.xcoff_translate_relocation(&mut relocation)?, + _ => unimplemented!(), + } + let implicit = match self.format { #[cfg(feature = "coff")] - BinaryFormat::Coff => self.coff_fixup_relocation(&mut relocation), + BinaryFormat::Coff => self.coff_adjust_addend(&mut relocation)?, #[cfg(feature = "elf")] - BinaryFormat::Elf => self.elf_fixup_relocation(&mut relocation)?, + BinaryFormat::Elf => self.elf_adjust_addend(&mut relocation)?, #[cfg(feature = "macho")] - BinaryFormat::MachO => self.macho_fixup_relocation(&mut relocation), + BinaryFormat::MachO => self.macho_adjust_addend(&mut relocation)?, #[cfg(feature = "xcoff")] - BinaryFormat::Xcoff => self.xcoff_fixup_relocation(&mut relocation), + BinaryFormat::Xcoff => self.xcoff_adjust_addend(&mut relocation)?, _ => unimplemented!(), }; - if addend != 0 { - self.write_relocation_addend(section, &relocation, addend)?; + if implicit && relocation.addend != 0 { + self.write_relocation_addend(section, &relocation)?; + relocation.addend = 0; } self.sections[section.0].relocations.push(relocation); Ok(()) @@ -554,13 +567,23 @@ impl<'a> Object<'a> { &mut self, section: SectionId, relocation: &Relocation, - addend: i64, ) -> Result<()> { + let size = match self.format { + #[cfg(feature = "coff")] + BinaryFormat::Coff => self.coff_relocation_size(relocation)?, + #[cfg(feature = "elf")] + BinaryFormat::Elf => self.elf_relocation_size(relocation)?, + #[cfg(feature = "macho")] + BinaryFormat::MachO => self.macho_relocation_size(relocation)?, + #[cfg(feature = "xcoff")] + BinaryFormat::Xcoff => self.xcoff_relocation_size(relocation)?, + _ => unimplemented!(), + }; let data = self.sections[section.0].data_mut(); let offset = relocation.offset as usize; - match relocation.size { - 32 => data.write_at(offset, &U32::new(self.endian, addend as u32)), - 64 => data.write_at(offset, &U64::new(self.endian, addend as u64)), + match size { + 32 => data.write_at(offset, &U32::new(self.endian, relocation.addend as u32)), + 64 => data.write_at(offset, &U64::new(self.endian, relocation.addend as u64)), _ => { return Err(Error(format!( "unimplemented relocation addend {:?}", @@ -572,7 +595,7 @@ impl<'a> Object<'a> { Error(format!( "invalid relocation offset {}+{} (max {})", relocation.offset, - relocation.size, + size, data.len() )) }) @@ -883,12 +906,6 @@ impl Symbol { pub struct Relocation { /// The section offset of the place of the relocation. pub offset: u64, - /// The size in bits of the place of relocation. - pub size: u8, - /// The operation used to calculate the result of the relocation. - pub kind: RelocationKind, - /// Information about how the result of the relocation operation is encoded in the place. - pub encoding: RelocationEncoding, /// The symbol referred to by the relocation. /// /// This may be a section symbol. @@ -897,6 +914,8 @@ pub struct Relocation { /// /// This may be in addition to an implicit addend stored at the place of the relocation. pub addend: i64, + /// The fields that define the relocation type. + pub flags: RelocationFlags, } /// An identifier used to reference a COMDAT section group. diff --git a/src/write/xcoff.rs b/src/write/xcoff.rs index fc58886e..c709167d 100644 --- a/src/write/xcoff.rs +++ b/src/write/xcoff.rs @@ -66,13 +66,50 @@ impl<'a> Object<'a> { } } - pub(crate) fn xcoff_fixup_relocation(&mut self, relocation: &mut Relocation) -> i64 { - let constant = match relocation.kind { - RelocationKind::Relative => relocation.addend + 4, - _ => relocation.addend, + pub(crate) fn xcoff_translate_relocation(&mut self, reloc: &mut Relocation) -> Result<()> { + let (kind, _encoding, size) = if let RelocationFlags::Generic { + kind, + encoding, + size, + } = reloc.flags + { + (kind, encoding, size) + } else { + return Ok(()); + }; + + let r_rtype = match kind { + RelocationKind::Absolute => xcoff::R_POS, + RelocationKind::Relative => xcoff::R_REL, + RelocationKind::Got => xcoff::R_TOC, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }; + let r_rsize = size - 1; + reloc.flags = RelocationFlags::Xcoff { r_rtype, r_rsize }; + Ok(()) + } + + pub(crate) fn xcoff_adjust_addend(&mut self, relocation: &mut Relocation) -> Result { + let r_rtype = if let RelocationFlags::Xcoff { r_rtype, .. } = relocation.flags { + r_rtype + } else { + return Err(Error(format!("invalid relocation flags {:?}", relocation))); }; - relocation.addend -= constant; - constant + if r_rtype == xcoff::R_REL { + relocation.addend += 4; + } + Ok(true) + } + + pub(crate) fn xcoff_relocation_size(&self, reloc: &Relocation) -> Result { + let r_rsize = if let RelocationFlags::Xcoff { r_rsize, .. } = reloc.flags { + r_rsize + } else { + return Err(Error(format!("unexpected relocation {:?}", reloc))); + }; + Ok(r_rsize + 1) } pub(crate) fn xcoff_write(&self, buffer: &mut dyn WritableBuffer) -> Result<()> { @@ -346,30 +383,26 @@ impl<'a> Object<'a> { if !section.relocations.is_empty() { debug_assert_eq!(section_offsets[index].reloc_offset, buffer.len()); for reloc in §ion.relocations { - let rtype = match reloc.kind { - RelocationKind::Absolute => xcoff::R_POS, - RelocationKind::Relative => xcoff::R_REL, - RelocationKind::Got => xcoff::R_TOC, - RelocationKind::Xcoff(x) => x, - _ => { - return Err(Error(format!("unimplemented relocation {:?}", reloc))); - } - }; + let (r_rtype, r_rsize) = + if let RelocationFlags::Xcoff { r_rtype, r_rsize } = reloc.flags { + (r_rtype, r_rsize) + } else { + return Err(Error("invalid relocation flags".into())); + }; if is_64 { let xcoff_rel = xcoff::Rel64 { r_vaddr: U64::new(BE, reloc.offset), r_symndx: U32::new(BE, symbol_offsets[reloc.symbol.0].index as u32), - // Specifies the bit length of the relocatable reference minus one. - r_rsize: (reloc.size - 1), - r_rtype: rtype, + r_rsize, + r_rtype, }; buffer.write(&xcoff_rel); } else { let xcoff_rel = xcoff::Rel32 { r_vaddr: U32::new(BE, reloc.offset as u32), r_symndx: U32::new(BE, symbol_offsets[reloc.symbol.0].index as u32), - r_rsize: (reloc.size - 1), - r_rtype: rtype, + r_rsize, + r_rtype, }; buffer.write(&xcoff_rel); } diff --git a/tests/round_trip/coff.rs b/tests/round_trip/coff.rs index 6785dc36..2b55788a 100644 --- a/tests/round_trip/coff.rs +++ b/tests/round_trip/coff.rs @@ -1,8 +1,8 @@ use object::read::{Object, ObjectSection}; use object::{read, write}; use object::{ - Architecture, BinaryFormat, Endianness, RelocationEncoding, RelocationKind, SymbolFlags, - SymbolKind, SymbolScope, + Architecture, BinaryFormat, Endianness, RelocationEncoding, RelocationFlags, RelocationKind, + SymbolFlags, SymbolKind, SymbolScope, }; #[test] @@ -27,11 +27,13 @@ fn reloc_overflow() { text, write::Relocation { offset: i, - size: 64, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, symbol, addend: 0, + flags: RelocationFlags::Generic { + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: 64, + }, }, ) .unwrap(); diff --git a/tests/round_trip/mod.rs b/tests/round_trip/mod.rs index b92a94a8..96af432a 100644 --- a/tests/round_trip/mod.rs +++ b/tests/round_trip/mod.rs @@ -3,8 +3,8 @@ use object::read::{Object, ObjectSection, ObjectSymbol}; use object::{read, write, SectionIndex, SubArchitecture}; use object::{ - Architecture, BinaryFormat, Endianness, RelocationEncoding, RelocationKind, SectionKind, - SymbolFlags, SymbolKind, SymbolScope, SymbolSection, + Architecture, BinaryFormat, Endianness, RelocationEncoding, RelocationFlags, RelocationKind, + SectionKind, SymbolFlags, SymbolKind, SymbolScope, SymbolSection, }; mod bss; @@ -65,11 +65,13 @@ fn coff_any() { text, write::Relocation { offset: 8, - size: arch.address_size().unwrap().bytes() * 8, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, symbol: func1_symbol, addend: 0, + flags: RelocationFlags::Generic { + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: arch.address_size().unwrap().bytes() * 8, + }, }, ) .unwrap(); @@ -182,11 +184,13 @@ fn elf_x86_64() { text, write::Relocation { offset: 8, - size: 64, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, symbol: func1_symbol, addend: 0, + flags: RelocationFlags::Generic { + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: 64, + }, }, ) .unwrap(); @@ -309,11 +313,13 @@ fn elf_any() { section, write::Relocation { offset: 8, - size: 32, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, symbol, addend: 0, + flags: RelocationFlags::Generic { + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: 32, + }, }, ) .unwrap(); @@ -323,11 +329,13 @@ fn elf_any() { section, write::Relocation { offset: 16, - size: 64, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, symbol, addend: 0, + flags: RelocationFlags::Generic { + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: 64, + }, }, ) .unwrap(); @@ -406,11 +414,13 @@ fn macho_x86_64() { text, write::Relocation { offset: 8, - size: 64, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, symbol: func1_symbol, addend: 0, + flags: RelocationFlags::Generic { + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: 64, + }, }, ) .unwrap(); @@ -419,11 +429,13 @@ fn macho_x86_64() { text, write::Relocation { offset: 16, - size: 32, - kind: RelocationKind::Relative, - encoding: RelocationEncoding::Generic, symbol: func1_symbol, addend: -4, + flags: RelocationFlags::Generic { + kind: RelocationKind::Relative, + encoding: RelocationEncoding::Generic, + size: 32, + }, }, ) .unwrap(); @@ -528,11 +540,13 @@ fn macho_any() { section, write::Relocation { offset: 8, - size: 32, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, symbol, addend: 0, + flags: RelocationFlags::Generic { + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: 32, + }, }, ) .unwrap(); @@ -542,11 +556,13 @@ fn macho_any() { section, write::Relocation { offset: 16, - size: 64, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, symbol, addend: 0, + flags: RelocationFlags::Generic { + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: 64, + }, }, ) .unwrap(); @@ -619,11 +635,13 @@ fn xcoff_powerpc() { text, write::Relocation { offset: 8, - size: 64, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, symbol: func1_symbol, addend: 0, + flags: RelocationFlags::Generic { + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: 64, + }, }, ) .unwrap();