How to use AddressSanitizer in gcc?

与世无争的帅哥 提交于 2019-11-27 07:34:53

You need to add the switch -lasan to your compile/link command line to link the correct library.

You need to add -fsanitize=address to both compiler flags (CFLAGS, CXXFLAGS) and linker flags (LDFLAGS). You've probably added it to your compiler flags only.

Note that using explicit -lasan option has been widely discouraged by ASan developers (e.g. here) as it misses some other important linker flags. The only recommended way to link is to use -fsanitize=address.

As a side note, for more aggressive verification flags check Asan FAQ (look for "more aggressive diagnostics").

Make sure you have libasan installed. For example, in Fedora:

dnf install libasan libasan-static

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