Starting with LLVM 17, having non-private labels between `.cfi_startproc`/`.cfi_endproc` triggers "invalid CFI advance_loc expression" errors when targeting Mach-O.
Use local labels instead, and store the pointer in `.data` so it can be read by `handle_syscall_trap()`.
Based on a patch by Jacek Caban.
From: Brendan Shanks bshanks@codeweavers.com
LLVM no longer allows non-private labels to appear between .cfi_startproc/endproc when targeting Mach-O.
Based on a patch by Jacek Caban.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55863 --- dlls/ntdll/unix/signal_x86_64.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c index 17a558da74c..8dd976fb987 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -1879,15 +1879,15 @@ static BOOL handle_syscall_trap( ucontext_t *sigcontext )
if ((void *)RIP_sig( sigcontext ) == __wine_syscall_dispatcher) { - extern void __wine_syscall_dispatcher_prolog_end(void); + extern const void *__wine_syscall_dispatcher_prolog_end_ptr;
- RIP_sig( sigcontext ) = (ULONG64)__wine_syscall_dispatcher_prolog_end; + RIP_sig( sigcontext ) = (ULONG64)__wine_syscall_dispatcher_prolog_end_ptr; } else if ((void *)RIP_sig( sigcontext ) == __wine_unix_call_dispatcher) { - extern void __wine_unix_call_dispatcher_prolog_end(void); + extern const void *__wine_unix_call_dispatcher_prolog_end_ptr;
- RIP_sig( sigcontext ) = (ULONG64)__wine_unix_call_dispatcher_prolog_end; + RIP_sig( sigcontext ) = (ULONG64)__wine_unix_call_dispatcher_prolog_end_ptr; R10_sig( sigcontext ) = RCX_sig( sigcontext ); } else return FALSE; @@ -2594,8 +2594,7 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "popq 0x80(%rcx)\n\t" __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t") "movl $0,0xb4(%rcx)\n\t" /* frame->restore_flags */ - ".globl " __ASM_NAME("__wine_syscall_dispatcher_prolog_end") "\n" - __ASM_NAME("__wine_syscall_dispatcher_prolog_end") ":\n\t" + __ASM_LOCAL_LABEL("__wine_syscall_dispatcher_prolog_end") ":\n\t" "movq %rax,0x00(%rcx)\n\t" "movq %rbx,0x08(%rcx)\n\t" __ASM_CFI_REG_IS_AT1(rbx, rcx, 0x08) @@ -2831,8 +2830,7 @@ __ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher, __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t") __ASM_CFI_REG_IS_AT2(rip, rcx, 0xf0,0x00) "movl $0,0xb4(%rcx)\n\t" /* frame->restore_flags */ - ".globl " __ASM_NAME("__wine_unix_call_dispatcher_prolog_end") "\n" - __ASM_NAME("__wine_unix_call_dispatcher_prolog_end") ":\n\t" + __ASM_LOCAL_LABEL("__wine_unix_call_dispatcher_prolog_end") ":\n\t" "movq %rbx,0x08(%rcx)\n\t" __ASM_CFI_REG_IS_AT1(rbx, rcx, 0x08) "movq %rsi,0x20(%rcx)\n\t" @@ -2930,6 +2928,14 @@ __ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher, __ASM_CFI(".cfi_adjust_cfa_offset 8\n\t") "ret" )
+asm( ".data\n\t" + ".globl " __ASM_NAME("__wine_syscall_dispatcher_prolog_end_ptr") "\n" + __ASM_NAME("__wine_syscall_dispatcher_prolog_end_ptr") ":\n\t" + ".8byte " __ASM_LOCAL_LABEL("__wine_syscall_dispatcher_prolog_end") "\n\t" + ".globl " __ASM_NAME("__wine_unix_call_dispatcher_prolog_end_ptr") "\n" + __ASM_NAME("__wine_unix_call_dispatcher_prolog_end_ptr") ":\n\t" + ".8byte " __ASM_LOCAL_LABEL("__wine_unix_call_dispatcher_prolog_end") "\n\t" + ".text\n\t" );
/*********************************************************************** * __wine_setjmpex