Chinaunix
标题:
有关ELF入口点及在qemu中运行的内存分布的疑问
[打印本页]
作者:
hackqiang
时间:
2012-05-17 18:17
标题:
有关ELF入口点及在qemu中运行的内存分布的疑问
本帖最后由 hackqiang 于 2012-05-17 18:18 编辑
有关ELF入口点及在qemu中运行的内存分布的疑问
编译了一个ecos系统,生成了elf格式的文件ecos.out,用qemu-system-arm(mini2440)加载运行,但是出现错误,于是用gdb调试(qemu做的gdbserver),
先看了ecos.out的elf信息:
readelf -h ecos.out
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: ARM
Version: 0x1
Entry point address: 0x8040
Start of program headers: 52 (bytes into file)
Start of section headers: 12011568 (bytes into file)
Flags: 0x4000002, has entry point, Version4 EABI
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: 21
Section header string table index: 18
复制代码
再看看段信息:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .debug_aranges PROGBITS 00000000 9724e0 004728 00 0 0 8
[ 2] .debug_pubnames PROGBITS 00000000 976c08 009d47 00 0 0 1
[ 3] .debug_info PROGBITS 00000000 98094f 117077 00 0 0 1
[ 4] .debug_abbrev PROGBITS 00000000 a979c6 022801 00 0 0 1
[ 5] .debug_line PROGBITS 00000000 aba1c7 0375ca 00 0 0 1
[ 6] .debug_frame PROGBITS 00000000 af1794 00ba24 00 0 0 4
[ 7] .debug_str PROGBITS 00000000 afd1b8 01adb4 01 MS 0 0 1
[ 8] .debug_loc PROGBITS 00000000 b17f6c 048e0c 00 0 0 1
[ 9] .fixed_vectors PROGBITS 00000020 b60d80 000140 00 0 0 32
[10] .rom_vectors PROGBITS 00008000 008000 000040 00 AX 0 0 1
[11] .text PROGBITS 00008040 008040 048200 00 AX 0 0 4
[12] .rodata PROGBITS 00050240 050240 920d38 00 A 0 0 8
[13] .data PROGBITS 00970f78 970f78 001568 00 WA 0 0 4
[14] .bss NOBITS 009724e0 9724e0 1cec70 00 WA 0 0 16
[15] .ARM.attributes ARM_ATTRIBUTES 00000000 b60ec0 000028 00 0 0 1
[16] .debug_ranges PROGBITS 00000000 b60ee8 011868 00 0 0 8
[17] .comment PROGBITS 00000000 b72750 001ffe 00 0 0 1
[18] .shstrtab STRTAB 00000000 b7474e 0000df 00 0 0 1
[19] .symtab SYMTAB 00000000 b74b78 010c80 10 20 3234 4
[20] .strtab STRTAB 00000000 b857f8 0086a0 00 0 0 1
复制代码
我的qemu中硬件RAM的地址是0x30000000,也就是说程序要从0x30008040开始跑,但是我调试了发现,在地址0x30000000-0x30008040间也在执行(使用 b *0x30000004; ni),但是0x30000000-0x30008040之间的数据就是ecos.out的拷贝,我的疑问是,为什么qemu没有直接从0x30008040跑,而是从0x30000000跑,0x30000000根本就不是text段,怎么能执行呢?
这样看来,是不是应该使用bin文件来供qemu加载?
作者:
tempname2
时间:
2012-05-17 18:48
嵌入式上应该先从ROM或者NOR FLASH开始跑BOOTLOADER吧。QEMU能直接把ELF文件加载到内存然后跳到ENTRY跑吗?好像有点印象,不过就算如此,第一条指令也会从0x8040开始。
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2