Understanding dynamic linking function calling mechanism
For a .so library, the elf linker primarily uses two processor-specific tables for dynamic linking, the Global Offset Table (GOT) and the Procedure Linkage Table (PLT).
The GOT within the application's executable file contains absolute addresses to locations in the shared library which the application references. It redirects address calculations to absolute locations in the shared library. Similarly, the PLT redirects all library function calls to their absolute locations. So a reference to a shared library function will directly transfer control to the function via the PLT without calling the dynamic ELF linker.
However, that said, the ELF linker's behavior can change depending on the state of the environment variables in the process environment. If 'lazy binding' is used by the ELF linker, the linker will then evaluate PLT entries on the first reference to each function in the library. To explain this further, the PLT entry will involve a jump to the GOT entry which contains an address that points back to the next instruction in the PLT. The linker is then called to resolve this function's address and copies it directly into the related GOT entry before executing the function itself. Subsequent calls to the function will not need to be resloved by the linker. But without late binding, all PLT entries are fully evaluated before even transferring control to the application.
So simply, a function call to a dll will behave differently depending on whether or not lazy binding is used by the linker, or whether the function is being referenced the first time in the execution of the program. In all cases though, the PLT and the GOT tables are used to handle dynamic library function calls.
Please contact us with your questions or concerns.