In Linux, references to shared libraries are resolved by default when the library is effectively called in your code. This is called lazy biding. Thus all binaries are not executable by the processor. Most of them are in fact interpreted (see /lib64/ld-linux-*.so
).
To perform that, the ELF binary contains two specific tables :
- the Procedure linkage table (PLT)
- the Global offset table (GOT)
The code you're executing references the PLT which performs the redirections. On the first call the GOT will contain a callback address which if executed jumps to the loader which will resolve the address to the dynamic library. The library is mapped in the virtual memory of your program, even though it is only present once in your physical memory.
You're using virtual memory so the addresses seen by your processes will be likely different thus the use of one GOT per process. As for the use of two tables : its principally for security reasons so you're never executing instructions from a writable page.
You can disable lazy biding if you wish by setting the LD_BIND_NOW
environment variable.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…