Results 1 to 6 of 6
Hi all,
I am using Linux OS ... my application XYZ uses shared libraries libA.so, and libB.so.
When application XYZ is started .... the libA.so and libB.so are loaded automatically ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 11-09-2010 #1Just Joined!
- Join Date
- Oct 2010
- Posts
- 5
Shared libraries auto load when app starts up
Hi all,
I am using Linux OS ... my application XYZ uses shared libraries libA.so, and libB.so.
When application XYZ is started .... the libA.so and libB.so are loaded automatically (given that the env variable LD_LIBRARY_PATH is properly set) ...
If I want to validate the integrity of these libs before they are loaded, how am I going to do about that?
I understand that if I explicitly call dlopen in my C/C++ app, I can write wrappter to the dlopen to validate the libraries before calling the actual dlopen ...
But in the case of auto loading shared libraries at startup time, do I need to do anything with kernel for this purpose or how can I do this?
Thanks,
Dang
- 11-09-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,142
Not so easy with C. Not so hard w/ C++ where you can execute code in your initialization blocks before main() is called. Define in a header something like this:
This should be one of the first headers your application code sees so the validation gets priority in initialization.Code:// Inline function. bool validate_libs() { // Validate libraries here if (!valid_libs) { ::abort(); } return true; } bool libs_are_valid = validate_libs();Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 11-09-2010 #3Just Joined!
- Join Date
- Oct 2010
- Posts
- 5
Thanks,
Will the inline function be called before all dependent shared libraries loaded ?
I will give it a try ....
Thanks,
Dang
========================
I gave it a try .. and it did load the shared libraries before calling the inline functions ...
I need to validate the libraries before they are loaded to memory ... Is that correct
the loading of the shared libraries to memory handled by the Kernel ?
Thanks
DangLast edited by uonedang71; 11-09-2010 at 03:43 PM.
- 11-10-2010 #4Just Joined!
- Join Date
- Dec 2009
- Location
- California
- Posts
- 89
Why do you need to validate them?
If it's for some sort of security reason, then I would suggest you compile your binary staticly and avoid shared libraries all together.
- 11-10-2010 #5Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,142
I would agree with this, to statically link your applications. After all, it is likely that the validation code requires something in the system shared libraries at least, so that they still have to be loaded first. I'm not sure, but there may be a way to delay loading of certain shared libraries until they are actually needed. I've not needed to do this myself, so I cannot say for sure it is possible.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 11-10-2010 #6Just Joined!
- Join Date
- Oct 2010
- Posts
- 5
Thanks folks,
I would probably compile these libraries statically ...
Thanks
Dang


Reply With Quote

