| ... | @@ -11,32 +11,28 @@ | ... | @@ -11,32 +11,28 @@ |
| 11 | | 11 | |
| 12 | const builtin = @import("builtin"); | 12 | const builtin = @import("builtin"); |
| 13 | const std = @import("std"); | 13 | const std = @import("std"); |
| 14 | | | |
| 15 | const compiler_rt = @import("../../compiler_rt.zig"); | | |
| 16 | const symbol = compiler_rt.symbol; | | |
| 17 | | | |
| 18 | const elf = std.elf; | 14 | const elf = std.elf; |
| 19 | const assert = std.debug.assert; | 15 | const assert = std.debug.assert; |
| 20 | const native_arch = builtin.cpu.arch; | 16 | const native_arch = builtin.cpu.arch; |
| 21 | const linux = std.os.linux; | 17 | const linux = std.os.linux; |
| 22 | const page_size_min = std.heap.page_size_min; | 18 | const page_size_min = std.heap.page_size_min; |
| 23 | | 19 | |
| | 20 | const compiler_rt = @import("../../compiler_rt.zig"); |
| | 21 | const symbol = compiler_rt.symbol; |
| | 22 | |
| 24 | comptime { | 23 | comptime { |
| 25 | // FreeBSD, NetBSD, and OpenBSD are expected to also use this in the future. | 24 | symbol(&__zig_elf_static_tls, "__zig_elf_static_tls"); |
| 26 | if (!builtin.link_libc and builtin.target.os.tag == .linux) { | 25 | symbol(&__zig_elf_static_tls_init, "__zig_elf_static_tls_init"); |
| 27 | symbol(&__zig_elf_static_tls, "__zig_elf_static_tls"); | 26 | symbol(&__zig_elf_static_tls_fill, "__zig_elf_static_tls_fill"); |
| 28 | symbol(&__zig_elf_static_tls_init, "__zig_elf_static_tls_init"); | 27 | |
| 29 | symbol(&__zig_elf_static_tls_fill, "__zig_elf_static_tls_fill"); | 28 | // To make static executables without libc work, it is our job to provide the TLS accessor |
| 30 | | 29 | // function for the GD and LD models. This function is unlikely to actually be used, since the |
| 31 | // To make static executables without libc work, it is our job to provide the TLS accessor | 30 | // linker should be able to relax every TLS access to the LE model and therefore eliminate all |
| 32 | // function for the GD and LD models. This function is unlikely to actually be used, since | 31 | // calls to this function, but that isn't guaranteed. |
| 33 | // the linker should be able to relax every TLS access to the LE model and therefore | 32 | if (native_arch == .s390x) |
| 34 | // eliminate all calls to this function, but that isn't guaranteed. | 33 | symbol(&__tls_get_offset, "__tls_get_offset") |
| 35 | if (native_arch == .s390x) | 34 | else |
| 36 | symbol(&__tls_get_offset, "__tls_get_offset") | 35 | symbol(&__tls_get_addr, "__tls_get_addr"); |
| 37 | else | | |
| 38 | symbol(&__tls_get_addr, "__tls_get_addr"); | | |
| 39 | } | | |
| 40 | } | 36 | } |
| 41 | | 37 | |
| 42 | /// Represents an ELF TLS variant. | 38 | /// Represents an ELF TLS variant. |