What is the search order for symbol lookup when resolving dynamic relocations?
When resolving symbols for a shared library does the loader first search in the ‘main executable’ (to let the main executable override definitions…) or what?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Per my understanding, each executable object has its own “lookup scope”:
LD_PRELOADfacility are added to the global lookup scope, right after the main executable.DF_SYMBOLICflag, then symbol references that originate within that object will look for definitions within the object before searching in the global lookup scope.dlopen()may have their own dependencies. If theRTLD_GLOBALflag was not set during the call todlopen(), these dependencies are added to the lookup scope for that object, but do not affect the global lookup scope. If theRTLD_GLOBALflag was passed todlopen(), then the shared object (and its dependencies) will be added to the “global” lookup scope, changing the behavior of subsequent symbol lookups.Ulrich Drepper’s guide “How to Write Shared Libraries” is recommended reading on this topic.