CrazyHorse DD-WRT Novice
Joined: 10 Jul 2006 Posts: 23
|
Posted: Fri Apr 02, 2010 15:47 Post subject: Writing mipsel assembly programs |
|
I've just built a cross binutils assembler for mipsel. I have this short program that I wrote:
.text
.globl main
main:
li $2, 4
la $4, greeting
syscall
li $4, 10
syscall
.data
greeting: .asciiz "Hello, world!"
% mipsel-linux-uclibc-as -mips32 hello.S -o hello.o
% mipsel-linux-uclibc-ld -e main hello.o -o hello
% scp hello XXxxXX@router:/tmp/
XXxxXX@router:/tmp# ./hello
Illegal instruction
Any ideas why it would be complaining about illegal instructions? I had a look at hello's elf header and compared it to hotplug's elf header (taken from router) and there are some differences but I'm unsure if these differences are important enough:
% mipsel-linux-uclibc-readelf -h ./hotplug
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0x400630
Start of program headers: 52 (bytes into file)
Start of section headers: 0 (bytes into file)
Flags: 0x50001007, noreorder, pic, cpic, o32, mips32
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 6
Size of section headers: 0 (bytes)
Number of section headers: 0
Section header string table index: 0
and
% mipsel-linux-uclibc-readelf -h ./hello ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0x4000d0
Start of program headers: 52 (bytes into file)
Start of section headers: 320 (bytes into file)
Flags: 0x50001000, o32, mips32
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 4
Size of section headers: 40 (bytes)
Number of section headers: 10
Section header string table index: 7
Any ideas? |
|