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]

[PATCH] SH: SEC_DEBUGGING relocs


Hi,

When the binary has a definition of foo which is a COMMON symbol
referenced from a debugging section and the shared library also
defines foo in its .data section, SH linker complains like as:

 unresolvable relocation against symbol `foo' from .debug_info section

This patch fixes it and gives a test case except for sh64. The patch
itself is just an SH version of
<URL:http://sources.redhat.com/ml/binutils/2002-07/msg00246.html>.
It's tested on sh-unknown-linux-gnu and sh64-unknown-linux-gnu
with no regressions and committed.

It would be better to add the test case for sh64. I'd like to leave
it to sh64 experts.

Regards,
	kaz
--
bfd/ChangeLog
	* elf32-sh.c (sh_elf_relocate_section): Don't complain about
        unresolved debugging relocs in dynamic applications.
	* elf64-sh64.c (sh_elf64_relocate_section): Likewise.

ld/testsuite/ChangeLog
	* ld-sh/refdbg-0-dso.d: New test.
	* ld-sh/refdbg-1.d: Likewise.
	* ld-sh/refdbg.s: Likewise.
	* ld-sh/refdbglib.s: Likewise.

diff -u3prN ORIG/src/bfd/elf32-sh.c LOCAL/src/bfd/elf32-sh.c
--- ORIG/src/bfd/elf32-sh.c	Thu Nov  7 06:46:23 2002
+++ LOCAL/src/bfd/elf32-sh.c	Thu Nov 28 08:47:17 2002
@@ -4753,6 +4753,13 @@ sh_elf_relocate_section (output_bfd, inf
 			  || ((input_section->flags & SEC_DEBUGGING) != 0
 			      && (h->elf_link_hash_flags
 				  & ELF_LINK_HASH_DEF_DYNAMIC) != 0)))
+		  /* Dynamic relocs are not propagated for SEC_DEBUGGING
+		     sections because such sections are not SEC_ALLOC and
+		     thus ld.so will not process them.  */
+		  || (sec->output_section == NULL
+		      && ((input_section->flags & SEC_DEBUGGING) != 0
+			  && (h->elf_link_hash_flags
+			      & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
 		  || (sec->output_section == NULL
 		      && (sh_elf_hash_entry (h)->tls_type == GOT_TLS_IE
 			  || sh_elf_hash_entry (h)->tls_type == GOT_TLS_GD)))
diff -u3prN ORIG/src/bfd/elf64-sh64.c LOCAL/src/bfd/elf64-sh64.c
--- ORIG/src/bfd/elf64-sh64.c	Sat Oct 26 11:59:56 2002
+++ LOCAL/src/bfd/elf64-sh64.c	Thu Nov 28 16:34:52 2002
@@ -1680,7 +1680,14 @@ sh_elf64_relocate_section (output_bfd, i
 			     sections against symbols defined externally
 			     in shared libraries.  We can't do anything
 			     with them here.  */
-			  || (input_section->flags & SEC_DEBUGGING) != 0)))
+			  || (input_section->flags & SEC_DEBUGGING) != 0))
+		  /* Dynamic relocs are not propagated for SEC_DEBUGGING
+		     sections because such sections are not SEC_ALLOC and
+		     thus ld.so will not process them.  */
+		  || (sec->output_section == NULL
+		      && ((input_section->flags & SEC_DEBUGGING) != 0
+			  && (h->elf_link_hash_flags
+			      & ELF_LINK_HASH_DEF_DYNAMIC) != 0)))
 		relocation = 0;
 	      else if (sec->output_section == NULL)
 		{
diff -u3prN ORIG/src/ld/testsuite/ld-sh/refdbg-0-dso.d LOCAL/src/ld/testsuite/ld-sh/refdbg-0-dso.d
--- ORIG/src/ld/testsuite/ld-sh/refdbg-0-dso.d	Thu Jan  1 09:00:00 1970
+++ LOCAL/src/ld/testsuite/ld-sh/refdbg-0-dso.d	Thu Nov 28 08:25:23 2002
@@ -0,0 +1,9 @@
+#source: refdbglib.s
+#as: -little
+#ld: -shared -EL
+#objdump: -drj.text
+#target: sh*-*-linux* sh*-*-netbsd*
+
+.*: +file format elf32-sh.*
+
+#pass
diff -u3prN ORIG/src/ld/testsuite/ld-sh/refdbg-1.d LOCAL/src/ld/testsuite/ld-sh/refdbg-1.d
--- ORIG/src/ld/testsuite/ld-sh/refdbg-1.d	Thu Jan  1 09:00:00 1970
+++ LOCAL/src/ld/testsuite/ld-sh/refdbg-1.d	Thu Nov 28 08:40:34 2002
@@ -0,0 +1,10 @@
+#source: refdbg.s
+#as: -little
+#ld: -EL tmpdir/refdbg-0-dso.so
+#objdump: -sj.debug_info
+#target: sh*-*-linux* sh*-*-netbsd*
+
+.*: +file format elf32-sh.*
+
+Contents of section \.debug_info:
+ 0+0 0+0 +.*
diff -u3prN ORIG/src/ld/testsuite/ld-sh/refdbg.s LOCAL/src/ld/testsuite/ld-sh/refdbg.s
--- ORIG/src/ld/testsuite/ld-sh/refdbg.s	Thu Jan  1 09:00:00 1970
+++ LOCAL/src/ld/testsuite/ld-sh/refdbg.s	Thu Nov 28 08:22:16 2002
@@ -0,0 +1,11 @@
+	.text
+	.align 2
+	.globl	_start
+	.type	_start,@function
+_start:
+	rts
+	nop
+
+	.comm	foo,4,4
+	.section	.debug_info,"",@progbits
+	.ualong	foo
diff -u3prN ORIG/src/ld/testsuite/ld-sh/refdbglib.s LOCAL/src/ld/testsuite/ld-sh/refdbglib.s
--- ORIG/src/ld/testsuite/ld-sh/refdbglib.s	Thu Jan  1 09:00:00 1970
+++ LOCAL/src/ld/testsuite/ld-sh/refdbglib.s	Thu Nov 28 08:23:47 2002
@@ -0,0 +1,8 @@
+	.text
+	.global	foo
+	.data
+	.align 2
+	.type	foo, @object
+	.size	foo, 4
+foo:
+	.long	1


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