Since recently, unwinding never should need to look at the unix libs any longer, and as aarch64 requires PE builds, there should be no need to unwind through any .dll.so files any longer.
Remove assembly unwind opcodes in the aarch64 unixlib.
These no longer are needed, as none of the code in unix libraries is being unwound any more.
We could probably remove all the `__ASM_CFI` from all the other `unix/signal_*.c` files, but I kept this limited to aarch64 for now.
From: Martin Storsjö martin@martin.st
Since recently, unwinding never should need to look at the unix libs any longer, and as aarch64 requires PE builds, there should be no need to unwind through any .dll.so files any longer.
Signed-off-by: Martin Storsjö martin@martin.st --- dlls/ntdll/unix/signal_arm64.c | 145 +-------------------------------- 1 file changed, 2 insertions(+), 143 deletions(-)
diff --git a/dlls/ntdll/unix/signal_arm64.c b/dlls/ntdll/unix/signal_arm64.c index 62886c74515..e9482e6f69c 100644 --- a/dlls/ntdll/unix/signal_arm64.c +++ b/dlls/ntdll/unix/signal_arm64.c @@ -202,132 +202,6 @@ static BOOL is_inside_syscall( ucontext_t *sigcontext ) (char *)SP_sig(sigcontext) <= (char *)arm64_thread_data()->syscall_frame); }
-/*********************************************************************** - * dwarf_virtual_unwind - * - * Equivalent of RtlVirtualUnwind for builtin modules. - */ -static NTSTATUS dwarf_virtual_unwind( ULONG64 ip, ULONG64 *frame, CONTEXT *context, - const struct dwarf_fde *fde, const struct dwarf_eh_bases *bases, - PEXCEPTION_ROUTINE *handler, void **handler_data ) -{ - const struct dwarf_cie *cie; - const unsigned char *ptr, *augmentation, *end; - ULONG_PTR len, code_end; - struct frame_info info; - struct frame_state state_stack[MAX_SAVED_STATES]; - int aug_z_format = 0; - unsigned char lsda_encoding = DW_EH_PE_omit; - - memset( &info, 0, sizeof(info) ); - info.state_stack = state_stack; - info.ip = (ULONG_PTR)bases->func; - *handler = NULL; - - cie = (const struct dwarf_cie *)((const char *)&fde->cie_offset - fde->cie_offset); - - /* parse the CIE first */ - - if (cie->version != 1 && cie->version != 3) - { - FIXME( "unknown CIE version %u at %p\n", cie->version, cie ); - return STATUS_INVALID_DISPOSITION; - } - ptr = cie->augmentation + strlen((const char *)cie->augmentation) + 1; - - info.code_align = dwarf_get_uleb128( &ptr ); - info.data_align = dwarf_get_sleb128( &ptr ); - if (cie->version == 1) - info.retaddr_reg = *ptr++; - else - info.retaddr_reg = dwarf_get_uleb128( &ptr ); - info.state.cfa_rule = RULE_CFA_OFFSET; - - TRACE( "function %lx base %p cie %p len %x id %x version %x aug '%s' code_align %lu data_align %ld retaddr %s\n", - ip, bases->func, cie, cie->length, cie->id, cie->version, cie->augmentation, - info.code_align, info.data_align, dwarf_reg_names[info.retaddr_reg] ); - - end = NULL; - for (augmentation = cie->augmentation; *augmentation; augmentation++) - { - switch (*augmentation) - { - case 'z': - len = dwarf_get_uleb128( &ptr ); - end = ptr + len; - aug_z_format = 1; - continue; - case 'L': - lsda_encoding = *ptr++; - continue; - case 'P': - { - unsigned char encoding = *ptr++; - *handler = (void *)dwarf_get_ptr( &ptr, encoding, bases ); - continue; - } - case 'R': - info.fde_encoding = *ptr++; - continue; - case 'S': - info.signal_frame = 1; - continue; - } - FIXME( "unknown augmentation '%c'\n", *augmentation ); - if (!end) return STATUS_INVALID_DISPOSITION; /* cannot continue */ - break; - } - if (end) ptr = end; - - end = (const unsigned char *)(&cie->length + 1) + cie->length; - execute_cfa_instructions( ptr, end, ip, &info, bases ); - - ptr = (const unsigned char *)(fde + 1); - info.ip = dwarf_get_ptr( &ptr, info.fde_encoding, bases ); /* fde code start */ - code_end = info.ip + dwarf_get_ptr( &ptr, info.fde_encoding & 0x0f, bases ); /* fde code length */ - - if (aug_z_format) /* get length of augmentation data */ - { - len = dwarf_get_uleb128( &ptr ); - end = ptr + len; - } - else end = NULL; - - *handler_data = (void *)dwarf_get_ptr( &ptr, lsda_encoding, bases ); - if (end) ptr = end; - - end = (const unsigned char *)(&fde->length + 1) + fde->length; - TRACE( "fde %p len %x personality %p lsda %p code %lx-%lx\n", - fde, fde->length, *handler, *handler_data, info.ip, code_end ); - execute_cfa_instructions( ptr, end, ip, &info, bases ); - *frame = context->Sp; - apply_frame_state( context, &info.state, bases ); - context->ContextFlags |= CONTEXT_UNWOUND_TO_CALL; - /* Set Pc based on Lr; libunwind also does this as part of unw_step. */ - context->Pc = context->Lr; - - TRACE( "next function pc=%016lx\n", context->Pc ); - TRACE(" x0=%016lx x1=%016lx x2=%016lx x3=%016lx\n", - context->X0, context->X1, context->X2, context->X3 ); - TRACE(" x4=%016lx x5=%016lx x6=%016lx x7=%016lx\n", - context->X4, context->X5, context->X6, context->X7 ); - TRACE(" x8=%016lx x9=%016lx x10=%016lx x11=%016lx\n", - context->X8, context->X9, context->X10, context->X11 ); - TRACE(" x12=%016lx x13=%016lx x14=%016lx x15=%016lx\n", - context->X12, context->X13, context->X14, context->X15 ); - TRACE(" x16=%016lx x17=%016lx x18=%016lx x19=%016lx\n", - context->X16, context->X17, context->X18, context->X19 ); - TRACE(" x20=%016lx x21=%016lx x22=%016lx x23=%016lx\n", - context->X20, context->X21, context->X22, context->X23 ); - TRACE(" x24=%016lx x25=%016lx x26=%016lx x27=%016lx\n", - context->X24, context->X25, context->X26, context->X27 ); - TRACE(" x28=%016lx fp=%016lx lr=%016lx sp=%016lx\n", - context->X28, context->Fp, context->Lr, context->Sp ); - - return STATUS_SUCCESS; -} - - /*********************************************************************** * unwind_builtin_dll * @@ -335,23 +209,8 @@ static NTSTATUS dwarf_virtual_unwind( ULONG64 ip, ULONG64 *frame, CONTEXT *conte */ NTSTATUS unwind_builtin_dll( void *args ) { - struct unwind_builtin_dll_params *params = args; - DISPATCHER_CONTEXT *dispatch = params->dispatch; - CONTEXT *context = params->context; - struct dwarf_eh_bases bases; - const struct dwarf_fde *fde = _Unwind_Find_FDE( (void *)(context->Pc - 1), &bases ); - - if (fde) - return dwarf_virtual_unwind( context->Pc, &dispatch->EstablisherFrame, context, fde, - &bases, &dispatch->LanguageHandler, &dispatch->HandlerData ); - - TRACE( "no info found for %lx, assuming leaf function\n", - context->Pc ); - dispatch->LanguageHandler = NULL; - dispatch->EstablisherFrame = context->Sp; - context->Pc = context->Lr; - context->ContextFlags |= CONTEXT_UNWOUND_TO_CALL; - return STATUS_SUCCESS; + ERR("unwinding of builtin dlls not supported\n"); + return STATUS_INVALID_DISPOSITION; }
From: Martin Storsjö martin@martin.st
These no longer are needed, as none of the code in unix libraries is being unwound any more.
Signed-off-by: Martin Storsjö martin@martin.st --- dlls/ntdll/unix/signal_arm64.c | 98 +--------------------------------- 1 file changed, 2 insertions(+), 96 deletions(-)
diff --git a/dlls/ntdll/unix/signal_arm64.c b/dlls/ntdll/unix/signal_arm64.c index e9482e6f69c..782b448bf44 100644 --- a/dlls/ntdll/unix/signal_arm64.c +++ b/dlls/ntdll/unix/signal_arm64.c @@ -62,8 +62,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(seh);
-#include "dwarf.h" - /*********************************************************************** * signal context platform-specific definitions */ @@ -794,26 +792,12 @@ extern NTSTATUS call_user_mode_callback( ULONG64 user_sp, void **ret_ptr, ULONG void *func, TEB *teb ); __ASM_GLOBAL_FUNC( call_user_mode_callback, "stp x29, x30, [sp,#-0xc0]!\n\t" - __ASM_CFI(".cfi_def_cfa_offset 0xc0\n\t") - __ASM_CFI(".cfi_offset 29,-0xc0\n\t") - __ASM_CFI(".cfi_offset 30,-0xb8\n\t") "mov x29, sp\n\t" - __ASM_CFI(".cfi_def_cfa_register 29\n\t") "stp x19, x20, [x29, #0x10]\n\t" - __ASM_CFI(".cfi_rel_offset 19,0x10\n\t") - __ASM_CFI(".cfi_rel_offset 20,0x18\n\t") "stp x21, x22, [x29, #0x20]\n\t" - __ASM_CFI(".cfi_rel_offset 21,0x20\n\t") - __ASM_CFI(".cfi_rel_offset 22,0x28\n\t") "stp x23, x24, [x29, #0x30]\n\t" - __ASM_CFI(".cfi_rel_offset 23,0x30\n\t") - __ASM_CFI(".cfi_rel_offset 24,0x38\n\t") "stp x25, x26, [x29, #0x40]\n\t" - __ASM_CFI(".cfi_rel_offset 25,0x40\n\t") - __ASM_CFI(".cfi_rel_offset 26,0x48\n\t") "stp x27, x28, [x29, #0x50]\n\t" - __ASM_CFI(".cfi_rel_offset 27,0x50\n\t") - __ASM_CFI(".cfi_rel_offset 28,0x58\n\t") "stp d8, d9, [x29, #0x60]\n\t" "stp d10, d11, [x29, #0x70]\n\t" "stp d12, d13, [x29, #0x80]\n\t" @@ -846,39 +830,16 @@ __ASM_GLOBAL_FUNC( user_mode_callback_return, "ldp x5, x29, [x4,#0x110]\n\t" /* prev_frame,syscall_cfa */ "str x5, [x3, #0x2f0]\n\t" /* arm64_thread_data()->syscall_frame */ "sub x29, x29, #0xc0\n\t" - __ASM_CFI(".cfi_def_cfa_register 29\n\t") - __ASM_CFI(".cfi_rel_offset 29,0x00\n\t") - __ASM_CFI(".cfi_rel_offset 30,0x08\n\t") - __ASM_CFI(".cfi_rel_offset 19,0x10\n\t") - __ASM_CFI(".cfi_rel_offset 20,0x18\n\t") - __ASM_CFI(".cfi_rel_offset 21,0x20\n\t") - __ASM_CFI(".cfi_rel_offset 22,0x28\n\t") - __ASM_CFI(".cfi_rel_offset 23,0x30\n\t") - __ASM_CFI(".cfi_rel_offset 24,0x38\n\t") - __ASM_CFI(".cfi_rel_offset 25,0x40\n\t") - __ASM_CFI(".cfi_rel_offset 26,0x48\n\t") - __ASM_CFI(".cfi_rel_offset 27,0x50\n\t") - __ASM_CFI(".cfi_rel_offset 28,0x58\n\t") "ldp x5, x6, [x29, #0xb0]\n\t" "str x6, [x3]\n\t" /* teb->Tib.ExceptionList */ "msr fpcr, x5\n\t" "lsr x5, x5, #32\n\t" "msr fpsr, x5\n\t" "ldp x19, x20, [x29, #0x10]\n\t" - __ASM_CFI(".cfi_same_value 19\n\t") - __ASM_CFI(".cfi_same_value 20\n\t") "ldp x21, x22, [x29, #0x20]\n\t" - __ASM_CFI(".cfi_same_value 21\n\t") - __ASM_CFI(".cfi_same_value 22\n\t") "ldp x23, x24, [x29, #0x30]\n\t" - __ASM_CFI(".cfi_same_value 23\n\t") - __ASM_CFI(".cfi_same_value 24\n\t") "ldp x25, x26, [x29, #0x40]\n\t" - __ASM_CFI(".cfi_same_value 25\n\t") - __ASM_CFI(".cfi_same_value 26\n\t") "ldp x27, x28, [x29, #0x50]\n\t" - __ASM_CFI(".cfi_same_value 27\n\t") - __ASM_CFI(".cfi_same_value 28\n\t") "ldp d8, d9, [x29, #0x60]\n\t" "ldp d10, d11, [x29, #0x70]\n\t" "ldp d12, d13, [x29, #0x80]\n\t" @@ -901,19 +862,6 @@ __ASM_GLOBAL_FUNC( user_mode_abort_thread, "sub x29, x1, #0xc0\n\t" /* switch to kernel stack */ "mov sp, x29\n\t" - __ASM_CFI(".cfi_def_cfa 29,0xc0\n\t") - __ASM_CFI(".cfi_offset 29,-0xc0\n\t") - __ASM_CFI(".cfi_offset 30,-0xb8\n\t") - __ASM_CFI(".cfi_offset 19,-0xb0\n\t") - __ASM_CFI(".cfi_offset 20,-0xa8\n\t") - __ASM_CFI(".cfi_offset 21,-0xa0\n\t") - __ASM_CFI(".cfi_offset 22,-0x98\n\t") - __ASM_CFI(".cfi_offset 23,-0x90\n\t") - __ASM_CFI(".cfi_offset 24,-0x88\n\t") - __ASM_CFI(".cfi_offset 25,-0x80\n\t") - __ASM_CFI(".cfi_offset 26,-0x78\n\t") - __ASM_CFI(".cfi_offset 27,-0x70\n\t") - __ASM_CFI(".cfi_offset 28,-0x68\n\t") "bl " __ASM_NAME("abort_thread") )
@@ -1428,26 +1376,12 @@ void call_init_thunk( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend, TEB */ __ASM_GLOBAL_FUNC( signal_start_thread, "stp x29, x30, [sp,#-0xc0]!\n\t" - __ASM_CFI(".cfi_def_cfa_offset 0xc0\n\t") - __ASM_CFI(".cfi_offset 29,-0xc0\n\t") - __ASM_CFI(".cfi_offset 30,-0xb8\n\t") "mov x29, sp\n\t" - __ASM_CFI(".cfi_def_cfa_register 29\n\t") "stp x19, x20, [x29, #0x10]\n\t" - __ASM_CFI(".cfi_rel_offset 19,0x10\n\t") - __ASM_CFI(".cfi_rel_offset 20,0x18\n\t") "stp x21, x22, [x29, #0x20]\n\t" - __ASM_CFI(".cfi_rel_offset 21,0x20\n\t") - __ASM_CFI(".cfi_rel_offset 22,0x28\n\t") "stp x23, x24, [x29, #0x30]\n\t" - __ASM_CFI(".cfi_rel_offset 23,0x30\n\t") - __ASM_CFI(".cfi_rel_offset 24,0x38\n\t") "stp x25, x26, [x29, #0x40]\n\t" - __ASM_CFI(".cfi_rel_offset 25,0x40\n\t") - __ASM_CFI(".cfi_rel_offset 26,0x48\n\t") "stp x27, x28, [x29, #0x50]\n\t" - __ASM_CFI(".cfi_rel_offset 27,0x50\n\t") - __ASM_CFI(".cfi_rel_offset 28,0x58\n\t") "add x5, x29, #0xc0\n\t" /* syscall_cfa */ /* set syscall frame */ "ldr x4, [x3, #0x2f0]\n\t" /* arm64_thread_data()->syscall_frame */ @@ -1497,20 +1431,7 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "mov x22, x10\n\t" /* switch to kernel stack */ "mov sp, x10\n\t" - /* we're now on the kernel stack, stitch unwind info with previous frame */ - __ASM_CFI_CFA_IS_AT2(x22, 0x98, 0x02) /* frame->syscall_cfa */ - __ASM_CFI(".cfi_offset 29, -0xc0\n\t") - __ASM_CFI(".cfi_offset 30, -0xb8\n\t") - __ASM_CFI(".cfi_offset 19, -0xb0\n\t") - __ASM_CFI(".cfi_offset 20, -0xa8\n\t") - __ASM_CFI(".cfi_offset 21, -0xa0\n\t") - __ASM_CFI(".cfi_offset 22, -0x98\n\t") - __ASM_CFI(".cfi_offset 23, -0x90\n\t") - __ASM_CFI(".cfi_offset 24, -0x88\n\t") - __ASM_CFI(".cfi_offset 25, -0x80\n\t") - __ASM_CFI(".cfi_offset 26, -0x78\n\t") - __ASM_CFI(".cfi_offset 27, -0x70\n\t") - __ASM_CFI(".cfi_offset 28, -0x68\n\t") + /* we're now on the kernel stack */ "and x20, x8, #0xfff\n\t" /* syscall number */ "ubfx x21, x8, #12, #2\n\t" /* syscall table number */ "ldr x16, [x18, #0x2f8]\n\t" /* arm64_thread_data()->syscall_table */ @@ -1533,7 +1454,6 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "ldr x16, [x16, x20, lsl 3]\n\t" "blr x16\n\t" "mov sp, x22\n" - __ASM_CFI_CFA_IS_AT2(sp, 0x98, 0x02) /* frame->syscall_cfa */ __ASM_LOCAL_LABEL("__wine_syscall_dispatcher_return") ":\n\t" "ldr w16, [sp, #0x10c]\n\t" /* frame->restore_flags */ "tbz x16, #1, 2f\n\t" /* CONTEXT_INTEGER */ @@ -1616,26 +1536,12 @@ __ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher, "mov x19, x10\n\t" /* switch to kernel stack */ "mov sp, x10\n\t" - /* we're now on the kernel stack, stitch unwind info with previous frame */ - __ASM_CFI_CFA_IS_AT2(x19, 0x98, 0x02) /* frame->syscall_cfa */ - __ASM_CFI(".cfi_offset 29, -0xc0\n\t") - __ASM_CFI(".cfi_offset 30, -0xb8\n\t") - __ASM_CFI(".cfi_offset 19, -0xb0\n\t") - __ASM_CFI(".cfi_offset 20, -0xa8\n\t") - __ASM_CFI(".cfi_offset 21, -0xa0\n\t") - __ASM_CFI(".cfi_offset 22, -0x98\n\t") - __ASM_CFI(".cfi_offset 23, -0x90\n\t") - __ASM_CFI(".cfi_offset 24, -0x88\n\t") - __ASM_CFI(".cfi_offset 25, -0x80\n\t") - __ASM_CFI(".cfi_offset 26, -0x78\n\t") - __ASM_CFI(".cfi_offset 27, -0x70\n\t") - __ASM_CFI(".cfi_offset 28, -0x68\n\t") + /* we're now on the kernel stack */ "ldr x16, [x0, x1, lsl 3]\n\t" "mov x0, x2\n\t" /* args */ "blr x16\n\t" "ldr w16, [sp, #0x10c]\n\t" /* frame->restore_flags */ "cbnz w16, " __ASM_LOCAL_LABEL("__wine_syscall_dispatcher_return") "\n\t" - __ASM_CFI_CFA_IS_AT2(sp, 0x98, 0x02) /* frame->syscall_cfa */ "ldp x18, x19, [sp, #0x90]\n\t" "ldp x16, x17, [sp, #0xf8]\n\t" /* switch to user stack */
We could probably remove all the `__ASM_CFI` from all the other `unix/signal_*.c` files, but I kept this limited to aarch64 for now.
No, these are still needed for Unix debuggers (on aarch64 too).
On Thu Jan 25 10:16:30 2024 +0000, Alexandre Julliard wrote:
We could probably remove all the `__ASM_CFI` from all the other
`unix/signal_*.c` files, but I kept this limited to aarch64 for now. No, these are still needed for Unix debuggers (on aarch64 too).
Oh, ok, I see - I'll skip that patch then.