linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] efistub: Only link libstub to final vmlinux
@ 2025-09-28  8:55 Tiezhu Yang
  2025-09-28 13:41 ` Ard Biesheuvel
  0 siblings, 1 reply; 43+ messages in thread
From: Tiezhu Yang @ 2025-09-28  8:55 UTC (permalink / raw)
  To: Ard Biesheuvel, Josh Poimboeuf, Huacai Chen
  Cc: loongarch, linux-arm-kernel, linux-riscv, linux-efi, linux-kbuild,
	linux-kernel

When compiling with LLVM and CONFIG_LTO_CLANG is set, there exists
the following objtool warning on LoongArch:

  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.

Do the similar things for arm64 and riscv, otherwise there may be objtool
warnings when arm64 and riscv support objtool, this is to make consistent
with the archs that use libstub.

Link: https://lore.kernel.org/lkml/pq4h7jgndnt6p45lj4kgubxjd5gidfetugcuf5rcxzxxanzetd@6rrlpjnjsmuy/
Suggested-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 Makefile                | 1 +
 arch/arm64/Makefile     | 5 ++++-
 arch/loongarch/Makefile | 5 ++++-
 arch/riscv/Makefile     | 5 ++++-
 scripts/link-vmlinux.sh | 5 ++---
 5 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 10355ecf32cb..8ba2e28ef3d1 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
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 73a10f65ce8b..038f37ef2143 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -156,7 +156,10 @@ KBUILD_CPPFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
 KBUILD_AFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
 
 libs-y		:= arch/arm64/lib/ $(libs-y)
-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
 
 # Default target when executing plain make
 boot		:= arch/arm64/boot
diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
index ae419e32f22e..4eb904c20718 100644
--- a/arch/loongarch/Makefile
+++ b/arch/loongarch/Makefile
@@ -169,7 +169,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/arch/riscv/Makefile b/arch/riscv/Makefile
index df57654a615e..cfd82b2c1bbf 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -173,7 +173,10 @@ boot-image-$(CONFIG_XIP_KERNEL)		:= xipImage
 KBUILD_IMAGE				:= $(boot)/$(boot-image-y)
 
 libs-y += arch/riscv/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
 
 ifeq ($(KBUILD_EXTMOD),)
 ifeq ($(CONFIG_MMU),y)
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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2025-11-22 11:05 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-28  8:55 [PATCH v2] efistub: Only link libstub to final vmlinux Tiezhu Yang
2025-09-28 13:41 ` Ard Biesheuvel
2025-09-28 13:52   ` Huacai Chen
2025-09-28 14:39     ` Ard Biesheuvel
2025-09-28 14:41       ` Ard Biesheuvel
2025-10-09  7:27         ` Tiezhu Yang
2025-10-10 16:25           ` Ard Biesheuvel
2025-10-11  1:13             ` Tiezhu Yang
2025-10-11  2:54               ` Huacai Chen
2025-10-11  3:40                 ` Ard Biesheuvel
2025-10-11  7:29                   ` Tiezhu Yang
2025-10-11  7:42                     ` Huacai Chen
2025-10-11  8:13                       ` Tiezhu Yang
2025-10-11 14:48                       ` Ard Biesheuvel
2025-10-11 15:01                         ` Huacai Chen
2025-10-11 15:58                           ` Ard Biesheuvel
2025-10-13  7:34                             ` Tiezhu Yang
2025-10-13 14:09                             ` Huacai Chen
2025-10-13 14:36                               ` Ard Biesheuvel
2025-10-14 16:47                                 ` Josh Poimboeuf
2025-10-16 14:52                                   ` Ard Biesheuvel
2025-10-16 15:49                                     ` Josh Poimboeuf
2025-10-17 11:00                                       ` Ard Biesheuvel
2025-10-17 16:22                                         ` Josh Poimboeuf
2025-10-17 16:26                                           ` Ard Biesheuvel
2025-10-17 17:05                                             ` Josh Poimboeuf
2025-10-20  1:24                                               ` Tiezhu Yang
2025-10-20  6:55                                                 ` Huacai Chen
2025-10-23  6:55                                                   ` Tiezhu Yang
2025-10-23  8:01                                                     ` Huacai Chen
2025-10-23  8:06                                                       ` Ard Biesheuvel
2025-10-26 11:20                                                         ` Huacai Chen
2025-10-28 13:47                                                           ` Ard Biesheuvel
2025-11-10  1:18                                                             ` Tiezhu Yang
2025-11-10  7:00                                                               ` Huacai Chen
2025-11-11 16:49                                                                 ` Ard Biesheuvel
2025-11-11 18:00                                                                 ` Josh Poimboeuf
2025-11-15  3:16                                                                   ` Huacai Chen
2025-11-17 11:33                                                                     ` Will Deacon
2025-11-21  2:09                                                                       ` Paul Walmsley
2025-11-21 14:36                                                                       ` Huacai Chen
2025-11-22 11:04                                                                         ` Tiezhu Yang
2025-09-30  2:52       ` Huacai Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).