In Linux, why are stubs required for standard libraries?
Share
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.
stubs are required to ensure proper linking of an executable across various linux releases without building the object files.
For example:
Let a be the executable we are building:
In the above case executable a has a dependency on the libz.so (
-lzis to link with libz.so). The linker resolves libz.so using the LD_LIBRARY_PATH.Now let us see the problem:
In RHEL5, we see an undefined symbol in the libz.so.
Unless we pass libc to the linker after lz in the above command, this cannot be resolved.
Stubs:
If we generate the stub for libz.so, packing all the symbols of libz.so in to a stub library and link with the stub library instead of the real library, we don’t see any errors:
Modified link line:
In the /home/lib/stubs directory, we have a stub library for libz.so by name libzstub.so.
Linker gives higher priority to the path given in the link command than LD_LIBRARY_PATH.
Now even if we link in the RHEL5 release, the linker resolves the symbols for the libz.so from the /home/lib/stubs directory.
Here the configuration details of the boxes i have used.
Loader takes care of loading the coresponding function at runtime.
RHEL5:
RHEL4: