This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patches] fine grained bounds checking patches for gcc 4.0.4 and 3.4.6

I have updated the bounds checking patches for gcc 4.0.2 and 3.4.4 on
My patches are available from
I have tested them under CentOS 4.4 Linux and Solaris/SPARC 10.

The patches add a -fbounds-checking flag that adds bounds checking tests to pointer and array accesses. Richard Jones developed the patches against gcc-2.7 in 1995. Herman ten Brugge is the current maintainer and updates patches to the boundschecking project at sourceforge.

You may freely mix object modules compiled with and without bounds checking. The bounds checker also includes replacements for mem* and str* routines and can detect invalid calls against checked memory objects, even from modules compiled without bounds checking.

You can run the bounds checking gcc from its build area using the script /u/gnu/bgcc-x.y/gcc/bounds/bgcc
For more build information, see the files created by the patches in /u/gnu/bgcc-x.y/gcc/bounds/.

To build a bounds checking gcc:
 cd /u/gnu				# go to a work area
 tar xzf gcc-x.y.tar.gz		# unpack gcc
 mv gcc-x.y bgcc-x.y			# rename the gcc directory
 cd bgcc-x.y				# go to the bgcc directory
 patch -p1 -T < gcc-x.y-bgcc-x.y.pat	# apply the patches
 touch gcc/			# force a rebuild of .y and .c
 mkdir objdir				# make an object file area
 cd objdir				# enter the area
 /u/gnu/bgcc-x.y/configure		# initialize the build
 make bootstrap			# do the build

Here are some features of the patches:

* Modules compiled with and without bounds checking may be linked together without special preparation.
o Checked pointers may be passed to modules compiled without bounds checking.
o Structures containing pointers may be passed between modules compiled with and without bounds checking.
* Modules compiled without bounds checking still check some pointer accesses.
o Checked pointers (pointers created by malloc or by modules compiled with bounds checking) are checked in calls to the str* and mem* library functions and in calls to modules compiled with bounds checking.
o The checks are similar to a malloc debug library, except more powerful because they also check local and static variables created in modules compiled with checking.
* The GCC_BOUNDS_OPTS environment variable passes options to the bounds checker.
o The -never-fatal option continues after errors.
o The -print-heap option shows memory leaks.

William Bader

PC Magazine?s 2007 editors? choice for best Web mail?award-winning Windows Live Hotmail.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]