預(yù)處理(prepressing)
gcc -E hello.c -o hello.i
cpp hello.c > hello.i
編譯(compilation)
gcc -S hello.i -o hello.s
匯編(Assembly)
as hello.s -o hello.o
gcc -c hello.s -o hello.o
鏈接(Linking)
靜態(tài)鏈接: 模塊的拼接過(guò)程
ld -static crt1.o
匯編器代替人工計(jì)算目標(biāo)地址(Symbol)
- 地址和空間分配
- 符號(hào)決議
- 重定位
PLT工作原理
GOT表結(jié)構(gòu)
PLT
動(dòng)態(tài)重定位表
可重定位表結(jié)構(gòu)
ELF32_R_SYM(Elf32_Rel->r_info) = (Elf32_Rel->r_info) >> 8
重定位項(xiàng)對(duì)應(yīng)符號(hào)在符號(hào)表中的下標(biāo)
ELF32_R_TYPE(0x607) = 7课幕,對(duì)應(yīng)R_386_JUMP_SLOT