public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: Roland McGrath <mcgrathr@google.com>
Cc: bug-binutils@gnu.org, binutils@sourceware.org
Subject: Re: .gnu.warning.foo interferes with archive-member rules
Date: Tue, 07 Jun 2011 09:08:00 -0000	[thread overview]
Message-ID: <20110607090830.GA4172@bubble.grove.modra.org> (raw)
In-Reply-To: <x57jlixed1md.fsf@frobland.mtv.corp.google.com>

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

       reply	other threads:[~2011-06-07  9:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <x57jlixed1md.fsf@frobland.mtv.corp.google.com>
2011-06-07  9:08 ` Alan Modra [this message]
     [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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110607090830.GA4172@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=bug-binutils@gnu.org \
    --cc=mcgrathr@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).