问题描述
我有两个第三方库偶尔会导出相同的符号名称。当可执行文件加载时, ld 通常会选择错误的文件,结果导致崩溃。我不能做太多关于这些库的内容,所以可能有一种方法来指导 ld 如何找到适当的imlementation?
OS - Solaris 10,我的程序是由autoconf / autotools / gcc构建的,冲突的库是 libclntsh (Oracle驱动程序的一部分)和OpenLDAP。遗憾的是,我不能使用Oracle的LDAP客户端实现 - 它缺少OpenLDAP的许多功能。
编辑:链接如下:libclntsh.so-> A.so- > MAIN如果您不需要在两个共享库中链接编译时间(从你的问题中不清楚),你可以使用共享库 -Bdirect
。这将记录共享库中所有符号的位置;如果在运行时出现符号的第二个定义(来自其他共享库),它将被忽略。
I have two third-party libraries occasionally having the same symbol name exported. When the executable is loaded, ld usually picks the wrong one and I getting crash as a result. I cannot do too much about the content of these libraries, so may be there is a way to instruct ld how to find the proper imlementation ?
OS - Solaris 10, my program is built by autoconf/autotools/gcc, conflicting libraries are libclntsh (part of Oracle driver) and OpenLDAP. Unfortuinately, I cannot use Oracle's implementation of LDAP client - it lacks many features OpenLDAP has.
Edited: The linkage is as following: libclntsh.so->A.so->MAIN<-B.so<-libldap_r.so
If you don't need to link in both shared libraries at compile time (which isn't clear from your question), you can use -Bdirect
for the shared library. This will record for all symbols from the shared library where they had been found; if then at run-time a second definition of the symbol appears (from the other shared library), it will be ignored.
这篇关于从LD中隐藏共享对象中的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!