【问题标题】:Improper section to segment mapping in ELF executable binaryELF 可执行二进制文件中的段映射不正确
【发布时间】:2012-07-25 21:15:36
【问题描述】:

我正在使用 readelf 命令分析 ELF 文件。我查看了程序头和节头,但发现并非所有节都映射到一个段。我提供了部分 readelf 输出:

Section Headers:
[Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
[ 0]                   NULL            00000000 000000 000000 00      0   0  0
[ 1] ddr_data_nc_wt    NOBITS          70001800 0000b4 000000 00   W  0   0  1
[ 2] ddr_data_c_wb     NOBITS          70001800 0000b4 000000 00   W  0   0  1
[ 3] ddr_text_c        NOBITS          70001800 0000b4 000000 00   X  0   0  1
[ 4] m2_textboot_c     LOPROC+0        b0000000 0000c0 0023cc 00  AX  0 2952790016  2
[ 5] m2_text_c         LOPROC+0        38000000 002490 004d22 00  AX  0 2952799232 16
[ 6] m2_data_c_wb      LOPROC+5        70000000 0071c0 0006a8 00  WA  0 2952819200  2
[ 7] data_boot_c       LOPROC+5        20000000 007870 000100 00  WA  0 2953019392  4

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  Flg Align
LOAD           0x0000c0 0xb0000000 0xb0000000 0x023cc 0x023cc R E 0x2
LOAD           0x002490 0xb0002400 0xb0002400 0x04d22 0x04d22 R E 0x10
LOAD           0x0071c0 0xb0007200 0xb0007200 0x006a8 0x017a8 RW  0x2
LOAD           0x007870 0xb0038000 0xb0038000 0x00100 0x08000 RW  0x4

Section to Segment mapping:
Segment Sections...
  00     m2_textboot_c
  01
  02
  03

There is no dynamic section in this file.

There are no relocations in this file.

There are no unwind sections in this file.

我发现只有 m2_textboot_c 部分被映射到 Segment 00,但没有提及其他部分的映射位置。你能告诉我什么可能是错的,应该怎么做吗?

另外,我想知道是否有任何机制可以使用节头而不是程序头将 ELF 二进制文件加载到处理器上。我遇到的每个在线帮助都使用程序头文件加载二进制文件。

【问题讨论】:

    标签: linux-kernel linux-device-driver elf


    【解决方案1】:

    我发现只有 m2_textboot_c 部分被映射到 Segment 00,但没有提及其他部分的映射位置

    您可能已经使用“自定义”链接器脚本链接了此 ELF 图像。 那个脚本控制着部分到段的映射,它(显然)没有做你想让它对其他部分做的事情。

    【讨论】:

      【解决方案2】:

      我猜 readelf 通过查看虚拟地址来执行节地址到段的反向映射。您的段跨越虚拟地址空间 0xb0000000-0xb0040000,并且该地址空间中包含的唯一部分确实是 m2_textboot_c。

      记住这一点,您可能应该将 m2_text_c 和 m2_data_c_wb 部分分别重新映射到 0xb0002400 和 0xb0007200,以便它们匹配第二个和第三个代码段。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-10-16
        • 2013-11-25
        • 1970-01-01
        • 2011-09-27
        • 2016-11-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多