Commit Graph

3322 Commits

Author SHA1 Message Date
Dmitry Vyukov db1ad12ae2 asan: fix atomic operations on ARM
implement correct atomic load/store for ARM
add test for atomic load/store
http://llvm-reviews.chandlerc.com/D2582

llvm-svn: 199802
2014-01-22 14:13:37 +00:00
Alexey Samsonov 8c03475f01 [Sanitizer] try harder to fix Werror build break after r199729
llvm-svn: 199736
2014-01-21 13:06:38 +00:00
Alexey Samsonov 39dbd7cc2c [Sanitizer] Update file names now that we intercept both scanf and printf
llvm-svn: 199735
2014-01-21 13:01:20 +00:00
Tim Northover bea1cafde8 Macho-embedded: update build script for newer Clang behaviour.
Clang now uses the *-apple-macho triples for embedded targets using MachO. The
environment makes less pretences to be running an actual Mach kernel with all
the support that would imply, so a few changes are needed to the build scripts:
    
+ The Apple way of detecting endianness applies in all cases so drop the
  __MACH__ test.
+ A quick rename since "darwin_embedded" no longer makes any sense. If there's
  no Mach going on, there's certainly no Darwin.
+ Change how we test for support for a platform. The functions we build don't
  need any SDK support (stdio.h, ...) so we don't need to check for it.

