public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: .gnu.warning.foo interferes with archive-member rules
       [not found] <x57jlixed1md.fsf@frobland.mtv.corp.google.com>
@ 2011-06-07  9:08 ` Alan Modra
       [not found]   ` <BANLkTimL5RxUHv0JzxxV_JsMcyWwBKQh+eF7ene2SPAEJEjj8A@mail.gmail.com>
  2011-06-08  4:48   ` H.J. Lu
  0 siblings, 2 replies; 4+ messages in thread
From: Alan Modra @ 2011-06-07  9:08 UTC (permalink / raw)
  To: Roland McGrath; +Cc: bug-binutils, binutils

On Mon, Jun 06, 2011 at 03:41:14PM -0700, Roland McGrath wrote:
> Consider:
> 
> 	% head ref.s def.s
> 	==> ref.s <==
> 		.data
> 	ptrsym:
> 	.long badsym
> 
> 		.section .gnu.warning.badsym,"",@progbits
> 		.string "badsym warning"
> 
> 	==> def.s <==
> 	.comm badsym,4
> 	% as --32 -o ref.o ref.s
> 	% as --32 -o def.o def.s
> 	% ar cqs def.a def.o
> 	% ./ld/ld-new -m elf_i386 -o foo ref.o def.a
> 	ref.o: In function `ptrsym':
> 	(.data+0x0): warning: badsym warning
> 	./ld/ld-new: warning: cannot find entry symbol _start; defaulting to 0000000008048054
> 	ref.o: In function `ptrsym':
> 	(.data+0x0): undefined reference to `badsym'
> 	[Exit 1]
> 	% 

I think you've managed to hit two bugs.  I'll commit the following
after some testing.

bfd/
	* elflink.c (_bfd_elf_archive_symbol_lookup): Follow warning and
	indirect links here.
ld/
	* ldlang.c (lang_one_common): Handle warning symbols.

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.406
diff -u -p -r1.406 elflink.c
--- bfd/elflink.c	26 May 2011 04:28:20 -0000	1.406
+++ bfd/elflink.c	7 Jun 2011 09:03:39 -0000
@@ -4911,7 +4911,7 @@ _bfd_elf_archive_symbol_lookup (bfd *abf
   char *p, *copy;
   size_t len, first;
 
-  h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE, FALSE);
+  h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE, TRUE);
   if (h != NULL)
     return h;
 
