+2012-10-22 Jan Beich <jbeich@tormail.org>
+ Alan Modra <amodra@gmail.com>
+
+ PR ld/14426
+ * ldlex.h (option_values): Add OPTION_IGNORE_UNRESOLVED_SYMBOL.
+ * lexsup.c (parse_args): Likewise.
+ (ld_options): Describe --ignore-unresolved-symbol.
+ * ldmain.h (add_ignoresym): Declare.
+ * ldmain.c (add_ignoresym): New function, extracted from..
+ (undefined_symbol): ..here. Return if the symbol is in ignore_hash.
+ (constructor_callback): Don't use global link_info here.
+ (reloc_overflow): Likewise.
+
2012-10-22 Alan Modra <amodra@gmail.com>
* plugin.c (plugin_load_plugins): Warning fix.
einfo (_("%P%F: bfd_hash_lookup failed: %E\n"));
}
+void
+add_ignoresym (struct bfd_link_info *info, const char *name)
+{
+ if (info->ignore_hash == NULL)
+ {
+ info->ignore_hash = xmalloc (sizeof (struct bfd_hash_table));
+ if (! bfd_hash_table_init_n (info->ignore_hash,
+ bfd_hash_newfunc,
+ sizeof (struct bfd_hash_entry),
+ 61))
+ einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
+ }
+
+ if (bfd_hash_lookup (info->ignore_hash, name, TRUE, TRUE) == NULL)
+ einfo (_("%P%F: bfd_hash_lookup failed: %E\n"));
+}
+
/* Record a symbol to be wrapped, from the --wrap option. */
void
/* Ensure that BFD_RELOC_CTOR exists now, so that we can give a
useful error message. */
- if (bfd_reloc_type_lookup (link_info.output_bfd, BFD_RELOC_CTOR) == NULL
+ if (bfd_reloc_type_lookup (info->output_bfd, BFD_RELOC_CTOR) == NULL
&& (info->relocatable
|| bfd_reloc_type_lookup (abfd, BFD_RELOC_CTOR) == NULL))
einfo (_("%P%F: BFD backend error: BFD_RELOC_CTOR unsupported\n"));
/* This is called when an undefined symbol is found. */
static bfd_boolean
-undefined_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED,
+undefined_symbol (struct bfd_link_info *info,
const char *name,
bfd *abfd,
asection *section,
#define MAX_ERRORS_IN_A_ROW 5
+ if (info->ignore_hash != NULL
+ && bfd_hash_lookup (info->ignore_hash, name, FALSE, FALSE) != NULL)
+ return TRUE;
+
if (config.warn_once)
{
- static struct bfd_hash_table *hash;
-
/* Only warn once about a particular undefined symbol. */
- if (hash == NULL)
- {
- hash = (struct bfd_hash_table *)
- xmalloc (sizeof (struct bfd_hash_table));
- if (!bfd_hash_table_init (hash, bfd_hash_newfunc,
- sizeof (struct bfd_hash_entry)))
- einfo (_("%F%P: bfd_hash_table_init failed: %E\n"));
- }
-
- if (bfd_hash_lookup (hash, name, FALSE, FALSE) != NULL)
- return TRUE;
-
- if (bfd_hash_lookup (hash, name, TRUE, TRUE) == NULL)
- einfo (_("%F%P: bfd_hash_lookup failed: %E\n"));
+ add_ignoresym (info, name);
}
/* We never print more than a reasonable number of errors in a row
/* This is called when a reloc overflows. */
static bfd_boolean
-reloc_overflow (struct bfd_link_info *info ATTRIBUTE_UNUSED,
+reloc_overflow (struct bfd_link_info *info,
struct bfd_link_hash_entry *entry,
const char *name,
const char *reloc_name,
reloc_name, entry->root.string,
entry->u.def.section,
entry->u.def.section == bfd_abs_section_ptr
- ? link_info.output_bfd : entry->u.def.section->owner);
+ ? info->output_bfd : entry->u.def.section->owner);
break;
default:
abort ();
TWO_DASHES },
{ {"wrap", required_argument, NULL, OPTION_WRAP},
'\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES },
+ { {"ignore-unresolved-symbol", required_argument, NULL,
+ OPTION_IGNORE_UNRESOLVED_SYMBOL},
+ '\0', N_("SYMBOL"),
+ N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES },
};
#define OPTION_COUNT ARRAY_SIZE (ld_options)
case OPTION_WRAP:
add_wrap (optarg);
break;
+ case OPTION_IGNORE_UNRESOLVED_SYMBOL:
+ add_ignoresym (&link_info, optarg);
+ break;
case OPTION_DISCARD_NONE:
link_info.discard = discard_none;
break;