]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR gold/12386
authorIan Lance Taylor <ian@airs.com>
Sat, 9 Jul 2011 06:11:34 +0000 (06:11 +0000)
committerIan Lance Taylor <ian@airs.com>
Sat, 9 Jul 2011 06:11:34 +0000 (06:11 +0000)
* options.h (class General_options): Add --unresolved-symbols.
* target-reloc.h (issue_undefined_symbol_error): Check
--unresolved-symbols.  Add comments.

gold/ChangeLog
gold/options.h
gold/target-reloc.h

index c8e21255cbc7cc36a721ac9fc917db4fffd1cc4b..eabc91d7672574a52d6ff18cb3f8f3d5a28c3056 100644 (file)
@@ -1,3 +1,10 @@
+2011-07-08  Ian Lance Taylor  <iant@google.com>
+
+       PR gold/12386
+       * options.h (class General_options): Add --unresolved-symbols.
+       * target-reloc.h (issue_undefined_symbol_error): Check
+       --unresolved-symbols.  Add comments.
+
 2011-07-08  Ian Lance Taylor  <iant@google.com>
 
        * testsuite/odr_violation2.cc (Ordering::operator()): Make
index 230900ab21dcebcd6556ec24efd508e3a7ae8cd1..817d0f00573e4385fba7cbf884135bbb3fae9cc2 100644 (file)
@@ -1069,6 +1069,13 @@ class General_options
   DEFINE_set(undefined, options::TWO_DASHES, 'u',
             N_("Create undefined reference to SYMBOL"), N_("SYMBOL"));
 
+  DEFINE_enum(unresolved_symbols, options::TWO_DASHES, '\0', NULL,
+             N_("How to handle unresolved symbols"),
+             ("ignore-all,report-all,ignore-in-object-files,"
+              "ignore-in-shared-libs"),
+             {"ignore-all", "report-all", "ignore-in-object-files",
+                 "ignore-in-shared-libs"});
+
   DEFINE_bool(verbose, options::TWO_DASHES, '\0', false,
               N_("Synonym for --debug=files"), NULL);
 
index fabc0a9f9186e4a0df1256da4796506782e704f3..87fa593d12a43d8db0d1abb29d305bd6aa1f691a 100644 (file)
@@ -176,13 +176,46 @@ visibility_error(const Symbol* sym)
 inline bool
 issue_undefined_symbol_error(const Symbol* sym)
 {
-  return (sym != NULL
-         && (sym->is_undefined() || sym->is_placeholder())
-         && sym->binding() != elfcpp::STB_WEAK
-         && !sym->is_defined_in_discarded_section()
-         && !parameters->target().is_defined_by_abi(sym)
-         && (!parameters->options().shared()
-             || parameters->options().defs()));
+  // We only report global symbols.
+  if (sym == NULL)
+    return false;
+
+  // We only report undefined symbols.
+  if (!sym->is_undefined() && !sym->is_placeholder())
+    return false;
+
+  // We don't report weak symbols.
+  if (sym->binding() == elfcpp::STB_WEAK)
+    return false;
+
+  // We don't report symbols defined in discarded sections.
+  if (sym->is_defined_in_discarded_section())
+    return false;
+
+  // If the target defines this symbol, don't report it here.
+  if (parameters->target().is_defined_by_abi(sym))
+    return false;
+
+  // See if we've been told to ignore whether this symbol is
+  // undefined.
+  const char* const u = parameters->options().unresolved_symbols();
+  if (u != NULL)
+    {
+      if (strcmp(u, "ignore-all") == 0)
+       return false;
+      if (strcmp(u, "ignore-in-object-files") == 0 && !sym->in_dyn())
+       return false;
+      if (strcmp(u, "ignore-in-shared-libs") == 0 && !sym->in_reg())
+       return false;
+    }
+
+  // When creating a shared library, only report unresolved symbols if
+  // -z defs was used.
+  if (parameters->options().shared() && !parameters->options().defs())
+    return false;
+
+  // Otherwise issue a warning.
+  return true;
 }
 
 // This function implements the generic part of relocation processing.