1

I'm am targeting an old router need MIPS-I executables but -mips1 produces MIPS32 executables.

Here is the compile command:

buildroot-2019.02.5/output/host/bin/mips-linux-gcc-7.4.0 -march=mips1 -mtune=mips1 -static ~/helloworld.c -o /tmp/hw.1013  -msoft-float

But the file is MIPS32, not MIPS-I

file /tmp/hw.1013

/tmp/hw.1013: ELF 32-bit MSB executable, MIPS, MIPS32 version 1 (SYSV), statically linked, not stripped

Older versions of gcc produce the correct MIPS-I binaries.

./mips-gcc --version
uClibc mips-rawgcc (GCC) 4.1.2

./mips-gcc -march=mips1  -static ~/helloworld.c -o /tmp/hw.1013  -msoft-float 
file /tmp/hw.1013
/tmp/hw.1013: ELF 32-bit MSB executable, MIPS, MIPS-I version 1 (SYSV), statically linked, not stripped
user570577
  • 109
  • 4

1 Answers1

1

I had the same issue with the Debian buster gcc 8 mipsel cross compiler package. Turned out to be because the standard libraries were compiled for mips32r2.
gcc does in fact produce MIPS-I assembly as you can see if you do a gcc -c source.c and look at the flags in the elf header of the object file readelf -h source.o. But when linked against a newer ISA library, ld will mark the executable with the newer ISA.

I suspect you're having the same issue since buildroot hasn't supported MIPS-I since 2014. Check with readelf -h on eg. your static uClibc library. In my buildroot-2014.11 toolchain it is located under output/host/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/lib/libc.a

user2973
  • 143
  • 5