Commit Graph

199 Commits

Author SHA1 Message Date
Martin Liska
b4f1f01d45 Cherry-pick compiler-rt revision 338606 (PR sanitizer/86022).
Fix sizeof(struct pthread) in glibc 2.14.

2018-08-02  Martin Liska  <mliska@suse.cz>

        PR sanitizer/86022
	* sanitizer_common/sanitizer_linux_libcdep.cc (ThreadDescriptorSize):
        Cherry-pick compiler-rt revision 338606.

From-SVN: r263246
2018-08-02 09:32:58 +00:00
Marek Polacek
c191b1abe9 Cherry-pick compiler-rt revision 318044 and 319180.
[PowerPC][tsan] Update tsan to handle changed memory layouts in newer kernels
    
    In more recent Linux kernels with 47 bit VMAs the layout of virtual memory
    for powerpc64 changed causing the thread sanitizer to not work properly. This
    patch adds support for 47 bit VMA kernels for powerpc64.
    
    Tested on several 4.x and 3.x kernel releases.

Regtested/bootstrapped on ppc64le-linux with kernel 4.14; applying to
trunk/8.3.

2018-08-01  Marek Polacek  <polacek@redhat.com>

	PR sanitizer/86759
	* tsan/tsan_platform.h: Cherry-pick compiler-rt revision 318044.
	* tsan/tsan_platform_linux.cc: Cherry-pick compiler-rt revision
	319180.

From-SVN: r263229
2018-08-01 17:17:29 +00:00
H.J. Lu
c83b4b8242 libsanitizer: Mark REAL(swapcontext) with indirect_return attribute on x86
Cherry-pick compiler-rt revision 337603:

When shadow stack from Intel CET is enabled, the first instruction of all
indirect branch targets must be a special instruction, ENDBR.

lib/asan/asan_interceptors.cc has

...
  int res = REAL(swapcontext)(oucp, ucp);
...

REAL(swapcontext) is a function pointer to swapcontext in libc.  Since
swapcontext may return via indirect branch on x86 when shadow stack is
enabled, as in this case,

int res = REAL(swapcontext)(oucp, ucp);
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^  This function may be
returned via an indirect branch.

Here compiler must insert ENDBR after call, like

call *bar(%rip)
endbr64

I opened an LLVM bug:

https://bugs.llvm.org/show_bug.cgi?id=38207

to add the indirect_return attribute so that it can be used to inform
compiler to insert ENDBR after REAL(swapcontext) call.  We mark
REAL(swapcontext) with the indirect_return attribute if it is available.

This fixed:

https://bugs.llvm.org/show_bug.cgi?id=38249

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D49608

	PR target/86560
	* asan/asan_interceptors.cc (swapcontext) Cherry-pick
	compiler-rt revision 337603.
	* sanitizer_common/sanitizer_internal_defs.h (__has_attribute):
	Likewise.

From-SVN: r263009
2018-07-26 07:48:55 -07:00
Jakub Jelinek
bdfc619ed8 Revert
2018-07-04  Maxim Ostapenko  <m.ostapenko@samsung.com>

	PR sanitizer/84250
	* config/gnu-user.h (LIBASAN_EARLY_SPEC): Pass -lstdc++ for static
	libasan.
	* gcc.c: Do not pass LIBUBSAN_SPEC if ASan is enabled with UBSan.

	* Makefile.am: Reorder libs.
	* Makefile.in: Regenerate.
	* asan/Makefile.am: Define DCAN_SANITIZE_UB=1, add dependancy from
	libsanitizer_ubsan.la.
	* asan/Makefile.in: Regenerate.
	* ubsan/Makefile.am: Define new libsanitizer_ubsan.la library.
	* ubsan/Makefile.in: Regenerate.

From-SVN: r262433
2018-07-05 11:47:05 +02:00
Maxim Ostapenko
ca8dd9f274 re PR sanitizer/84250 (Symbol collision when using both Address and Undefined Behavior sanitizers (-fsanitize=address,undefined))
gcc/

2018-07-04  Maxim Ostapenko  <m.ostapenko@samsung.com>

	PR sanitizer/84250
	* config/gnu-user.h (LIBASAN_EARLY_SPEC): Pass -lstdc++ for static
	libasan.
	* gcc.c: Do not pass LIBUBSAN_SPEC if ASan is enabled with UBSan.

libsanitizer/

2018-07-04  Maxim Ostapenko  <m.ostapenko@samsung.com>

	PR sanitizer/84250
	* Makefile.am: Reorder libs.
	* Makefile.in: Regenerate.
	* asan/Makefile.am: Define DCAN_SANITIZE_UB=1, add dependancy from
	libsanitizer_ubsan.la.
	* asan/Makefile.in: Regenerate.
	* ubsan/Makefile.am: Define new libsanitizer_ubsan.la library.
	* ubsan/Makefile.in: Regenerate.

