Is there a flag or any other directive that I can use to force the Linux Dynamic Linker ld.so
to load all shared libraries at once at start of the program instead of lazy binding.
Essentially I want to turn off lazy binding.
Thanks
With dynamic linking, external symbols referenced in user code and defined in a shared library are resolved by the loader at load time. When you compile a program that uses shared libraries, they are dynamically linked to your program by default.
Static libraries – are bound to a program statically at compile time. Dynamic or shared libraries – are loaded when a program is launched and loaded into memory and binding occurs at run time.
By using dynamic linking, you can upgrade the routines in the shared libraries without relinking. This form of linking is the default and no additional options are needed. Static linking means that the code for all routines called by your program becomes part of the executable file.
Dynamic linking means that the code for some external routines is located and loaded when the program is first run. When you compile a program that uses shared libraries, the shared libraries are dynamically linked to your program by default.
Setting environment variable LD_BIND_NOW = 1
will do that.
Thanks to @skwllsp for the answer.
man ld sayes:
-z keyword
now - When generating an executable or shared library, mark it to tell the dynamic linker to resolve all symbols when the program is started, or when the shared library is linked to using dlopen, instead of deferring function call resolution to the point when the function is first called
http://linux.die.net/man/1/ld
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With