mudflap/address sanitizer

摘录几篇文档,归纳一下:

mudflap:

编译时加上-fmudflap -lmudflap,编译出的程序在运行时会进行内存越界等检测。

gcc mudflap_test.c -fmudflap -lmudflap

仅限于GCC4.9之前的GCC版本:

The mudflap run time checker was removed in GCC 4.9 and it is superseded by Address Sanitizer. The mudflap options remain, but do nothing. This page applies only to earlier versions of GCC.

也就是说从GCC 4.9开始就mudflap就被Address Sanitizer(GCC 4.8引入)给替代了!~


address sanitizer:

gcc 4.8的一个很酷的新特性是内建的“地址消毒剂”:C/C++的内存错误检测器,例如,如果您访问了已经删除的内存,它会立刻报告。

它基本上是重写了malloc和free,并且在访问之前做内存检查(详情请看 项目wiki )。很显然它采用了一种非常高效的方式,因为相比于不做检查执行仅缓慢了2倍!
只要在编译器调用中添加-fsanitize=address -fno-omit-frame-pointer,在链接器调用中添加-fsanitize=address。
AddressSanitizer     , a fast memory error detector, has been added and can be     enabled via -fsanitize=address. Memory access     instructions will be instrumented to detect heap-, stack-, and     global-buffer overflow as well as use-after-free bugs. To get     nicer stacktraces, use -fno-omit-frame-pointer.

具体可参考后面的link。


相关link如下:

使用mudflap检查内存越界

http://hi.baidu.com/mgqw864/item/e082042126bbed3094f62b8f


http://blog.qt.digia.com/cn/2013/04/22/using-gccs-4-8-0-address-sanitizer-with-qt/

在Qt中使用gcc 4.8.0的地址消毒剂(Address Sanitizer)


下面两个link是关于GCC4.8的,里面也提到address sanitizer,附在这里。
http://www.infoq.com/cn/news/2013/03/gcc48_released

GCC 4.8发布,完成向C++的迁移

http://www.internetnews.com/blog/skerner/open-source-gcc-4.8-compiler-including-address-sanitizer-security.html
Open Source GCC 4.8 Compiler Including Address Sanitizer Security




你可能感兴趣的:(toolchain,arm,linux开发)