From 0fd3610e6dde8e04e51da4a747e120bcbc9ca097 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 11 Aug 2015 06:27:53 +0000 Subject: [PATCH] [RuntimeDyld][AArch64] Add explicit addends before calling relocationValueRef. relocationValueRef uses the addend, so it has to be set before the call. llvm-svn: 244574 --- .../RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h | 9 ++++----- .../RuntimeDyld/AArch64/MachO_ARM64_relocations.s | 12 ++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h index 7bf7641..929639c 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h @@ -272,15 +272,14 @@ public: RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI)); RE.Addend = decodeAddend(RE); - RelocationValueRef Value( - getRelocationValueRef(Obj, RelI, RE, ObjSectionToID)); assert((ExplicitAddend == 0 || RE.Addend == 0) && "Relocation has "\ "ARM64_RELOC_ADDEND and embedded addend in the instruction."); - if (ExplicitAddend) { + if (ExplicitAddend) RE.Addend = ExplicitAddend; - Value.Offset = ExplicitAddend; - } + + RelocationValueRef Value( + getRelocationValueRef(Obj, RelI, RE, ObjSectionToID)); bool IsExtern = Obj.getPlainRelocationExternal(RelInfo); if (!IsExtern && RE.IsPCRel) diff --git a/llvm/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s b/llvm/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s index 04d269e..0387b93 100644 --- a/llvm/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s +++ b/llvm/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s @@ -55,6 +55,18 @@ ldr2: ldr x0, [x0, _ptr@GOTPAGEOFF] ret +# rtdyld-check: decode_operand(add1, 2) = (tgt+8)[11:2] << 2 + .globl _test_explicit_addend_reloc + .align 4 +_test_explicit_addend_reloc: +add1: + add x0, x0, tgt@PAGEOFF+8 + + .align 3 +tgt: + .long 0 + .long 0 + .long 7 # Test ARM64_RELOC_UNSIGNED relocation. The absolute 64-bit address of the # function should be stored at the 8-byte memory location. -- 2.7.4