Why does the address of an internal symbol needs to be recorded in .got?
1
vote
0
answers
55
views
I am reading the blog https://eli.thegreenplace.net/2011/11/11/position-independent-code-pic-in-shared-libraries-on-x64
In the part "x64 PIC with data references - an example", it seems that the module is telling the dynamic linker to fill the absolute address of
myglob
into .got
, then the code get that address and read data from that address.
But why does the compiler have to do this, it's a symbol come from itself, why can't just use RIP-relative addressing to access this symbol? Is it because sometimes .data
of the module might be load to a unknown offset to .text
(instead of always loaded next to .text
)?
I mean, if address_of(myglob)-address_of(instruction_that_access_myglob)
is a certain value, why do we even have to know the absolute address of myglob
?
Asked by 炸鱼薯条德里克
(1435 rep)
Feb 14, 2019, 02:15 AM
Last activity: Feb 14, 2019, 02:24 AM
Last activity: Feb 14, 2019, 02:24 AM