Undefined symbol error with -static-libasan
Asked Answered
P

1

4

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
Peep answered 11/10, 2017 at 7:24 Comment(0)
H
5

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: force a reference to missing symbol from your code:

extern "C" void __asan_unregister_globals();
extern "C" void __asan_register_globals();
__attribute__((used)) void *force_missing_symbols[] = {
  (void *)__asan_unregister_globals,
  (void *)__asan_register_globals
};

(you'll need to do this for all missing symbols).

Hallie answered 11/10, 2017 at 9:27 Comment(5)
What are the LDFLAGS ?Peep
@Janaka: Linker flags.Hallie
In this case, I need to keep my application independent from Oracle. So that won't be good solution for me.Peep
@Janaka: I added an (ugly) workaround. Or you can ask GCC maintainers to fix this by posting a comment in Bugzilla.Hallie
@Janaka: Did you have a chance to try suggested workarounds?Hallie

© 2022 - 2024 — McMap. All rights reserved.