Commit Graph

6018 Commits

Author SHA1 Message Date
Chris Bieneman 2a6c13274c [CMake] [builtins] Only include the atomic builtins if(APPLE).
There are lingering issues building the atomic builtins with various versions of gcc. To unblock people we can only include them on Apple platforms where they are more tested.

llvm-svn: 248386
2015-09-23 15:28:44 +00:00
Chris Bieneman 9c46be2d2f Code cleanup based on post-commit review from Aaron Ballman.
llvm-svn: 248385
2015-09-23 15:28:35 +00:00
Chris Bieneman 0d427986f5 [CMake] [Darwin] Bug 21562 - Add a CMake equivalent for make/platform/clang_darwin.mk in compiler_rt
Summary:
Building the builtins on Darwin platforms is a bit complicated. This is a first-pass implementation of the functionality from clang_darwin.mk into CMake.

When building the builtins on Darwin we have layers of blacklists that we apply based on platform, architecture, and minimum supported OS version.

Reviewers: bogner, filcab, bob.wilson, samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D13059

llvm-svn: 248383
2015-09-23 15:18:17 +00:00
Chris Bieneman be61720c4e [builtins] Fixing broken bot building on linux with -Werror
Returning a void expression is bad.

llvm-svn: 248346
2015-09-22 23:35:24 +00:00
Evgeniy Stepanov a7ecbe5685 [asan] Add missing -pthread in tests.
llvm-svn: 248332
2015-09-22 22:24:46 +00:00
Chris Bieneman 0a9466c11e [builtins] One more stab at fixing the bots.
llvm-svn: 248330
2015-09-22 22:19:21 +00:00
Chris Bieneman 7908b12967 [builtins] Fixing atomic builtins to be compiled out if stdatomic.h isn't available.
This should fix the bots broken by r248322.

Reviewed by bogner over my shoulder.

llvm-svn: 248328
2015-09-22 21:50:43 +00:00
Evgeniy Stepanov 9147de0ddf [asan] Versioned interceptor for pthread_create.
This fixes a crash in pthread_create on linux/i386 due to abi
incompatibility between intercepted and non-intercepted functions.

See the test case for more details.

llvm-svn: 248325
2015-09-22 21:34:44 +00:00
Chris Bieneman 54445f92a9 [CMake] Add atomic builtins to GENERIC_SOURCES list.
Reviewers: bogner, samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D13069

llvm-svn: 248322
2015-09-22 21:18:19 +00:00
Renato Golin 7716df5b7d Disable final MSAN test in AArch64 to get the bots green
llvm-svn: 248014
2015-09-18 18:02:55 +00:00
Renato Golin 4610486e88 Disable one MSAN test in AArch64 until we have a proper fix
llvm-svn: 248008
2015-09-18 17:22:48 +00:00
Adhemerval Zanella dab7043d89 [compiler-rt] [sanitizer] Clean buildbot failures for aarch64
Currently aarch64 lacks instrumentation support for variadic arguments
for MSan.  This patch sets the UBSan tests that uses it as to require
stable-runtime and sets aarch64/ubsan as an unstable one.

llvm-svn: 247996
2015-09-18 15:48:32 +00:00
Evgeniy Stepanov 6e663a1e32 Revert "ubsan: Implement memory permission validation for vtables."
This reverts r247484 and two follow-up commits.
Breaks ppc and x86_64 sanitizer bots.

llvm-svn: 247921
2015-09-17 19:15:54 +00:00
Reid Kleckner 3e9d733e68 [Windows] xfail a test that uses C++ EH
llvm-svn: 247845
2015-09-16 20:32:22 +00:00
Evgeniy Stepanov 10c9ea51a0 Fix compilation warning in compiler-rt.
error: width of bit-field 'allocated' (8 bits) exceeds the width of
its type; value will be truncated to 1 bit [-Werror,-Wbitfield-width]

llvm-svn: 247840
2015-09-16 19:54:36 +00:00
Chris Bieneman 672311b368 [CMake] Make the sample program in darwin_test_archs have a symbol it needs to link.
This resolves an issue building compiler-rt using Xcode 7 that was reported on llvm-dev:

http://lists.llvm.org/pipermail/llvm-dev/2015-September/090245.html

