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]
Other format: [Raw text]

check mips abi x linker emulation compatibility


We currently fail to reject attempts to link say mips ELF64 object
files using elfn32 or elf32 emulations, or N32 ELF32 objects using
elf32 or elf64 emulations.  This patch fixes this problem without
introducing regressions on mips-linux-gnu, but it's a disaster for the
linker testsuite in mips64-linux-gnu: the assembler generates ABI-less
elf32 code by default, which the linker rightfully recognizes as
elf32, thus rejecting to link it using the default n32 emulation.  I'm
thinking one way to fix the problem is to get the assembler to
actually choose an ABI as default.  Currently it just leaves mips_abi
set to NO_ABI through to the end of the compilation, which makes it
fail to set any of the ABI flag bits.  I'm thinking of doing it with
some triple-specific machinery, akin to what we currently use to set
MIPS_DEFAULT_64BIT.

I was thinking of doing the same change for Irix as well, however, now
I realize that the IRIX assembler doesn't default to n32, unlike the
compiler.  I'm not entirely sure on how to proceed: it seems that our
assembler matches IRIX's behavior, but the linker doesn't, the main
difference being that we fail to detect the emulation to be used from
the input object files.  I've no idea of how much effort it would be
to get GNU ld to do that, and I'm not entirely sure it's worth the
effort.

Meanwhile, I'm considering the possibility of switching the linker
default ABI on mips64-linux-gnu to o32, at least to get linker tests
to pass.  Comments?

Anyway, ok to install?

Index: bfd/ChangeLog
from  Alexandre Oliva  <aoliva at redhat dot com>

	* elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Improve
	error message for mixing different-endian files.  Check for ABI
	compatibility of input files with the selected emulation.

Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/uberbaum/bfd/elfxx-mips.c,v
retrieving revision 1.46
diff -u -p -r1.46 elfxx-mips.c
--- bfd/elfxx-mips.c 12 Mar 2003 23:05:51 -0000 1.46
+++ bfd/elfxx-mips.c 23 Mar 2003 23:28:15 -0000
@@ -8905,11 +8905,24 @@ _bfd_mips_elf_merge_private_bfd_data (ib
 
   /* Check if we have the same endianess */
   if (! _bfd_generic_verify_endian_match (ibfd, obfd))
-    return FALSE;
+    {
+      (*_bfd_error_handler)
+	(_("%s: endianness incompatible with that of the selected emulation"),
+	 bfd_archive_filename (ibfd));
+      return FALSE;
+    }
 
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
     return TRUE;
+
+  if (strcmp (bfd_get_target (ibfd), bfd_get_target (obfd)) != 0)
+    {
+      (*_bfd_error_handler)
+	(_("%s: ABI is incompatible with that of the select emulation"),
+	 bfd_archive_filename (ibfd));
+      return FALSE;
+    }
 
   new_flags = elf_elfheader (ibfd)->e_flags;
   elf_elfheader (obfd)->e_flags |= new_flags & EF_MIPS_NOREORDER;
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva at {redhat dot com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva at {lsd dot ic dot unicamp dot br, gnu.org}
Free Software Evangelist                Professional serial bug killer

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