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 Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
context_gl_windows.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
context_gl_windows.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
crash_handler_windows.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
crash_handler_windows.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
detect.py Fix thread_local, tls, ASLR, and DEP with MingW 2021-03-25 23:20:12 +01:00
godot.ico Make the Windows icon file smaller 2017-06-20 14:38:50 +02:00
godot.natvis Added LocalVector to Visual Studio debugger visualization 2021-02-25 15:14:32 +01:00
godot_res.rc PCK: Set VERSION_PATCH in header, factor out header magic 2020-01-06 13:13:17 +01:00
godot_windows.cpp Fix thread_local, tls, ASLR, and DEP with MingW 2021-03-25 23:20:12 +01:00
joypad_windows.cpp Replace malloc's with Godot's memalloc macro 2021-03-13 22:01:27 +01:00
joypad_windows.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
key_mapping_windows.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
key_mapping_windows.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
lang_table.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
logo.png Optimize images losslessly using oxipng -o6 --strip all --zopfli 2018-06-28 19:17:41 +02:00
os_windows.cpp Modernize Thread 2021-02-18 11:58:08 +01:00
os_windows.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
platform_config.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
platform_windows_builders.py SCons: Format buildsystem files with psf/black 2020-06-10 15:30:52 +02:00
power_windows.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
power_windows.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
SCsub SCons: Fix debug_symbols tests after switch to BoolVariable 2021-02-08 22:36:32 +01:00
windows_terminal_logger.cpp Replace malloc's with Godot's memalloc macro 2021-03-13 22:01:27 +01:00
windows_terminal_logger.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00