diff options
author | Greg Hudson <ghudson@mit.edu> | 2016-06-30 12:32:20 -0400 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2016-08-10 21:42:01 -0400 |
commit | 0a203b8720f2514569e46ad51755b43a38346113 (patch) | |
tree | ead7ce94ece3d654b97927883ea7d15b63a0227e | |
parent | 4947c270032691d556140b290e1b10846b692968 (diff) | |
download | krb5-0a203b8720f2514569e46ad51755b43a38346113.zip krb5-0a203b8720f2514569e46ad51755b43a38346113.tar.gz krb5-0a203b8720f2514569e46ad51755b43a38346113.tar.bz2 |
Add asan build support
Add the --enable-asan configure option. This option suppresses the
undefined symbol check when building shared libraries on Linux, and
adds -fsanitize=address to the compiler and linker options.
-rw-r--r-- | doc/build/options2configure.rst | 5 | ||||
-rw-r--r-- | src/aclocal.m4 | 1 | ||||
-rw-r--r-- | src/config/pre.in | 15 | ||||
-rw-r--r-- | src/config/shlib.conf | 4 | ||||
-rw-r--r-- | src/configure.in | 21 |
5 files changed, 41 insertions, 5 deletions
diff --git a/doc/build/options2configure.rst b/doc/build/options2configure.rst index 418ec25..0fd0307 100644 --- a/doc/build/options2configure.rst +++ b/doc/build/options2configure.rst @@ -282,6 +282,11 @@ Optional features **-**\ **-disable-aesni** Disable support for using AES instructions on x86 platforms. +**-**\ **-enable-asan**\ [=\ *ARG*] + Enable building with asan memory error checking. If *ARG* is + given, it controls the -fsanitize compilation flag value (the + default is "address"). + Optional packages ----------------- diff --git a/src/aclocal.m4 b/src/aclocal.m4 index 118c2c5..b9f9d2a 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -1046,6 +1046,7 @@ AC_SUBST(PFLIBEXT) AC_SUBST(LIBINSTLIST) AC_SUBST(DYNOBJEXT) AC_SUBST(MAKE_DYNOBJ_COMMAND) +AC_SUBST(UNDEF_CHECK) ]) dnl diff --git a/src/config/pre.in b/src/config/pre.in index cec2218..b3678b8 100644 --- a/src/config/pre.in +++ b/src/config/pre.in @@ -150,19 +150,22 @@ CONFIG_RELTOPDIR = @CONFIG_RELTOPDIR@ # WARN_CFLAGS user override but starts off set by configure # PTHREAD_CFLAGS set by configure, not included in CFLAGS so that we # don't pull the pthreads library into shared libraries +# ASAN_FLAGS set by configure when --enable-asan is used ALL_CFLAGS = $(DEFS) $(DEFINES) $(KRB_INCLUDES) $(LOCALINCLUDES) \ -DKRB5_DEPRECATED=1 \ -DKRB5_PRIVATE \ - $(CPPFLAGS) $(CFLAGS) $(WARN_CFLAGS) $(PTHREAD_CFLAGS) + $(CPPFLAGS) $(CFLAGS) $(WARN_CFLAGS) $(PTHREAD_CFLAGS) $(ASAN_FLAGS) ALL_CXXFLAGS = $(DEFS) $(DEFINES) $(KRB_INCLUDES) $(LOCALINCLUDES) \ -DKRB5_DEPRECATED=1 \ -DKRB5_PRIVATE \ - $(CPPFLAGS) $(CXXFLAGS) $(WARN_CXXFLAGS) $(PTHREAD_CFLAGS) + $(CPPFLAGS) $(CXXFLAGS) $(WARN_CXXFLAGS) $(PTHREAD_CFLAGS) \ + $(ASAN_FLAGS) CFLAGS = @CFLAGS@ CXXFLAGS = @CXXFLAGS@ WARN_CFLAGS = @WARN_CFLAGS@ WARN_CXXFLAGS = @WARN_CXXFLAGS@ +ASAN_FLAGS = @ASAN_FLAGS@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ THREAD_LINKOPTS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) @@ -281,8 +284,8 @@ EXEEXT = # prog: foo.o bar.o $(KRB5_BASE_DEPLIBS) # $(CC_LINK) -o $@ foo.o bar.o $(KRB5_BASE_LIBS) -CC_LINK=@CC_LINK@ -CXX_LINK=@CXX_LINK@ +CC_LINK=@CC_LINK@ $(ASAN_FLAGS) +CXX_LINK=@CXX_LINK@ $(ASAN_FLAGS) # Makefile.in files which build programs can override the list of # directories to look for dependent libraries in (in the form -Ldir1 @@ -553,6 +556,10 @@ MAKE_DYNOBJ_COMMAND=@MAKE_DYNOBJ_COMMAND@ DYNOBJ_EXPDEPS=@DYNOBJ_EXPDEPS@ DYNOBJ_EXPFLAGS=@DYNOBJ_EXPFLAGS@ +# For some platforms, a flag which causes shared library creation to +# check for undefined symbols. Suppressed when using --enable-asan. +UNDEF_CHECK=@UNDEF_CHECK@ + # File with symbol names to be exported, both functions and data, # currently not distinguished. SHLIB_EXPORT_FILE=$(srcdir)/$(LIBPREFIX)$(LIBBASE).exports diff --git a/src/config/shlib.conf b/src/config/shlib.conf index f5eb6e3..3e4af6c 100644 --- a/src/config/shlib.conf +++ b/src/config/shlib.conf @@ -422,7 +422,9 @@ mips-*-netbsd*) SHLIBEXT=.so # Linux ld doesn't default to stuffing the SONAME field... # Use objdump -x to examine the fields of the library - LDCOMBINE='$(CC) -shared -fPIC -Wl,-h,$(LIBPREFIX)$(LIBBASE)$(SHLIBSEXT),--no-undefined' + # UNDEF_CHECK is suppressed by --enable-asan + LDCOMBINE='$(CC) -shared -fPIC -Wl,-h,$(LIBPREFIX)$(LIBBASE)$(SHLIBSEXT) $(UNDEF_CHECK)' + UNDEF_CHECK='-Wl,--no-undefined' # $(EXPORT_CHECK) runs export-check.pl when in maintainer mode. LDCOMBINE_TAIL='-Wl,--version-script binutils.versions $(EXPORT_CHECK)' SHLIB_EXPORT_FILE_DEP=binutils.versions diff --git a/src/configure.in b/src/configure.in index 7ef0c62..433e9d1 100644 --- a/src/configure.in +++ b/src/configure.in @@ -399,6 +399,27 @@ if test "$enableval" = no ; then fi KRB5_RUN_FLAGS +# asan is a gcc and clang facility to instrument the code with memory +# error checking. To use it, we compile C and C++ source files with +# -fsanitize=address, and set ASAN=yes to suppress the undefined +# symbols check when building shared libraries. +AC_ARG_ENABLE([asan], +AC_HELP_STRING([--enable-asan],[Build with asan memory checking]),[], + [enable_asan=no]) +if test "$enable_asan" != no; then + if test "$enable_asan" = yes; then + enable_asan=address + fi + ASAN_FLAGS="$DEFS -fsanitize=$enable_asan" + ASAN=yes + UNDEF_CHECK= +else + ASAN_FLAGS= + ASAN=no +fi +AC_SUBST(ASAN_FLAGS) +AC_SUBST(ASAN) + AC_TYPE_SIGNAL # from old include/configure.in |