aboutsummaryrefslogtreecommitdiff
path: root/compiler-rt
AgeCommit message (Collapse)AuthorFilesLines
2024-06-21[hwasan][aarch64] Fix missing DT_AARCH64_BTI_PLT flag (#95796)Tulio Magno Quites Machado Filho1-5/+17
When building hwasan on aarch64, the DT_AARCH64_BTI_PLT flag is missing from libclang_rt.hwasan.so because some object files without DT_AARCH64_BTI_PLT are linked in the final DSO. These files are specific to riscv64 and x86_64, ending up with no aarch64 code in them. Avoid building and linking architecture-specific files unless the architecture is listed in HWASAN_SUPPORTED_ARCH.
2024-06-21[scudo] Add TEST_SKIP macro to skip the current test (#96192)Fabio D'Urso4-5/+10
2024-06-21Enable building 16 bit floating point builtins in apple platforms if ↵Gabriel Baraldi1-6/+13
supported by the compiler (#84192) Currently we will not build float16/bfloat16 builtins on apple platforms, LLVM will include calls to those builtins and fail to link. I copied the test code we perform for non apple platforms because oddly we branch on it being apple for building builtins
2024-06-21Revert "[ubsan] Display correct runtime messages for negative _BitInt" (#96239)earnol4-251/+8
Reverts llvm/llvm-project#93612 due to the issues with ppc64le platform.
2024-06-20[compiler-rt] Fix build breakage (#96235)Alexander Shaposhnikov1-1/+8
Add missing flags in cmake. Follow-up to cae6d458a.
2024-06-21mmapForContinuousMode: Redo #95702: Align Linux's impl to __APPLE__'s a little.NAKAMURA Takumi1-4/+6
I've made this small cosmetic changes, `s/CountersOffsetInBiasMode/FileOffsetToCounters/`
2024-06-21Revert "mmapForContinuousMode: Align Linux's impl to __APPLE__'s more. NFC. ↵NAKAMURA Takumi1-26/+4
(#95702)" This reverts commit 7cf84d3b0bc5eda3a907dfd026d51a17e28114a3. (llvmorg-19-init-14939-g7cf84d3b0bc5) This has my wrong assumptions possibly. This was failing fuchsia.
2024-06-20[NFC] fix incorrect #endif comment (#95991)Florian Mayer1-1/+1
2024-06-20[ubsan] Display correct runtime messages for negative _BitInt (#93612)earnol4-8/+251
Without this patch compiler-rt ubsan library has a bug displaying incorrect values for variables of the _BitInt (previously called _ExtInt) type. This patch affects affects both: generation of metadata inside code generator and runtime part. The runtime part provided only for i386 and x86_64 runtimes. Other runtimes should be updated to take full benefit of this patch. The patch is constructed the way to be backward compatible and int and float type runtime diagnostics should be unaffected for not yet updated runtimes. This patch fixes issue: https://github.com/llvm/llvm-project/issues/64100. Co-authored-by: Vladislav Aranov <vladislav.aranov@ericsson.com> Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
2024-06-20mmapForContinuousMode: Align Linux's impl to __APPLE__'s more. NFC. (#95702)NAKAMURA Takumi1-4/+26
2024-06-20[nsan] Fix style issueFangrui Song12-869/+841
The initial check-in of compiler-rt/lib/nsan #94322 has a lot of style issues. Fix them before the history becomes more useful. Pull Request: https://github.com/llvm/llvm-project/pull/96142
2024-06-19[CompilerRT] Add support for numerical sanitizer (#94322)Alexander Shaposhnikov23-1/+2390
This diff contains the compiler-rt changes / preparations for nsan. Test plan: 1. cd build/runtimes/runtimes-bins && ninja check-nsan 2. ninja check-all
2024-06-19Reland "[scudo] Apply filling when realloc shrinks and re-grows a block ↵Fabio D'Urso2-5/+31
in-place" (#95838) Reland of #93212, which had been reverted in commit bddd8eae17df6511aee789744ccdc158de817081.
2024-06-18fixup! [compiler-rt][AArch64][FMV] Use the hw.optional.arm.caps fast path ↵Jon Roelofs1-0/+15
(#95275) https://github.com/llvm/llvm-project/pull/95275#issuecomment-2177366693
2024-06-18[scudo] Test secondary cache options only if enabled (#95872)Caslyn Tonelli1-5/+6
Configs that use `MapAllocatorNoCache` for its secondary cache will return `false` if `setOption` is called with some [specific options](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/scudo/standalone/secondary.h#L104), and this breaks with the `SecondaryOptions` test. This change will gate testing all `setOption` expectations for cache options only if the allocator cache is enabled. This will unblock [github.com/llvm/llvm-project/pull/95595 ](https://github.com/llvm/llvm-project/pull/95595) from merging into Fuchsia.
2024-06-17Reapply "[HWASan] [compiler-rt] support non-4k pages on Android" (#95853)Florian Mayer11-30/+37
Updated MapDynamicShadow callsite in asan_win.
2024-06-17Revert "[HWASan] [compiler-rt] support non-4k pages on Android" (#95853)Florian Mayer10-35/+29
Reverts llvm/llvm-project#95069 Broke windows bot
2024-06-17[scudo] Update error handling for seondary cache entry count (#95595)Joshua Baehring2-6/+7
Initially, the scudo allocator would return an error if the user attempted to set the cache capacity (i.e. the number of possible entries in the cache) above the maximum cache capacity. Now the allocator will resort to using the maximum cache capacity in this event. An error will still be returned if the user attempts to set the number of entries to a negative value.
2024-06-17[HWASan] [compiler-rt] support non-4k pages on Android (#95069)Florian Mayer10-29/+35
2024-06-16mmapForContinuousMode: Calculate FileOffsetToBitmap from ↵NAKAMURA Takumi1-2/+1
FileOffsetToCounters. NFC.
2024-06-16ReformatNAKAMURA Takumi1-3/+4
2024-06-14[compiler-rt] Remove 'memprof_meminfoblock.h' from MEMPROF_HEADERS (NFC) ↵Youngsuk Kim1-1/+0
(#95334) Commit 8306968b592d942cc49bde2e387061e673a9fbb7 deleted file `compiler-rt/lib/memprof/memprof_meminfoblock.h`, but didn't remove it from MEMPROF_HEADERS in `compiler-rt/lib/memprof/CMakeLists.txt`. Remove unneeded leftover line in `compiler-rt/lib/memprof/CMakeLists.txt`. p.s. GH #54777 reported a llvm14 build failure due to the existence of the leftover line, but I'm unable to reproduce the build failure with llvm19 trunk.
2024-06-14Reapply: [MC/DC][Coverage] Loosen the limit of NumConds from 6 (#82448)NAKAMURA Takumi1-1/+1
By storing possible test vectors instead of combinations of conditions, the restriction is dramatically relaxed. This introduces two options to `cc1`: * `-fmcdc-max-conditions=32767` * `-fmcdc-max-test-vectors=2147483646` This change makes coverage mapping, profraw, and profdata incompatible with Clang-18. - Bitmap semantics changed. It is incompatible with previous format. - `BitmapIdx` in `Decision` points to the end of the bitmap. - Bitmap is packed per function. - `llvm-cov` can understand `profdata` generated by `llvm-profdata-18`. RFC: https://discourse.llvm.org/t/rfc-coverage-new-algorithm-and-file-format-for-mc-dc/76798 -- Change(s) since llvmorg-19-init-14288-g7ead2d8c7e91 - Update compiler-rt/test/profile/ContinuousSyncMode/image-with-mcdc.c
2024-06-13[compiler-rt][AArch64][FMV] Use the hw.optional.arm.caps fast path (#95275)Jon Roelofs1-2/+75
MacOS 15.0 and iOS 18.0 added a new sysctl to fetch a bitvector of all the hw.optional.arm.FEAT_*'s in one go. Using this has a perf advantage over doing multiple round-trips to the kernel and back, but since it's not present in older oses, we still need the slow fallback.
2024-06-13[HWASan] comment why hwasan_symbolize_stack_uas is arm64 onlyFlorian Mayer1-1/+2
2024-06-13Reland '[hwasan] Add fixed_shadow_base flag (#73980)' (#95445)Thurston Dang3-2/+90
This was reverted in https://github.com/llvm/llvm-project/pull/95435 because it broke Android static hwasan binaries. This reland limits the change to !SANITIZER_ANDROID. Original commit message: When set to non-zero, the HWASan runtime will map the shadow base at the specified constant address. This is particularly useful in conjunction with the existing compiler option 'hwasan-mapping-offset', which bakes a hardcoded constant address into the instrumentation. --------- Co-authored-by: Vitaly Buka <vitalybuka@gmail.com>
2024-06-13[HWASan] disable hwasan_symbolize_stack_uas on x86Florian Mayer1-1/+2
2024-06-13[llvm-project] Fix typo "seperate" (#95373)Jay Foad2-2/+2
2024-06-13[DFSan] Fix sscanf checking that ordinary characters match. (#95333)Andrew Browne2-240/+393
Fixes: #94769
2024-06-13Revert "[hwasan] Add fixed_shadow_base flag" (#95435)Florian Mayer3-89/+2
Reverts llvm/llvm-project#73980 This broke static hwasan binaries in Android, for some reason the fixed_shadow_base branch gets taken
2024-06-13[compiler-rt][builtins] Add opt-in pthread_mutex_t locks to libatomic (#95326)Logikable2-2/+20
When an uninstrumented libatomic is used with a TSan instrumented memcpy, TSan may report a data race in circumstances where writes are arguably safe. This occurs because __atomic_compare_exchange won't be instrumented in an uninstrumented libatomic, so TSan doesn't know that the subsequent memcpy is race-free. On the other hand, pthread_mutex_(un)lock will be intercepted by TSan, meaning an uninstrumented libatomic will not report this false-positive. pthread_mutexes also may try a number of different strategies to acquire the lock, which may bound the amount of time a thread has to wait for a lock during contention. While pthread_mutex_lock has a larger overhead (due to the function call and some dispatching), a dispatch to libatomic already predicates a lack of performance guarantees.
2024-06-13[HWASan] add test for hwasan_symbolize of stack uas (#95186)Florian Mayer1-0/+22
2024-06-13Revert "[asan] Make frame number checks more flexable (#94307)"Hans Wennborg11-34/+34
It broke tests on Mac, see comment on the PR. > Use more flexable regex ([0-9]+) for frame number checks. Since the > frame numbers might change if some functions are not inlined. > > Similar to > * > https://github.com/llvm/llvm-project/commit/0360f3218a13666123849f6699216bdbebe64833 > * > https://github.com/llvm/llvm-project/commit/404bc5ca2ae5fffa45d5240dcf52b7f134988867 This reverts commit 98174fb6ec9784d9eb7be313ee1317ca6e703d90 and the follow-up commit 86d8aec97fd9e009e9b360ffeee744d3acce730d.
2024-06-13[FMV][compiler-rt] Fix cpu features initialization. (#95149)Alexandros Lamprineas7-105/+68
To detect features we either use HWCAPs or directly extract system register bitfields and compare with a value. In many cases equality comparisons give wrong results for example FEAT_SVE is not set if SVE2 is available (see the issue #93651). I am also making the access to __aarch64_cpu_features atomic. The corresponding PR for the ACLE specification is https://github.com/ARM-software/acle/pull/322.
2024-06-13[GWP-ASan] Various test fixes. (#94938)Mitch Phillips5-23/+5
When running some tests with --gtest_repeat=100 --gtest_shuffle, I encountered some problems because the allocator wasn't torn down completely, and the singleton pointer ended up pointing to a use-after-scope'd object. This patch has a couple of fixes and niceties: 1. Removing the once-init stuff from tests, now that it's implicitly done in GuardedPoolAllocator::installAtFork() anyway. 2. Calling uninitTestOnly() in the late_init test. 3. Resetting the HasReportedBadPoolAccess when the signal handlers are installed (allowing for --gtest_repeat w/ recoverable mode). 4. Adding a check and resetting the singleton pointer in uninitTestOnly().
2024-06-12[asan] Attempt to fix tests broken by #94307. (#95340)dyung3-3/+3
2024-06-12[asan] Make frame number checks more flexable (#94307)Hau Hsu11-34/+34
Use more flexable regex ([0-9]+) for frame number checks. Since the frame numbers might change if some functions are not inlined. Similar to * https://github.com/llvm/llvm-project/commit/0360f3218a13666123849f6699216bdbebe64833 * https://github.com/llvm/llvm-project/commit/404bc5ca2ae5fffa45d5240dcf52b7f134988867
2024-06-12[AArch64][compiler-rt] Disable SME ABI routines if function multiversioning ↵Kerry McLaughlin1-6/+17
is not supported (#94973) This prevents build failures when building with `DISABLE_AARCH64_FMV`, see https://github.com/llvm/llvm-project/pull/92921.
2024-06-11[ORC][MachO] Register objc protolist, protorefs, nlclslist metadata sections ↵Ben Langmuir6-0/+608
(#95144) Add missing __DATA sections that the objc runtime expects to register. This fixes running objc code that makes use of `@protocol` references and `__attribute__((objc_nonlazy_class))` classes. rdar://129368761
2024-06-11[scudo] Fix the calculation of PushedBytesDelta (#95177)ChiaHungDuan1-1/+1
BytesInBG is always greater or equal to BG->BytesInBGAtLastCheckpoint. Note that the bug led to unnecessary attempts of page releasing and doesn't have critical impact on the correctness.
2024-06-10Revert "[scudo] Apply filling when realloc shrinks and re-grows a block ↵Fabio D'Urso2-32/+5
in-place (#93212)" This reverts commit 760d880ea602117aa2e6bba4cf31069f09225b4b. It broke https://lab.llvm.org/buildbot/#/builders/169/builds/32309
2024-06-10[scudo] Apply filling when realloc shrinks and re-grows a block in-place ↵Fabio D'Urso2-5/+32
(#93212)
2024-06-08[compiler-rt] Replace deprecated aligned_storage with aligned byte array ↵Marc Auberer11-71/+50
(#94171) `std::aligned_storage` is deprecated with C++23, see [here](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1413r3.pdf). This replaces the usages of `std::aligned_storage` within compiler-rt with an aligned `std::byte` array. I will provide patches for other subcomponents as well.
2024-06-07[dfsan] Fix release_shadow_space.c (#94770)Thurston Dang1-4/+10
DFSan's sscanf is incorrect (https://github.com/llvm/llvm-project/issues/94769), which results in erroneous matches when scraping RSS from /proc/maps. This patch works around the issue by using strstr as a secondary check. It also adds a loose validity check for the initial RSS measurement, to guard against regressions in get_rss_kb(). Fixes https://github.com/llvm/llvm-project/issues/91287
2024-06-07Check if LLD is built when checking if lto_supported (#92752)Jan Voung1-1/+8
Otherwise, older copies of LLD may not understand the latest bitcode versions (for example, if we increase `ModuleSummaryIndex::BitCodeSummaryVersion`) Related to https://github.com/llvm/llvm-project/pull/90692#issuecomment-2113250317
2024-06-06[dfsan] Add test case for sscanf (#94700)Thurston Dang1-0/+19
This test case shows a limitation of DFSan's sscanf implementation (introduced in https://reviews.llvm.org/D153775): it simply ignores ordinary characters in the format string, instead of actually comparing them against the input. This may change the semantics of instrumented programs. Importantly, this also means that DFSan's release_shadow_space.c test, which relies on sscanf to scrape the RSS from /proc/maps output, will incorrectly match lines that don't contain RSS information. As a result, it adding together numbers from irrelevant output (e.g., base addresses), resulting in test flakiness (https://github.com/llvm/llvm-project/issues/91287).
2024-06-07[compiler-rt] Map internal_sigaction to __sys_sigaction on FreeBSD (#84441)Alexander Richardson1-2/+14
This function is called during very early startup and which can result in a crash on FreeBSD. The sigaction() function in libc is indirected via a table so that it can be interposed by the threading library rather than calling the syscall directly. In the crash I was observing this table had not yet been relocated, so we ended up jumping to an invalid address. To avoid this problem we can call __sys_sigaction, which calls the syscall directly and in FreeBSD 15 is part of libsys rather than libc, so does not depend on libc being fully initialized.
2024-06-06[sanitizer_common] Change allocator base in test case for compatibili… ↵Thurston Dang1-2/+7
(#93234) …ty with high-entropy ASLR With high-entropy ASLR (e.g., 32-bits == 16TB), the allocator base of 0x700000000000 (112TB) may collide with the placement of the libraries (e.g., on Linux, the mmap base could be 128TB - 16TB == 112TB). This results in a segfault in the test case. This patch moves the allocator base below the PIE program segment, inspired by fb77ca05ffb4f8e666878f2f6718a9fb4d686839. As per that patch: 1) we are leaving the old behavior for Apple 2) since ASLR cannot be set above 32-bits for x86-64 Linux, we expect this new layout to be durable. Note that this is only changing a test case, not the behavior of sanitizers. Sanitizers have their own settings for initializing the allocator base. Reproducer: 1. ninja check-sanitizer # Just to build the test binary needed below; no need to actually run the tests here 2. sudo sysctl vm.mmap_rnd_bits=32 # Increase ASLR entropy 3. for f in `seq 1 10000`; do echo $f; GTEST_FILTER=*SizeClassAllocator64Dense ./projects/compiler-rt/lib/sanitizer_common/tests/Sanitizer-x86_64-Test > /tmp/x; if [ $? -ne 0 ]; then cat /tmp/x; fi; done
2024-06-06[sanitizer] Make CHECKs in bitvector more precise (NFC) (#94630)Nikita Popov1-4/+4
These CHECKs are all checking indices, which must be strictly smaller than the size (otherwise they would go out of bounds).
2024-06-05Revert "[compiler-rt][builtins] Switch libatomic locks to pthread_mutex_t ↵Martin Storsjö1-18/+13
(#94374)" This reverts commit b62b7a42bbee4a3bbf9094808f460fdc9c119bd7 and a5729b71d844c1444f7d348dc2d4ea5b98de5ec5. This commit broke compilation for systems that lack pthreads.