This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa mudflap] preferred technique for wrapping symbols?
- From: graydon at redhat dot com
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 13 Aug 2002 13:37:50 -0400
- Subject: [tree-ssa mudflap] preferred technique for wrapping symbols?
- Reply-to: graydon at redhat dot com
Hi,
Part of the work on mudflap (a memory checking extension) involves
wrapping common libc entries at link-time. There are two motivations:
memory allocation functions must be wrapped to track the regions which
are valid, and also several of the more "low level" bulk memory
operations in libc (mem*, b* and str*) are useful places to insert a
single "cheap" argument-sanity check, rather than rebuilding all of
glibc with mudflap and checking each memory read or write.
Previously we wrapped functions using a gcc spec entry containing
multiple --wrap=foo options. As the list of functions we wish to wrap
has grown, this has started to look a little ugly. We are now
wondering if there is a preferred technique for wrapping a number of
functions simultaneously.
If not, the following patch is submitted for approval on the tree-ssa
branch.
-graydon
Index: gcc/gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.324.2.7
diff -u -r1.324.2.7 gcc.c
--- gcc/gcc.c 12 Aug 2002 01:33:16 -0000 1.324.2.7
+++ gcc/gcc.c 13 Aug 2002 17:19:34 -0000
@@ -555,7 +555,15 @@
#ifndef MFLIB_SPEC
/* XXX hack */
-#define MFLIB_SPEC " %{fmudflap: --wrap=malloc --wrap=free --wrap=calloc --wrap=realloc -lmudflap}"
+#define MFLIB_SPEC " %{fmudflap: --wrap=malloc --wrap=free" \
+" --wrap=calloc --wrap=realloc --wrap=memcpy --wrap=memmove" \
+" --wrap=memset --wrap=memcmp --wrap=memchr --wrap=memrchr" \
+" --wrap=strcpy --wrap=strncpy --wrap=strcat --wrap=strncat" \
+" --wrap=strcmp --wrap=strcasecmp --wrap=strncmp --wrap=strncasecmp" \
+" --wrap=strdup --wrap=strndup --wrap=strchr --wrap=strrchr" \
+" --wrap=strstr --wrap=memmem --wrap=strlen --wrap=strnlen" \
+" --wrap=bzero --wrap=bcopy --wrap=bcmp --wrap=index --wrap=rindex" \
+" -lmudflap}"
#endif
/* config.h can define LIBGCC_SPEC to override how and when libgcc.a is