Re: [PATCH v1 1/3] LoongArch: Only link libstub to final vmlinux
From: Huacai Chen <chenhuacai@kernel.org>
Date: 2025-09-25 02:44:00
Also in:
linux-efi, linux-kbuild, linux-riscv, lkml, loongarch
Hi, Tiezhu, On Fri, Sep 19, 2025 at 5:36 PM Tiezhu Yang [off-list ref] wrote:
quoted hunk ↗ jump to hunk
When compiling with LLVM and CONFIG_LTO_CLANG is set, there exists the following objtool warning: vmlinux.o: warning: objtool: __efistub_efi_boot_kernel() falls through to next function __efistub_exit_boot_func() This is because efi_boot_kernel() doesn't end with a return instruction or an unconditional jump, then objtool has determined that the function can fall through into the next function. At the beginning, try to do something to make efi_boot_kernel() ends with an unconditional jump instruction, but this modification seems not proper. Since the efistub functions are useless for stack unwinder, they can be ignored by objtool. After many discussions, no need to link libstub to the vmlinux.o, only link libstub to the final vmlinux. Link: https://lore.kernel.org/lkml/pq4h7jgndnt6p45lj4kgubxjd5gidfetugcuf5rcxzxxanzetd@6rrlpjnjsmuy/ (local) Suggested-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> --- Makefile | 1 + arch/loongarch/Makefile | 5 ++++- scripts/link-vmlinux.sh | 5 ++--- 3 files changed, 7 insertions(+), 4 deletions(-)diff --git a/Makefile b/Makefile index 9771619ac596..b8e7c63ae3d1 100644 --- a/Makefile +++ b/Makefile@@ -1201,6 +1201,7 @@ KBUILD_VMLINUX_OBJS := built-in.a $(patsubst %/, %/lib.a, $(filter %/, $(libs-y) KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y)) export KBUILD_VMLINUX_LIBS +export KBUILD_VMLINUX_LIBS_PRELINK export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds ifdef CONFIG_TRIM_UNUSED_KSYMS
Why does the LoongArch patch modify the common parts? Since the whole series is small enough, I suggest modifying everything in a single patch. And the single patch can be merged via the efi tree. Huacai
quoted hunk ↗ jump to hunk
diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile index a3a9759414f4..e9c61f76a045 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile@@ -164,7 +164,10 @@ CHECKFLAGS += $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -dM -E -x c /dev endif libs-y += arch/loongarch/lib/ -libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a + +ifdef CONFIG_EFI_STUB +KBUILD_VMLINUX_LIBS_PRELINK += $(objtree)/drivers/firmware/efi/libstub/lib.a +endif drivers-y += arch/loongarch/crypto/diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 51367c2bfc21..b3cbff31d8a9 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh@@ -61,12 +61,11 @@ vmlinux_link() shift if is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT; then - # Use vmlinux.o instead of performing the slow LTO link again. objs=vmlinux.o - libs= + libs="${KBUILD_VMLINUX_LIBS_PRELINK}" else objs=vmlinux.a - libs="${KBUILD_VMLINUX_LIBS}" + libs="${KBUILD_VMLINUX_LIBS} ${KBUILD_VMLINUX_LIBS_PRELINK}" fi if is_enabled CONFIG_GENERIC_BUILTIN_DTB; then --2.42.0