aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/windows/tls.zig
AgeCommit message (Collapse)Author
2024-09-28Initial port work for `*-windows-itanium` support.Alex Rønne Petersen
https://llvm.org/docs/HowToBuildWindowsItaniumPrograms.html This is a weird middle ground between `*-windows-gnu` and `*-windows-msvc`. It uses the C++ ABI of the former while using the system libraries of the latter.
2024-08-03std.os.windows.tls: Set `AddressOfCallBacks` to `&__xl_a + 1`.Alex Rønne Petersen
`__xl_a` is just a global variable containing a null function pointer. There's nothing magical about it or its name at all. The section names used on `__xl_a` and `__xl_b` (`.CRT$XLA` and `.CRT$XLZ`) are the real magic here. The compiler emits TLS variables into `.CRT$XL<x>` sections, where `x` is an uppercase letter between A and Z (exclusive). The linker then sorts those sections alphabetically (due to the `$`), and the result is a neat array of TLS initialization callbacks between `__xl_a` and `__xl_z`. That array is null-terminated, though! Normally, `__xl_z` serves as the null terminator; however, by pointing `AddressesOfCallBacks` to `__xl_a`, which just contains a null function pointer, we've effectively made it so that the PE loader will just immediately stop invoking TLS callbacks. Fix that by pointing to the first actual TLS callback instead (or `__xl_z` if there are none).
2024-08-03std.os.windows.tls: Only define _tls_array when targeting MSVC.Alex Rønne Petersen
LLVM does not use it when emitting code for the MinGW ABI.
2024-08-03std.os.windows.tls: Slightly improve type safety.Alex Rønne Petersen
2024-08-03std.os.windows.tls: Change type of `_tls_start`/`_tls_end` to `*anyopaque`.Alex Rønne Petersen
If they're typed as `u8`, they can be aligned to anything. We want at least pointer size alignment.
2024-08-03std: Move start_windows_tls.zig to os/windows/tls.zig.Alex Rønne Petersen
Just to be consistent with Linux.