1

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.