我已经参考了“readelf -h target.bin”的输出(target.bin 在目标机器上运行)来配置交叉编译器。我假设交叉编译器编译的二进制程序的 readelf 输出应该与 target.bin 的输出相同。
但是,在以下情况下,两个具有不同“readelf”输出的程序可以在目标机器上成功运行。此外,具有与 target.bin 的输出类似的 readelf 输出的另一个程序在目标机器上不可执行。似乎 readelf 输出对于交叉编译器的配置并不重要。 那么...对于目标机器的交叉编译器的正确配置,我应该参考哪些内容?
例子:
readelf -h target.bin(target.bin 是运行在目标机器上的二进制程序)输出:
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: 0x403570
Start of program headers: 52 (bytes into file)
Start of section headers: 114040 (bytes into file)
Flags: 0x5, noreorder, cpic, 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: 23
Section header string table index: 22
readelf -h myfail_target.bin(由我编译)在目标机器上不可执行,输出:
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: 0x400170
Start of program headers: 52 (bytes into file)
Start of section headers: 16444 (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: 5
Size of section headers: 40 (bytes)
Number of section headers: 21
Section header string table index: 20
readelf -h mysuccess_target.bin(由我编译),可在目标机器上执行,输出:
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: 0x400140
Start of program headers: 52 (bytes into file)
Start of section headers: 28572 (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: 3
Size of section headers: 40 (bytes)
Number of section headers: 20
Section header string table index: 17
任何意见将不胜感激。