阅读《程序员的自我修改》第三章 中关于ELF 文件结构描述 关于重定位表 P79时候产生的问题。
文章中说只要有绝对地址的段,就会有重定位。但是readelf -S helloWorld.o时候,里面有printf 时候并没有出现重定向?
#include
int main()
{
printf("hello\n");
return 0;
}
deadpool@deadpool-K53SD:~/elffun.d$ readelf -S helloWorld.o
共有 30 个节头,从偏移量 0x1800 开始:
节头:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .interp PROGBITS 08048154 000154 000013 00 A 0 0 1
[ 2] .note.ABI-tag NOTE 08048168 000168 000020 00 A 0 0 4
[ 3] .note.gnu.build-i NOTE 08048188 000188 000024 00 A 0 0 4
[ 4] .gnu.hash GNU_HASH 080481ac 0001ac 000020 04 A 5 0 4
[ 5] .dynsym DYNSYM 080481cc 0001cc 000050 10 A 6 1 4
[ 6] .dynstr STRTAB 0804821c 00021c 00004a 00 A 0 0 1
[ 7] .gnu.version VERSYM 08048266 000266 00000a 02 A 5 0 2
[ 8] .gnu.version_r VERNEED 08048270 000270 000020 00 A 6 1 4
[ 9] .rel.dyn REL 08048290 000290 000008 08 A 5 0 4
[10] .rel.plt REL 08048298 000298 000018 08 AI 5 12 4
[11] .init PROGBITS 080482b0 0002b0 000023 00 AX 0 0 4
[12] .plt PROGBITS 080482e0 0002e0 000040 04 AX 0 0 16
[13] .text PROGBITS 08048320 000320 000192 00 AX 0 0 16
[14] .fini PROGBITS 080484b4 0004b4 000014 00 AX 0 0 4
[15] .rodata PROGBITS 080484c8 0004c8 00000e 00 A 0 0 4
[16] .eh_frame_hdr PROGBITS 080484d8 0004d8 00002c 00 A 0 0 4
[17] .eh_frame PROGBITS 08048504 000504 0000cc 00 A 0 0 4
[18] .init_array INIT_ARRAY 08049f08 000f08 000004 00 WA 0 0 4
[19] .fini_array FINI_ARRAY 08049f0c 000f0c 000004 00 WA 0 0 4
[20] .jcr PROGBITS 08049f10 000f10 000004 00 WA 0 0 4
[21] .dynamic DYNAMIC 08049f14 000f14 0000e8 08 WA 6 0 4
[22] .got PROGBITS 08049ffc 000ffc 000004 04 WA 0 0 4
[23] .got.plt PROGBITS 0804a000 001000 000018 04 WA 0 0 4
[24] .data PROGBITS 0804a018 001018 000008 00 WA 0 0 4
[25] .bss NOBITS 0804a020 001020 000004 00 WA 0 0 1
[26] .comment PROGBITS 00000000 001020 000052 01 MS 0 0 1
[27] .shstrtab STRTAB 00000000 001072 000106 00 0 0 1
[28] .symtab SYMTAB 00000000 001178 000430 10 29 45 4
[29] .strtab STRTAB 00000000 0015a8 000255 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
deadpool@deadpool-K53SD:~/elffun.d$ gcc helloWorld.c -o helloWorld.o
等待后续看