Commit Graph

48 Commits

Author SHA1 Message Date
Timur Iskhodzhanov eee13914e2 Define SANITIZER_INTERFACE_ATTRIBUTE on Windows and fix all the places where SANITIZER_INTERFACE_ATTRIBUTE or SANITIZER_ATTRIBUTE_WEAK are used
llvm-svn: 188261
2013-08-13 11:42:45 +00:00
Evgeniy Stepanov 863746eb1a [sanitizer] Fix windows build.
llvm-svn: 183225
2013-06-04 14:06:16 +00:00
Evgeniy Stepanov 56050e8f69 [sanitizer] Fix __sanitizer_unaligned_* to work with unaligned data types.
llvm-svn: 183224
2013-06-04 13:49:10 +00:00
Timur Iskhodzhanov baf90ccfac Fix ALIGNED misuse in asan_thread.cc (built on all platforms); also, add a comment to the ALIGNED macro describing the correct usage
llvm-svn: 183214
2013-06-04 08:25:17 +00:00
Peter Collingbourne 6f4be19b57 [nolibc] Change internal syscall API to remove reliance on libc's errno.
This change moves to a model where the error value of a system call is
potentially contained in the return value itself rather than being
implicit in errno.  The helper function internal_iserror can be used
to extract the error value from a return value.  On platforms other
than Linux/x86_64 this still uses errno, but other platforms are free
to port their error handling to this new model.

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

llvm-svn: 181436
2013-05-08 14:43:49 +00:00
Timur Iskhodzhanov 664ec5d7a8 Finally drop the 'static' from INLINE and ALWAYS_INLINE
The ALWAYS_INLINE doesn't have static on POSIX anyways since r178341; the INLINE is only used in .h files, so shouldn't have been 'static' in the first place

llvm-svn: 179371
2013-04-12 09:37:20 +00:00
Alexey Samsonov 87c2a87b50 [Sanitizer] Fix OnPrint weak hook. Disable weak hooks for gotsan.
llvm-svn: 178640
2013-04-03 13:22:54 +00:00
Kostya Serebryany 91952cda76 [tsan] restore performance critical inlining in tsan: remove static from ALWAYS_INLINE, use ALWAYS_INLINE USED for critical functions.
llvm-svn: 178341
2013-03-29 09:44:16 +00:00
Timur Iskhodzhanov e3164e9647 Add "static" to the Windows ALWAYS_INLINE macro (similar to what we do on POSIX)
llvm-svn: 178296
2013-03-28 22:07:28 +00:00
Timur Iskhodzhanov a6788325cf Make all the ALWAYS_INLINE users Windows-friendly; also, avoid ALWAYS_INLINE INLINE combinations
llvm-svn: 178266
2013-03-28 18:52:40 +00:00
Evgeniy Stepanov 95eaa21637 [sanitizer] More renamed macros.
llvm-svn: 177401
2013-03-19 14:54:17 +00:00
Evgeniy Stepanov 0af672326a [sanitizer] Replace more platform checks with SANITIZER_ constants.
llvm-svn: 177400
2013-03-19 14:33:38 +00:00
Evgeniy Stepanov d3b56605f1 [sanitizer] Move ASan platform macros to sanitizer_common and rename them appropriately.
llvm-svn: 177397
2013-03-19 13:54:41 +00:00
Kostya Serebryany f0b8f989e9 add Linux syscall wrappers and ThreadLister to sanitizer_common
ThreadLister is a Linux-specific class for obtaining the thread IDs of a process from procfs (/proc/<pid>/task/). It will be used by leak checking code.
Also add several syscall wrappers which will be required by the same code that uses ThreadLister, but are not used in ThreadLister itself.
Patch by Sergey Matveev

