summaryrefslogtreecommitdiff
path: root/test/cfi
AgeCommit message (Collapse)Author
2018-07-20Change the cap on the amount of padding for each vtable to 32-byte ↵Peter Collingbourne
(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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337622 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-19[compiler-rt] Add NewPM testing to CFI testsTeresa Johnson
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337465 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-29[cfi] Use __builtin version of __clear_cache.Evgeniy Stepanov
__builtin___clear_cache is also present on X86 and does the right thing (i.e. nop) there. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335997 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-29[cfi] Reset i-cache after copying code in test.Evgeniy Stepanov
Fixes intermittent crashes on Android. Also add PROT_READ to the code mapping for no real reason. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335943 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28Correct the test modified in rL335777.Haojian Wu
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335865 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27Another shot at fixing android r335644 failureVlad Tsyrklevich
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335777 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27Fix another bot broken by r335644Vlad Tsyrklevich
The android sanitizer bot can't resolve the function name in the DSO and it's not relevant to the test. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335693 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26Fix test broken by r335644Vlad Tsyrklevich
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335657 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26CFI: Print DSO names for failed cross-DSO icallsVlad Tsyrklevich
Reviewers: pcc Reviewed By: pcc Subscribers: kubamracek, delcypher, llvm-commits, kcc, #sanitizers Differential Revision: https://reviews.llvm.org/D48583 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335644 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26Mark mfcall.cpp as UNSUPPORTED: win32.Peter Collingbourne
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335573 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26Implement CFI for indirect calls via a member function pointer.Peter Collingbourne
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335569 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-09cfi: Disable simple-pass.cpp on Darwin.Peter Collingbourne
-mretpoline does not work yet on Darwin. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@327168 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-09Use branch funnels for virtual calls when retpoline mitigation is enabled.Peter Collingbourne
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@327163 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-01[ubsan] Re-commit: lit changes for lld testing, future lto testing.Roman Lebedev
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319575 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-01Revert "[ubsan] lit changes for lld testing, future lto testing."Roman Lebedev
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319529 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-01[ubsan] lit changes for lld testing, future lto testing.Roman Lebedev
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319525 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-17Enable PDB generation with lld in asan and cfi tests on Windows.Peter Collingbourne
PDB emission now works well enough that we can rely on it for these tests to pass. Differential Revision: https://reviews.llvm.org/D40188 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318546 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-16[cfi] Test cross-dso CFI on Android.Evgeniy Stepanov
Reviewers: vitalybuka, pcc Subscribers: llvm-commits, srhines Differential Revision: https://reviews.llvm.org/D38911 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315922 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-13[cfi] Use %ld_flags_rpath_* substitutions in tests (NFC)Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315775 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-13LowerTypeTests: Give imported symbols a type with size 0 so that they are ↵Peter Collingbourne
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315753 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-06[sanitizer] Test ubsan and cfi on android.Evgeniy Stepanov
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315105 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-05[cfi] Disable tests with lld on i386.Evgeniy Stepanov
bin/ld.lld: error: ubsan_handlers.cc:(.debug_info+0x80D5D): has non-ABS reloc Bug pending. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315027 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-05[sanitizer] Move %ld_flags_rpath_exe to common and use it in more tests.Evgeniy Stepanov
Reviewers: vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D38527 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315010 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-05[cfi] Mark a test as unsupported on darwin.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315007 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-05[cfi] Test on all available targets.Evgeniy Stepanov
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315001 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-02Use %run for running CFI testsFilipe Cabecinhas
Reviewers: pcc, krasin, eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D38412 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314659 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-15ubsan: Unbreak ubsan_cxx runtime library on Windows.Peter Collingbourne
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313391 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-15cfi: Enable ThinLTO tests on Windows.Peter Collingbourne
We now avoid using absolute symbols on Windows (D37407 and D37408), so this should work. Fixes PR32770. Differential Revision: https://reviews.llvm.org/D37883 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313379 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-25[cfi] only add cfi tests on supported arches.Sean Fertile
Differential Revision: https://reviews.llvm.org/D35101 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@311745 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-01fix trivial typo; NFCHiroshi Inoue
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306955 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-16[cfi] Enable icall tests with thinlto.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@305534 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-24[cfi] Fix wrong CMake condition for WIN32.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301257 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-24[cfi] Disable ThinLTO + CFI tests on Windows.Evgeniy Stepanov
PR32770. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301235 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-22[cfi] Disable thinlto tests on Darwin.Ahmed Bougacha
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301065 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-21[cfi] Replace elif with elseif in cmake.Evgeniy Stepanov
Apparently, elif() is deprecated. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301022 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-21[cfi] Run tests with and without lld and thinlto.Evgeniy Stepanov
Run tests in all configurations: (standalone, with devirtualization) * (gold, lld) * (lto, thinlto) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301016 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-20[cfi] Add explicit -flto in create-derivers test.Evgeniy Stepanov
This is necessary to run the test suite in ThinLTO mode - otherwise opt complains about an input file containing several modules. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300901 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-20[cfi] Move one test under cross-dso/icall.Evgeniy Stepanov
The test is using indirect calls. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300900 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-25Fix sanitizer tests with LLVM_TOOL_LLD_BUILD=OFF.Evgeniy Stepanov
Only depend on LLD if it is going to be built. Re-land of r298174 which got reverted in r298287. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298753 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-22Use lld-link /nopdb to suppress PDB generation when DWARF is requiredReid Kleckner
Fixes cfi/stats.cpp and asan/fuse-lld.cc on Windows. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298545 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-22XFAIL CFI stats test while LLD produces corrupt PDBs that confuse DIAReid Kleckner
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298476 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-20Revert r298174, r298173, r298169, r298159.Evgeniy Stepanov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298287 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-18Fix sanitizer tests with LLVM_TOOL_LLD_BUILD=OFF.Evgeniy Stepanov
Only depend on LLD if it is going to be built. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298174 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-14[cfi] Disable bad-split test on win32.Evgeniy Stepanov
It appears that the fix only helped Itanium ABI. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@297775 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-14[cfi] Add test for type metadata split issue.Evgeniy Stepanov
https://reviews.llvm.org/D30716 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@297771 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-14[cfi] Mark tests as xfailing on DarwinVedant Kumar
This allows them to be run on other platforms, undoing damage from r286902. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@286904 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-14[cfi] Mark some tests as requiring additional support from the MachO writerVedant Kumar
These tests need to be marked as unsupported on Darwin: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/1545 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@286902 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11[cfi] Test case for weak symbol handling.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@286637 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11[cfi] Tweak a test for the cfi-icall change.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@286612 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-22cfi: Fixes for check-cfi when configured as an external project.Peter Collingbourne
Differential Revision: https://reviews.llvm.org/D24817 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282189 91177308-0d34-0410-b5e6-96231b3b80d8