public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H. J. Lu" <hjl@lucon.org>
To: Nick Clifton <nickc@redhat.com>
Cc: binutils@sources.redhat.com
Subject: Re: PATCH: PR ld/2884: Crash in elf64_ia64_relocate_section
Date: Tue, 11 Jul 2006 17:41:00 -0000	[thread overview]
Message-ID: <20060711174103.GA4385@lucon.org> (raw)
In-Reply-To: <44B3B00C.8030103@redhat.com>

On Tue, Jul 11, 2006 at 03:05:00PM +0100, Nick Clifton wrote:
> Hi H. J.
> 
> >2006-07-06  H.J. Lu  <hongjiu.lu@intel.com>
> >
> >	PR ld/2884
> >	* elflink.c (_bfd_elf_merge_symbol): Set ref_dynamic to 0 for
> >	hidden and internal visibility.  Copy the symbol info from the
> >	old versioned dynamic definition to the new one with
> >	non-default visibility.
> 
> Approved (with the grammatical correction mentioned by Jim).
> 

That piece code is very tricky. When elf_backend_copy_indirect_symbol
was called, we copied many bits, some of which are incorrect and
unexpected for hidden and internal symbols. We need to call
elf_backend_hide_symbol to remove those extra bits.


H.J.
-----
2006-07-11  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/2884
	* elflink.c (_bfd_elf_merge_symbol): Copy the symbol info from
	the old versioned dynamic definition to the new one with
	non-default visibility.  Hide the symbol if it is hidden or
	internal.

--- bfd/elflink.c.foo	2006-07-05 11:50:35.000000000 -0700
+++ bfd/elflink.c	2006-07-11 10:32:55.000000000 -0700
@@ -1007,7 +1007,41 @@ _bfd_elf_merge_symbol (bfd *abfd,
 	 relocatable file and the old definition comes from a dynamic
 	 object, we remove the old definition.  */
       if ((*sym_hash)->root.type == bfd_link_hash_indirect)
-	h = *sym_hash;
+	{
+	  /* Handle the case where the old dynamic definition is
+	     default versioned.  We need to copy the symbol info from
+	     the symbol with default version to the normal one if it
+	     was referenced before.  */
+	  if (h->ref_regular)
+	    {
+	      const struct elf_backend_data *bed
+		= get_elf_backend_data (abfd);
+	      struct elf_link_hash_entry *vh = *sym_hash;
+	      vh->root.type = h->root.type;
+	      h->root.type = bfd_link_hash_indirect;
+	      (*bed->elf_backend_copy_indirect_symbol) (info, vh, h);
+	      /* Protected symbols will override the dynamic definition
+		 with default version.  */
+	      if (ELF_ST_VISIBILITY (sym->st_other) == STV_PROTECTED)
+		{
+		  h->root.u.i.link = (struct bfd_link_hash_entry *) vh;
+		  vh->dynamic_def = 1;
+		  vh->ref_dynamic = 1;
+		}
+	      else
+		{
+		  h->root.type = vh->root.type;
+		  vh->ref_dynamic = 0;
+		  /* We have to hide it here since it was made dynamic
+		     global with extra bits when the symbol info was
+		     copied from the old dynamic definition.  */
+		  (*bed->elf_backend_hide_symbol) (info, vh, TRUE);
+		}
+	      h = vh;
+	    }
+	  else
+	    h = *sym_hash;
+	}
 
       if ((h->root.u.undef.next || info->hash->undefs_tail == &h->root)
 	  && bfd_is_und_section (sec))

  reply	other threads:[~2006-07-11 17:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-06 23:28 H. J. Lu
2006-07-10 20:11 ` James E Wilson
2006-07-11 14:05 ` Nick Clifton
2006-07-11 17:41   ` H. J. Lu [this message]
2006-07-12  4:03     ` H. J. Lu
2006-07-12  9:08       ` Nick Clifton
2006-07-12 17:19         ` H. J. Lu

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=20060711174103.GA4385@lucon.org \
    --to=hjl@lucon.org \
    --cc=binutils@sources.redhat.com \
    --cc=nickc@redhat.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).