aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2012-11-19 15:39:28 -0800
committerPaul Eggert2012-11-19 15:39:28 -0800
commit8ea5c4de2a2a9d71b3877974c92def925fb26f5d (patch)
tree7c278a931b73b5e6792c5a7b780e90759e9cdeaa
parent141462223d6f8063bf01692c2f41ecc58baea506 (diff)
downloademacs-8ea5c4de2a2a9d71b3877974c92def925fb26f5d.tar.gz
emacs-8ea5c4de2a2a9d71b3877974c92def925fb26f5d.zip
Improve static checking of integer overflow and stack smashing.
* configure.ac (WARN_CFLAGS): Add -Wstack-protector and -Wstrict-overflow if using GCC 4.7.2 or later on a platform with at least 64-bit long int. This improves static checking on these platforms, when configured with --enable-gcc-warnings.
-rw-r--r--ChangeLog8
-rw-r--r--configure.ac19
2 files changed, 24 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 05e1a14d55d..6852069087a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
12012-11-19 Paul Eggert <eggert@cs.ucla.edu>
2
3 Improve static checking of integer overflow and stack smashing.
4 * configure.ac (WARN_CFLAGS): Add -Wstack-protector and
5 -Wstrict-overflow if using GCC 4.7.2 or later on a platform with
6 at least 64-bit long int. This improves static checking on these
7 platforms, when configured with --enable-gcc-warnings.
8
12012-11-17 Paul Eggert <eggert@cs.ucla.edu> 92012-11-17 Paul Eggert <eggert@cs.ucla.edu>
2 10
3 Assume POSIX 1003.1-1988 or later for fcntl.h (Bug#12881). 11 Assume POSIX 1003.1-1988 or later for fcntl.h (Bug#12881).
diff --git a/configure.ac b/configure.ac
index 1884cc7ccf7..2a079cad264 100644
--- a/configure.ac
+++ b/configure.ac
@@ -717,11 +717,24 @@ else
717 # <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>. 717 # <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
718 nw="$nw -Wshadow" 718 nw="$nw -Wshadow"
719 719
720 # The following lines should be removable at some point. 720 # The following line should be removable at some point.
721 nw="$nw -Wstack-protector"
722 nw="$nw -Wstrict-overflow"
723 nw="$nw -Wsuggest-attribute=pure" 721 nw="$nw -Wsuggest-attribute=pure"
724 722
723 AC_MSG_CHECKING([whether to use -Wstack-protector -Wstrict-overflow])
724 AC_PREPROC_IFELSE(
725 [AC_LANG_PROGRAM(
726 [[#if (1 <= __LONG_MAX__ >> 31 >> 31 \
727 && 4 < __GNUC__ + (7 < __GNUC_MINOR__ + (2 <= __GNUC_PATCHLEVEL__)))
728 /* OK */
729 #else
730 #error "Not GCC, or GCC before 4.7.2, or 'long int' has < 64 bits."
731 #endif
732 ]])],
733 [AC_MSG_RESULT(yes)],
734 [AC_MSG_RESULT(no)
735 nw="$nw -Wstack-protector"
736 nw="$nw -Wstrict-overflow"])
737
725 gl_MANYWARN_ALL_GCC([ws]) 738 gl_MANYWARN_ALL_GCC([ws])
726 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw]) 739 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
727 for w in $ws; do 740 for w in $ws; do