Asan : Issue with asan library loading

血红的双手。 提交于 2020-02-06 07:56:03

问题


In our build system we have recently integrated ASAN tool (adding -fsanitize=address) to CFLAGS & also while linking , creating library .so files. Note:- We are using GCC 6.3 compiler.

We are able to successfully build our code. But while running it fails with following issue:

==52215==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.

Here is my gcc command:-

/local/common/pkgs/gcc/v6.3.0/bin/gcc -m32 -shared -o /local/testing/build/new_tool/asan_build/syn/verilog/libspd.so  -Wl,-rpath=\$ORIGIN/lib -Wl,-rpath=\$ORIGIN/../lib -W1,-rpath=/local/common/gcc/v6.3.0/lib  -fsanitize=address -L/local/testing/build/new_tool/asan_build/modules /local/testing/build/new_tool/asan_build/modules/silvpi.o /local/testing/build/new_tool/asan_build/modules/sypsv.o /local/testing/build/new_tool/asan_build/modules/cdnsv_tfs.o /local/testing/build/new_tool/asan_build/modules/libcore.o /local/testing/build/new_tool/asan_build/modules/vpi_user.o /local/testing/build/new_tool/asan_build/modules/libdenbase.a /local/testing/build/new_tool/asan_build/modules/libbdd.a  -L/local/testing/build/new_tool/asan_build/syn/lib -L/local/testing/build/new_tool/asan_build/modules -L/home/local/outer/Linux/lib /local/testing/build/new_tool/asan_build/modules/vhpimodelfunc.o /local/testing/build/new_tool/asan_build/modules/vipcommonlib.a  -lm -lc -ldenbase -lbdd -ldenbase -lviputil -llocalCommonMT_sh

I am able to build library libspd.so successfully. But when we try to run it fails with above error i mentioned.

i can see the dependent library list of libspd.so

ldd /local/testing/build/new_tool/asan_build/syn/verilog/libspd.so
    linux-gate.so.1 =>  (0x00279000)
    libasan.so.3 => /local/pkgs/gcc/v6.3.0/lib/libasan.so.3 (0xf7175000)
    libm.so.6 => /lib/libm.so.6 (0x0014e000)
    libc.so.6 => /lib/libc.so.6 (0xf6f83000)
    libcdsCommonMT_sh.so => /local/testing/build/new_tool/asan_build/verilog/../lib/liblocalCommonMT_sh.so (0x00178000)
    libdl.so.2 => /lib/libdl.so.2 (0x00197000)

We are trying to run our application with 'xrun' where it runs simulation on top of my build which was build with asan. As error says : you should either link runtime to your application i was trying to add my complete asan library path to LD_LIBRARY_PATH, Still facing the same issue.

Not sure whats going wrong here. How can i resolve this issue?

Any idea? Thanks and regards!


回答1:


You have several ways to work around this:

  • build main executable with -fsanitize=address
  • get rid of /etc/ld.so.preload on your test machine
  • disable the check (need recent GCC) with export ASAN_OPTIONS=verify_asan_link_order=0; but you have to be sure that libraries from /etc/ld.so.preload do not intercept symbols important for Asan e.g. malloc, free, etc., otherwise things will start breaking


来源:https://stackoverflow.com/questions/59853730/asan-issue-with-asan-library-loading

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