* riscv: TLS init fix
@ 2018-02-20 7:20 DJ Delorie
2018-02-21 21:57 ` Palmer Dabbelt
0 siblings, 1 reply; 2+ messages in thread
From: DJ Delorie @ 2018-02-20 7:20 UTC (permalink / raw)
To: libc-alpha
RISC-V TLS doesn't require GP to be initialized, and doing so breaks
TLS in a shared object.
diff --git a/sysdeps/riscv/tls-macros.h b/sysdeps/riscv/tls-macros.h
index 5433ed9d16..7f0dd926d0 100644
--- a/sysdeps/riscv/tls-macros.h
+++ b/sysdeps/riscv/tls-macros.h
@@ -23,19 +23,9 @@
#include <sysdep.h>
#include "dl-tls.h"
-#define LOAD_GP \
- ".option push\n\t" \
- ".option norelax\n\t" \
- "la gp, __global_pointer$\n\t" \
- ".option pop\n\t"
-
-#define UNLOAD_GP
-
#define TLS_GD(x) \
({ void *__result; \
- asm (LOAD_GP \
- "la.tls.gd %0, " #x "\n\t" \
- UNLOAD_GP \
+ asm ("la.tls.gd %0, " #x "\n\t" \
: "=r" (__result)); \
__tls_get_addr (__result); })
@@ -43,19 +33,15 @@
#define TLS_IE(x) \
({ void *__result; \
- asm (LOAD_GP \
- "la.tls.ie %0, " #x "\n\t" \
+ asm ("la.tls.ie %0, " #x "\n\t" \
"add %0, %0, tp\n\t" \
- UNLOAD_GP \
: "=r" (__result)); \
__result; })
#define TLS_LE(x) \
({ void *__result; \
- asm (LOAD_GP \
- "lui %0, %%tprel_hi(" #x ")\n\t" \
+ asm ("lui %0, %%tprel_hi(" #x ")\n\t" \
"add %0, %0, tp, %%tprel_add(" #x ")\n\t" \
"addi %0, %0, %%tprel_lo(" #x ")\n\t" \
- UNLOAD_GP \
: "=r" (__result)); \
__result; })
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: riscv: TLS init fix
2018-02-20 7:20 riscv: TLS init fix DJ Delorie
@ 2018-02-21 21:57 ` Palmer Dabbelt
0 siblings, 0 replies; 2+ messages in thread
From: Palmer Dabbelt @ 2018-02-21 21:57 UTC (permalink / raw)
To: dj; +Cc: libc-alpha
On Mon, 19 Feb 2018 18:54:49 PST (-0800), dj@redhat.com wrote:
>
> RISC-V TLS doesn't require GP to be initialized, and doing so breaks
> TLS in a shared object.
>
> diff --git a/sysdeps/riscv/tls-macros.h b/sysdeps/riscv/tls-macros.h
> index 5433ed9d16..7f0dd926d0 100644
> --- a/sysdeps/riscv/tls-macros.h
> +++ b/sysdeps/riscv/tls-macros.h
> @@ -23,19 +23,9 @@
> #include <sysdep.h>
> #include "dl-tls.h"
>
> -#define LOAD_GP \
> - ".option push\n\t" \
> - ".option norelax\n\t" \
> - "la gp, __global_pointer$\n\t" \
> - ".option pop\n\t"
> -
> -#define UNLOAD_GP
> -
> #define TLS_GD(x) \
> ({ void *__result; \
> - asm (LOAD_GP \
> - "la.tls.gd %0, " #x "\n\t" \
> - UNLOAD_GP \
> + asm ("la.tls.gd %0, " #x "\n\t" \
> : "=r" (__result)); \
> __tls_get_addr (__result); })
>
> @@ -43,19 +33,15 @@
>
> #define TLS_IE(x) \
> ({ void *__result; \
> - asm (LOAD_GP \
> - "la.tls.ie %0, " #x "\n\t" \
> + asm ("la.tls.ie %0, " #x "\n\t" \
> "add %0, %0, tp\n\t" \
> - UNLOAD_GP \
> : "=r" (__result)); \
> __result; })
>
> #define TLS_LE(x) \
> ({ void *__result; \
> - asm (LOAD_GP \
> - "lui %0, %%tprel_hi(" #x ")\n\t" \
> + asm ("lui %0, %%tprel_hi(" #x ")\n\t" \
> "add %0, %0, tp, %%tprel_add(" #x ")\n\t" \
> "addi %0, %0, %%tprel_lo(" #x ")\n\t" \
> - UNLOAD_GP \
> : "=r" (__result)); \
> __result; })
With a ChangeLog and such this looks good to me. Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-21 21:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-20 7:20 riscv: TLS init fix DJ Delorie
2018-02-21 21:57 ` Palmer Dabbelt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).