Undefined symbol error with -static-libasan

帅比萌擦擦* 提交于 2019-12-11 03:28:53

问题


I use address sanitizer to sanitize my application, Which is linked with SOCI. But that prompt followijg error message while using with Oracle.

./SociUT: symbol lookup error: /home/testhome/libs/libsoci_oracle.d.so.1.4.18: undefined symbol: __asan_unregister_globals

Here is the build output of aplication

/home/rel/GCC/asan-gcc-4.9.3/bc0232/bin/g++ -std=c++11  -g3 -static-libasan -fsanitize=address -fno-omit-frame-pointer  -L/home/mt_1/4/4.7.c/build/bc0397/tech/MB/link/API/63  -L/usr/lib64  -L/usr/lib64  -L/home/janaka077/mt-git/mt-database/mt_1/database_SOCI_Core/bin  -L/usr/local/boost_1_59_0/stage/lib  -L/usr/local/boost_1_59_0/stage/lib  -L/usr/local/gtest-1.7.0/lib/.libs   -o SociUT Main.o version.o  -lmb.d -lrdmacm -libverbs -lxml2 -lmsoci.d -lboost_date_time -lboost_filesystem -lboost_system -lboost_serializion -lboost_thread -lboost_chrono -lgtest -lz  -lnsl -lrt -ldl -lz -lcrypt -lnuma

回答1:


This is GCC PR 64234. At some point I may even get to fixing it)

Can you use dynamic runtime instead (i.e. remove -static-libasan)? Another option is adding -lsoci_oracle.d to LDFLAGS (this would inform GCC to export necessary symbols). Or you can add a really silly workaround i.e. force a reference to missing symbol from your code:

extern "C" void __asan_unregister_globals(void *globals, size_t n);
void *force_missing_symbol = (void *)__asan_unregister_globals;

(you'll need to do this for all missing symbols, prototypes can be obtained from this header).



来源:https://stackoverflow.com/questions/46682210/undefined-symbol-error-with-static-libasan

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!