This is the mail archive of the binutils@sourceware.org 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]

Re: _bfd_elf_merge_symbol tidy


The code I'm deleting here was added by HJ in
http://sourceware.org/ml/binutils/2001-11/msg00640.html
Reading between the lines in that thread, I'd guess HJ first added the
symbol loop detection, then moved that code into
_bfd_elf_add_default_symbol.  The thing is that if "override" is true
then the call to elf_link_hash_lookup will be using the same name as
we used earlier when creating the symbol, and therefore must return
the same as "hi" at the _bfd_elf_add_default_symbol call point.  That
in turn means one of the "return TRUE" statements must be hit.  So
there is no need for the symbol lookup, and it's better to move the
"override" test out of _bfd_elf_add_default_symbol.  Also, note that
"definition" is cleared when "override".

A higher level consideration says that if a symbol is being
overridden, then we must have already created any necessary indirect
symbols when processing the symbol doing the overriding.

	* elflink.c (_bfd_elf_add_default_symbol): Delete "override" param.
	(elf_link_add_object_symbols): Don't call _bfd_elf_add_default_symbol
	when override is true.

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.480
diff -u -p -r1.480 elflink.c
--- bfd/elflink.c	25 Mar 2013 06:03:48 -0000	1.480
+++ bfd/elflink.c	25 Mar 2013 06:04:36 -0000
@@ -1579,8 +1579,7 @@ _bfd_elf_add_default_symbol (bfd *abfd,
 			     Elf_Internal_Sym *sym,
 			     asection **psec,
 			     bfd_vma *value,
-			     bfd_boolean *dynsym,
-			     bfd_boolean override)
+			     bfd_boolean *dynsym)
 {
   bfd_boolean type_change_ok;
   bfd_boolean size_change_ok;
@@ -1591,6 +1590,7 @@ _bfd_elf_add_default_symbol (bfd *abfd,
   const struct elf_backend_data *bed;
   bfd_boolean collect;
   bfd_boolean dynamic;
+  bfd_boolean override;
   char *p;
   size_t len, shortlen;
   asection *sec;
@@ -1603,24 +1603,6 @@ _bfd_elf_add_default_symbol (bfd *abfd,
   if (p == NULL || p[1] != ELF_VER_CHR)
     return TRUE;
 
-  if (override)
-    {
-      /* We are overridden by an old definition. We need to check if we
-	 need to create the indirect symbol from the default name.  */
-      hi = elf_link_hash_lookup (elf_hash_table (info), name, TRUE,
-				 FALSE, FALSE);
-      BFD_ASSERT (hi != NULL);
-      if (hi == h)
-	return TRUE;
-      while (hi->root.type == bfd_link_hash_indirect
-	     || hi->root.type == bfd_link_hash_warning)
-	{
-	  hi = (struct elf_link_hash_entry *) hi->root.u.i.link;
-	  if (hi == h)
-	    return TRUE;
-	}
-    }
-
   bed = get_elf_backend_data (abfd);
   collect = bed->collect;
   dynamic = (abfd->flags & DYNAMIC) != 0;
@@ -4425,10 +4407,10 @@ error_free_dyn:
 
 	  /* Check to see if we need to add an indirect symbol for
 	     the default name.  */
-	  if (definition || h->root.type == bfd_link_hash_common)
+	  if (definition
+	      || (!override && h->root.type == bfd_link_hash_common))
 	    if (!_bfd_elf_add_default_symbol (abfd, info, h, name, isym,
-					      &sec, &value, &dynsym,
-					      override))
+					      &sec, &value, &dynsym))
 	      goto error_free_vers;
 
 	  if (definition && !dynamic)

-- 
Alan Modra
Australia Development Lab, IBM


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