rust/compiler/rustc_codegen_gcc/src
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
..
back Move dcx creation into WriteBackendMethods::codegen 2025-07-03 14:43:09 +00:00
intrinsic compiler: Parse p- specs in datalayout string, allow definition of custom default data address space 2025-07-07 09:04:53 +02:00
abi.rs Merge commit '4b5c44b141' into subtree-update_cg_gcc_2025-06-30 2025-06-30 16:12:42 +02:00
allocator.rs Make __rust_alloc_error_handler_should_panic a function 2025-07-03 10:52:21 -07:00
asm.rs Merge commit 'fda0bb9588' into subtree-update_cg_gcc_2025-06-18 2025-06-18 15:11:44 +02:00
attributes.rs use codegen_instance_attrs where an instance is (easily) available 2025-07-16 23:24:32 +02:00
base.rs Make predefine methods take &mut self 2025-05-28 20:55:00 +00:00
builder.rs Remove support for dynamic allocas 2025-07-07 23:04:06 +02:00
callee.rs use codegen_instance_attrs where an instance is (easily) available 2025-07-16 23:24:32 +02:00
common.rs Add opaque TypeId handles for CTFE 2025-07-09 16:37:11 +00:00
consts.rs compiler: Parse p- specs in datalayout string, allow definition of custom default data address space 2025-07-07 09:04:53 +02:00
context.rs Merge commit '4b5c44b141' into subtree-update_cg_gcc_2025-06-30 2025-06-30 16:12:42 +02:00
coverageinfo.rs Unbox and unwrap the contents of StatementKind::Coverage 2024-03-23 22:05:11 +11:00
debuginfo.rs Merge commit 'b7091eca6d' into subtree-update_cg_gcc_2025-06-28 2025-06-28 23:37:08 +02:00
declare.rs Merge commit 'b7091eca6d' into subtree-update_cg_gcc_2025-06-28 2025-06-28 23:37:08 +02:00
errors.rs move -Ctarget-feature handling into shared code 2025-06-19 09:44:01 +09:00
gcc_util.rs various minor target feature cleanups 2025-06-19 10:50:03 +09:00
int.rs Merge commit 'fda0bb9588' into subtree-update_cg_gcc_2025-06-18 2025-06-18 15:11:44 +02:00
lib.rs Rollup merge of #143388 - bjorn3:lto_refactors, r=compiler-errors 2025-07-17 03:58:28 +02:00
mono_item.rs use codegen_instance_attrs where an instance is (easily) available 2025-07-16 23:24:32 +02:00
type_.rs Merge commit 'fda0bb9588' into subtree-update_cg_gcc_2025-06-18 2025-06-18 15:11:44 +02:00
type_of.rs Merge commit 'fda0bb9588' into subtree-update_cg_gcc_2025-06-18 2025-06-18 15:11:44 +02:00