arm hello world not starting - 命令对齐而不是页面对齐

时间:2013-11-20 09:46:55

标签: linux embedded arm

我为armv6创建了一个hello world应用程序......但它没有启动

./hello.out
> Killed

ldd ./hello.out
> $ not a dynamic executable

/lib/ld-linux.so.3 --list ./hello.out
> ./hello.out: error while loading shared libraries: ./hello.out: ELF load command alignment not page-aligned

“命令对齐而非页面对齐”是什么意思?

1 个答案:

答案 0 :(得分:0)

这意味着ELF文件中的一个段不是页面对齐的。页面通常以4096(0x1000)字节边界对齐。

您可以使用readelf命令检查ELF文件,例如参见bash的程序头:

{ test: 1 }

两个$ readelf -l /bin/bash Elf file type is EXEC (Executable file) Entry point 0x419b80 There are 9 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align PHDR 0x0000000000000040 0x0000000000400040 0x0000000000400040 0x00000000000001f8 0x00000000000001f8 R E 8 INTERP 0x0000000000000238 0x0000000000400238 0x0000000000400238 0x000000000000001c 0x000000000000001c R 1 [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2] LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000 0x00000000000bca0c 0x00000000000bca0c R E 200000 LOAD 0x00000000000bcde0 0x00000000006bcde0 0x00000000006bcde0 0x0000000000003d1c 0x000000000000d4e8 RW 200000 DYNAMIC 0x00000000000bcdf8 0x00000000006bcdf8 0x00000000006bcdf8 0x0000000000000200 0x0000000000000200 RW 8 NOTE 0x0000000000000254 0x0000000000400254 0x0000000000400254 0x0000000000000044 0x0000000000000044 R 4 GNU_EH_FRAME 0x00000000000a8a00 0x00000000004a8a00 0x00000000004a8a00 0x0000000000002ea4 0x0000000000002ea4 R 4 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 10 GNU_RELRO 0x00000000000bcde0 0x00000000006bcde0 0x00000000006bcde0 0x0000000000000220 0x0000000000000220 R 1 部分的对齐方为LOAD。这是0x1000(4096)的正确倍数。