godot/platform/windows
Hein-Pieter van Braam-Stewart ff3099abcf Fix thread_local, tls, ASLR, and DEP with MingW
This commit changes the way Thread::caller_id works. By moving caller_id
to the .cpp file we make sure that the TLS variable doesn't get
relocated twice causing a crash. Since we build with LTO for release
builds (and everyone should be doing that anyway) there is no extra
overhead from the non-static method. We do do an extra bool check now
there but I don't think this will add much in the way of overhead.

This check cannot be avoided if we still want to be able to cache the
thread ID hash, as we had to move the setter because of limitations of
the WinRT platform. The original workaround for this was in #46813 but
this has some unintended consequences. Specifically; threads that never
create a Thread object will always return 0 in Thread::get_caller_id()
which caused a regression. For instance the editor now freezes when
importing large textures. This PR also addresses that.

Additionally we now enable ASLR support when building with MingW, this
includes a workaround for MingW. MingW refuses to create an appropriate
relocation table if no symbols are exported. So we just export the
various main() functions in godot_windows.cpp.

While ASLR support isn't criticial for Godot, previous versions of Godot
just happened to work with a dynamic base 'by accident' and some users
run Godot this way. After the thread change the .tls section now needs
relocations to make this work. By enabling ASLR at build-time we create
these relocations and people who forced ALSR on previously will now get
a working Godot again.

This fixes #47256 and fixes #47219

This is the 3.x version of this PR. For master a different approach is
possible which I will make in the coming days.
2021-03-25 23:20:12 +01:00
..
export
SCsub
context_gl_windows.cpp
context_gl_windows.h
crash_handler_windows.cpp
crash_handler_windows.h
detect.py Fix thread_local, tls, ASLR, and DEP with MingW 2021-03-25 23:20:12 +01:00
godot.ico
godot.natvis
godot_res.rc
godot_windows.cpp Fix thread_local, tls, ASLR, and DEP with MingW 2021-03-25 23:20:12 +01:00
joypad_windows.cpp
joypad_windows.h
key_mapping_windows.cpp
key_mapping_windows.h
lang_table.h
logo.png
os_windows.cpp
os_windows.h
platform_config.h
platform_windows_builders.py
power_windows.cpp
power_windows.h
windows_terminal_logger.cpp
windows_terminal_logger.h