0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
zig/lib/std/os/linux.zig
Alex Rønne Petersen 736d37ad16
move std.os.linux.tls to compiler_rt as __zig_elf_static_tls_*
As with __zig_elf_auxv, we need a canonical location for __tls_get_addr (or
__tls_get_offset on s390x), and compiler-rt is the obvious place. But that also
means that moving all of std.os.linux.tls there just makes sense. I decided not
to namespace this under linux because it's expected that most of this code will
apply to the BSDs too.

The ABI that std now expects is:

    extern fn __zig_elf_static_tls_init(phdrs: [*]elf.ElfN.Phdr, phnum: usize) void;
    extern fn __zig_elf_static_tls_fill(area: [*]u8) usize;
    extern var __zig_elf_static_tls: extern struct {
        size: usize,
        alignment: usize,
        gdt_entry_number: usize,
    };

Users can override all three weak symbols with strong symbols if they want to
provide their own ELF TLS implementation, which may be useful to do when doing
manual dynamic loading from a static executable. Note that __tls_get_addr (or
__tls_get_offset on s390x) must also be provided, per the ELF TLS specification.
2026-10-05 03:26:41 +02:00

11350 lines
316 KiB