santosh
santosh

Reputation: 501

Building glib library with ASAN

i am working on building glib library with ASAN, gcc version is 6.3 .

I am able to compile and build glib library with ASAN. My configure command is :-

../configure  CC='/local/test/v6.3.0/bin/gcc' CXX='/local/test/v6.3.0/bin/g++' CFLAGS='-fPIC -O2 -fsanitize=address' CXXFLAGS='-fPIC -fsanitize=address' LDFLAGS='-L/local/test/v6.3.0/lib64 -lasan' LD_LIBRARY_PATH='/local/test/v6.3.0/lib64'  --enable-static=yes --prefix=/home/testing/debug_glib/glib-2.56.1/testing_glb --enable-libmount=no PYTHON=/local/test/pkgs/python/v2.7.6/bin/python --with-pcre=/home/testing/pcre_lib/pcre-8.20/pcre_library

Here when i try to use newly created glib library, I am hitting undefined reference to symbol issue :

$ /local/test/client_new/test_build/kkl/tools/kenzip -c dcltotb.tcl
/home/testing/lib/libglib-2.0.so: undefined symbol: __asan_option_detect_stack_use_after_return

I am linking ASAN library (-lasan) which has above symbol defined in it. Any thing missing here? Please help! Thanks in Advance.

Upvotes: 0

Views: 1182

Answers (2)

yugr
yugr

Reputation: 21886

First you need to correct your LDFLAGS to be

LDFLAGS=-fsanitize=address

Then, you need to preload libasan when running your unsanitized executable with

LD_PRELOAD=path/to/libasan.so /local/test/client_new/test_build/kkl/tools/kenzip -c dcltotb.tcl

Upvotes: 0

Philip Withnall
Philip Withnall

Reputation: 5705

Build the latest version of GLib (2.62.4). It is built using Meson, rather than autotools, and you can enable ASAN by passing -Db_sanitize=address to meson when configuring the build.

Upvotes: 1

Related Questions