符号版本控制和 dlsym
我使用 dlopen
在程序中加载 pthread 库,并使用 dlsym
获取 pthread_create
和 pthread_join
的处理程序。
如何确保两个处理程序的版本兼容?我不在乎这些符号是新版本还是旧版本。我只是希望我使用的任何 pthread_create
都能与我得到的 pthread_join
很好地配合。
我知道有一个 dlvsym 可以向其传递显式版本号,但我不关心确切的版本号,因为我希望我的代码独立于库版本。
I load the pthread library in my program using dlopen
, and fetch handlers to pthread_create
and pthread_join
using dlsym
.
How can I ensure that both the handlers are of a compatible version? I do not care if the symbols are of new version or old versions. I just want that whatever pthread_create
I use to work well with the pthread_join
that I get.
I know there is a dlvsym
to which I can pass explicit version number, but I do not care about exact version numbers as I want my code to be independent of library versions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
版本控制存在的唯一原因是对针对古代版本的 glibc 编译的程序进行了糟糕的 ABI 兼容性尝试,而实际上这根本无法工作。 (他们已经悄悄地破坏了 ABI 至少一次,据我所知,这种方式是不兼容的。)忽略它。
The only reason the versioning exists is for a poor attempt at ABI-compatibility with programs compiled against ancient versions of glibc, which will not actually work anyway. (They've silently broken the ABI at least once in a way that, as far as I can tell, cannot be compatible.) Just ignore it.
听起来你需要“dladdr - 查找包含给定地址的共享对象”。
但是,由于您没有说明您正在使用什么平台,因此它可能不可用。
看看吧..
Sounds like you need "dladdr - find the shared object containing a given address".
However as you have not said what platform you are using, so it might not be available.
Have a look and see..