[SH] TLS IE -> LE optimization issue

Kaz Kojima kkojima@rr.iij4u.or.jp
Mon Apr 16 11:47:00 GMT 2012


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)



More information about the Binutils mailing list