Skip to content

Commit 80b6177

Browse files
author
git apple-llvm automerger
committed
Merge commit '8fab83cfeac0' from swift/release/5.3 into swift/master
2 parents 9cd869a + 8fab83c commit 80b6177

File tree

5 files changed

+61
-45
lines changed

5 files changed

+61
-45
lines changed

lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import socket_packet_pump
1313
import subprocess
1414
from lldbsuite.test.lldbtest import *
15+
from lldbsuite.test import configuration
1516

1617
from six.moves import queue
1718

@@ -89,6 +90,10 @@ def get_debugserver_exe():
8990
if "LLDB_DEBUGSERVER_PATH" in os.environ:
9091
return os.environ["LLDB_DEBUGSERVER_PATH"]
9192

93+
if configuration.arch and configuration.arch == "x86_64" and \
94+
platform.machine().startswith("arm64"):
95+
return '/Library/Apple/usr/libexec/oah/debugserver'
96+
9297
return _get_debug_monitor_from_lldb(
9398
lldbtest_config.lldbExec, "debugserver")
9499

lldb/test/API/macosx/macCatalyst/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
C_SOURCES := main.c
22

3-
TRIPLE := $(ARCH)-apple-ios13.0-macabi
3+
override TRIPLE := $(ARCH)-apple-ios13.0-macabi
44
CFLAGS_EXTRAS := -target $(TRIPLE)
55

66
# FIXME: rdar://problem/54986190

lldb/test/API/macosx/macCatalystAppMacOSFramework/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
C_SOURCES := main.c
22
LD_EXTRAS := -L. -lfoo
33

4-
TRIPLE := $(ARCH)-apple-ios13.0-macabi
4+
override TRIPLE := $(ARCH)-apple-ios13.0-macabi
55
CFLAGS_EXTRAS := -target $(TRIPLE)
66

77
# FIXME: rdar://problem/54986190

llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ class MachOLinkGraphBuilder_arm64 : public MachOLinkGraphBuilder {
262262
// If this is an Addend relocation then process it and move to the
263263
// paired reloc.
264264

265-
Addend = RI.r_symbolnum;
265+
Addend = SignExtend64(RI.r_symbolnum, 24);
266266

267267
if (RelItr == RelEnd)
268268
return make_error<JITLinkError>("Unpaired Addend reloc at " +
@@ -345,6 +345,11 @@ class MachOLinkGraphBuilder_arm64 : public MachOLinkGraphBuilder {
345345
TargetSymbol = TargetSymbolOrErr->GraphSymbol;
346346
else
347347
return TargetSymbolOrErr.takeError();
348+
uint32_t Instr = *(const ulittle32_t *)FixupContent;
349+
uint32_t EncodedAddend = (Instr & 0x003FFC00) >> 10;
350+
if (EncodedAddend != 0)
351+
return make_error<JITLinkError>("GOTPAGEOFF12 target has non-zero "
352+
"encoded addend");
348353
break;
349354
}
350355
case GOTPageOffset12: {
@@ -528,23 +533,17 @@ class MachOJITLinker_arm64 : public JITLinker<MachOJITLinker_arm64> {
528533
}
529534

530535
static unsigned getPageOffset12Shift(uint32_t Instr) {
531-
constexpr uint32_t LDRLiteralMask = 0x3ffffc00;
532-
533-
// Check for a GPR LDR immediate with a zero embedded literal.
534-
// If found, the top two bits contain the shift.
535-
if ((Instr & LDRLiteralMask) == 0x39400000)
536-
return Instr >> 30;
536+
constexpr uint32_t LoadStoreImm12Mask = 0x3b000000;
537+
constexpr uint32_t Vec128Mask = 0x04800000;
537538

538-
// Check for a Neon LDR immediate of size 64-bit or less with a zero
539-
// embedded literal. If found, the top two bits contain the shift.
540-
if ((Instr & LDRLiteralMask) == 0x3d400000)
541-
return Instr >> 30;
539+
if ((Instr & LoadStoreImm12Mask) == 0x39000000) {
540+
uint32_t ImplicitShift = Instr >> 30;
541+
if (ImplicitShift == 0)
542+
if ((Instr & Vec128Mask) == Vec128Mask)
543+
ImplicitShift = 4;
542544

543-
// Check for a Neon LDR immediate of size 128-bit with a zero embedded
544-
// literal.
545-
constexpr uint32_t SizeBitsMask = 0xc0000000;
546-
if ((Instr & (LDRLiteralMask | SizeBitsMask)) == 0x3dc00000)
547-
return 4;
545+
return ImplicitShift;
546+
}
548547

549548
return 0;
550549
}
@@ -591,10 +590,12 @@ class MachOJITLinker_arm64 : public JITLinker<MachOJITLinker_arm64> {
591590
}
592591
case Page21:
593592
case GOTPage21: {
594-
assert(E.getAddend() == 0 && "PAGE21/GOTPAGE21 with non-zero addend");
593+
assert((E.getKind() != GOTPage21 || E.getAddend() == 0) &&
594+
"GOTPAGE21 with non-zero addend");
595595
uint64_t TargetPage =
596-
E.getTarget().getAddress() & ~static_cast<uint64_t>(4096 - 1);
597-
uint64_t PCPage = B.getAddress() & ~static_cast<uint64_t>(4096 - 1);
596+
(E.getTarget().getAddress() + E.getAddend()) &
597+
~static_cast<uint64_t>(4096 - 1);
598+
uint64_t PCPage = FixupAddress & ~static_cast<uint64_t>(4096 - 1);
598599

599600
int64_t PageDelta = TargetPage - PCPage;
600601
if (PageDelta < -(1 << 30) || PageDelta > ((1 << 30) - 1))
@@ -610,8 +611,8 @@ class MachOJITLinker_arm64 : public JITLinker<MachOJITLinker_arm64> {
610611
break;
611612
}
612613
case PageOffset12: {
613-
assert(E.getAddend() == 0 && "PAGEOFF12 with non-zero addend");
614-
uint64_t TargetOffset = E.getTarget().getAddress() & 0xfff;
614+
uint64_t TargetOffset =
615+
(E.getTarget().getAddress() + E.getAddend()) & 0xfff;
615616

616617
uint32_t RawInstr = *(ulittle32_t *)FixupPtr;
617618
unsigned ImmShift = getPageOffset12Shift(RawInstr);

llvm/test/ExecutionEngine/JITLink/AArch64/MachO_Arm64_relocations.s

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,61 +58,71 @@ test_gotpageoff12:
5858
# For the GOTPAGEOFF12 relocation we test the ADD instruction, all LDR/GPR
5959
# variants and all LDR/Neon variants.
6060
#
61-
# jitlink-check: decode_operand(test_page21, 1) = (named_data[32:12] - test_page21[32:12])
62-
# jitlink-check: decode_operand(test_pageoff12add, 2) = named_data[11:0]
63-
# jitlink-check: decode_operand(test_pageoff12gpr8, 2) = named_data[11:0]
64-
# jitlink-check: decode_operand(test_pageoff12gpr16, 2) = named_data[11:1]
65-
# jitlink-check: decode_operand(test_pageoff12gpr32, 2) = named_data[11:2]
66-
# jitlink-check: decode_operand(test_pageoff12gpr64, 2) = named_data[11:3]
67-
# jitlink-check: decode_operand(test_pageoff12neon8, 2) = named_data[11:0]
68-
# jitlink-check: decode_operand(test_pageoff12neon16, 2) = named_data[11:1]
69-
# jitlink-check: decode_operand(test_pageoff12neon32, 2) = named_data[11:2]
70-
# jitlink-check: decode_operand(test_pageoff12neon64, 2) = named_data[11:3]
71-
# jitlink-check: decode_operand(test_pageoff12neon128, 2) = named_data[11:4]
61+
# jitlink-check: decode_operand(test_page21, 1) = ((named_data + 256) - test_page21)[32:12]
62+
# jitlink-check: decode_operand(test_pageoff12add, 2) = (named_data + 256)[11:0]
63+
# jitlink-check: decode_operand(test_pageoff12gpr8, 2) = (named_data + 256)[11:0]
64+
# jitlink-cherk: decode_operand(test_pageoff12gpr8s, 2) = (named_data + 256)[11:0]
65+
# jitlink-check: decode_operand(test_pageoff12gpr16, 2) = (named_data + 256)[11:1]
66+
# jitlink-check: decode_operand(test_pageoff12gpr16s, 2) = (named_data + 256)[11:1]
67+
# jitlink-check: decode_operand(test_pageoff12gpr32, 2) = (named_data + 256)[11:2]
68+
# jitlink-check: decode_operand(test_pageoff12gpr64, 2) = (named_data + 256)[11:3]
69+
# jitlink-check: decode_operand(test_pageoff12neon8, 2) = (named_data + 256)[11:0]
70+
# jitlink-check: decode_operand(test_pageoff12neon16, 2) = (named_data + 256)[11:1]
71+
# jitlink-check: decode_operand(test_pageoff12neon32, 2) = (named_data + 256)[11:2]
72+
# jitlink-check: decode_operand(test_pageoff12neon64, 2) = (named_data + 256)[11:3]
73+
# jitlink-check: decode_operand(test_pageoff12neon128, 2) = (named_data + 256)[11:4]
7274
.globl test_page21
7375
.p2align 2
7476
test_page21:
75-
adrp x0, named_data@PAGE
77+
adrp x0, named_data@PAGE + 256
7678

7779
.globl test_pageoff12add
7880
test_pageoff12add:
79-
add x0, x0, named_data@PAGEOFF
81+
add x0, x0, named_data@PAGEOFF + 256
8082

8183
.globl test_pageoff12gpr8
8284
test_pageoff12gpr8:
83-
ldrb w0, [x0, named_data@PAGEOFF]
85+
ldrb w0, [x0, named_data@PAGEOFF + 256]
86+
87+
.globl test_pageoff12gpr8s
88+
test_pageoff12gpr8s:
89+
ldrsb w0, [x0, named_data@PAGEOFF + 256]
8490

8591
.globl test_pageoff12gpr16
8692
test_pageoff12gpr16:
87-
ldrh w0, [x0, named_data@PAGEOFF]
93+
ldrh w0, [x0, named_data@PAGEOFF + 256]
94+
95+
.globl test_pageoff12gpr16s
96+
test_pageoff12gpr16s:
97+
ldrsh w0, [x0, named_data@PAGEOFF + 256]
8898

8999
.globl test_pageoff12gpr32
90100
test_pageoff12gpr32:
91-
ldr w0, [x0, named_data@PAGEOFF]
101+
ldr w0, [x0, named_data@PAGEOFF + 256]
92102

93103
.globl test_pageoff12gpr64
94104
test_pageoff12gpr64:
95-
ldr x0, [x0, named_data@PAGEOFF]
105+
ldr x0, [x0, named_data@PAGEOFF + 256]
96106

97107
.globl test_pageoff12neon8
98108
test_pageoff12neon8:
99-
ldr b0, [x0, named_data@PAGEOFF]
109+
ldr b0, [x0, named_data@PAGEOFF + 256]
100110

101111
.globl test_pageoff12neon16
102112
test_pageoff12neon16:
103-
ldr h0, [x0, named_data@PAGEOFF]
113+
ldr h0, [x0, named_data@PAGEOFF + 256]
104114

105115
.globl test_pageoff12neon32
106116
test_pageoff12neon32:
107-
ldr s0, [x0, named_data@PAGEOFF]
117+
ldr s0, [x0, named_data@PAGEOFF + 256]
108118

109119
.globl test_pageoff12neon64
110120
test_pageoff12neon64:
111-
ldr d0, [x0, named_data@PAGEOFF]
121+
ldr d0, [x0, named_data@PAGEOFF + 256]
112122

113123
.globl test_pageoff12neon128
114124
test_pageoff12neon128:
115-
ldr q0, [x0, named_data@PAGEOFF]
125+
ldr q0, [x0, named_data@PAGEOFF + 256]
116126

117127
# Check that calls to external functions trigger the generation of stubs and GOT
118128
# entries.

0 commit comments

Comments
 (0)