From: Lang Hames Date: Fri, 11 Oct 2019 01:50:31 +0000 (+0000) Subject: [JITLink] Fix MachO/arm64 GOTPAGEOFF encoding. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=76392d9eda0f48dd03255d9123cfe958b5ae453e;p=llvm [JITLink] Fix MachO/arm64 GOTPAGEOFF encoding. 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 --- diff --git a/lib/ExecutionEngine/JITLink/MachO_arm64.cpp b/lib/ExecutionEngine/JITLink/MachO_arm64.cpp index ab33631ceeb..945343bff89 100644 --- a/lib/ExecutionEngine/JITLink/MachO_arm64.cpp +++ b/lib/ExecutionEngine/JITLink/MachO_arm64.cpp @@ -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; }