llvm-svn: 176179
2013-02-27 11:22:40 +00:00
Kostya Serebryany fd61b6f0c8 [asan] make asan work with 7fff8000 offset and prelink
When prelink is installed in the system, prelink-ed
libraries map between 0x003000000000 and 0x004000000000 thus occupying the shadow Gap,
so we need so split the address space even further, like this:
|| [0x10007fff8000, 0x7fffffffffff] || HighMem    ||
|| [0x02008fff7000, 0x10007fff7fff] || HighShadow ||
|| [0x004000000000, 0x02008fff6fff] || ShadowGap3 ||
|| [0x003000000000, 0x003fffffffff] || MidMem     ||
|| [0x00087fff8000, 0x002fffffffff] || ShadowGap2 ||
|| [0x00067fff8000, 0x00087fff7fff] || MidShadow  ||
|| [0x00008fff7000, 0x00067fff7fff] || ShadowGap  ||
|| [0x00007fff8000, 0x00008fff6fff] || LowShadow  ||
|| [0x000000000000, 0x00007fff7fff] || LowMem     ||

Do it only if necessary.

Also added a bit of profiling code to make sure that the
mapping code is efficient.

Added a lit test to simulate prelink-ed libraries.
Unfortunately, this test does not work with binutils-gold linker.
If gold is the default linker the test silently passes.

Also replaced
__has_feature(address_sanitizer)
with
__has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
in two places.

Patch partially by Jakub Jelinek.

llvm-svn: 175263
2013-02-15 12:00:24 +00:00
Kostya Serebryany b4c2c5c8a6 [asan] print a short one-line report summary after the full report. Currently, works only if symbolization happens in-process.
llvm-svn: 174501
2013-02-06 12:36:49 +00:00
Alexey Samsonov 4985b8766e [Sanitizer] use u32 instead of mode_t, which is defined in Darwin headers
llvm-svn: 174189
2013-02-01 16:32:18 +00:00
Alexey Samsonov 39313b780d [Sanitizer] make internal_open have the same interface as libc version
llvm-svn: 174187
2013-02-01 15:58:46 +00:00
Evgeniy Stepanov 358698279d [sanitizer] Further split private and public sanitizer headers.
And make msan_interface.h C-compatible.

llvm-svn: 173928
2013-01-30 13:12:08 +00:00
Dmitry Vyukov 7f4603200f asan: fix ARM build
llvm-svn: 172613
2013-01-16 14:35:13 +00:00
Dmitry Vyukov 2854326db6 asan: correct non-temporal prefetch for memory allocator
llvm-svn: 172522
2013-01-15 09:03:20 +00:00
Dmitry Vyukov 86585ad319 asan: add memory prefetch to quarantine recycle
llvm-svn: 172216
2013-01-11 16:40:24 +00:00
Kostya Serebryany 734f1eb5f4 [asan/tsan] do not use __WORDSIZE macro, as it is glibc-private thing. Instead, define our own SANITIZER_WORDSIZE
llvm-svn: 168424
2012-11-21 12:38:58 +00:00
Dmitry Vyukov 2817639411 tsan: define missing compier macros for windows
llvm-svn: 167450
2012-11-06 12:54:16 +00:00
Dmitry Vyukov e9bafdf5b8 tsan: fix non-msvc windows build
llvm-svn: 167449
2012-11-06 12:50:13 +00:00
Dmitry Vyukov 04dd4b7349 tasn: improve sanitizer_internal_defs.h
The file uses namespaces and extern "LANG", so it's kinda senseless to use #ifdef __cplusplus

llvm-svn: 167448
2012-11-06 12:49:22 +00:00
Dmitry Vyukov e6b5a696e3 tsan: fix windows build
__declspec is not _WIN32, it's _MSC_VER

llvm-svn: 167447
2012-11-06 12:47:42 +00:00
Kostya Serebryany 278bd2e3a3 [asan] fix lint
llvm-svn: 166006
2012-10-16 04:50:32 +00:00
Alexey Samsonov 3a0a88fe0a [Sanitizer] Add UNREACHABLE(msg) macro
llvm-svn: 165492
2012-10-09 08:42:07 +00:00
Evgeniy Stepanov 49e8576a09 [*San]: handle EINTR.
llvm-svn: 165006
2012-10-02 13:41:40 +00:00
Alexey Samsonov a555b3faf4 [ASan] Apply some ASan-relevant pieces of patch by Ruben Van Boxem. In the same time, remove ASan from CMake build on Windows after conversation with Timur. We don't want to support building ASan on Windows until it is in a working state.
llvm-svn: 164486
2012-09-24 11:43:40 +00:00
Alexey Samsonov c21f901b2f [Sanitizer] fix warnings reported by gcc. Update the list of targets to check lint for
llvm-svn: 163608
2012-09-11 10:31:28 +00:00
Chandler Carruth 1aa4fef601 Relocate the external headers provided by ASan and the common sanitizer
library.

