Re: [PATCH v2 3/4] objtool/LoongArch: Fix unreachable instruction warnings about entry points

From: Tiezhu Yang
Date: Wed Sep 17 2025 - 05:48:52 EST


On 2025/9/17 下午3:07, Huacai Chen wrote:
Hi, Tiezhu,

On Wed, Sep 17, 2025 at 9:10 AM Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> wrote:

When compiling with LLVM and CONFIG_LTO_CLANG is set, there exist the
following objtool warnings:

vmlinux.o: warning: objtool: kernel_entry+0x0: unreachable instruction
vmlinux.o: warning: objtool: smpboot_entry+0x0: unreachable instruction

kernel_entry() and smpboot_entry() are in arch/loongarch/kernel/head.S,
there is "OBJECT_FILES_NON_STANDARD_head.o := y" to skip objtool checking
for head.o, but the STACK_FRAME_NON_STANDARD macro does not work for link
time validation of vmlinux.o according to objtool documentation, just give
a proper unwind hint to fix the warnings.

By the way, ASM_BUG() can be removed due to unnecessary, otherwise there
are following warnings:

kernel_entry+0xf4: start_kernel() missing __noreturn
in .c/.h or NORETURN() in noreturns.h

smpboot_entry+0x68: start_secondary() missing __noreturn
in .c/.h or NORETURN() in noreturns.h

This is because the previous instructions of kernel_entry+0xf4 and
smpboot_entry+0x68 are the 'bl' instructions, start_kernel() and
start_secondary() are the respective call destination symbols which
are noreturn functions, then the 'bl' instructions are already marked
as dead end in annotate_call_site().

For now, it is time to remove "OBJECT_FILES_NON_STANDARD_head.o := y"
in arch/loongarch/kernel/Makefile.

...

-OBJECT_FILES_NON_STANDARD_head.o := y
This line should be kept, othewise we get:

arch/loongarch/kernel/head.o: warning: objtool: kernel_entry+0xf4:
start_kernel() missing __noreturn in .c/.h or NORETURN() in
noreturns.h

even without LTO. This is a regression, we can only remove it after
the above warning be fixed.

As said in the commit message, ASM_BUG() needs to be removed
to fix the above warning.

I tested again with GCC and LLVM (with and without LTO),
there is no the warning what you said, please double check.

(1) GCC
make ARCH=loongarch defconfig
make ARCH=loongarch -j8

(2) LLVM without LTO
make ARCH=loongarch LLVM=1 clean defconfig
make ARCH=loongarch LLVM=1 olddefconfig all -j8

(3) LLVM with LTO
make ARCH=loongarch LLVM=1 clean defconfig
scripts/config -d LTO_NONE -e LTO_CLANG_THIN
make ARCH=loongarch LLVM=1 olddefconfig all -j8

Thanks,
Tiezhu