我正在尝试为我拥有的一个小型嵌入式设备编译几个程序。它是一个Little-endian MIPS(mipsel)处理器。我通过telnet和内置的ftp客户端从中检索了这个可执行文件:
root@debian-mipsel:/home/user/wansview/devel# readelf -h unzip1
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: 0x401cc0
Start of program headers: 52 (bytes into file)
Start of section headers: 169960 (bytes into file)
Flags: 0x10001007, noreorder, pic, cpic, o32, mips2
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: 24
Section header string table index: 23
root@debian-mipsel:/home/user/wansview/devel# file unzip1
unzip1: ELF 32-bit LSB executable, MIPS, MIPS-II version 1 (SYSV), dynamically linked (uses shared libs), stripped
我随后下载了MIPSEL版本的Debian并在QEMU中运行它。当我运行上面检索到的程序时,会得到以下输出:
root@debian-mipsel:/home/user/wansview/devel# ./unzip1
-bash: ./unzip1: No such file or directory
我了解它的意思是这不是正确的平台。尽管如此,我还是编译了一个小的hello world程序来比较ELF和文件信息。我的hello world程序在Debian MIPSEL上可以正常运行,但在嵌入式设备上返回“No such file or directory
”。然而,它的readelf
和file
输出非常相似:
root@debian-mipsel:/home/user/wansview/devel# 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: 0x400740
Start of program headers: 52 (bytes into file)
Start of section headers: 3652 (bytes into file)
Flags: 0x10001005, noreorder, cpic, o32, mips2
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 10
Size of section headers: 40 (bytes)
Number of section headers: 36
Section header string table index: 35
root@debian-mipsel:/home/user/wansview/devel# file hello
hello: ELF 32-bit LSB executable, MIPS, MIPS-II version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xeb3877062337a3dfd15cc09305691685ac0e8c57, with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x1040000, stripped
我想更好地理解我的两个系统之间的差异,以及为什么可执行文件不能在两个系统上运行。有没有任何标志可以添加到gcc
中,以成功地编译嵌入式设备?
关于设备的更多信息
# cat /proc/cpuinfo
system type : Ralink SoC
processor : 0
cpu model : MIPS 24K V4.12
BogoMIPS : 239.10
wait instruction : yes
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : yes
hardware watchpoint : yes
ASEs implemented : mips16 dsp
VCED exceptions : not available
VCEI exceptions : not available
关于Debian MIPSEL的更多信息
(在debian-mipsel上编译的二进制文件无法在目标嵌入式设备上运行)
root@debian-mipsel:/home/user/wansview/devel# cat /proc/cpuinfo
system type : MIPS Malta
processor : 0
cpu model : MIPS 24Kc V0.0 FPU V0.0
BogoMIPS : 1038.33
wait instruction : yes
microsecond timers : yes
tlb_entries : 16
extra interrupt vector : yes
hardware watchpoint : yes, count: 1, address/irw mask: [0x0ff8]
ASEs implemented : mips16
shadow register sets : 1
kscratch registers : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not available
关于Aboriginal Linux Mipsel的更多信息
(在Aboriginal Linux上编译的二进制文件可以在嵌入式设备上运行,并且可以运行从设备检索出来的二进制文件。我对此并不满意,因为它缺少我编译较大应用程序所需的make
和其他工具)
(mipsel:1) /home/wansview # cat /proc/cpuinfo
system type : MIPS Malta
machine : Unknown
processor : 0
cpu model : MIPS 24Kc V0.0 FPU V0.0
BogoMIPS : 1013.76
wait instruction : yes
microsecond timers : yes
tlb_entries : 16
extra interrupt vector : yes
hardware watchpoint : yes, count: 1, address/irw mask: [0x0ff8]
isa : mips1 mips2 mips32r1 mips32r2
ASEs implemented : mips16
shadow register sets : 1
kscratch registers : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not available
LDD
这里是运行 ldd
命令对比我的hello world和unzip1在aboriginal linux和debian mipsel上的截图。从设备中检索的应用在Aboriginal Linux上可以正常运行,如果我在Aboriginal Linux下编译则可以在嵌入式设备上运行生成的二进制文件。我不满意Aboriginal Linux的原因是它没有GNU make
和其他更适用于大型应用的有用工具,并且没有简单的方法将它们安装到此设备上。
ldd
输出的截图。你似乎是对的,其中一个正在寻找libc.so.6
,另一个正在寻找libc.so.0
。有什么解决方案吗? - Juicy