As we know, any executable file, which is running, is loaded into RAM.
Also, we have two kinds of libs: static link library and dynamic link library.
The two kinds of libs should be loaded into RAM too while they are needed.
As I know, we have two ways to load the dynamic library:
- link it while compiling, such as
g++ -lsofile - load dynamically in the code, we have
dlopento do this
I've post this question but I can't still make sure that we could list all lib files. For the first case above, I think we can get the link file with ldd, or check /proc/{PID}/maps. But for the second case, I'm thinking if I can get the link files with some method, here is an example:
void SomeModule()
{
//dlopen here to link mysofile
}
int main()
{
if (user_enter == 'a')
{
printf("hello world");
}
else
{
SomeModule();
}
}
In this example, when we execute it and type always a, the dlopen will never be called, so mysofile will never be linked, which means that mysofile will never be loaded into RAM. Am I right?
If so, how can I get the necessary lib files of the executable file except reading the source code?