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]

Committed: make .dtpoffd directive usable


For the purpose of debug relocations I had to stretch the
definition of the R_CRIS_32_DTPREL reloc to allow overridable
(non-locally-determined) symbols too.  There is no general
offset-only TLS relocation for CRIS; for non-local symbols the
module number and offset are always required together, which is
served by R_CRIS_DTP.

Committed, tested cris-elf & cris-axis-linux-gnu.

bfd:
	* elf32-cris.c (cris_elf_relocate_section): <case
	R_CRIS_16_DTPREL, R_CRIS_32_DTPREL>: Allow use of non-local
	symbols for non-allocated sections.  Don't check whether to
	generate R_CRIS_DTPMOD for non-allocated sections.
	(cris_elf_gc_sweep_hook) <case R_CRIS_32_DTPREL>: Don't
	handle relocation GC:ing if applied to non-allocated section.
	(cris_elf_check_relocs): Similar.

ld/testsuite:
	* ld-cris/tls-commx.s, ld-cris/tls-dso-dtpoffd2.d,
	ld-cris/tls-dso-dtpoffd4.d, ld-cris/tls-dtpoffdx.s,
	ld-cris/tls-e-dtpoffd1.d: New tests.

Index: ld-cris/tls-commx.s
===================================================================
RCS file: ld-cris/tls-commx.s
diff -N ld-cris/tls-commx.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-cris/tls-commx.s	24 Mar 2009 07:54:32 -0000
@@ -0,0 +1 @@
+	.tls_common x,4,4
Index: ld-cris/tls-dso-dtpoffd2.d
===================================================================
RCS file: ld-cris/tls-dso-dtpoffd2.d
diff -N ld-cris/tls-dso-dtpoffd2.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-cris/tls-dso-dtpoffd2.d	24 Mar 2009 07:54:32 -0000
@@ -0,0 +1,37 @@
+#source: start1.s
+#source: tls-dtpoffdx.s
+#source: tls-gd-1.s
+#source: tls128.s
+#source: tls-x.s
+#as: --no-underscore --em=criself --pic -I$srcdir/$subdir
+#ld: -m crislinux --shared
+#objdump: -d -s -t -r -p
+
+# Linking a file with a DTPOFF from a .dtpoffd of a GD variable, PIC
+# (globally defined here but overridable).  Making sure it links and
+# that the offset is correct, locally.
+
+.*:     file format elf32-cris
+
+Program Header:
+#...
+     TLS off   .*
+         filesz 0x0+84 memsz 0x0+84 flags r--
+#...
+SYMBOL TABLE:
+#...
+0+80 g       .tdata	0+4 x
+#...
+Contents of section .rela.dyn:
+ 01a4 b8220000 17030000 00000000           .*
+Contents of section .text:
+ 01b0 41b20000 5fae0c00                    .*
+#...
+Contents of section .got:
+ 22ac 3c220000 00000000 00000000 00000000  .*
+ 22bc 00000000                             .*
+Contents of section .debug_info:
+ 0000 80000000                             .*
+#...
+Disassembly of section .text:
+#pass
Index: ld-cris/tls-dso-dtpoffd4.d
===================================================================
RCS file: ld-cris/tls-dso-dtpoffd4.d
diff -N ld-cris/tls-dso-dtpoffd4.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-cris/tls-dso-dtpoffd4.d	24 Mar 2009 07:54:32 -0000
@@ -0,0 +1,37 @@
+#source: start1.s
+#source: tls-dtpoffdx.s
+#source: tls-gd-1.s
+#source: tls128.s
+#source: tls-commx.s
+#as: --no-underscore --em=criself --pic -I$srcdir/$subdir
+#ld: -m crislinux --shared
+#objdump: -d -s -t -r -p
+
+# Linking a file with a DTPOFF from a .dtpoffd of a GD COMMON
+# variable, PIC (globally defined here but overridable).  Making sure
+# it links and that the offset is correct, locally.
+
+.*:     file format elf32-cris
+
+Program Header:
+#...
+     TLS off   .*
+         filesz 0x0+80 memsz 0x0+84 flags r--
+#...
+SYMBOL TABLE:
+#...
+0+80 g       .tbss	0+4 x
+#...
+Contents of section .rela.dyn:
+ 01a4 b4220000 17030000 00000000           .*
+Contents of section .text:
+ 01b0 41b20000 5fae0c00                    .*
+#...
+Contents of section .got:
+ 22a8 38220000 00000000 00000000 00000000  .*
+ 22b8 00000000                             .*
+Contents of section .debug_info:
+ 0000 80000000                             .*
+#...
+Disassembly of section .text:
+#pass
Index: ld-cris/tls-dtpoffdx.s
===================================================================
RCS file: ld-cris/tls-dtpoffdx.s
diff -N ld-cris/tls-dtpoffdx.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-cris/tls-dtpoffdx.s	24 Mar 2009 07:54:32 -0000
@@ -0,0 +1,2 @@
+ .section .debug_info
+ .dtpoffd x
Index: ld-cris/tls-e-dtpoffd1.d
===================================================================
RCS file: ld-cris/tls-e-dtpoffd1.d
diff -N ld-cris/tls-e-dtpoffd1.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-cris/tls-e-dtpoffd1.d	24 Mar 2009 07:54:32 -0000
@@ -0,0 +1,32 @@
+#source: start1.s
+#source: tls-dtpoffdx.s
+#source: tls-gd-1.s
+#source: tls128.s
+#source: tls-x.s
+#as: --no-underscore --em=criself --pic -I$srcdir/$subdir
+#ld: -m crislinux
+#objdump: -d -s -t -r -p
+
+.*:     file format elf32-cris
+
+Program Header:
+#...
+     TLS off  .*
+         filesz 0x0+84 memsz 0x0+84 flags r--
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+80 g       .tdata	0+4 x
+#...
+Contents of section .text:
+ 80094 41b20000 5fae0c00                    .*
+Contents of section .tdata:
+#...
+Contents of section .got:
+ 82120 00000000 00000000 00000000 01000000  .*
+ 82130 80000000                             .*
+Contents of section .debug_info:
+ 0000 fcffffff                             .*
+Contents of section .debug_line:
+#pass