These headers are intended to be available to user code when built with
AddressSanitizer (or one of the other sanitizer's in the future) to
interface with the runtime library. As such, they form stable external
C interfaces, and the headers shouldn't be located within the
implementation.

I've pulled them out into what seem like fairly obvious locations and
names, but I'm wide open to further bikeshedding of these names and
locations.

I've updated the code and the build system to cope with the new
locations, both CMake and Makefile. Please let me know if this breaks
anyone's build.

The eventual goal is to install these headers along side the Clang
builtin headers when we build the ASan runtime and install it. My
current thinking is to locate them at:

  <prefix>/lib/clang/X.Y/include/sanitizer/common_interface_defs.h
  <prefix>/lib/clang/X.Y/include/sanitizer/asan_interface.h
  <prefix>/lib/clang/X.Y/include/sanitizer/...

But maybe others have different suggestions?

Fixing the style of the #include between these headers at least unblocks
experimentation with installing them as they now should work when
installed in these locations.

llvm-svn: 162822
2012-08-29 02:27:54 +00:00
Kostya Serebryany 66a37f3aef [asan] one more fix for windows build
llvm-svn: 162762
2012-08-28 15:25:07 +00:00
Kostya Serebryany 7575968aa4 [asan] actually move StackTrace to sanitizer_common
llvm-svn: 162757
2012-08-28 14:11:57 +00:00
Kostya Serebryany ccc470c499 [asan] some renaming before we move StackTrace into sanitizer_common (part 2)
llvm-svn: 162748
2012-08-28 11:54:51 +00:00
Alexey Samsonov dc8d1f1039 [Sanitizer] move low-level (mmap-based) allocator to sanitizer_common
llvm-svn: 162663
2012-08-27 09:30:58 +00:00
Dmitry Vyukov 6fa46f7003 tsan/asan: unify atomics (move atomics from tsan to sanitizer_common)
llvm-svn: 159437
2012-06-29 16:58:33 +00:00
Dmitry Vyukov 090f345522 tsan: prevent insertion of unwanted memset/memcpy/memcmp into runtime
llvm-svn: 159294
2012-06-27 21:00:23 +00:00
Kostya Serebryany 6e26fa9dd1 [tsan] first step in implementing a custom allocator for tsan (and msan) which saves precious shadow
llvm-svn: 158913
2012-06-21 10:04:36 +00:00
Alexey Samsonov 156958dd0c [Sanitizer] move all the rest re-implementations of libc functions from ASan runtime to common sanitizer runtime
llvm-svn: 158519
2012-06-15 13:09:52 +00:00
Alexey Samsonov 40e5128412 [Sanitizer] move ShadowRangeIsAvailable and several defines to common runtime
llvm-svn: 158499
2012-06-15 07:29:14 +00:00
Alexey Samsonov aac5d0c831 [Sanitizer] Workaround for -Wunused-private-field warning - add an attribute in TSan unit test, and silence this warning as gtest has unused fields.
llvm-svn: 158449
2012-06-14 14:02:32 +00:00
Alexey Samsonov e95e29c2ac [Sanitizer] Make UNIMPLEMENTED macro common.
llvm-svn: 158077
2012-06-06 15:47:40 +00:00
Alexey Samsonov e428779dbf [Sanitizer] Use common CHECK machinery. Currently each tool has to define its own CheckFailed function.
llvm-svn: 158075
2012-06-06 15:22:20 +00:00
Alexey Samsonov 8bafdd020e [Sanitizer] fix Win build - ignore __attribute__((format)).
llvm-svn: 158067
2012-06-06 13:37:02 +00:00
Alexey Samsonov ee07290628 [Sanitizer] Move more functions/constants to sanitizer_common.
llvm-svn: 158056
2012-06-06 09:26:25 +00:00
Alexey Samsonov 5bbf8290a7 [Sanitizer] rename sanitizer_defs.h to sanitizer_internal_defs.h
llvm-svn: 158001
2012-06-05 14:25:27 +00:00