Skip to content

Commit 974f9af

Browse files
authored
Mark labels in x64 write barrier code as local/alt_entry (#119245)
* Mark labels in x64 write barrier code as local/alt_entry to prevent incorrect transformations by the ld64/ld-prime linkers * Fix the LEAF_END_MARKED macro for Apple platforms too * Mark all labels inside JIT_PatchedCode region as .alt_entry on Apple platforms * Another take at eliminating UB in patchedcode.S with Apple linkers * Workaround for broken unwind info * Use classic linker on Xcode 15
1 parent d8f4d2c commit 974f9af

File tree

8 files changed

+217
-94
lines changed

8 files changed

+217
-94
lines changed

eng/native/configurecompiler.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ if (CLR_CMAKE_HOST_UNIX)
3434
endif()
3535
endif()
3636

37+
# Force usage of classic linker on Xcode 15
38+
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND
39+
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15 AND
40+
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
41+
add_link_options("-Wl,-ld_classic")
42+
endif()
43+
3744
if (CMAKE_CONFIGURATION_TYPES) # multi-configuration generator?
3845
set(CMAKE_CONFIGURATION_TYPES "Debug;Checked;Release;RelWithDebInfo" CACHE STRING "" FORCE)
3946
endif (CMAKE_CONFIGURATION_TYPES)

src/coreclr/pal/inc/unixasmmacrosamd64.inc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ C_FUNC(\Name):
5353
.endm
5454

5555
.macro LEAF_END_MARKED Name, Section
56-
C_FUNC(\Name\()_End):
56+
#if defined(__APPLE__)
57+
.alt_entry C_FUNC(\Name\()_End)
58+
.private_extern C_FUNC(\Name\()_End)
59+
#else
5760
.global C_FUNC(\Name\()_End)
61+
#endif
62+
C_FUNC(\Name\()_End):
5863
LEAF_END \Name, \Section
5964
// make sure this symbol gets its own address
6065
nop

src/coreclr/pal/inc/unixasmmacrosarm64.inc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,13 @@ C_FUNC(\Name):
6464
.endm
6565

6666
.macro LEAF_END_MARKED Name, Section
67-
C_FUNC(\Name\()_End):
67+
#if defined(__APPLE__)
68+
.alt_entry C_FUNC(\Name\()_End)
69+
.private_extern C_FUNC(\Name\()_End)
70+
#else
6871
.global C_FUNC(\Name\()_End)
72+
#endif
73+
C_FUNC(\Name\()_End):
6974
LEAF_END \Name, \Section
7075
// make sure this symbol gets its own address
7176
nop

src/coreclr/vm/amd64/CachedInterfaceDispatchCoreCLR.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LEAF_ENTRY RhpVTableOffsetDispatch, _TEXT
2323
// to get the address in the vtable chunk list of what we want to dereference
2424
#ifdef TARGET_APPLE
2525
// Apple's linker has issues which break unwind info if
26-
// an ALTERNATE_ENTRY is present in the middle of a function see https://github.com/dotnet/runtime/pull/114982#discussion_r2083272768
26+
// an ALTERNATE_ENTRY is present in the middle of a function see https://github.com/dotnet/runtime/issues/119005
2727
.cfi_endproc
2828
#endif
2929
ALTERNATE_ENTRY RhpVTableOffsetDispatchAVLocation

0 commit comments

Comments
 (0)