Skip to content

Commit 8c898a9

Browse files
github-actions[bot]filipnavarajkotas
authored
[release/8.0] Make CoreCLR/NativeAOT assembly compile with .subsections_via_symbols on Apple platforms (#92544)
* Make CoreCLR/NativeAOT assembly compile with .subsections_via_symbols on Apple platforms * Fix build with LSE_INSTRUCTIONS_ENABLED_BY_DEFAULT --------- Co-authored-by: Filip Navara <navara@emclient.com> Co-authored-by: Jan Kotas <jkotas@microsoft.com>
1 parent 7027ff1 commit 8c898a9

File tree

7 files changed

+92
-70
lines changed

7 files changed

+92
-70
lines changed

src/coreclr/nativeaot/Runtime/arm64/AllocFast.S

+18-12
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ OFFSETOF__Thread__m_alloc_context__alloc_limit = OFFSETOF__Thread__m_rgbAll
4646
add x2, x2, x12
4747
ldr x13, [x1, #OFFSETOF__Thread__m_alloc_context__alloc_limit]
4848
cmp x2, x13
49-
bhi RhpNewFast_RarePath
49+
bhi LOCAL_LABEL(RhpNewFast_RarePath)
5050

5151
// Update the alloc pointer to account for the allocation.
5252
str x2, [x1, #OFFSETOF__Thread__m_alloc_context__alloc_ptr]
@@ -57,7 +57,7 @@ OFFSETOF__Thread__m_alloc_context__alloc_limit = OFFSETOF__Thread__m_rgbAll
5757
mov x0, x12
5858
ret
5959

60-
RhpNewFast_RarePath:
60+
LOCAL_LABEL(RhpNewFast_RarePath):
6161
mov x1, #0
6262
b C_FUNC(RhpNewObject)
6363
LEAF_END RhpNewFast, _TEXT
@@ -88,12 +88,12 @@ RhpNewFast_RarePath:
8888
bl C_FUNC(RhpGcAlloc)
8989

9090
// Set the new objects MethodTable pointer on success.
91-
cbz x0, NewOutOfMemory
91+
cbz x0, LOCAL_LABEL(NewOutOfMemory)
9292

9393
POP_COOP_PINVOKE_FRAME
9494
EPILOG_RETURN
9595

96-
NewOutOfMemory:
96+
LOCAL_LABEL(NewOutOfMemory):
9797
// This is the OOM failure path. We are going to tail-call to a managed helper that will throw
9898
// an out of memory exception that the caller of this allocator understands.
9999

@@ -113,7 +113,7 @@ NewOutOfMemory:
113113
movz x2, MAX_STRING_LENGTH & 0xFFFF
114114
movk x2, MAX_STRING_LENGTH >> 16, lsl 16
115115
cmp x1, x2
116-
bhi StringSizeOverflow
116+
bhi LOCAL_LABEL(StringSizeOverflow)
117117

118118
// Compute overall allocation size (align(base size + (element size * elements), 8)).
119119
mov w2, #STRING_COMPONENT_SIZE
@@ -139,7 +139,7 @@ NewOutOfMemory:
139139
add x2, x2, x12
140140
ldr x12, [x3, #OFFSETOF__Thread__m_alloc_context__alloc_limit]
141141
cmp x2, x12
142-
bhi C_FUNC(RhpNewArrayRare)
142+
bhi LOCAL_LABEL(RhNewString_Rare)
143143

144144
// Reload new object address into r12.
145145
ldr x12, [x3, #OFFSETOF__Thread__m_alloc_context__alloc_ptr]
@@ -156,14 +156,17 @@ NewOutOfMemory:
156156

157157
ret
158158

159-
StringSizeOverflow:
159+
LOCAL_LABEL(StringSizeOverflow):
160160
// We get here if the length of the final string object can not be represented as an unsigned
161161
// 32-bit value. We are going to tail-call to a managed helper that will throw
162162
// an OOM exception that the caller of this allocator understands.
163163

164164
// x0 holds MethodTable pointer already
165165
mov x1, #1 // Indicate that we should throw OverflowException
166166
b C_FUNC(RhExceptionHandling_FailedAllocation)
167+
168+
LOCAL_LABEL(RhNewString_Rare):
169+
b C_FUNC(RhpNewArrayRare)
167170
LEAF_END RhNewString, _Text
168171

169172
// Allocate one dimensional, zero based array (SZARRAY).
@@ -177,7 +180,7 @@ StringSizeOverflow:
177180
// case (32 dimensional MdArray) is less than 0xffff, and thus the product fits in 64 bits.
178181
mov x2, #0x7FFFFFFF
179182
cmp x1, x2
180-
bhi ArraySizeOverflow
183+
bhi LOCAL_LABEL(ArraySizeOverflow)
181184

182185
ldrh w2, [x0, #OFFSETOF__MethodTable__m_usComponentSize]
183186
umull x2, w1, w2
@@ -204,7 +207,7 @@ StringSizeOverflow:
204207
add x2, x2, x12
205208
ldr x12, [x3, #OFFSETOF__Thread__m_alloc_context__alloc_limit]
206209
cmp x2, x12
207-
bhi C_FUNC(RhpNewArrayRare)
210+
bhi LOCAL_LABEL(RhpNewArray_Rare)
208211

209212
// Reload new object address into x12.
210213
ldr x12, [x3, #OFFSETOF__Thread__m_alloc_context__alloc_ptr]
@@ -221,14 +224,17 @@ StringSizeOverflow:
221224

222225
ret
223226

224-
ArraySizeOverflow:
227+
LOCAL_LABEL(ArraySizeOverflow):
225228
// We get here if the size of the final array object can not be represented as an unsigned
226229
// 32-bit value. We are going to tail-call to a managed helper that will throw
227230
// an overflow exception that the caller of this allocator understands.
228231

229232
// x0 holds MethodTable pointer already
230233
mov x1, #1 // Indicate that we should throw OverflowException
231234
b C_FUNC(RhExceptionHandling_FailedAllocation)
235+
236+
LOCAL_LABEL(RhpNewArray_Rare):
237+
b C_FUNC(RhpNewArrayRare)
232238
LEAF_END RhpNewArray, _TEXT
233239

234240
// Allocate one dimensional, zero based array (SZARRAY) using the slow path that calls a runtime helper.
@@ -254,12 +260,12 @@ ArraySizeOverflow:
254260
bl C_FUNC(RhpGcAlloc)
255261

256262
// Set the new objects MethodTable pointer and length on success.
257-
cbz x0, ArrayOutOfMemory
263+
cbz x0, LOCAL_LABEL(ArrayOutOfMemory)
258264

259265
POP_COOP_PINVOKE_FRAME
260266
EPILOG_RETURN
261267

262-
ArrayOutOfMemory:
268+
LOCAL_LABEL(ArrayOutOfMemory):
263269
// This is the OOM failure path. We are going to tail-call to a managed helper that will throw
264270
// an out of memory exception that the caller of this allocator understands.
265271

src/coreclr/nativeaot/Runtime/arm64/ExceptionHandling.S

+33-33
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@
275275
// where the tail-calling thread had saved LR, which may not match where we have saved LR.
276276

277277
ldr x1, [x2, #OFFSETOF__Thread__m_pvHijackedReturnAddress]
278-
cbz x1, NotHijacked
278+
cbz x1, LOCAL_LABEL(NotHijacked)
279279

280280
ldr x3, [x2, #OFFSETOF__Thread__m_ppvHijackedReturnAddressLocation]
281281

@@ -286,13 +286,13 @@
286286

287287
add x12, sp, #(STACKSIZEOF_ExInfo + SIZEOF__PAL_LIMITED_CONTEXT) // re-compute SP at callsite
288288
cmp x3, x12 // if (m_ppvHijackedReturnAddressLocation < SP at callsite)
289-
blo TailCallWasHijacked
289+
blo LOCAL_LABEL(TailCallWasHijacked)
290290

291291
// normal case where a valid return address location is hijacked
292292
str x1, [x3]
293-
b ClearThreadState
293+
b LOCAL_LABEL(ClearThreadState)
294294

295-
TailCallWasHijacked:
295+
LOCAL_LABEL(TailCallWasHijacked):
296296

297297
// Abnormal case where the return address location is now invalid because we ended up here via a tail
298298
// call. In this case, our hijacked return address should be the correct caller of this method.
@@ -302,13 +302,13 @@ TailCallWasHijacked:
302302
str lr, [sp, #(rsp_offsetof_Context + OFFSETOF__PAL_LIMITED_CONTEXT__LR)]
303303
str lr, [sp, #(rsp_offsetof_Context + OFFSETOF__PAL_LIMITED_CONTEXT__IP)]
304304

305-
ClearThreadState:
305+
LOCAL_LABEL(ClearThreadState):
306306

307307
// clear the Thread's hijack state
308308
str xzr, [x2, #OFFSETOF__Thread__m_ppvHijackedReturnAddressLocation]
309309
str xzr, [x2, #OFFSETOF__Thread__m_pvHijackedReturnAddress]
310310

311-
NotHijacked:
311+
LOCAL_LABEL(NotHijacked):
312312

313313
add x1, sp, #rsp_offsetof_ExInfo // x1 <- ExInfo*
314314
str xzr, [x1, #OFFSETOF__ExInfo__m_exception] // pExInfo->m_exception = null
@@ -429,13 +429,13 @@ NotHijacked:
429429

430430
add x12, x5, #OFFSETOF__Thread__m_ThreadStateFlags
431431

432-
ClearRetry_Catch:
432+
LOCAL_LABEL(ClearRetry_Catch):
433433
ldxr w4, [x12]
434434
bic w4, w4, #TSF_DoNotTriggerGc
435435
stxr w6, w4, [x12]
436-
cbz w6, ClearSuccess_Catch
437-
b ClearRetry_Catch
438-
ClearSuccess_Catch:
436+
cbz w6, LOCAL_LABEL(ClearSuccess_Catch)
437+
b LOCAL_LABEL(ClearRetry_Catch)
438+
LOCAL_LABEL(ClearSuccess_Catch):
439439

440440
//
441441
// set preserved regs to the values expected by the funclet
@@ -487,21 +487,21 @@ ClearSuccess_Catch:
487487
ldr x3, [sp, #rsp_offset_x3] // x3 <- current ExInfo*
488488
ldr x2, [x2, #OFFSETOF__REGDISPLAY__SP] // x2 <- resume SP value
489489

490-
PopExInfoLoop:
490+
LOCAL_LABEL(PopExInfoLoop):
491491
ldr x3, [x3, #OFFSETOF__ExInfo__m_pPrevExInfo] // x3 <- next ExInfo
492-
cbz x3, DonePopping // if (pExInfo == null) { we're done }
492+
cbz x3, LOCAL_LABEL(DonePopping) // if (pExInfo == null) { we're done }
493493
cmp x3, x2
494-
blt PopExInfoLoop // if (pExInfo < resume SP} { keep going }
494+
blt LOCAL_LABEL(PopExInfoLoop) // if (pExInfo < resume SP} { keep going }
495495

496-
DonePopping:
496+
LOCAL_LABEL(DonePopping):
497497
str x3, [x1, #OFFSETOF__Thread__m_pExInfoStackHead] // store the new head on the Thread
498498

499499
PREPARE_EXTERNAL_VAR_INDIRECT_W RhpTrapThreads, 3
500500

501-
tbz x3, #TrapThreadsFlags_AbortInProgress_Bit, NoAbort
501+
tbz x3, #TrapThreadsFlags_AbortInProgress_Bit, LOCAL_LABEL(NoAbort)
502502

503503
ldr x3, [sp, #rsp_offset_is_not_handling_thread_abort]
504-
cbnz x3, NoAbort
504+
cbnz x3, LOCAL_LABEL(NoAbort)
505505

506506
// It was the ThreadAbortException, so rethrow it
507507
// reset SP
@@ -510,7 +510,7 @@ DonePopping:
510510
mov sp, x2
511511
b C_FUNC(RhpThrowHwEx)
512512

513-
NoAbort:
513+
LOCAL_LABEL(NoAbort):
514514
// reset SP and jump to continuation address
515515
mov sp, x2
516516
br x0
@@ -564,13 +564,13 @@ NoAbort:
564564

565565
add x12, x2, #OFFSETOF__Thread__m_ThreadStateFlags
566566

567-
ClearRetry:
567+
LOCAL_LABEL(ClearRetry):
568568
ldxr w4, [x12]
569569
bic w4, w4, #TSF_DoNotTriggerGc
570570
stxr w3, w4, [x12]
571-
cbz w3, ClearSuccess
572-
b ClearRetry
573-
ClearSuccess:
571+
cbz w3, LOCAL_LABEL(ClearSuccess)
572+
b LOCAL_LABEL(ClearRetry)
573+
LOCAL_LABEL(ClearSuccess):
574574

575575
//
576576
// set preserved regs to the values expected by the funclet
@@ -602,13 +602,13 @@ ClearSuccess:
602602
ldr x2, [sp, rsp_FinallyFunclet_offset_thread]
603603

604604
add x12, x2, #OFFSETOF__Thread__m_ThreadStateFlags
605-
SetRetry:
605+
LOCAL_LABEL(SetRetry):
606606
ldxr w1, [x12]
607607
orr w1, w1, #TSF_DoNotTriggerGc
608608
stxr w3, w1, [x12]
609-
cbz w3, SetSuccess
610-
b SetRetry
611-
SetSuccess:
609+
cbz w3, LOCAL_LABEL(SetSuccess)
610+
b LOCAL_LABEL(SetRetry)
611+
LOCAL_LABEL(SetSuccess):
612612

613613
ldp d8, d9, [sp, #0x00]
614614
ldp d10, d11, [sp, #0x10]
@@ -707,13 +707,13 @@ SetSuccess:
707707

708708
add x12, x5, #OFFSETOF__Thread__m_ThreadStateFlags
709709

710-
ClearRetry_Propagate:
710+
LOCAL_LABEL(ClearRetry_Propagate):
711711
ldxr w4, [x12]
712712
bic w4, w4, #TSF_DoNotTriggerGc
713713
stxr w6, w4, [x12]
714-
cbz w6, ClearSuccess_Propagate
715-
b ClearRetry_Propagate
716-
ClearSuccess_Propagate:
714+
cbz w6, LOCAL_LABEL(ClearSuccess_Propagate)
715+
b LOCAL_LABEL(ClearRetry_Propagate)
716+
LOCAL_LABEL(ClearSuccess_Propagate):
717717

718718
//
719719
// set preserved regs to the values expected by the funclet
@@ -749,13 +749,13 @@ ClearSuccess_Propagate:
749749
ldr x3, [sp, #rsp_offset_x3] // x3 <- current ExInfo*
750750
ldr x2, [x2, #OFFSETOF__REGDISPLAY__SP] // x2 <- resume SP value
751751

752-
Propagate_PopExInfoLoop:
752+
LOCAL_LABEL(Propagate_PopExInfoLoop):
753753
ldr x3, [x3, #OFFSETOF__ExInfo__m_pPrevExInfo] // x3 <- next ExInfo
754-
cbz x3, Propagate_DonePopping // if (pExInfo == null) { we're done }
754+
cbz x3, LOCAL_LABEL(Propagate_DonePopping) // if (pExInfo == null) { we're done }
755755
cmp x3, x2
756-
blt Propagate_PopExInfoLoop // if (pExInfo < resume SP} { keep going }
756+
blt LOCAL_LABEL(Propagate_PopExInfoLoop) // if (pExInfo < resume SP} { keep going }
757757

758-
Propagate_DonePopping:
758+
LOCAL_LABEL(Propagate_DonePopping):
759759
str x3, [x1, #OFFSETOF__Thread__m_pExInfoStackHead] // store the new head on the Thread
760760

761761
// restore preemptive mode

src/coreclr/nativeaot/Runtime/arm64/GcProbe.S

+7-5
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ NESTED_ENTRY RhpGcProbeHijack, _TEXT, NoHandler
127127
FixupHijackedCallstack
128128

129129
PREPARE_EXTERNAL_VAR_INDIRECT_W RhpTrapThreads, 3
130-
tbnz x3, #TrapThreadsFlags_TrapThreads_Bit, WaitForGC
130+
tbnz x3, #TrapThreadsFlags_TrapThreads_Bit, LOCAL_LABEL(WaitForGC)
131131
ret
132132

133-
WaitForGC:
133+
LOCAL_LABEL(WaitForGC):
134134
orr x12, x12, DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_X0 + PTFF_SAVE_X1
135135
b C_FUNC(RhpWaitForGC)
136136
NESTED_END RhpGcProbeHijack
@@ -144,11 +144,11 @@ NESTED_ENTRY RhpWaitForGC, _TEXT, NoHandler
144144
bl C_FUNC(RhpWaitForGC2)
145145

146146
ldr x2, [sp, #OFFSETOF__PInvokeTransitionFrame__m_Flags]
147-
tbnz x2, #PTFF_THREAD_ABORT_BIT, ThrowThreadAbort
147+
tbnz x2, #PTFF_THREAD_ABORT_BIT, LOCAL_LABEL(ThrowThreadAbort)
148148

149149
POP_PROBE_FRAME
150150
EPILOG_RETURN
151-
ThrowThreadAbort:
151+
LOCAL_LABEL(ThrowThreadAbort):
152152
POP_PROBE_FRAME
153153
mov w0, #STATUS_REDHAWK_THREAD_ABORT
154154
mov x1, lr // return address as exception PC
@@ -159,8 +159,10 @@ NESTED_END RhpWaitForGC
159159

160160
LEAF_ENTRY RhpGcPoll
161161
PREPARE_EXTERNAL_VAR_INDIRECT_W RhpTrapThreads, 0
162-
cbnz w0, C_FUNC(RhpGcPollRare) // TrapThreadsFlags_None = 0
162+
cbnz w0, LOCAL_LABEL(RhpGcPoll_Rare) // TrapThreadsFlags_None = 0
163163
ret
164+
LOCAL_LABEL(RhpGcPoll_Rare):
165+
b C_FUNC(RhpGcPollRare)
164166
LEAF_END RhpGcPoll
165167

166168
NESTED_ENTRY RhpGcPollRare, _TEXT, NoHandler

0 commit comments

Comments
 (0)