Asan:有关Asan库加载的问题 [英] Asan : Issue with asan library loading

查看:3958
本文介绍了Asan:有关Asan库加载的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的构建系统中,我们最近将ASAN工具(添加-fsanitize = address)集成到CFLAGS&还在链接时,创建库.so文件。
注意:-我们正在使用GCC 6.3编译器。

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.

这是我的gcc命令:-

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

我能够成功构建库 libspd.so 。但是,当我们尝试运行它时,由于上面提到的错误而失败。

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

我可以看到 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)

我们正在尝试使用'xrun '它在使用asan构建的构建之上运行模拟。
错误提示:您应该将运行时链接到您的应用程序我试图将完整的asan库路径添加到LD_LIBRARY_PATH,仍然面临相同的问题。

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!

推荐答案

您有几种解决方法:


  • 使用 -fsanitize = address
  • 构建主可执行文件
  • 摆脱 /etc/ld.so.preload 在测试计算机上

  • 通过 export ASAN_OPTIONS = verify_asan_link_order禁用检查(需要最近的GCC) = 0 ;但您必须确保 /etc/ld.so.preload 中的库不会截获对Asan重要的符号,例如malloc,free等,否则事情将开始崩溃

  • 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

这篇关于Asan:有关Asan库加载的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