From-SVN: r262421
2018-07-04 22:49:06 +03:00
Denis Khalikov
3b07c0e5e4 re PR sanitizer/86090 ([ASAN] ASAN does not properly configure libbacktrace.)
2018-06-13  Denis Khalikov  <d.khalikov@partner.samsung.com>

libsanitizer/

	PR sanitizer/86090
	* configure.ac: Check for lstat and readlink.
	* configure, config.h.in: Rebuild.

From-SVN: r261564
2018-06-13 22:51:42 +03:00
Matthias Klose
5b87c1fe09 re PR sanitizer/86012 (libsanitizer build failure on sparc64-linux-gnu)
2018-05-31  Matthias Klose  <doko@ubuntu.com>

        PR sanitizer/86012
        * sanitizer_common/sanitizer_platform_limits_posix.cc: Define
        SIZEOF_STRUCT_USTAT for 32bit sparc.

From-SVN: r260990
2018-05-31 09:57:33 +00:00
H.J. Lu
71b55d45e4 libsanitizer: Use pre-computed size of struct ustat for Linux
Cherry-pick compiler-rt revision 333213:

<sys/ustat.h> has been removed from glibc 2.28 by:

commit cf2478d53ad7071e84c724a986b56fe17f4f4ca7
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Sun Mar 18 11:28:59 2018 +0800

    Deprecate ustat syscall interface

This patch uses pre-computed size of struct ustat for Linux.

	PR sanitizer/85835
	* sanitizer_common/sanitizer_platform_limits_posix.cc: Don't
	include <sys/ustat.h> for Linux.
	(SIZEOF_STRUCT_USTAT): New.
	(struct_ustat_sz): Use SIZEOF_STRUCT_USTAT for Linux.

From-SVN: r260684
2018-05-24 12:52:32 -07:00
Hans-Peter Nilsson
752361c980 If someone has access to a 64-bit mips-linux system to test this (with the obvious edit), that'd be really nice.
If someone has access to a 64-bit mips-linux system to test
this (with the obvious edit), that'd be really nice.  Until
then, best to not introduce possible build failures.

	* configure.tgt <mips*-*-linux*>: Enable build, excluding
	mips*64*-*-linux*.

From-SVN: r259665
2018-04-26 01:16:47 +00:00
Hans-Peter Nilsson
9f943b2446 As mentioned in <http://gcc.gnu.org/ml/gcc/2018-03/msg00133.html> the bogus adjustment to 160 from 144 (which is reverted here)...
As mentioned in <http://gcc.gnu.org/ml/gcc/2018-03/msg00133.html>
the bogus adjustment to 160 from 144 (which is reverted here),
is a single-token commit in upstream r301307, an attempt to
correct a failed build due to an upstream change to compile the
runtime with D_FILE_OFFSET_BITS=64.  The correct fix is here:
just use the right include.  Yes, user-struct-stat64-as-stat is
actually 160 for MIPS o32 and I hear user-struct-stat is also
160 for n32.  There are additional fields appended for
user-struct-stat!  I guess for MIPS it's as bad as it gets for
mixing up kernel and user struct stat.  The context of the patch
doesn't show that in the #else there's the correct include, the
one for <asm/stat.h> to get the kernel-struct-stat.  If you
can't compile it, IMHO the kernel headers are just too old; 3.2
is fine for example.

	* sanitizer_common/sanitizer_platform_limits_linux.cc: Do not
	take the shortcut to #include <sys/stat.h> for MIPS instead of
	the kernel <asm/stat.h>.  Explain why sys/stat.h is misleading
	or wrong to get the kernel struct stat.
	* sanitizer_common/sanitizer_platform_limits_posix.h [__mips__]:
	Correct the value for 32-bit non-android struct_kernel_stat_sz.

From-SVN: r259664
2018-04-26 01:12:56 +00:00
Hans-Peter Nilsson
bc40f16691 This appears to be present in compiler-rt upstream, but as part of more intrusive changes.
This appears to be present in compiler-rt upstream, but as part
of more intrusive changes.  For gcc, the lack of this results in
a fatal warning (-Werror) at build-time.

	* sanitizer_common/sanitizer_atomic_clang_other.h [_MIPS_SIM
	&& _MIPS_SIM == _ABIO32] (lock): Add initializer for .pad member.

From-SVN: r259663
2018-04-26 01:09:27 +00:00
H.J. Lu
7b47ecf2f7 Regenerate configure of target libraries
* configure: Regenerated.

From-SVN: r259610
2018-04-24 09:45:26 -07:00
Jakub Jelinek
a0e1df888d cet.m4 (GCC_CET_FLAGS): Default to --disable-cet, replace --enable-cet=default with --enable-cet=auto.
* config/cet.m4 (GCC_CET_FLAGS): Default to --disable-cet, replace
	--enable-cet=default with --enable-cet=auto.

	* doc/install.texi: Document --disable-cet being the default and
	--enable-cet=auto.

	* configure: Regenerated.

