CFI: Switch sense of type erasure flag
Previously, we had `NO_SELF_TYPE_ERASURE`, a negative configuration. Now we have `ERASE_SELF_TYPE`, a positive configuration.
This commit is contained in:
parent
36b6f9b58e
commit
93c2bace58
4 changed files with 10 additions and 8 deletions
|
@ -147,7 +147,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
||||||
for options in [
|
for options in [
|
||||||
TypeIdOptions::GENERALIZE_POINTERS,
|
TypeIdOptions::GENERALIZE_POINTERS,
|
||||||
TypeIdOptions::NORMALIZE_INTEGERS,
|
TypeIdOptions::NORMALIZE_INTEGERS,
|
||||||
TypeIdOptions::NO_SELF_TYPE_ERASURE,
|
TypeIdOptions::ERASE_SELF_TYPE,
|
||||||
]
|
]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.powerset()
|
.powerset()
|
||||||
|
@ -173,7 +173,9 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
||||||
|
|
||||||
if self.tcx.sess.is_sanitizer_kcfi_enabled() {
|
if self.tcx.sess.is_sanitizer_kcfi_enabled() {
|
||||||
// LLVM KCFI does not support multiple !kcfi_type attachments
|
// LLVM KCFI does not support multiple !kcfi_type attachments
|
||||||
let mut options = TypeIdOptions::empty();
|
// Default to erasing the self type. If we need the concrete type, there will be a
|
||||||
|
// hint in the instance.
|
||||||
|
let mut options = TypeIdOptions::ERASE_SELF_TYPE;
|
||||||
if self.tcx.sess.is_sanitizer_cfi_generalize_pointers_enabled() {
|
if self.tcx.sess.is_sanitizer_cfi_generalize_pointers_enabled() {
|
||||||
options.insert(TypeIdOptions::GENERALIZE_POINTERS);
|
options.insert(TypeIdOptions::GENERALIZE_POINTERS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,9 @@ bitflags! {
|
||||||
/// `-fsanitize-cfi-icall-experimental-normalize-integers` option for cross-language LLVM
|
/// `-fsanitize-cfi-icall-experimental-normalize-integers` option for cross-language LLVM
|
||||||
/// CFI and KCFI support.
|
/// CFI and KCFI support.
|
||||||
const NORMALIZE_INTEGERS = 4;
|
const NORMALIZE_INTEGERS = 4;
|
||||||
/// Do not perform self type erasure for attaching a secondary type id to methods with their
|
/// Generalize the instance by erasing the concrete `Self` type where possible.
|
||||||
/// concrete self so they can be used as function pointers.
|
/// Only has an effect on `{kcfi_,}typeid_for_instance`.
|
||||||
const NO_SELF_TYPE_ERASURE = 8;
|
const ERASE_SELF_TYPE = 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1172,7 +1172,7 @@ pub fn typeid_for_instance<'tcx>(
|
||||||
instance.args = tcx.mk_args_trait(invoke_ty, trait_ref.args.into_iter().skip(1));
|
instance.args = tcx.mk_args_trait(invoke_ty, trait_ref.args.into_iter().skip(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if !options.contains(EncodeTyOptions::NO_SELF_TYPE_ERASURE) {
|
if options.contains(EncodeTyOptions::ERASE_SELF_TYPE) {
|
||||||
if let Some(impl_id) = tcx.impl_of_method(instance.def_id())
|
if let Some(impl_id) = tcx.impl_of_method(instance.def_id())
|
||||||
&& let Some(trait_ref) = tcx.impl_trait_ref(impl_id)
|
&& let Some(trait_ref) = tcx.impl_trait_ref(impl_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,5 +18,5 @@ impl Trait1 for Type1 {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}6Trait1u6regionEEE"}
|
// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}5Type1EE"}
|
||||||
// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}5Type1EE"}
|
// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}6Trait1u6regionEEE"}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue