elf 格式简析
program header
Elf file type is EXEC (Executable file)
Entry point 0x308000
There are 4 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x001000 0x02800000 0x02800000 0x01000 0x01000 R 0
LOAD 0x002000 0x00308000 0x00308000 0x1d47a0 0x3a9680 RWE 0x1000
LOAD 0x1d7000 0x03008000 0x03008000 0x1e7350 0x220500 RWE 0x20
LOAD 0x3bf000 0x0b808000 0x0b808000 0x1e7350 0x220500 RWE 0x20
Section to Segment mapping:
Segment Sections...
00 ROM
01 data
02 data
03 data
offset --> 相对elf header头部最开开始的物理地址偏移
VirtAddr --> 加载到内存时候的虚拟地址
PhysAddr --> 无意义
FileSiz --> elf中program尺寸
MemSiz --> program 加载到meme尺寸,含bss
section header
There are 16 section headers, starting at offset 0x866b58:
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .text PROGBITS 0000000000308000 00001000
00000000001c29b0 0000000000000000 WAX 0 0 4096
[ 2] .cpu_private PROGBITS 00000000ff800000 001d57a0
0000000000002b68 0000000000000000 W 0 0 32
[ 3] .data PROGBITS 00000000004cb000 001c4000
00000000000117a0 0000000000000000 WA 0 0 4096
[ 4] .bss NOBITS 00000000004dd000 001d57a0
00000000001d4680 0000000000000000 WA 0 0 4096
[ 5] .debug_aranges PROGBITS 0000000000000000 001d8310
00000000000053a0 0000000000000000 0 0 16
[ 6] .debug_pubnames PROGBITS 0000000000000000 001dd6b0
0000000000012bfd 0000000000000000 0 0 1
[ 7] .debug_info PROGBITS 0000000000000000 001f02ad
000000000048732f 0000000000000000 0 0 1
[ 8] .debug_abbrev PROGBITS 0000000000000000 006775dc
00000000000464d2 0000000000000000 0 0 1
[ 9] .debug_line PROGBITS 0000000000000000 006bdaae
000000000005bf05 0000000000000000 0 0 1
[10] .debug_str PROGBITS 0000000000000000 007199b3
00000000000236ab 0000000000000001 MS 0 0 1
[11] .debug_loc PROGBITS 0000000000000000 0073d05e
000000000010c6b2 0000000000000000 0 0 1
[12] .debug_ranges PROGBITS 0000000000000000 00849710
000000000001d3a0 0000000000000000 0 0 1
[13] .shstrtab STRTAB 0000000000000000 00866ab0
00000000000000a2 0000000000000000 0 0 1
[14] .symtab SYMTAB 0000000000000000 00866f58
000000000001de68 0000000000000018 15 2451 8
[15] .strtab STRTAB 0000000000000000 00884dc0
00000000000124d6 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
address --> 虚拟地址
offset --> 相对elf header头部最开开始的物理地址偏移
EntSize --> 符号表等section中的表项数目
elf file
=elf header +
program header +
program data ( = section data + section data + ...) +
section header