@@ -4934,14 +4934,14 @@ _bfd_elf_archive_symbol_lookup (bfd *abf
   memcpy (copy, name, first);
   memcpy (copy + first, name + first + 1, len - first);
 
-  h = elf_link_hash_lookup (elf_hash_table (info), copy, FALSE, FALSE, FALSE);
+  h = elf_link_hash_lookup (elf_hash_table (info), copy, FALSE, FALSE, TRUE);
   if (h == NULL)
     {
       /* We also need to check references to the symbol without the
 	 version.  */
       copy[first - 1] = '\0';
       h = elf_link_hash_lookup (elf_hash_table (info), copy,
-				FALSE, FALSE, FALSE);
+				FALSE, FALSE, TRUE);
     }
 
   bfd_release (abfd, copy);
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.370
diff -u -p -r1.370 ldlang.c
--- ld/ldlang.c	23 May 2011 05:41:01 -0000	1.370
+++ ld/ldlang.c	7 Jun 2011 09:03:41 -0000
@@ -5885,6 +5885,9 @@ lang_one_common (struct bfd_link_hash_en
   bfd_vma size;
   asection *section;
 
+  if (h->type == bfd_link_hash_warning)
+    h = h->u.i.link;
+
   if (h->type != bfd_link_hash_common)
     return TRUE;
 


-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: .gnu.warning.foo interferes with archive-member rules
       [not found]   ` <BANLkTimL5RxUHv0JzxxV_JsMcyWwBKQh+eF7ene2SPAEJEjj8A@mail.gmail.com>
@ 2011-06-08  0:36     ` Alan Modra
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2011-06-08  0:36 UTC (permalink / raw)
  To: Roland McGrath; +Cc: bug-binutils, binutils

On Tue, Jun 07, 2011 at 09:50:18AM -0700, Roland McGrath wrote:
> Thanks!  I don't understand your changes at all off hand, and I strongly
> suspected that the patch I tried was too simple-minded to be right.

Setting "follow" true for the elf_link_hash_lookup calls in
_bfd_elf_archive_symbol_lookup means we get to the real symbol in the
elf_link_add_archive_symbols loop you were patching.  We want that
because elf_link_add_archive_symbols needs to make a decision
depending on whether the symbol is defined or not, and specially treat
commons.  Indirect and warning syms can point to any other sym type.

The lang_one_common change is needed in any function called by
bfd_link_hash_traverse.  When warning symbols are created, they
replace the "real" entry in the hash table, so you never get to see
the real symbol in a hash traversal.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: .gnu.warning.foo interferes with archive-member rules
  2011-06-07  9:08 ` .gnu.warning.foo interferes with archive-member rules Alan Modra
       [not found]   ` <BANLkTimL5RxUHv0JzxxV_JsMcyWwBKQh+eF7ene2SPAEJEjj8A@mail.gmail.com>
@ 2011-06-08  4:48   ` H.J. Lu
  2011-06-14  2:57     ` Alan Modra
  1 sibling, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2011-06-08  4:48 UTC (permalink / raw)
  To: Roland McGrath, bug-binutils, binutils

On Tue, Jun 7, 2011 at 2:08 AM, Alan Modra <amodra@gmail.com> wrote:
> On Mon, Jun 06, 2011 at 03:41:14PM -0700, Roland McGrath wrote:
>> Consider:
>>
>>       % head ref.s def.s
>>       ==> ref.s <==
>>               .data
>>       ptrsym:
>>       .long badsym
>>
>>               .section .gnu.warning.badsym,"",@progbits
>>               .string "badsym warning"
>>
>>       ==> def.s <==
>>       .comm badsym,4
>>       % as --32 -o ref.o ref.s
>>       % as --32 -o def.o def.s
>>       % ar cqs def.a def.o
>>       % ./ld/ld-new -m elf_i386 -o foo ref.o def.a
>>       ref.o: In function `ptrsym':
>>       (.data+0x0): warning: badsym warning
>>       ./ld/ld-new: warning: cannot find entry symbol _start; defaulting to 0000000008048054
>>       ref.o: In function `ptrsym':
>>       (.data+0x0): undefined reference to `badsym'
>>       [Exit 1]
>>       %
>
> I think you've managed to hit two bugs.  I'll commit the following
> after some testing.
>
> bfd/
>        * elflink.c (_bfd_elf_archive_symbol_lookup): Follow warning and
>        indirect links here.
> ld/
>        * ldlang.c (lang_one_common): Handle warning symbols.
>
I checked in this testcase.

Thanks.


-- 
H.J.
---
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 5ee6f44..31d542d 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2011-06-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* ld-elf/elf.exp: Build symbol3.a and symbol3w.a.
+
+	* ld-elf/symbol3.s: New.
+	* ld-elf/symbol3w.s: Likewise.
+	* ld-elf/warn3.d: Likewise.
+
 2011-06-02  Nathan Sidwell  <nathan@codesourcery.com>

 	Adjust tests for zero offset formatting.
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index b9ff0bd..e991f83 100644
--- a/ld/testsuite/ld-elf/elf.exp
+++ b/ld/testsuite/ld-elf/elf.exp
@@ -40,6 +40,15 @@ if { [is_remote host] } then {
     remote_download host merge.ld
 }

+run_ld_link_tests {
+    {"Build symbol3.a"
+     "" ""
+     {symbol3.s} {} "symbol3.a"}
+    {"Build symbol3w.a"
+     "" ""
+     {symbol3w.s} {} "symbol3w.a"}
+}
+
 set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
 foreach t $test_list {
     # We need to strip the ".d", but can leave the dirname.
diff --git a/ld/testsuite/ld-elf/symbol3.s b/ld/testsuite/ld-elf/symbol3.s
new file mode 100644
index 0000000..4fd76d5
--- /dev/null
+++ b/ld/testsuite/ld-elf/symbol3.s
@@ -0,0 +1 @@
+	 .comm badsym,4
diff --git a/ld/testsuite/ld-elf/symbol3w.s b/ld/testsuite/ld-elf/symbol3w.s
new file mode 100644
index 0000000..33262a6
--- /dev/null
+++ b/ld/testsuite/ld-elf/symbol3w.s
@@ -0,0 +1,4 @@
+	.data
+	.dc.a	badsym
+        .section        .gnu.warning.badsym,"",%progbits
+        .string "badsym warning"
diff --git a/ld/testsuite/ld-elf/warn3.d b/ld/testsuite/ld-elf/warn3.d
new file mode 100644
index 0000000..c99618d
--- /dev/null
+++ b/ld/testsuite/ld-elf/warn3.d
@@ -0,0 +1,15 @@
+#source: start.s
+#ld: tmpdir/symbol3w.o tmpdir/symbol3.a
+#warning: .*: warning: badsym warning$
+#readelf: -s
+#notarget: "sparc64-*-solaris2*" "sparcv9-*-solaris2*"
+#xfail: arc-*-* d30v-*-* dlx-*-* fr30-*-* frv-*-elf i860-*-* i960-*-*
+#xfail: iq*-*-* mn10200-*-* moxie-*-* msp*-*-* mt-*-* or32-*-* pj*-*-*
+# if not using elf32.em, you don't get fancy section handling
+
+# Check that warnings are generated for the symbols in .gnu.warning
+# construct and that the symbol still appears as expected.
+
+#...
+ +[0-9]+: +[0-9a-f]+ +4 +OBJECT +GLOBAL +DEFAULT +[1-9] badsym
+#pass

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: .gnu.warning.foo interferes with archive-member rules
  2011-06-08  4:48   ` H.J. Lu
@ 2011-06-14  2:57     ` Alan Modra
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2011-06-14  2:57 UTC (permalink / raw)
  To: binutils

	* ld-elf/elf.exp: Don't attempt to build symbol3.a for hppa64-hpux.
	* ld-elf/warn3.d: Correct target selection and comment.

Index: ld/testsuite/ld-elf/elf.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/elf.exp,v
retrieving revision 1.24
diff -u -p -r1.24 elf.exp
--- ld/testsuite/ld-elf/elf.exp	10 Jun 2011 14:04:24 -0000	1.24
+++ ld/testsuite/ld-elf/elf.exp	13 Jun 2011 01:26:59 -0000
@@ -40,13 +40,15 @@ if { [is_remote host] } then {
     remote_download host merge.ld
 }
 
-run_ld_link_tests {
-    {"Build symbol3.a"
-     "" ""
-     {symbol3.s} {} "symbol3.a"}
-    {"Build symbol3w.a"
-     "" ""
-     {symbol3w.s} {} "symbol3w.a"}
+if { ![istarget hppa64*-hpux*] } {
+    run_ld_link_tests {
+	{"Build symbol3.a"
+	    "" ""
+	    {symbol3.s} {} "symbol3.a"}
+	{"Build symbol3w.a"
+	    "" ""
+	    {symbol3w.s} {} "symbol3w.a"}
+    }
 }
 
 # Run a test to check linking a shared library with a broken linker
Index: ld/testsuite/ld-elf/warn3.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/warn3.d,v
retrieving revision 1.1
diff -u -p -r1.1 warn3.d
--- ld/testsuite/ld-elf/warn3.d	8 Jun 2011 04:47:04 -0000	1.1
+++ ld/testsuite/ld-elf/warn3.d	13 Jun 2011 01:26:59 -0000
@@ -2,10 +2,9 @@
 #ld: tmpdir/symbol3w.o tmpdir/symbol3.a 
 #warning: .*: warning: badsym warning$
 #readelf: -s
-#notarget: "sparc64-*-solaris2*" "sparcv9-*-solaris2*"
-#xfail: arc-*-* d30v-*-* dlx-*-* fr30-*-* frv-*-elf i860-*-* i960-*-*
-#xfail: iq*-*-* mn10200-*-* moxie-*-* msp*-*-* mt-*-* or32-*-* pj*-*-*
-# if not using elf32.em, you don't get fancy section handling
+#notarget: hppa64*-hpux*
+#xfail: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-*
+# generic linker targets don't support .gnu.warning sections.
 
 # Check that warnings are generated for the symbols in .gnu.warning
 # construct and that the symbol still appears as expected.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-06-14  2:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <x57jlixed1md.fsf@frobland.mtv.corp.google.com>
2011-06-07  9:08 ` .gnu.warning.foo interferes with archive-member rules Alan Modra
     [not found]   ` <BANLkTimL5RxUHv0JzxxV_JsMcyWwBKQh+eF7ene2SPAEJEjj8A@mail.gmail.com>
2011-06-08  0:36     ` Alan Modra
2011-06-08  4:48   ` H.J. Lu
2011-06-14  2:57     ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).