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]

fix powerpc macros in tls-macros.h


Several of the glibc tls tests fail on powerpc when compiled with
current mainline gcc, due to the TLS_GD asm lacking an output operand.
This patch cures the problem, and tidies a couple of the powerpc64
macros.  Tested powerpc-linux and powerpc64-linux.

2010-02-10  Alan Modra  <amodra@gmail.com>

	* elf/tls-macros.h (__TLS_CALL_CLOBBERS <__powerpc__>): Remove r3.
	Define and use for __powerpc64__ too.
	(TLS_LD <__powerpc__>): Add r3 to clobbers.
	(TLS_GD <__powerpc__>): Set asm output.  Make __result r3 reg.
	(TLS_GD <__powerpc64__>): Make __result r3 reg.

diff --git a/elf/tls-macros.h b/elf/tls-macros.h
index 6463a6c..db2ec1f 100644
--- a/elf/tls-macros.h
+++ b/elf/tls-macros.h
@@ -701,14 +701,16 @@ register void *__gp __asm__("$29");
      (int *) (__builtin_thread_pointer() + __offset); })
 # endif
 
-#elif defined __powerpc__ && !defined __powerpc64__
+#elif defined __powerpc__
 
-#include "config.h"
-
-# define __TLS_CALL_CLOBBERS						\
-	"0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",	\
+# define __TLS_CALL_CLOBBERS					\
+	"0", "4", "5", "6", "7", "8", "9", "10", "11", "12",	\
 	"lr", "ctr", "cr0", "cr1", "cr5", "cr6", "cr7"
 
+#if !defined __powerpc64__
+
+#include "config.h"
+
 /* PowerPC32 Local Exec TLS access.  */
 # define TLS_LE(x)				\
   ({ int *__result;				\
@@ -753,7 +755,7 @@ register void *__gp __asm__("$29");
 	  "bl __tls_get_addr@plt\n\t"			\
 	  "addi %0,3," #x "@dtprel"			\
 	  : "=r" (__result) :				\
-	  : __TLS_CALL_CLOBBERS);			\
+	  : "3", __TLS_CALL_CLOBBERS);			\
      __result; })
 # else
 #  define TLS_LD(x)					\
@@ -764,7 +766,7 @@ register void *__gp __asm__("$29");
 	  "bl __tls_get_addr@plt\n\t"			\
 	  "addi %0,3," #x "@dtprel"			\
 	  : "=r" (__result) :				\
-	  : __TLS_CALL_CLOBBERS);			\
+	  : "3", __TLS_CALL_CLOBBERS);			\
      __result; })
 # endif
 
@@ -778,7 +780,7 @@ register void *__gp __asm__("$29");
 	  "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t"	\
 	  "addi 3,3," #x "@got@tlsgd\n\t"		\
 	  "bl __tls_get_addr@plt"			\
-	  : :						\
+	  : "=r" (__result) :				\
 	  : __TLS_CALL_CLOBBERS);			\
      __result; })
 # else
@@ -788,12 +790,12 @@ register void *__gp __asm__("$29");
 	  "mflr 3\n\t"					\
 	  "addi 3,3," #x "@got@tlsgd\n\t"		\
 	  "bl __tls_get_addr@plt"			\
-	  : :						\
+	  : "=r" (__result) :				\
 	  : __TLS_CALL_CLOBBERS);			\
      __result; })
 # endif
 
-#elif defined __powerpc__ && defined __powerpc64__
+#else
 
 /* PowerPC64 Local Exec TLS access.  */
 # define TLS_LE(x) \
@@ -828,27 +830,21 @@ register void *__gp __asm__("$29");
         "  addis %0,3," #x "@dtprel@ha\n"  \
         "  addi  %0,%0," #x "@dtprel@l\n"  \
         : "=b" (__result) :  \
-        : "0", "3", "4", "5", "6", "7",    \
-          "8", "9", "10", "11", "12",      \
-          "lr", "ctr",  \
-          "cr0", "cr1", "cr5", "cr6", "cr7");  \
+        : "3", __TLS_CALL_CLOBBERS);  \
       __result;  \
   })
 /* PowerPC64 General Dynamic TLS access.  */
 #  define TLS_GD(x) \
-  ({  int * __result;  \
+  ({  register int *__result __asm__ ("r3");  \
       asm (  \
         "  addi  3,2," #x "@got@tlsgd\n"  \
         "  bl    " __TLS_GET_ADDR "\n"  \
         "  nop   \n"  \
-        "  mr    %0,3\n"  \
         : "=b" (__result) :  \
-        : "0", "3", "4", "5", "6", "7",    \
-          "8", "9", "10", "11", "12",      \
-          "lr", "ctr",  \
-          "cr0", "cr1", "cr5", "cr6", "cr7");  \
+        : __TLS_CALL_CLOBBERS);  \
       __result;  \
   })
+#endif
 
 #elif !defined TLS_LE || !defined TLS_IE \
       || !defined TLS_LD || !defined TLS_GD

-- 
Alan Modra
Australia Development Lab, IBM


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