As mentioned using -fsanitize=address during compilation or .so file creation will automatically link libasan.so library right ?
I am facing issue :-
==13640==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
xrun: *E,ELBERR: Error during elaboration (status 1), exiting.
I found the same issue and fix for the same here :- https://github.com/google/sanitizers/issues/796
Firstly i try to use -fsanitize=address ,-static-libasan
flags to my gcc compiler and linker to created .so files. The created library file 'libsynsv.so
' itself don't show the 'asan' library as its dependency with ldd libsynsv.so
output.
My GCC command is :-
/libs/common/pkgs/gcc/v6.3.0p2/bin/gcc -m32 -shared -o /folder/workspace/san/client/src/main/cvip/asan/Release/denali/verilog/libsynsv.so -fsanitize=address -static-libasan -Wl,-rpath=\$ORIGIN/lib -Wl,-rpath=\$ORIGIN/../lib -Wl,-E -L/folder/workspace/san/client/src/main/cvip/asan/Release/modules /folder/workspace/san/client/src/main/cvip/asan/Release/modules/silvpi.o /folder/workspace/san/client/src/main/cvip/asan/Release/modules/sansv.o /folder/workspace/san/client/src/main/cvip/asan/Release/modules/cdnsv_tfs.o /folder/workspace/san/client/src/main/cvip/asan/Release/modules/libcore.o /folder/workspace/san/client/src/main/cvip/asan/Release/modules/vpi_user.o /folder/workspace/san/client/src/main/cvip/asan/Release/modules/libkenbase.a /folder/workspace/san/client/src/main/cvip/asan/Release/modules/libbdd.a -L/folder/workspace/san/client/src/main/cvip/asan/Release/denali/lib -L/folder/workspace/san/client/src/main/cvip/asan/Release/modules -L/home/denalibld/extlibs/lib /folder/workspace/san/client/src/main/cvip/asan/Release/modules/vhpimodelfunc.o /folder/workspace/san/client/src/main/cvip/asan/Release/modules/vipcommonlib.a /home/libs/test/lib/libdenz.a /home/libs/test/lib/libddom0.4.a -lm -lc -ldenbase -lbdd -ldenbase -lviputil -lcdsCommonMT_sh
ldd o/p of my library :-
ldd libsynsv.so
linux-gate.so.1 => (0x00d29000)
libm.so.6 => /lib/libm.so.6 (0x009b9000)
libc.so.6 => /lib/libc.so.6 (0x002a8000)
libviputil.so => /folder/san/client/src/main/cvip/asan/Release/verilog/../lib/libviputil.so (0xf7164000)
libcdsCommonMT_sh.so => /lan/workspace/san/client/src/main/cvip/asan/Release/verilog/../lib/libcdsCommonMT_sh.so (0x00121000)
librt.so.1 => /lib/librt.so.1 (0x00140000)
libdl.so.2 => /lib/libdl.so.2 (0x0099b000)
libpthread.so.0 => /lib/libpthread.so.0 (0x007ba000)
/lib/ld-linux.so.2 (0x00288000)
libz.so.1 => /lib/libz.so.1 (0x00947000)
libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0x00149000)
After i try to run my application with created library . It throws following error :
xmelab: *W,LIBLDFL: Failed to load dynamic library /folder/san/client/src/main/cvip/asan/Release/verilog/libsynsv.so:
/folder/san/client/src/main/cvip/asan/Release/verilog/../lib/libviputil.so: undefined symbol: __asan_option_detect_stack_use_after_return.
Is there any issue with my GCC command? Why my library was not linked to asan though i ran with -fsanitize-address.