llvm-svn: 247833
2015-09-16 18:29:52 +00:00
Adhemerval Zanella 19074450ee [MSan] Enable MSAN for aarch64
This patch enabled msan for aarch64 with 39-bit VMA and 42-bit VMA.
As defined by lib/msan/msan.h the memory layout used is for 39-bit is:

   00 0000 0000 - 40 0000 0000:  invalid
   40 0000 0000 - 43 0000 0000:  shadow
   43 0000 0000 - 46 0000 0000:  origin
   46 0000 0000 - 55 0000 0000:  invalid
   55 0000 0000 - 56 0000 0000:  app (low)
   56 0000 0000 - 70 0000 0000:  invalid
   70 0000 0000 - 80 0000 0000:  app (high)

And for 42-bit VMA:

   000 0000 0000 - 100 0000 0000:  invalid
   100 0000 0000 - 11b 0000 0000:  shadow
   11b 0000 0000 - 120 0000 0000:  invalid
   120 0000 0000 - 13b 0000 0000:  origin
   13b 0000 0000 - 2aa 0000 0000:  invalid
   2aa 0000 0000 - 2ab 0000 0000:  app (low)
   2ab 0000 0000 - 3f0 0000 0000:  invalid
   3f0 0000 0000 - 400 0000 0000:  app (high)

Most of tests are passing with exception of:

   * Linux/mallinfo.cc
   * chained_origin_limits.cc
   * dlerror.cc
   * param_tls_limit.cc
   * signal_stress_test.cc
   * nonnull-arg.cpp

The 'Linux/mallinfo.cc' is due the fact AArch64 returns the sret in 'x8'
instead of default first argument 'x1'.  So a function prototype that
aims  to mimic (by using first argument as the return of function) won't
work. For GCC one can make a register alias (register var asm ("r8")), but
for clang it detects is an unused variable and generate wrong code.

The 'chained_origin_limits' is probably due a wrong code generation,
since it fails only when origin memory is used
(-fsanitize-memory-track-origins=2) and only in the returned code
(return buf[50]).

The 'signal_streess_test' and 'nonnull-arg' are due currently missing variadic
argument handling in memory sanitizer code instrumentation on LLVM side.

Both 'dlerror' and 'param_tls_test' are unknown failures that require
further investigation.

All the failures are XFAIL for aarch64 for now.

llvm-svn: 247809
2015-09-16 15:12:25 +00:00
Naomi Musgrave 36597fa128 Explicit reference to bug highlighted by
test/msan/dtor-trivial.cpp. Runtime testing for poisoning
vtable pointer in dtor.

Summary: Runtime testing for vtable ptr poisoning in dtor.

Reviewers: eugenis, kcc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12713

Clean test case & comments.

Update tests for vptr poisoning order.

Simplify test to rely upon globals.

Assertions verify that vtable still accessible from dtors.

Testing linear inheritance and multiple inheritance for vtable poisoning.

Macros for testing expected failing functions.

Rename macros.

Removed xfail, modified FileCheck commands, to expect test to crash.

llvm-svn: 247763
2015-09-16 00:41:28 +00:00
Alexey Samsonov f23dee5408 [ASan] Add test for .preinit_array/.init_array/.fini_array sections.
llvm-svn: 247737
2015-09-15 23:06:17 +00:00
Adhemerval Zanella 172cc32ef3 [sanitizer] Move CheckVMASize after flag initialization
llvm-svn: 247684
2015-09-15 13:22:54 +00:00
Alexey Samsonov 1b76da6a6c Support inline functions symbolization in Addr2Line symbolizer.
Patch by Maxim Ostapenko!

Summary:
Right now, Addr2Line symbolizer in asan_symbolize.py doesn't support inline functions symbolization. This might be a useful feature for using ASan on embedded systems.

Test results:

$ cat test.c

static inline void FooBarBaz() {
  __sanitizer_print_stack_trace();
}

int main() {
  FooBarBaz();
  return 0;
}

$ clang  test.c -fsanitize=address -g -O2 -o test.x && ./test.x &> /tmp/test.log
$ ./projects/compiler-rt/lib/asan/scripts/asan_symbolize.py  -l /tmp/test.log
    #0 0x42095e in __sanitizer_print_stack_trace _asan_rtl_
    #1 0x4cec07 in FooBarBaz /home/max/build/llvm/asan/test.c:4
    #2 0x4cec07 in main /home/max/build/llvm/asan/test.c:8
    #3 0x7f89f0891ec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287

Reviewers: glider, samsonov

Subscribers: jevinskie, llvm-commits, ygribov

Differential Revision: http://reviews.llvm.org/D12153

