summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/cfi
Commit message (Collapse)AuthorAgeFilesLines
* [cfi][test] cross-dso/stats.cpp: don't assume the order of static constructorsFangrui Song2020-01-081-4/+4
| | | | | | | | __sanitizer_stat_init is called for the executable first, then the shared object. In WriterModuleReport(), the information for the shared object will be recorded first. It'd be nice to get rid of the order requirement of static constructors. (This should make .ctors platforms work.)
* Add missing lld checks in sanitizer tests.Evgenii Stepanov2019-10-281-1/+1
| | | | | | Do not add an lld dependency when this target does not exist. In this case the system installation of lld is used (or whatever is detected with -fuse-ld=lld by default).
* CFI: wrong type passed to llvm.type.test with multiple inheritance ↵Dmitry Mikulin2019-10-151-0/+38
| | | | | | | | devirtualization. Differential Revision: https://reviews.llvm.org/D67985 llvm-svn: 374909
* [compiler-rt] Rename lit.*.cfg.* -> lit.*.cfg.py.*Reid Kleckner2019-06-276-5/+5
| | | | | | | | | | | | | These lit configuration files are really Python source code. Using the .py file extension helps editors and tools use the correct language mode. LLVM and Clang already use this convention for lit configuration, this change simply applies it to all of compiler-rt. Reviewers: vitalybuka, dberris Differential Revision: https://reviews.llvm.org/D63658 llvm-svn: 364591
* compiler-rt tests: Unbreak cmake with LLVM_ENABLE_PIC=OFF on macNico Weber2019-01-161-9/+11
| | | | | | | | The LTO target doesn't exist with LLVM_ENABLE_PIC turned off. Differential Revision: https://reviews.llvm.org/D56800 llvm-svn: 351373
* [Cfi] Compiling cfi library on FreeBSD and NetBSDDavid Carlier2018-10-011-1/+1
| | | | | | | | | | | | Making the library slighty more portable. Reviewers: vitalybuka, krytarowski Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D51682 llvm-svn: 343510
* [CMake] Use normalized Windows target triplesPetr Hosek2018-08-095-5/+5
| | | | | | | | | | | Changes the default Windows target triple returned by GetHostTriple.cmake from the old environment names (which we wanted to move away from) to newer, normalized ones. This also requires updating all tests to use the new systems names in constraints. Differential Revision: https://reviews.llvm.org/D47381 llvm-svn: 339307
* Change the cap on the amount of padding for each vtable to 32-byte ↵Peter Collingbourne2018-07-201-3/+3
| | | | | | | | | | | | | (previously it was 128-byte) We tested different cap values with a recent commit of Chromium. Our results show that the 32-byte cap yields the smallest binary and all the caps yield similar performance. Based on the results, we propose to change the cap value to 32-byte. Patch by Zhaomo Yang! Differential Revision: https://reviews.llvm.org/D49405 llvm-svn: 337622
* [compiler-rt] Add NewPM testing to CFI testsTeresa Johnson2018-07-192-8/+15
| | | | | | | | | | | | | | | | | | Summary: Executes both LTO and ThinLTO CFI tests an additional time using the new pass manager. I only bothered to add with gold and not lld as testing with one linker should be sufficient. I didn't add for APPLE or WIN32 since I don't have a way to test those. Depends on D49429. Reviewers: pcc Subscribers: dberris, mgorny, mehdi_amini, delcypher, dexonsmith, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D49432 llvm-svn: 337465
* [cfi] Use __builtin version of __clear_cache.Evgeniy Stepanov2018-06-291-1/+1
| | | | | | __builtin___clear_cache is also present on X86 and does the right thing (i.e. nop) there. llvm-svn: 335997
* [cfi] Reset i-cache after copying code in test.Evgeniy Stepanov2018-06-291-2/+4
| | | | | | | Fixes intermittent crashes on Android. Also add PROT_READ to the code mapping for no real reason. llvm-svn: 335943
* Correct the test modified in rL335777.Haojian Wu2018-06-281-1/+1
| | | | llvm-svn: 335865
* Another shot at fixing android r335644 failureVlad Tsyrklevich2018-06-271-10/+15
| | | | | | | | | The android buildbot moves the build outputs to a different directory and rewrites the executable path, the DSO passed as an argument does not get re-written. Use rpaths to load the DSO the same way the test/cfi/cross-dso/ tests do and test the DSO name differently. llvm-svn: 335777
* Fix another bot broken by r335644Vlad Tsyrklevich2018-06-271-1/+1
| | | | | | | The android sanitizer bot can't resolve the function name in the DSO and it's not relevant to the test. llvm-svn: 335693
* Fix test broken by r335644Vlad Tsyrklevich2018-06-261-2/+4
| | | | llvm-svn: 335657
* CFI: Print DSO names for failed cross-DSO icallsVlad Tsyrklevich2018-06-261-0/+42
| | | | | | | | | | | | Reviewers: pcc Reviewed By: pcc Subscribers: kubamracek, delcypher, llvm-commits, kcc, #sanitizers Differential Revision: https://reviews.llvm.org/D48583 llvm-svn: 335644
* Mark mfcall.cpp as UNSUPPORTED: win32.Peter Collingbourne2018-06-261-0/+2
| | | | llvm-svn: 335573
* Implement CFI for indirect calls via a member function pointer.Peter Collingbourne2018-06-261-0/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similarly to CFI on virtual and indirect calls, this implementation tries to use program type information to make the checks as precise as possible. The basic way that it works is as follows, where `C` is the name of the class being defined or the target of a call and the function type is assumed to be `void()`. For virtual calls: - Attach type metadata to the addresses of function pointers in vtables (not the functions themselves) of type `void (B::*)()` for each `B` that is a recursive dynamic base class of `C`, including `C` itself. This type metadata has an annotation that the type is for virtual calls (to distinguish it from the non-virtual case). - At the call site, check that the computed address of the function pointer in the vtable has type `void (C::*)()`. For non-virtual calls: - Attach type metadata to each non-virtual member function whose address can be taken with a member function pointer. The type of a function in class `C` of type `void()` is each of the types `void (B::*)()` where `B` is a most-base class of `C`. A most-base class of `C` is defined as a recursive base class of `C`, including `C` itself, that does not have any bases. - At the call site, check that the function pointer has one of the types `void (B::*)()` where `B` is a most-base class of `C`. Differential Revision: https://reviews.llvm.org/D47567 llvm-svn: 335569
* cfi: Disable simple-pass.cpp on Darwin.Peter Collingbourne2018-03-091-0/+3
| | | | | | -mretpoline does not work yet on Darwin. llvm-svn: 327168
* Use branch funnels for virtual calls when retpoline mitigation is enabled.Peter Collingbourne2018-03-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The retpoline mitigation for variant 2 of CVE-2017-5715 inhibits the branch predictor, and as a result it can lead to a measurable loss of performance. We can reduce the performance impact of retpolined virtual calls by replacing them with a special construct known as a branch funnel, which is an instruction sequence that implements virtual calls to a set of known targets using a binary tree of direct branches. This allows the processor to speculately execute valid implementations of the virtual function without allowing for speculative execution of of calls to arbitrary addresses. This patch extends the whole-program devirtualization pass to replace certain virtual calls with calls to branch funnels, which are represented using a new llvm.icall.jumptable intrinsic. It also extends the LowerTypeTests pass to recognize the new intrinsic, generate code for the branch funnels (x86_64 only for now) and lay out virtual tables as required for each branch funnel. The implementation supports full LTO as well as ThinLTO, and extends the ThinLTO summary format used for whole-program devirtualization to support branch funnels. For more details see RFC: http://lists.llvm.org/pipermail/llvm-dev/2018-January/120672.html Differential Revision: https://reviews.llvm.org/D42453 llvm-svn: 327163
* [ubsan] Re-commit: lit changes for lld testing, future lto testing.Roman Lebedev2017-12-012-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: As discussed in https://github.com/google/oss-fuzz/issues/933, it would be really awesome to be able to use ThinLTO for fuzzing. However, as @kcc has pointed out, it is currently undefined (untested) whether the sanitizers actually function properly with LLD and/or LTO. This patch is inspired by the cfi test, which already do test with LTO (and/or LLD), since LTO is required for CFI to function. I started with UBSan, because it's cmakelists / lit.* files appeared to be the cleanest. This patch adds the infrastructure to easily add LLD and/or LTO sub-variants of the existing lit test configurations. Also, this patch adds the LLD flavor, that explicitly does use LLD to link. The check-ubsan does pass on my machine. And to minimize the [initial] potential buildbot breakage i have put some restrictions on this flavour. Please review carefully, i have not worked with lit/sanitizer tests before. The original attempt, r319525 was reverted in r319526 due to the failures in compiler-rt standalone builds. Reviewers: eugenis, vitalybuka Reviewed By: eugenis Subscribers: #sanitizers, pcc, kubamracek, mgorny, llvm-commits, mehdi_amini, inglorion, kcc Differential Revision: https://reviews.llvm.org/D39508 llvm-svn: 319575
* Revert "[ubsan] lit changes for lld testing, future lto testing."Roman Lebedev2017-12-012-7/+3
| | | | | | | | | | | | | | | | | | | | This reverts commit r319525. This change has introduced a problem with the Lit tests build for compiler-rt using Gold: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/6047/steps/test%20standalone%20compiler-rt/logs/stdio llvm-lit: /b/sanitizer-x86_64-linux/build/llvm/utils/lit/lit/TestingConfig.py:101: fatal: unable to parse config file '/b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/profile/Linux/lit.local.cfg', traceback: Traceback (most recent call last): File "/b/sanitizer-x86_64-linux/build/llvm/utils/lit/lit/TestingConfig.py", line 88, in load_from_path exec(compile(data, path, 'exec'), cfg_globals, None) File "/b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/profile/Linux/lit.local.cfg", line 37, in <module> if root.host_os not in ['Linux'] or not is_gold_linker_available(): File "/b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/profile/Linux/lit.local.cfg", line 27, in is_gold_linker_available stderr = subprocess.PIPE) File "/usr/lib/python2.7/subprocess.py", line 390, in __init__ errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1024, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory llvm-svn: 319529
* [ubsan] lit changes for lld testing, future lto testing.Roman Lebedev2017-12-012-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: As discussed in https://github.com/google/oss-fuzz/issues/933, it would be really awesome to be able to use ThinLTO for fuzzing. However, as @kcc has pointed out, it is currently undefined (untested) whether the sanitizers actually function properly with LLD and/or LTO. This patch is inspired by the cfi test, which already do test with LTO (and/or LLD), since LTO is required for CFI to function. I started with UBSan, because it's cmakelists / lit.* files appeared to be the cleanest. This patch adds the infrastructure to easily add LLD and/or LTO sub-variants of the existing lit test configurations. Also, this patch adds the LLD flavor, that explicitly does use LLD to link. The check-ubsan does pass on my machine. And to minimize the [initial] potential buildbot breakage i have put some restrictions on this flavour. Please review carefully, i have not worked with lit/sanitizer tests before. Reviewers: eugenis, vitalybuka Reviewed By: eugenis Subscribers: #sanitizers, pcc, kubamracek, mgorny, llvm-commits, mehdi_amini, inglorion, kcc Differential Revision: https://reviews.llvm.org/D39508 llvm-svn: 319525
* Enable PDB generation with lld in asan and cfi tests on Windows.Peter Collingbourne2017-11-172-1/+2
| | | | | | | | | PDB emission now works well enough that we can rely on it for these tests to pass. Differential Revision: https://reviews.llvm.org/D40188 llvm-svn: 318546
* [cfi] Test cross-dso CFI on Android.Evgeniy Stepanov2017-10-165-1/+46
| | | | | | | | | | Reviewers: vitalybuka, pcc Subscribers: llvm-commits, srhines Differential Revision: https://reviews.llvm.org/D38911 llvm-svn: 315922
* [cfi] Use %ld_flags_rpath_* substitutions in tests (NFC)Evgeniy Stepanov2017-10-135-70/+70
| | | | llvm-svn: 315775
* LowerTypeTests: Give imported symbols a type with size 0 so that they are ↵Peter Collingbourne2017-10-131-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | not assumed not to alias. It is possible for both a base and a derived class to be satisfied with a unique vtable. If a program contains casts of the same pointer to both of those types, the CFI checks will be lowered to this (with ThinLTO): if (p != &__typeid_base_global_addr) trap(); if (p != &__typeid_derived_global_addr) trap(); The optimizer may then use the first condition combined with the assumption that __typeid_base_global_addr and __typeid_derived_global_addr may not alias to optimize away the second comparison, resulting in an unconditional trap. This patch fixes the bug by giving imported globals the type [0 x i8]*, which prevents the optimizer from assuming that they do not alias. Differential Revision: https://reviews.llvm.org/D38873 llvm-svn: 315753
* [sanitizer] Test ubsan and cfi on android.Evgeniy Stepanov2017-10-063-3/+6
| | | | | | | | | | | | | | | Summary: Enable check-cfi and check-ubsan on Android. Check-ubsan includes standalone and ubsan+asan, but not tsan or msan. Cross-dso cfi tests are disabled for now. Reviewers: vitalybuka, pcc Subscribers: srhines, kubamracek, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D38608 llvm-svn: 315105
* [cfi] Disable tests with lld on i386.Evgeniy Stepanov2017-10-051-1/+1
| | | | | | | | bin/ld.lld: error: ubsan_handlers.cc:(.debug_info+0x80D5D): has non-ABS reloc Bug pending. llvm-svn: 315027
* [sanitizer] Move %ld_flags_rpath_exe to common and use it in more tests.Evgeniy Stepanov2017-10-051-3/+3
| | | | | | | | | | Reviewers: vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D38527 llvm-svn: 315010
* [cfi] Mark a test as unsupported on darwin.Evgeniy Stepanov2017-10-051-1/+2
| | | | llvm-svn: 315007
* [cfi] Test on all available targets.Evgeniy Stepanov2017-10-053-12/+23
| | | | | | | | | | | | | | Summary: Run CFI tests on all targets current toolchain can target. On multiarch Linux, this will run all CFI tests with -m32 and -m64. Reviewers: pcc Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D38572 llvm-svn: 315001
* Use %run for running CFI testsFilipe Cabecinhas2017-10-0214-135/+135
| | | | | | | | | | Reviewers: pcc, krasin, eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D38412 llvm-svn: 314659
* ubsan: Unbreak ubsan_cxx runtime library on Windows.Peter Collingbourne2017-09-151-0/+1
| | | | | | | | | | | | | | | | This was originally broken by r258744 which introduced a weak reference from ubsan to ubsan_cxx. This reference does not work directly on Windows because COFF has no direct concept of weak symbols. The fix is to use /alternatename to create a weak external reference to ubsan_cxx. Also fix the definition (and the name, so that we drop cached values) of the cmake flag that controls whether to build ubsan_cxx. Now the user-controllable flag is always on, and we turn it off internally depending on whether we support building it. Differential Revision: https://reviews.llvm.org/D37882 llvm-svn: 313391
* cfi: Enable ThinLTO tests on Windows.Peter Collingbourne2017-09-151-1/+1
| | | | | | | | | | | We now avoid using absolute symbols on Windows (D37407 and D37408), so this should work. Fixes PR32770. Differential Revision: https://reviews.llvm.org/D37883 llvm-svn: 313379
* [cfi] only add cfi tests on supported arches.Sean Fertile2017-08-251-5/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D35101 llvm-svn: 311745
* fix trivial typo; NFCHiroshi Inoue2017-07-011-1/+1
| | | | llvm-svn: 306955
* [cfi] Enable icall tests with thinlto.Evgeniy Stepanov2017-06-164-7/+41
| | | | llvm-svn: 305534
* [cfi] Fix wrong CMake condition for WIN32.Evgeniy Stepanov2017-04-241-1/+1
| | | | llvm-svn: 301257
* [cfi] Disable ThinLTO + CFI tests on Windows.Evgeniy Stepanov2017-04-241-1/+2
| | | | | | PR32770. llvm-svn: 301235
* [cfi] Disable thinlto tests on Darwin.Ahmed Bougacha2017-04-221-1/+0
| | | | | | | | | | | | These were added in r301016, but they're failing, because -fsanitize=cfi seemingly causes -flto=thin to emit raw bitcode objects, rather than the mach-o-wrapped bitcode we emit with -flto=thin alone. That causes all tests to fail with ld64 errors. Filed PR32741. llvm-svn: 301065
* [cfi] Replace elif with elseif in cmake.Evgeniy Stepanov2017-04-211-1/+1
| | | | | | Apparently, elif() is deprecated. llvm-svn: 301022
* [cfi] Run tests with and without lld and thinlto.Evgeniy Stepanov2017-04-216-17/+62
| | | | | | | Run tests in all configurations: (standalone, with devirtualization) * (gold, lld) * (lto, thinlto) llvm-svn: 301016
* [cfi] Add explicit -flto in create-derivers test.Evgeniy Stepanov2017-04-201-4/+5
| | | | | | | This is necessary to run the test suite in ThinLTO mode - otherwise opt complains about an input file containing several modules. llvm-svn: 300901
* [cfi] Move one test under cross-dso/icall.Evgeniy Stepanov2017-04-201-1/+1
| | | | | | The test is using indirect calls. llvm-svn: 300900
* Fix sanitizer tests with LLVM_TOOL_LLD_BUILD=OFF.Evgeniy Stepanov2017-03-251-1/+1
| | | | | | | | Only depend on LLD if it is going to be built. Re-land of r298174 which got reverted in r298287. llvm-svn: 298753
* Use lld-link /nopdb to suppress PDB generation when DWARF is requiredReid Kleckner2017-03-221-2/+0
| | | | | | Fixes cfi/stats.cpp and asan/fuse-lld.cc on Windows. llvm-svn: 298545
* XFAIL CFI stats test while LLD produces corrupt PDBs that confuse DIAReid Kleckner2017-03-221-0/+2
| | | | llvm-svn: 298476
* Revert r298174, r298173, r298169, r298159.Evgeniy Stepanov2017-03-201-1/+1
| | | | | | | | | | | Revert "Fix sanitizer tests with LLVM_TOOL_LLD_BUILD=OFF." Revert "[asan] Remove gc-sections test with bfd." Revert "[asan] Disable globals-gc test with ld.bfd." Revert "[asan] Fix dead stripping of globals on Linux (compiler-rt)" OOM in gold linker. llvm-svn: 298287
* Fix sanitizer tests with LLVM_TOOL_LLD_BUILD=OFF.Evgeniy Stepanov2017-03-181-1/+1
| | | | | | Only depend on LLD if it is going to be built. llvm-svn: 298174
OpenPOWER on IntegriCloud