2

According to my understanding, for the .rodata, the compiler can simply put it "next" to the .text section, because it shares the same page permissions, so wherever the binary is loaded, an instruction can find the global vars in the .rodata through RIP-relative adressing But what about the data and bss since they are located at random distances to the .text section ?

1 Answer 1

1

AFAIK in the current ELF PIE implementations all sections/segments are assumed to be at a fixed offset from the load base, so RIP relative addressing continues to work.

In theory it is possible to place the r/w data area at a different offset but it would require major changes in the compiler and dynamic linker behavior. Also, the file format doesn’t really foresee this possibility.

From the major OSes I think currently only macOS does this (for the Mach-O format).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.