mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 14:01:51 +00:00
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
@ -147,7 +147,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
||||
for options in [
|
||||
TypeIdOptions::GENERALIZE_POINTERS,
|
||||
TypeIdOptions::NORMALIZE_INTEGERS,
|
||||
TypeIdOptions::NO_SELF_TYPE_ERASURE,
|
||||
TypeIdOptions::ERASE_SELF_TYPE,
|
||||
]
|
||||
.into_iter()
|
||||
.powerset()
|
||||
@ -173,7 +173,9 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
||||
|
||||
if self.tcx.sess.is_sanitizer_kcfi_enabled() {
|
||||
// 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() {
|
||||
options.insert(TypeIdOptions::GENERALIZE_POINTERS);
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ bitflags! {
|
||||
/// `-fsanitize-cfi-icall-experimental-normalize-integers` option for cross-language LLVM
|
||||
/// CFI and KCFI support.
|
||||
const NORMALIZE_INTEGERS = 4;
|
||||
/// Do not perform self type erasure for attaching a secondary type id to methods with their
|
||||
/// concrete self so they can be used as function pointers.
|
||||
const NO_SELF_TYPE_ERASURE = 8;
|
||||
/// Generalize the instance by erasing the concrete `Self` type where possible.
|
||||
/// Only has an effect on `{kcfi_,}typeid_for_instance`.
|
||||
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));
|
||||
}
|
||||
|
||||
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())
|
||||
&& 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: ![[TYPE2]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}5Type1EE"}
|
||||
// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}5Type1EE"}
|
||||
// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}6Trait1u6regionEEE"}
|
||||
|
Loading…
Reference in New Issue
Block a user