|
|
ce426f |
commit acd98a8ed1460497e788c701eb92616f1df9b446
|
|
|
ce426f |
Author: Andreas Krebbel <krebbel@linux.vnet.ibm.com>
|
|
|
ce426f |
Date: Fri Nov 29 09:57:04 2013 +0100
|
|
|
ce426f |
|
|
|
ce426f |
[BZ #16214] S/390: Fix TLS GOT pointer setup.
|
|
|
ce426f |
|
|
|
ce426f |
diff --git glibc-2.17-c758a686/sysdeps/s390/Versions glibc-2.17-c758a686/sysdeps/s390/Versions
|
|
|
ce426f |
index e18617c..baf9842 100644
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/s390/Versions
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/s390/Versions
|
|
|
ce426f |
@@ -3,4 +3,8 @@ ld {
|
|
|
ce426f |
# runtime interface to TLS
|
|
|
ce426f |
__tls_get_offset;
|
|
|
ce426f |
}
|
|
|
ce426f |
+ GLIBC_PRIVATE {
|
|
|
ce426f |
+ # Exported by ld used by libc.
|
|
|
ce426f |
+ __tls_get_addr_internal;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
}
|
|
|
ce426f |
diff --git glibc-2.17-c758a686/sysdeps/s390/dl-tls.h glibc-2.17-c758a686/sysdeps/s390/dl-tls.h
|
|
|
ce426f |
index 68a5af4..52192a2 100644
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/s390/dl-tls.h
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/s390/dl-tls.h
|
|
|
ce426f |
@@ -26,11 +26,26 @@ typedef struct
|
|
|
ce426f |
|
|
|
ce426f |
|
|
|
ce426f |
#ifdef SHARED
|
|
|
ce426f |
-/* This is the prototype for the GNU version. */
|
|
|
ce426f |
-extern void *__tls_get_addr (tls_index *ti) attribute_hidden;
|
|
|
ce426f |
+
|
|
|
ce426f |
extern unsigned long __tls_get_offset (unsigned long got_offset);
|
|
|
ce426f |
|
|
|
ce426f |
# ifdef IS_IN_rtld
|
|
|
ce426f |
+
|
|
|
ce426f |
+# include <shlib-compat.h>
|
|
|
ce426f |
+
|
|
|
ce426f |
+extern void *__tls_get_addr (tls_index *ti) attribute_hidden;
|
|
|
ce426f |
+/* Make a temporary alias of __tls_get_addr to remove the hidden
|
|
|
ce426f |
+ attribute. Then export __tls_get_addr as __tls_get_addr_internal
|
|
|
ce426f |
+ for use from libc. We do not want to export __tls_get_addr, but we
|
|
|
ce426f |
+ do need to use it from libc when looking up the address of a TLS
|
|
|
ce426f |
+ variable. We don't use __tls_get_offset because it requires r12 to
|
|
|
ce426f |
+ be setup and that might not always be true. Either way it's more
|
|
|
ce426f |
+ optimal to use __tls_get_addr directly (that's what
|
|
|
ce426f |
+ __tls_get_offset does anyways). */
|
|
|
ce426f |
+strong_alias (__tls_get_addr, __tls_get_addr_internal_tmp);
|
|
|
ce426f |
+versioned_symbol (ld, __tls_get_addr_internal_tmp,
|
|
|
ce426f |
+ __tls_get_addr_internal, GLIBC_PRIVATE);
|
|
|
ce426f |
+
|
|
|
ce426f |
/* The special thing about the s390 TLS ABI is that we do not have the
|
|
|
ce426f |
standard __tls_get_addr function but the __tls_get_offset function
|
|
|
ce426f |
which differs in two important aspects:
|
|
|
ce426f |
@@ -63,15 +78,21 @@ __tls_get_offset:\n\
|
|
|
ce426f |
1: .long __tls_get_addr - 0b\n\
|
|
|
ce426f |
");
|
|
|
ce426f |
# endif
|
|
|
ce426f |
-# endif
|
|
|
ce426f |
+# else /* IS_IN_rtld */
|
|
|
ce426f |
+extern void *__tls_get_addr_internal (tls_index *ti);
|
|
|
ce426f |
+# endif /* !IS_IN_rtld */
|
|
|
ce426f |
|
|
|
ce426f |
# define GET_ADDR_OFFSET \
|
|
|
ce426f |
(ti->ti_offset - (unsigned long) __builtin_thread_pointer ())
|
|
|
ce426f |
|
|
|
ce426f |
-# define __TLS_GET_ADDR(__ti) \
|
|
|
ce426f |
- ({ extern char _GLOBAL_OFFSET_TABLE_[] attribute_hidden; \
|
|
|
ce426f |
- (void *) __tls_get_offset ((char *) (__ti) - _GLOBAL_OFFSET_TABLE_) \
|
|
|
ce426f |
- + (unsigned long) __builtin_thread_pointer (); })
|
|
|
ce426f |
+/* Use the privately exported __tls_get_addr_internal instead of
|
|
|
ce426f |
+ __tls_get_offset in order to avoid the __tls_get_offset special
|
|
|
ce426f |
+ linkage requiring the GOT pointer to be set up in r12. The
|
|
|
ce426f |
+ compiler will take care of setting up r12 only if itself issued the
|
|
|
ce426f |
+ __tls_get_offset call. */
|
|
|
ce426f |
+# define __TLS_GET_ADDR(__ti) \
|
|
|
ce426f |
+ ({ (void *) __tls_get_addr_internal ((char *) (__ti)) \
|
|
|
ce426f |
+ + (unsigned long) __builtin_thread_pointer (); })
|
|
|
ce426f |
|
|
|
ce426f |
#endif
|
|
|
ce426f |
|
|
|
ce426f |
diff --git glibc-2.17-c758a686/sysdeps/s390/s390-32/tls-macros.h glibc-2.17-c758a686/sysdeps/s390/s390-32/tls-macros.h
|
|
|
ce426f |
index 8a0ad58..a592d81 100644
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/s390/s390-32/tls-macros.h
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/s390/s390-32/tls-macros.h
|
|
|
ce426f |
@@ -8,12 +8,15 @@
|
|
|
ce426f |
|
|
|
ce426f |
#ifdef PIC
|
|
|
ce426f |
# define TLS_IE(x) \
|
|
|
ce426f |
- ({ unsigned long __offset; \
|
|
|
ce426f |
+ ({ unsigned long __offset, __got; \
|
|
|
ce426f |
asm ("bras %0,1f\n" \
|
|
|
ce426f |
- "0:\t.long " #x "@gotntpoff\n" \
|
|
|
ce426f |
- "1:\tl %0,0(%0)\n\t" \
|
|
|
ce426f |
- "l %0,0(%0,%%r12):tls_load:" #x \
|
|
|
ce426f |
- : "=&a" (__offset) : : "cc" ); \
|
|
|
ce426f |
+ "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \
|
|
|
ce426f |
+ ".long " #x "@gotntpoff\n" \
|
|
|
ce426f |
+ "1:\tl %1,0(%0)\n\t" \
|
|
|
ce426f |
+ "la %1,0(%1,%0)\n\t" \
|
|
|
ce426f |
+ "l %0,4(%0)\n\t" \
|
|
|
ce426f |
+ "l %0,0(%0,%1):tls_load:" #x "\n" \
|
|
|
ce426f |
+ : "=&a" (__offset), "=&a" (__got) : : "cc" ); \
|
|
|
ce426f |
(int *) (__builtin_thread_pointer() + __offset); })
|
|
|
ce426f |
#else
|
|
|
ce426f |
# define TLS_IE(x) \
|
|
|
ce426f |
diff --git glibc-2.17-c758a686/sysdeps/s390/s390-64/tls-macros.h glibc-2.17-c758a686/sysdeps/s390/s390-64/tls-macros.h
|
|
|
ce426f |
index be8aa6c..3c59436 100644
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/s390/s390-64/tls-macros.h
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/s390/s390-64/tls-macros.h
|
|
|
ce426f |
@@ -8,12 +8,13 @@
|
|
|
ce426f |
|
|
|
ce426f |
#ifdef PIC
|
|
|
ce426f |
# define TLS_IE(x) \
|
|
|
ce426f |
- ({ unsigned long __offset; \
|
|
|
ce426f |
- asm ("bras %0,1f\n" \
|
|
|
ce426f |
- "0:\t.quad " #x "@gotntpoff\n" \
|
|
|
ce426f |
- "1:\tlg %0,0(%0)\n\t" \
|
|
|
ce426f |
- "lg %0,0(%0,%%r12):tls_load:" #x \
|
|
|
ce426f |
- : "=&a" (__offset) : : "cc" ); \
|
|
|
ce426f |
+ ({ unsigned long __offset, __got; \
|
|
|
ce426f |
+ asm ("bras %0,0f\n\t" \
|
|
|
ce426f |
+ ".quad " #x "@gotntpoff\n" \
|
|
|
ce426f |
+ "0:\tlarl %1,_GLOBAL_OFFSET_TABLE_\n\t" \
|
|
|
ce426f |
+ "lg %0,0(%0)\n\t" \
|
|
|
ce426f |
+ "lg %0,0(%0,%1):tls_load:" #x "\n" \
|
|
|
ce426f |
+ : "=&a" (__offset), "=&a" (__got) : : "cc" ); \
|
|
|
ce426f |
(int *) (__builtin_thread_pointer() + __offset); })
|
|
|
ce426f |
#else
|
|
|
ce426f |
# define TLS_IE(x) \
|