aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2012-10-22 13:33:48 +0000
committerAlan Modra <amodra@bigpond.net.au>2012-10-22 13:33:48 +0000
commit43874b12f02b381690e718a21fa7c61dd2801db7 (patch)
tree26338b97fab45b883e5e2ca08869ab30bcb02a96
parent5a7c20332184a69689bbbe24d84d0197b7377eb4 (diff)
downloadbinutils-43874b12f02b381690e718a21fa7c61dd2801db7.tar.gz
include/
PR ld/14426 * bfdlink.h (bfd_link_info): Add ignore_hash. ld/ 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.
-rw-r--r--include/ChangeLog5
-rw-r--r--include/bfdlink.h4
-rw-r--r--ld/ChangeLog13
-rw-r--r--ld/ldlex.h1
-rw-r--r--ld/ldmain.c46
-rw-r--r--ld/ldmain.h1
-rw-r--r--ld/lexsup.c7
7 files changed, 57 insertions, 20 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index e702ebe61..a731efb52 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-22 Jan Beich <jbeich@tormail.org>
+
+ PR ld/14426
+ * bfdlink.h (bfd_link_info): Add ignore_hash.
+
2012-10-08 Jason Merrill <jason@redhat.com>
* demangle.h (enum demangle_component_type): Add
diff --git a/include/bfdlink.h b/include/bfdlink.h
index d900b4783..aaac24495 100644
--- a/include/bfdlink.h
+++ b/include/bfdlink.h
@@ -435,6 +435,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 output BFD. */
bfd *output_bfd;
diff --git a/ld/ChangeLog b/ld/ChangeLog
index e16bf3d55..e390c9e6d 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,16 @@
+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.
diff --git a/ld/ldlex.h b/ld/ldlex.h
index 5e3d2fcf8..441f673ae 100644
--- a/ld/ldlex.h
+++ b/ld/ldlex.h
@@ -135,6 +135,7 @@ enum option_values
#endif /* ENABLE_PLUGINS */
OPTION_DEFAULT_SCRIPT,
OPTION_PRINT_OUTPUT_FORMAT,
+ OPTION_IGNORE_UNRESOLVED_SYMBOL,
};
/* The initial parser states. */
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 15f8ebf20..a784670ad 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -643,6 +643,23 @@ add_ysym (const char *name)
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
@@ -1091,7 +1108,7 @@ constructor_callback (struct bfd_link_info *info,
/* 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"));
@@ -1228,7 +1245,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,
@@ -1240,25 +1257,14 @@ 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)
- {
- 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
@@ -1336,7 +1342,7 @@ int overflow_cutoff_limit = 10;
/* 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,
@@ -1375,7 +1381,7 @@ reloc_overflow (struct bfd_link_info *info ATTRIBUTE_UNUSED,
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 ();
diff --git a/ld/ldmain.h b/ld/ldmain.h
index 83638339c..4d6bb0400 100644
--- a/ld/ldmain.h
+++ b/ld/ldmain.h
@@ -41,6 +41,7 @@ extern int overflow_cutoff_limit;
extern void add_ysym (const char *);
extern void add_wrap (const char *);
+extern void add_ignoresym (struct bfd_link_info *, const char *);
extern void add_keepsyms_file (const char *);
#endif
diff --git a/ld/lexsup.c b/ld/lexsup.c
index fc410c9e3..c6baebe88 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -496,6 +496,10 @@ static const struct ld_option ld_options[] =
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)
@@ -1341,6 +1345,9 @@ parse_args (unsigned argc, char **argv)
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;