llvm-svn: 247642
2015-09-14 23:56:42 +00:00
Chris Bieneman 679ab85a7c [CMake] Add options to control building sanitizers and builtins.
There are situations where a user may want to build only the compiler-rt builtins, or only the sanitizer runtimes. This exposes options to do that. Both default to On, so there should be no implicit change in behavior.

llvm-svn: 247607
2015-09-14 19:59:24 +00:00
Chris Bieneman fb92d9a249 [CMake] If COMPILER_RT_INCLUDE_TESTS is off we shouldn't include the root test directory.
llvm-svn: 247606
2015-09-14 19:54:12 +00:00
Peter Collingbourne dcba38a78b ubsan: Also disable vptr validation on powerpc64le.
llvm-svn: 247499
2015-09-12 05:24:44 +00:00
Peter Collingbourne e299bc51b6 ubsan: Disable vptr validation on powerpc64.
Should fix sanitizer-ppc64-linux1 bot.

llvm-svn: 247493
2015-09-12 00:08:28 +00:00
Peter Collingbourne cf303a4d8b ubsan: Implement memory permission validation for vtables.
If the pointer passed to the getVtablePrefix function was read from a freed
object, we may end up following pointers into objects on the heap and
printing bogus dynamic type names in diagnostics. However, we know that
vtable pointers will generally only point into memory mapped from object
files, not objects on the heap.

This change causes us to only follow pointers in a vtable if the vtable
and one of the virtual functions it points to appear to have appropriate
permissions (i.e. non-writable, and maybe executable), which will generally
exclude heap pointers.

Only enabled for Linux; this hasn't been tested on FreeBSD, and vtables are
writable on Mac (PR24782) so this won't work there.

Differential Revision: http://reviews.llvm.org/D12790

llvm-svn: 247484
2015-09-11 22:18:35 +00:00
Adhemerval Zanella 0563686a1c [compiler-rt] [sanitizers] Add VMA size check at runtime
This patch adds a runtime check for asan, dfsan, msan, and tsan for
architectures that support multiple VMA size (like aarch64).  Currently
the check only prints a warning indicating which is the VMA built and
expected against the one detected at runtime.

llvm-svn: 247413
2015-09-11 13:55:00 +00:00
Roman Divacky 7433cd4fe6 Unbreak building on FreeBSD.
llvm-svn: 247347
2015-09-10 21:56:16 +00:00
Peter Collingbourne 6f94087329 CFI: Run the tests only on supported architectures/OSs.
Specifically, only run the cfi-icall tests on x86/x86_64, and add
an XFAIL for darwin.

llvm-svn: 247325
2015-09-10 19:18:08 +00:00
Peter Collingbourne 1db3a448b5 CFI: Add diagnostic handler and tests for indirect call checker.
Differential Revision: http://reviews.llvm.org/D11858

llvm-svn: 247239
2015-09-10 02:18:02 +00:00
Evgeniy Stepanov 4c2dd111f2 [msan] Unpoison dlpi_phdr in dl_iterate_phdr.
In some cases, PHDR table is allocated with malloc() by the linker
instead of being mapped from file. It needs to be unpoisoned in the
dl_iterate_phdr callback then.

This happens when program headers are not part of any loadable ELF
segment.

llvm-svn: 247100
2015-09-08 23:14:44 +00:00
Alexey Samsonov 63eaeca7d0 [CMake] Remove all uses of LLVM_NATIVE_ARCH.
Instead, assume we're going to target triple specified by
COMPILER_RT_DEFAULT_TARGET_TRIPLE and build runtimes for this triple
(and hope that the host compiler can target them).

This will help users that use cross-compiler on their host to build
Clang that would work on a different architecture. This will also come in
handy if one would want to configure several compiler-rt build trees on
the same host, using just-built Clang that can target many
architectures.

This doesn't change the behavior in the default build configuration.

llvm-svn: 247099
2015-09-08 23:13:47 +00:00
Alexey Samsonov 0d0200d727 [CMake] Rename COMPILER_RT_TEST_TARGET_TRIPLE to more appropriate COMPILER_RT_DEFAULT_TARGET_TRIPLE.
llvm-svn: 247094
2015-09-08 22:48:35 +00:00
Naomi Musgrave 18203f763c Failing test highlighting no poisoning when destructor not declared.
Summary:
When destructor for a class is not declared, no destructor
is emitted, and members are not poisoned. Test case exhibits this
current bug in use-after-dtor implementation (detailed in
https://github.com/google/sanitizers/issues/596).

Reviewers: eugenis, kcc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12617

Rename test files.

llvm-svn: 247091
2015-09-08 22:41:50 +00:00
Evgeniy Stepanov 640499b1fa [asan] Disable ThreadSelfTest on Android.
Also #ifdef out the implementation of ThreadSelf() and
ThreadSelfOffset() helper functions that are broken and unused on
Android.

llvm-svn: 247053
2015-09-08 19:32:37 +00:00
Chris Bieneman 041f785224 [autoconf] Add __umodti3 to iOS builtins for arm64.
llvm-svn: 247026
2015-09-08 17:18:45 +00:00
Kuba Brecka 6f7ef0ea3e Revert r246961 "[asan] Intercept and wrap XPC callback blocks".
There is a build failure for the simulator.

llvm-svn: 246967
2015-09-07 12:25:51 +00:00
Kuba Brecka dfaac293dc [asan] Intercept and wrap XPC callback blocks
On recent OS X systems, blocks used as callbacks for XPC events (set up e.g. via xpc_connection_set_event_handler) are not later executed via the public libdispatch API (dispatch_async, etc). Because we don't intercept the path where the block is executed, we can fail to register the newly created dispatch thread. To fix that, let's intercept libxpc's APIs that take a block as a callback handler, and let's wrap these blocks in the same way as we do for libdispatch API.

Differential Revision: http://reviews.llvm.org/D12490

llvm-svn: 246961
2015-09-07 11:19:22 +00:00
Evgeniy Stepanov de77b1cdf3 [asan] Detect asanwrapper binary in android tests.
Tests need to be run either via asanwrapper or asanwrapper64
depending in the binary bitness. This matters when testing on an
aarch64 device.

llvm-svn: 246891
2015-09-04 22:39:21 +00:00
Evgeniy Stepanov dc8616b541 [asan] Fix >80 chars line.
llvm-svn: 246875
2015-09-04 21:19:48 +00:00
Evgeniy Stepanov add0f2aad5 [asan] Disable asm instrumentation tests on android/x86.
https://github.com/google/sanitizers/issues/353

llvm-svn: 246866
2015-09-04 20:26:58 +00:00
Evgeniy Stepanov 7dee008911 [asan] Disable array cookie test on ARM, enable on Android/x86.
The failure is caused by the missing implementation of array cookie
poisoning in Clang for ARMCXXABI and has nothing to do with Android
(and the test passes on Android/x86).

llvm-svn: 246832
2015-09-04 01:15:28 +00:00
Evgeniy Stepanov 6d500c5560 [asan] Delay syslog use on Android until the end of __asan_init.
Due to a slightly different initialization order, syslog on
android/x86 calls vsnprintf, which can not be handled until interceptors
are initialized at least.

llvm-svn: 246831
2015-09-04 01:15:25 +00:00
Naomi Musgrave 8eb36d2210 Test triangle inheritance member poisoning.
Summary: Verify that all members are poisoned.

Reviewers: eugenis, kcc

Differential Revision: http://reviews.llvm.org/D12023

Test virtual functions and virtual bases poisoning proper size.

Runtime testing of destroying diamond inheritance.

Explicit testing for 0 optimizations.

Simplify test to only test interesting values.

Test poisoning on multiple inheritance with nontrivial and trivial members.

Removed unnecessary header.

Testing (anonymous/)bit fields.

Revised object instantiation in test to avoid undefined behavior.

llvm-svn: 246817
2015-09-03 23:06:13 +00:00
Dmitry Vyukov 3464dac0ca tsan: speed up race deduplication
Race deduplication code proved to be a performance bottleneck in the past if suppressions/annotations are used, or just some races left unaddressed. And we still get user complaints about this:
https://groups.google.com/forum/#!topic/thread-sanitizer/hB0WyiTI4e4
ReportRace already has several layers of caching for racy pcs/addresses to make deduplication faster. However, ReportRace still takes a global mutex (ThreadRegistry and ReportMutex) during deduplication and also calls mmap/munmap (which take process-wide semaphore in kernel), this makes deduplication non-scalable.

This patch moves race deduplication outside of global mutexes and also removes all mmap/munmap calls.
As the result, race_stress.cc with 100 threads and 10000 iterations become 30x faster:

before:
real	0m21.673s
user	0m5.932s
sys	0m34.885s

after:
real	0m0.720s
user	0m23.646s
sys	0m1.254s

http://reviews.llvm.org/D12554

llvm-svn: 246758
2015-09-03 11:20:46 +00:00
Evgeniy Stepanov d67f1b9dbc [asan] Split a test in two.
wait3 is gone in android-21. Move it out of the common
(wait/waitpid/wait3) test, and mark as unsupported on Android.

llvm-svn: 246742
2015-09-03 01:26:30 +00:00
Evgeniy Stepanov afe6c1d466 [asan] Replace valloc with posix_memalign in test.
valloc is gone in android-21.

llvm-svn: 246741
2015-09-03 01:22:06 +00:00
Evgeniy Stepanov b865f61ff9 [asan] Fix signal interception on Android.
All supported version of Android provide both "signal" and
"bsd_signal" libc exports. Binaries built for API level <21 call
bsd_signal; newer binaries call signal.

Simply intercept both.

Fixes AddressSanitizer.SignalTest on Android/x86.

llvm-svn: 246716
2015-09-02 21:32:46 +00:00
Reid Kleckner b6f39cbba2 [windows] Add retries to cope with linker/filesystem flakiness
Hopefully this fixes PR24554, and we receive less build spam.

llvm-svn: 246708
2015-09-02 20:45:36 +00:00
Peter Collingbourne cd5d761c3e CFI: Make the cfi target a dependency of compiler-rt.
This causes the blacklist to be copied into place as a default build step.

llvm-svn: 246617
2015-09-02 02:18:46 +00:00
Peter Collingbourne 4c5b0a3d58 CFI: Add blacklist entries for various standard library functions.
llvm-svn: 246602
2015-09-01 23:00:56 +00:00
Chris Bieneman 9772c6342e [autoconf] Add ___udivti3 to iOS builtins
llvm-svn: 246599
2015-09-01 22:39:04 +00:00
Kostya Serebryany 94dd76aefa [tsan] workaround for a crash in deadlock detector, bug https://github.com/google/sanitizers/issues/594
llvm-svn: 246592
2015-09-01 21:36:18 +00:00
Reid Kleckner a71dabd591 Mark the log_path ubsan test as requiring a shell. It uses globs.
llvm-svn: 246566
2015-09-01 18:17:21 +00:00
Chris Bieneman 9e6af15890 [CMake] Enable building builtins for iOS and iOS simulator.
Building iOS does respect COMPILER_RT_ENABLE_IOS.

llvm-svn: 246501
2015-08-31 22:26:02 +00:00
Chris Bieneman 3b0b43c8c6 [CMake] Fixing lip output library name on Darwin platforms.
llvm-svn: 246499
2015-08-31 22:22:18 +00:00
Chris Bieneman b38affa474 [CMake] Fix building builtins on Linux and Darwin.
Summary:
I broke building the builtins with r245967. This fixes them on Linux and builds them properly for Darwin.

The old code could not be made to work on Darwin as a result of the refactoring of add_compiler_rt_runtime, so I had to rework the way they are built for Darwin. This solution is not ideal and will be fixed in subsequent commits. I just want to get this in so everything is working again.

Reviewers: samsonov, chh, compnerd, bogner

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12500

llvm-svn: 246487
2015-08-31 21:24:50 +00:00
Chih-Hung Hsieh 4814b9c93a builtins: implement __emutls_get_address
For targets like Android that depends on libgcc's emulated thread local storage.
clang/llvm can generate calls to __emutls_get_address since
http://reviews.llvm.org/D10522 and http://reviews.llvm.org/D10524

Differential Revision: http://reviews.llvm.org/D12001

llvm-svn: 246454
2015-08-31 17:14:07 +00:00
Kuba Brecka b79932addf [asan] Fix the freopen interceptor to allow NULL instead of a filename
According to `man freopen`, passing NULL instead of a filename is valid, however the current implementation of the interceptor assumes this parameter is non-NULL. Let's fix that and add a test case.

Differential Revision: http://reviews.llvm.org/D11389

llvm-svn: 246435
2015-08-31 12:41:55 +00:00
Adhemerval Zanella 15db6dc2fb [compiler-rt] [tsan] Enable TSan for AArch64/42-bit VMA
This patch adds support for tsan on aarch64-linux with 42-bit VMA
(current default config for 64K pagesize kernels).  The support is
enabled by defining the SANITIZER_AARCH64_VMA to 42 at build time
for both clang/llvm and compiler-rt.  The default VMA is 39 bits.

It also enabled tsan for previous supported VMA (39).

llvm-svn: 246330
2015-08-28 20:40:50 +00:00
Alexey Samsonov ee03b5bbb9 [CMake] Unify build rules for sanitizer_common for Apple and non-Apple platforms.
Additionally, link safestack runtime on OS X with nolibc version of
sanitizer_common runtime, as we do on Linux.

llvm-svn: 246227
2015-08-27 22:23:27 +00:00
Alexey Samsonov 2daddb05de [CMake] Delete unused variable and target.
llvm-svn: 246221
2015-08-27 22:04:02 +00:00
Alexey Samsonov 53b8750e7d [Sanitizers] Make abort_on_error common flag.
Summary:
Teach all sanitizers to call abort() instead of _exit() after printing
an error report, if requested. This behavior is the default on Mac OS.

Reviewers: kcc, kubabrecka

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12332

llvm-svn: 246205
2015-08-27 20:40:24 +00:00
Chris Bieneman f12cf13f38 [CMake] Add ARCHS option to add_sanitizer_rt_symbols.
Summary:
This is another step in a multi-step refactoring to move add_sanitizer_rt_symbols in the direction of other add_* functions in compiler-rt.

Changes to CMakeLists files are all minimal except ubsan which tests the new ARCHS loop.

Further cleanup patches will follow.

Reviewers: filcab, bogner, kubabrecka, zaks.anna, glider, samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12410

llvm-svn: 246199
2015-08-27 20:07:54 +00:00
Alexey Samsonov 34620a8e4f [Sanitizer] Use internal_memmove instead of the one implicitly generated by compiler.
llvm-svn: 246198
2015-08-27 20:07:28 +00:00
Evgeniy Stepanov b732e384e1 [sanitizer] Disable sem_* interceptors on Mac.
llvm-svn: 246190
2015-08-27 19:20:01 +00:00
Evgeniy Stepanov 533fde9f4d [sanitizer] Move sem_* to common interceptors.
llvm-svn: 246184
2015-08-27 18:51:18 +00:00
Chris Bieneman 2be86df4b1 [CMake] Add PARENT_TARGET option to add_sanitizer_rt_symbols.
Summary: This is another step in a multi-step refactoring to move add_sanitizer_rt_symbols in the direction of other add_* functions in compiler-rt.

Reviewers: filcab, bogner, kubabrecka, zaks.anna, glider, samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12409

llvm-svn: 246178
2015-08-27 18:27:33 +00:00
Reid Kleckner 255ee043cb Unit test the CRLF change to suppression parsing
It's a simpler, faster, and more portable.

llvm-svn: 246171
2015-08-27 18:05:33 +00:00
Reid Kleckner 766e507784 [windows] Avoid unix2dos, it seems to not work on our bot
llvm-svn: 246162
2015-08-27 16:56:10 +00:00
Adhemerval Zanella 8ea893a57a [compiler-rt] [tsan] Fix GetTls for aarch64
This patch fix the function GetTls for aarch64, where it assumes it
follows the x86_64 way where the TLS initial address is at the end
of TLS.  Instead aarch64 set the TLS address as the thread pointer.

llvm-svn: 246148
2015-08-27 13:11:00 +00:00
Chris Bieneman bfc74bd3fc [CMake] Converting add_sanitizer_rt_symbols to use cmake_parse_arguments.
Summary: This is the first step in a multi-step refactoring to move add_sanitizer_rt_symbols in the direction of other add_* functions in compiler-rt.

Reviewers: filcab, bogner, kubabrecka, zaks.anna, glider, samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12386

llvm-svn: 246102
2015-08-26 23:12:25 +00:00
Chris Bieneman 3454005b05 [CMake] Cleaning up ubsan to use OBJECT_LIBS and to not loop when calling add_compiler_rt_runtime.
llvm-svn: 246097
2015-08-26 22:36:31 +00:00
Reid Kleckner ac86c29bd0 Handle suppression files ending in CRLF (\r\n)
The gnuwin32 version of 'echo' appears to produce such files, causing a
test failure that only reproduced with gnuwin32.

llvm-svn: 246096
2015-08-26 22:23:50 +00:00
Alexey Samsonov 966eba0585 [Sanitizer] Test churn: use %env_tool_opts in sanitizer_common lit tests.
This follows the approach we use in ASan and UBSan lit tests to setup
tool options in a portable way, and to provide a nice way to specify
testsuite-wide defaults.

llvm-svn: 246058
2015-08-26 19:29:07 +00:00
Chris Bieneman 7173f07d70 [CMake] Add OBJECT_LIBS option to add_compiler_rt_runtime, and refactored asan call site to use it.
Summary: This is one more step to allow us to eliminate platform-specific code from the library CMakeLists files. Subsequent patches will refactor all call sites to use this and other new features.

Reviewers: filcab, bogner, kubabrecka, zaks.anna, glider, samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12339

llvm-svn: 246047
2015-08-26 18:33:51 +00:00
Eric Fiselier 30130f2070 [compiler-rt] Add common interceptor for wcrtomb.
Summary: Currently there is a libc++ test failing under MSAN because wcrtomb is not intercepted. This patch adds an interceptor for it. 

Reviewers: samsonov, eugenis

Subscribers: tberghammer, danalbert, srhines, llvm-commits

Differential Revision: http://reviews.llvm.org/D12311

llvm-svn: 245994
2015-08-26 00:14:08 +00:00
Evgeniy Stepanov f8af87957c [msan] Regression test for PR24561.
Fixed in r245980.

llvm-svn: 245981
2015-08-25 22:20:15 +00:00
Chris Bieneman f4b7bcec97 [CMake] fixing a typo that is breaking bots.
llvm-svn: 245971
2015-08-25 20:00:35 +00:00
Chris Bieneman d160260681 [CMake] merge add_compiler_rt_runtime and add_compiler_rt_darwin_runtime into a single function
Summary: This refactoring moves much of the Apple-specific behavior into a function in AddCompilerRT. The next cleanup patch will remove more of the if(APPLE) checks in the outlying CMakeLists.

This patch adds a bunch of new functionality to add_compiler_rt_runtime so that the target names don't need to be reconstructed outside the call. It also updates some of the call sites to exercise the new functionality, but does not update all uses fully. Subsequent patches will further update call sites and move to using the new features.

Reviewers: filcab, bogner, kubabrecka, zaks.anna, glider, samsonov

Subscribers: beanz, rengolin, llvm-commits

Differential Revision: http://reviews.llvm.org/D12292

llvm-svn: 245970
2015-08-25 19:53:09 +00:00
Alexey Samsonov 47aa53e91c [UBSan] Test churn: use the approach from r244839 and r245962 in UBSan lit tests.
Introduce %env_ubsan_opts= substitution instead of specifying
UBSAN_OPTIONS manually in the RUN-lines. This will come in handy
once we introduce some default UBSAN_OPTIONS for the whole testsuite
(for instance, make abort_on_error common option).

llvm-svn: 245967
2015-08-25 19:01:44 +00:00
Alexey Samsonov 1130681716 [ASan] More ASAN_OPTIONS churn: use %env_asan_opts where applicable.
Reviewers: filcab, rnk, kubabrecka

Subscribers: tberghammer, danalbert, srhines, llvm-commits

Differential Revision: http://reviews.llvm.org/D12305

llvm-svn: 245962
2015-08-25 18:27:53 +00:00
Alexey Samsonov f3b9c895fa [UBSan] Add the ability to print more precise error kind in summary line.
Reviewers: rsmith, pcc

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D12215

llvm-svn: 245897
2015-08-24 23:18:49 +00:00
Alexey Samsonov ab229c13a6 [Sanitizer] Dump coverage if we're killing the program with __sanitizer::Die().
Previously we had to call __sanitizer_cov_dump() from tool-specific
callbacks - instead, let sanitizer_common library handle this in a
single place.

This is a re-application of r245770, with slightly different approach
taken.

llvm-svn: 245890
2015-08-24 22:21:47 +00:00
Alexey Samsonov b92aa0fc3f [Sanitizers] Allow to install several internal Die callbacks.
This is required to properly re-apply r245770:
1) We should be able to dump coverage in __sanitizer::Die() if coverage
   collection is turned on.
