1

I know that using dlopen with RLTD_NOLOAD one can find out whether a shared object is already loaded or not. This, however, doesn't seem to work if a so is linked to the executable and loaded by the linker during application startup.

I mean, lets say I have mylib.so and load it with dlopen. Later, if I make dlopen with RLTD_NOLOAD, I get the handle as expected.

However, if I link mylib.so to the application ( -lmylib at the makefile ) dlopen returns NULL.

How can I get a handle to the shared object if it is directly linked to the exec. and not loaded explicitly?

Thanks in Advance

4

1 回答 1

1

这已经太晚了,但是——

dlopen(NULL, RTLD_LAZY/*Any load option u want*/)将获得二进制文件的句柄。它应该能够在它加载的二进制或共享库中找到任何符号。我认为这是一个很好的起点。

于 2010-10-14T09:00:37.577 回答