The new mips gas breaks gcc 2.96

H. J. Lu hjl@lucon.org
Thu Aug 1 19:39:00 GMT 2002


On Thu, Aug 01, 2002 at 04:44:51PM -0700, Eric Christopher wrote:
> 
> > > Yup. Also, the gcc steering committee has said that march/mtune will be
> > > TheWay(tm).
> > > 
> > 
> > I have no plan to change all the scripts which use -mcpu. As I said,
> > I will change my Linux binutils so that at least it will take -mcpu.
> 
> Have fun. I gave warning and a warning message about this.
> 

FYI, this is what I use.


H.J.
-------------- next part --------------
2002-08-01  H.J. Lu <hjl@gnu.org>

	* config/tc-mips.c (OPTION_MCPU): Put it back.
	(md_parse_option): Handle OPTION_MCPU.
	(mips_after_parse_args): Don't change anything.

2002-07-26  H.J. Lu <hjl@gnu.org>

	* config/tc-mips.c (mips_after_parse_args): Updated.

2002-04-04  H.J. Lu <hjl@gnu.org>

	* elf32-mips.c: Move all changes to ...
	* elfxx-mips.c: Here.

2001-10-26  H.J. Lu <hjl@gnu.org>

	* elf32-mips.c: Include "opcode/mips.h".
	(bfd_mips_elf_set_isa): New function. Set the EF_MIPS_ARCH
	field in the ELF header.
	(_bfd_mips_elf_final_write_processing): Set the EF_MIPS_ARCH
	field only if it is unset.

2002-06-06  H.J. Lu <hjl@gnu.org>

	* config/tc-mips.c (mips_after_parse_args): Check if -march is
	compatible with -mipsN.
	(md_begin): Call bfd_mips_elf_set_isa to set ISA in the ELF
	header for ELF.

2001-10-26  H.J. Lu <hjl@gnu.org>

	* mips.h (bfd_mips_elf_set_isa): New prototype.

--- binutils/bfd/elfxx-mips.c.mips	Thu Aug  1 16:33:27 2002
+++ binutils/bfd/elfxx-mips.c	Thu Aug  1 16:34:10 2002
@@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place - Suit
 #include "elf-bfd.h"
 #include "elfxx-mips.h"
 #include "elf/mips.h"
+#include "opcode/mips.h"
 
 /* Get the ECOFF swapping routines.  */
 #include "coff/sym.h"
@@ -5882,6 +5883,55 @@ _bfd_mips_elf_finish_dynamic_sections (o
   return true;
 }
 
+/* Set MIPS ISA in the ELF header.  */
+boolean
+bfd_mips_elf_set_isa (abfd, isa)
+     bfd *abfd;
+     int isa;
+{
+  unsigned long val;
+
+  switch (isa)
+    {
+    default:
+      return false;
+      break;
+
+    case ISA_MIPS1:
+      val = E_MIPS_ARCH_1;
+      break;
+
+    case ISA_MIPS2:
+      val = E_MIPS_ARCH_2;
+      break;
+
+    case ISA_MIPS3:
+      val = E_MIPS_ARCH_3;
+      break;
+
+    case ISA_MIPS4:
+      val = E_MIPS_ARCH_4;
+      break;
+
+    case ISA_MIPS5:
+      val = E_MIPS_ARCH_5;
+      break;
+
+    case ISA_MIPS32:
+      val = E_MIPS_ARCH_32;
+      break;
+
+    case ISA_MIPS64:
+      val = E_MIPS_ARCH_64;
+      break;
+    }
+
+  elf_elfheader (abfd)->e_flags &= ~EF_MIPS_ARCH;
+  elf_elfheader (abfd)->e_flags |= val;
+
+  return true;
+}
+
 /* The final processing done just before writing out a MIPS ELF object
    file.  This gets the MIPS architecture right based on the machine
    number.  This is used by both the 32-bit and the 64-bit ABI.  */