2) We don't want to explicitly do this in every single
   sanitizer that supports it.
3) We don't want to link in coverage (and therefore symbolization) bits
   into small sanitizers that don't support it (safestack).

The solution is to make InitializeCoverage() register its own Die()
callback that would call __sanitizer_cov_dump(). This callback should be
executed in addition to another tool-specific die callbacks (if there
are any).

llvm-svn: 245889
2015-08-24 22:21:44 +00:00
Alexey Samsonov 87da1509e7 [autoconf] Properly exclude sanitizer_common nolibc sources from build.
llvm-svn: 245865
2015-08-24 19:38:59 +00:00
Adhemerval Zanella 2a1e58d000 [dfsan] Enable DFSan for AArch64/42-bit VMA
This patch adds support for dfsan on aarch64-linux with 42-bit VMA
(current default config for 64K pagesize kernels).  The support is
enabled by defining the SANITIZER_AARCH64_VMA to 42 at build time
for both clang/llvm and compiler-rt.  The default VMA is 39 bits.

llvm-svn: 245841
2015-08-24 13:50:14 +00:00
Alexey Samsonov 4369a3f4ad Revert r245770 and r245777.
These changes break both autoconf Mac OS X buildbot (linker errors
due to wrong Makefiles) and CMake buildbot (safestack test failures).

