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.
gcc
isn't in-charge of loading the libraries, either ld.so
does it automatically when your program loads, or you do it manually as @jldupont suggests.
And ld.so
might deliberately randomise the order to prevent return-to-stdlib attacks.
So either:
-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.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