OSDN Git Service

PR 1150
authornickc <nickc>
Fri, 23 Dec 2005 12:29:35 +0000 (12:29 +0000)
committernickc <nickc>
Fri, 23 Dec 2005 12:29:35 +0000 (12:29 +0000)
* elf-bfd.h (struct elf_backend_data): New field 'elf_backend_ignore_undef_symbol'.
* elfxx-target.h (elf_backend_ignore_undef_symbol): Define to NULL if not
  already defined.
  (elfNN_bed): Initialise the elf_backend_ignore_undef_symbol field.
* elfxx-mips.c (_bfd_mips_elf_ignore_undef_symbol): New function.
* elfxx-mips.h (elf_backend_ignore_undef_symbol): Define and prototype.
* elflink.c (elf_link_output_extsym): Check elf_backend_ignore_undef_symbol
  before reporting an undefined symbol in a shared library.

bfd/ChangeLog
bfd/elf-bfd.h
bfd/elflink.c
bfd/elfxx-mips.c
bfd/elfxx-mips.h
bfd/elfxx-target.h

index a7efbca..521d51b 100644 (file)
@@ -1,3 +1,18 @@
+2005-12-23  Michael Weiser  <michael@weiser.dinsnail.net>
+
+       PR 1150
+       * elf-bfd.h (struct elf_backend_data): New field
+       'elf_backend_ignore_undef_symbol'.
+       * elfxx-target.h (elf_backend_ignore_undef_symbol): Define to NULL
+       if not already defined.
+       (elfNN_bed): Initialise the elf_backend_ignore_undef_symbol field.
+       * elfxx-mips.c (_bfd_mips_elf_ignore_undef_symbol): New function.
+       * elfxx-mips.h (elf_backend_ignore_undef_symbol): Define and
+       prototype.
+       * elflink.c (elf_link_output_extsym): Check
+       elf_backend_ignore_undef_symbol before reporting an undefined
+       symbol in a shared library.
+
 2005-12-23  Joel Brobecker  <brobecker@adacore.com>
 
        * corefile.c (generic_core_file_matches_executable_p): New function.
index f957283..18ccdb5 100644 (file)
@@ -883,6 +883,11 @@ struct elf_backend_data
     (struct elf_link_hash_entry *, const Elf_Internal_Sym *, bfd_boolean,
      bfd_boolean);
 
+  /* Decide whether an undefined symbol is special and can be ignored.
+     This is the case for OPTIONAL symbols on IRIX.  */
+  bfd_boolean (*elf_backend_ignore_undef_symbol)
+    (struct elf_link_hash_entry *);
+
   /* Emit relocations.  Overrides default routine for emitting relocs,
      except during a relocatable link, or if all relocs are being emitted.  */
   bfd_boolean (*elf_backend_emit_relocs)
index 127f002..a065dca 100644 (file)
@@ -6346,22 +6346,32 @@ elf_link_output_extsym (struct elf_link_hash_entry *h, void *data)
 
   bed = get_elf_backend_data (finfo->output_bfd);
 
-  /* If we have an undefined symbol reference here then it must have
-     come from a shared library that is being linked in.  (Undefined
-     references in regular files have already been handled).  If we
-     are reporting errors for this situation then do so now.  */
-  if (h->root.type == bfd_link_hash_undefined
-      && h->ref_dynamic
-      && !h->ref_regular
-      && ! elf_link_check_versioned_symbol (finfo->info, bed, h)
-      && finfo->info->unresolved_syms_in_shared_libs != RM_IGNORE)
-    {
-      if (! ((*finfo->info->callbacks->undefined_symbol)
-            (finfo->info, h->root.root.string, h->root.u.undef.abfd,
-             NULL, 0, finfo->info->unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)))
-       {
-         eoinfo->failed = TRUE;
-         return FALSE;
+  if (h->root.type == bfd_link_hash_undefined)
+    {
+      /* If we have an undefined symbol reference here then it must have
+        come from a shared library that is being linked in.  (Undefined
+        references in regular files have already been handled).  */
+      bfd_boolean ignore_undef = FALSE;
+
+      /* Some symbols may be special in that the fact that they're
+        undefined can be safely ignored - let backend determine that.  */
+      if (bed->elf_backend_ignore_undef_symbol)
+       ignore_undef = bed->elf_backend_ignore_undef_symbol (h);
+
+      /* If we are reporting errors for this situation then do so now.  */
+      if (ignore_undef == FALSE
+         && h->ref_dynamic
+         && ! h->ref_regular
+         && ! elf_link_check_versioned_symbol (finfo->info, bed, h)
+         && finfo->info->unresolved_syms_in_shared_libs != RM_IGNORE)
+       {
+         if (! (finfo->info->callbacks->undefined_symbol
+                (finfo->info, h->root.root.string, h->root.u.undef.abfd,
+                 NULL, 0, finfo->info->unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)))
+           {
+             eoinfo->failed = TRUE;
+             return FALSE;
+           }
        }
     }
 
index af8f3c7..6849048 100644 (file)
@@ -10012,3 +10012,11 @@ _bfd_mips_elf_merge_symbol_attribute (struct elf_link_hash_entry *h,
       && ELF_MIPS_IS_OPTIONAL (isym->st_other))
     h->other |= STO_OPTIONAL;
 }
+
+/* Decide whether an undefined symbol is special and can be ignored.
+   This is the case for OPTIONAL symbols on IRIX.  */
+bfd_boolean
+_bfd_mips_elf_ignore_undef_symbol (struct elf_link_hash_entry *h)
+{
+  return ELF_MIPS_IS_OPTIONAL (h->other) ? TRUE : FALSE;
+}
index 3af342a..07e661d 100644 (file)
@@ -129,6 +129,8 @@ extern bfd_vma _bfd_mips_elf_sign_extend
   (bfd_vma, int);
 extern void _bfd_mips_elf_merge_symbol_attribute
   (struct elf_link_hash_entry *, const Elf_Internal_Sym *, bfd_boolean, bfd_boolean);
+extern bfd_boolean _bfd_mips_elf_ignore_undef_symbol
+  (struct elf_link_hash_entry *);
 
 extern const struct bfd_elf_special_section _bfd_mips_elf_special_sections [];
 
@@ -137,3 +139,4 @@ extern const struct bfd_elf_special_section _bfd_mips_elf_special_sections [];
 #define elf_backend_special_sections _bfd_mips_elf_special_sections
 #define elf_backend_eh_frame_address_size _bfd_mips_elf_eh_frame_address_size
 #define elf_backend_merge_symbol_attribute  _bfd_mips_elf_merge_symbol_attribute
+#define elf_backend_ignore_undef_symbol _bfd_mips_elf_ignore_undef_symbol
index 2c9aa19..d8a15cf 100644 (file)
 #ifndef elf_backend_merge_symbol_attribute
 #define elf_backend_merge_symbol_attribute     NULL
 #endif
+#ifndef elf_backend_ignore_undef_symbol
+#define elf_backend_ignore_undef_symbol                NULL
+#endif
 #ifndef elf_backend_emit_relocs
 #define elf_backend_emit_relocs                        _bfd_elf_link_output_relocs
 #endif
@@ -592,6 +595,7 @@ static const struct elf_backend_data elfNN_bed =
   elf_backend_copy_indirect_symbol,
   elf_backend_hide_symbol,
   elf_backend_merge_symbol_attribute,
+  elf_backend_ignore_undef_symbol,
   elf_backend_emit_relocs,
   elf_backend_count_relocs,
   elf_backend_grok_prstatus,