[RuntimeDyld][AArch64] Add explicit addends before calling relocationValueRef.
authorLang Hames <lhames@gmail.com>
Tue, 11 Aug 2015 06:27:53 +0000 (06:27 +0000)
committerLang Hames <lhames@gmail.com>
Tue, 11 Aug 2015 06:27:53 +0000 (06:27 +0000)
relocationValueRef uses the addend, so it has to be set before the call.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244574 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s

index 7bf764114bae8b4e7a61354e700252a101c91a7d..929639cecce4d9358e3f79d65a5c3c1841de9a0e 100644 (file)
@@ -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)
index 04d269e2aebf11241784420d7d59d6b867e01b32..0387b932f1c5891fc940e08c432d61b9b71d0f4c 100644 (file)
@@ -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.