This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Add x32 support to TLS_LE/TLS_IE/TLS_GD


Hi,

This patch adds x32 support to TLS_LE/TLS_IE/TLS_GD.  We don't need the
'q' suffix with register operand.  Also x32 doesn't have 0x66 byte in
TLS GD code sequence.  Tested on Linux/x32 and Linux/x86-64.  OK to
install?

Thanks.


H.J.
---
	* elf/tls-macros.h (TLS_LE): Use mov instead of movq to load
	thread pointer.
	(TLS_IE): Use mov/add instead of movq/addq to load thread
	pointer.
	(TLS_GD_PREFIX): New.
	(TLS_GD): Use it.
 
diff --git a/elf/tls-macros.h b/elf/tls-macros.h
index ea6f14f..e753d5c 100644
--- a/elf/tls-macros.h
+++ b/elf/tls-macros.h
@@ -101,15 +101,15 @@
 
 # define TLS_LE(x) \
   ({ int *__l;								      \
-     asm ("movq %%fs:0,%0\n\t"						      \
-	  "leaq " #x "@tpoff(%0), %0"					      \
+     asm ("mov %%fs:0,%0\n\t"						      \
+	  "lea " #x "@tpoff(%0), %0"					      \
 	  : "=r" (__l));						      \
      __l; })
 
 # define TLS_IE(x) \
   ({ int *__l;								      \
-     asm ("movq %%fs:0,%0\n\t"						      \
-	  "addq " #x "@gottpoff(%%rip),%0"				      \
+     asm ("mov %%fs:0,%0\n\t"						      \
+	  "add " #x "@gottpoff(%%rip),%0"				      \
 	  : "=r" (__l));						      \
      __l; })
 
@@ -122,9 +122,15 @@
 	  : : "rdi", "rsi", "r8", "r9", "r10", "r11"); 			      \
      __l; })
 
+# ifdef __ILP32__
+#  define TLS_GD_PREFIX
+# else
+#  define TLS_GD_PREFIX	".byte 0x66\n\t"
+# endif
+
 # define TLS_GD(x) \
   ({ int *__l, __c, __d;						      \
-     asm (".byte 0x66\n\t"						      \
+     asm (TLS_GD_PREFIX							      \
 	  "leaq " #x "@tlsgd(%%rip),%%rdi\n\t"				      \
 	  ".word 0x6666\n\t"						      \
 	  "rex64\n\t"							      \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]