This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [SH] TLS IE -> LE optimization issue
- From: Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- To: binutils at sourceware dot org
- Cc: amodra at gmail dot com, thomas at codesourcery dot com, aoliva at redhat dot com
- Date: Mon, 16 Apr 2012 07:18:11 +0900 (JST)
- Subject: Re: [SH] TLS IE -> LE optimization issue
- References: <87obqvpr9l.fsf@schwinge.name> <20120414002643.GA3218@bubble.grove.modra.org>
Alan Modra <amodra@gmail.com> wrote:
> On Fri, Apr 13, 2012 at 05:48:06PM +0200, Thomas Schwinge wrote:
>> That is, we need a __thread variable that is referenced from another
>> compilation unit; these two are linked into an executable; and we need a
>> (dummy) SO in order to trigger creation of the .dynamic section, etc.
>
> A dummy .so should make no difference to dynamic relocations, so
> you've found a bug in the SH allocate_dynrelocs.
>
> elf32-ppc.c allocate_dynrelocs handles this situation by testing
> whether the tls symbol is defined in a dynamic library. If not, no
> dynamic relocation is allocated and a special GOT entry for local
> dynamic TLS syms is used, tlsld_got.
Ah, then a minimal fix would be a patch like below, though I'm
not sure if it's enough. Also there might be similar problems
in SH allocate_dynrelocs for the other TLS relocations.
Regards,
kaz
--
--- ORIG/src/bfd/elf32-sh.c 2012-03-04 10:20:50.000000000 +0900
+++ src/bfd/elf32-sh.c 2012-04-15 07:52:20.000000000 +0900
@@ -3111,6 +3111,9 @@ allocate_dynrelocs (struct elf_link_hash
&& (got_type == GOT_NORMAL || got_type == GOT_FUNCDESC))
htab->srofixup->size += 4;
}
+ /* No dynamic relocations required when IE->LE conversion happens. */
+ else if (got_type == GOT_TLS_IE && !h->def_dynamic && !info->shared)
+ ;
/* R_SH_TLS_IE_32 needs one dynamic relocation if dynamic,
R_SH_TLS_GD needs one if local symbol and two if global. */
else if ((got_type == GOT_TLS_GD && h->dynindx == -1)