From ff715085d4de8c87614b67158a18d8085ceec3c2 Mon Sep 17 00:00:00 2001 From: Guido Draheim Date: Tue, 13 Mar 2018 02:23:29 +0100 Subject: [PATCH] add --with-asan option #40 --- Makefile.in | 2 ++ SDL/Makefile.in | 2 ++ bins/Makefile.am | 25 +++++++++++++------------ bins/Makefile.in | 28 +++++++++++++++------------- configure | 32 ++++++++++++++++++++++++++++++++ configure.ac | 19 +++++++++++++++++++ docs/Makefile.in | 2 ++ test/Makefile.in | 2 ++ zzip/Makefile.in | 2 ++ zzipwrap/Makefile.in | 2 ++ 10 files changed, 91 insertions(+), 25 deletions(-) diff --git a/Makefile.in b/Makefile.in index c24b27e..f8b38ff 100644 --- a/Makefile.in +++ b/Makefile.in @@ -241,6 +241,8 @@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ +ASAN_CFLAGS = @ASAN_CFLAGS@ +ASAN_LIBS = @ASAN_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ diff --git a/SDL/Makefile.in b/SDL/Makefile.in index 3e2c086..4230a66 100644 --- a/SDL/Makefile.in +++ b/SDL/Makefile.in @@ -238,6 +238,8 @@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ +ASAN_CFLAGS = @ASAN_CFLAGS@ +ASAN_LIBS = @ASAN_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ diff --git a/bins/Makefile.am b/bins/Makefile.am index 9483dc9..ed1df98 100644 --- a/bins/Makefile.am +++ b/bins/Makefile.am @@ -2,6 +2,7 @@ AUTOMAKE_OPTIONS = 1.4 foreign AUTOTOOL_VERSION=autoconf-2.52 automake-1.5 libtool-1.4.2 DEFAULT_INCLUDES = # nothing - no default of -I. -I$(srcdir) DEFS = @DEFS@ -I$(top_builddir) -I$(top_srcdir) # also for automake 1.4 +CFLAGS = @CFLAGS@ @ASAN_CFLAGS@ bin_PROGRAMS = zzcat zzdir zzxorcat zzxordir zzxorcopy \ unzzip unzzip-mix unzzip-mem unzzip-big unzip-mem @@ -20,26 +21,26 @@ noinst_HEADERS = unzzipdir-zip.h unzzipcat-zip.h unzzip-states.h zzipmake-zip.h EXTRA_DIST = $(aclocal_DATA) $(noinst_HEADERS) CLEANFILES = $(WCC10_CLEAN) -zziptest_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz -zzcat_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz -zzdir_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz -zzxorcat_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz -zzxordir_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz -zzobfuscated_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +zziptest_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ +zzcat_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ +zzdir_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ +zzxorcat_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ +zzxordir_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ +zzobfuscated_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ -zzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +zzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ zzip_SOURCES = zzip.c zzipmake-zip.c -unzzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +unzzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ unzzip_SOURCES = unzzip.c unzzipcat-zip.c unzzipdir-zip.c -unzzip_mix_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +unzzip_mix_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ unzzip_mix_SOURCES = unzzip.c unzzipcat-mix.c unzzipdir-mix.c -unzzip_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz +unzzip_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz @ASAN_LIBS@ unzzip_mem_SOURCES = unzzip.c unzzipcat-mem.c unzzipdir-mem.c -unzzip_big_LDADD = ../zzip/libzzipfseeko.la @RESOLVES@ -lz +unzzip_big_LDADD = ../zzip/libzzipfseeko.la @RESOLVES@ -lz @ASAN_LIBS@ unzzip_big_SOURCES = unzzip.c unzzipcat-big.c unzzipdir-big.c -unzip_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz +unzip_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz @ASAN_LIBS@ ../zzip/libzzip.la : @top_srcdir@/zzip/*.c (cd ../zzip && $(MAKE) `basename $@`) diff --git a/bins/Makefile.in b/bins/Makefile.in index c31a770..3a9b806 100644 --- a/bins/Makefile.in +++ b/bins/Makefile.in @@ -288,13 +288,15 @@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ +ASAN_CFLAGS = @ASAN_CFLAGS@ +ASAN_LIBS = @ASAN_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ +CFLAGS = @CFLAGS@ @ASAN_CFLAGS@ CONFIG_FILES = @CONFIG_FILES@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ @@ -443,23 +445,23 @@ WCC10_CLEAN = *.obj *.lk1 *.mk1 *.mk *.sym *.tgt noinst_HEADERS = unzzipdir-zip.h unzzipcat-zip.h unzzip-states.h zzipmake-zip.h EXTRA_DIST = $(aclocal_DATA) $(noinst_HEADERS) CLEANFILES = $(WCC10_CLEAN) -zziptest_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz -zzcat_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz -zzdir_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz -zzxorcat_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz -zzxordir_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz -zzobfuscated_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz -zzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +zziptest_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ +zzcat_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ +zzdir_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ +zzxorcat_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ +zzxordir_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ +zzobfuscated_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ +zzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ zzip_SOURCES = zzip.c zzipmake-zip.c -unzzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +unzzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ unzzip_SOURCES = unzzip.c unzzipcat-zip.c unzzipdir-zip.c -unzzip_mix_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +unzzip_mix_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz @ASAN_LIBS@ unzzip_mix_SOURCES = unzzip.c unzzipcat-mix.c unzzipdir-mix.c -unzzip_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz +unzzip_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz @ASAN_LIBS@ unzzip_mem_SOURCES = unzzip.c unzzipcat-mem.c unzzipdir-mem.c -unzzip_big_LDADD = ../zzip/libzzipfseeko.la @RESOLVES@ -lz +unzzip_big_LDADD = ../zzip/libzzipfseeko.la @RESOLVES@ -lz @ASAN_LIBS@ unzzip_big_SOURCES = unzzip.c unzzipcat-big.c unzzipdir-big.c -unzip_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz +unzip_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz @ASAN_LIBS@ all: all-am .SUFFIXES: diff --git a/configure b/configure index b525cf7..f1306de 100755 --- a/configure +++ b/configure @@ -643,6 +643,8 @@ PKG_CONFIG RESOLVES ZZIPLIB_LDFLAGS ZIPTESTS +ASAN_CFLAGS +ASAN_LIBS SDL_GENERATE SDL ZLIB_VERSION @@ -811,6 +813,7 @@ with_debug with_lowstk enable_mmap enable_sdl +with_asan with_defines enable_frame_pointer enable_enable_default_pkgconfigdir @@ -1493,6 +1496,8 @@ Optional Packages: --with-lowstk limited thread stack + --with-asan compile with adress sanitizer + --with-defines easy,harden,allow_modulo_entries Some influential environment variables: @@ -15370,6 +15375,33 @@ $as_echo "enabled SDL generation of... $SDL_GENERATE" >&6; } fi + +# ---------------------------------------------------------------- +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether using address sanitizer" >&5 +$as_echo_n "checking whether using address sanitizer... " >&6; } + +# Check whether --with-asan was given. +if test "${with_asan+set}" = set; then : + withval=$with_asan; case "${withval}" in + yes|no) with_asan="$withval" ;; + *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: oops" >&5 +$as_echo "oops" >&6; } + as_fn_error $? "bad value ${withval} for --with-asan" "$LINENO" 5 ;; + esac +else + with_asan="no" +fi + +ASAN_LIBS="" +ASAN_CFLAGS="" +if test ".$with_asan" = ".yes" ; then + ASAN_LIBS="-lasan" + ASAN_CFLAGS="-fsanitize=address" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_asan, $ASAN_CFLAGS" >&5 +$as_echo "$with_asan, $ASAN_CFLAGS" >&6; } + + # --------------------------------------------------------------- { $as_echo "$as_me:${as_lineno-$LINENO}: checking running extra tests on make check" >&5 $as_echo_n "checking running extra tests on make check... " >&6; } diff --git a/configure.ac b/configure.ac index 737fea3..9d45f34 100644 --- a/configure.ac +++ b/configure.ac @@ -283,6 +283,25 @@ else fi AC_SUBST([SDL]) AC_SUBST([SDL_GENERATE]) + +# ---------------------------------------------------------------- +AC_MSG_CHECKING(whether using address sanitizer) +AC_ARG_WITH(asan, AC_HELP_STRING( + [--with-asan],[compile with adress sanitizer]) + , [case "${withval}" in + yes|no) with_asan="$withval" ;; + *) AC_MSG_RESULT(oops) + AC_MSG_ERROR(bad value ${withval} for --with-asan) ;; + esac], [with_asan="no"]) +ASAN_LIBS="" +ASAN_CFLAGS="" +if test ".$with_asan" = ".yes" ; then + ASAN_LIBS="-lasan" + ASAN_CFLAGS="-fsanitize=address" +fi +AC_MSG_RESULT([$with_asan, $ASAN_CFLAGS]) +AC_SUBST([ASAN_LIBS]) +AC_SUBST([ASAN_CFLAGS]) # --------------------------------------------------------------- AC_MSG_CHECKING(running extra tests on make check) if test "MKZIP" != ":" ; then diff --git a/docs/Makefile.in b/docs/Makefile.in index 9a24055..50d1e76 100644 --- a/docs/Makefile.in +++ b/docs/Makefile.in @@ -155,6 +155,8 @@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ +ASAN_CFLAGS = @ASAN_CFLAGS@ +ASAN_LIBS = @ASAN_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ diff --git a/test/Makefile.in b/test/Makefile.in index 92fa312..4b181c2 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -210,6 +210,8 @@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ +ASAN_CFLAGS = @ASAN_CFLAGS@ +ASAN_LIBS = @ASAN_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ diff --git a/zzip/Makefile.in b/zzip/Makefile.in index 62aecb4..1861ffe 100644 --- a/zzip/Makefile.in +++ b/zzip/Makefile.in @@ -254,6 +254,8 @@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ +ASAN_CFLAGS = @ASAN_CFLAGS@ +ASAN_LIBS = @ASAN_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ diff --git a/zzipwrap/Makefile.in b/zzipwrap/Makefile.in index 37f7ed9..9a2f0ec 100644 --- a/zzipwrap/Makefile.in +++ b/zzipwrap/Makefile.in @@ -248,6 +248,8 @@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ +ASAN_CFLAGS = @ASAN_CFLAGS@ +ASAN_LIBS = @ASAN_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ -- 2.40.0