-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[Clang][Basic] Add __has_feature
checks for CFI sanitizers
#151348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
49149a0
75b0360
d741f65
b6a7ce7
7da5378
fded769
cc13c4b
64556aa
f0094c0
6e0c3c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// RUN: %clang -E -fvisibility=hidden -flto -fno-sanitize-ignorelist -fsanitize=cfi -c %s -o - | FileCheck %s --check-prefix=CHECK-CFI | ||
// RUN: %clang -E -fvisibility=hidden -flto -fno-sanitize-ignorelist -fsanitize=cfi -fsanitize-cfi-cross-dso -c %s -o - | FileCheck %s --check-prefix=CHECK-CFI | ||
// RUN: %clang -E -fvisibility=hidden -flto -fno-sanitize-ignorelist -fsanitize=cfi -fno-sanitize=cfi-nvcall,cfi-vcall,cfi-mfcall,cfi-icall -c %s -o - | FileCheck %s --check-prefix=CHECK-CFI | ||
// RUN: %clang -E -fsanitize=kcfi -c %s -o - | FileCheck %s --check-prefix=CHECK-CFI | ||
// CHECK-CFI: CFISanitizerEnabled | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep kcfi separated for now before we decide to combine them.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree to separate them, but I don't think we can change that later as soon as anyone uses that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. Tried to fix it in a new commit. |
||
|
||
// RUN: %clang -E -c %s -o - | FileCheck %s --check-prefix=CHECK-NO-CFI | ||
// CHECK-NO-CFI: CFISanitizerDisabled | ||
|
||
// RUN: %clang -E -fsanitize=cfi-cast-strict -c %s -o - | FileCheck %s --check-prefixes=CHECK-CFI,CHECK-CFI-CAST-STRICT | ||
// CHECK-CFI-CAST-STRICT: CFICastStrictSanitizerEnabled | ||
|
||
// RUN: %clang -E -fvisibility=hidden -flto -fno-sanitize-ignorelist -fsanitize=cfi-derived-cast -c %s -o - | FileCheck %s --check-prefixes=CHECK-CFI,CHECK-CFI-DERIVED-CAST | ||
// CHECK-CFI-DERIVED-CAST: CFIDerivedCastSanitizerEnabled | ||
|
||
// RUN: %clang -E -fvisibility=hidden -flto -fno-sanitize-ignorelist -fsanitize=cfi-icall -c %s -o - | FileCheck %s --check-prefixes=CHECK-CFI,CHECK-CFI-ICALL | ||
// CHECK-CFI-ICALL: CFIICallSanitizerEnabled | ||
|
||
// RUN: %clang -E -fvisibility=hidden -flto -fno-sanitize-ignorelist -fsanitize=cfi-mfcall -c %s -o - | FileCheck %s --check-prefixes=CHECK-CFI,CHECK-CFI-MFCALL | ||
// CHECK-CFI-MFCALL: CFIMFCallSanitizerEnabled | ||
|
||
// RUN: %clang -E -fvisibility=hidden -flto -fno-sanitize-ignorelist -fsanitize=cfi-unrelated-cast -c %s -o - | FileCheck %s --check-prefixes=CHECK-CFI,CHECK-CFI-UNRELATED-CAST | ||
// CHECK-CFI-UNRELATED-CAST: CFIUnrelatedCastSanitizerEnabled | ||
|
||
// RUN: %clang -E -fvisibility=hidden -flto -fno-sanitize-ignorelist -fsanitize=cfi-nvcall -c %s -o - | FileCheck %s --check-prefixes=CHECK-CFI,CHECK-CFI-NVCALL | ||
// CHECK-CFI-NVCALL: CFINVCallSanitizerEnabled | ||
|
||
// RUN: %clang -E -fvisibility=hidden -flto -fno-sanitize-ignorelist -fsanitize=cfi-vcall -c %s -o - | FileCheck %s --check-prefixes=CHECK-CFI,CHECK-CFI-VCALL | ||
// CHECK-CFI-VCALL: CFIVCallSanitizerEnabled | ||
|
||
#if __has_feature(cfi_sanitizer) | ||
int CFISanitizerEnabled(); | ||
#else | ||
int CFISanitizerDisabled(); | ||
#endif | ||
|
||
#if __has_feature(cfi_cast_strict_sanitizer) | ||
int CFICastStrictSanitizerEnabled(); | ||
#else | ||
int CFICastStrictSanitizerDisabled(); | ||
#endif | ||
|
||
#if __has_feature(cfi_derived_cast_sanitizer) | ||
int CFIDerivedCastSanitizerEnabled(); | ||
#else | ||
int CFIDerivedCastSanitizerDisabled(); | ||
#endif | ||
|
||
#if __has_feature(cfi_icall_sanitizer) | ||
int CFIICallSanitizerEnabled(); | ||
#else | ||
int CFIICallSanitizerDisabled(); | ||
#endif | ||
|
||
#if __has_feature(cfi_mfcall_sanitizer) | ||
int CFIMFCallSanitizerEnabled(); | ||
#else | ||
int CFIMFCallSanitizerDisabled(); | ||
#endif | ||
|
||
#if __has_feature(cfi_unrelated_cast_sanitizer) | ||
int CFIUnrelatedCastSanitizerEnabled(); | ||
#else | ||
int CFIUnrelatedCastSanitizerDisabled(); | ||
#endif | ||
|
||
#if __has_feature(cfi_nvcall_sanitizer) | ||
int CFINVCallSanitizerEnabled(); | ||
#else | ||
int CFINVCallSanitizerDisabled(); | ||
#endif | ||
|
||
#if __has_feature(cfi_vcall_sanitizer) | ||
int CFIVCallSanitizerEnabled(); | ||
#else | ||
int CFIVCallSanitizerDisabled(); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FEATURE(cfi_sanitizer, LangOpts.Sanitize.hasOneOf(SanitizerKind::CFI))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a new commit. Thanks!