]> sourceware.org Git - glibc.git/commitdiff
Add hidden __tls_get_addr/___tls_get_addr alias
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 21 Dec 2014 17:12:04 +0000 (09:12 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 21 Dec 2014 17:27:11 +0000 (09:27 -0800)
__tls_get_addr/___tls_get_addr is always defined in ld.so.  There is
no need to call them via PLT inside ld.so.  This patch adds the hidden
__tls_get_addr/___tls_get_addr aliases and calls them directly from
_dl_tlsdesc_dynamic.  There is no need to set up the EBX register in
i386 _dl_tlsdesc_dynamic when calling the hidden ___tls_get_addr.

* elf/dl-tls.c (__tls_get_addr): Provide the hidden definition
if not defined.
* sysdeps/i386/dl-tls.h (___tls_get_addr): Provide the hidden
definition.
* sysdeps/i386/dl-tlsdesc.S (_dl_tlsdesc_dynamic): Call the
hidden ___tls_get_addr.
* sysdeps/x86_64/dl-tlsdesc.S (_dl_tlsdesc_dynamic): Call the
hidden __tls_get_addr.
* sysdeps/generic/localplt.data (__tls_get_addr): Removed.
* sysdeps/unix/sysv/linux/i386/localplt.data (___tls_get_addr):
Likewise.

ChangeLog
elf/dl-tls.c
sysdeps/generic/localplt.data
sysdeps/i386/dl-tls.h
sysdeps/i386/dl-tlsdesc.S
sysdeps/unix/sysv/linux/i386/localplt.data
sysdeps/x86_64/dl-tlsdesc.S

index 078af75e47909ba5f06c62f88cc464a4cfb48cf7..28c293db478bb7687e81990ab15b4f667acb2587 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2014-12-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf/dl-tls.c (__tls_get_addr): Provide the hidden definition
+       if not defined.
+       * sysdeps/i386/dl-tls.h (___tls_get_addr): Provide the hidden
+       definition.
+       * sysdeps/i386/dl-tlsdesc.S (_dl_tlsdesc_dynamic): Call the
+       hidden ___tls_get_addr.
+       * sysdeps/x86_64/dl-tlsdesc.S (_dl_tlsdesc_dynamic): Call the
+       hidden __tls_get_addr.
+       * sysdeps/generic/localplt.data (__tls_get_addr): Removed.
+       * sysdeps/unix/sysv/linux/i386/localplt.data (___tls_get_addr):
+       Likewise.
+
 2014-12-21  Andreas Schwab  <schwab@linux-m68k.org>
 
        * sysdeps/m68k/dl-machine.h (RTLD_START): Remove @PLTPC from
index 76b8b368d1962aaf2e077612ad20a7831eee89cd..0abb0249b248bad8722ee5ab6647f24b44c7d097 100644 (file)
@@ -809,6 +809,16 @@ update_get_addr (GET_ADDR_ARGS)
   return (void *) p + GET_ADDR_OFFSET;
 }
 
+/* For all machines that have a non-macro version of __tls_get_addr, we
+   want to use rtld_hidden_proto/rtld_hidden_def in order to call the
+   internal alias for __tls_get_addr from ld.so. This avoids a PLT entry
+   in ld.so for __tls_get_addr.  */
+
+#ifndef __tls_get_addr
+extern void * __tls_get_addr (GET_ADDR_ARGS);
+rtld_hidden_proto (__tls_get_addr)
+rtld_hidden_def (__tls_get_addr)
+#endif
 
 /* The generic dynamic and local dynamic model cannot be used in
    statically linked applications.  */
index d7d673454fa561f6f34c45711062a54f9dc82b66..1a40cf984112918d0bac3dc272dca5832da3c07b 100644 (file)
@@ -7,10 +7,9 @@ libc.so: malloc
 libc.so: memalign
 libc.so: realloc
 libm.so: matherr
-# The dynamic loader needs __tls_get_addr for TLS, and uses __libc_memalign
-# internally to allocate aligned TLS storage. The other malloc family of
-# functions are expected to allow user symbol interposition.
-ld.so: __tls_get_addr
+# The dynamic loader uses __libc_memalign internally to allocate aligned
+# TLS storage. The other malloc family of functions are expected to allow
+# user symbol interposition.
 ld.so: __libc_memalign
 ld.so: malloc
 ld.so: calloc
index 48809a5da1b1aefc2ae2bf3f01630bc99e73b66c..99b86f902a6c358ade378160ba1d8b17512ed382 100644 (file)
@@ -50,6 +50,8 @@ __tls_get_addr (tls_index *ti)
    version of this file.  */
 # define __tls_get_addr __attribute__ ((__regparm__ (1))) ___tls_get_addr
 strong_alias (___tls_get_addr, ___tls_get_addr_internal)
+rtld_hidden_proto (___tls_get_addr)
+rtld_hidden_def (___tls_get_addr)
 #else
 
 /* Users should get the better interface.  */
index e6753e9e1990559919245781c5c1f5697a461311..570b180dd09ae3b17ba57ec6af86b30edd9d337f 100644 (file)
@@ -126,10 +126,7 @@ _dl_tlsdesc_dynamic:
        .p2align 4,,7
 .Lslow:
        cfi_adjust_cfa_offset (28)
-       movl    %ebx, 16(%esp)
-       LOAD_PIC_REG (bx)
-       call    ___tls_get_addr@PLT
-       movl    16(%esp), %ebx
+       call    HIDDEN_JUMPTARGET (___tls_get_addr)
        jmp     .Lret
        cfi_endproc
        .size   _dl_tlsdesc_dynamic, .-_dl_tlsdesc_dynamic
index 009797bc069a69d4bd187d31fa061d6b6c649e85..b25abf800650c8aba280b48a606b243e664c67a3 100644 (file)
@@ -5,12 +5,9 @@ libc.so: malloc
 libc.so: memalign
 libc.so: realloc
 libm.so: matherr
-# The dynamic loader needs ___tls_get_addr for TLS, and uses __libc_memalign
-# internally to allocate aligned TLS storage. The other malloc family of
-# functions are expected to allow user symbol interposition.
-# Note that it is triple underscore for ___tls_get_addr e.g. the alternate
-# ABI.
-ld.so: ___tls_get_addr
+# The dynamic loader uses __libc_memalign internally to allocate aligned
+# TLS storage. The other malloc family of functions are expected to allow
+# user symbol interposition.
 ld.so: __libc_memalign
 ld.so: malloc
 ld.so: calloc
index 92e18a54c2a5153bca6fea446410cd388b40da12..03f5ca494fab4cbe2fba3a8526719eb38130be2c 100644 (file)
@@ -128,7 +128,7 @@ _dl_tlsdesc_dynamic:
        movq    %r10, 40(%rsp)
        movq    %r11, 48(%rsp)
        /* %rdi already points to the tlsinfo data structure.  */
-       call    __tls_get_addr@PLT
+       call    HIDDEN_JUMPTARGET (__tls_get_addr)
        movq    8(%rsp), %rdx
        movq    16(%rsp), %rcx
        movq    24(%rsp), %r8
This page took 0.126242 seconds and 5 git commands to generate.