text relocations in shared objects?
when I compile the following code (file named d.c) using gcc
int var=10;
void fun( void ) {
var++;
int a=var;
}
with
gcc -c -o d.o -fPIC d.c
and call readelf -S there is a reloction section called .rela.text for the .text section
if I link the file to a shared object (reloctest.so) with
gcc -shared d.o -o reloctest.so
the relocation section vanishes
Is it guaranteed that there are no relocation for the .text segment in 开发者_运维百科shared objects? I think yes (due to relocations were added for PLT and DYN) but I'm not sure
Thanks for any answers
Basically yes.
If you want to fully understand it you should read understanding elf.
精彩评论