Bug 24832 - mips: convert from data to object always generate MIPS I
Summary: mips: convert from data to object always generate MIPS I
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.33
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-22 10:25 UTC by YunQiang Su
Modified: 2019-07-25 15:37 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description YunQiang Su 2019-07-22 10:25:07 UTC
$ echo "abc" > xx.dat
$ mips64el-linux-gnuabi64-ld -r -b binary xx.dat -o xx.o
$ file xx.o
xx.o: ELF 64-bit LSB relocatable, MIPS, MIPS-I version 1 (SYSV), not stripped

while to link xx.o with real mips64 objects, it fails:


Index: binutils-2.32.51.20190707/bfd/elfxx-mips.c
===================================================================
--- binutils-2.32.51.20190707.orig/bfd/elfxx-mips.c
+++ binutils-2.32.51.20190707/bfd/elfxx-mips.c
@@ -12193,6 +12193,11 @@ mips_set_isa_flags (bfd *abfd)
   switch (bfd_get_mach (abfd))
     {
     default:
+      if (ABI_N32_P (abfd) || ABI_64_P (abfd))
+        val = E_MIPS_ARCH_3;
+      else
+        val = E_MIPS_ARCH_1;
+      break;
     case bfd_mach_mips3000:
       val = E_MIPS_ARCH_1;
       break;

can convert it to: 
xx.o: ELF 64-bit LSB relocatable, MIPS, MIPS-III version 1 (SYSV), not stripped


https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=932287
https://buildd.debian.org/status/fetch.php?pkg=glib2.0&arch=mips64el&ver=2.61.1-2&stamp=1563280987&raw=0
Comment 1 Sourceware Commits 2019-07-25 15:36:25 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c7c860d2d29ca3e774c29f328d2af42eeb031958

commit c7c860d2d29ca3e774c29f328d2af42eeb031958
Author: YunQiang Su <syq@debian.org>
Date:   Thu Jul 25 16:34:58 2019 +0100

    When linking binary files into MIPS executables, default to MIPS 3 emaulation for 64-bit objects.
    
    	PR 24832
    	* elfxx-mips.c (mips_set_isa_flags): Default to MIPS 3 for 64-bit
    	mips inputs.
Comment 2 Nick Clifton 2019-07-25 15:37:51 UTC
Hi YunQiang,

  Thanks for the bug report and patch.  I have applied the patch along
  with a changelog entry to the source repository.

Cheers
  Nick