| ... | @@ -29,10 +29,14 @@ comptime { | ... | @@ -29,10 +29,14 @@ comptime { |
| 29 | // function for the GD and LD models. This function is unlikely to actually be used, since the | 29 | // function for the GD and LD models. This function is unlikely to actually be used, since the |
| 30 | // linker should be able to relax every TLS access to the LE model and therefore eliminate all | 30 | // linker should be able to relax every TLS access to the LE model and therefore eliminate all |
| 31 | // calls to this function, but that isn't guaranteed. | 31 | // calls to this function, but that isn't guaranteed. |
| 32 | if (native_arch == .s390x) | 32 | if (native_arch == .s390x) { |
| 33 | symbol(&__tls_get_offset, "__tls_get_offset") | 33 | symbol(&__tls_get_offset, "__tls_get_offset"); |
| 34 | else | 34 | } else { |
| 35 | symbol(&__tls_get_addr, "__tls_get_addr"); | 35 | symbol(&__tls_get_addr, "__tls_get_addr"); |
| | 36 | if (native_arch == .x86) { |
| | 37 | symbol(&___tls_get_addr, "___tls_get_addr"); |
| | 38 | } |
| | 39 | } |
| 36 | } | 40 | } |
| 37 | | 41 | |
| 38 | /// Represents an ELF TLS variant. | 42 | /// Represents an ELF TLS variant. |
| ... | @@ -740,6 +744,18 @@ fn __tls_get_addr(ti: *const TlsIndex) callconv(.c) *anyopaque { | ... | @@ -740,6 +744,18 @@ fn __tls_get_addr(ti: *const TlsIndex) callconv(.c) *anyopaque { |
| 740 | return block[@intCast(ti.offset)..]; | 744 | return block[@intCast(ti.offset)..]; |
| 741 | } | 745 | } |
| 742 | | 746 | |
| | 747 | fn ___tls_get_addr() callconv(.naked) *anyopaque { |
| | 748 | comptime assert(native_arch == .x86); |
| | 749 | |
| | 750 | // We receive the `TlsIndex` pointer in eax. |
| | 751 | comptime assert(@sizeOf(AbiTcb) + @sizeOf(ZigTcb) + @offsetOf(Dtv, "tls_block") == 12); |
| | 752 | asm volatile ( |
| | 753 | \\ mov 4(%%eax), %%eax |
| | 754 | \\ add %%gs:12, %%eax |
| | 755 | \\ ret |
| | 756 | ); |
| | 757 | } |
| | 758 | |
| 743 | fn __tls_get_offset() callconv(.naked) noreturn { | 759 | fn __tls_get_offset() callconv(.naked) noreturn { |
| 744 | comptime assert(native_arch == .s390x); | 760 | comptime assert(native_arch == .s390x); |
| 745 | | 761 | |