在 2022-12-24 06:14, Pali Rohár 写道:
I just quickly tested it only in wine. Without LTO it prints "ł$" (really strange, looks like some memory problem, maybe in wine?).
Oops, sorry forgot that the callback for `__cxa_thread_atexit` should be specified with `__cdecl`, otherwise its argument (the second argument for `__cxa_thread_atexit`) will be passed incorrectly on i686.
This can be rectified like this:
```
typedef void __thiscall atexit_func(void*);
extern int __cxa_thread_atexit(atexit_func*, void*, void*);
extern void* __dso_handle;
extern int puts(const char*);
void
__thiscall
puts_wrapper(void* param)
{
puts(param);
}
int
main(void)
{
/* print a string upon the current thread's exit. */
__cxa_thread_atexit(puts_wrapper, "test thread atexit",
&__dso_handle);
}
```
And with LTO it prints nothing. When I added __attribute__((used)) for those 3 symbols then it started printing "ő<".
So the attribute seems necessary. Patches are welcome. -- Best regards, LIU Hao
OpenPGP_signature
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
