I have a gcc-compiled application linked against dynamic libraries. Is there a way to impose the order in which libraries are loaded? (In my case one library constructor uses resources set up by other library constructor).
Thanks.
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.
gccisn’t in-charge of loading the libraries, eitherld.sodoes it automatically when your program loads, or you do it manually as @jldupont suggests.And
ld.somight deliberately randomise the order to prevent return-to-stdlib attacks.So either:
That is when you get to the point of linking each shared library, make sure it includes
-l<dependentlib>in the link command. You can test this by creating a trival program that links only with that shared library – if it builds and runs, then the library contains all necessary dependent libs. This might help if ld.so loads the libraries in dependency order – which I think it has to do.