Re: [AD] Fortify and Allegro |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> And here it is. I apparently hadn't made a previous copy of the
> configure.in file before changing it, so I didn't notice it had
> changed for this addition when I scanned for this diff (eg,
> something like find -name \*.fortify).
I've commited the attached patch.
--
Eric Botcazou
Index: aclocal.m4
===================================================================
RCS file: /cvsroot/alleg/allegro/aclocal.m4,v
retrieving revision 1.43
diff -u -r1.43 aclocal.m4
--- aclocal.m4 17 May 2003 12:58:09 -0000 1.43
+++ aclocal.m4 29 May 2003 10:05:11 -0000
@@ -268,6 +268,22 @@
])
dnl
+dnl Test for debugging with Fortify.
+dnl
+dnl Variables:
+dnl allegro_debug_with_fortify=(yes|)
+dnl
+AC_DEFUN(ALLEGRO_ACTEST_DEBUG_WITH_FORTIFY,
+[AC_ARG_ENABLE(dbg-with-fortify,
+[ --enable-dbg-with-fortify[=x] enable debugging with Fortify [default=no]],
+test "X$enableval" != "Xno" && allegro_enable_debug_with_fortify=yes)
+
+if test -n "$allegro_enable_debug_with_fortify"; then
+ AC_CHECK_HEADER(fortify/fortify.h, allegro_debug_with_fortify=yes)
+fi
+])
+
+dnl
dnl Test for OSS DIGI driver.
dnl
dnl Variables:
Index: configure.in
===================================================================
RCS file: /cvsroot/alleg/allegro/configure.in,v
retrieving revision 1.60
diff -u -r1.60 configure.in
--- configure.in 17 May 2003 12:58:09 -0000 1.60
+++ configure.in 29 May 2003 10:05:15 -0000
@@ -281,6 +281,12 @@
AC_DEFINE(ALLEGRO_USE_SCHED_YIELD,1,[Define if sched_yield is provided by some library.])
fi
+dnl Test for debugging with Fortify.
+ALLEGRO_ACTEST_DEBUG_WITH_FORTIFY
+if test -n "$allegro_debug_with_fortify"; then
+ LIBS="$LIBS -lfortify"
+fi
+
dnl Test for OSS drivers.
ALLEGRO_ACTEST_OSSDIGI
if test -n "$allegro_support_ossdigi"; then
@@ -636,6 +642,9 @@
WFLAGS="$WFLAGS $WCFLAGS"
dnl In this order...
ALLEGRO_DEBUG_CFLAGS="$CFLAGS -g $WFLAGS -DDEBUGMODE"
+ if test "X$allegro_debug_with_fortify" = "Xyes"; then
+ ALLEGRO_DEBUG_CFLAGS="$ALLEGRO_DEBUG_CFLAGS -DFORTIFY"
+ fi
ALLEGRO_PROFILE_CFLAGS="$CFLAGS -pg $TARGET_ARCH -O2 -funroll-loops -ffast-math $WFLAGS"
if test "X$allegro_cv_support_fomit_frame_pointer" = "Xyes"; then
CFLAGS="$CFLAGS $TARGET_ARCH -O2 -funroll-loops -ffast-math -fomit-frame-pointer $WFLAGS"
@@ -665,6 +674,24 @@
EOF
+dnl Warn if passed --enable-dbg-with-fortify
+if test -n "$allegro_debug_with_fortify"; then
+ if test -z "$allegro_build_debugging_library"; then
+ cat >> makefile.info << EOF
+ Warning: the library will not be built with Fortify support.
+ The support is only enabled with the debug version.
+
+EOF
+ fi
+ if test -z "$allegro_build_debugging_programs"; then
+ cat >> makefile.info << EOF
+ Warning: the programs will not be built with Fortify support.
+ The support is only enabled with the debug version.
+
+EOF
+ fi
+fi
+
dnl Prepare initial dependencies file (if missing).
if test -f "$srcdir/makefile.dep"; then
if test `cd "$srcdir" ; pwd` != `cd . ; pwd`; then
@@ -694,4 +721,5 @@
AC_MSG_WARN([This might be called gmake on your system.])
fi
fi
-make info
+
+${MAKE-make} info
Index: include/allegro/base.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/base.h,v
retrieving revision 1.18
diff -u -r1.18 base.h
--- include/allegro/base.h 27 Jan 2003 12:48:32 -0000 1.18
+++ include/allegro/base.h 29 May 2003 10:05:15 -0000
@@ -29,6 +29,10 @@
#include <time.h>
#endif
+#if (defined DEBUGMODE) && (defined FORTIFY)
+ #include <fortify/fortify.h>
+#endif
+
#include "internal/alconfig.h"
#ifdef __cplusplus
Index: include/allegro/unicode.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/unicode.h,v
retrieving revision 1.4
diff -u -r1.4 unicode.h
--- include/allegro/unicode.h 31 Oct 2002 12:56:24 -0000 1.4
+++ include/allegro/unicode.h 29 May 2003 10:05:15 -0000
@@ -94,7 +94,11 @@
AL_PRINTFUNC(int, usprintf, (char *buf, AL_CONST char *format, ...), 2, 3);
#ifndef ustrdup
- #define ustrdup(src) _ustrdup(src, malloc)
+ #ifdef FORTIFY
+ #define ustrdup(src) _ustrdup(src, Fortify_malloc)
+ #else
+ #define ustrdup(src) _ustrdup(src, malloc)
+ #endif
#endif
#define ustrcpy(dest, src) ustrzcpy(dest, INT_MAX, src)