免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2315 | 回复: 1

[其他] 有关ELF入口点及在qemu中运行的内存分布的疑问 [复制链接]

论坛徽章:
0
发表于 2012-05-17 18:17 |显示全部楼层
本帖最后由 hackqiang 于 2012-05-17 18:18 编辑

有关ELF入口点及在qemu中运行的内存分布的疑问
编译了一个ecos系统,生成了elf格式的文件ecos.out,用qemu-system-arm(mini2440)加载运行,但是出现错误,于是用gdb调试(qemu做的gdbserver),
先看了ecos.out的elf信息:
  1. readelf -h ecos.out
  2. ELF Header:
  3.   Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  4.   Class:                             ELF32
  5.   Data:                              2's complement, little endian
  6.   Version:                           1 (current)
  7.   OS/ABI:                            UNIX - System V
  8.   ABI Version:                       0
  9.   Type:                              EXEC (Executable file)
  10.   Machine:                           ARM
  11.   Version:                           0x1
  12.   Entry point address:               0x8040
  13.   Start of program headers:          52 (bytes into file)
  14.   Start of section headers:          12011568 (bytes into file)
  15.   Flags:                             0x4000002, has entry point, Version4 EABI
  16.   Size of this header:               52 (bytes)
  17.   Size of program headers:           32 (bytes)
  18.   Number of program headers:         1
  19.   Size of section headers:           40 (bytes)
  20.   Number of section headers:         21
  21.   Section header string table index: 18
复制代码
再看看段信息:
  1. Section Headers:
  2.   [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  3.   [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  4.   [ 1] .debug_aranges    PROGBITS        00000000 9724e0 004728 00      0   0  8
  5.   [ 2] .debug_pubnames   PROGBITS        00000000 976c08 009d47 00      0   0  1
  6.   [ 3] .debug_info       PROGBITS        00000000 98094f 117077 00      0   0  1
  7.   [ 4] .debug_abbrev     PROGBITS        00000000 a979c6 022801 00      0   0  1
  8.   [ 5] .debug_line       PROGBITS        00000000 aba1c7 0375ca 00      0   0  1
  9.   [ 6] .debug_frame      PROGBITS        00000000 af1794 00ba24 00      0   0  4
  10.   [ 7] .debug_str        PROGBITS        00000000 afd1b8 01adb4 01  MS  0   0  1
  11.   [ 8] .debug_loc        PROGBITS        00000000 b17f6c 048e0c 00      0   0  1
  12.   [ 9] .fixed_vectors    PROGBITS        00000020 b60d80 000140 00      0   0 32
  13.   [10] .rom_vectors      PROGBITS        00008000 008000 000040 00  AX  0   0  1
  14.   [11] .text             PROGBITS        00008040 008040 048200 00  AX  0   0  4
  15.   [12] .rodata           PROGBITS        00050240 050240 920d38 00   A  0   0  8
  16.   [13] .data             PROGBITS        00970f78 970f78 001568 00  WA  0   0  4
  17.   [14] .bss              NOBITS          009724e0 9724e0 1cec70 00  WA  0   0 16
  18.   [15] .ARM.attributes   ARM_ATTRIBUTES  00000000 b60ec0 000028 00      0   0  1
  19.   [16] .debug_ranges     PROGBITS        00000000 b60ee8 011868 00      0   0  8
  20.   [17] .comment          PROGBITS        00000000 b72750 001ffe 00      0   0  1
  21.   [18] .shstrtab         STRTAB          00000000 b7474e 0000df 00      0   0  1
  22.   [19] .symtab           SYMTAB          00000000 b74b78 010c80 10     20 3234  4
  23.   [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加载?

论坛徽章:
2
CU十二周年纪念徽章
日期:2013-10-24 15:41:34处女座
日期:2013-12-27 22:22:41
发表于 2012-05-17 18:48 |显示全部楼层
嵌入式上应该先从ROM或者NOR FLASH开始跑BOOTLOADER吧。QEMU能直接把ELF文件加载到内存然后跳到ENTRY跑吗?好像有点印象,不过就算如此,第一条指令也会从0x8040开始。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP