Search code examples
compiler-constructioncross-platformmips

illegal instruction on correct mips elf32


Basically I have this box:

# cat proc/cpuinfo 
system type             : RTL8672
processor               : 0
cpu model               : 56322
BogoMIPS                : 619.31
tlb_entries             : 64
mips16 implemented      : yes

    cat proc/version 
    Linux version 2.6.30.9 (xia@njzd) (gcc version 4.4.6 (Realtek RSDK-1.5.6p2) ) #2 Wed Apr 29 18:57:54 CST 2015

Here is how program look like on the box

$ readelf -a httpd 
ELF Header:
  Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           MIPS R3000
  Version:                           0x1
  Entry point address:               0x4a1330
  Start of program headers:          52 (bytes into file)
  Start of section headers:          816092 (bytes into file)
  Flags:                             0x1007, noreorder, pic, cpic, o32, mips1
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         8
  Size of section headers:           40 (bytes)
  Number of section headers:         24
  Section header string table index: 23

And here is mine after cross compile

$ readelf -a File2 
ELF Header:
  Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           MIPS R3000
  Version:                           0x1
  Entry point address:               0x400280
  Start of program headers:          52 (bytes into file)
  Start of section headers:          651896 (bytes into file)
  Flags:                             0x1007, noreorder, pic, cpic, o32, mips1
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         6
  Size of section headers:           40 (bytes)
  Number of section headers:         33
  Section header string table index: 30

But still when I run File2 I'm getting illegal instruction, I'm suspecting that cross-compiler using BLA instruction and my box does not support that one, how could I tell my mips cross-compiles to replace BLA with some other instruction ? In this mailing list they talking about JAL/JALR to BAL transformation for Linux (o32 ABI), any tip ?


Solution

  • cat proc/cpuinfo

    system type: RTL8672

    processor: 0

    cpu model : 56322

    An RTL8672 is not a full MIPS implementation, but a Lexra. You will need a customized toolchain that knows how to handle this.

    Something like this

    https://github.com/infinite-monkeys/rtl8672-toolchain

    or for a binary-only toolchain, look for 'rsdk'

    e.g. https://github.com/KrabbyPatty/rtl819x-toolchain/tree/master/toolchain