Add support for --ignore-unresolved-symbol
This commit is contained in:
parent
16304febf2
commit
2c2b152b21
|
@ -369,6 +369,10 @@ struct bfd_link_info
|
|||
option). If this is NULL, no symbols are being wrapped. */
|
||||
struct bfd_hash_table *wrap_hash;
|
||||
|
||||
/* Hash table of symbols which may be left unresolved during
|
||||
a link. If this is NULL, no symbols can be left unresolved. */
|
||||
struct bfd_hash_table *ignore_hash;
|
||||
|
||||
/* The list of input BFD's involved in the link. These are chained
|
||||
together via the link_next field. */
|
||||
bfd *input_bfds;
|
||||
|
|
|
@ -297,6 +297,7 @@ main (int argc, char **argv)
|
|||
link_info.keep_hash = NULL;
|
||||
link_info.notice_hash = NULL;
|
||||
link_info.wrap_hash = NULL;
|
||||
link_info.ignore_hash = NULL;
|
||||
link_info.input_bfds = NULL;
|
||||
link_info.create_object_symbols_section = NULL;
|
||||
link_info.gc_sym_list = NULL;
|
||||
|
@ -781,6 +782,22 @@ add_ysym (const char *name)
|
|||
einfo (_("%P%F: bfd_hash_lookup failed: %E\n"));
|
||||
}
|
||||
|
||||
void
|
||||
add_ignoresym (const char *name)
|
||||
{
|
||||
if (link_info.ignore_hash == NULL)
|
||||
{
|
||||
link_info.ignore_hash = xmalloc (sizeof (struct bfd_hash_table));
|
||||
if (! bfd_hash_table_init_n (link_info.ignore_hash,
|
||||
bfd_hash_newfunc,
|
||||
61))
|
||||
einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
|
||||
}
|
||||
|
||||
if (bfd_hash_lookup (link_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
|
||||
|
@ -1300,7 +1317,7 @@ warning_find_reloc (bfd *abfd, asection *sec, void *iarg)
|
|||
/* 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,
|
||||
|
@ -1312,22 +1329,24 @@ undefined_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED,
|
|||
|
||||
#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)
|
||||
if (info->ignore_hash == NULL)
|
||||
{
|
||||
hash = xmalloc (sizeof (struct bfd_hash_table));
|
||||
if (! bfd_hash_table_init (hash, bfd_hash_newfunc))
|
||||
info->ignore_hash = xmalloc (sizeof (struct bfd_hash_table));
|
||||
if (! bfd_hash_table_init (info->ignore_hash, bfd_hash_newfunc))
|
||||
einfo (_("%F%P: bfd_hash_table_init failed: %E\n"));
|
||||
}
|
||||
|
||||
if (bfd_hash_lookup (hash, name, FALSE, FALSE) != NULL)
|
||||
if (bfd_hash_lookup (info->ignore_hash, name, FALSE, FALSE) != NULL)
|
||||
return TRUE;
|
||||
|
||||
if (bfd_hash_lookup (hash, name, TRUE, TRUE) == NULL)
|
||||
if (bfd_hash_lookup (info->ignore_hash, name, TRUE, TRUE) == NULL)
|
||||
einfo (_("%F%P: bfd_hash_lookup failed: %E\n"));
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ extern int overflow_cutoff_limit;
|
|||
|
||||
extern void add_ysym (const char *);
|
||||
extern void add_wrap (const char *);
|
||||
extern void add_ignoresym (const char *);
|
||||
extern void add_keepsyms_file (const char *);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -152,7 +152,8 @@ enum option_values
|
|||
OPTION_WARN_UNRESOLVED_SYMBOLS,
|
||||
OPTION_ERROR_UNRESOLVED_SYMBOLS,
|
||||
OPTION_WARN_SHARED_TEXTREL,
|
||||
OPTION_REDUCE_MEMORY_OVERHEADS
|
||||
OPTION_REDUCE_MEMORY_OVERHEADS,
|
||||
OPTION_IGNORE_UNRESOLVED_SYMBOL
|
||||
};
|
||||
|
||||
/* The long options. This structure is used for both the option
|
||||
|
@ -520,6 +521,10 @@ static const struct ld_option ld_options[] =
|
|||
'\0', NULL, NULL, TWO_DASHES }, /* NetBSD. */
|
||||
{ {"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)
|
||||
|
@ -1262,6 +1267,9 @@ parse_args (unsigned argc, char **argv)
|
|||
case OPTION_WRAP:
|
||||
add_wrap (optarg);
|
||||
break;
|
||||
case OPTION_IGNORE_UNRESOLVED_SYMBOL:
|
||||
add_ignoresym (optarg);
|
||||
break;
|
||||
case OPTION_DISCARD_NONE:
|
||||
link_info.discard = discard_none;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue