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]

[tree-ssa mudflap] preferred technique for wrapping symbols?


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


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}"
 /* config.h can define LIBGCC_SPEC to override how and when libgcc.a is

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