PATCH: BPs for fixinc

Greg McGary greg@mcgary.org
Tue Aug 22 03:37:00 GMT 2000


This patch allows us to build crt*.o properly (never build with bounds
checking), and to build fixinc when bootstrapping with bounds checks.
The gnu-regex.c change is already checked into glibc's regex.c.

make bootstrap; make -C gcc compare; make check:

native i686-pc-linux:		no build or test suite regressions
native sparc-sun-solaris2.6:	no build or test suite regressions

OK to commit?

2000-08-21  Greg McGary  <greg@mcgary.org>

	* Makefile.in (crt*.o): Forcibly inhibit bounds checking.
	(fixinc.sh): Pass CC, CFLAGS and LDFLAGS to mkfixinc.sh
	* fixinc/Makefile.in (fixincl): Pass $(LDFLAGS) to $(CC).
	* fixinc/mkfixinc.sh: Pass $CC, $CFLAGS and $LDFLAGS to $MAKE.
	* fixinc/gnu-regex.c (SET_HIGH_BOUND, MOVE_BUFFER_POINTER,
	ELSE_EXTEND_BUFFER_HIGH_BOUND): New macros.
	(EXTEND_BUFFER): Use them.

Index: gcc/Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Makefile.in,v
retrieving revision 1.495
diff -u -p -r1.495 Makefile.in
--- Makefile.in	2000/08/20 14:57:15	1.495
+++ Makefile.in	2000/08/21 23:34:54
@@ -1026,14 +1026,14 @@ stmp-multilib: $(LIBGCC_DEPS)
 $(T)crtbegin.o: crtstuff.c $(GCC_PASSES) $(CONFIG_H) \
   defaults.h frame.h gbl-ctors.h stmp-int-hdrs tsystem.h
 	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
-	  -finhibit-size-directive -fno-inline-functions \
+	  -finhibit-size-directive -fno-inline-functions -fno-bounded-pointers \
 	  -fno-exceptions $(CRTSTUFF_T_CFLAGS) @inhibit_libc@ \
 	  -c $(srcdir)/crtstuff.c -DCRT_BEGIN -o $(T)crtbegin$(objext)
 
 $(T)crtend.o: crtstuff.c $(GCC_PASSES) $(CONFIG_H) \
   defaults.h frame.h gbl-ctors.h stmp-int-hdrs tsystem.h
 	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
-	  -finhibit-size-directive -fno-inline-functions \
+	  -finhibit-size-directive -fno-inline-functions -fno-bounded-pointers \
 	  -fno-exceptions $(CRTSTUFF_T_CFLAGS) @inhibit_libc@ \
 	  -c $(srcdir)/crtstuff.c -DCRT_END -o $(T)crtend$(objext)
 
@@ -1041,7 +1041,7 @@ $(T)crtend.o: crtstuff.c $(GCC_PASSES) $
 $(T)crtbeginS.o: crtstuff.c $(GCC_PASSES) $(CONFIG_H) \
   defaults.h frame.h gbl-ctors.h stmp-int-hdrs tsystem.h
 	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
-	  -finhibit-size-directive -fno-inline-functions \
+	  -finhibit-size-directive -fno-inline-functions -fno-bounded-pointers \
 	  -fno-exceptions $(CRTSTUFF_T_CFLAGS_S) @inhibit_libc@ \
 	  -c $(srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFS_O \
 	  -o $(T)crtbeginS$(objext)
@@ -1049,7 +1049,7 @@ $(T)crtbeginS.o: crtstuff.c $(GCC_PASSES
 $(T)crtendS.o: crtstuff.c $(GCC_PASSES) $(CONFIG_H) \
   defaults.h frame.h gbl-ctors.h stmp-int-hdrs tsystem.h
 	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
-	  -finhibit-size-directive -fno-inline-functions \
+	  -finhibit-size-directive -fno-inline-functions -fno-bounded-pointers \
 	  -fno-exceptions $(CRTSTUFF_T_CFLAGS_S) @inhibit_libc@ \
 	  -c $(srcdir)/crtstuff.c -DCRT_END -DCRTSTUFFS_O \
 	  -o $(T)crtendS$(objext)
@@ -1078,7 +1078,8 @@ c-errors.o: c-errors.c $(CONFIG_H) syste
 c-parse.o : $(srcdir)/c-parse.c $(CONFIG_H) $(TREE_H) c-lex.h $(GGC_H) \
     $(srcdir)/c-parse.h c-tree.h c-common.h input.h flags.h system.h \
     toplev.h output.h
-	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -c $(srcdir)/c-parse.c
+	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
+		-DYYFILE=\"$(srcdir)/c-parse.y\" -c $(srcdir)/c-parse.c
 $(srcdir)/c-parse.h: $(srcdir)/c-parse.c
 $(srcdir)/c-parse.c: $(srcdir)/c-parse.y
 	cd $(srcdir); $(BISON) $(BISONFLAGS) -d -o c-parse.c c-parse.y
@@ -1964,7 +1965,8 @@ fixinc.sh: $(FIXINCSRCDIR)/mkfixinc.sh $
 	$(FIXINCSRCDIR)/server.c $(FIXINCSRCDIR)/gnu-regex.h \
 	$(FIXINCSRCDIR)/server.h $(FIXINCSRCDIR)/inclhack.def specs.ready
 	MAKE="$(MAKE)"; srcdir=`cd $(srcdir)/fixinc; pwd` ; \
-	export MAKE srcdir ; \
+	CC="$(CC)"; CFLAGS="$(CFLAGS)"; LDFLAGS="$(LDFLAGS)"; \
+	export MAKE srcdir CC CFLAGS LDFLAGS; \
 	cd ./fixinc; $(SHELL) $${srcdir}/mkfixinc.sh $(target)
 
 # Build fixed copies of system files.
Index: gcc/fixinc/Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/Makefile.in,v
retrieving revision 1.23
diff -u -p -r1.23 Makefile.in
--- Makefile.in	2000/05/31 15:03:41	1.23
+++ Makefile.in	2000/08/21 23:34:55
@@ -73,7 +73,7 @@ all : $(TARGETS)
 gen : fixincl.x
 
 fixincl: $(OBJ) $(LIBERTY)
-	$(CC) $(FIXINC_DEFS) -o $@ $(OBJ) $(LIBERTY)
+	$(CC) $(FIXINC_DEFS) $(LDFLAGS) -o $@ $(OBJ) $(LIBERTY)
 
 $(OBJ)      : $(HDR)
 fixincl.o   : fixincl.x fixincl.c
Index: gcc/fixinc/gnu-regex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/gnu-regex.c,v
retrieving revision 1.5
diff -u -p -r1.5 gnu-regex.c
--- gnu-regex.c	2000/05/10 13:47:35	1.5
+++ gnu-regex.c	2000/08/21 23:34:57
@@ -1617,6 +1617,26 @@ static reg_errcode_t compile_range _RE_A
    reset the pointers that pointed into the old block to point to the
    correct places in the new one.  If extending the buffer results in it
    being larger than MAX_BUF_SIZE, then flag memory exhausted.  */
+#if __BOUNDED_POINTERS__
+# define SET_HIGH_BOUND(P) (__ptrhigh (P) = __ptrlow (P) + bufp->allocated)
+# define MOVE_BUFFER_POINTER(P) \
+  (__ptrlow (P) += incr, SET_HIGH_BOUND (P), __ptrvalue (P) += incr)
+# define ELSE_EXTEND_BUFFER_HIGH_BOUND		\
+  else						\
+    {						\
+      SET_HIGH_BOUND (b);			\
+      SET_HIGH_BOUND (begalt);			\
+      if (fixup_alt_jump)			\
+	SET_HIGH_BOUND (fixup_alt_jump);	\
+      if (laststart)				\
+	SET_HIGH_BOUND (laststart);		\
+      if (pending_exact)			\
+	SET_HIGH_BOUND (pending_exact);		\
+    }
+#else
+# define MOVE_BUFFER_POINTER(P) (P) += incr
+# define ELSE_EXTEND_BUFFER_HIGH_BOUND
+#endif
 #define EXTEND_BUFFER()							\
   do { 									\
     unsigned char *old_buffer = bufp->buffer;				\
@@ -1631,15 +1651,17 @@ static reg_errcode_t compile_range _RE_A
     /* If the buffer moved, move all the pointers into it.  */		\
     if (old_buffer != bufp->buffer)					\
       {									\
-        b = (b - old_buffer) + bufp->buffer;				\
-        begalt = (begalt - old_buffer) + bufp->buffer;			\
+	int incr = bufp->buffer - old_buffer;				\
+	MOVE_BUFFER_POINTER (b);					\
+	MOVE_BUFFER_POINTER (begalt);					\
         if (fixup_alt_jump)						\
-          fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\
+	  MOVE_BUFFER_POINTER (fixup_alt_jump);				\
         if (laststart)							\
-          laststart = (laststart - old_buffer) + bufp->buffer;		\
+	  MOVE_BUFFER_POINTER (laststart);				\
         if (pending_exact)						\
-          pending_exact = (pending_exact - old_buffer) + bufp->buffer;	\
+	  MOVE_BUFFER_POINTER (pending_exact);				\
       }									\
+    ELSE_EXTEND_BUFFER_HIGH_BOUND					\
   } while (0)
 
 
Index: gcc/fixinc/mkfixinc.sh
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/mkfixinc.sh,v
retrieving revision 1.23
diff -u -p -r1.23 mkfixinc.sh
--- mkfixinc.sh	2000/08/14 18:08:46	1.23
+++ mkfixinc.sh	2000/08/21 23:34:58
@@ -111,9 +111,8 @@ then
 fi
 
 #  OK.  We gotta make the thing.
-#
-echo $MAKE SHELL=\"$SHELL\" install-bin
-
 #  make and install either the binary or the default script
-#
-$MAKE SHELL="$SHELL" install-bin
+
+cmd="$MAKE SHELL=\"$SHELL\" CC=\"$CC\" CFLAGS=\"$CFLAGS\" LDFLAGS=\"$LDFLAGS\" install-bin"
+echo $cmd
+eval $cmd


More information about the Gcc-patches mailing list