如何查找应用程序启动期间加载的共享对象?
我知道使用 dlopen 和 RLTD_NOLOAD 可以查明共享对象是否已加载。但是,如果将 so 链接到可执行文件并在应用程序启动期间由链接器加载,则这似乎不起作用。
我的意思是,假设我有 mylib.so 并使用 dlopen 加载它。稍后,如果我使用 RLTD_NOLOAD 进行 dlopen,我会按预期获得句柄。
但是,如果我将 mylib.so 链接到应用程序(makefile 中的 -lmylib ),dlopen 将返回 NULL。
如果共享对象直接链接到 exec,我怎样才能获得它的句柄。并且没有显式加载?
提前致谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这已经太晚了,但是 -
dlopen(NULL, RTLD_LAZY/*Any load option u Want*/)
将获得二进制文件的句柄。它应该能够在它加载的二进制或共享库中找到任何符号。我认为这是一个很好的起点。This is way too late, but -
dlopen(NULL, RTLD_LAZY/*Any load option u want*/)
will get a handle to the binary. And it is supposed to be able to find any symbol in the binary or shared libs it has loaded. I think that is a good place to start.