如何查找应用程序启动期间加载的共享对象?

发布于 2024-08-23 02:02:36 字数 309 浏览 3 评论 0原文

我知道使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

衣神在巴黎 2024-08-30 02:02:36

这已经太晚了,但是 -

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文