我有以下简单的“hello world”程序:
#include <stdio.h>
int main() {
printf("Hello world.\n");
return 0;
}
我将其编译为
gcc -static -O0 -g -std=gnu11 -o test_helloworld test_helloworld.c -lpthread
现在,我想通过发出检查它的内存段readelf -l
并获得以下输出:
Elf file type is EXEC (Executable file)
Entry point 0x400890
There are 6 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000
0x00000000000c96cf 0x00000000000c96cf R E 200000
LOAD 0x00000000000c9eb8 0x00000000006c9eb8 0x00000000006c9eb8
0x0000000000001c98 0x00000000000035b0 RW 200000
NOTE 0x0000000000000190 0x0000000000400190 0x0000000000400190
0x0000000000000044 0x0000000000000044 R 4
TLS 0x00000000000c9eb8 0x00000000006c9eb8 0x00000000006c9eb8
0x0000000000000020 0x0000000000000050 R 8
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 10
GNU_RELRO 0x00000000000c9eb8 0x00000000006c9eb8 0x00000000006c9eb8
0x0000000000000148 0x0000000000000148 R 1
我对Align
列感到困惑:这些数字是字节还是千字节?我认为对齐应该等于页面大小。为什么我得到那些号码?
谢谢!