godot/core/os
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
..
copymem.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
dir_access.cpp Add descriptive error message when trying to access a dir fails 2021-02-25 22:40:32 +01:00
dir_access.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
file_access.cpp Allow nullptr with zero length in FileAccess get_buffer 2021-03-17 15:17:02 +01:00
file_access.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
input_event.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
input_event.h Add support for new SDL gamecontroller keywords. 2021-02-07 16:41:23 +00:00
input.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
input.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
keyboard.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
keyboard.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
main_loop.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
main_loop.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
memory.cpp Modernize atomics 2021-02-18 12:23:25 +01:00
memory.h Modernize atomics 2021-02-18 12:23:25 +01:00
midi_driver.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
midi_driver.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
mutex.cpp Modernize Mutex 2021-02-18 11:58:08 +01:00
mutex.h Modernize Mutex 2021-02-18 11:58:08 +01:00
os.cpp Fix Godot returned status code on unexpected error 2021-02-25 18:39:29 +01:00
os.h Fix Godot returned status code on unexpected error 2021-02-25 18:39:29 +01:00
rw_lock.h Modernize RWLock 2021-02-18 11:41:07 +01:00
SCsub SCons: Format buildsystem files with psf/black 2020-06-10 15:30:52 +02:00
semaphore.h Modernize Semaphore 2021-02-18 11:58:08 +01:00
thread_safe.h Modernize Mutex 2021-02-18 11:58:08 +01:00
thread.cpp Fix thread_local, tls, ASLR, and DEP with MingW 2021-03-25 23:20:12 +01:00
thread.h Fix thread_local, tls, ASLR, and DEP with MingW 2021-03-25 23:20:12 +01:00
threaded_array_processor.h Fix thread_process_array when NO_THREADS. 2021-02-26 15:23:23 +01:00