So I am trying to learn about dynamic linking. On SysV ABI on amd64, functions from other shared libraries can be loaded lazily via the Procedure Linkage Table by initializing the GOT entry for the function to point at the next instruction in its plt entry. This will eventually pass control on to the dynamic linker that will load the library, update the GOT entry and jump to function. Now for other global symbols that are not functions (do not have PLT entries), how or when will they be initialized? Can it be done lazily?
Asked
Active
Viewed 56 times
1 Answers
0
This will eventually pass control on to the dynamic linker that will load the library, update the GOT entry and jump to function
This is only partially correct: the library will normally already be loaded, and the loader only resolves the symbol and updates the GOT
entry to point to the symbol definition.
Now for other global symbols that are not functions (do not have PLT entries), how or when will they be initialized?
When the library (or executable) referencing the symbol is loaded, the loader resolves all the data symbols in it, before making it available.
Can it be done lazily?
No.
See also this answer.

Employed Russian
- 199,314
- 34
- 295
- 362
-
Thank you very much for your answer. It cleared many things up. However, if the loader can resolve GOT entry values for symbols at load time, why then even have a separate PLT for functions and lazily update the GOT entry for them? – Siam Habib Nov 11 '21 at 10:17
-
@SiamHabib This answer is probably worth a read: https://stackoverflow.com/a/68605780/50617 – Employed Russian Nov 11 '21 at 14:36