diff --git a/lib/ExecutionEngine/JITLink/MachO_arm64.cpp b/lib/ExecutionEngine/JITLink/MachO_arm64.cpp index 701ddb4a8ae..169e20a1d1d 100644 --- a/lib/ExecutionEngine/JITLink/MachO_arm64.cpp +++ b/lib/ExecutionEngine/JITLink/MachO_arm64.cpp @@ -413,9 +413,8 @@ public: PerGraphGOTAndPLTStubsBuilder_MachO_arm64>::PerGraphGOTAndPLTStubsBuilder; bool isGOTEdgeToFix(Edge &E) const { - return (E.getKind() == GOTPage21 || E.getKind() == GOTPageOffset12 || - E.getKind() == PointerToGOT) && - E.getTarget().isExternal(); + return E.getKind() == GOTPage21 || E.getKind() == GOTPageOffset12 || + E.getKind() == PointerToGOT; } Symbol &createGOTEntry(Symbol &Target) { diff --git a/test/ExecutionEngine/JITLink/AArch64/MachO_arm64_relocations.s b/test/ExecutionEngine/JITLink/AArch64/MachO_arm64_relocations.s index e09857ffc74..67f07857f82 100644 --- a/test/ExecutionEngine/JITLink/AArch64/MachO_arm64_relocations.s +++ b/test/ExecutionEngine/JITLink/AArch64/MachO_arm64_relocations.s @@ -52,6 +52,23 @@ test_gotpage21_external: test_gotpageoff12_external: ldr x0, [x0, external_data@GOTPAGEOFF] +# Check ARM64_RELOC_GOTPAGE21 / ARM64_RELOC_GOTPAGEOFF12 handling with a +# reference to a defined symbol. Validate both the reference to the GOT entry, +# and also the content of the GOT entry. +# jitlink-check: *{8}(got_addr(macho_reloc.o, named_data)) = named_data +# jitlink-check: decode_operand(test_gotpage21_defined, 1) = \ +# jitlink-check: (got_addr(macho_reloc.o, named_data)[32:12] - \ +# jitlink-check: test_gotpage21_defined[32:12]) +# jitlink-check: decode_operand(test_gotpageoff12_defined, 2) = \ +# jitlink-check: got_addr(macho_reloc.o, named_data)[11:3] + .globl test_gotpage21_defined + .p2align 2 +test_gotpage21_defined: + adrp x0, named_data@GOTPAGE + .globl test_gotpageoff12_defined +test_gotpageoff12_defined: + ldr x0, [x0, named_data@GOTPAGEOFF] + # Check ARM64_RELOC_PAGE21 / ARM64_RELOC_PAGEOFF12 handling with a reference to # a local symbol. #