This is the mail archive of the binutils@sources.redhat.com 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, elf32-cris.c: Don't error on R_CRIS_32_GOTREL with just normal objects.


Seen when linking programs statically with an old glibc and a
new libgcc (GCC CVS); the old glibc will contain "normal"
symbols that libgcc defines .hidden and refers to with
local-only PIC relocs.  Maybe the undefweak case isn't useful,
but it's there for completeness sake anyway.  With this, my GCC
testsuite results are no longer a mess.  Yay.

Dan, I'd like this on the 2.14 branch.  Ok?

bfd:
	* elf32-cris.c (cris_elf_relocate_section) <case
	R_CRIS_32_GOTREL>: When linking a program, don't complain about a
	symbol from a normal object or an undefined weak symbol.

ld/testsuite:

	* ld-cris/locref1.d, ld-cris/locref1.s, ld-cris/locref2.d,
	ld-cris/locref2.s: New tests.

--- /dev/null	Tue Jan  1 05:00:00 1980
+++ ld-cris/locref1.d	Wed Jun 18 04:02:07 2003
@@ -0,0 +1,23 @@
+#as: --no-underscore --pic
+#source: expdyn1.s
+#source: locref1.s
+#ld: -m crislinux
+#objdump: -dt
+
+# Referencing a "normal" (non-hidden) symbol with a local-only PIC
+# relocation is ok when building an executable.
+
+.*:     file format elf32-cris
+
+SYMBOL TABLE:
+#...
+0+80076 g     F \.text	0+2 expfn
+0+820a0 g     O \.data	0+ expobj
+#...
+0+820a4 g     O \.got	0+ _GLOBAL_OFFSET_TABLE_
+#...
+Disassembly of section \.text:
+#...
+0+80078 <y>:
+   80078:	6fae d2df ffff  .*
+   8007e:	6fbe fcff ffff  .*
--- /dev/null	Tue Jan  1 05:00:00 1980
+++ ld-cris/locref1.s	Wed Jun 18 02:14:09 2003
@@ -0,0 +1,3 @@
+y:
+ move.d expfn:GOTOFF,$r10
+ move.d expobj:GOTOFF,$r11
--- /dev/null	Tue Jan  1 05:00:00 1980
+++ ld-cris/locref2.d	Wed Jun 18 04:01:57 2003
@@ -0,0 +1,23 @@
+#as: --no-underscore --pic
+#source: gotrel1.s
+#source: locref2.s
+#ld: -m crislinux
+#objdump: -dt
+
+# Referencing an undefined weak (non-hidden) symbol with a local-only
+# PIC relocation is ok when building an executable.
+
+.*:     file format elf32-cris
+
+SYMBOL TABLE:
+#...
+0+  w      \*UND\*	0+ expfn
+0+  w      \*UND\*	0+ expobj
+#...
+0+820a0 g     O \.got	0+ _GLOBAL_OFFSET_TABLE_
+#...
+Disassembly of section \.text:
+#...
+0+8007c <y>:
+   8007c:	6fae 60df f7ff  .*
+   80082:	6fbe 60df f7ff  .*
--- /dev/null	Tue Jan  1 05:00:00 1980
+++ ld-cris/locref2.s	Wed Jun 18 04:19:14 2003
@@ -0,0 +1,5 @@
+ .weak expfn
+ .weak expobj
+y:
+ move.d expfn:GOTOFF,$r10
+ move.d expobj:GOTOFF,$r11
Index: elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.40
diff -p -c -r1.40 elf32-cris.c
*** elf32-cris.c	17 Feb 2003 18:24:38 -0000	1.40
--- elf32-cris.c	18 Jun 2003 02:20:03 -0000
*************** cris_elf_relocate_section (output_bfd, i
*** 1129,1136 ****
  	  break;
  
  	case R_CRIS_32_GOTREL:
! 	  /* This relocation must only be performed against local symbols.  */
! 	  if (h != NULL && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
  	    {
  	      (*_bfd_error_handler)
  		(_("%s: relocation %s is not allowed for global symbol: `%s' from %s section"),
--- 1129,1143 ----
  	  break;
  
  	case R_CRIS_32_GOTREL:
! 	  /* This relocation must only be performed against local symbols.
! 	     It's also ok when we link a program and the symbol is either
! 	     defined in an ordinary (non-DSO) object or is undefined weak.  */
! 	  if (h != NULL
! 	      && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
! 	      && !(!info->shared
! 		   && ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
! 		       || ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
! 			   && h->root.type == bfd_link_hash_undefweak))))
  	    {
  	      (*_bfd_error_handler)
  		(_("%s: relocation %s is not allowed for global symbol: `%s' from %s section"),

brgds, H-P


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