[MCJIT] Defer application of AArch64 MachO GOT relocations until resolve time.
authorLang Hames <lhames@gmail.com>
Tue, 21 Oct 2014 23:41:15 +0000 (23:41 +0000)
committerLang Hames <lhames@gmail.com>
Tue, 21 Oct 2014 23:41:15 +0000 (23:41 +0000)
On AArch64, GOT references are page relative (ADRP + LDR), so they can't be
applied until we know exactly where, within a page, the GOT entry will be in
the target address space.

Fixes <rdar://problem/18693976>.

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

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

index 980daaaf62524f214f5bd4dcbf1d75a792c33e8a..f5cf9ac29bf4cc8d6b3d810bccbb929ebfe4fde3 100644 (file)
@@ -368,9 +368,9 @@ private:
     assert(RE.Size == 2);
     SectionEntry &Section = Sections[RE.SectionID];
     StubMap::const_iterator i = Stubs.find(Value);
-    uintptr_t Addr;
+    int64_t Offset;
     if (i != Stubs.end())
-      Addr = reinterpret_cast<uintptr_t>(Section.Address) + i->second;
+      Offset = static_cast<int64_t>(i->second);
     else {
       // FIXME: There must be a better way to do this then to check and fix the
       // alignment every time!!!
@@ -391,11 +391,11 @@ private:
       else
         addRelocationForSection(GOTRE, Value.SectionID);
       Section.StubOffset = StubOffset + getMaxStubSize();
-      Addr = StubAddress;
+      Offset = static_cast<int64_t>(StubOffset);
     }
-    RelocationEntry TargetRE(RE.SectionID, RE.Offset, RE.RelType, /*Addend=*/0,
+    RelocationEntry TargetRE(RE.SectionID, RE.Offset, RE.RelType, Offset,
                              RE.IsPCRel, RE.Size);
-    resolveRelocation(TargetRE, static_cast<uint64_t>(Addr));
+    addRelocationForSection(TargetRE, RE.SectionID);
   }
 };
 }
index 29c95e6ce353af8ddf8a1f3d386ca1ba33aa77be..04d269e2aebf11241784420d7d59d6b867e01b32 100644 (file)
@@ -1,5 +1,5 @@
 # RUN: llvm-mc -triple=arm64-apple-ios7.0.0 -code-model=small -relocation-model=pic -filetype=obj -o %T/foo.o %s
-# RUN: llvm-rtdyld -triple=arm64-apple-ios7.0.0 -verify -check=%s %/T/foo.o
+# RUN: llvm-rtdyld -triple=arm64-apple-ios7.0.0 -map-section foo.o,__text=0x10bc0 -verify -check=%s %/T/foo.o
 
     .section  __TEXT,__text,regular,pure_instructions
     .ios_version_min 7, 0