diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-09-10 02:17:40 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-09-10 02:17:40 +0000 |
commit | 2c7f7e31c4c0afc84f8614a48ef7e1449b458c58 (patch) | |
tree | c086262a5904b3d67a23e8baa1d5ae186989ad56 /clang/test/CodeGenCXX/cfi-icall.cpp | |
parent | d3b904d440fee3c869d8c8a2c33dffd8bc82b384 (diff) | |
download | bcm5719-llvm-2c7f7e31c4c0afc84f8614a48ef7e1449b458c58.tar.gz bcm5719-llvm-2c7f7e31c4c0afc84f8614a48ef7e1449b458c58.zip |
CFI: Introduce -fsanitize=cfi-icall flag.
This flag causes the compiler to emit bit set entries for functions as well
as runtime bitset checks at indirect call sites. Depends on the new function
bitset mechanism.
Differential Revision: http://reviews.llvm.org/D11857
llvm-svn: 247238
Diffstat (limited to 'clang/test/CodeGenCXX/cfi-icall.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/cfi-icall.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/cfi-icall.cpp b/clang/test/CodeGenCXX/cfi-icall.cpp new file mode 100644 index 00000000000..eceb92a4421 --- /dev/null +++ b/clang/test/CodeGenCXX/cfi-icall.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-icall -fsanitize-trap=cfi-icall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM %s +// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsanitize=cfi-icall -fsanitize-trap=cfi-icall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s + +// Tests that we assign unnamed metadata nodes to functions whose types have +// internal linkage. + +namespace { + +struct S {}; + +void f(S *s) { +} + +} + +void g() { + void (*fp)(S *) = f; + // CHECK: call i1 @llvm.bitset.test(i8* {{.*}}, metadata ![[VOIDS:[0-9]+]]) + fp(0); +} + +// ITANIUM: !{![[VOIDS]], void (%"struct.(anonymous namespace)::S"*)* @_ZN12_GLOBAL__N_11fEPNS_1SE, i64 0} +// MS: !{![[VOIDS]], void (%"struct.(anonymous namespace)::S"*)* @"\01?f@?A@@YAXPEAUS@?A@@@Z", i64 0} |