From 12ac1cf5374e06e54207ad961bcd4b721d5843b5 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 23 Dec 2005 12:29:36 +0000 Subject: [PATCH] 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. --- bfd/ChangeLog | 15 +++++++++++++++ bfd/elf-bfd.h | 5 +++++ bfd/elflink.c | 42 ++++++++++++++++++++++++++---------------- bfd/elfxx-mips.c | 8 ++++++++ bfd/elfxx-mips.h | 3 +++ bfd/elfxx-target.h | 4 ++++ 6 files changed, 61 insertions(+), 16 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a7efbca08b..521d51b88f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,18 @@ +2005-12-23 Michael Weiser + + 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 * corefile.c (generic_core_file_matches_executable_p): New function. diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index f957283e1d..18ccdb5752 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -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) diff --git a/bfd/elflink.c b/bfd/elflink.c index 127f002bed..a065dca83e 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -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; + } } } diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index af8f3c7947..6849048717 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -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; +} diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h index 3af342a230..07e661d81c 100644 --- a/bfd/elfxx-mips.h +++ b/bfd/elfxx-mips.h @@ -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 diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 2c9aa197db..d8a15cf46f 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -420,6 +420,9 @@ #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, -- 2.34.1