llvm-svn: 199731
2014-01-21 12:38:02 +00:00
Alexey Samsonov 20494ca293 Fix unused function warning from r199729
llvm-svn: 199730
2014-01-21 12:16:19 +00:00
Alexey Samsonov 00cd273c46 Sanitize printf functions.
Intercept and sanitize arguments passed to printf functions in ASan and TSan
(don't do this in MSan for now). The checks are controlled by runtime flag
(off by default for now).

Patch http://llvm-reviews.chandlerc.com/D2480 by Yuri Gribov!

llvm-svn: 199729
2014-01-21 11:58:33 +00:00
Evgeniy Stepanov e676aadecf [asan] Enable frame pointer based unwinder on ARM.
This code works with AAPCS-style {fp, lr} frames. Unlike linux perf, it does
not unwind through code compiled with -mapcs-frame (which Clang does not
support anyway).

llvm-svn: 199725
2014-01-21 11:04:58 +00:00
Alexey Samsonov 0714b7b31b [Sanitizer] Support %.*s in internal printf implementation. Patch by Yuri Gribov.
llvm-svn: 199724
2014-01-21 10:59:44 +00:00
Kostya Serebryany 9fcb4c4a6e [asan] one more test for https://code.google.com/p/address-sanitizer/issues/detail?id=258
llvm-svn: 199723
2014-01-21 10:57:07 +00:00
Kostya Serebryany 4871067a55 [asan] relax the checks inside __sanitizer_annotate_contiguous_container: they are too optimistic due to https://code.google.com/p/address-sanitizer/issues/detail?id=258.
llvm-svn: 199715
2014-01-21 09:53:49 +00:00
Evgeniy Stepanov e98f9099a9 [msandr] Access app TLS directly in native exec mode.
In optimized hybrid execution we do not use DynamoRIO private loader, which
mangles TLS access, so we can access the application's TLS directly.

Patch by Qin Zhao.

llvm-svn: 199655
2014-01-20 13:09:29 +00:00
Nick Lewycky 62fd6778f5 Fix think-o from r199332 -- write to the new_filename we're building, not
filename the global variable.

llvm-svn: 199572
2014-01-19 07:37:29 +00:00
Kostya Serebryany 123994c4a6 [asan] use correct type when computing shadow address in allocator (caused SEGV when asan run-time is built with gcc 4.8.2 on 32-bit arch)
llvm-svn: 199544
2014-01-18 09:38:31 +00:00
Joerg Sonnenberger a9b3aee516 Support NetBSD/ARM.
llvm-svn: 199492
2014-01-17 14:06:22 +00:00
Kostya Serebryany 714c67c31e [asan] extend asan-coverage (still experimental).
- add a mode for collecting per-block coverage (-asan-coverage=2).
   So far the implementation is naive (all blocks are instrumented),
   the performance overhead on top of asan could be as high as 30%.
 - Make sure the one-time calls to __sanitizer_cov are moved to function buttom,
   which in turn required to copy the original debug info into the call insn.

Here is the performance data on SPEC 2006
(train data, comparing asan with asan-coverage={0,1,2}):

                             asan+cov0     asan+cov1      diff 0-1    asan+cov2       diff 0-2      diff 1-2
       400.perlbench,        65.60,        65.80,         1.00,        76.20,         1.16,         1.16
           401.bzip2,        65.10,        65.50,         1.01,        75.90,         1.17,         1.16
             403.gcc,         1.64,         1.69,         1.03,         2.04,         1.24,         1.21
             429.mcf,        21.90,        22.60,         1.03,        23.20,         1.06,         1.03
           445.gobmk,       166.00,       169.00,         1.02,       205.00,         1.23,         1.21
           456.hmmer,        88.30,        87.90,         1.00,        91.00,         1.03,         1.04
           458.sjeng,       210.00,       222.00,         1.06,       258.00,         1.23,         1.16
      462.libquantum,         1.73,         1.75,         1.01,         2.11,         1.22,         1.21
         464.h264ref,       147.00,       152.00,         1.03,       160.00,         1.09,         1.05
         471.omnetpp,       115.00,       116.00,         1.01,       140.00,         1.22,         1.21
           473.astar,       133.00,       131.00,         0.98,       142.00,         1.07,         1.08
       483.xalancbmk,       118.00,       120.00,         1.02,       154.00,         1.31,         1.28
            433.milc,        19.80,        20.00,         1.01,        20.10,         1.02,         1.01
            444.namd,        16.20,        16.20,         1.00,        17.60,         1.09,         1.09
          447.dealII,        41.80,        42.20,         1.01,        43.50,         1.04,         1.03
          450.soplex,         7.51,         7.82,         1.04,         8.25,         1.10,         1.05
          453.povray,        14.00,        14.40,         1.03,        15.80,         1.13,         1.10
             470.lbm,        33.30,        34.10,         1.02,        34.10,         1.02,         1.00
         482.sphinx3,        12.40,        12.30,         0.99,        13.00,         1.05,         1.06

llvm-svn: 199488
2014-01-17 11:00:30 +00:00
Evgeniy Stepanov 755fc5c313 [asan] Link runtime library with -lm -Wl,-z,defs to ensure that it declares all its dependencies.
llvm-svn: 199483
2014-01-17 09:38:46 +00:00
Alexey Samsonov a64851bccb [Sanitizer] Remove empty method
llvm-svn: 199481
2014-01-17 08:39:05 +00:00
Evgeniy Stepanov 877bb8ba59 [asan] Fix a build warning on windows.
llvm-svn: 199390
2014-01-16 14:21:17 +00:00
Joerg Sonnenberger da93c0f37c Add missing __aeabi_fcmpun alias to match C version.
llvm-svn: 199386
2014-01-16 13:55:24 +00:00
Alexey Samsonov 4d075df406 [Sanitizer] Add basic support for using libbacktrace in symbolizer.
This change allows to compile sanitizer sources so that *san runtime
will attempt to use libbacktrace and/or libiberty for symbolization
(instead of communicating with llvm-symbolizer).

I've tested this patch by manually defining SANITIZER_LIBBACKTRACE and/or
SANITIZER_CP_DEMANGLE, linking with necessary libraries and verifying that
all tests from ASan test suite work.

Based on patches by Jakub Jelinek!

llvm-svn: 199384
2014-01-16 13:48:15 +00:00
Evgeniy Stepanov 364bfdf4c9 [asan] Fix a bunch of style issues.
llvm-svn: 199380
2014-01-16 13:17:13 +00:00
Evgeniy Stepanov fe906a1df6 [asan] Restore lost -pie in Android tests.
llvm-svn: 199379
2014-01-16 13:11:37 +00:00
Evgeniy Stepanov c61623b170 [asan] Implement delayed activation of AddressSanitizer
This change adds ASAN_OPTIONS=start_deactivated=1 flag. When present, ASan will
start in "deactivated" mode, with no heap poisoning, no quarantine, no stack
trace gathering, and minimal redzones. All this features come back when
__asan_init is called for the constructor of an instrumented library.

The primary use case for this feature is Android. Code itself is not
Android-specific, and this patch includes a Linux test for it.

llvm-svn: 199377
2014-01-16 12:31:50 +00:00
Evgeniy Stepanov 780d85a8ef [asan] Remove leftover use of -fsanitize-address-zero-base-shadow.
llvm-svn: 199373
2014-01-16 11:42:40 +00:00
Evgeniy Stepanov e259b658e4 [asan] Nuke ASAN_FLEXIBLE_MAPPING_AND_OFFSET.
llvm-svn: 199370
2014-01-16 10:16:19 +00:00
Joerg Sonnenberger ef0cbe9366 ARM's @ comment mode strikes again. Use %function on ARM.
llvm-svn: 199342
2014-01-16 00:36:49 +00:00
Bob Wilson e38cc76c32 Remove support for armv7f slice. <rdar://problem/12478440>
This was never used for anything so we should just get rid of it.

llvm-svn: 199333
2014-01-15 21:05:20 +00:00
Joerg Sonnenberger c989455e6d Avoid shadowing the global filename. Reorg mangle_filename to be more
precise in the length accounting and use memcpy instead of
strcpy/strcat.

Differential Revision: http://llvm-reviews.chandlerc.com/D2547

llvm-svn: 199332
2014-01-15 20:57:10 +00:00
Kostya Serebryany 06222915cf [lsan] remove LeakSanitizerIsTurnedOffForTheCurrentProcess (this was a bad idea), leave __lsan_is_turned_off
llvm-svn: 199304
2014-01-15 08:04:21 +00:00
Evgeniy Stepanov fc0ba53531 [msan] Fix an incorrect comment.
llvm-svn: 199300
2014-01-15 06:49:40 +00:00
Joerg Sonnenberger 197568a02f Declare assembler functions as symbols of type function for ELF.
Fixes dynamically linked programs on NetBSD/i386.

llvm-svn: 199273
2014-01-14 23:31:23 +00:00
Kostya Serebryany 6e53cfc1ac [tsan] one more explicit memset in tsan rtl (to please gcc 4.8.2)
llvm-svn: 199216
2014-01-14 15:00:10 +00:00
Kostya Serebryany 19e6e4a445 [tsan] reduce the size of stack frame in MapRodata to please gcc 4.8.2
llvm-svn: 199200
2014-01-14 10:25:42 +00:00
Kostya Serebryany 47d5569de1 [asan] Include <sys/stat.h> if __x86_64__ is defined
struct stat defined in <asm/stat.h> is incorrect for x32.  <asm/stat.h>
is included to get struct __old_kernel_stat.  But struct __old_kernel_stat
isn't used for x86-64 nor x32.  This patch includes <sys/stat.h> instead
of <asm/stat.h> and comments out size check of struct __old_kernel_stat
for x86-64.

Patch by H.J. Lu

llvm-svn: 199192
2014-01-14 07:38:53 +00:00
Sergey Matveev 3a47244c94 [lsan] Add __lsan_default_suppressions() to the public interface header.
llvm-svn: 199121
2014-01-13 17:26:57 +00:00
Kostya Serebryany e8699fcd8e [sanitizer] fix comment
llvm-svn: 199112
2014-01-13 15:06:20 +00:00
Kostya Serebryany d651412cd4 [asan] fix the ppc32 build (by Jakub Jelinek). Note that the LLVM build still builds only for 64-bit PowerPC, and not for 32-bit
llvm-svn: 199090
2014-01-13 10:19:12 +00:00
Kostya Serebryany 2b76278d38 [lsan] handle 'new T[0]' where T is a type with DTOR; fixes https://code.google.com/p/address-sanitizer/issues/detail?id=257
llvm-svn: 198932
2014-01-10 10:48:01 +00:00
Kostya Serebryany 27f5b8800d [lsan] rename __lsan_is_turned_off to LeakSanitizerIsTurnedOffForTheCurrentProcess (leave the old variant for now for compatibility)
llvm-svn: 198921
2014-01-10 07:58:25 +00:00
Evgeniy Stepanov 3ee789cbbb [msan] Temporarily disable two tests that are failing with new glibc.
llvm-svn: 198919
2014-01-10 07:34:16 +00:00
Evgeniy Stepanov 219719a2da [asan] Implement max_redzone runtime flag.
llvm-svn: 198873
2014-01-09 14:41:03 +00:00
Justin Bogner d46fd08690 SDKs: Add inttypes.h to the darwin SDK stub
This unbreaks the configure build on darwin, where we build with the
stub SDK in -isysroot. Oddly, the cmake build doesn't have this
restriction, which probably means the cmake configs are out of date.

llvm-svn: 198676
2014-01-07 05:42:09 +00:00
Justin Bogner 3e69e13092 Revert "Only include inttypes.h on platforms for which PRIu64 isn't in stdint.h"
This reverts commit e7778e08878d0c61903205428eeb131db9d11b3c.

llvm-svn: 198657
2014-01-07 01:46:49 +00:00
Justin Bogner 1917588d0c Revert "Explicitly enable PRIu64 by defining __STDC_FORMAT_MACROS if it isn't"
This reverts commit d1b5d3b0e885ef057643fcea99bff8b6cce04b93.

llvm-svn: 198656
2014-01-07 01:46:46 +00:00
Kaelyn Uhrain 9ee39534aa Explicitly enable PRIu64 by defining __STDC_FORMAT_MACROS if it isn't
yet defined.

llvm-svn: 198650
2014-01-07 00:29:19 +00:00
Kaelyn Uhrain 88d8974152 Only include inttypes.h on platforms for which PRIu64 isn't in stdint.h
llvm-svn: 198647
2014-01-06 23:37:31 +00:00
Kaelyn Uhrain 617499fe6c Use the PRIu64 macro for printing a uint64_t.
Otherwise on (some) 64-bit systems, -Wformat will trigger a warning
because uint64_t is an 'unsigned long' not an 'unsigned long long'.
Consequently, PGOProfiling.c would fail to build if -Werror and
-Wformat are both enabled.

llvm-svn: 198644
2014-01-06 23:17:27 +00:00
Justin Bogner 65bb804f05 profile: Rudimentary suppport for PGO instrumentation
This is fairly minimal support for instrumentation based PGO. The data
format is inefficient, and the output file name is hardcoded to
pgo-data.

llvm-svn: 198638
2014-01-06 22:27:03 +00:00
NAKAMURA Takumi d40d387fb1 Update the copyright credits -- Happy new year 2014!
FIXME: Dragonegg may be updated at non-trivial changes.
llvm-svn: 198274
2014-01-01 08:27:31 +00:00
Dmitry Vyukov 5b57ea7a24 tsan: fix Go build
Currently fails with:
gotsan.cc:7686:40: error: the address of 'int __sanitizer_pthread_attr_getstack(void*, void**, size_t*)' will always evaluate as 'true' [-Werror=address]

llvm-svn: 198261
2013-12-31 09:38:23 +00:00