rust/compiler/rustc_const_eval/src/interpret
Matthias Krüger accf61dd42
Rollup merge of #143293 - folkertdev:naked-function-kcfi, r=compiler-errors
fix `-Zsanitizer=kcfi` on `#[naked]` functions

fixes https://github.com/rust-lang/rust/issues/143266

With `-Zsanitizer=kcfi`, indirect calls happen via generated intermediate shim that forwards the call. The generated shim preserves the attributes of the original, including `#[unsafe(naked)]`. The shim is not a naked function though, and violates its invariants (like having a body that consists of a single `naked_asm!` call).

My fix here is to match on the `InstanceKind`, and only use `codegen_naked_asm` when the instance is not a `ReifyShim`. That does beg the question whether there are other `InstanceKind`s that could come up. As far as I can tell the answer is no: calling via `dyn` seems to work find, and `#[track_caller]` is disallowed in combination with `#[naked]`.

r? codegen
````@rustbot```` label +A-naked
cc ````@maurer```` ````@rcvalle````
2025-07-18 04:27:51 +02:00
..
call.rs Add InterpCx::fn_abi_of_instance/_fn_ptr with tracing, shadowing FnAbiOf 2025-07-15 15:04:53 +02:00
cast.rs Remove support for dyn* 2025-07-01 19:00:21 +00:00
discriminant.rs Add InterpCx::layout_of with tracing, shadowing LayoutOf 2025-06-27 11:49:22 +02:00
eval_context.rs Add InterpCx::fn_abi_of_instance/_fn_ptr with tracing, shadowing FnAbiOf 2025-07-15 15:04:53 +02:00
intern.rs simplfy memory kind handling during interning 2025-07-16 15:29:52 +02:00
intrinsics.rs type_id_eq: check that the hash fully matches the type 2025-07-16 08:02:47 +02:00
machine.rs simplfy memory kind handling during interning 2025-07-16 15:29:52 +02:00
memory.rs Rollup merge of #143293 - folkertdev:naked-function-kcfi, r=compiler-errors 2025-07-18 04:27:51 +02:00
mod.rs const heap: fix ICE on forgotten make_global 2025-07-16 15:29:52 +02:00
operand.rs Add InterpCx::layout_of with tracing, shadowing LayoutOf 2025-06-27 11:49:22 +02:00
operator.rs Add InterpCx::layout_of with tracing, shadowing LayoutOf 2025-06-27 11:49:22 +02:00
place.rs setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +03:00
projection.rs Add opaque TypeId handles for CTFE 2025-07-09 16:37:11 +00:00
stack.rs Make frame spans appear on a separate trace line 2025-07-16 09:25:35 +02:00
step.rs Add InterpCx::fn_abi_of_instance/_fn_ptr with tracing, shadowing FnAbiOf 2025-07-15 15:04:53 +02:00
traits.rs Remove support for dyn* 2025-07-01 19:00:21 +00:00
util.rs Make enter_trace_span take a closure for better optimization 2025-07-08 15:24:56 +02:00
validity.rs const heap: fix ICE on forgotten make_global 2025-07-16 15:29:52 +02:00
visitor.rs Remove support for dyn* 2025-07-01 19:00:21 +00:00