From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25651 invoked by alias); 9 Jun 2014 09:41:47 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 25640 invoked by uid 89); 9 Jun 2014 09:41:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f180.google.com Received: from mail-ig0-f180.google.com (HELO mail-ig0-f180.google.com) (209.85.213.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 09 Jun 2014 09:41:45 +0000 Received: by mail-ig0-f180.google.com with SMTP id h18so125620igc.13 for ; Mon, 09 Jun 2014 02:41:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=MHopQGKk0BHn7QfikSzeOqysIgx3ebuca8QVkHNRIm0=; b=DkgZB6KuKeXrl8z7OA05EsRIkpxay2W6rCxha2pbkv5eKo031E6R6+Mjn28vvEeuZn /nHdJLV1voQsE5pcVOb8P05qZxJzah2quJsuCoH8z3woxg0RE0N+kXbrw51bTTcUcghz l/Gv+1kbMfFDeOP4AFfvU/OE4K6nDtCm+O4xmGYLOdjewp5ehRb22w/im3SHEYwhWBcz JOtvCpL56O4DbbbwPzi6HjfsvUvHwv/KSI3tLb0QqEl92aA3505wi2UQD7ePtlUNnFPB UoAsZfc/FnsprGQ+m5VV+EXDSU5Jqttb9isSPU/Zy+gzdpI4G8jsN1dvVSh5tWLxzNeC Nxmg== X-Gm-Message-State: ALoCoQmB3zsIySzErbZEo4z0NEmaqvHV48mx7RTqMJVdhI29eillwGjC26/jgXEfNos3dzbw9eUt MIME-Version: 1.0 X-Received: by 10.43.155.68 with SMTP id lh4mr15774755icc.30.1402306903233; Mon, 09 Jun 2014 02:41:43 -0700 (PDT) Received: by 10.64.225.50 with HTTP; Mon, 9 Jun 2014 02:41:43 -0700 (PDT) In-Reply-To: <1400854416-3764-1-git-send-email-will.newton@linaro.org> References: <1400854416-3764-1-git-send-email-will.newton@linaro.org> Date: Mon, 09 Jun 2014 09:41:00 -0000 Message-ID: Subject: Re: [PATCH] ld/ARM: Fix IFUNC and TLS descriptors in the same shared object From: Will Newton To: "binutils@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-06/txt/msg00073.txt.bz2 On 23 May 2014 15:13, Will Newton wrote: > Combining TLS descriptors and GNU indirect functions in the same > object could lead to assertions or multiple dynamic relocations > for the same GOT slot. Fix the bookkeeping so this doesn't happen. > > This allows building and make checking glibc with -mtls-dialect=gnu2. > > bfd/ChangeLog: > > 2014-05-21 Will Newton > > * elf32-arm.c (elf32_arm_allocate_plt_entry): Increment > htab->next_tls_desc_index in the non-IPLT case. > Calculate GOT offset correctly for the non-IPLT case. > (allocate_dynrelocs_for_symbol): Don't increment > htab->next_tls_desc_index here. > > ld/testsuite/ChangeLog: > > 2014-05-21 Will Newton > > * ld-arm/arm-elf.exp: Add ifunc-gdesc test. > * ld-arm/ifunc-gdesc.r: New file. > * ld-arm/ifunc-gdesc.s: Likewise. > * ld-arm/ifunc-gdesc.ver: Likewise. > --- > bfd/elf32-arm.c | 9 ++++++--- > ld/testsuite/ld-arm/arm-elf.exp | 3 +++ > ld/testsuite/ld-arm/ifunc-gdesc.r | 6 ++++++ > ld/testsuite/ld-arm/ifunc-gdesc.s | 29 +++++++++++++++++++++++++++++ > ld/testsuite/ld-arm/ifunc-gdesc.ver | 4 ++++ > 5 files changed, 48 insertions(+), 3 deletions(-) > create mode 100644 ld/testsuite/ld-arm/ifunc-gdesc.r > create mode 100644 ld/testsuite/ld-arm/ifunc-gdesc.s > create mode 100644 ld/testsuite/ld-arm/ifunc-gdesc.ver Ping? > diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c > index 526d4f8..6a20baf 100644 > --- a/bfd/elf32-arm.c > +++ b/bfd/elf32-arm.c > @@ -7521,6 +7521,8 @@ elf32_arm_allocate_plt_entry (struct bfd_link_info *info, > first entry. */ > if (splt->size == 0) > splt->size += htab->plt_header_size; > + > + htab->next_tls_desc_index++; > } > > /* Allocate the PLT entry itself, including any leading Thumb stub. */ > @@ -7533,7 +7535,10 @@ elf32_arm_allocate_plt_entry (struct bfd_link_info *info, > { > /* We also need to make an entry in the .got.plt section, which > will be placed in the .got section by the linker script. */ > - arm_plt->got_offset = sgotplt->size - 8 * htab->num_tls_desc; > + if (is_iplt_entry) > + arm_plt->got_offset = sgotplt->size; > + else > + arm_plt->got_offset = sgotplt->size - 8 * htab->num_tls_desc; > sgotplt->size += 4; > } > } > @@ -13359,8 +13364,6 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) > h->target_internal = ST_BRANCH_TO_ARM; > } > > - htab->next_tls_desc_index++; > - > /* VxWorks executables have a second set of relocations for > each PLT entry. They go in a separate relocation section, > which is processed by the kernel loader. */ > diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp > index c255587..2e7e164 100644 > --- a/ld/testsuite/ld-arm/arm-elf.exp > +++ b/ld/testsuite/ld-arm/arm-elf.exp > @@ -460,6 +460,9 @@ set armelftests_nonacl { > "" {long-plt-format.s} > {{objdump "-d -j .plt" long-plt-format.d}} > "long-plt-format"} > + {"IFUNC and TLS descriptor shared library" "-shared -T arm-lib.ld --version-script=ifunc-gdesc.ver" "" "" {ifunc-gdesc.s} > + {{objdump "-Rw" ifunc-gdesc.r}} > + "ifunc-gdesc.so"} > } > > run_ld_link_tests $armelftests_common > diff --git a/ld/testsuite/ld-arm/ifunc-gdesc.r b/ld/testsuite/ld-arm/ifunc-gdesc.r > new file mode 100644 > index 0000000..a49dd2b > --- /dev/null > +++ b/ld/testsuite/ld-arm/ifunc-gdesc.r > @@ -0,0 +1,6 @@ > +tmpdir/ifunc-gdesc.so: file format elf32-(big|little)arm > +DYNAMIC RELOCATION RECORDS > +OFFSET TYPE VALUE > +0000825c R_ARM_IRELATIVE \*ABS\* > +00008248 R_ARM_TLS_DESC \*ABS\* > +00008250 R_ARM_TLS_DESC \*ABS\* > diff --git a/ld/testsuite/ld-arm/ifunc-gdesc.s b/ld/testsuite/ld-arm/ifunc-gdesc.s > new file mode 100644 > index 0000000..a07a5d5 > --- /dev/null > +++ b/ld/testsuite/ld-arm/ifunc-gdesc.s > @@ -0,0 +1,29 @@ > + > + .arm > + > +foo: > + bl ifunc1(PLT) > + ldr r0,1f > +2: bl loc1(tlscall) > + nop > +1: .word loc1(tlsdesc) + (. - 2b) > + > + ldr r0,1f > +2: bl loc2(tlscall) > + nop > +1: .word loc2(tlsdesc) + (. - 2b) > + > + .type ifunc1,%gnu_indirect_function > + .global ifunc1 > +ifunc1: > + mov pc,lr > + .size ifunc1,.-ifunc1 > + > + > + .section .tdata,"awT",%progbits > + .space 8 > + .type loc1, %object > +loc1: .space 4 > + .type loc2, %object > +loc2: .space 4 > + > diff --git a/ld/testsuite/ld-arm/ifunc-gdesc.ver b/ld/testsuite/ld-arm/ifunc-gdesc.ver > new file mode 100644 > index 0000000..a82ffc4 > --- /dev/null > +++ b/ld/testsuite/ld-arm/ifunc-gdesc.ver > @@ -0,0 +1,4 @@ > +{ > +global: foo; > +local: *; > +}; > \ No newline at end of file > -- > 1.9.0 > -- Will Newton Toolchain Working Group, Linaro