WIP: Fix static windows build tls
This is based on !1399 (closed) (literally, the first two commits of mine) and on !1316 (closed) but with a bunch of changes and (hopefully) corrections.
To understand why this works take a look at the documentation for the PE file format (https://docs.microsoft.com/en-us/windows/win32/debug/pe-format), the ".CRT$XLD" is actually part of an array spanning
from the start of section ".CRTXLA" to the start of section ".CRT
XLZ". The microsoft CRT puts it's dynamic tls callbacks at ".CRT$XLD" so we might as well do the same (order doesn't really matter, and the sections will be
merged by the linker)
This is pointed to by the TLS directory that the CRT sets up, and these are run by the OS/loader when appropriate. It's essentially a DllMain but for exes as well (and thus by extension for static libraries).
I'm not 100% sure how to test if this works, so wip for now.