This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
gold patch committed: Add --warn-unresolved-symbols
- From: Ian Lance Taylor <iant at google dot com>
- To: binutils at sourceware dot org
- Date: Thu, 07 Jan 2010 10:32:24 -0800
- Subject: gold patch committed: Add --warn-unresolved-symbols
I committed this patch to gold to add the --warn-unresolved-symbols
option, as well as --error-unresolved-symbols which restores the
default behaviour.
Ian
2010-01-07 Ian Lance Taylor <iant@google.com>
PR 10980
* options.h (class General_options): Add --warn-unresolved-symbols
and --error-unresolved-symbols.
* errors.cc (Errors::undefined_symbol): Implement
--warn-unresolved-symbols.
Index: errors.cc
===================================================================
RCS file: /cvs/src/src/gold/errors.cc,v
retrieving revision 1.11
diff -p -u -r1.11 errors.cc
--- errors.cc 14 Dec 2009 19:53:04 -0000 1.11
+++ errors.cc 7 Jan 2010 18:30:55 -0000
@@ -1,6 +1,6 @@
// errors.cc -- handle errors for gold
-// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
@@ -156,21 +156,33 @@ Errors::undefined_symbol(const Symbol* s
{
bool initialized = this->initialize_lock();
gold_assert(initialized);
+
+ const char* zmsg;
{
Hold_lock h(*this->lock_);
if (++this->undefined_symbols_[sym] >= max_undefined_error_report)
return;
- ++this->error_count_;
+ if (parameters->options().warn_unresolved_symbols())
+ {
+ ++this->warning_count_;
+ zmsg = _("warning");
+ }
+ else
+ {
+ ++this->error_count_;
+ zmsg = _("error");
+ }
}
+
const char* const version = sym->version();
if (version == NULL)
- fprintf(stderr, _("%s: %s: error: undefined reference to '%s'\n"),
- this->program_name_, location.c_str(),
+ fprintf(stderr, _("%s: %s: %s: undefined reference to '%s'\n"),
+ this->program_name_, location.c_str(), zmsg,
sym->demangled_name().c_str());
else
fprintf(stderr,
- _("%s: %s: error: undefined reference to '%s', version '%s'\n"),
- this->program_name_, location.c_str(),
+ _("%s: %s: %s: undefined reference to '%s', version '%s'\n"),
+ this->program_name_, location.c_str(), zmsg,
sym->demangled_name().c_str(), version);
}
Index: options.h
===================================================================
RCS file: /cvs/src/src/gold/options.h,v
retrieving revision 1.135
diff -p -u -r1.135 options.h
--- options.h 7 Jan 2010 18:16:24 -0000 1.135
+++ options.h 7 Jan 2010 18:30:55 -0000
@@ -972,6 +972,14 @@ class General_options
N_("Warn if text segment is not shareable"),
N_("Do not warn if text segment is not shareable (default)"));
+ DEFINE_bool(warn_unresolved_symbols, options::TWO_DASHES, '\0', false,
+ N_("Report unresolved symbols as warnings"),
+ NULL);
+ DEFINE_bool_alias(error_unresolved_symbols, warn_unresolved_symbols,
+ options::TWO_DASHES, '\0',
+ N_("Report unresolved symbols as errors"),
+ NULL, true);
+
DEFINE_bool(whole_archive, options::TWO_DASHES, '\0', false,
N_("Include all archive contents"),
N_("Include only needed archive contents"));