From patchwork Sat Dec 20 21:10:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 4390 Received: (qmail 12967 invoked by alias); 20 Dec 2014 21:11:01 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 12957 invoked by uid 89); 20 Dec 2014 21:11:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f180.google.com X-Received: by 10.170.212.10 with SMTP id d10mr13374837ykf.49.1419109856621; Sat, 20 Dec 2014 13:10:56 -0800 (PST) Date: Sat, 20 Dec 2014 13:10:55 -0800 From: "H.J. Lu" To: Andreas Schwab Cc: Carlos O'Donell , Chris Metcalf , GLIBC Devel Subject: Re: [PATCH] Add hidden __tls_get_addr/___tls_get_addr alias Message-ID: <20141220211055.GA9637@gmail.com> References: <5494CB6E.6090706@ezchip.com> <5494F4A3.9030609@redhat.com> <20141220203247.GA22423@gmail.com> <878ui2rqd7.fsf@igel.home> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <878ui2rqd7.fsf@igel.home> User-Agent: Mutt/1.5.23 (2014-03-12) On Sat, Dec 20, 2014 at 09:57:40PM +0100, Andreas Schwab wrote: > "H.J. Lu" writes: > > > +# The dynamic loader uses __libc_memalign # internally to allocate aligned > > Spurious #. > Fixed. H.J. --- * 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 | 14 ++++++++++++++ elf/dl-tls.c | 5 +++++ sysdeps/generic/localplt.data | 7 +++---- sysdeps/i386/dl-tls.h | 2 ++ sysdeps/i386/dl-tlsdesc.S | 5 +---- sysdeps/unix/sysv/linux/i386/localplt.data | 9 +++------ sysdeps/x86_64/dl-tlsdesc.S | 2 +- 7 files changed, 29 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index a354c93..a397544 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2014-12-20 H.J. Lu + * 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-20 H.J. Lu + * sysdeps/i386/dl-machine.h (_dl_start_user): Remove @PLT from "call _dl_init@PLT". * sysdeps/x86_64/dl-machine.h (_dl_start_user): Likewise. diff --git a/elf/dl-tls.c b/elf/dl-tls.c index 76b8b36..cff213f 100644 --- a/elf/dl-tls.c +++ b/elf/dl-tls.c @@ -809,6 +809,11 @@ update_get_addr (GET_ADDR_ARGS) return (void *) p + GET_ADDR_OFFSET; } +#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. */ diff --git a/sysdeps/generic/localplt.data b/sysdeps/generic/localplt.data index d7d6734..1a40cf9 100644 --- a/sysdeps/generic/localplt.data +++ b/sysdeps/generic/localplt.data @@ -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 diff --git a/sysdeps/i386/dl-tls.h b/sysdeps/i386/dl-tls.h index 48809a5..99b86f9 100644 --- a/sysdeps/i386/dl-tls.h +++ b/sysdeps/i386/dl-tls.h @@ -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. */ diff --git a/sysdeps/i386/dl-tlsdesc.S b/sysdeps/i386/dl-tlsdesc.S index e6753e9..570b180 100644 --- a/sysdeps/i386/dl-tlsdesc.S +++ b/sysdeps/i386/dl-tlsdesc.S @@ -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 diff --git a/sysdeps/unix/sysv/linux/i386/localplt.data b/sysdeps/unix/sysv/linux/i386/localplt.data index 009797b..b25abf8 100644 --- a/sysdeps/unix/sysv/linux/i386/localplt.data +++ b/sysdeps/unix/sysv/linux/i386/localplt.data @@ -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 diff --git a/sysdeps/x86_64/dl-tlsdesc.S b/sysdeps/x86_64/dl-tlsdesc.S index 92e18a5..03f5ca4 100644 --- a/sysdeps/x86_64/dl-tlsdesc.S +++ b/sysdeps/x86_64/dl-tlsdesc.S @@ -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