|
尝试为专用的MIPS platform上写个小程序helloword,最后生成bin文件。但总是无法在实际机器上运行。readelf输出如下:
ELF Header:
Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, big endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: SUNPLUS S+Core
Version: 0x1
Entry point address: 0x8000f000
Start of program headers: 52 (bytes into file)
Start of section headers: 264 (bytes into file)
Flags: 0x20001101
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 2
Size of section headers: 40 (bytes)
Number of section headers: 5
Section header string table index: 4
Section Headers:
[Nr] Name Type Addr Off Size ES *** Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 8000f000 000080 000040 00 WAX 0 0 16
[ 2] .data PROGBITS 8000f040 0000c0 000010 00 WA 0 0 16
[ 3] .reginfo LOPROC+6 8000f050 0000d0 000018 18 A 0 0 4
[ 4] .shstrtab STRTAB 00000000 0000e8 000020 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
There are no section groups in this file.
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz *** Align
LOPROC+0 0x0000d0 0x8000f050 0x8000f050 0x00018 0x00018 R 0x4
LOAD 0x000000 0x8000ef80 0x8000ef80 0x000d0 0x000d0 RWE 0x10
Section to Segment mapping:
Segment Sections...
00 .reginfo
01 .text .data
There is no dynamic section in this file.
There are no relocations in this file.
There are no unwind sections in this file.
No version information found in this file.
但根据提供的原始bin文件,其readelf结果如下:
ELF Header:
Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, big endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: SUNPLUS S+Core
Version: 0x1
Entry point address: 0x80008000
Start of program headers: 52 (bytes into file)
Start of section headers: 216 (bytes into file)
Flags: 0x20001101
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 1
Size of section headers: 40 (bytes)
Number of section headers: 5
Section header string table index: 4
Section Headers:
[Nr] Name Type Addr Off Size ES *** Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 80008000 000054 00003c 00 WAX 0 0 4
[ 2] .reginfo LOPROC+6 00400000 0000a0 000018 01 0 0 4
[ 3] .data PROGBITS 8000803c 000090 000010 00 WA 0 0 4
[ 4] .shstrtab STRTAB 00000000 0000b8 000020 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
There are no section groups in this file.
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz *** Align
LOAD 0x000054 0x80008000 0x80008000 0x0004c 0x0004c RWE 0x4
Section to Segment mapping:
Segment Sections...
00 .text .data
There is no dynamic section in this file.
There are no relocations in this file.
There are no unwind sections in this file.
No version information found in this file.
因此有如下几个问题请教:
1、ld如何设置连接参数(或自定义ldscript?),以便生成只有一个program header的elf文件?也就是去掉“ LOPROC+0 0x0000d0 0x8000f050 0x8000f050 0x00018 0x00018 R 0x4”这些东西。
2、如何修改elf header中的flags?是ld连接时、还是在objcopy时?
3、section header中的align怎么修改呢?如何定义为4?我自己生成的是16。 |
|