Linkers, Loaders & Executables
When dynamic linking uses lazy binding through the PLT (procedure linkage table), which statement is correct?
- AA shared-library function's address is resolved the first time it is called, and later calls jump straight to the resolved address
- BAll function addresses are always resolved before the program starts
- CThe library file is reread from disk on every call
Show answer and explanation
Answer: A. A shared-library function's address is resolved the first time it is called, and later calls jump straight to the resolved address
The program calls external functions through small PLT stubs. With lazy binding, the first call makes the stub jump to the dynamic linker's resolver, which finds the real address and writes it into the GOT. Later calls jump directly to the address in the GOT. Skipping resolution of unused functions speeds up start-up. For security, though, resolving everything at start-up and making the GOT read-only is also widely used.
- A. Correct. Functions never called are never resolved.
- B. That is immediate binding at start-up.
- C. The file is not reread from disk.