authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2019-09-04 17:48:01+02:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2019-09-04 17:48:01+02:00
logdf06976e73e37a36009fb5f43c2310ad610a4a2e
treea2ca16f1a7e3aab7e4e15038752373f58ef0a7cb
parent77d04c03e3f20c4c60d98e73b876222006aa05fc

Only check for TLS support on arm if TLS segment exists


1 files changed, 9 insertions(+), 11 deletions(-)

std/os/linux/tls.zig+9-11
...@@ -133,7 +133,7 @@ pub fn initTLS() void {...@@ -133,7 +133,7 @@ pub fn initTLS() void {
133 var at_phent: usize = undefined;133 var at_phent: usize = undefined;
134 var at_phnum: usize = undefined;134 var at_phnum: usize = undefined;
135 var at_phdr: usize = undefined;135 var at_phdr: usize = undefined;
136 var at_hwcap: ?usize = null;136 var at_hwcap: usize = undefined;
137137
138 var i: usize = 0;138 var i: usize = 0;
139 while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) {139 while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) {
...@@ -146,16 +146,6 @@ pub fn initTLS() void {...@@ -146,16 +146,6 @@ pub fn initTLS() void {
146 }146 }
147 }147 }
148148
149 // If the cpu is arm-based, check if it supports the TLS register
150 if (at_hwcap) |hwcap| {
151 if (builtin.arch == builtin.Arch.arm and hwcap & std.os.linux.HWCAP_TLS == 0) {
152 // If the CPU does not support TLS via a coprocessor register,
153 // a kernel helper function can be used instead on certain linux kernels.
154 // See linux/arch/arm/include/asm/tls.h and musl/src/thread/arm/__set_thread_area.c.
155 @panic("TODO: Implement ARM fallback TLS functionality");
156 }
157 }
158
159 // Sanity check149 // Sanity check
160 assert(at_phent == @sizeOf(elf.Phdr));150 assert(at_phent == @sizeOf(elf.Phdr));
161151
...@@ -171,6 +161,14 @@ pub fn initTLS() void {...@@ -171,6 +161,14 @@ pub fn initTLS() void {
171 }161 }
172162
173 if (tls_phdr) |phdr| {163 if (tls_phdr) |phdr| {
164 // If the cpu is arm-based, check if it supports the TLS register
165 if (builtin.arch == builtin.Arch.arm and hwcap & std.os.linux.HWCAP_TLS == 0) {
166 // If the CPU does not support TLS via a coprocessor register,
167 // a kernel helper function can be used instead on certain linux kernels.
168 // See linux/arch/arm/include/asm/tls.h and musl/src/thread/arm/__set_thread_area.c.
169 @panic("TODO: Implement ARM fallback TLS functionality");
170 }
171
174 // Offsets into the allocated TLS area172 // Offsets into the allocated TLS area
175 var tcb_offset: usize = undefined;173 var tcb_offset: usize = undefined;
176 var dtv_offset: usize = undefined;174 var dtv_offset: usize = undefined;