Recent ntdll/unix/signal_x86_64.c changes
commit ea640f6cece7660ffc853b7d574fbe52af34901a Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Sep 11 11:25:29 2023 +0200 ntdll: Ignore attempts to change segment registers on x86-64. moved the following code +#ifdef DS_sig + DS_sig(sigcontext) = ds64_sel; +#else + __asm__ volatile( "movw %0,%%ds" :: "r" (ds64_sel) ); +#endif +#ifdef ES_sig + ES_sig(sigcontext) = ds64_sel; +#else + __asm__ volatile( "movw %0,%%es" :: "r" (ds64_sel) ); +#endif into static inline void leave_handler( const ucontext_t *sigcontext ) Alas this has "const ucontext_t *sigcontext", so platforms like FreeBSD that define DS_sig will try to do DS_sig(sigcontext) = ds64_sel; which results in GCC rightfully diagnosing: dlls/ntdll/unix/signal_x86_64.c: In function ‘leave_handler’: dlls/ntdll/unix/signal_x86_64.c:822:24: error: assignment of member ‘mc_ds’ in read-only object 822 | DS_sig(sigcontext) = ds64_sel; | ^ I submitted https://gitlab.winehq.org/wine/wine/-/merge_requests/3845 which restores the build on FreeBSD and presumably NetBSD, but wonder: Could FreeBSD/NetBSD align with Linux and macOS which d not define DS_sig (and ES_sig) and thus use into different code paths in leave_handler? Gerald
Gerald Pfeifer <gerald(a)pfeifer.com> writes:
I submitted https://gitlab.winehq.org/wine/wine/-/merge_requests/3845 which restores the build on FreeBSD and presumably NetBSD, but wonder:
Could FreeBSD/NetBSD align with Linux and macOS which d not define DS_sig (and ES_sig) and thus use into different code paths in leave_handler?
It depends on whether the kernel restores them from the context on signal return. My guess is that it does since they are defined in ucontext_t. We have tests for this in dlls/ntdll/tests/exception.c, so you can try both approaches and see which one breaks the tests. -- Alexandre Julliard julliard(a)winehq.org
participants (2)
-
Alexandre Julliard -
Gerald Pfeifer