Index: elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.102
diff -p -u -r1.102 elf32-cris.c
--- elf32-cris.c	24 Mar 2009 03:32:31 -0000	1.102
+++ elf32-cris.c	24 Mar 2009 07:51:14 -0000
@@ -1615,10 +1615,12 @@ cris_elf_relocate_section (output_bfd, i
 	case R_CRIS_16_DTPREL:
 	case R_CRIS_32_DTPREL:
 	  /* This relocation must only be performed against local
-	     symbols.  It's also ok when we link a program and the
-	     symbol is defined in an ordinary (non-DSO) object (if
-	     it's undefined there, we've already seen an error).  */
+	     symbols, or to sections that are not loadable.  It's also
+	     ok when we link a program and the symbol is defined in an
+	     ordinary (non-DSO) object (if it's undefined there, we've
+	     already seen an error).  */
 	  if (h != NULL
+	      && (input_section->flags & SEC_ALLOC) != 0
 	      && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
 	      && (info->shared
 		  || (!h->def_regular
@@ -1641,14 +1643,16 @@ cris_elf_relocate_section (output_bfd, i
 	      return FALSE;
 	    }
 
-	  BFD_ASSERT (elf_cris_hash_table (info)->dtpmod_refcount != 0);
+	  BFD_ASSERT ((input_section->flags & SEC_ALLOC) == 0
+		      || elf_cris_hash_table (info)->dtpmod_refcount != 0);
 
 	  /* Fill in a R_CRIS_DTPMOD reloc at offset 3 if we haven't
 	     already done so.  Note that we do this in .got.plt, not
 	     in .got, as .got.plt contains the first part, still the
 	     reloc is against .got, because the linker script directs
 	     (is required to direct) them both into .got.  */
-	  if (elf_cris_hash_table (info)->dtpmod_refcount > 0)
+	  if (elf_cris_hash_table (info)->dtpmod_refcount > 0
+	      && (input_section->flags & SEC_ALLOC) != 0)
 	    {
 	      asection *sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
 	      BFD_ASSERT (sgotplt != NULL);
@@ -2684,6 +2688,10 @@ cris_elf_gc_sweep_hook (bfd *abfd,
 	  break;
 
 	case R_CRIS_32_DTPREL:
+	  /* This'd be a .dtpreld entry in e.g. debug info.  */
+	  if ((sec->flags & SEC_ALLOC) == 0)
+	    break;
+	  /* Fall through.  */
 	case R_CRIS_16_DTPREL:
 	  elf_cris_hash_table (info)->dtpmod_refcount--;
 	  if (elf_cris_hash_table (info)->dtpmod_refcount == 0)
@@ -3151,8 +3159,17 @@ cris_elf_check_relocs (abfd, info, sec, 
 	 on the first input bfd we found that contained dynamic relocs.  */
       switch (r_type)
 	{
-	case R_CRIS_16_DTPREL:
 	case R_CRIS_32_DTPREL:
+	  if ((sec->flags & SEC_ALLOC) == 0)
+	    /* This'd be a .dtpreld entry in e.g. debug info.  We have
+	       several different switch statements below, but none of
+	       that is needed; we need no preparations for resolving
+	       R_CRIS_32_DTPREL into a non-allocated section (debug
+	       info), so let's just move on to the next
+	       relocation.  */
+	    continue;
+	  /* Fall through.  */
+	case R_CRIS_16_DTPREL:
 	  /* The first .got.plt entry is right after the R_CRIS_DTPMOD
 	     entry at index 3. */
 	  if (elf_cris_hash_table (info)->dtpmod_refcount == 0)

brgds, H-P


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