This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PATCH: Fix mixing MIPS object files.
On Tue, Nov 05, 2002 at 06:55:15PM +0000, Richard Sandiford wrote:
> "H. J. Lu" <hjl@lucon.org> writes:
> > What do you expect? The binary contains instructions from MIPS IV as
> > well as vr4100.
>
> Well, I was expecting an error. The point is, if we link based on the
> BFD machine (which is interpreted from the ELF header flags, or at least
> ought to be) then we'd be able to pick up that sort of thing.
>
How about this patch?
H.J.
---
2002-11-05 H.J. Lu <hjl@gnu.org>
* elfxx-mips.c (_bfd_mips_elf_mach_match): New.
(_bfd_mips_elf_merge_private_bfd_data): Use it.
--- bfd/elfxx-mips.c.merge Tue Nov 5 11:01:21 2002
+++ bfd/elfxx-mips.c Tue Nov 5 11:37:39 2002
@@ -366,6 +366,8 @@ static INLINE char* elf_mips_abi_name PA
static void mips_elf_irix6_finish_dynamic_symbol
PARAMS ((bfd *, const char *, Elf_Internal_Sym *));
static boolean _bfd_mips_elf_mach_extends_p PARAMS ((flagword, flagword));
+static boolean _bfd_mips_elf_mach_match
+ PARAMS ((flagword, flagword,flagword, flagword));
/* This will be used when we sort the dynamic relocation records. */
static bfd *reldyn_sorting_bfd;
@@ -7760,6 +7762,26 @@ _bfd_mips_elf_mach_extends_p (base, exte
|| (base == E_MIPS_MACH_4100 && extension == E_MIPS_MACH_4120));
}
+/* Return true if machine NEW_MACH implementing ISA NEW_ISA is
+ compatible with machine OLD_MACH implementing OLD_ISA. */
+
+static boolean
+_bfd_mips_elf_mach_match (new_mach, new_isa, old_mach, old_isa)
+ flagword new_mach, new_isa, old_mach, old_isa;
+{
+ if (new_mach == old_mach)
+ return true;
+
+ /* If any of them has non-zero EF_MIPS_MACH, its ISA has to be the
+ highest. */
+ if ((new_mach == 0 && new_isa > old_isa)
+ || (old_mach == 0 && old_isa > new_isa))
+ return false;
+
+ return _bfd_mips_elf_mach_extends_p (new_mach, old_mach)
+ || _bfd_mips_elf_mach_extends_p (old_mach, new_mach);
+}
+
/* Merge backend specific data from an object file to the output
object file when linking. */
@@ -7866,9 +7888,8 @@ _bfd_mips_elf_merge_private_bfd_data (ib
/* If either has no machine specified, just compare the general isa's.
Some combinations of machines are ok, if the isa's match. */
- if (new_mach == old_mach
- || _bfd_mips_elf_mach_extends_p (new_mach, old_mach)
- || _bfd_mips_elf_mach_extends_p (old_mach, new_mach))
+ if (_bfd_mips_elf_mach_match (new_mach, new_isa, old_mach,
+ old_isa))
{
/* Don't warn about mixing code using 32-bit ISAs, or mixing code
using 64-bit ISAs. They will normally use the same data sizes