diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8508f3770f4..2e49912561e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2014-05-14 Yury Gribov + + PR sanitizer/61100 + * c-c++-common/asan/asan-interface-1.c: New test. + * lib/asan-dg.exp (asan_include_flags): New function. + (asan_init): Call asan_include_flags to obtain path + to sanitizer headers. + 2014-05-13 Peter Bergner * lib/target-support.exp (check_dfp_hw_available): New function. diff --git a/gcc/testsuite/c-c++-common/asan/asan-interface-1.c b/gcc/testsuite/c-c++-common/asan/asan-interface-1.c new file mode 100644 index 00000000000..33ed1b0e845 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/asan-interface-1.c @@ -0,0 +1,13 @@ +/* Check that interface headers work. */ + +/* { dg-do run { target { *-*-linux* } } } */ + +#include + +int main() { + char tmp; + if (__asan_address_is_poisoned((volatile char *)&tmp + 1)) + return 0; + return 1; +} + diff --git a/gcc/testsuite/lib/asan-dg.exp b/gcc/testsuite/lib/asan-dg.exp index 9ba39db15e4..7a12160bb19 100644 --- a/gcc/testsuite/lib/asan-dg.exp +++ b/gcc/testsuite/lib/asan-dg.exp @@ -23,6 +23,21 @@ proc check_effective_target_faddress_sanitizer {} { } "-fsanitize=address"] } +proc asan_include_flags {} { + global srcdir + global TESTING_IN_BUILD_TREE + + set flags "" + + if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } { + return "${flags}" + } + + set flags "-I$srcdir/../../libsanitizer/include" + + return "$flags" +} + # # asan_link_flags -- compute library path and flags to find libasan. # (originally from g++.exp) @@ -80,17 +95,19 @@ proc asan_init { args } { } } + set include_flags "[asan_include_flags]" + if [info exists TEST_ALWAYS_FLAGS] { set asan_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS } if [info exists ALWAYS_CXXFLAGS] { set ALWAYS_CXXFLAGS [concat "{ldflags=$link_flags}" $ALWAYS_CXXFLAGS] - set ALWAYS_CXXFLAGS [concat "{additional_flags=-fsanitize=address -g}" $ALWAYS_CXXFLAGS] + set ALWAYS_CXXFLAGS [concat "{additional_flags=-fsanitize=address -g $include_flags}" $ALWAYS_CXXFLAGS] } else { if [info exists TEST_ALWAYS_FLAGS] { - set TEST_ALWAYS_FLAGS "$link_flags -fsanitize=address -g $TEST_ALWAYS_FLAGS" + set TEST_ALWAYS_FLAGS "$link_flags -fsanitize=address -g $include_flags $TEST_ALWAYS_FLAGS" } else { - set TEST_ALWAYS_FLAGS "$link_flags -fsanitize=address -g" + set TEST_ALWAYS_FLAGS "$link_flags -fsanitize=address -g $include_flags" } } if { $link_flags != "" } { diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog index 5a6cf6e66bd..319f9322690 100644 --- a/libsanitizer/ChangeLog +++ b/libsanitizer/ChangeLog @@ -1,3 +1,10 @@ +2014-05-14 Yury Gribov + + PR sanitizer/61100 + * Makefile.am (nodist_saninclude_HEADERS): Install + public headers. + * Makefile.in: Regenerate. + 2014-03-07 Rainer Orth * libbacktrace/Makefile.am (libsanitizer_libbacktrace_la_SOURCES): diff --git a/libsanitizer/Makefile.am b/libsanitizer/Makefile.am index b0dc582ccfb..6b0c571c46e 100644 --- a/libsanitizer/Makefile.am +++ b/libsanitizer/Makefile.am @@ -1,7 +1,13 @@ ACLOCAL_AMFLAGS = -I .. -I ../config +sanincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include/sanitizer + +nodist_saninclude_HEADERS = + if SANITIZER_SUPPORTED SUBDIRS = sanitizer_common +nodist_saninclude_HEADERS += \ + include/sanitizer/common_interface_defs.h if !USING_MAC_INTERPOSE SUBDIRS += interception endif @@ -9,6 +15,9 @@ if LIBBACKTRACE_SUPPORTED SUBDIRS += libbacktrace endif SUBDIRS += lsan asan ubsan +nodist_saninclude_HEADERS += \ + include/sanitizer/lsan_interface.h \ + include/sanitizer/asan_interface.h if TSAN_SUPPORTED SUBDIRS += tsan endif diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in index 60cbe2ee554..0b8924554dc 100644 --- a/libsanitizer/Makefile.in +++ b/libsanitizer/Makefile.in @@ -35,9 +35,12 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -@SANITIZER_SUPPORTED_TRUE@@USING_MAC_INTERPOSE_FALSE@am__append_1 = interception -@LIBBACKTRACE_SUPPORTED_TRUE@@SANITIZER_SUPPORTED_TRUE@am__append_2 = libbacktrace -@SANITIZER_SUPPORTED_TRUE@@TSAN_SUPPORTED_TRUE@am__append_3 = tsan +@SANITIZER_SUPPORTED_TRUE@am__append_1 = include/sanitizer/common_interface_defs.h \ +@SANITIZER_SUPPORTED_TRUE@ include/sanitizer/lsan_interface.h \ +@SANITIZER_SUPPORTED_TRUE@ include/sanitizer/asan_interface.h +@SANITIZER_SUPPORTED_TRUE@@USING_MAC_INTERPOSE_FALSE@am__append_2 = interception +@LIBBACKTRACE_SUPPORTED_TRUE@@SANITIZER_SUPPORTED_TRUE@am__append_3 = libbacktrace +@SANITIZER_SUPPORTED_TRUE@@TSAN_SUPPORTED_TRUE@am__append_4 = tsan subdir = . DIST_COMMON = ChangeLog $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ @@ -98,8 +101,9 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__installdirs = "$(DESTDIR)$(toolexeclibdir)" -HEADERS = $(nodist_toolexeclib_HEADERS) +am__installdirs = "$(DESTDIR)$(sanincludedir)" \ + "$(DESTDIR)$(toolexeclibdir)" +HEADERS = $(nodist_saninclude_HEADERS) $(nodist_toolexeclib_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ @@ -250,9 +254,11 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I .. -I ../config -@SANITIZER_SUPPORTED_TRUE@SUBDIRS = sanitizer_common $(am__append_1) \ -@SANITIZER_SUPPORTED_TRUE@ $(am__append_2) lsan asan ubsan \ -@SANITIZER_SUPPORTED_TRUE@ $(am__append_3) +sanincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include/sanitizer +nodist_saninclude_HEADERS = $(am__append_1) +@SANITIZER_SUPPORTED_TRUE@SUBDIRS = sanitizer_common $(am__append_2) \ +@SANITIZER_SUPPORTED_TRUE@ $(am__append_3) lsan asan ubsan \ +@SANITIZER_SUPPORTED_TRUE@ $(am__append_4) gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) # Work around what appears to be a GNU make bug handling MAKEFLAGS @@ -378,6 +384,26 @@ distclean-multi: $(MULTICLEAN) $(AM_MAKEFLAGS) DO=distclean multi-clean # $(MAKE) maintainer-clean-multi: $(MULTICLEAN) $(AM_MAKEFLAGS) DO=maintainer-clean multi-clean # $(MAKE) +install-nodist_sanincludeHEADERS: $(nodist_saninclude_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sanincludedir)" || $(MKDIR_P) "$(DESTDIR)$(sanincludedir)" + @list='$(nodist_saninclude_HEADERS)'; test -n "$(sanincludedir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(sanincludedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(sanincludedir)" || exit $$?; \ + done + +uninstall-nodist_sanincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(nodist_saninclude_HEADERS)'; test -n "$(sanincludedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(sanincludedir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(sanincludedir)" && rm -f $$files install-nodist_toolexeclibHEADERS: $(nodist_toolexeclib_HEADERS) @$(NORMAL_INSTALL) test -z "$(toolexeclibdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibdir)" @@ -538,7 +564,7 @@ check: check-recursive all-am: Makefile all-multi $(HEADERS) config.h installdirs: installdirs-recursive installdirs-am: - for dir in "$(DESTDIR)$(toolexeclibdir)"; do \ + for dir in "$(DESTDIR)$(sanincludedir)" "$(DESTDIR)$(toolexeclibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive @@ -588,7 +614,7 @@ info: info-recursive info-am: -install-data-am: +install-data-am: install-nodist_sanincludeHEADERS install-dvi: install-dvi-recursive @@ -634,7 +660,8 @@ ps: ps-recursive ps-am: -uninstall-am: uninstall-nodist_toolexeclibHEADERS +uninstall-am: uninstall-nodist_sanincludeHEADERS \ + uninstall-nodist_toolexeclibHEADERS .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all all-multi \ clean-multi ctags-recursive distclean-multi install-am \ @@ -649,13 +676,14 @@ uninstall-am: uninstall-nodist_toolexeclibHEADERS info-am install install-am install-data install-data-am \ install-dvi install-dvi-am install-exec install-exec-am \ install-html install-html-am install-info install-info-am \ - install-man install-multi install-nodist_toolexeclibHEADERS \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - maintainer-clean-multi mostlyclean mostlyclean-generic \ - mostlyclean-libtool mostlyclean-multi pdf pdf-am ps ps-am tags \ - tags-recursive uninstall uninstall-am \ + install-man install-multi install-nodist_sanincludeHEADERS \ + install-nodist_toolexeclibHEADERS install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic maintainer-clean-multi mostlyclean \ + mostlyclean-generic mostlyclean-libtool mostlyclean-multi pdf \ + pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-nodist_sanincludeHEADERS \ uninstall-nodist_toolexeclibHEADERS