about summary refs log tree commit diff
path: root/sysdeps/s390/s390-32
diff options
context:
space:
mode:
authorStefan Liebler <stli@linux.vnet.ibm.com>2017-06-27 15:23:43 +0200
committerStefan Liebler <stli@linux.vnet.ibm.com>2017-06-27 15:23:43 +0200
commit83653f804dca6e8e9606e20e708be45b8422d96c (patch)
treeac749dfd641118813b3f4f377eaac00442ae6638 /sysdeps/s390/s390-32
parent39bd76df3d61c6d83c5aa8bab06c7c1dbe7159ac (diff)
downloadglibc-83653f804dca6e8e9606e20e708be45b8422d96c.tar.gz
glibc-83653f804dca6e8e9606e20e708be45b8422d96c.tar.xz
glibc-83653f804dca6e8e9606e20e708be45b8422d96c.zip
S390: Save and restore r12 in TLS_IE macro.
The testcases elf/tst-tls1-static and elf/tst-tls2-static
are failing on s390 if gcc is configured with --enable-default-pie.

According to binutils, there are only four valid cases for IE -> LE transition:
lg %rx,(0,%ry)    -> sllg %rx,%ry,0
lg %rx,(%ry,0)    -> sllg %rx,%ry,0
lg %rx,(%ry,%r12) -> sllg %rx,%ry,0
lg %rx,(%r12,%ry) -> sllg %rx,%ry,0

Thus I've adjusted the TLS_IE macro in s390 tls-macros.h files in PIC case
in order to use r12 for the address of global offset table.
The adjusted macro definition is not used if gcc is not configured with
--enable-default-pie.

ChangeLog:

	* sysdeps/s390/s390-32/tls-macros.h (TLS_IE): Use r12 for GOT address.
	* sysdeps/s390/s390-64/tls-macros.h (TLS_IE): Likewise.
Diffstat (limited to 'sysdeps/s390/s390-32')
-rw-r--r--sysdeps/s390/s390-32/tls-macros.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/sysdeps/s390/s390-32/tls-macros.h b/sysdeps/s390/s390-32/tls-macros.h
index a4c5fffa33..153523a4ae 100644
--- a/sysdeps/s390/s390-32/tls-macros.h
+++ b/sysdeps/s390/s390-32/tls-macros.h
@@ -8,15 +8,17 @@
 
 #ifdef PIC
 # define TLS_IE(x) \
-  ({ unsigned long __offset, __got;					      \
+  ({ unsigned long __offset, __save12;					      \
      __asm__ ("bras %0,1f\n"						      \
 	      "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t"			      \
 	      ".long " #x "@gotntpoff\n"				      \
-	      "1:\tl %1,0(%0)\n\t"					      \
-	      "la %1,0(%1,%0)\n\t"					      \
+	      "1:\tlr %1,%%r12\n\t"					      \
+	      "l %%r12,0(%0)\n\t"					      \
+	      "la %%r12,0(%0,%%r12)\n\t"				      \
 	      "l %0,4(%0)\n\t"						      \
-	      "l %0,0(%0,%1):tls_load:" #x "\n"				      \
-	      : "=&a" (__offset), "=&a" (__got) : : "cc" );		      \
+	      "l %0,0(%0,%%r12):tls_load:" #x "\n\t"			      \
+	      "lr %%r12,%1\n"						      \
+	      : "=&a" (__offset), "=&a" (__save12) : : "cc" );		      \
      (int *) (__builtin_thread_pointer() + __offset); })
 #else
 # define TLS_IE(x) \