构建带内存错误检查的gcc
——
http://gcc.gnu.org/
2. 下载gcc扩展boundschecking。
http://sourceforge.net/projects/boundschecking/
3. 给gcc打上补丁。
[root@localhost toolchain]# tar jxvf /mnt/hgfs/linux/gcc-3.4.2.tar.bz2
[root@localhost toolchain]# bzip2 -d bounds-checking-gcc-3.4.2-1.00.patch.bz2
[root@localhost toolchain]# cd gcc-3.4.2/
[root@localhost gcc-3.4.2]# patch -p1 -s < ../bounds-checking-gcc-3.4.2-1.00.patch
4. 编译
[root@localhost gcc-3.4.2]# cd ..
[root@localhost toolchain]# mkdir build
[root@localhost toolchain]# cd build/
[root@localhost build]# ../gcc-3.4.2/configure --prefix=/opt/gcc-3.4.2-bc
[root@localhost build]# make;make install
5. 使用
编译时加”-g -fbounds-checking”,-g是为了让bounds-cheking能找到符号表,报告 出现错误的源代码位置。如果是编译共享库,还要链接libbounscheking.a库。
~~end~~
评论