Linux 关于交叉编译器的正确配置,我应该参考哪些内容?

Linux 关于交叉编译器的正确配置,我应该参考哪些内容?,linux,mips,cross-compiling,buildroot,readelf,Linux,Mips,Cross Compiling,Buildroot,Readelf,对于交叉编译器的配置,我已经参考了“readelf-htarget.bin”(target.bin在目标机器上运行)的输出。我假设由交叉编译器编译的二进制程序的readelf输出应该与target.bin的输出相同 但是,在以下情况下,两个相互具有不同“readelf”输出的程序可以在目标机器上成功运行。此外,另一个readelf输出与target.bin的输出类似的程序在目标机器上不可执行。看起来readelf输出对于交叉编译器的配置并不重要。 然后。。。要为目标机器正确配置交叉编译器,我应该

对于交叉编译器的配置,我已经参考了“readelf-htarget.bin”(target.bin在目标机器上运行)的输出。我假设由交叉编译器编译的二进制程序的readelf输出应该与target.bin的输出相同

但是,在以下情况下,两个相互具有不同“readelf”输出的程序可以在目标机器上成功运行。此外,另一个readelf输出与target.bin的输出类似的程序在目标机器上不可执行。看起来readelf输出对于交叉编译器的配置并不重要。 然后。。。要为目标机器正确配置交叉编译器,我应该参考哪些内容?

例子: readelf-h target.bin(target.bin是在目标机器上运行的二进制程序)输出:

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
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
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:               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
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

任何评论都将不胜感激。

首先让我印象深刻的是,您的工作代码有
mips32
,但后来我意识到您的顶级示例没有,所以这确实有点令人困惑!(这是你的另一个问题中的hello world程序吗?你可能想在这里发布它,以及其他人看到的编译器命令行和版本)PS我可以理解你在这里的挫折感,我讨厌它,因为有些东西本来就应该行得通,而在我的情况下,通常都很有效,突然之间没有了……我做了一些进一步的挖掘,发现了一些关于2.4.x内核和MIPS ELF中的bug的讨论,尽管这可能只是偶然的,如果您的非工作/工作软件运行在较新的内核上。我想知道小精灵是否真的和它有任何关系。。。这可能更像是一种编译器特性。例如,在调试(非优化)编译和优化编译中,您是否会遇到相同的错误?静态链接和动态链接怎么样?