summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2016-08-04builtins: split out the EABI and VFP ARM sourcesSaleem Abdulrasool
These are meant to only be included on certain targets. This only disables it for Windows ARM for now. Ideally these would be conditionally included as appropriate. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277777 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-04Avoid re-entrancy between __sanitizer::Report, OutputDebugString, and ↵Reid Kleckner
RtlRaiseException Our Report implementation calls OutputDebugString, which calls RtlRaiseException, which can re-enter back into the ASan runtime and cause a hang. Don't treat this special debugger-only exception code as a noreturn event, since the stack won't really unwind all the way. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277763 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-04fix whitespaces from https://reviews.llvm.org/D23170Etienne Bergeron
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277746 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-04[compiler-rt] Fix memory allocator for dynamic address spaceEtienne Bergeron
Summary: The sanitizer allocators can works with a dynamic address space (i.e. specified with ~0ULL). Unfortunately, the code was broken on GetMetadata and GetChunkIdx. The current patch is moving the Win64 memory test to a dynamic address space. There is a migration to move every concept to a dynamic address space on windows. To have a better coverage, the unittest are now testing dynamic address space on other platforms too. Reviewers: rnk, kcc Subscribers: kubabrecka, dberris, llvm-commits, chrisha Differential Revision: https://reviews.llvm.org/D23170 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277745 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-04[compiler-rt][XRay] Stash xmm registers in the trampolinesDean Michael Berris
We now stash and restore the xmm registers in the trampolines so that log handlers don't need to worry about clobbering these registers. In response to comments in D21612. Reviewers: rSerge, eugenis, echristo, rnk Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D23051 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277683 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03[ASan] Report illegal instruction exceptions in ASanReid Kleckner
Summary: Respect the handle_sigill common flag and handle_segv flags while we're at it. We still handle signals/exceptions differently on Unix and Windows. The installation process is tricky on Windows, and difficult to push down into sanitizer_common without concerning it with the different static/dynamic CRT models on Windows. Reviewers: kcc, etienneb Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D23098 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277621 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03[compiler-rt] Fix CHECK coding style [NFC]Etienne Bergeron
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277604 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03[compilter-rt] Try to fix correctly rL277560Etienne Bergeron
rL277560: [compiler-rt] Fix broken interception unittest git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277567 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03[sanitizer] remove one redundant loop from the allocatorKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277563 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03[compiler-rt] Fix broken interception unittestEtienne Bergeron
Summary: This patch is fixing a broken unittest which make the win64 bot failing. The bug was introduce here: https://reviews.llvm.org/D23046 The interception code is not the same in 32-bit and in 64-bit. The added unittest can only be patched on 32-bits. Reviewers: rnk Subscribers: llvm-commits, chrisha Differential Revision: https://reviews.llvm.org/D23099 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277560 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03Reduce coverage PC buffer size on 32-bit Windows to match 32-bit LinuxReid Kleckner
In r235779, Timur bumped the buffer size up to 1<<27, or about 134 million coverage points, presumably to handle Chrome. We allocate two arrays of uptrs with this size, and this reliably exhausts all available address space on 32-bit Windows (2 allocations of 512MB) when ASan is also enabled. Let's reduce the buffer size for now to stabilize the test suite. We can re-evaluate the approach later when we've brought the Chrome ASan builders back to life. Kostya said that Mike reduced the number of instrumented coverage points that LLVM emits by half since Timur made this change, so reducing this array size should also be safe. With this change, the 32-bit ASan tests reliably pass for me on Windows 10. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277558 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03[sanitizer] refactor TransferBatch to hide the implementation. NFC expected. ↵Kostya Serebryany
Second attempt after failed r276383 which was reverted. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277554 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02[scudo] add NORETURN to the declaration of dieWithMessage; this should fix a ↵Kostya Serebryany
warning in lib/scudo/scudo_termination.cpp git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277546 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02[sanitizer] Implement a __asan_default_options() equivalent for ScudoKostya Serebryany
Summary: Currently, the Scudo Hardened Allocator only gets its flags via the SCUDO_OPTIONS environment variable. With this patch, we offer the opportunity for programs to define their own options via __scudo_default_options() which behaves like __asan_default_options() (weak symbol). A relevant test has been added as well, and the documentation updated accordingly. I also used this patch as an opportunity to rename a few variables to comply with the LLVM naming scheme, and replaced a use of Report with dieWithMessage for consistency (and to avoid a callback). Reviewers: llvm-commits, kcc Differential Revision: https://reviews.llvm.org/D23018 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277536 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02[compiler-rt] Add more interception patterns.Etienne Bergeron
Summary: These instructions where not supported on my win7 computer. They were happening on strstr when building chrome unittests with asan. Reviewers: rnk Subscribers: llvm-commits, chrisha Differential Revision: https://reviews.llvm.org/D23081 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277519 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02[asan] Intercept RtlRaiseException instead of kernel32!RaiseExceptionReid Kleckner
Summary: On my install of Windows 10, RaiseException is a tail call to kernelbase!RaiseException. Obviously, we fail to intercept that. Instead, try hooking at the ntdll!RtlRaiseException layer. It is unlikely that this layer will contain control flow. Intercepting at this level requires adding a decoding for 'LEA ESP, [ESP + 0xXXXXXXXX]', which is a really obscure way to write 'SUB ESP, 0xXXXXXXXX' that avoids clobbering EFLAGS. Reviewers: etienneb Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D23046 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277518 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02fix comments typos [NFC]Etienne Bergeron
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277511 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02[Profile] track ownership of filename pattern stringXinliang David Li
Make sure runtime copy and owns the string when passed in from external users of runtime API. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277507 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02[asan] Remove NtWaitForWorkViaWorkerFactory interceptorReid Kleckner
Summary: On Windows 10, this gets called after TLS has been torn down from NTDLL, and we crash attempting to return fake_tsd. This interceptor isn't needed after r242948 anyway, so let's remove it. The ASan runtime can now tolerate unregistered threads calling __asan_handle_no_return. Reviewers: vitalybuka, etienneb Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D23044 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277478 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02Follow-up for r277458: Update the tsan_mman_test.cc unit test.Kuba Brecka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277463 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02[tsan] Fix the behavior of OSAtomicTestAndClearKuba Brecka
The system implementation of OSAtomicTestAndClear returns the original bit, but the TSan interceptor has a bug which always returns zero from the function. This patch fixes this and adds a test. Differential Revision: https://reviews.llvm.org/D23061 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277461 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02[tsan] Fix behavior of realloc(nullptr, 0) on DarwinKuba Brecka
On Darwin, there are some apps that rely on realloc(nullptr, 0) returning a valid pointer. TSan currently returns nullptr in this case, let's fix it to avoid breaking binary compatibility. Differential Revision: https://reviews.llvm.org/D22800 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277458 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02[CMake] Load LLVMConfig for standalone build of builtinsJonas Hahnfeld
Therefore move some code into reusable macros. Differential Revision: https://reviews.llvm.org/D22866 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277418 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-01Use 'unsigned long' to match the APIs of the MS bitscan intrinsicsReid Kleckner
We were getting warnings about how 'uint32_t*' is different from 'unsigned long*' even though they are effectively the same on Windows. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277363 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-01[compiler-rt] Fix various typos in asan dll [NFC]Etienne Bergeron
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277345 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-31XFAIL one sanitizer symbolizer test for FreeBSDDimitry Andric
Summary: Due to a QoI issuse in FreeBSD's libcxxrt-based demangler, one sanitizer symbolizer test consistently appears to fail: Value of: DemangleSwiftAndCXX("foo") Actual: "float" Expected: "foo" This is because libcxxrt's __cxa_demangle() incorrectly demangles the "foo" identifier to "float". It should return an error instead. For now, XFAIL this particular test for FreeBSD, until we can fix libcxxrt properly (which might take some time to coordinate with upstream). Reviewers: rnk, zaks.anna, emaste Subscribers: emaste, llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D23001 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277297 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-31[compiler-rt] Add support for interception redirect exports.Etienne Bergeron
Summary: On windows, an export can be redirected to an other DLL. This patch is adding the required support to the internal GetProcAddress implementation. This case was encountered by instrumenting chromium (win 64-bits) using this GN configuration: ``` is_component_build = true is_debug = false enable_nacl = false is_clang = true is_asan = true clang_base_path = "d:\src\llvm\ninja64" clang_use_chrome_plugins = false clang_version = "4.0.0" ``` The operating system is win7 (x64). Visual Studio: 2015 Professional Reviewers: rnk Subscribers: llvm-commits, chrisha Differential Revision: https://reviews.llvm.org/D22880 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277294 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29tsan: Enable 48-bit VMA support on aarch64Adhemerval Zanella
This patch adds 48-bits VMA support for tsan on aarch64. As current mappings for aarch64, 48-bit VMA also supports PIE executable. This limits the mapping mechanism because the PIE address bits (usually 0aaaaXXXXXXXX) makes it harder to create a mask/xor value to include all memory regions. I think it is possible to create a large application VAM range by either dropping PIE support or tune current range. It also changes slight the way addresses are packed in SyncVar structure: previously it assumes x86_64 as the maximum VMA range. Since ID is 14 bits wide, shifting 48 bits should be ok. Tested on x86_64, ppc64le and aarch64 (39 and 48 bits VMA). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277137 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29[compiler-rt][XRay] Address follow-up comments to initial interface and ↵Dean Michael Berris
initialisation code This addresses some comments from D21612, which contains the following changes: - Update __xray_patch() and __xray_unpatch() API documentation to not imply asynchrony. - Introduce a scope cleanup mechanism to make sure we can roll-back changes to the XRayPatching global atomic. - Introduce a few more comments for potential extension points for other platforms (for the implementation details of patching and un-patching). Reviewers: eugenis, rnk, kcc, echristo, majnemer Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D22911 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277124 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28Fix broken build botEtienne Bergeron
The address resolution is ussing RTLD_NEXT and not RTLD_DEFAULT. Which means &func may not be equivalent to dlsym("func"). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276951 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27[compiler-rt] Fix warnings in interception codeEtienne Bergeron
Summary: This patch is re-introducing the code to fix the dynamic hooking on windows and to fix a compiler warning on Apple. Related patches: * https://reviews.llvm.org/D22641 * https://reviews.llvm.org/D22610 * https://reviews.llvm.org/rL276311 * https://reviews.llvm.org/rL276490 Both architecture are using different techniques to hook on library functions (memchr, strcpy,...). On Apple, the function is not dynamically hooked and the symbol always points to a valid function (i.e. can't be null). The REAL macro returns the symbol. On windows, the function is dynamically patch and the REAL(...) function may or may not be null. It depend on whether or not the function was hooked correctly. Also, on windows memcpy and memmove are the same. ``` #if !defined(__APPLE__) [...] # define REAL(x) __interception::PTR_TO_REAL(x) # define ASSIGN_REAL(dst, src) REAL(dst) = REAL(src) [...] #else // __APPLE__ [...] # define REAL(x) x # define ASSIGN_REAL(x, y) [...] #endif // __APPLE__ Reviewers: rnk Subscribers: kcc, hans, kubabrecka, llvm-commits, bruno, chrisha Differential Revision: https://reviews.llvm.org/D22758 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276885 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27tsan: don't deliver signals when they are blockedDmitry Vyukov
When we delay signals we can deliver them when the signal is blocked. This can be surprising to the program. Intercept signal blocking functions merely to process pending signals. As the result, at worst we will delay a signal till return from the signal blocking function. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276876 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27Use RAII for ensuring that mprotect calls are undoneDean Michael Berris
Summary: This fixes an mprotect leak identified in D21612. Reviewers: echristo, rSerge Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D22757 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276833 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-26[asan] Remove zero FSR check on ARM.Evgeniy Stepanov
The kernel on Nexus 5X returns error_code in ucontext which has correct FSR_WRITE flag, but empty (zero) abort type field. Removing the checks means that we will report all SEGVs as READ on very old kernels, but will properly distinguish READ vs WRITE on moderately old ones. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276803 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-26[asan] Hardcode page size 4096 on Android.Evgeniy Stepanov
EXEC_PAGESIZE lies. sysconf() is broken in .preinit_array. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276802 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-26[sanitizer] Try to fix LargeMmapAllocator test on WindowsReid Kleckner
This test attempts to allocate 100 512MB aligned pages of memory. This is implemented in the usual way by allocating size + alignment bytes and aligning the result. As a result, this test allocates 51.2GB of memory. Windows allocates swap for all memory allocated, and our bots do not have this much swap available. Avoid the failure by using a more reasonable alignment, like 16MB, as we do on 32-bit. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276779 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25Define compatibility flag if not defined with -std=c++Xinliang David Li
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276708 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25Revert "Enable cross-compilation across architectures on android"Chris Bieneman
This reverts commit r276333. As I commented in the review (https://reviews.llvm.org/D22415), this change isn't needed because CMAKE_C_FLAGS is implicitly added by CMake to the command line for all C source files. With this patch enabled CMAKE_C_FLAGS is duplicated on all C sources, and applied to ASM sources, which is not ideal. I sent an email about this to llvm-commits on the commit thread. I suspect the problem the patch author was actually seeing is that CMAKE_C_FLAGS isn't applied to ASM files, and the builtins library has quite a few of those. The correct solution there is to specify CMAKE_ASM_FLAGS with whatever flags need to be passed to the compiler when compiling ASM files. If there are other problems with flag propagation, please let me know. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276683 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-24Revert r276539 "Silence -Wpointer-bool-conversion warning after r276324"Bruno Cardoso Lopes
Some bots are not happy with the change. This reverts commit d307ca28083065851ad969444f3c063562f2d4bd. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276541 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-24Silence -Wpointer-bool-conversion warning after r276324Bruno Cardoso Lopes
sanitizer_common_interceptors.inc:667:12: warning: address of function 'memchr' will always evaluate to 'true' [-Wpointer-bool-conversion] if (REAL(memchr)) { ~~ ^~~~~~ git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276539 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22Revert "fix https://reviews.llvm.org/D22610" and "[compiler-rt] Fix ↵Bruno Cardoso Lopes
memmove/memcpy overlap detection on windows" This currently fails ~500 tests on Darwin: http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/20456/ This reverts commit 4cfee0dff1facb8fa2827d25c5943bfef96d1a8f and dbd91205d578cb61ab77be06087e9f65ba8a7ec8. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276490 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22[sanitizer] revert r276383 while investigating failures on botKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276456 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22Try to fix more Windows portability issues in sanitizer testsReid Kleckner
Add a %stdcxx11 lit substitution for -std=c++11. Windows defaults to -std=c++14 when VS 2015 is used because the STL requires it. Harcoding -std=c++11 in the ASan tests actually downgrades the C++ standard level, leading to test failures. Relax a FileCheck pattern in use-after-scope-types.cc. Disable the sanitizer_common OOM tests. They fail on bots with low swap, and cause other concurrently running tests to OOM. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276454 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22[Profile] cleanup: do not reference name directly of vars shared between rt ↵Xinliang David Li
and llvm git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276385 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22[sanitizer] refactor TransferBatch to hide the implementation. NFCKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276383 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22[sanitizer] allocator: introduce kUseSeparateSizeClassForBatch (false by ↵Kostya Serebryany
default). When true, it will cause all TransferBatches to be allocated on a separate dedicated size class, which improves security and may potentially simplify memory reclamation. However in the current state this may cause up to 3% extra memory usage. Subsequent changes should bring this overhead down git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276377 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21[Profile] deprecate __llvm_profile_override_default_filename (part2)Xinliang David Li
This eliminates unncessary calls and init functions. Differential Revision: http://reviews.llvm.org/D22614 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276355 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21[sanitizer] trying to fix Mac botsKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276346 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21[sanitizer] better allocator stats (with rss)Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276343 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21[compiler-rt] Add support for relative offset adjustment in interceptionEtienne Bergeron
Summary: Some instructions can only be copied if the relative offset is adjusted. This patch adds support for two common instruction. It's quite common to have a indirect load in the prologue (loading the security cookie). Reviewers: rnk Subscribers: llvm-commits, wang0109, chrisha Differential Revision: https://reviews.llvm.org/D22647 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276336 91177308-0d34-0410-b5e6-96231b3b80d8