summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* hwasan: Add __hwasan_init_static() function.Peter Collingbourne2019-01-318-19/+64
| | | | | | | | | | | This function initializes enough of the runtime to be able to run instrumented code in a statically linked executable. It replaces __hwasan_shadow_init() which wasn't doing enough initialization for instrumented code that uses either TLS or IFUNC to work. Differential Revision: https://reviews.llvm.org/D57490 llvm-svn: 352816
* [fuzzer] Use RawPrint instead of Printf for instrumentation warningJonathan Metzman2019-01-312-7/+11
| | | | | | | | | | | | | | | Summary: Use RawPrint instead of Printf for instrumentation warning because Printf doesn't work on Win when instrumentation is being initialized (since OutputFile is not yet initialized). Reviewers: kcc Reviewed By: kcc Differential Revision: https://reviews.llvm.org/D57531 llvm-svn: 352789
* Revert r352732: [libFuzzer] replace slow std::mt19937 with a much faster ↵Jeremy Morse2019-01-311-3/+3
| | | | | | | | | | std::minstd_rand This causes a failure on the following bot as well as our internal ones: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fuzzer/builds/23103 llvm-svn: 352747
* [libFuzzer] replace slow std::mt19937 with a much faster std::minstd_randKostya Serebryany2019-01-311-3/+3
| | | | llvm-svn: 352732
* [libFuzzer] set libFuzzer's own SEGV handler even one is already present, ↵Kostya Serebryany2019-01-314-13/+18
| | | | | | but call that handler from ours (unless we are unprotecting lazy counters). Call ProtectLazyCounters later, so that it runs after the initialization code in the target. llvm-svn: 352713
* [libFuzzer] Set default sanitizer options in fuzzer testsJulian Lettner2019-01-311-2/+3
| | | | | | | | | | | | | | | | | | | | | Summary: Set default `ASAN_OPTIONS` when running libFuzzer tests. This allows us to remove special casing in code for Darwin where we usually pass `abort_on_error=0` to override platform defaults for tests. A previous commit changed the code to make the tests pass: https://github.com/llvm/llvm-project/commit/7764a04af007eca68eafcf5caaea560ed05e35a9 Adapted a few tests to use `%env_asan_opts=` instead of directly setting the environment variable. rdar://problem/47515276 Reviewers: kcc, george.karpenkov Differential Revision: https://reviews.llvm.org/D57465 llvm-svn: 352711
* [libFuzzer] experimental performance optimization -lazy_counters, off by ↵Kostya Serebryany2019-01-3111-1/+78
| | | | | | default. Posix-only for now, tested on Linux llvm-svn: 352700
* [libFuzzer] remove stale code, NFCKostya Serebryany2019-01-309-346/+0
| | | | llvm-svn: 352604
* [libFuzzer] refactor the handling of instrumentation counters so that they ↵Kostya Serebryany2019-01-303-47/+107
| | | | | | are grouped in regions one full page each. Needed for future optimization. NFC llvm-svn: 352603
* [libFuzzer] remove stale code Kostya Serebryany2019-01-296-113/+3
| | | | llvm-svn: 352571
* [libFuzzer] revert an accidental commitKostya Serebryany2019-01-291-3/+35
| | | | llvm-svn: 352567
* [libFuzzer] remove deprecated support for -fsanitize-coverage=trace-pc[-guard]Kostya Serebryany2019-01-291-35/+3
| | | | llvm-svn: 352566
* [libFuzzer] remove deprecated support for -fsanitize-coverage=trace-pc[-guard]Kostya Serebryany2019-01-291-9/+12
| | | | llvm-svn: 352564
* Adjust documentation for git migration.James Y Knight2019-01-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes most references to the paths: llvm.org/svn/ llvm.org/git/ llvm.org/viewvc/ github.com/llvm-mirror/ github.com/llvm-project/ reviews.llvm.org/diffusion/ to instead point to https://github.com/llvm/llvm-project. This is *not* a trivial substitution, because additionally, all the checkout instructions had to be migrated to instruct users on how to use the monorepo layout, setting LLVM_ENABLE_PROJECTS instead of checking out various projects into various subdirectories. I've attempted to not change any scripts here, only documentation. The scripts will have to be addressed separately. Additionally, I've deleted one document which appeared to be outdated and unneeded: lldb/docs/building-with-debug-llvm.txt Differential Revision: https://reviews.llvm.org/D57330 llvm-svn: 352514
* [compiler-rt] Fix reporting unrecognized flags in unit tests.Igor Kudrin2019-01-291-0/+3
| | | | | | | | Previously, the warning messages might be issued within a wrong test case. Differential Revision: https://reviews.llvm.org/D57318 llvm-svn: 352447
* [libFuzzer][Windows] Use dllexport for all declarations in FuzzerInterface.hJonathan Metzman2019-01-281-1/+1
| | | | | | | | | | | | | | | | | Summary: Use dllexport for all declarations in FuzzerInterface.h Use it for clang even though clang supports default visibility attribute to prevent a warning from being thrown when LLVMFuzzerMutate is defined with dllexport. This makes `FUZZER_INTERFACE_VISIBILITY` (FuzzerInterface.h) consistent with `ATTRIBUTE_INTERFACE` (FuzzerDefs.h) when using clang on Windows. Reviewers: vitalybuka, morehouse Reviewed By: morehouse Differential Revision: https://reviews.llvm.org/D57305 llvm-svn: 352395
* [fuzzer][afl] Remove AFL_DRIVER_EXTRA_STATS_FILENAMEJonathan Metzman2019-01-281-165/+4
| | | | | | | | | | | | | | Summary: Remove this feature as it is unused, buggy, and not worth correcting since the forkserver makes it difficult. Reviewers: morehouse, jfb Reviewed By: morehouse Differential Revision: https://reviews.llvm.org/D57308 llvm-svn: 352392
* Make more allocator methods work correctly with in an out-of-process mode.Dan Liew2019-01-272-13/+18
| | | | | | | | | | | | | | | | | | | | | | Summary: This makes `GetBlockBegin()` and `GetBlockBeginFastLocked()` work correctly with `RemoteAddressSpaceView`. This has a knock on effect of also making the `PointerIsMine()` and `GetMetaData()` methods behave correctly when `RemoteAddressSpaceView` is used to instantiate the allocators. This will be used by future out-of-process allocator enumeration patches. rdar://problem/45284065 Reviewers: kcc, vitalybuka, dvyukov, cryptoad, eugenis, george.karpenkov, yln Subscribers: #sanitizers, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D56964 llvm-svn: 352335
* [libFuzzer] print uncovered functions when doing -print_coverage=1Kostya Serebryany2019-01-261-6/+6
| | | | llvm-svn: 352263
* Fix XRayTest link on FreeBSD (and likely NetBSD too)Dimitry Andric2019-01-251-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: As reported on llvm-testers, during 8.0.0-rc1 testing I got errors while building of `XRayTest`, during `check-all`: ``` [100%] Generating XRayTest-x86_64-Test /home/dim/llvm/8.0.0/rc1/Phase3/Release/llvmCore-8.0.0-rc1.obj/./lib/libLLVMSupport.a(Signals.cpp.o): In function `llvm::sys::PrintStackTrace(llvm::raw_ostream&)': Signals.cpp:(.text._ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x24): undefined reference to `backtrace' Signals.cpp:(.text._ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x254): undefined reference to `llvm::itaniumDemangle(char const*, char*, unsigned long*, int*)' clang-8: error: linker command failed with exit code 1 (use -v to see invocation) gmake[3]: *** [projects/compiler-rt/lib/xray/tests/unit/CMakeFiles/TXRayTest-x86_64-Test.dir/build.make:73: projects/compiler-rt/lib/xray/tests/unit/XRayTest-x86_64-Test] Error 1 gmake[3]: Target 'projects/compiler-rt/lib/xray/tests/unit/CMakeFiles/TXRayTest-x86_64-Test.dir/build' not remade because of errors. gmake[2]: *** [CMakeFiles/Makefile2:33513: projects/compiler-rt/lib/xray/tests/unit/CMakeFiles/TXRayTest-x86_64-Test.dir/all] Error 2 gmake[2]: Target 'CMakeFiles/check-all.dir/all' not remade because of errors. gmake[1]: *** [CMakeFiles/Makefile2:737: CMakeFiles/check-all.dir/rule] Error 2 gmake[1]: Target 'check-all' not remade because of errors. gmake: *** [Makefile:277: check-all] Error 2 [Release Phase3] check-all failed ``` This is because the `backtrace` function requires `-lexecinfo` on BSD platforms. To fix this, detect the `execinfo` library in `cmake/config-ix.cmake`, and add it to the unit test link flags. Additionally, since the code in `sys::PrintStackTrace` makes use of `itaniumDemangle`, also add `-lLLVMDemangle`. (Note that this is more of a general problem with libLLVMSupport, but I'm looking for a quick fix now so it can be merged to the 8.0 branch.) Reviewers: dberris, hans, mgorny, samsonov Reviewed By: dberris Subscribers: krytarowski, delcypher, erik.pilkington, #sanitizers, emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D57181 llvm-svn: 352234
* Enhance support for NetBSD in SafeStackKamil Rytarowski2019-01-251-5/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Always try to detect and call internal or real libc symbols instead of locally installed interceptors. This covers: - GetTid() - TgKill() - Mmap() - Munmap() - Mprotect() This cherry-picks code from sanitizer_common/sanitizer_netbsd.cc. Reviewers: vitalybuka Reviewed By: vitalybuka Subscribers: llvm-commits, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D57179 llvm-svn: 352154
* [hwasan] Madvise away thread aux dataEvgeniy Stepanov2019-01-251-13/+29
| | | | | | | | | | | | | | | | | | | | Summary: Release memory pages for thread data (allocator cache, stack allocations ring buffer, etc) when a thread exits. We can not simply munmap them because this memory is custom allocated within a limited address range, and it needs to stay "reserved". This change alters thread storage layout by putting the ring buffer before Thread instead of after it. This makes it possible to find the start of the thread aux allocation given only the Thread pointer. Reviewers: kcc, pcc Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D56621 llvm-svn: 352151
* [hwasan] Implement print_module_map flag.Evgeniy Stepanov2019-01-252-7/+13
| | | | | | | | | | Reviewers: kcc, pcc Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D57130 llvm-svn: 352150
* [libFuzzer][MSVC] Disable exceptions in MSVC headersJonathan Metzman2019-01-251-3/+4
| | | | | | | | | | | | | | | | Summary: Disable exceptions in MSVC headers using -D_HAS_EXCEPTIONS=0 to silence compiler warning instead of using /Ehsc. Reviewers: rnk, morehouse, metzman Reviewed By: rnk, morehouse, metzman Subscribers: rnk, morehouse, mgorny Differential Revision: https://reviews.llvm.org/D57119 llvm-svn: 352144
* [libFuzzer] more agressive value profiling and CMP tracing for switch statementsKostya Serebryany2019-01-241-11/+31
| | | | llvm-svn: 352107
* [scudo] Tuning changes based on feedback from current useKostya Kortchinsky2019-01-243-4/+6
| | | | | | | | | | | | | | | | | | | | | | Summary: This tunes several of the default parameters used within the allocator: - disable the deallocation type mismatch on Android by default; this was causing too many issues with third party libraries; - change the default `SizeClassMap` to `Dense`, it caches less entries and is way more memory efficient overall; - relax the timing of the RSS checks, 10 times per second was too much, lower it to 4 times (every 250ms), and update the test so that it passes with the new default. Reviewers: eugenis Reviewed By: eugenis Subscribers: srhines, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D57116 llvm-svn: 352057
* Revert https://reviews.llvm.org/D56485.Martin Liska2019-01-242-1/+7
| | | | llvm-svn: 352033
* Always compare C++ typeinfo (based on libstdc++ implementation).Martin Liska2019-01-242-7/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D56485. llvm-svn: 352032
* Fix building sanitizers for MinGWMartin Storsjo2019-01-231-1/+1
| | | | | | The /EHsc flag is MSVC specific, not generic to the windows target. llvm-svn: 351927
* hwasan: Move memory access checks into small outlined functions on aarch64.Peter Collingbourne2019-01-231-8/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Each hwasan check requires emitting a small piece of code like this: https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html#memory-accesses The problem with this is that these code blocks typically bloat code size significantly. An obvious solution is to outline these blocks of code. In fact, this has already been implemented under the -hwasan-instrument-with-calls flag. However, as currently implemented this has a number of problems: - The functions use the same calling convention as regular C functions. This means that the backend must spill all temporary registers as required by the platform's C calling convention, even though the check only needs two registers on the hot path. - The functions take the address to be checked in a fixed register, which increases register pressure. Both of these factors can diminish the code size effect and increase the performance hit of -hwasan-instrument-with-calls. The solution that this patch implements is to involve the aarch64 backend in outlining the checks. An intrinsic and pseudo-instruction are created to represent a hwasan check. The pseudo-instruction is register allocated like any other instruction, and we allow the register allocator to select almost any register for the address to check. A particular combination of (register selection, type of check) triggers the creation in the backend of a function to handle the check for specifically that pair. The resulting functions are deduplicated by the linker. The pseudo-instruction (really the function) is specified to preserve all registers except for the registers that the AAPCS specifies may be clobbered by a call. To measure the code size and performance effect of this change, I took a number of measurements using Chromium for Android on aarch64, comparing a browser with inlined checks (the baseline) against a browser with outlined checks. Code size: Size of .text decreases from 243897420 to 171619972 bytes, or a 30% decrease. Performance: Using Chromium's blink_perf.layout microbenchmarks I measured a median performance regression of 6.24%. The fact that a perf/size tradeoff is evident here suggests that we might want to make the new behaviour conditional on -Os/-Oz. But for now I've enabled it unconditionally, my reasoning being that hwasan users typically expect a relatively large perf hit, and ~6% isn't really adding much. We may want to revisit this decision in the future, though. I also tried experimenting with varying the number of registers selectable by the hwasan check pseudo-instruction (which would result in fewer variants being created), on the hypothesis that creating fewer variants of the function would expose another perf/size tradeoff by reducing icache pressure from the check functions at the cost of register pressure. Although I did observe a code size increase with fewer registers, I did not observe a strong correlation between the number of registers and the performance of the resulting browser on the microbenchmarks, so I conclude that we might as well use ~all registers to get the maximum code size improvement. My results are below: Regs | .text size | Perf hit -----+------------+--------- ~all | 171619972 | 6.24% 16 | 171765192 | 7.03% 8 | 172917788 | 5.82% 4 | 177054016 | 6.89% Differential Revision: https://reviews.llvm.org/D56954 llvm-svn: 351920
* [builtins] Do not set hidden attribute on AndroidYi Kong2019-01-231-2/+6
| | | | | | | | | | Bionic libc relies on an old libgcc behaviour which does not set hidden visibility attribute. Keep exporting these symbols on Android for compatibility. Differential Revision: https://reviews.llvm.org/D56977 llvm-svn: 351915
* [libFuzzer][MSVC] Enable building libFuzzer with MSVCJonathan Metzman2019-01-224-6/+13
| | | | | | | | | | | | | | | Summary: Enable building libFuzzer with MSVC. * Don't try to include <endian.h> in FuzzerSHA1.cpp. MSVC doesn't have this header, and WINDOWS is always little endian (even on ARM) Subscribers: srhines, mgorny, javed.absar, kristof.beyls Differential Revision: https://reviews.llvm.org/D56510 llvm-svn: 351855
* [safestack] Return syscalls for mmap, munmap and mprotectVitaly Buka2019-01-222-4/+31
| | | | | | This function can be already intercepted by instrumented code. llvm-svn: 351783
* [safestack] Fix NetBSD buildVitaly Buka2019-01-221-4/+15
| | | | llvm-svn: 351771
* [HWASAN] Improve tag mismatch diagnosticsEugene Leviant2019-01-213-8/+36
| | | | | | | | | Reports correct size and tags when either size is not power of two or offset to bad granule is not zero. Differential revision: https://reviews.llvm.org/D56603 llvm-svn: 351730
* [safestack] Remove unsupported platformsVitaly Buka2019-01-211-12/+6
| | | | llvm-svn: 351716
* [safestack] Fix FreeBSD runtime buildVitaly Buka2019-01-211-0/+4
| | | | llvm-svn: 351715
* [libFuzzer][MSVC] Make Sanitizer Coverage MSVC-compatibleJonathan Metzman2019-01-211-20/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Make Sanitizer Coverage work when compiled work when compiler-rt is compiled with MSVC. The previous solution did not work for MSVC because MSVC tried to align the .SCOV$CZ section even though we used __declspec(align(1)) on its only symbol: __stop___sancov_cntrs. Because the counter array is composed of 1 byte elements, it does not always end on an 8 or 4 byte boundary. This means that padding was sometimes added to added to align the next section, .SCOV$CZ. Use a different strategy now: instead of only instructing the compiler not to align the symbol, make the section one byte long by making its only symbol a uint8_t, so that the linker won't try to align it. Reviewers: morehouse, rnk Reviewed By: rnk Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D56866 llvm-svn: 351714
* [ASan] On Darwin record global allocator pointer and size in introspection ↵Dan Liew2019-01-211-1/+17
| | | | | | | | | | | | struct. This implements `mi_extra_init(...)` for the ASan allocator on Darwin and uses the `__lsan::GetAllocatorGlobalRange(...)` function to retrieve the allocator pointer and size. rdar://problem/45284065 llvm-svn: 351713
* On Darwin add allocator address and size fields toDan Liew2019-01-214-0/+28
| | | | | | | | | | | | | | `sanitizer_malloc_introspection_t` and initialize them to zero. We allow sanitizer implementations to perform different initialization by defining `COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT` to be `1` and providing an implementation of `mi_extra_init(...)`. We use these changes in future patches to implement malloc zone enumeration. rdar://problem/45284065 llvm-svn: 351712
* On Darwin allow for sanitizer malloc implementations to provide a zoneDan Liew2019-01-214-4/+22
| | | | | | | | | | | | | | | | enumerator. This is done by defining `COMMON_MALLOC_HAS_ZONE_ENUMERATOR` to `1` and then by providing an implementation of the `mi_enumerator(...)` function. If a custom implementation isn't desired the macro is set to `0` which causes a stub version (that fails) to be used. Currently all Darwin sanitizers that have malloc implementations define this to be `0` so there is no functionality change. rdar://problem/45284065 llvm-svn: 351711
* Fix bug in `AsanAllocatorASVT` (ASan) and `AllocatorASVT` (LSan) templated ↵Dan Liew2019-01-202-2/+4
| | | | | | | | | | | | | | alias. We forgot to pass `AddressSpaceView` to the `CombinedAllocator` which meant we would always use `LocalAddressSpaceView` for the `CombinedAllocator` leading to a static_assert failing when we tried to do `AsanAllocatorASVT<RemoteAddressSpaceView>` or `AllocatorASVT<RemoteAddressSpaceView>`. rdar://problem/45284065 llvm-svn: 351689
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-19333-1286/+999
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-19670-2646/+2010
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [hwasan] Madvise away unused shadow.Evgeniy Stepanov2019-01-193-1/+30
| | | | | | | | | | | | | | | | | | Summary: Whenever a large shadow region is tagged to zero, madvise(DONT_NEED) as much of it as possible. This reduces shadow RSS on Android by 45% or so, and total memory use by 2-4%, probably even more on long running multithreaded programs. CPU time seems to be in the noise. Reviewers: kcc, pcc Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D56757 llvm-svn: 351620
* [safestack] Add ThreadId type as uint64_tVitaly Buka2019-01-182-4/+11
| | | | | | | | | | Reviewers: krytarowski, eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D56937 llvm-svn: 351607
* [safestack] Remove dependency of SafeStack on sanitizer_commonVitaly Buka2019-01-184-35/+138
| | | | | | | | | | | | | | Summary: SafeStack needs just few functions from there, but sanitizer_common introduces conflicts with other runtimes, e.g. SCUDO. Reviewers: eugenis, kcc, cryptoad Subscribers: mgorny, krytarowski, fedor.sergeev, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D56886 llvm-svn: 351506
* [safestack] Replace statics with unnamed namespaceVitaly Buka2019-01-181-29/+33
| | | | | | | | | | Reviewers: eugenis Subscribers: jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D56888 llvm-svn: 351503
* [libFuzzer][MSVC] Make attribute-use compatible with MSVCJonathan Metzman2019-01-177-24/+46
| | | | | | | | | | | | | | Summary: Replace attributes with macros that use equivalent declspecs for MSVC. Reviewers: vitalybuka Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D56512 llvm-svn: 351456
* Make compiler-rt CMakeLists.txt formatting a bit more like LLVM's usual ↵Nico Weber2019-01-163-11/+21
| | | | | | formatting llvm-svn: 351363
OpenPOWER on IntegriCloud