This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
gold patch committed: Fix some minor usage issues
- From: Ian Lance Taylor <iant at google dot com>
- To: binutils at sourceware dot org
- Date: Tue, 23 Jun 2009 22:02:30 -0700
- Subject: gold patch committed: Fix some minor usage issues
PR 10237 reports that gold gets an internal error if -r is used with a
shared library, and that gold reports an error if invoked with -V and no
input files. I committed this patch to fix those cases.
Ian
2009-06-23 Ian Lance Taylor <iant@google.com>
PR 10237
* options.cc (General_options::parse_V): Set printed_version_.
(General_options::General_options): Initialize printed_version_.
* options.h (class General_options): Add printed_version_ field.
* gold.cc (queue_initial_tasks): If there are no input files,
don't give a fatal error if we printed the version information.
(queue_middle_tasks): If using -r with a shared object, give a
fatal error rather than an ordinary error.
Index: gold.cc
===================================================================
RCS file: /cvs/src/src/gold/gold.cc,v
retrieving revision 1.63
diff -p -u -r1.63 gold.cc
--- gold.cc 14 Mar 2009 05:56:46 -0000 1.63
+++ gold.cc 24 Jun 2009 04:40:46 -0000
@@ -164,7 +164,11 @@ queue_initial_tasks(const General_option
Symbol_table* symtab, Layout* layout, Mapfile* mapfile)
{
if (cmdline.begin() == cmdline.end())
- gold_fatal(_("no input files"));
+ {
+ if (options.printed_version())
+ gold_exit(true);
+ gold_fatal(_("no input files"));
+ }
int thread_count = options.thread_count_initial();
if (thread_count == 0)
@@ -364,7 +368,7 @@ queue_middle_tasks(const General_options
(*input_objects->dynobj_begin())->name().c_str());
}
if (!doing_static_link && parameters->options().relocatable())
- gold_error(_("cannot mix -r with dynamic object %s"),
+ gold_fatal(_("cannot mix -r with dynamic object %s"),
(*input_objects->dynobj_begin())->name().c_str());
if (!doing_static_link
&& options.oformat_enum() != General_options::OBJECT_FORMAT_ELF)
Index: options.cc
===================================================================
RCS file: /cvs/src/src/gold/options.cc,v
retrieving revision 1.87
diff -p -u -r1.87 options.cc
--- options.cc 23 Jun 2009 06:39:46 -0000 1.87
+++ options.cc 24 Jun 2009 04:40:46 -0000
@@ -273,6 +273,7 @@ void
General_options::parse_V(const char*, const char*, Command_line*)
{
gold::print_version(true);
+ this->printed_version_ = true;
printf(_(" Supported targets:\n"));
std::vector<const char*> supported_names;
gold::supported_target_names(&supported_names);
@@ -708,7 +709,8 @@ namespace gold
{
General_options::General_options()
- : execstack_status_(General_options::EXECSTACK_FROM_INPUT), static_(false),
+ : printed_version_(false),
+ execstack_status_(General_options::EXECSTACK_FROM_INPUT), static_(false),
do_demangle_(false), plugins_(),
incremental_disposition_(INCREMENTAL_CHECK), implicit_incremental_(false)
{
Index: options.h
===================================================================
RCS file: /cvs/src/src/gold/options.h,v
retrieving revision 1.101
diff -p -u -r1.101 options.h
--- options.h 23 Jun 2009 06:39:47 -0000 1.101
+++ options.h 24 Jun 2009 04:40:46 -0000
@@ -946,6 +946,11 @@ class General_options
// any problems.
void finalize();
+ // True if we printed the version information.
+ bool
+ printed_version() const
+ { return this->printed_version_; }
+
// The macro defines output() (based on --output), but that's a
// generic name. Provide this alternative name, which is clearer.
const char*
@@ -1090,6 +1095,8 @@ class General_options
void
add_plugin_option(const char* opt);
+ // Whether we printed version information.
+ bool printed_version_;
// Whether to mark the stack as executable.
Execstack execstack_status_;
// Whether to do a static link.
@@ -1106,7 +1113,7 @@ class General_options
// --incremental-unchanged or --incremental-unknown option. The
// value may change as we proceed parsing the command line flags.
Incremental_disposition incremental_disposition_;
- // Wheater we have seen one of the options that require incremental
+ // Whether we have seen one of the options that require incremental
// build (--incremental-changed, --incremental-unchanged or
// --incremental-unknown)
bool implicit_incremental_;