Trying to understand how the relocation happens in the situation below
I have a shared library libbigshr.so which uses another shared library libfunlib.so. In the latter I have declared this global variable foo. To compile the former I had to do forward declaration as extern int foo
.
.rel.dyn at libbigshr.so
Offset Info Type Sym.Value Sym. Name
000005a5 00000401 R_386_32 00000000 foo
000005ab 00000401 R_386_32 00000000 foo
000005c7 00000401 R_386_32 00000000 foo
.rel.dyn at libfunlib.so
000005a5 00000901 R_386_32 00002010 foo
In the libfunlib the translation offset is proper value (0x2010), therefore I don't have problem. But wanted to know the how the correct addresses were inserted in libbigshr. I can understand, that once a variable has been allocated the memory and its location is identified the same can be used everywhere else. But I am interested in the procedure of doing so.
Due to my ignorance my question may not have sufficient data to answer it - so please let me know and I will furnish more details.