This is the mail archive of the gcc-patches@gcc.gnu.org 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]

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


pinskia@physics.uc.edu wrote:

> [...]
> Just a question: is the code that is in gcc.c supposed to be
> compatible with K+R C?
> 
> If so try to get around string concatenate, look at cc1_options in
> gcc.c for how do it right.

Good point.  I submit this patch instead:

2002-08-13  Frank Ch. Eigler  <fche@redhat.com>

	* gcc.c (MFWRAP_SPEC, MFLIB_SPEC): New macros, splitting MFLIB_SPEC.
	(mfwrap_spec, mflib_spec): Define corresponding vars.
	(static_specs): Define correponding spec aliases.
	(LINK_COMMAND_SPEC): Include -fmudflap refs to new spec aliases.
	(cpp_unique_options): Move -fmudflap MFCPP_SPEC clause here.
	(cc1_options): Move -fmudflap MFCC1_SPEC clause here.
	(MFCC1_SPEC, MFCPP_SPEC, MFLIB_SPEC): Remove macros and uses.

Index: 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.c	12 Aug 2002 01:33:16 -0000	1.324.2.7
+++ gcc.c	13 Aug 2002 21:34:17 -0000
@@ -544,18 +544,24 @@
 #define LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
 #endif
 
-/* general mudflap specs */
-#ifndef MFCPP_SPEC
-#define MFCPP_SPEC " %{fmudflap:-D_MUDFLAP}"
+/* mudflap specs */
+#ifndef MFWRAP_SPEC
+/* XXX: valid only if linking with static libmudflap.a */
+/* XXX: valid only for GNU ld */
+/* XXX: should exactly match hooks provided by libmudflap.a */
+#define MFWRAP_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\
+}"
 #endif
-
-#ifndef MFCC1_SPEC
-#define MFCC1_SPEC " %{fmudflap:-fmudflap -fno-builtin}"
-#endif
-
 #ifndef MFLIB_SPEC
-/* XXX hack */
-#define MFLIB_SPEC " %{fmudflap: --wrap=malloc --wrap=free --wrap=calloc --wrap=realloc -lmudflap}"
+#define MFLIB_SPEC " %{fmudflap: -lmudflap}"
 #endif
 
 /* config.h can define LIBGCC_SPEC to override how and when libgcc.a is
@@ -632,7 +638,8 @@
 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
     %(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t}\
     %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
-    %{static:} %{L*} %(link_libgcc) %o %{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}}\
+    %{static:} %{L*} %(mfwrap) %(mflib) \
+    %(link_libgcc) %o %{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}}\
     %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}"
 #endif
 
@@ -651,15 +658,17 @@
 #endif
 
 static const char *asm_debug;
-static const char *cpp_spec = CPP_SPEC MFCPP_SPEC;
+static const char *cpp_spec = CPP_SPEC;
 static const char *cpp_predefines = CPP_PREDEFINES;
-static const char *cc1_spec = CC1_SPEC MFCC1_SPEC;
+static const char *cc1_spec = CC1_SPEC;
 static const char *cc1plus_spec = CC1PLUS_SPEC;
 static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC;
 static const char *asm_spec = ASM_SPEC;
 static const char *asm_final_spec = ASM_FINAL_SPEC;
 static const char *link_spec = LINK_SPEC;
-static const char *lib_spec = LIB_SPEC MFLIB_SPEC;
+static const char *lib_spec = LIB_SPEC;
+static const char *mfwrap_spec = MFWRAP_SPEC;
+static const char *mflib_spec = MFLIB_SPEC;
 static const char *libgcc_spec = LIBGCC_SPEC;
 static const char *endfile_spec = ENDFILE_SPEC;
 static const char *startfile_spec = STARTFILE_SPEC;
@@ -692,6 +701,7 @@
  %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2 -D__GNUC_PATCHLEVEL__=%v3}\
  %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
  %{remap} %{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i\
+ %{fmudflap:-D_MUDFLAP}\
  %{E|M|MM:%W{o*}}";
 
 /* This contains cpp options which are common with cc1_options and are passed
@@ -717,7 +727,8 @@
  %{Qn:-fno-ident} %{--help:--help}\
  %{--target-help:--target-help}\
  %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\
- %{fsyntax-only:-o %j} %{-param*}";
+ %{fsyntax-only:-o %j} %{-param*}\
+ %{fmudflap:-fmudflap -fno-builtin}";
 
 static const char *asm_options =
 "%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}";
@@ -1392,6 +1403,8 @@
   INIT_STATIC_SPEC ("endfile",			&endfile_spec),
   INIT_STATIC_SPEC ("link",			&link_spec),
   INIT_STATIC_SPEC ("lib",			&lib_spec),
+  INIT_STATIC_SPEC ("mfwrap",			&mfwrap_spec),
+  INIT_STATIC_SPEC ("mflib",			&mflib_spec),
   INIT_STATIC_SPEC ("libgcc",			&libgcc_spec),
   INIT_STATIC_SPEC ("startfile",		&startfile_spec),
   INIT_STATIC_SPEC ("switches_need_spaces",	&switches_need_spaces),




- FChE


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