diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index 1344d08b420a2..0d5d99c3cacdd 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -155,9 +155,10 @@ STUBCOPY_FLAGS-$(CONFIG_LOONGARCH) += --prefix-alloc-sections=.init \
--prefix-symbols=__efistub_
STUBCOPY_RELOC-$(CONFIG_LOONGARCH) := R_LARCH_MARK_LA
-# Drop the section created by __ADDRESSABLE() so it doesn't get prefixed.
-# Its job is already done.
-STUBCOPY_FLAGS-y += --remove-section=.discard.addressable
+# Drop the section created by __ADDRESSABLE() from the absolute symbol check
+# and the objcopy, otherwise it gets prefixed and doesn't get discared.
+STUBCOPY_RM_SECTIONS := --remove-section=.discard.addressable
+STUBCOPY_FLAGS-y += $(STUBCOPY_RM_SECTIONS)
$(obj)/%.stub.o: $(obj)/%.o FORCE
$(call if_changed,stubcopy)
@@ -170,7 +171,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE
#
quiet_cmd_stubcopy = STUBCPY $@
cmd_stubcopy = \
- $(STRIP) --strip-debug -o $@ $<; \
+ $(STRIP) --strip-debug $(STUBCOPY_RM_SECTIONS) -o $@ $<; \
if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); then \
echo "$@: absolute symbol references not allowed in the EFI stub" >&2; \
/bin/false; \diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 6fd3182f5f458..e5aea1c0e54a2 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -570,6 +570,20 @@ config OBJTOOL_WERROR
If unsure, say Y.
+# For when objtool defers its work to the linked image (vmlinux.o or module.o)
+# rather than running on individual translation units.
+config OBJTOOL_DEFERRED
+ def_bool y
+ depends on OBJTOOL
+ depends on OBJTOOL_CONTROL_FLOW || NOINSTR_VALIDATION || LTO_CLANG || \
+ X86_KERNEL_IBT || KLP_BUILD
+
+# Objtool reverse-engineers the control flow graph
+config OBJTOOL_CONTROL_FLOW
+ def_bool y
+ depends on OBJTOOL
+ depends on UNWINDER_ORC || STACK_VALIDATION || HAVE_UACCESS_VALIDATION
+
config STACK_VALIDATION
bool "Compile-time stack metadata validation"
depends on HAVE_STACK_VALIDATION && UNWINDER_FRAME_POINTER
@@ -588,20 +602,6 @@ config NOINSTR_VALIDATION
select OBJTOOL
default y
-# Objtool reverse-engineers the control flow graph
-config OBJTOOL_CONTROL_FLOW
- def_bool y
- depends on OBJTOOL
- depends on UNWINDER_ORC || STACK_VALIDATION || HAVE_UACCESS_VALIDATION
-
-# Objtool defers its work to the linked image (vmlinux.o or module.o) rather
-# than running on individual translation units.
-config OBJTOOL_DEFERRED
- def_bool y
- depends on OBJTOOL
- depends on OBJTOOL_CONTROL_FLOW || NOINSTR_VALIDATION || LTO_CLANG || \
- X86_KERNEL_IBT || KLP_BUILD
-
config VMLINUX_MAP
bool "Generate vmlinux.map file when linking"
depends on EXPERT
diff --git a/rust/.gitignore b/rust/.gitignore
index c198d1a52e60e..d3829ffab80ba 100644
--- a/rust/.gitignore
+++ b/rust/.gitignore
@@ -6,6 +6,5 @@ doctests_kernel_generated.rs
doctests_kernel_generated_kunit.c
uapi_generated.rs
exports_*_generated.h
-intrinsics_annotate_generated.c
doc/
test/
diff --git a/rust/Makefile b/rust/Makefile
index 0aa9f298a2757..02795bcd54d62 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -36,9 +36,6 @@ endif
obj-$(CONFIG_RUST) += exports.o
-always-$(CONFIG_RUST) += intrinsics_annotate_generated.c
-obj-$(CONFIG_RUST) += intrinsics_annotate_generated.o
-
always-$(CONFIG_RUST) += host/libproc_macro2.rlib host/libquote.rlib host/libsyn.rlib
always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
@@ -52,6 +49,8 @@ ifndef CONFIG_UML
always-$(subst y,$(CONFIG_RUST),$(CONFIG_BUG)) += kernel/generated_arch_warn_asm.rs kernel/generated_arch_reachable_asm.rs
endif
+always-$(subst y,$(CONFIG_RUST),$(CONFIG_OBJTOOL_DEFERRED)) += kernel/generated_ignore_noreturn_asm.rs
+
# Avoids running `$(RUSTC)` when it may not be available.
ifdef CONFIG_RUST
@@ -705,20 +704,6 @@ ifdef CONFIG_PPC32
__udivdi3 __umoddi3
endif
-# For objtool, annotate the redirect-intrinsics as returnable. Their call
-# sites were compiled against the returnable intrinsics, but the redirected
-# versions are noreturn.
-quiet_cmd_intrinsics_annotate = GEN $@
- cmd_intrinsics_annotate = { \
- echo '/* Generated by rust/Makefile - do not edit */'; \
- echo '\#include <linux/annotate.h>'; \
- for s in $(redirect-intrinsics); do \
- echo "ANNOTATE_IGNORE_NORETURN(__rust$$s);"; \
- done; } > $@
-
-$(obj)/intrinsics_annotate_generated.c: $(srctree)/rust/Makefile FORCE
- $(call if_changed,intrinsics_annotate)
-
ifdef CONFIG_MODVERSIONS
cmd_gendwarfksyms = $(if $(skip_gendwarfksyms),, \
$(call rust_exports,$@,"%s\n") | \@@ -766,6 +751,10 @@ $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*'
$(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE
+$(call if_changed_rule,rustc_library)
+ifdef CONFIG_OBJTOOL_DEFERRED
+$(obj)/compiler_builtins.o: $(obj)/kernel/generated_ignore_noreturn_asm.rs
+endif
+
$(obj)/zerocopy.o: private skip_clippy = 1
$(obj)/zerocopy.o: private skip_gendwarfksyms = 1
$(obj)/zerocopy.o: private rustc_target_envs := $(zerocopy-envs)
diff --git a/rust/compiler_builtins.rs b/rust/compiler_builtins.rs
index fc6b54636dd54..2d8461c75ec59 100644
--- a/rust/compiler_builtins.rs
+++ b/rust/compiler_builtins.rs
@@ -33,6 +33,18 @@ macro_rules! define_panicking_intrinsics(
pub extern "C" fn $ident() {
panic!($reason);
}
+
+ // The redirected call sites were compiled against the real
+ // intrinsics, which return. Tell objtool to ignore the noreturn
+ // status of the panicking intrinsics.
+ #[cfg(CONFIG_OBJTOOL_DEFERRED)]
+ ::core::arch::global_asm!(
+ include!(concat!(
+ env!("OBJTREE"),
+ "/rust/kernel/generated_ignore_noreturn_asm.rs"
+ )),
+ sym = sym $ident,
+ );
)*
}
);diff --git a/rust/kernel/.gitignore b/rust/kernel/.gitignore
index f636ad95aaf3d..a78a3e0e220a1 100644
--- a/rust/kernel/.gitignore
+++ b/rust/kernel/.gitignore
@@ -3,3 +3,4 @@
/generated_arch_static_branch_asm.rs
/generated_arch_warn_asm.rs
/generated_arch_reachable_asm.rs
+/generated_ignore_noreturn_asm.rs
diff --git a/rust/kernel/generated_ignore_noreturn_asm.rs.S b/rust/kernel/generated_ignore_noreturn_asm.rs.S
new file mode 100644
index 0000000000000..e2a531cba8acd
--- /dev/null
+++ b/rust/kernel/generated_ignore_noreturn_asm.rs.S
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include <linux/annotate.h>
+
+// Cut here.
+
+ASM_ANNOTATE_LABEL({sym}, ANNOTYPE_IGNORE_NORETURN)diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build
index 5237bad90f2cb..82a74de11d0df 100755
--- a/scripts/livepatch/klp-build
+++ b/scripts/livepatch/klp-build
@@ -599,7 +599,7 @@ copy_orig_objects() {
xtrace_save "copying original objects"
for _file in "${files[@]}"; do
- local rel_file="${_file/.ko/.o}"
+ local rel_file="${_file/%.ko/.o}"
local file="$PWD/${_file/%.ko/.ko.o}"
local orig_file="$ORIG_DIR/$rel_file"
local orig_dir="$(dirname "$orig_file")"@@ -607,7 +607,7 @@ copy_orig_objects() {
[[ ! -f "$file" ]] && die "missing $(basename "$file") for $_file"
mkdir -p "$orig_dir"
- cp -f "$file" "$orig_dir"
+ cp -f "$file" "$orig_file"
done
xtrace_restore
@@ -635,7 +635,7 @@ copy_patched_objects() {
xtrace_save "copying changed objects"
for _file in "${files[@]}"; do
- local rel_file="${_file/.ko/.o}"
+ local rel_file="${_file/%.ko/.o}"
local file="$PWD/${_file/%.ko/.ko.o}"
local orig_file="$ORIG_DIR/$rel_file"
local patched_file="$PATCHED_DIR/$rel_file"@@ -646,7 +646,7 @@ copy_patched_objects() {
cmp -s "$orig_file" "$file" && continue
mkdir -p "$patched_dir"
- cp -f "$file" "$patched_dir"
+ cp -f "$file" "$patched_file"
found=1
done
xtrace_restorediff --git a/tools/objtool/check.c b/tools/objtool/check.c
index cfd2d16cd5041..626402023e4a3 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2350,19 +2350,14 @@ static int add_jump_table_alts(struct objtool_file *file)
static void read_exports(struct objtool_file *file)
{
struct section *sec;
- struct symbol *func;
struct reloc *reloc;
sec = find_section_by_name(file->elf, ".export_symbol");
if (!sec || !sec->rsec)
return;
- for_each_reloc(sec->rsec, reloc) {
- func = find_func_by_offset(reloc->sym->sec,
- reloc->sym->offset + reloc_addend(reloc));
- if (func)
- func->exported = 1;
- }
+ for_each_reloc(sec->rsec, reloc)
+ reloc->sym->exported = 1;
}
static void set_func_state(struct cfi_state *state)