From f4355be96e10a76ff4cf9c855f719bd2bd3f2e1d Mon Sep 17 00:00:00 2001 From: Philip Craig Date: Fri, 10 Nov 2023 15:41:34 +1000 Subject: [PATCH] Delete format specific variants in RelocationKind Replace uses of these variants with read::Relocation::flags and write::Relocation::flags. Additionally, for write::Relocation, move the kind/encoding/size fields into RelocationFlags::Generic, since these are not required when using format specific variants. --- crates/examples/src/objcopy.rs | 4 +- .../testfiles/coff/import_msvc.lib.objdump | 18 +- crates/examples/testfiles/elf/base.o.objdump | 6 +- crates/examples/testfiles/elf/base.objdump | 18 +- .../macho/base-aarch64-debug.o.objdump | 14 +- .../testfiles/macho/base-aarch64.o.objdump | 8 +- .../macho/base-x86_64-debug.o.objdump | 12 +- .../testfiles/macho/base-x86_64.o.objdump | 6 +- .../testfiles/macho/reloc-aarch64.o.objdump | 34 ++-- .../testfiles/macho/reloc-arm.o.objdump | 28 ++-- .../testfiles/macho/reloc-i386.o.objdump | 8 +- .../testfiles/macho/reloc-x86_64.o.objdump | 30 ++-- .../testfiles/pe/base-bigobj.o.objdump | 20 +-- .../testfiles/pe/base-bigobj.obj.objdump | 14 +- crates/examples/testfiles/pe/base.o.objdump | 20 +-- crates/examples/testfiles/pe/base.obj.objdump | 14 +- .../examples/testfiles/xcoff/base.o.objdump | 10 +- .../testfiles/xcoff/base.xcoff.objdump | 136 +++++++-------- .../examples/testfiles/xcoff/base32.o.objdump | 10 +- .../testfiles/xcoff/base32.xcoff.objdump | 128 +++++++------- src/common.rs | 28 ++-- src/read/coff/relocation.rs | 24 +-- src/read/elf/relocation.rs | 93 +++++------ src/read/macho/relocation.rs | 35 ++-- src/read/mod.rs | 16 +- src/read/xcoff/relocation.rs | 14 +- src/write/coff.rs | 55 +++--- src/write/elf/object.rs | 156 ++++++++---------- src/write/macho.rs | 83 +++++----- src/write/mod.rs | 48 +----- src/write/xcoff.rs | 28 ++-- tests/round_trip/coff.rs | 12 +- tests/round_trip/mod.rs | 76 +++++---- 33 files changed, 588 insertions(+), 618 deletions(-) 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 2d62f547..698ec65b 100644 --- a/crates/examples/testfiles/coff/import_msvc.lib.objdump +++ b/crates/examples/testfiles/coff/import_msvc.lib.objdump @@ -95,9 +95,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 @@ -172,9 +172,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 @@ -249,8 +249,8 @@ 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.o.objdump b/crates/examples/testfiles/elf/base.o.objdump index cf5c650d..6aff8fb8 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: Label, 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 42d1685f..903b7d4e 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 f4cad6f0..056736d7 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 96c36054..e1b2e410 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 a279b3b4..62959723 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 ffb8c1bc..09eba5ba 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 5f4071a1..8f0f736b 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 994cf586..0abfcb3f 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 c6a1677a..b35dbf97 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 044bdd39..669e36a2 100644 --- a/crates/examples/testfiles/macho/reloc-x86_64.o.objdump +++ b/crates/examples/testfiles/macho/reloc-x86_64.o.objdump @@ -13,22 +13,22 @@ 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 fe5dc976..628f33b6 100644 --- a/crates/examples/testfiles/pe/base-bigobj.o.objdump +++ b/crates/examples/testfiles/pe/base-bigobj.o.objdump @@ -35,17 +35,17 @@ 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 373144dc..efc0e532 100644 --- a/crates/examples/testfiles/pe/base-bigobj.obj.objdump +++ b/crates/examples/testfiles/pe/base-bigobj.obj.objdump @@ -45,18 +45,18 @@ 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 3326a5fd..811f2144 100644 --- a/crates/examples/testfiles/pe/base.o.objdump +++ b/crates/examples/testfiles/pe/base.o.objdump @@ -35,17 +35,17 @@ 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 373144dc..efc0e532 100644 --- a/crates/examples/testfiles/pe/base.obj.objdump +++ b/crates/examples/testfiles/pe/base.obj.objdump @@ -45,18 +45,18 @@ 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 332dd81f..1ff5d7ed 100644 --- a/crates/examples/testfiles/xcoff/base.o.objdump +++ b/crates/examples/testfiles/xcoff/base.o.objdump @@ -19,12 +19,12 @@ Symbols 17: Symbol { name: ".rodata.str1.1L...str", address: 80, size: 8, kind: Data, section: Section(SectionIndex(2)), scope: Dynamic, 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 2b01d564..4f401559 100644 --- a/crates/examples/testfiles/xcoff/base.xcoff.objdump +++ b/crates/examples/testfiles/xcoff/base.xcoff.objdump @@ -91,75 +91,75 @@ 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 5a209a6d..c8bb9aaf 100644 --- a/crates/examples/testfiles/xcoff/base32.o.objdump +++ b/crates/examples/testfiles/xcoff/base32.o.objdump @@ -19,12 +19,12 @@ Symbols 17: Symbol { name: ".rodata.str1.1L...str", address: 78, size: 4, kind: Data, section: Section(SectionIndex(2)), scope: Dynamic, 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 aa35ddb0..f92d5e4b 100644 --- a/crates/examples/testfiles/xcoff/base32.xcoff.objdump +++ b/crates/examples/testfiles/xcoff/base32.xcoff.objdump @@ -89,71 +89,71 @@ 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 e87d9d5c..ef72f48e 100644 --- a/src/common.rs +++ b/src/common.rs @@ -291,6 +291,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 @@ -311,19 +313,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. @@ -333,6 +322,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, @@ -503,7 +494,16 @@ pub enum SymbolFlags { /// Relocation fields that are specific to each file format and architecture. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[non_exhaustive] -pub(crate) enum RelocationFlags { +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. diff --git a/src/read/coff/relocation.rs b/src/read/coff/relocation.rs index 44d2c68d..4ae9766c 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,25 +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 => match relocation.typ.get(LE) { + pe::IMAGE_FILE_MACHINE_ARM64 => 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), - typ => (RelocationKind::Coff(typ), 0, 0), + _ => (RelocationKind::Unknown, 0, 0), }, - pe::IMAGE_FILE_MACHINE_I386 => match relocation.typ.get(LE) { + 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), @@ -58,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), @@ -73,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, @@ -89,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 233e57f4..73c08e18 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,26 +400,24 @@ 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_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 { @@ -432,6 +432,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 05c48061..ecf61ad4 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 8230d43b..83ec89c8 100644 --- a/src/read/mod.rs +++ b/src/read/mod.rs @@ -578,6 +578,7 @@ pub struct Relocation { target: RelocationTarget, addend: i64, implicit_addend: bool, + flags: RelocationFlags, } impl Relocation { @@ -613,18 +614,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 78c6acfc..09b60307 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.rs b/src/write/coff.rs index f680cf4d..a89168fd 100644 --- a/src/write/coff.rs +++ b/src/write/coff.rs @@ -83,25 +83,32 @@ impl<'a> Object<'a> { name } - pub(crate) fn coff_translate_relocation(&mut self, relocation: &mut Relocation) -> Result<()> { - 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; } - Ok(()) - } - pub(crate) fn coff_relocation_flags(&self, reloc: &Relocation) -> Result { let typ = match self.architecture { - Architecture::I386 => match (reloc.kind, reloc.size) { + 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, @@ -110,12 +117,11 @@ impl<'a> Object<'a> { (RelocationKind::SectionOffset, 32) => coff::IMAGE_REL_I386_SECREL, (RelocationKind::SectionOffset, 7) => coff::IMAGE_REL_I386_SECREL7, (RelocationKind::Relative, 32) => coff::IMAGE_REL_I386_REL32, - (RelocationKind::Coff(x), _) => x, _ => { return Err(Error(format!("unimplemented relocation {:?}", reloc))); } }, - Architecture::X86_64 => match (reloc.kind, reloc.size) { + 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, @@ -130,30 +136,27 @@ impl<'a> Object<'a> { (RelocationKind::SectionIndex, 16) => coff::IMAGE_REL_AMD64_SECTION, (RelocationKind::SectionOffset, 32) => coff::IMAGE_REL_AMD64_SECREL, (RelocationKind::SectionOffset, 7) => coff::IMAGE_REL_AMD64_SECREL7, - (RelocationKind::Coff(x), _) => x, _ => { return Err(Error(format!("unimplemented relocation {:?}", reloc))); } }, - Architecture::Arm => match (reloc.kind, reloc.size) { + 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, - (RelocationKind::Coff(x), _) => x, _ => { return Err(Error(format!("unimplemented relocation {:?}", reloc))); } }, - Architecture::Aarch64 => match (reloc.kind, reloc.size) { + 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, - (RelocationKind::Coff(x), _) => x, _ => { return Err(Error(format!("unimplemented relocation {:?}", reloc))); } @@ -165,13 +168,11 @@ impl<'a> Object<'a> { ))); } }; - Ok(RelocationFlags::Coff { typ }) + reloc.flags = RelocationFlags::Coff { typ }; + Ok(()) } - pub(crate) fn coff_adjust_addend( - &self, - relocation: &mut crate::write::RawRelocation, - ) -> Result { + pub(crate) fn coff_adjust_addend(&self, relocation: &mut Relocation) -> Result { let typ = if let RelocationFlags::Coff { typ } = relocation.flags { typ } else { @@ -214,7 +215,7 @@ impl<'a> Object<'a> { Ok(true) } - pub(crate) fn coff_relocation_size(&self, reloc: &crate::write::RawRelocation) -> Result { + pub(crate) fn coff_relocation_size(&self, reloc: &Relocation) -> Result { let typ = if let RelocationFlags::Coff { typ } = reloc.flags { typ } else { @@ -285,11 +286,13 @@ impl<'a> Object<'a> { section_id, Relocation { offset: 0, - size: stub_size * 8, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, symbol: symbol_id, addend: 0, + flags: RelocationFlags::Generic { + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: stub_size * 8, + }, }, )?; diff --git a/src/write/elf/object.rs b/src/write/elf/object.rs index 69a441de..a7c89da4 100644 --- a/src/write/elf/object.rs +++ b/src/write/elf/object.rs @@ -152,11 +152,20 @@ impl<'a> Object<'a> { }) } - pub(crate) fn elf_translate_relocation(&mut self, _relocation: &mut Relocation) {} + 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(()); + }; - pub(crate) fn elf_relocation_flags(&self, reloc: &Relocation) -> Result { let r_type = match self.architecture { - Architecture::Aarch64 => match (reloc.kind, reloc.encoding, reloc.size) { + 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, @@ -173,54 +182,48 @@ impl<'a> Object<'a> { | (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) { + Architecture::Aarch64_Ilp32 => match (kind, encoding, 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) { + Architecture::Arm => match (kind, encoding, 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) { + Architecture::Avr => match (kind, encoding, 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) { + Architecture::Bpf => match (kind, encoding, 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) { + Architecture::Csky => match (kind, encoding, 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) { + 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, @@ -231,43 +234,36 @@ impl<'a> Object<'a> { (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::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 (reloc.kind, reloc.encoding, reloc.size) { + }, + Architecture::Hexagon => match (kind, encoding, 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) { + 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, @@ -284,59 +280,49 @@ impl<'a> Object<'a> { | (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::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 (reloc.kind, reloc.encoding, reloc.size) { + }, + Architecture::Msp430 => match (kind, encoding, 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) { + Architecture::PowerPc => match (kind, encoding, 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) { + Architecture::PowerPc64 => match (kind, encoding, 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::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 } - } - Architecture::S390x => match (reloc.kind, reloc.encoding, reloc.size) { + _ => { + 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, @@ -373,59 +359,49 @@ impl<'a> Object<'a> { (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) { + Architecture::Sbf => match (kind, encoding, 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::Sparc64 => match (reloc.kind, reloc.encoding, reloc.size) { + 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, - (RelocationKind::Elf(x), _, _) => x, _ => { return Err(Error(format!("unimplemented relocation {:?}", reloc))); } }, - Architecture::Xtensa => match (reloc.kind, reloc.encoding, reloc.size) { + Architecture::Xtensa => match (kind, encoding, 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))); - } + return Err(Error(format!("unimplemented relocation {:?}", reloc))); } }; - Ok(RelocationFlags::Elf { r_type }) + reloc.flags = RelocationFlags::Elf { r_type }; + Ok(()) } - pub(crate) fn elf_adjust_addend( - &mut self, - _relocation: &mut crate::write::RawRelocation, - ) -> Result { + pub(crate) fn elf_adjust_addend(&mut self, _relocation: &mut Relocation) -> Result { // Determine whether the addend is stored in the relocation or the data. let implicit = !self.elf_has_relocation_addend()?; Ok(implicit) } - pub(crate) fn elf_relocation_size(&self, reloc: &crate::write::RawRelocation) -> Result { + pub(crate) fn elf_relocation_size(&self, reloc: &Relocation) -> Result { let r_type = if let RelocationFlags::Elf { r_type } = reloc.flags { r_type } else { diff --git a/src/write/macho.rs b/src/write/macho.rs index 850c6503..0aea9c7d 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,22 @@ impl<'a> Object<'a> { init_symbol_id } - pub(crate) fn macho_translate_relocation(&mut self, relocation: &mut Relocation) { + 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!(relocation.size, 12 | 21 | 26) { - relocation.size = 32; + if self.architecture == Architecture::Aarch64 && matches!(size, 12 | 21 | 26) { + size = 32; } - } - - pub(crate) fn macho_relocation_flags(&self, reloc: &Relocation) -> Result { - let r_length = match reloc.size { + let r_length = match size { 8 => 0, 16 => 1, 32 => 2, @@ -267,13 +278,13 @@ impl<'a> Object<'a> { _ => return Err(Error(format!("unimplemented reloc size {:?}", reloc))), }; let (r_pcrel, r_type) = match self.architecture { - Architecture::I386 => match reloc.kind { + Architecture::I386 => match kind { RelocationKind::Absolute => (false, macho::GENERIC_RELOC_VANILLA), _ => { return Err(Error(format!("unimplemented relocation {:?}", reloc))); } }, - Architecture::X86_64 => match (reloc.kind, reloc.encoding) { + Architecture::X86_64 => match (kind, encoding) { (RelocationKind::Absolute, RelocationEncoding::Generic) => { (false, macho::X86_64_RELOC_UNSIGNED) } @@ -295,46 +306,34 @@ impl<'a> Object<'a> { (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))); - } + Architecture::Aarch64 | Architecture::Aarch64_Ilp32 => match (kind, encoding) { + (RelocationKind::Absolute, RelocationEncoding::Generic) => { + (false, macho::ARM64_RELOC_UNSIGNED) } - } - _ => { - if let RelocationKind::MachO { value, relative } = reloc.kind { - (relative, value) - } else { + (RelocationKind::Relative, RelocationEncoding::AArch64Call) => { + (true, macho::ARM64_RELOC_BRANCH26) + } + _ => { return Err(Error(format!("unimplemented relocation {:?}", reloc))); } + }, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); } }; - Ok(RelocationFlags::MachO { + reloc.flags = RelocationFlags::MachO { r_type, r_pcrel, r_length, - }) + }; + Ok(()) } - pub(crate) fn macho_adjust_addend( - &mut self, - relocation: &mut crate::write::RawRelocation, - ) -> Result { + 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 @@ -376,7 +375,7 @@ impl<'a> Object<'a> { Ok(implicit) } - pub(crate) fn macho_relocation_size(&self, reloc: &crate::write::RawRelocation) -> Result { + pub(crate) fn macho_relocation_size(&self, reloc: &Relocation) -> Result { if let RelocationFlags::MachO { r_length, .. } = reloc.flags { Ok(8 << r_length) } else { diff --git a/src/write/mod.rs b/src/write/mod.rs index 22d48cc9..f728a015 100644 --- a/src/write/mod.rs +++ b/src/write/mod.rs @@ -523,30 +523,13 @@ impl<'a> Object<'a> { #[cfg(feature = "coff")] BinaryFormat::Coff => self.coff_translate_relocation(&mut relocation)?, #[cfg(feature = "elf")] - BinaryFormat::Elf => self.elf_translate_relocation(&mut relocation), + BinaryFormat::Elf => self.elf_translate_relocation(&mut relocation)?, #[cfg(feature = "macho")] - BinaryFormat::MachO => self.macho_translate_relocation(&mut relocation), + BinaryFormat::MachO => self.macho_translate_relocation(&mut relocation)?, #[cfg(feature = "xcoff")] - BinaryFormat::Xcoff => self.xcoff_translate_relocation(&mut relocation), + BinaryFormat::Xcoff => self.xcoff_translate_relocation(&mut relocation)?, _ => unimplemented!(), } - let flags = match self.format { - #[cfg(feature = "coff")] - BinaryFormat::Coff => self.coff_relocation_flags(&relocation)?, - #[cfg(feature = "elf")] - BinaryFormat::Elf => self.elf_relocation_flags(&relocation)?, - #[cfg(feature = "macho")] - BinaryFormat::MachO => self.macho_relocation_flags(&relocation)?, - #[cfg(feature = "xcoff")] - BinaryFormat::Xcoff => self.xcoff_relocation_flags(&relocation)?, - _ => unimplemented!(), - }; - let mut relocation = RawRelocation { - offset: relocation.offset, - symbol: relocation.symbol, - addend: relocation.addend, - flags, - }; let implicit = match self.format { #[cfg(feature = "coff")] BinaryFormat::Coff => self.coff_adjust_addend(&mut relocation)?, @@ -569,7 +552,7 @@ impl<'a> Object<'a> { fn write_relocation_addend( &mut self, section: SectionId, - relocation: &RawRelocation, + relocation: &Relocation, ) -> Result<()> { let size = match self.format { #[cfg(feature = "coff")] @@ -723,7 +706,7 @@ pub struct Section<'a> { size: u64, align: u64, data: Cow<'a, [u8]>, - relocations: Vec, + relocations: Vec, symbol: Option, /// Section flags that are specific to each file format. pub flags: SectionFlags, @@ -907,27 +890,6 @@ impl Symbol { /// A relocation in an object file. #[derive(Debug)] 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. - pub symbol: SymbolId, - /// The addend to use in the relocation calculation. - /// - /// This may be in addition to an implicit addend stored at the place of the relocation. - pub addend: i64, -} - -/// Temporary relocation structure introduced during refactor. -#[derive(Debug)] -pub(crate) struct RawRelocation { /// The section offset of the place of the relocation. pub offset: u64, /// The symbol referred to by the relocation. diff --git a/src/write/xcoff.rs b/src/write/xcoff.rs index 4faa734b..c709167d 100644 --- a/src/write/xcoff.rs +++ b/src/write/xcoff.rs @@ -66,26 +66,32 @@ impl<'a> Object<'a> { } } - pub(crate) fn xcoff_translate_relocation(&mut self, _relocation: &mut Relocation) {} + 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(()); + }; - pub(crate) fn xcoff_relocation_flags(&self, reloc: &Relocation) -> Result { - let r_rtype = match reloc.kind { + let r_rtype = match 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_rsize = reloc.size - 1; - Ok(RelocationFlags::Xcoff { r_rtype, r_rsize }) + let r_rsize = size - 1; + reloc.flags = RelocationFlags::Xcoff { r_rtype, r_rsize }; + Ok(()) } - pub(crate) fn xcoff_adjust_addend( - &mut self, - relocation: &mut crate::write::RawRelocation, - ) -> Result { + 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 { @@ -97,7 +103,7 @@ impl<'a> Object<'a> { Ok(true) } - pub(crate) fn xcoff_relocation_size(&self, reloc: &crate::write::RawRelocation) -> Result { + pub(crate) fn xcoff_relocation_size(&self, reloc: &Relocation) -> Result { let r_rsize = if let RelocationFlags::Xcoff { r_rsize, .. } = reloc.flags { r_rsize } else { 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 cd696f60..e5ca670c 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}; 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; @@ -43,11 +43,13 @@ fn coff_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(); @@ -140,11 +142,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(); @@ -267,11 +271,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(); @@ -281,11 +287,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(); @@ -364,11 +372,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(); @@ -377,11 +387,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(); @@ -480,11 +492,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(); @@ -494,11 +508,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(); @@ -570,11 +586,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();