This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Don't ignore "-m emulation" command line option
- From: H.J.Lu <hjl at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 16 Oct 2015 15:08:44 -0000
- Subject: [binutils-gdb] Don't ignore "-m emulation" command line option
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6457197210144f50a696097c0d308d81d46d5510
commit 6457197210144f50a696097c0d308d81d46d5510
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Fri Oct 16 08:04:58 2015 -0700
Don't ignore "-m emulation" command line option
Gold shouldn't ignore "-m emulation" command line option, which may
lead to incorrect output.
PR gold/19119
* options.h (General_options): Remove "obsolete" from -m.
* parameters.cc (set_parameters_target): Check if input target
is compatible with output emulation set by "-m emulation".
Diff:
---
gold/ChangeLog | 7 +++++++
gold/options.h | 2 +-
gold/parameters.cc | 10 ++++++++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/gold/ChangeLog b/gold/ChangeLog
index ff11c88..1f619f7 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,10 @@
+2015-10-16 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR gold/19119
+ * options.h (General_options): Remove "obsolete" from -m.
+ * parameters.cc (set_parameters_target): Check if input target
+ is compatible with output emulation set by "-m emulation".
+
2015-10-13 H.J. Lu <hongjiu.lu@intel.com>
PR gold/19118
diff --git a/gold/options.h b/gold/options.h
index 641efee..4d65225 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -934,7 +934,7 @@ class General_options
N_("OFFSET"));
DEFINE_string(m, options::EXACTLY_ONE_DASH, 'm', "",
- N_("Set GNU linker emulation; obsolete"), N_("EMULATION"));
+ N_("Set GNU linker emulation"), N_("EMULATION"));
DEFINE_bool(mmap_output_file, options::TWO_DASHES, '\0', true,
N_("Map the output file for writing (default)."),
diff --git a/gold/parameters.cc b/gold/parameters.cc
index 5ed1912..15df42a 100644
--- a/gold/parameters.cc
+++ b/gold/parameters.cc
@@ -297,6 +297,16 @@ set_parameters_options(const General_options* options)
void
set_parameters_target(Target* target)
{
+ if (parameters->options_valid() && parameters->options().user_set_m())
+ {
+ const char* emulation = parameters->options().m();
+ Target* output = select_target_by_emulation(emulation);
+ if (!output)
+ gold_error(_("unrecognised output emulation: %s"), emulation);
+ else if (output != target)
+ gold_error(_("input file is incompatible with %s output emulation"),
+ emulation);
+ }
static_parameters.set_target(target);
}