llvm-svn: 245784
2015-08-22 05:15:55 +00:00
Alexey Samsonov 74683fe519 Try to fix Mac build.
llvm-svn: 245777
2015-08-22 01:07:05 +00:00
Alexey Samsonov eb4fe7883f [TSan] Support __sanitizer_set_death_callback().
llvm-svn: 245776
2015-08-22 01:07:02 +00:00
Evgeniy Stepanov d6376d9875 [asan] Don't apply glibc-specific TLS calculations on Android.
This fixes an infinite recursion between GetTls and GetTlsSize on
Android-x86.

llvm-svn: 245773
2015-08-22 00:47:12 +00:00
Alexey Samsonov 8e38c71cb7 [Sanitizer] Dump coverage if we're killing the program with __sanitizer::Die().
Previously we had to call __sanitizer_cov_dump() from tool-specific
callbacks - instead, let sanitizer_common library handle this in a single place.

llvm-svn: 245770
2015-08-22 00:28:12 +00:00
Alexey Samsonov b6a604aea5 [DFSan] Remove nolibc build.
It's not used now, as is not even included in "dfsan" target.

llvm-svn: 245766
2015-08-21 23:58:45 +00:00
Alexey Samsonov fc95c85cb5 [LSan] Support __sanitizer_set_death_callback in standalone LSan.
llvm-svn: 245758
2015-08-21 23:00:30 +00:00
Alexey Samsonov 540ac1aab4 [MSan] Deprecate __msan_set_death_callback() in favor of __sanitizer_set_death_callback().
llvm-svn: 245754
2015-08-21 22:45:12 +00:00
Alexey Samsonov bb79b06f4e [Sanitizers] Unify the semantics and usage of "exitcode" runtime flag across all sanitizers.
Summary:
Merge "exitcode" flag from ASan, LSan, TSan and "exit_code" from MSan
into one entity. Additionally, make sure sanitizer_common now uses the
value of common_flags()->exitcode when dying on error, so that this
flag will automatically work for other sanitizers (UBSan and DFSan) as
well.

