]> granicus.if.org Git - llvm/commitdiff
[JITLink] Fix MachO/arm64 GOTPAGEOFF encoding.
authorLang Hames <lhames@gmail.com>
Fri, 11 Oct 2019 01:50:31 +0000 (01:50 +0000)
committerLang Hames <lhames@gmail.com>
Fri, 11 Oct 2019 01:50:31 +0000 (01:50 +0000)
The original implementation failed to shift the immediate down.

This should fix some of the bot failures due to r374476.

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

lib/ExecutionEngine/JITLink/MachO_arm64.cpp

index ab33631ceeb2436f3122ab77c61d676d69c2cecb..945343bff89d24caca52cec764100e0a554cd253 100644 (file)
@@ -614,12 +614,15 @@ private:
     }
     case GOTPageOffset12: {
       assert(E.getAddend() == 0 && "GOTPAGEOF12 with non-zero addend");
-      uint64_t TargetOffset = E.getTarget().getAddress() & 0xfff;
 
       uint32_t RawInstr = *(ulittle32_t *)FixupPtr;
       assert((RawInstr & 0xfffffc00) == 0xf9400000 &&
              "RawInstr isn't a 64-bit LDR immediate");
-      uint32_t FixedInstr = RawInstr | (TargetOffset << 10);
+
+      uint32_t TargetOffset = E.getTarget().getAddress() & 0xfff;
+      assert((TargetOffset & 0x7) == 0 && "GOT entry is not 8-byte aligned");
+      uint32_t EncodedImm = (TargetOffset >> 3) << 10;
+      uint32_t FixedInstr = RawInstr | EncodedImm;
       *(ulittle32_t *)FixupPtr = FixedInstr;
       break;
     }