クロスコンパイラの設定については、「readelf -h target.bin」の出力 (ターゲット マシンで target.bin が実行される) を参照しました。クロスコンパイラでコンパイルされたバイナリプログラムの readelf 出力は、target.bin の出力と同じであると想定しました。
ただし、次の場合、「readelf」出力が互いに異なる 2 つのプログラムが、ターゲット マシン上で正常に実行される可能性があります。さらに、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
コメントをいただければ幸いです。