我正在编译我的应用程序,它包含二进制文件和一些动态库。我的makefile使用
LDFLAGS=-Wl,-rpath='$$ORIGIN/../lib',-rpath=/opt/suse/lib64,--disable-new-dtags
对于没有asan的正常构建,这样可以在运行时首先在../lib中搜索所有库(直接链接和动态加载)。
当我使用带有-fsanitize = address的asan用于CXXFLAGS和LDFLAGS时,ld不再使用rpath来搜索动态加载的(dlopen)库。
echo $LD_LIBRARY_PATH
:/EDI_TOOLS/ORACLE/client:/home1/conic/Trafo/program/UmsetzerV19
strace输出:
open("tls/x86_64/Consumer_EndTransaction.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("tls/Consumer_EndTransaction.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("x86_64/Consumer_EndTransaction.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("Consumer_EndTransaction.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/EDI_TOOLS/ORACLE/client/Consumer_EndTransaction.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home1/conic/Trafo/program/UmsetzerV19/Consumer_EndTransaction.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/gcc/x86_64-suse-linux/5/Consumer_EndTransaction.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=83482, ...}) = 0
objdump -x给出了这个输出(更多,但rpath设置正确)。可以正确找到NEEDED中的所有库。
Dynamic Section:
NEEDED libasan.so.2
NEEDED libKernel.so
NEEDED libCUtil.so
NEEDED libApi.so
NEEDED libactivemq-cpp.so.19
NEEDED libnorm.so
NEEDED libcurl.so.4
NEEDED libcurlpp.so.0
NEEDED libutilspp.so.0
NEEDED libtdsodbc.so.0
NEEDED libicuuc.so.58
NEEDED libicui18n.so.58
NEEDED libxerces-c-3.1.so
NEEDED libxalan-c.so.111
NEEDED libldap60.so
NEEDED libclntsh.so.12.1
NEEDED libuuid.so.1
NEEDED libz.so.1
NEEDED libdl.so.2
NEEDED libstdc++.so.6
NEEDED libm.so.6
NEEDED libgcc_s.so.1
NEEDED libpthread.so.0
NEEDED libc.so.6
RPATH $ORIGIN/../lib:/opt/suse/lib64
我正在使用SLES 11
g++-5 (SUSE Linux) 5.3.1 20160301 [gcc-5-branch revision 233849]
GNU ld (GNU Binutils; SUSE Linux Enterprise 11) 2.25.0
ld.so-1.7.0
我错过了什么吗?
答案 0 :(得分:0)
似乎围绕dlopen()
的ASAN包装器改变了它的行为。看起来像以下错误:https://bugzilla.redhat.com/show_bug.cgi?id=1449604