Don't ignore "-m emulation" command line option
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 16 Oct 2015 15:04:58 +0000 (08:04 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 16 Oct 2015 15:05:09 +0000 (08:05 -0700)
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".

gold/ChangeLog
gold/options.h
gold/parameters.cc

index ff11c8890a07d974525ab537db70af3fe846b79e..1f619f73efb34b6468e6e669d2ce9c87d86b6e39 100644 (file)
@@ -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
index 641efee3a37fddec971eaaf626884ecd70e6050e..4d6522572c7f0d51ed8f577ee962de8fa535821e 100644 (file)
@@ -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)."),
index 5ed191225122a40608921c30be431c2920b1877a..15df42afc9b4ba558ce143718ee43baebf35fd8b 100644 (file)
@@ -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);
 }