rust/compiler/rustc_codegen_llvm/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 Rollup merge of #143388 - bjorn3:lto_refactors, r=compiler-errors 2025-07-17 03:58:28 +02:00
builder Rollup merge of #143388 - bjorn3:lto_refactors, r=compiler-errors 2025-07-17 03:58:28 +02:00
coverageinfo Remove methods from StaticCodegenMethods that are not called in cg_ssa itself 2025-05-28 20:55:00 +00:00
debuginfo Rollup merge of #143920 - oli-obk:cg-llvm-safety, r=jieyouxu 2025-07-16 17:06:40 +02:00
llvm Shrink some unsafe blocks in cg_llvm 2025-07-14 08:27:08 +00:00
abi.rs use is_multiple_of instead of manual modulo 2025-07-05 10:55:35 +02:00
allocator.rs Make __rust_alloc_error_handler_should_panic a function 2025-07-03 10:52:21 -07:00
asm.rs emit .att_syntax when global/naked asm use that option 2025-07-09 01:09:55 +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 Eliminate all direct uses of LLVMMDStringInContext2 2025-07-14 08:27:08 +00:00
callee.rs use codegen_instance_attrs where an instance is (easily) available 2025-07-16 23:24:32 +02:00
common.rs Avoid a bunch of unnecessary unsafe blocks in cg_llvm 2025-07-14 08:27:08 +00:00
consts.rs Eliminate all direct uses of LLVMMDStringInContext2 2025-07-14 08:27:08 +00:00
context.rs Eliminate all direct uses of LLVMMDStringInContext2 2025-07-14 08:27:08 +00:00
declare.rs Eliminate all direct uses of LLVMMDStringInContext2 2025-07-14 08:27:08 +00:00
errors.rs Merge run_fat_lto, optimize_fat and autodiff into run_and_optimize_fat_lto 2025-07-03 16:22:32 +00:00
intrinsic.rs compiler: Parse p- specs in datalayout string, allow definition of custom default data address space 2025-07-07 09:04:53 +02:00
lib.rs Rollup merge of #143388 - bjorn3:lto_refactors, r=compiler-errors 2025-07-17 03:58:28 +02:00
llvm_util.rs Disable f16 on Aarch64 without neon for llvm < 20.1.1 2025-06-30 09:46:56 -05:00
mono_item.rs Rollup merge of #143293 - folkertdev:naked-function-kcfi, r=compiler-errors 2025-07-18 04:27:51 +02:00
type_.rs Eliminate all direct uses of LLVMMDStringInContext2 2025-07-14 08:27:08 +00:00
type_of.rs rename BackendRepr::Vector → SimdVector 2025-02-28 17:17:45 +01:00
va_arg.rs Auto merge of #143182 - xdoardo:more-addrspace, r=workingjubilee 2025-07-07 17:28:14 +00:00
value.rs Add warn(unreachable_pub) to rustc_codegen_llvm. 2024-08-16 08:46:57 +10:00