logoalt Hacker News

cataphracttoday at 1:32 AM1 replyview on HN

Assuming the symbol is defined in the library, when the static linker runs (ld -- we're not talking ld.so), it will decide whether the global variable is preemptable or not, that is, if it can be resolved to a symbol outside the dso. Generally, by default it is, though this depends on many things -- visibility attributes, linker scripts, -Bsymbolic, etc. If it is, ld will have the final code reach into the GOT. If not, it can just use instruction (PC) relative offsets.


Replies

gmueckltoday at 1:41 AM

I've never observed a (non-LTO) linker exchange instructions. I want to see an example before I can believe this.