zig/lib/std/os
Alex Rønne Petersen cb1fffb29e
std.os.windows.tls: Set AddressOfCallBacks to &__xl_a + 1.
`__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-03 20:55:00 +02:00
..
linux Merge pull request #20870 from alexrp/target-cleanup-3 2024-08-01 01:32:32 -07:00
plan9 extract std.posix from std.os 2024-03-19 11:45:09 -07:00
uefi chore: correct non-standard comments. 2024-07-28 21:34:14 -07:00
windows std.os.windows.tls: Set AddressOfCallBacks to &__xl_a + 1. 2024-08-03 20:55:00 +02:00
emscripten.zig std.c reorganization 2024-07-19 00:30:32 -07:00
linux.zig std.os.linux: Unbreak the build 2024-08-01 13:05:26 +02:00
plan9.zig std: fix typos (#20560) 2024-07-09 14:25:42 -07:00
uefi.zig os.uefi: add ns to epoch 2023-12-20 20:05:16 -08:00
wasi.zig Do not run asserts for WASI alignment when not targeting WASI 2024-05-11 07:23:07 +00:00
windows.zig Watch.zig: add initial windows implementation 2024-07-27 11:32:43 -04:00