uboot2 --elf文件分析

来源:互联网 发布:数据可视化概念 编辑:程序博客网 时间:2024/05/22 14:43

root@ubuntu:/opt/FriendlyARM/u-boot-1.1.6/u-boot-1.1.6# file u-boot
u-boot: ELF 32-bit LSB executable, ARM, version 1, statically linked, not stripped
root@ubuntu:/opt/FriendlyARM/u-boot-1.1.6/u-boot-1.1.6# file u-boot.bin 
u-boot.bin: data

root@ubuntu:/opt/FriendlyARM/u-boot-1.1.6/u-boot-1.1.6# readelf -h u-boot

ELF Header:
Magic: 7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: ARM
ABI Version: 0
Type: EXEC (Executable file)
Machine: ARM
Version: 0x1
Entry point address: 0x33f80000
Start of program headers: 52 (bytes into file)
Start of section headers: 345172 (bytes into file)
Flags: 0x602, has entry point, GNU EABI, software FP, VFP
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: 21

Section header string table index: 18

有上述的信息可知,uboot被连接的地址为0x33f80000,那为什么该代码还能被ARM从起始地址0x00000000运行呢?因为uboot的第一段代码是与位置无关的代码(PIC),即无论改代码被连接到何处都可以运行。经过第一段uboot将其自身代码的code、data、bss各段copy到0x33f80000处,并执行代码。
原创粉丝点击