在 2026-9-25 20:59, Pali Rohár 写道:
This completely differs from gcc output. If I understood the code
correctly the stack layout is:

   8 bytes return address
   8 bytes rbp
   8 bytes rsi
   1544 bytes for local variables
   <--- here points original %rsp (new %rbp+128)



So those 3 lines (context.Rip, context.Rsp, context.Rbp) are highly
dependent on the compiler version. The only thing which seems to be
correct is "context.Rip".

What we could do with it? Just to note that even current version of the
_invoke_watson in mingw-w64 git is broken.

`context.Rbp` should always be filled by `RtlVirtualUnwind()`.

`context.Rip` is `__builtin_return_address(0)`; I think there's no need to call `__builtin_extract_return_addr()` for x86 (32 or 64).

`context.Rsp` is the stack top of the caller frame so this should be `__builtin_dwarf_cfa()`. Despite the name, it doesn't seem to have anything to do with DWARF.


--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to