我有一个工具发出一个ELF,据我所知它符合规范。 Readelf输出看起来很好,但objdump拒绝反汇编任何东西。objdump将不会显示我的ELF部分
我已经简化了输入到一个单一的全局变量,并且“int main(void){return 0;}”来帮助调试 - 微小的段大小是正确的。
尤其objdump的似乎无法找到部分表:
$ objdump -h kernel.elf
kernel.elf: file format elf32-littlearm
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 0000001c ff000000 ff000000 00008000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000004 ff00001c ff00001c 0000801c 2**2
CONTENTS, ALLOC, LOAD, DATA
:
$ arm-none-linux-gnueabi-readelf -S davidm.elf
There are 4 section headers, starting at offset 0x74:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text NULL ff000000 000034 00001c 00 AX 0 0 4
[ 2] .data NULL ff00001c 000050 000004 00 WA 0 0 4
[ 3] .shstrtab NULL 00000000 000114 000017 00 0 0 0
$ arm-none-linux-gnueabi-objdump -h davidm.elf
davidm.elf: file format elf32-littlearm
Sections:
Idx Name Size VMA LMA File off Algn
我也有另外一个ELF,来自完全相同的对象构建,只能用普通工具链使用产生即使我从'known good'内核中剥离了.comment和.ARM.attributes部分(因为objdump需要它们),它仍然很高兴地列出了那里的部分,但是并没有在我的工具davidm.elf中列出。
我已经确认这两节的内容与readelf -x是相同的。
我唯一能想象的是ELF文件的布局是不同的,打破了BFD的一些期望,这可以解释为什么readelf(和我的工具)处理它很好,但objdump有麻烦。
完全readelf:
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: 0xff000000
Start of program headers: 84 (bytes into file)
Start of section headers: 116 (bytes into file)
Flags: 0x5000002, has entry point, Version5 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: 4
Section header string table index: 3
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text NULL ff000000 000034 00001c 00 AX 0 0 4
[ 2] .data NULL ff00001c 000050 000004 00 WA 0 0 4
[ 3] .shstrtab NULL 00000000 000114 000017 00 0 0 0
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 0x000034 0xff000000 0xff000000 0x00020 0x00020 RWE 0x8000
Section to Segment mapping:
Segment Sections...
00 .text .data
There is no dynamic section in this file.
There are no relocations in this file.
There are no unwind sections in this file.
No version information found in this file.
能在磁盘上的布局的侵略包装是造成麻烦?我是否违反了BFD期望,记录或其他方面的某些字节流对齐限制?
最后 - 这个文件不打算被映射到一个地址空间,加载器会将memcpy段的数据放到所需的位置,所以不需要播放mmap友好的文件对齐技巧。保持ELF较小更重要。
干杯, DavidM
编辑:有人问我要上传的文件,和/或提供 'objdump的-x'。所以我做了两个: davidm.elf
$ objdump -x davidm.elf
davidm.elf: file format elf32-littlearm
davidm.elf
architecture: arm, flags 0x00000002:
EXEC_P
start address 0xff000000
Program Header:
LOAD off 0x00000034 vaddr 0xff000000 paddr 0xff000000 align 2**15
filesz 0x00000020 memsz 0x00000020 flags rwx
private flags = 5000002: [Version5 EABI] [has entry point]
Sections:
Idx Name Size VMA LMA File off Algn
SYMBOL TABLE:
no symbols
你能上传坏比较readelf输出
感谢赶上这文件样本?或者至少输出'objdump -x'? –
当然可以;原始Q用链接和“objdump -x”输出更新。 –