[PATCH 3/4] ntdll: Add CFI expressions for __wine_syscall_dispatcher.

Jinoh Kang jinoh.kang.kr at gmail.com
Wed Feb 9 10:03:13 CST 2022


On 2/10/22 01:00, Jinoh Kang wrote:
> On 2/8/22 04:05, Rémi Bernon wrote:
>> Making sure stack pointer points to previous syscall / exit frame before
>> entering a syscall, and restoring the PE frame information on return.
>>
>> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52213
>> Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
>> ---
>>  dlls/ntdll/unix/signal_i386.c   | 9 +++++++++
>>  dlls/ntdll/unix/signal_x86_64.c | 9 +++++++++
>>  2 files changed, 18 insertions(+)
>>
>> diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c
>> index d98a3b1d4bb..2f6e2fd4153 100644
>> --- a/dlls/ntdll/unix/signal_i386.c
>> +++ b/dlls/ntdll/unix/signal_i386.c
>> @@ -2492,6 +2492,9 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher,
>>                     "movl %esi,0x30(%ecx)\n\t"
>>                     "movl %ebp,0x34(%ecx)\n\t"
>>                     "leal 0x34(%ecx),%ebp\n\t"
>> +                   __ASM_CFI(".cfi_def_cfa %ebp,0\n\t")
> 
> This changes the value of CFA.  By definition, the actual value of CFA (not the CFA register) may never change within the context of a subroutine activation [1].
> If we desire to switch CFA to a different frame anyway (with EIP overriden), we must end the current FDE with ".cfi_endproc" and start another FDE with ".cfi_startproc simple".
> See [2] and [3] for how glibc achieves this.
> 
>> +                   __ASM_CFI(".cfi_rel_offset %eip,-0x2c\n\t")
> 
> This is the system call return address, which would be in a PE module.
> I don't think this is very useful, since we will later switch to the exit frame anyway.
> 
>> +                   __ASM_CFI(".cfi_rel_offset %esp,-0x28\n\t")
> 
> This makes GDB unhappy: "previous frame inner to this frame (corrupt stack)?" [4].

Oops, I forgot the link.  It's at https://stackoverflow.com/questions/52518857/stackful-coroutines-gdb-previous-frame-inner-to-this-frame-corrupt-stack.  My apologies.



-- 
Sincerely,
Jinoh Kang



More information about the wine-devel mailing list