[PATCH RFA] Copy and print MIPS ASE flags.

cgd@broadcom.com cgd@broadcom.com
Mon Mar 18 19:16:00 GMT 2002


The following patch adds support to bfd's elf32-mips handling to:

* copy the MIPS ASE flags to new BFDs when appropriate, and

* print the ASE flags when printing the ELF header.

The latter mirrors behaviour already in readelf.

No test case provided because, uh, well, nothing currently sets these
flags.  (Speaking of which, people hacking on mips16 might want to set
the MIPS16 flag...  8-)


To be honest, I could buy a well-phrased argument promoting the
position of "don't copy them from one binary to another, or _ever_ set
them at all right now."

But I think that objdump and readelf should behave consistently, at
least.  8-)


thoughts?


cgd
===================================================================
2002-03-18  Chris Demetriou  <cgd@broadcom.com>

	* elf32-mips.c (_bfd_mips_elf_merge_private_bfd_data): Merge ASE
	use flags into resulting BFD.
	(_bfd_mips_elf_print_private_bfd_data): Print out information
	about the ASE flags set in the header.

Index: elf32-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mips.c,v
retrieving revision 1.147
diff -u -p -r1.147 elf32-mips.c
--- elf32-mips.c	2002/02/19 12:40:29	1.147
+++ elf32-mips.c	2002/03/19 03:07:29
@@ -3198,6 +3198,14 @@ _bfd_mips_elf_merge_private_bfd_data (ib
       old_flags &= ~(EF_MIPS_ARCH | EF_MIPS_MACH);
     }
 
+  /* Retain the union of set ASE flags.  */
+  if ((new_flags & EF_MIPS_ARCH_ASE) != (old_flags & EF_MIPS_ARCH_ASE))
+    {
+      elf_elfheader (obfd)->e_flags |= (new_flags & EF_MIPS_ARCH_ASE);
+      new_flags &= ~EF_MIPS_ARCH_ASE;
+      old_flags &= ~EF_MIPS_ARCH_ASE;
+    }
+
   /* Compare ABI's.  The 64-bit ABI does not use EF_MIPS_ABI.  But, it
      does set EI_CLASS differently from any 32-bit ABI.  */
   if ((new_flags & EF_MIPS_ABI) != (old_flags & EF_MIPS_ABI)
@@ -3287,6 +3295,12 @@ _bfd_mips_elf_print_private_bfd_data (ab
     fprintf (file, _(" [mips64]"));
   else
     fprintf (file, _(" [unknown ISA]"));
+
+  if (elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH_ASE_MDMX)
+    fprintf (file, _(" [mdmx]"));
+
+  if (elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH_ASE_M16)
+    fprintf (file, _(" [mips16]"));
 
   if (elf_elfheader (abfd)->e_flags & EF_MIPS_32BITMODE)
     fprintf (file, _(" [32bitmode]"));



More information about the Binutils mailing list