From-SVN: r259487
2018-04-19 09:45:51 +02:00
David Malcolm
001ddaa852 re PR jit/85384 (libgccjit does not work if --with-gcc-major-version is used)
PR jit/85384
	* acx.m4 (GCC_BASE_VER): Remove \$\$ from sed expression.

	* configure.ac (gcc-driver-name.h): Honor --with-gcc-major-version
	by using gcc_base_ver to generate a gcc_driver_version, and use
	it when generating GCC_DRIVER_NAME.
	* configure: Regenerate.

	* configure: Regenerate.

From-SVN: r259462
2018-04-18 11:46:58 +02:00
Bill Seurer
19ddb884eb re PR sanitizer/85389 (posix_memalign() crash with address sanitizer when passing invalid arguments)
PR sanitizer/85389
	* asan/asan_allocator.h (kAllocatorSpace): For __powerpc64__ change
	from 0xa0000000000ULL to ~(uptr)0.

From-SVN: r259459
2018-04-18 09:02:40 +02:00
Jakub Jelinek
359ea407e9 re PR sanitizer/84761 (AddressSanitizer is not compatible with glibc 2.27 on x86)
PR sanitizer/84761
	* sanitizer_common/sanitizer_linux_libcdep.cc (__GLIBC_PREREQ):
	Define if not defined.
	(DL_INTERNAL_FUNCTION): Don't define.
	(InitTlsSize): For __i386__ if not compiled against glibc 2.27+
	determine at runtime whether to use regparm(3), stdcall calling
	convention for older glibcs or normal calling convention for
	newer glibcs for call to _dl_get_tls_static_info.

From-SVN: r258663
2018-03-19 21:47:29 +01:00
Segher Boessenkool
1422855a40 rs6000: Fix sanitizer frame unwind on 32-bit ABIs
This fixes more than half of our testcase failures on BE.


libsanitizer/
	* sanitizer_common/sanitizer_stacktrace.cc
	(BufferedStackTrace::FastUnwindStack): Use the correct frame offset
	for PowerPC SYSV ABI.

From-SVN: r258525
2018-03-14 14:46:03 +01:00
Igor Tsimbalist
14e335edc8 CET shouldn't be enabled in 32-bit run-time libraries by defualt
ENDBR32 and RDSSPD are multi-byte NOPs on x86-64 processors and
newer x86 processors, starting Pentium Pro.  They are UD on older
32-bit processors. Detect this at configure time and adjust the
default value for enable_cet. GCC will enable CET in 32-bit run-time
libraries in any case if --enable-cet is used to configure GCC.

	PR target/84148
	* config/cet.m4: Check if target support multi-byte NOPS (SSE).
	* libatomic/configure: Regenerate.
	* libbacktrace/configure: Likewise.
	* libgcc/configure: Likewise.
	* libgfortran/configure: Likewise.
	* libgomp/configure: Likewise.
	* libitm/configure: Likewise.
	* libmpx/configure: Likewise.
	* libobjc/configure: Likewise.
	* libquadmath/configure: Likewise.
	* libsanitizer/configure: Likewise.
	* libssp/configure: Likewise.
	* libstdc++-v3/configure: Likewise.
	* libvtv/configure: Likewise.

From-SVN: r257809
2018-02-19 17:25:49 +01:00
Rainer Orth
9dfc6e8394 Add upstream svn rev for PR sanitizer/82825.
From-SVN: r257405
2018-02-06 08:16:22 +00:00
Martin Liska
4c4f3c3fef Cherry-pick libsanitizer pointer-pair tristate option.
2018-02-05  Martin Liska  <mliska@suse.cz>

	* doc/invoke.texi: Cherry-pick upstream r323995.
2018-02-05  Martin Liska  <mliska@suse.cz>

	* c-c++-common/asan/pointer-compare-1.c: Adjust ASAN_OPTIONS
	options.
	* c-c++-common/asan/pointer-compare-2.c: Likewise.
	* c-c++-common/asan/pointer-subtract-1.c: Likewise.
	* c-c++-common/asan/pointer-subtract-2.c: Likewise.
	* c-c++-common/asan/pointer-subtract-3.c: Likewise.
	* c-c++-common/asan/pointer-subtract-4.c: Likewise.
	* c-c++-common/asan/pointer-compare-3.c: New test.
2018-02-05  Martin Liska  <mliska@suse.cz>

	* asan/asan_flags.inc: Cherry-pick upstream r323995.
	* asan/asan_report.cc (CheckForInvalidPointerPair):
	Cherry-pick upstream r323995.

From-SVN: r257387
2018-02-05 11:01:50 +00:00
Rainer Orth
2d509539db Guard against undefined weak symbols before Mac OS X 10.9 (PR sanitizer/82825)
PR sanitizer/82825
	* sanitizer_common/sanitizer_internal_defs.h: Cherry-pick upstream
	r??????.

