This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [SH] TLS IE -> LE optimization issue


Hi!

On Mon, 16 Apr 2012 07:18:11 +0900, Kaz Kojima <kkojima@rr.iij4u.or.jp> wrote:
> 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.

> --- 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)

This does work fine, thanks!  (No regressions all over a sh-linux-gnu
toolchain (SH4).)


And, for GDB's benefit, I'd like to put in this mini patch, OK?

bfd/
	* elf32-sh.c (elf_sh_link_hash_entry): Specify an enum identifier for
	got_type.
	(allocate_dynrelocs, sh_elf_relocate_section, sh_elf_check_relocs): Use
	it.

Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.175
diff -u -p -r1.175 elf32-sh.c
--- bfd/elf32-sh.c	13 Mar 2012 06:04:35 -0000	1.175
+++ bfd/elf32-sh.c	17 Apr 2012 11:57:31 -0000
@@ -2406,7 +2406,7 @@ struct elf_sh_link_hash_entry
      and thus require fixups or relocations.  */
   bfd_signed_vma abs_funcdesc_refcount;
 
-  enum {
+  enum got_type {
     GOT_UNKNOWN = 0, GOT_NORMAL, GOT_TLS_GD, GOT_TLS_IE, GOT_FUNCDESC
   } got_type;
 };
@@ -3078,7 +3078,7 @@ allocate_dynrelocs (struct elf_link_hash
     {
       asection *s;
       bfd_boolean dyn;
-      int got_type = sh_elf_hash_entry (h)->got_type;
+      enum got_type got_type = sh_elf_hash_entry (h)->got_type;
 
       /* Make sure this symbol is output as a dynamic symbol.
 	 Undefined weak syms won't yet be marked as dynamic.  */
@@ -3977,7 +3980,7 @@ sh_elf_relocate_section (bfd *output_bfd
       bfd_reloc_status_type r;
       int seen_stt_datalabel = 0;
       bfd_vma off;
-      int got_type;
+      enum got_type got_type;
       const char *symname = NULL;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
@@ -6090,7 +6093,7 @@ sh_elf_check_relocs (bfd *abfd, struct b
   const Elf_Internal_Rela *rel_end;
   asection *sreloc;
   unsigned int r_type;
-  int got_type, old_got_type;
+  enum got_type got_type, old_got_type;
 
   sreloc = NULL;
 


GrÃÃe,
 Thomas

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]