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?
CodePudding user response:
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.