From-SVN: r256813
2018-01-17 19:31:43 +00:00
Rainer Orth
1f7273e5db Allow for lack of VM_MEMORY_OS_ALLOC_ONCE on Mac OS X (PR sanitizer/82824)
PR sanitizer/82824
	* lsan/lsan_common_mac.cc: Cherry-pick upstream r322437.

From-SVN: r256650
2018-01-13 21:01:27 +00:00
Martin Liska
05abad4cca invoke.texi: Document the options.
gcc/
	* doc/invoke.texi: Document the options.
	* flag-types.h (enum sanitize_code): Add
	SANITIZE_POINTER_COMPARE and SANITIZE_POINTER_SUBTRACT.
	* ipa-inline.c (sanitize_attrs_match_for_inline_p): Add handling
	of SANITIZE_POINTER_COMPARE and SANITIZE_POINTER_SUBTRACT.
	* opts.c: Define new sanitizer options.
	* sanitizer.def (BUILT_IN_ASAN_POINTER_COMPARE): Likewise.
	(BUILT_IN_ASAN_POINTER_SUBTRACT): Likewise.
gcc/c/
	* c-typeck.c (pointer_diff): Add new argument and instrument
	pointer subtraction.
	(build_binary_op): Similar for pointer comparison.
gcc/cp/
	* typeck.c (pointer_diff): Add new argument and instrument
	pointer subtraction.
	(cp_build_binary_op): Create compound expression if doing an
	instrumentation.
gcc/testsuite/
	* c-c++-common/asan/pointer-compare-1.c: New test.
	* c-c++-common/asan/pointer-compare-2.c: New test.
	* c-c++-common/asan/pointer-subtract-1.c: New test.
	* c-c++-common/asan/pointer-subtract-2.c: New test.
	* c-c++-common/asan/pointer-subtract-3.c: New test.
	* c-c++-common/asan/pointer-subtract-4.c: New test.
libsanitizer/
	* asan/asan_descriptions.cc: Cherry-pick upstream r319668.
	* asan/asan_descriptions.h: Likewise.
	* asan/asan_report.cc: Likewise.
	* asan/asan_thread.cc: Likewise.
	* asan/asan_thread.h: Likewise.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r255404
2017-12-05 10:23:25 +01:00
Igor Tsimbalist
9069eb28d4 Enable building libsanitizer with Intel CET
libsanitizer/
	* acinclude.m4: Add enable.m4 and cet.m4.
	* Makefile.in: Regenerate.
	* asan/Makefile.am: Update AM_CXXFLAGS.
	* asan/Makefile.in: Regenerate.
	* configure: Likewise.
	* configure.ac: Set CET_FLAGS. Update EXTRA_CFLAGS,
	EXTRA_CXXFLAGS, EXTRA_ASFLAGS.
	* interception/Makefile.am: Update AM_CXXFLAGS.
	* interception/Makefile.in: Regenerate.
	* libbacktrace/Makefile.am: Update AM_CFLAGS, AM_CXXFLAGS.
	* libbacktrace/Makefile.in: Regenerate.
	* lsan/Makefile.am: Update AM_CXXFLAGS.
	* lsan/Makefile.in: Regenerate.
	* sanitizer_common/Makefile.am: Update AM_CXXFLAGS,
	AM_CCASFLAGS.
	* sanitizer_common/sanitizer_linux_x86_64.S: Include cet.h.
	Add _CET_ENDBR macro.
	* sanitizer_common/Makefile.in: Regenerate.
	* tsan/Makefile.am: Update AM_CXXFLAGS.
	* tsan/Makefile.in: Regenerate.
	* tsan/tsan_rtl_amd64.S Include cet.h. Add _CET_ENDBR macro.
	* ubsan/Makefile.am: Update AM_CXXFLAGS.
	* ubsan/Makefile.in: Regenerate.

From-SVN: r254896
2017-11-17 22:34:50 +01:00
Jakub Jelinek
5925290f7d re PR bootstrap/82670 (UBSAN bootstrap broken after recent libsanitizer merge)
PR bootstrap/82670
	* ubsan/Makefile.am (ubsan_files): Remove ubsan_init_standalone.cc
	and ubsan_signals_standalone.cc.
	* ubsan/Makefile.in: Regenerated.

From-SVN: r254518
2017-11-08 09:17:02 +01:00
Tom de Vries
735e62b905 [libsanitizer] Remove semicolon after do {} while (0) in macro body
2017-11-05  Tom de Vries  <tom@codesourcery.com>

	PR other/82784
	* asan/asan_poisoning.cc (CHECK_SMALL_REGION): Remove semicolon after
	"do {} while (0)".
	* lsan/lsan_common.cc (LOG_POINTERS, LOG_THREADS): Same.

