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]

Re: recent powerpc64 mixed dot-sym no-dot-sym breakage


I managed to break powerpc64 ld -r with the following change.

2005-02-01  Alan Modra  <amodra@bigpond.net.au>
[snip]
	(add_symbol_adjust): Make an undefweak func desc for old ABI
	objects to link with --as-needed shared libs.  Return fail status.

Found when compiling glibc with an older compiler using dot-symbols.  The
simple fix to add_symbol_adjust cures this problem, with the rest of the
patch being paranoid checking that symbols are actually defined before we
do certain operations.

	* elf64-ppc.c (add_symbol_adjust): Don't create fake descriptor
	syms when doing a relocatable link.
	(ppc64_elf_gc_mark_hook): Check that syms are defined before looking
	at u.def.section.
	(ppc64_elf_tls_setup): Likewise.
	(ppc64_elf_edit_opd): Don't use an undefined func desc sym.

--- elf64-ppc.c.orig	2005-02-04 14:38:50.803280013 +1030
+++ elf64-ppc.c	2005-02-04 14:13:47.000000000 +1030
@@ -4074,6 +4074,7 @@ add_symbol_adjust (struct elf_link_hash_
   eh = (struct ppc_link_hash_entry *) h;
   fdh = get_fdh (eh, htab);
   if (fdh == NULL
+      && !data->info->relocatable
       && (eh->elf.root.type == bfd_link_hash_undefined
 	  || eh->elf.root.type == bfd_link_hash_undefweak)
       && eh->elf.ref_regular)
@@ -4884,7 +4885,9 @@ ppc64_elf_gc_mark_hook (asection *sec,
 	      && eh->elf.root.type != bfd_link_hash_defweak)
 	    continue;
 
-	  if (eh->is_func_descriptor)
+	  if (eh->is_func_descriptor
+	      && (eh->oh->elf.root.type == bfd_link_hash_defined
+		  || eh->oh->elf.root.type == bfd_link_hash_defweak))
 	    rsec = eh->oh->elf.root.u.def.section;
 	  else if (get_opd_info (eh->elf.root.u.def.section) != NULL
 		   && opd_entry_value (eh->elf.root.u.def.section,
@@ -4930,12 +4933,17 @@ ppc64_elf_gc_mark_hook (asection *sec,
 	    case bfd_link_hash_defined:
 	    case bfd_link_hash_defweak:
 	      eh = (struct ppc_link_hash_entry *) h;
-	      if (eh->oh != NULL && eh->oh->is_func_descriptor)
+	      if (eh->oh != NULL
+		  && eh->oh->is_func_descriptor
+		  && (eh->oh->elf.root.type == bfd_link_hash_defined
+		      || eh->oh->elf.root.type == bfd_link_hash_defweak))
 		eh = eh->oh;
 
 	      /* Function descriptor syms cause the associated
 		 function code sym section to be marked.  */
-	      if (eh->is_func_descriptor)
+	      if (eh->is_func_descriptor
+		  && (eh->oh->elf.root.type == bfd_link_hash_defined
+		      || eh->oh->elf.root.type == bfd_link_hash_defweak))
 		{
 		  /* They also mark their opd section.  */
 		  if (!eh->elf.root.u.def.section->gc_mark)
@@ -6194,8 +6202,14 @@ ppc64_elf_edit_opd (bfd *obfd, struct bf
 
 		  if (h != NULL
 		      && h->root.root.string[0] == '.')
-		    fdh = get_fdh ((struct ppc_link_hash_entry *) h,
-				   ppc_hash_table (info));
+		    {
+		      fdh = get_fdh ((struct ppc_link_hash_entry *) h,
+				     ppc_hash_table (info));
+		      if (fdh != NULL
+			  && fdh->elf.root.type != bfd_link_hash_defined
+			  && fdh->elf.root.type != bfd_link_hash_defweak)
+			fdh = NULL;
+		    }
 
 		  skip = (sym_sec->owner != ibfd
 			  || sym_sec->output_section == bfd_abs_section_ptr);
@@ -6379,7 +6393,9 @@ ppc64_elf_tls_setup (bfd *obfd, struct b
 
       if (htab->tls_get_addr_fd == NULL
 	  && h->oh != NULL
-	  && h->oh->is_func_descriptor)
+	  && h->oh->is_func_descriptor
+	  && (h->oh->elf.root.type == bfd_link_hash_defined
+	      || h->oh->elf.root.type == bfd_link_hash_defweak))
 	htab->tls_get_addr_fd = h->oh;
     }
 

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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