Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to find the differance between RTLD_NOW and RTLD_LAZY flags. My query is why RTLD_LAZY loading the library whose function I've never referanced.
now I want to check which libraries are loaded by cd /proc/<pid>
and vi maps
Here it looks that before fun5.so calling no nonstansard libray is loaded and after calling fun5 function all fun5.so,fun1.so and fun.2.so are loaded as per expectation.Now if I replace RTLD_NOW by RTLD_LAZY then only fun5.so and fun1.so should be loaded because I have never called fun() and fun2() , but actually fun2.so is also loading.so where am I wrong? Am I wrong at creating fun5.so? if so then how should I create it?
Thanks for your reply.
but as per the man page RTLD_LAZY Only resolve symbols as the code that references them is executed and I've never called fun() or fun2() to execute.In fun5.c I've only defined those function and never called.
Thanks for your reply.
but as per the man page RTLD_LAZY Only resolve symbols as the code that references them is executed and I've never called fun() or fun2() to execute.In fun5.c I've only defined those function and never called.
You did call the function fun5 in fun5.so. And that required it to be loaded - and in turn that required fun2.so.
Had you NOT called fun5, then neither library would have been loaded.
Both get loaded because it is an explicit dependency between fun5.so and fun2.so. If the application is going to call fun5, then both libraries MUST be loaded. dlopen has no way to know ahead of time if fun2 is/is not going to be needed - and doesn't have any way to determine that.
Now if fun5 used dlopen to load the fun2.so with a lazy open then it would only be loaded IF something fun5 did called a function in fun2.so.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.