From-SVN: r254419
2017-11-05 09:57:17 +00:00
Jakub Jelinek
9a45ffbd12 re PR sanitizer/82595 (bootstrap fails in libsanitizer on powerpc64-unknown-linux-gnu)
PR sanitizer/82595
	* config/gnu-user.h (LIBTSAN_EARLY_SPEC): Add libtsan_preinit.o
	for -fsanitize=thread link of executables.
	(LIBLSAN_EARLY_SPEC): Add liblsan_preinit.o for -fsanitize=leak
	link of executables.

	* lsan/lsan.h (__lsan_init): Add SANITIZER_INTERFACE_ATTRIBUTE.
	* lsan/Makefile.am (nodist_toolexeclib_HEADERS): Add
	liblsan_preinit.o.
	(lsan_files): Remove lsan_preinit.cc.
	(liblsan_preinit.o): New rule.
	* lsan/Makefile.in: Regenerated.

From-SVN: r253925
2017-10-20 09:32:35 +02:00
Jakub Jelinek
5d3805fca3 ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
	builtins, store max (log2 (align), 0) into uchar field instead of
	align into uptr field.
	(ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins,
	store uchar 0 field instead of uptr 0 field.
	(instrument_nonnull_return): Use _v1 suffixed nonnull return builtin,
	instead of passing one address of struct with 2 locations pass
	two addresses of structs with 1 location each.
	* sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH,
	BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT,
	BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN,
	BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed.
	(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1,
	BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT,
	BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1,
	BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins.

	* c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword
	from expected output regexps.
	* c-c++-common/ubsan/float-cast-overflow-2.c: Likewise.
	* c-c++-common/ubsan/float-cast-overflow-3.c: Likewise.
	* c-c++-common/ubsan/float-cast-overflow-4.c: Likewise.
	* c-c++-common/ubsan/float-cast-overflow-5.c: Likewise.
	* c-c++-common/ubsan/float-cast-overflow-6.c: Likewise.
	* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
	* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
	* c-c++-common/ubsan/float-cast-overflow-10.c: Likewise.
	* g++.dg/ubsan/float-cast-overflow-bf.C: Likewise.
	* gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise.
	* g++.dg/asan/default-options-1.C (__asan_default_options): Add
	used attribute.
	* g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2
	in the environment.

	* All source files: Merge from upstream 315899.
        * asan/Makefile.am (nodist_saninclude_HEADERS): Add
	include/sanitizer/tsan_interface.h.
        * asan/libtool-version: Bump the libasan SONAME.
	* lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc.
	(lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc.
        * sanitizer_common/Makefile.am (sanitizer_common_files): Add
	sancov_flags.cc, sanitizer_allocator_checks.cc,
	sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc,
	sanitizer_file.cc, sanitizer_mac_libcdep.cc and
	sanitizer_stoptheworld_mac.cc.  Remove sanitizer_coverage_libcdep.cc
	and sanitizer_coverage_mapping_libcdep.cc.
        * tsan/Makefile.am (tsan_files): Add tsan_external.cc.
	* ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1.
	(ubsan_files): Add ubsan_init_standalone.cc and
	ubsan_signals_standalone.cc.
	* ubsan/libtool-version: Bump the libubsan SONAME.
        * asan/Makefile.in: Regenerate.
        * lsan/Makefile.in: Regenerate.
        * sanitizer_common/Makefile.in: Regenerate.
        * tsan/Makefile.in: Regenerate.
	* ubsan/Makefile.in: Regenerate.

From-SVN: r253887
2017-10-19 13:23:59 +02:00
H.J. Lu
bf4df9e6b4 Add sanitizer_linux_x86_64.lo if __x86_64__ is defined by $CC
Since size of "void *" is 4 bytes for x32, check if __x86_64__ is defined
by $CC, instead of

if test x$ac_cv_sizeof_void_p = x8; then

to decide wether sanitizer_linux_x86_64.lo should be used.

	PR sanitizer/82379
	* configure.tgt (SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS): Set
	to sanitizer_linux_x86_64.lo if __x86_64__ is defined by $CC.

From-SVN: r253441
2017-10-05 03:39:32 -07:00
Jakub Jelinek
d1453bec27 backtrace-rename.h (backtrace_uncompress_zdebug): Define.
* libbacktrace/backtrace-rename.h (backtrace_uncompress_zdebug):
	Define.

From-SVN: r253351
2017-10-02 16:00:53 +02:00
Jakub Jelinek
a5320f3ce2 * include/system/sys/ptrace.h: New file.
From-SVN: r250910
2017-08-07 10:32:47 +02:00
Jakub Jelinek
c9b39a4955 re PR sanitizer/80998 (Implement -fsanitize=pointer-overflow)
PR sanitizer/80998
	* sanopt.c (pass_sanopt::execute): Handle IFN_UBSAN_PTR.
	* tree-ssa-alias.c (call_may_clobber_ref_p_1): Likewise.
	* flag-types.h (enum sanitize_code): Add SANITIZER_POINTER_OVERFLOW.
	Or it into SANITIZER_UNDEFINED.
	* ubsan.c: Include gimple-fold.h and varasm.h.
	(ubsan_expand_ptr_ifn): New function.
	(instrument_pointer_overflow): New function.
	(maybe_instrument_pointer_overflow): New function.
	(instrument_object_size): Formatting fix.
	(pass_ubsan::execute): Call instrument_pointer_overflow
	and maybe_instrument_pointer_overflow.
	* internal-fn.c (expand_UBSAN_PTR): New function.
	* ubsan.h (ubsan_expand_ptr_ifn): Declare.
	* sanitizer.def (__ubsan_handle_pointer_overflow,
	__ubsan_handle_pointer_overflow_abort): New builtins.
	* tree-ssa-tail-merge.c (merge_stmts_p): Handle IFN_UBSAN_PTR.
	* internal-fn.def (UBSAN_PTR): New internal function.
	* opts.c (sanitizer_opts): Add pointer-overflow.
	* lto-streamer-in.c (input_function): Handle IFN_UBSAN_PTR.
	* fold-const.c (build_range_check): Compute pointer range check in
	integral type if pointer arithmetics would be needed.  Formatting
	fixes.
gcc/testsuite/
	* c-c++-common/ubsan/ptr-overflow-1.c: New test.
	* c-c++-common/ubsan/ptr-overflow-2.c: New test.
libsanitizer/
	* ubsan/ubsan_handlers.cc: Cherry-pick upstream r304461.
	* ubsan/ubsan_checks.inc: Likewise.
	* ubsan/ubsan_handlers.h: Likewise.

From-SVN: r250656
2017-07-28 12:37:51 +02:00
Jakub Jelinek
144e36a796 re PR sanitizer/81066 (sanitizer_stoptheworld_linux_libcdep.cc:276:22: error: aggregate ‘sigaltstack handler_stack’ has incomplete type and cannot be defined)
PR sanitizer/81066
	* sanitizer_common/sanitizer_linux.h: Cherry-pick upstream r307969.
	* sanitizer_common/sanitizer_linux.cc: Likewise.
	* sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc: Likewise.
	* tsan/tsan_platform_linux.cc: Likewise.

From-SVN: r250200
2017-07-14 11:10:45 +02:00
Martin Liska
d9f8c5af8b Cherry-pick upstream r299036 from libsanitizer (PR sanitizer/80166).
2017-04-06  Martin Liska  <mliska@suse.cz>

	PR sanitizer/80166
	* sanitizer_common/sanitizer_common_interceptors.inc (INTERCEPTOR):
	Cherry-pick upstream r299036.
2017-04-06  Martin Liska  <mliska@suse.cz>

	PR sanitizer/80166
	* gcc.dg/asan/pr80166.c: New test.

From-SVN: r246730
2017-04-06 13:42:24 +00:00
Jakub Jelinek
fd6cba40e1 re PR sanitizer/78158 (Strange data race detection with thread sanitizer)
PR sanitizer/78158
	* tsan/tsan_interface_atomic.cc: Cherry-pick upstream r298378.

From-SVN: r246402
2017-03-22 19:46:54 +01:00
Andreas Tobler
9b9ad3606d re PR sanitizer/79562 (sanitizer breaks bootstrap of x86_64-*-freebsd)
2017-02-16  Andreas Tobler  <andreast@gcc.gnu.org>

    PR sanitizer/79562
    * sanitizer_common/sanitizer_platform_limits_posix.cc: Cherry-pick
    upstream r294806.

From-SVN: r245520
2017-02-16 22:23:51 +01:00
Jakub Jelinek
1509524bcc re PR sanitizer/79341 (Many Asan tests fail on s390)
PR sanitizer/79341
	* configure.tgt (s390*-*-linux*): Don't disable libsanitizer on
	s390-linux 31-bit.
	* sanitizer_common/sanitizer_internal_defs.h: Cherry-pick upstream
	r294793.
	* sanitizer_common/sanitizer_common_interceptors.inc: Cherry-pick
	upstream r294790.
	* sanitizer_common/sanitizer_linux_s390.cc: Cherry-pick upstream
	r294799.

From-SVN: r245350
2017-02-11 00:34:49 +01:00
Maxim Ostapenko
778e0ac397 re PR sanitizer/78663 (Hundreds of asan failures on x86_64-apple-darwin10 at r243019)
PR sanitizer/78663
	* sanitizer_common/sanitizer_mac.cc: Cherry-pick upstream r293992.
	* sanitizer_common/sanitizer_platform_interceptors.h: Likewise.

From-SVN: r245149
2017-02-03 14:17:59 +02:00
Jakub Jelinek
4997a71dbb s390.c (s390_asan_shadow_offset): New function.
gcc/
	* config/s390/s390.c (s390_asan_shadow_offset): New function.
	(TARGET_ASAN_SHADOW_OFFSET): Redefine.
libsanitizer/
	* configure.tgt: Enable asan and ubsan on 64-bit s390*-*-linux*.

From-SVN: r245060
2017-01-31 14:50:20 +01:00
Jakub Jelinek
c831801da8 * configure.tgt: Enable tsan and lsan on powerpc64{,le}-*-linux*.
From-SVN: r244854
2017-01-24 09:19:37 +01:00
Jakub Jelinek
86b2a5583b re PR sanitizer/79168 (libtsan fails to link when cross compiling GCC tip for Aarch64 target)
PR sanitizer/79168
	* merge.sh (change_comment_headers): Don't remove 2nd and 3rd line
	if the 3rd line doesn't contain 'The LLVM Compiler Infrastructure'
	text.
	* sanitizer_common/sanitizer_linux_mips64.S: Regenerated.
	* sanitizer_common/sanitizer_linux_x86_64.S: Likewise.
	* tsan/tsan_ppc_regs.h: Likewise.
	* tsan/tsan_rtl_aarch64.S: Likewise.
	* tsan/tsan_rtl_mips64.S: Likewise.
	* tsan/tsan_rtl_ppc64.S: Likewise.

From-SVN: r244844
2017-01-24 01:18:36 +01:00
Jakub Jelinek
73aa401ecf re PR other/79046 (g++ -print-file-name=plugin uses full version number in path)
PR other/79046
libatomic/
	* testsuite/Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead
	of cat to get version from BASE-VER file.
	* testsuite/Makefile.in: Regenerated.
libffi/
	* configure.ac: Add GCC_BASE_VER.
	* include/Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead
	of cat to get version from BASE-VER file.
	* configure: Regenerated.
	* testsuite/Makefile.in: Regenerated.
	* include/Makefile.in: Regenerated.
	* Makefile.in: Regenerated.
	* man/Makefile.in: Regenerated.
libgomp/
	* testsuite/Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead
	of cat to get version from BASE-VER file.
	* testsuite/Makefile.in: Regenerated.
libitm/
	* testsuite/Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead
	of cat to get version from BASE-VER file.
	* testsuite/Makefile.in: Regenerated.
libmpx/
	* mpxrt/Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead
	of cat to get version from BASE-VER file.
	* mpxwrap/Makefile.am (gcc_version): Likewise.
	* mpxrt/Makefile.in: Regenerated.
	* mpxwrap/Makefile.in: Regenerated.
liboffloadmic/
	* plugin/configure.ac: Add GCC_BASE_VER.
	* plugin/Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead
	of cat to get version from BASE-VER file.
	* plugin/configure: Regenerated.
	* plugin/aclocal.m4: Regenerated.
	* plugin/Makefile.in: Regenerated.
libsanitizer/
	* interception/Makefile.am (gcc_version): Use @get_gcc_base_ver@
	instead of cat to get version from BASE-VER file.
	* asan/Makefile.am (gcc_version): Likewise.
	* ubsan/Makefile.am (gcc_version): Likewise.
	* sanitizer_common/Makefile.am (gcc_version): Likewise.
	* lsan/Makefile.am (gcc_version): Likewise.
	* tsan/Makefile.am (gcc_version): Likewise.
	* interception/Makefile.in: Regenerated.
	* asan/Makefile.in: Regenerated.
	* ubsan/Makefile.in: Regenerated.
	* sanitizer_common/Makefile.in: Regenerated.
	* lsan/Makefile.in: Regenerated.
	* tsan/Makefile.in: Regenerated.
libvtv/
	* testsuite/Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead
	of cat to get version from BASE-VER file.
	* testsuite/Makefile.in: Regenerated.

From-SVN: r244742
2017-01-21 09:47:11 +01:00
Jakub Jelinek
3c36aa6ba2 re PR other/79046 (g++ -print-file-name=plugin uses full version number in path)
PR other/79046
	* configure: Regenerated.
config/
	* acx.m4 (GCC_BASE_VER): New m4 function.
	(ACX_TOOL_DIRS): Require GCC_BASE_VER, for
	--with-gcc-major-version-only use just major number from BASE-VER.
gcc/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.in (version): Use @get_gcc_base_ver@ instead of cat to get
	version from BASE-VER file.
	(CFLAGS-gcc.o): Add -DBASEVER=$(BASEVER_s).
	(gcc.o): Depend on $(BASEVER).
	* common.opt (dumpfullversion): New option.
	* gcc.c (driver_handle_option): Handle OPT_dumpfullversion.
	* doc/invoke.texi: Document -dumpfullversion.
	* doc/install.texi: Document --with-gcc-major-version-only.
	* configure: Regenerated.
libatomic/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* testsuite/Makefile.in: Regenerated.
	* configure: Regenerated.
	* Makefile.in: Regenerated.
libgomp/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* testsuite/Makefile.in: Regenerated.
	* configure: Regenerated.
	* Makefile.in: Regenerated.
libgcc/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.in (version): Use @get_gcc_base_ver@ instead of cat to get
	version from BASE-VER file.
	* configure: Regenerated.
libssp/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* configure: Regenerated.
	* Makefile.in: Regenerated.
liboffloadmic/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* aclocal.m4: Include ../config/acx.m4.
	* configure: Regenerated.
	* Makefile.in: Regenerated.
libquadmath/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* configure: Regenerated.
	* Makefile.in: Regenerated.
libmpx/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* configure: Regenerated.
	* Makefile.in: Regenerated.
libada/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.in (version): Use @get_gcc_base_ver@ instead of cat to get
	version from BASE-VER file.
	* configure: Regenerated.
lto-plugin/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* configure: Regenerated.
	* Makefile.in: Regenerated.
libitm/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* testsuite/Makefile.in: Regenerated.
	* configure: Regenerated.
	* Makefile.in: Regenerated.
fixincludes/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.in (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* configure: Regenerated.
libcilkrts/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* aclocal.m4: Include ../config/acx.m4.
	* configure: Regenerated.
	* Makefile.in: Regenerated.
libcc1/
	* configure.ac: Add GCC_BASE_VER.  For --with-gcc-major-version-only
	use just major number from BASE-VER.
	* configure: Regenerated.
	* Makefile.in: Regenerated.
libobjc/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.in (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* configure: Regenerated.
libstdc++-v3/
	* configure.ac: Add GCC_BASE_VER.
	* fragment.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* po/Makefile.in: Regenerated.
	* libsupc++/Makefile.in: Regenerated.
	* testsuite/Makefile.in: Regenerated.
	* src/Makefile.in: Regenerated.
	* configure: Regenerated.
	* Makefile.in: Regenerated.
	* include/Makefile.in: Regenerated.
	* doc/Makefile.in: Regenerated.
	* python/Makefile.in: Regenerated.
	* src/c++11/Makefile.in: Regenerated.
	* src/c++98/Makefile.in: Regenerated.
	* src/filesystem/Makefile.in: Regenerated.
libvtv/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* testsuite/Makefile.in: Regenerated.
	* configure: Regenerated.
	* Makefile.in: Regenerated.
libsanitizer/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* libbacktrace/Makefile.in: Regenerated.
	* interception/Makefile.in: Regenerated.
	* asan/Makefile.in: Regenerated.
	* ubsan/Makefile.in: Regenerated.
	* configure: Regenerated.
	* sanitizer_common/Makefile.in: Regenerated.
	* lsan/Makefile.in: Regenerated.
	* Makefile.in: Regenerated.
	* tsan/Makefile.in: Regenerated.
libgfortran/
	* configure.ac: Add GCC_BASE_VER.
	* Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
	get version from BASE-VER file.
	* configure: Regenerated.
	* Makefile.in: Regenerated.

From-SVN: r244521
2017-01-17 10:38:48 +01:00
James Clarke
942136a43d re PR sanitizer/78992 (Incorrect sigaction definition on 32-bit sparc)
PR sanitizer/78992
	* sanitizer_common/sanitizer_platform_limits_posix.h
	(struct __sanitizer_sigaction): Cherry-pick upstream r291561.

From-SVN: r244275
2017-01-10 16:22:56 +01:00
Maxim Ostapenko
11bbe99531 Add PR sanitizer/78532 patch to libsanitizer/LOCAL_PATCHES.
From-SVN: r243016
2016-11-30 14:32:55 +02:00
Maxim Ostapenko
d61ed91ece re PR sanitizer/78532 (libsanitizer fails to build on sparc64-linux-gnu)
PR sanitizer/78532
	* sanitizer_common/sanitizer_platform_limits_posix.h
	(__sanitizer_sigaction): Adjust for sparc targets and various Glibc
	versions.

From-SVN: r243014
2016-11-30 14:31:07 +02:00
Markus Trippelsdorf
f4214e239f Remove r242480 from libsanitizer/LOCAL_PATCHES
The fix is now upstream.

	* LOCAL_PATCHES: Remove r242480.

From-SVN: r242957
2016-11-29 13:13:31 +00:00
Rainer Orth
0021284370 Add PR sanitizer/78267 patch to libsanitizer/LOCAL_PATCHES
From-SVN: r242634
2016-11-20 10:51:53 +00:00
Rainer Orth
97448adf21 Fix libsanitizer build on OS X 10.1[01], macOS 10.12 (PR sanitizer/78267)
fixincludes:
	PR sanitizer/78267
	* inclhack.def (darwin_availabilityinternal, darwin_os_trace_1)
	(darwin_os_trace_2, darwin_os_trace_3): New fixes.
	(hpux_stdint_least_fast): Remove spurious _EOFix_.
	* fixincl.x: Regenerate.
	* tests/bases/AvailabilityInternal.h: New file.
	* tests/bases/os/trace.h: New file.

2016-11-20  Jack Howarth  <howarth.at.gcc@gmail.com>

	libsanitizer:
	PR sanitizer/78267
	* sanitizer_common/sanitizer_mac.cc: Include <os/trace.h> only if
	compiler supports blocks extension.

From-SVN: r242633
2016-11-20 10:49:47 +00:00
Markus Trippelsdorf
61a58d07c6 Add revsison to libsanitizer/LOCAL_PATCHES
From-SVN: r242481
2016-11-16 11:23:47 +00:00