User-visible changes:
* "exit_code" MSan runtime flag is now deprecated. If explicitly
  specified, this flag will take precedence over "exitcode".
  The users are encouraged to migrate to the new version.
* __asan_set_error_exit_code() and __msan_set_exit_code() functions
  are removed. With few exceptions, we don't support changing runtime
  flags during program execution - we can't make them thread-safe.
  The users should use __sanitizer_set_death_callback()
  that would call _exit() with proper exit code instead.
* Plugin tools (LSan and UBSan) now inherit the exit code of the parent
  tool. In particular, this means that ASan would now crash the program
  with exit code "1" instead of "23" if it detects leaks.

Reviewers: kcc, eugenis

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12120

llvm-svn: 245734
2015-08-21 20:49:37 +00:00
Dmitry Vyukov 7830c2d726 tsan: don't report any bugs when report_bugs=0 flag is set
llvm-svn: 245720
2015-08-21 18:21:24 +00:00
Chris Bieneman 2ac796d6cc [CMake] Need to filter out test architectures on ubsan as well.
llvm-svn: 245714
2015-08-21 18:06:00 +00:00
Chris Bieneman 797f5b3683 [CMake] Fixing haswell filtering.
Turns out this wasn't working at all.

llvm-svn: 245713
2015-08-21 18:05:57 +00:00
Adhemerval Zanella 36b5042753 [compiler-rt] [sanitizers] Add aarch64 syscall optimization support
This patch adds the inline syscall support for aarch64 instead of relying
on the syscall runtime function.

llvm-svn: 245702
2015-08-21 14:50:36 +00:00