This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Does -march=r5000 imply HAVE_64BIT_GPRS?


Richard Sandiford wrote:
> "H . J . Lu" <hjl@lucon.org> writes:
> 
> > It looks like the case. But I don't know for sure. Assuming I do get
> > 32-bit code, why is mips4 set? When the binary loaded into memory,
> > bad things may happen when the mips4 flag is set.
> 
> Yes, it certainly looks like a bug.

I've looked into this and found that the elf header flags for
E_MIPS_ARCH_* and E_MIPS_MACH_* are never set in the assembler,
instead they are later guessed in bfd in dependency of bfd_mach_mips*
where earlier settings done by the asssembler are also killed, so
it is impossible to override the machines default ISA (of course
only WRT the ELF headers).

Since I haven't found a good reason why bfd should override the
assembler's settings with it's little information, I removed the
relevant code there and introduced something similiar in the
assembler.


2001-08-16  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>

	/bfd/ChangeLog
	* elf32-mips.c (_bfd_mips_elf_final_write_processing): Remove setting
	of elf header flags for ARCH/MACH.

	/gas/ChangeLog
	* config/tc-mips.c (mips_elf_final_processing): Add setting of elf
	header flags for ARCH/MACH.

	/binutils/ChangeLog
	* readelf.c (get_machine_flags): Add recognition of EF_MIPS_32BITMODE.


diff -BurpNX /bigdisk/src/binutils-exclude src-orig/bfd/elf32-mips.c src/bfd/elf32-mips.c
--- src-orig/bfd/elf32-mips.c	Wed Jul  4 13:55:24 2001
+++ src/bfd/elf32-mips.c	Thu Aug 16 01:35:22 2001
@@ -2352,80 +2353,10 @@ _bfd_mips_elf_final_write_processing (ab
      bfd *abfd;
      boolean linker ATTRIBUTE_UNUSED;
 {
-  unsigned long val;
   unsigned int i;
   Elf_Internal_Shdr **hdrpp;
   const char *name;
   asection *sec;
-
-  switch (bfd_get_mach (abfd))
-    {
-    default:
-    case bfd_mach_mips3000:
-      val = E_MIPS_ARCH_1;
-      break;
-
-    case bfd_mach_mips3900:
-      val = E_MIPS_ARCH_1 | E_MIPS_MACH_3900;
-      break;
-
-    case bfd_mach_mips6000:
-      val = 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;
-      break;
-
-    case bfd_mach_mips4010:
-      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4010;
-      break;
-
-    case bfd_mach_mips4100:
-      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4100;
-      break;
-
-    case bfd_mach_mips4111:
-      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4111;
-      break;
-
-    case bfd_mach_mips4650:
-      val = E_MIPS_ARCH_3 | 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;
-      break;
-
-    case bfd_mach_mips32:
-      val = E_MIPS_ARCH_32;
-      break;
-
-    case bfd_mach_mips32_4k:
-      val = E_MIPS_ARCH_32 | E_MIPS_MACH_MIPS32_4K;
-      break;
-
-    case bfd_mach_mips5:
-      val = E_MIPS_ARCH_5;
-      break;
-
-    case bfd_mach_mips64:
-      val = E_MIPS_ARCH_64;
-      break;
-
-    case bfd_mach_mips_sb1:
-      val = E_MIPS_ARCH_64 | E_MIPS_MACH_SB1;
-      break;
-    }
-
-  elf_elfheader (abfd)->e_flags &= ~(EF_MIPS_ARCH | EF_MIPS_MACH);
-  elf_elfheader (abfd)->e_flags |= val;
 
   /* Set the sh_info field for .gptab sections and other appropriate
      info for each special section.  */
diff -BurpNX /bigdisk/src/binutils-exclude src-orig/gas/config/tc-mips.c src/gas/config/tc-mips.c
--- src-orig/gas/config/tc-mips.c	Sun Aug 12 13:34:58 2001
+++ src/gas/config/tc-mips.c	Thu Aug 16 00:39:49 2001
@@ -11572,6 +11870,62 @@ mips_elf_final_processing ()
     elf_elfheader (stdoutput)->e_flags |= EF_MIPS_NOREORDER;
   if (mips_pic != NO_PIC)
     elf_elfheader (stdoutput)->e_flags |= EF_MIPS_PIC;
+  switch (file_mips_isa)
+    {
+      case ISA_MIPS1:
+	elf_elfheader (stdoutput)->e_flags |= E_MIPS_ARCH_1;
+	break;
+      case ISA_MIPS2:
+	elf_elfheader (stdoutput)->e_flags |= E_MIPS_ARCH_2;
+	break;
+      case ISA_MIPS3:
+	elf_elfheader (stdoutput)->e_flags |= E_MIPS_ARCH_3;
+	break;
+      case ISA_MIPS4:
+	elf_elfheader (stdoutput)->e_flags |= E_MIPS_ARCH_4;
+	break;
+      case ISA_MIPS5:
+	elf_elfheader (stdoutput)->e_flags |= E_MIPS_ARCH_5;
+	break;
+      case ISA_MIPS32:
+	elf_elfheader (stdoutput)->e_flags |= E_MIPS_ARCH_32;
+	break;
+      case ISA_MIPS64:
+	elf_elfheader (stdoutput)->e_flags |= E_MIPS_ARCH_64;
+	break;
+      case ISA_UNKNOWN:
+      default:
+	if (mips_64)
+	  elf_elfheader (stdoutput)->e_flags |= E_MIPS_ARCH_3;
+	else
+	  elf_elfheader (stdoutput)->e_flags |= E_MIPS_ARCH_1;
+	break;
+    }
+
+  switch (mips_arch)
+    {
+    case CPU_R3900:
+      elf_elfheader (stdoutput)->e_flags |= E_MIPS_MACH_3900;
+      break;
+    case CPU_R4010:
+      elf_elfheader (stdoutput)->e_flags |= E_MIPS_MACH_4010;
+      break;
+    case CPU_VR4100:
+      elf_elfheader (stdoutput)->e_flags |= E_MIPS_MACH_4100;
+      break;
+    case CPU_R4111:
+      elf_elfheader (stdoutput)->e_flags |= E_MIPS_MACH_4111;
+      break;
+    case CPU_R4650:
+      elf_elfheader (stdoutput)->e_flags |= E_MIPS_MACH_4650;
+      break;
+    case CPU_MIPS32_4K:
+      elf_elfheader (stdoutput)->e_flags |= E_MIPS_MACH_MIPS32_4K;
+      break;
+    case CPU_SB1:
+      elf_elfheader (stdoutput)->e_flags |= E_MIPS_MACH_SB1;
+      break;
+    }
 
   /* Set the MIPS ELF ABI flags.  */
   if (mips_abi_string == NULL)
diff -BurpNX /bigdisk/src/binutils-exclude src-orig/binutils/readelf.c src/binutils/readelf.c
--- src-orig/binutils/readelf.c	Sun Aug 12 13:34:57 2001
+++ src/binutils/readelf.c	Thu Aug 16 01:45:31 2001
@@ -1577,6 +1577,9 @@ get_machine_flags (e_flags, e_machine)
 	  if (e_flags & EF_MIPS_ABI2)
 	    strcat (buf, ", abi2");
 
+	  if (e_flags & EF_MIPS_32BITMODE)
+	    strcat (buf, ", 32bitmode");
+
 	  if ((e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_1)
 	    strcat (buf, ", mips1");
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]