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]

PATCH: PR ld/13229: V2 of getsymbol linker plugin interface is not supported by GNU LD


When a plugin symbol is optimized out by linker plugin, we shouldn't
put it in symbol table for non-relocatable link.  OK for trunk?

Thanks.

H.J.
---
2011-10-07  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13229
	PR ld/13244
	* elflink.c (elf_link_output_extsym): Don't output any plugin
	symbols for non-relocatable link.

diff --git a/bfd/elflink.c b/bfd/elflink.c
index 7120aad..e04cb7c 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -8580,6 +8580,7 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
   const struct elf_backend_data *bed;
   long indx;
   int ret;
+  bfd *sym_bfd; 
 
   if (h->root.type == bfd_link_hash_warning)
     {
@@ -8667,8 +8668,18 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
   /* We don't want to output symbols that have never been mentioned by
      a regular file, or that we have been told to strip.  However, if
      h->indx is set to -2, the symbol is used by a reloc and we must
-     output it.  */
-  if (h->indx == -2)
+     output it.  Don't output any plugin symbols for non-relocatable
+     link.  */
+  if (!finfo->info->relocatable
+      && ((((h->root.type == bfd_link_hash_defweak
+	     || h->root.type == bfd_link_hash_defined)
+	    && (sym_bfd = h->root.u.def.section->owner) != NULL)
+	   || ((h->root.type == bfd_link_hash_undefined
+		|| h->root.type == bfd_link_hash_undefweak)
+	       && (sym_bfd = h->root.u.undef.abfd) != NULL))
+	  && (sym_bfd->flags & BFD_PLUGIN) != 0))
+    return TRUE;
+  else if (h->indx == -2)
     strip = FALSE;
   else if ((h->def_dynamic
 	    || h->ref_dynamic
@@ -8687,11 +8698,6 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
 	       || h->root.type == bfd_link_hash_defweak)
 	   && elf_discarded_section (h->root.u.def.section))
     strip = TRUE;
-  else if ((h->root.type == bfd_link_hash_undefined
-	    || h->root.type == bfd_link_hash_undefweak)
-	   && h->root.u.undef.abfd != NULL
-	   && (h->root.u.undef.abfd->flags & BFD_PLUGIN) != 0)
-    strip = TRUE;
   else
     strip = FALSE;
 


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