crt: tls: Move _register_thread_local_exe_atexit_callback into own source unit and do not call it for DLL builds
Add a new internal function __mingw_register_thread_local_exe_atexit_callback
which will call the CRT _register_thread_local_exe_atexit_callback() function
with the mingw-w64 supplied callback function. Supplied callback function
for now just calls the __mingw_cxa_atexit_callback_ptr (which is pointer to
the tls_atexit_callback) previously directly passed as argument to
_register_thread_local_exe_atexit_callback().
Stores pointer of the __mingw_register_thread_local_exe_atexit_callback
into the tentative __mingw_register_thread_local_exe_atexit_callback_ptr
variable and call it from crtexe.c on demand when is linked into final
exectuable. And reference the __mingw_register_thread_local_exe_atexit_callback
symbol from tls_atexit.c where is the __mingw_cxa_atexit_callback_ptr
defined and expected to be __mingw_register_thread_local_exe_atexit_callback
called from CRT EXE startup code.
With these tenative definitions, the _register_thread_local_exe_atexit_callback()
would be included in final binary image only if the callback is really
required and only for EXE builds.
Before this change the _register_thread_local_exe_atexit_callback() with
tls_atexit_callback argument was called from PE TLS DLL_PROCESS_ATTACH
callback. After this change, _register_thread_local_exe_atexit_callback()
(with new mingw-w64 callback which calls tls_atexit_callback via
__mingw_cxa_atexit_callback_ptr) is called from new function
__mingw_register_thread_local_exe_atexit_callback() which is called from
CRT EXE startup code (crtexe.c).
Also extend documentation for tls_atexit_callback and tls_callback.
Signed-off-by: LIU Hao <lh_mouse@126.com>
5 files changed