所以我想開始編寫一些mips程序集,並設置我的工具。 我正在使用Arch Linux,並從用戶存儲庫安裝了交叉mipsel-linux-gnu-gcc和binutils,這很好用,並且成功地將我的簡單測試程序編譯爲mipsel二進制文件。由於無效的ELF頭文件,MIPS仿真程序無法運行mips可執行文件
我不想要任何花式的gui或類似的東西來模仿我,並且去了qemu。這是我有問題。當我嘗試運行我的可執行文件qemu-mipsel ./test
時,qemu只是回覆./test: Invalid ELF image for this architecture
。
的第一件事,我雖然是「可以QEMU真的只是運行基地MIPS的二進制文件這樣呢?這看起來幾乎像魔術,這不可能是正確的。」,所以我就開始使用Google,如果它實際上是可能的,found a tutorial on how to to similar compilation for a openwrt but with C code <,在看完這篇教程之後,我的步驟似乎也應該起作用。
這是我編的組裝,清潔,簡單的命令 mipsel-linux-gnu-as test.asm -o test; chmod +x ./test
這裏的file
命令 ./test: ELF 32-bit LSB relocatable, MIPS, MIPS-I version 1 (SYSV), not stripped
這裏的輸出年代readelf -a ./test
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: REL (Relocatable file)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 164 (bytes into file)
Flags: 0x1000, o32, mips1
Size of this header: 52 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 40 (bytes)
Number of section headers: 9
Section header string table index: 6
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000000 000040 000010 00 AX 0 0 16
[ 2] .data PROGBITS 00000000 000050 000000 00 WA 0 0 16
[ 3] .bss NOBITS 00000000 000050 000000 00 WA 0 0 16
[ 4] .reginfo MIPS_REGINFO 00000000 000050 000018 18 A 0 0 4
[ 5] .pdr PROGBITS 00000000 000068 000000 00 0 0 4
[ 6] .shstrtab STRTAB 00000000 000068 00003a 00 0 0 1
[ 7] .symtab SYMTAB 00000000 00020c 000060 10 8 6 4
[ 8] .strtab STRTAB 00000000 00026c 000001 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
There are no section groups in this file.
There are no program headers in this file.
There are no relocations in this file.
The decoding of unwind sections for machine type MIPS R3000 is not currently supported.
Symbol table '.symtab' contains 6 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 SECTION LOCAL DEFAULT 1
2: 00000000 0 SECTION LOCAL DEFAULT 2
3: 00000000 0 SECTION LOCAL DEFAULT 3
4: 00000000 0 SECTION LOCAL DEFAULT 4
5: 00000000 0 SECTION LOCAL DEFAULT 5
No version information found in this file.
FYI:Debian的MIPS VM在HTTPS QEMU系統,MIPS: //people.debian.org/~aurel32/qemu/mips/,可執行文件可以運行,並且可以跨平臺安裝「multiarch」軟件包。 (和ppc和胳膊和sh4也) – user3710044 2015-04-04 17:39:59