Search code examples
linkerld

What is prelinking in the context of ld.so mean and how does LD_TRACE_PRELINKING affect it


I'm trying to understand all the ways can I manipulate ld.so, and I can't understand the documentation for the LD_TRACE_PRELINKING environment variable.

The manpage says:

       LD_TRACE_PRELINKING (since glibc 2.4)
              If this environment variable is defined, trace prelinking of the object whose name is assigned to this environment variable.  (Use ldd(1) to get a list of the objects that might be traced.)  If the object name is not recognized, then
              all prelinking activity is traced.

Which is not terribly useful since I can't find any information about what is prelinking of an object in the context ld.so, and whether or not it's also traced when activating LD_TRACE_LOADED_OBJECTS.

So, what is prelinking in ld.so and how does LD_TRACE_PRELINKING affects ld.so?


Solution

  • The dynamic loader/linker (like ld.so) has to perform symbol resolution and binding operations at the start of program execution and when shared libraries are dynamically loaded. Some of these activities can be performed in advance without actually executing program code and the results can be cached for use during actual execution. This improves startup time and overall program execution time. On linux, prelink is the tool that drives this optimization, with the core functionality implemented in ld.so.