diff options
author | Maxim Ostapenko <m.ostapenko@samsung.com> | 2017-10-27 15:14:27 +0300 |
---|---|---|
committer | Dongkyun Son <dongkyun.s@samsung.com> | 2017-12-08 17:37:21 +0900 |
commit | c135181e3aee094be79134585645b6049ed133f3 (patch) | |
tree | dede1008adc85513f546bf3b81dad59015d7def8 | |
parent | 8ac9c3d09f4d2d0c162ccb0a4d695a0804e8c53b (diff) | |
download | linaro-gcc-c135181e3aee094be79134585645b6049ed133f3.tar.gz linaro-gcc-c135181e3aee094be79134585645b6049ed133f3.tar.bz2 linaro-gcc-c135181e3aee094be79134585645b6049ed133f3.zip |
[TTC-11] Embed UBSan into ASan runtimesubmit/tizen_base/20171208.084018accepted/tizen/base/20171215.171112
Change the way we use ASan and UBSan together. Instead of keeping two
separate runtimes (libasan.so and libubsan.so), embed UBSan into ASan.
UBSan initialization code (e.g. flag parsing) is directly called
from ASan initialization, so we are able to enforce correct
initialization order.
This mirrors the approach we already use for ASan+LSan. This change
doesn't modify the way we use standalone UBSan.
gcc/
* config/gnu-user.h: append -lstdc++ if we link against ASan
runtime.
* gcc.c: Do not link against libubsan.so if
-fsanitize=address,undefined is used.
gcc/testsuite/
* c-c++-common/asan/asan_and_ubsan-1.c: New test.
libsanitizer/
* Makefile.am: Build UBSan strictly before ASan.
* Makefile.in: Regenerate.
* asan/Makefile.am: Embed UBSan into ASan runtime.
* asan/Makefile.in: Regenerate.
* configure.ac: Configure UBSan strictly before ASan.
* configure: Regenerate.
ubsan/ubsan_diag.cc (__sanitizer_print_stack_trace): Move to ...
ubsan/ubsan_diag_standalone.cc: ... here.
* ubsan/Makefile.am: Create a "plugin" library to be embedded
into ASan runtime.
* ubsan/Makefile.in: Regenerate.
Change-Id: Ia848a93929effb4b0ec057243c7343c1bd94fbfb
Signed-off-by: Maxim Ostapenko <m.ostapenko@samsung.com>
-rw-r--r-- | ChangeLog.Tizen | 5 | ||||
-rw-r--r-- | gcc/config/gnu-user.h | 2 | ||||
-rw-r--r-- | gcc/gcc.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/asan/asan_and_ubsan-1.c | 27 | ||||
-rw-r--r-- | libsanitizer/Makefile.am | 2 | ||||
-rw-r--r-- | libsanitizer/Makefile.in | 6 | ||||
-rw-r--r-- | libsanitizer/asan/Makefile.am | 4 | ||||
-rw-r--r-- | libsanitizer/asan/Makefile.in | 8 | ||||
-rwxr-xr-x | libsanitizer/configure | 12 | ||||
-rw-r--r-- | libsanitizer/configure.ac | 2 | ||||
-rw-r--r-- | libsanitizer/ubsan/Makefile.am | 6 | ||||
-rw-r--r-- | libsanitizer/ubsan/Makefile.in | 62 | ||||
-rw-r--r-- | libsanitizer/ubsan/ubsan_diag.cc | 9 | ||||
-rw-r--r-- | libsanitizer/ubsan/ubsan_diag_standalone.cc | 36 |
14 files changed, 133 insertions, 50 deletions
diff --git a/ChangeLog.Tizen b/ChangeLog.Tizen index ec013283ca6..8a1e379604c 100644 --- a/ChangeLog.Tizen +++ b/ChangeLog.Tizen @@ -29,6 +29,11 @@ # log at the same time (actually you can't). However, if you update this # file after the commit hash is fixed, you are free to add the commit hash. ################################################################################ +2017-12-08 Maxim Ostapenko <m.ostapenko@samsung.com> + + commit 7a29613062b65ef76e06ce7851e6f50c51f63049 + [TTC-11] Embed UBSan into ASan runtime + 2017-12-07 Denis Khalikov <d.khalikov@partner.samsung.com> commit 89481bdfec835f7d84c5c236117e3a0da4cc6a9f diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h index b0bf40a954f..32e09885a5f 100644 --- a/gcc/config/gnu-user.h +++ b/gcc/config/gnu-user.h @@ -145,7 +145,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \ "%{static-libasan:%{!shared:" \ LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \ - LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}" + LD_DYNAMIC_OPTION " -lstdc++ }}%{!static-libasan:-lasan}" #undef LIBTSAN_EARLY_SPEC #define LIBTSAN_EARLY_SPEC "%{static-libtsan:%{!shared:" \ LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \ diff --git a/gcc/gcc.c b/gcc/gcc.c index c6a6fe08448..1c2b3ab5882 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -976,7 +976,7 @@ proper position among the other output files. */ %{static:%ecannot specify -static with -fsanitize=address}}\ %{%:sanitize(thread):" LIBTSAN_SPEC "\ %{static:%ecannot specify -static with -fsanitize=thread}}\ - %{%:sanitize(undefined):" LIBUBSAN_SPEC "}\ + %{!%:sanitize(address):%{%:sanitize(undefined):" LIBUBSAN_SPEC "}}\ %{%:sanitize(leak):" LIBLSAN_SPEC "}}}" #endif diff --git a/gcc/testsuite/c-c++-common/asan/asan_and_ubsan-1.c b/gcc/testsuite/c-c++-common/asan/asan_and_ubsan-1.c new file mode 100644 index 00000000000..2a0d3968fa4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/asan_and_ubsan-1.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=address,shift -fno-builtin-memset" } */ +/* { dg-shouldfail "asan" } */ + +extern +#ifdef __cplusplus +"C" +#endif +void *memset (void *, int, __SIZE_TYPE__); + +volatile int ten = 10; + +int main() { + volatile int a = 1; + a <<= (ten + 30); + char x[10]; + memset(x, 0, 10); + int res = x[ten] + a; /* BOOOM */ + return res; +} + +/* { dg-output "\[^\n\r]*shift exponent 40 is too large for \[^\n\r]*-bit type 'int'.*" } */ +/* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*asan_and_ubsan-1.c:18|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is located in stack of thread T0.*(\n|\r\n|\r)" */ +/* { dg-output "\[^\n\r]*in main.*asan_and_ubsan-1.c.*(\n|\r\n|\r)" */ + diff --git a/libsanitizer/Makefile.am b/libsanitizer/Makefile.am index d0d2387220f..72c9a2953a1 100644 --- a/libsanitizer/Makefile.am +++ b/libsanitizer/Makefile.am @@ -14,7 +14,7 @@ endif if LIBBACKTRACE_SUPPORTED SUBDIRS += libbacktrace endif -SUBDIRS += lsan asan ubsan +SUBDIRS += lsan ubsan asan nodist_saninclude_HEADERS += \ include/sanitizer/lsan_interface.h \ include/sanitizer/asan_interface.h diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in index c1cd9d1392b..4ce36473878 100644 --- a/libsanitizer/Makefile.in +++ b/libsanitizer/Makefile.in @@ -141,8 +141,8 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS ETAGS = etags CTAGS = ctags -DIST_SUBDIRS = sanitizer_common interception libbacktrace lsan asan \ - ubsan tsan +DIST_SUBDIRS = sanitizer_common interception libbacktrace lsan ubsan \ + asan tsan ACLOCAL = @ACLOCAL@ ALLOC_FILE = @ALLOC_FILE@ AMTAR = @AMTAR@ @@ -292,7 +292,7 @@ ACLOCAL_AMFLAGS = -I .. -I ../config sanincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include/sanitizer nodist_saninclude_HEADERS = $(am__append_1) $(am__append_5) @SANITIZER_SUPPORTED_TRUE@SUBDIRS = sanitizer_common $(am__append_2) \ -@SANITIZER_SUPPORTED_TRUE@ $(am__append_3) lsan asan ubsan \ +@SANITIZER_SUPPORTED_TRUE@ $(am__append_3) lsan ubsan asan \ @SANITIZER_SUPPORTED_TRUE@ $(am__append_4) gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am index bea23e54497..8b758edeaf8 100644 --- a/libsanitizer/asan/Makefile.am +++ b/libsanitizer/asan/Makefile.am @@ -3,7 +3,7 @@ AM_CPPFLAGS = -I $(top_srcdir)/include -I $(top_srcdir) # May be used by toolexeclibdir. gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) -DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DASAN_HAS_EXCEPTIONS=1 -DASAN_NEEDS_SEGV=1 -DCAN_SANITIZE_UB=0 @OBSTACK_DEFS@ +DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DASAN_HAS_EXCEPTIONS=1 -DASAN_NEEDS_SEGV=1 -DCAN_SANITIZE_UB=1 @OBSTACK_DEFS@ if USING_MAC_INTERPOSE DEFS += -DMAC_INTERPOSE_FUNCTIONS -DMISSING_BLOCKS_SUPPORT endif @@ -45,7 +45,7 @@ asan_files = \ asan_win_dynamic_runtime_thunk.cc libasan_la_SOURCES = $(asan_files) -libasan_la_LIBADD = $(top_builddir)/sanitizer_common/libsanitizer_common.la $(top_builddir)/lsan/libsanitizer_lsan.la +libasan_la_LIBADD = $(top_builddir)/sanitizer_common/libsanitizer_common.la $(top_builddir)/lsan/libsanitizer_lsan.la $(top_builddir)/ubsan/libsanitizer_ubsan.la if !USING_MAC_INTERPOSE libasan_la_LIBADD += $(top_builddir)/interception/libinterception.la endif diff --git a/libsanitizer/asan/Makefile.in b/libsanitizer/asan/Makefile.in index 2a183db3625..ed81727992e 100644 --- a/libsanitizer/asan/Makefile.in +++ b/libsanitizer/asan/Makefile.in @@ -109,7 +109,8 @@ LTLIBRARIES = $(toolexeclib_LTLIBRARIES) am__DEPENDENCIES_1 = libasan_la_DEPENDENCIES = \ $(top_builddir)/sanitizer_common/libsanitizer_common.la \ - $(top_builddir)/lsan/libsanitizer_lsan.la $(am__append_2) \ + $(top_builddir)/lsan/libsanitizer_lsan.la \ + $(top_builddir)/ubsan/libsanitizer_ubsan.la $(am__append_2) \ $(am__append_3) $(am__DEPENDENCIES_1) am__objects_1 = asan_activation.lo asan_allocator.lo asan_debugging.lo \ asan_descriptions.lo asan_errors.lo asan_fake_stack.lo \ @@ -174,7 +175,7 @@ CYGPATH_W = @CYGPATH_W@ DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS \ -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \ -DASAN_HAS_EXCEPTIONS=1 -DASAN_NEEDS_SEGV=1 \ - -DCAN_SANITIZE_UB=0 @OBSTACK_DEFS@ $(am__append_1) + -DCAN_SANITIZE_UB=1 @OBSTACK_DEFS@ $(am__append_1) DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ @@ -339,7 +340,8 @@ asan_files = \ libasan_la_SOURCES = $(asan_files) libasan_la_LIBADD = \ $(top_builddir)/sanitizer_common/libsanitizer_common.la \ - $(top_builddir)/lsan/libsanitizer_lsan.la $(am__append_2) \ + $(top_builddir)/lsan/libsanitizer_lsan.la \ + $(top_builddir)/ubsan/libsanitizer_ubsan.la $(am__append_2) \ $(am__append_3) $(LIBSTDCXX_RAW_CXX_LDFLAGS) libasan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(link_libasan) diff --git a/libsanitizer/configure b/libsanitizer/configure index dd952294b28..3d859acf3cb 100755 --- a/libsanitizer/configure +++ b/libsanitizer/configure @@ -12029,7 +12029,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12031 "configure" +#line 12032 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12135,7 +12135,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12137 "configure" +#line 12138 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -16523,7 +16523,7 @@ ac_config_files="$ac_config_files Makefile libsanitizer.spec libbacktrace/backtr ac_config_headers="$ac_config_headers config.h" -ac_config_files="$ac_config_files interception/Makefile sanitizer_common/Makefile libbacktrace/Makefile lsan/Makefile asan/Makefile ubsan/Makefile" +ac_config_files="$ac_config_files interception/Makefile sanitizer_common/Makefile libbacktrace/Makefile lsan/Makefile ubsan/Makefile asan/Makefile" if test "x$TSAN_SUPPORTED" = "xyes"; then @@ -17676,8 +17676,8 @@ do "sanitizer_common/Makefile") CONFIG_FILES="$CONFIG_FILES sanitizer_common/Makefile" ;; "libbacktrace/Makefile") CONFIG_FILES="$CONFIG_FILES libbacktrace/Makefile" ;; "lsan/Makefile") CONFIG_FILES="$CONFIG_FILES lsan/Makefile" ;; - "asan/Makefile") CONFIG_FILES="$CONFIG_FILES asan/Makefile" ;; "ubsan/Makefile") CONFIG_FILES="$CONFIG_FILES ubsan/Makefile" ;; + "asan/Makefile") CONFIG_FILES="$CONFIG_FILES asan/Makefile" ;; "tsan/Makefile") CONFIG_FILES="$CONFIG_FILES tsan/Makefile" ;; *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; @@ -19592,7 +19592,7 @@ _EOF . ${multi_basedir}/config-ml.in { ml_norecursion=; unset ml_norecursion;} ;; - "asan/Makefile":F) cat > vpsed$$ << \_EOF + "ubsan/Makefile":F) cat > vpsed$$ << \_EOF s!`test -f '$<' || echo '$(srcdir)/'`!! _EOF sed -f vpsed$$ $ac_file > tmp$$ @@ -19603,7 +19603,7 @@ _EOF . ${multi_basedir}/config-ml.in { ml_norecursion=; unset ml_norecursion;} ;; - "ubsan/Makefile":F) cat > vpsed$$ << \_EOF + "asan/Makefile":F) cat > vpsed$$ << \_EOF s!`test -f '$<' || echo '$(srcdir)/'`!! _EOF sed -f vpsed$$ $ac_file > tmp$$ diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac index 06d3a66e64f..a6f0639e6b0 100644 --- a/libsanitizer/configure.ac +++ b/libsanitizer/configure.ac @@ -370,7 +370,7 @@ AH_BOTTOM([#include "libbacktrace/backtrace-rename.h"]) AC_CONFIG_FILES([Makefile libsanitizer.spec libbacktrace/backtrace-supported.h]) AC_CONFIG_HEADER(config.h) -AC_CONFIG_FILES(AC_FOREACH([DIR], [interception sanitizer_common libbacktrace lsan asan ubsan], [DIR/Makefile ]), +AC_CONFIG_FILES(AC_FOREACH([DIR], [interception sanitizer_common libbacktrace lsan ubsan asan], [DIR/Makefile ]), [cat > vpsed$$ << \_EOF s!`test -f '$<' || echo '$(srcdir)/'`!! _EOF diff --git a/libsanitizer/ubsan/Makefile.am b/libsanitizer/ubsan/Makefile.am index 9e70b12d3fd..9c7430495b8 100644 --- a/libsanitizer/ubsan/Makefile.am +++ b/libsanitizer/ubsan/Makefile.am @@ -10,6 +10,7 @@ AM_CXXFLAGS += -std=gnu++11 ACLOCAL_AMFLAGS = -I m4 toolexeclib_LTLIBRARIES = libubsan.la +noinst_LTLIBRARIES = libsanitizer_ubsan.la ubsan_plugin_files = \ ubsan_diag.cc \ @@ -25,8 +26,11 @@ ubsan_plugin_files = \ ubsan_files = \ $(ubsan_plugin_files) \ ubsan_init_standalone.cc + ubsan_diag_standalone.cc -libubsan_la_SOURCES = $(ubsan_files) +libsanitizer_ubsan_la_SOURCES = $(ubsan_plugin_files) + +libubsan_la_SOURCES = $(ubsan_files) libubsan_la_LIBADD = $(top_builddir)/sanitizer_common/libsanitizer_common.la if !USING_MAC_INTERPOSE libubsan_la_LIBADD += $(top_builddir)/interception/libinterception.la diff --git a/libsanitizer/ubsan/Makefile.in b/libsanitizer/ubsan/Makefile.in index 0af2224eaf2..6fb87841222 100644 --- a/libsanitizer/ubsan/Makefile.in +++ b/libsanitizer/ubsan/Makefile.in @@ -102,15 +102,18 @@ am__uninstall_files_from_dir = { \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(toolexeclibdir)" -LTLIBRARIES = $(toolexeclib_LTLIBRARIES) -am__DEPENDENCIES_1 = -libubsan_la_DEPENDENCIES = \ - $(top_builddir)/sanitizer_common/libsanitizer_common.la \ - $(am__append_1) $(am__append_2) $(am__DEPENDENCIES_1) +LTLIBRARIES = $(noinst_LTLIBRARIES) $(toolexeclib_LTLIBRARIES) +libsanitizer_ubsan_la_LIBADD = am__objects_1 = ubsan_diag.lo ubsan_flags.lo ubsan_handlers.lo \ ubsan_handlers_cxx.lo ubsan_init.lo ubsan_type_hash.lo \ ubsan_type_hash_itanium.lo ubsan_type_hash_win.lo \ ubsan_value.lo +am_libsanitizer_ubsan_la_OBJECTS = $(am__objects_1) +libsanitizer_ubsan_la_OBJECTS = $(am_libsanitizer_ubsan_la_OBJECTS) +am__DEPENDENCIES_1 = +libubsan_la_DEPENDENCIES = \ + $(top_builddir)/sanitizer_common/libsanitizer_common.la \ + $(am__append_1) $(am__append_2) $(am__DEPENDENCIES_1) am__objects_2 = $(am__objects_1) ubsan_init_standalone.lo am_libubsan_la_OBJECTS = $(am__objects_2) libubsan_la_OBJECTS = $(am_libubsan_la_OBJECTS) @@ -130,7 +133,7 @@ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = $(libubsan_la_SOURCES) +SOURCES = $(libsanitizer_ubsan_la_SOURCES) $(libubsan_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -294,6 +297,7 @@ AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \ -std=gnu++11 ACLOCAL_AMFLAGS = -I m4 toolexeclib_LTLIBRARIES = libubsan.la +noinst_LTLIBRARIES = libsanitizer_ubsan.la ubsan_plugin_files = \ ubsan_diag.cc \ ubsan_flags.cc \ @@ -309,7 +313,8 @@ ubsan_files = \ $(ubsan_plugin_files) \ ubsan_init_standalone.cc -libubsan_la_SOURCES = $(ubsan_files) +libsanitizer_ubsan_la_SOURCES = $(ubsan_plugin_files) +libubsan_la_SOURCES = $(ubsan_files) libubsan_la_LIBADD = \ $(top_builddir)/sanitizer_common/libsanitizer_common.la \ $(am__append_1) $(am__append_2) $(LIBSTDCXX_RAW_CXX_LDFLAGS) @@ -388,6 +393,15 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done install-toolexeclibLTLIBRARIES: $(toolexeclib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(toolexeclib_LTLIBRARIES)'; test -n "$(toolexeclibdir)" || list=; \ @@ -420,6 +434,8 @@ clean-toolexeclibLTLIBRARIES: echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done +libsanitizer_ubsan.la: $(libsanitizer_ubsan_la_OBJECTS) $(libsanitizer_ubsan_la_DEPENDENCIES) $(EXTRA_libsanitizer_ubsan_la_DEPENDENCIES) + $(CXXLINK) $(libsanitizer_ubsan_la_OBJECTS) $(libsanitizer_ubsan_la_LIBADD) $(LIBS) libubsan.la: $(libubsan_la_OBJECTS) $(libubsan_la_DEPENDENCIES) $(EXTRA_libubsan_la_DEPENDENCIES) $(libubsan_la_LINK) -rpath $(toolexeclibdir) $(libubsan_la_OBJECTS) $(libubsan_la_LIBADD) $(LIBS) @@ -557,8 +573,8 @@ maintainer-clean-generic: @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-generic clean-libtool clean-toolexeclibLTLIBRARIES \ - mostlyclean-am +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + clean-toolexeclibLTLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) @@ -629,19 +645,21 @@ uninstall-am: uninstall-toolexeclibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-toolexeclibLTLIBRARIES ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags dvi dvi-am html html-am info 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-pdf install-pdf-am install-ps install-ps-am \ - install-strip install-toolexeclibLTLIBRARIES installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags uninstall uninstall-am uninstall-toolexeclibLTLIBRARIES - + clean-libtool clean-noinstLTLIBRARIES \ + clean-toolexeclibLTLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags dvi dvi-am \ + html html-am info 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-pdf install-pdf-am \ + install-ps install-ps-am install-strip \ + install-toolexeclibLTLIBRARIES installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-toolexeclibLTLIBRARIES + + ubsan_diag_standalone.cc # Use special rules for files that require RTTI support. ubsan_handlers_cxx.% ubsan_type_hash.% ubsan_type_hash_itanium.% : AM_CXXFLAGS += -frtti diff --git a/libsanitizer/ubsan/ubsan_diag.cc b/libsanitizer/ubsan/ubsan_diag.cc index 9adfb6b21fc..9c64ee3bf4f 100644 --- a/libsanitizer/ubsan/ubsan_diag.cc +++ b/libsanitizer/ubsan/ubsan_diag.cc @@ -481,13 +481,4 @@ bool __ubsan::IsISanFunctionCheckSuppressed(ReportOptions *Opts) { return false; } -extern "C" SANITIZER_INTERFACE_ATTRIBUTE -void __sanitizer_print_stack_trace() { - using namespace __ubsan; - - GET_REPORT_OPTIONS(false); - - PrintStackTrace(Opts.pc, Opts.bp); -} - #endif // CAN_SANITIZE_UB diff --git a/libsanitizer/ubsan/ubsan_diag_standalone.cc b/libsanitizer/ubsan/ubsan_diag_standalone.cc new file mode 100644 index 00000000000..ddc1be7018c --- /dev/null +++ b/libsanitizer/ubsan/ubsan_diag_standalone.cc @@ -0,0 +1,36 @@ +//===-- ubsan_diag_standalone.cc ------------------------------------------===// +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Diagnostic reporting for the standalone UBSan runtime. +// +//===----------------------------------------------------------------------===// + +#include "ubsan_platform.h" +#if CAN_SANITIZE_UB +#include "ubsan_diag.h" + +using namespace __ubsan; + +extern "C" { +SANITIZER_INTERFACE_ATTRIBUTE +void __sanitizer_print_stack_trace() { + uptr top = 0; + uptr bottom = 0; + bool request_fast_unwind = common_flags()->fast_unwind_on_fatal; + if (request_fast_unwind) + __sanitizer::GetThreadStackTopAndBottom(false, &top, &bottom); + + GET_CURRENT_PC_BP_SP; + (void)sp; + BufferedStackTrace stack; + stack.Unwind(kStackTraceMax, pc, bp, nullptr, top, bottom, + request_fast_unwind); + stack.Print(); +} +} // extern "C" + +#endif // CAN_SANITIZE_UB |