@@ -5891,75 +5941,92 @@ _bfd_mips_elf_final_write_processing (ab
      bfd *abfd;
      boolean linker ATTRIBUTE_UNUSED;
 {
-  unsigned long val;
+  unsigned long isa, cpu;
   unsigned int i;
   Elf_Internal_Shdr **hdrpp;
   const char *name;
   asection *sec;
 
+  isa = 0;
+  cpu = 0;
   switch (bfd_get_mach (abfd))
     {
     default:
     case bfd_mach_mips3000:
-      val = E_MIPS_ARCH_1;
+      isa = E_MIPS_ARCH_1;
       break;
 
     case bfd_mach_mips3900:
-      val = E_MIPS_ARCH_1 | E_MIPS_MACH_3900;
+      isa = E_MIPS_ARCH_1;
+      cpu = E_MIPS_MACH_3900;
       break;
 
     case bfd_mach_mips6000:
-      val = E_MIPS_ARCH_2;
+      isa = E_MIPS_ARCH_2;
       break;
 
     case bfd_mach_mips4000:
     case bfd_mach_mips4300:
     case bfd_mach_mips4400:
     case bfd_mach_mips4600:
-      val = E_MIPS_ARCH_3;
+      isa = E_MIPS_ARCH_3;
       break;
 
     case bfd_mach_mips4010:
-      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4010;
+      isa = E_MIPS_ARCH_3;
+      cpu =  E_MIPS_MACH_4010;
       break;
 
     case bfd_mach_mips4100:
-      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4100;
+      isa = E_MIPS_ARCH_3;
+      cpu = E_MIPS_MACH_4100;
       break;
 
     case bfd_mach_mips4111:
-      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4111;
+      isa = E_MIPS_ARCH_3;
+      cpu = E_MIPS_MACH_4111;
       break;
 
     case bfd_mach_mips4650:
-      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4650;
+      isa = E_MIPS_ARCH_3;
+      cpu = E_MIPS_MACH_4650;
       break;
 
     case bfd_mach_mips5000:
     case bfd_mach_mips8000:
     case bfd_mach_mips10000:
     case bfd_mach_mips12000:
-      val = E_MIPS_ARCH_4;
+      isa = E_MIPS_ARCH_4;
       break;
 
     case bfd_mach_mips5:
-      val = E_MIPS_ARCH_5;
+      isa = E_MIPS_ARCH_5;
       break;
 
     case bfd_mach_mips_sb1:
-      val = E_MIPS_ARCH_64 | E_MIPS_MACH_SB1;
+      isa = E_MIPS_ARCH_64;
+      cpu = E_MIPS_MACH_SB1;
       break;
 
     case bfd_mach_mipsisa32:
-      val = E_MIPS_ARCH_32;
+      isa = E_MIPS_ARCH_32;
       break;
 
     case bfd_mach_mipsisa64:
-      val = E_MIPS_ARCH_64;
+      isa = E_MIPS_ARCH_64;
     }
 
-  elf_elfheader (abfd)->e_flags &= ~(EF_MIPS_ARCH | EF_MIPS_MACH);
-  elf_elfheader (abfd)->e_flags |= val;
+  if (isa != 0 && (elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == 0)
+    {
+      elf_elfheader (abfd)->e_flags &= ~EF_MIPS_ARCH;
+      elf_elfheader (abfd)->e_flags |= isa;
+    }
+
+  if (cpu != 0)
+    {
+      elf_elfheader (abfd)->e_flags &= ~EF_MIPS_MACH;
+      elf_elfheader (abfd)->e_flags |= cpu;
+    }
 
   /* Set the sh_info field for .gptab sections and other appropriate
      info for each special section.  */
--- binutils/gas/config/tc-mips.c.mips	Thu Aug  1 16:33:28 2002
+++ binutils/gas/config/tc-mips.c	Thu Aug  1 17:17:26 2002
@@ -226,6 +226,9 @@ static int mips_tune = CPU_UNKNOWN;
 static const char *mips_tune_string;
 static const struct mips_cpu_info *mips_tune_info;
 
+/* The deprecated -mcpu option.  */
+static int seen_mips_cpu = 0;
+
 /* True when generating 32-bit code for a 64-bit processor.  */
 static int mips_32bitmode = 0;
 
@@ -1029,6 +1032,12 @@ md_begin ()
   if (! bfd_set_arch_mach (stdoutput, bfd_arch_mips, mips_arch))
     as_warn (_("Could not set architecture and machine"));
 
+#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
+  if (OUTPUT_FLAVOR == bfd_target_elf_flavour
+      && ! bfd_mips_elf_set_isa (stdoutput, mips_opts.isa))
+    as_warn (_("Could not set architecture"));
+#endif
+
   op_hash = hash_new ();
 
   for (i = 0; i < NUMOPCODES;)
@@ -9927,6 +9936,9 @@ struct option md_longopts[] =
 #define OPTION_NO_MDEBUG   (OPTION_ELF_BASE + 8)
   {"no-mdebug", no_argument, NULL, OPTION_NO_MDEBUG},
 #endif /* OBJ_ELF */
+/* Pray it is large enough so that it won't conflict with others.  */
+#define OPTION_MCPU (OPTION_MD_BASE + 0x7000000)
+  {"mcpu", required_argument, NULL, OPTION_MCPU},
   {NULL, no_argument, NULL, 0}
 };
 size_t md_longopts_size = sizeof (md_longopts);
@@ -10032,13 +10044,35 @@ md_parse_option (c, arg)
       break;
 
     case OPTION_MTUNE:
+      if (seen_mips_cpu)
+	goto mips_cpu_error;
       mips_set_option_string (&mips_tune_string, arg);
       break;
 
     case OPTION_MARCH:
+      if (seen_mips_cpu)
+	goto mips_cpu_error;
       mips_set_option_string (&mips_arch_string, arg);
       break;
 
+    case OPTION_MCPU:
+      if (mips_tune_string == 0 && mips_tune_string == 0)
+	{
+	  as_warn (_("The -mcpu option is deprecated.  Please use "
+		     "-march and -mtune instead."));
+
+	  mips_set_option_string (&mips_tune_string, arg);
+	  mips_set_option_string (&mips_arch_string, arg);
+	  seen_mips_cpu = 1;
+	}
+      else
+	{
+mips_cpu_error:
+	  as_fatal (_("The -mcpu option is deprecated.  Please use "
+		    "-march and -mtune instead."));
+	}
+      break;
+
     case OPTION_M4650:
       mips_set_option_string (&mips_arch_string, "4650");
       mips_set_option_string (&mips_tune_string, "4650");
--- binutils/include/elf/mips.h.mips	Thu Aug  1 16:33:28 2002
+++ binutils/include/elf/mips.h	Thu Aug  1 16:34:10 2002
@@ -817,6 +817,9 @@ extern void bfd_mips_elf_swap_options_in
 extern void bfd_mips_elf_swap_options_out
   PARAMS ((bfd *, const Elf_Internal_Options *, Elf_External_Options *));
 
+/* Set MIPS ISA in the ELF header.  */
+extern boolean bfd_mips_elf_set_isa PARAMS ((bfd *, int));
+
 /* Values which may appear in the kind field of an Elf_Options
    structure.  */
 


More information about the Binutils mailing list