1
Fork 0

cfg(kcfi)

This commit is contained in:
Alice Ryhl 2025-04-12 10:49:39 +00:00
parent 17d412439a
commit 6c6a39e6bf
3 changed files with 18 additions and 9 deletions

View file

@ -7,7 +7,7 @@ use crate::char::{EscapeDebugExtArgs, MAX_LEN_UTF8};
use crate::marker::PhantomData; use crate::marker::PhantomData;
use crate::num::fmt as numfmt; use crate::num::fmt as numfmt;
use crate::ops::Deref; use crate::ops::Deref;
use crate::{iter, result, str}; use crate::{iter, mem, result, str};
mod builders; mod builders;
#[cfg(not(no_fp_fmt_parse))] #[cfg(not(no_fp_fmt_parse))]

View file

@ -72,6 +72,13 @@ macro_rules! argument_new {
// a `fn(&T, ...)`, so the invariant is maintained. // a `fn(&T, ...)`, so the invariant is maintained.
ty: ArgumentType::Placeholder { ty: ArgumentType::Placeholder {
value: NonNull::<$t>::from_ref($x).cast(), value: NonNull::<$t>::from_ref($x).cast(),
#[cfg(not(any(sanitize = "cfi", sanitize = "kcfi")))]
formatter: {
let f: fn(&$t, &mut Formatter<'_>) -> Result = $f;
// SAFETY: This is only called with `value`, which has the right type.
unsafe { mem::transmute(f) }
},
#[cfg(any(sanitize = "cfi", sanitize = "kcfi"))]
formatter: |ptr: NonNull<()>, fmt: &mut Formatter<'_>| { formatter: |ptr: NonNull<()>, fmt: &mut Formatter<'_>| {
let func = $f; let func = $f;
// SAFETY: This is the same type as the `value` field. // SAFETY: This is the same type as the `value` field.

View file

@ -140,17 +140,19 @@ Number of file 0 mappings: 6
- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10) - Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10)
Highest counter ID seen: c1 Highest counter ID seen: c1
Function name: closure::main::{closure#18} (unused) Function name: closure::main::{closure#18}
Raw bytes (24): 0x[01, 01, 00, 04, 00, 19, 0d, 02, 1c, 00, 02, 1d, 02, 12, 00, 02, 11, 00, 12, 00, 01, 11, 01, 0e] Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 19, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 11, 00, 12, 01, 01, 11, 01, 0e]
Number of files: 1 Number of files: 1
- file 0 => global file 1 - file 0 => global file 1
Number of expressions: 0 Number of expressions: 1
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
Number of file 0 mappings: 4 Number of file 0 mappings: 4
- Code(Zero) at (prev + 25, 13) to (start + 2, 28) - Code(Counter(0)) at (prev + 25, 13) to (start + 2, 28)
- Code(Zero) at (prev + 2, 29) to (start + 2, 18) - Code(Counter(1)) at (prev + 2, 29) to (start + 2, 18)
- Code(Zero) at (prev + 2, 17) to (start + 0, 18) - Code(Expression(0, Sub)) at (prev + 2, 17) to (start + 0, 18)
- Code(Zero) at (prev + 1, 17) to (start + 1, 14) = (c0 - c1)
Highest counter ID seen: (none) - Code(Counter(0)) at (prev + 1, 17) to (start + 1, 14)
Highest counter ID seen: c1
Function name: closure::main::{closure#19} Function name: closure::main::{closure#19}
Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 43, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 11, 00, 12, 01, 01, 11, 01, 0e] Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 43, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 11, 00, 12, 01, 01, 11, 01, 0e]