]> www.infradead.org Git - users/jedix/linux-maple.git/commit
LoongArch: Pass annotate-tablejump option if LTO is enabled
authorTiezhu Yang <yangtiezhu@loongson.cn>
Wed, 20 Aug 2025 14:23:15 +0000 (22:23 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Wed, 20 Aug 2025 14:23:15 +0000 (22:23 +0800)
commit5dfea6644d201bfeffaa7e0d79d62309856613b7
tree52130d85984ca23f86a62eca911819afdf084426
parenta47bc954cf0eb51f2828e1607d169d487df7f11f
LoongArch: Pass annotate-tablejump option if LTO is enabled

When compiling with LLVM and CONFIG_LTO_CLANG is set, there exist many
objtool warnings "sibling call from callable instruction with modified
stack frame".

For this special case, the related object file shows that there is no
generated relocation section '.rela.discard.tablejump_annotate' for the
table jump instruction jirl, thus objtool can not know that what is the
actual destination address.

It needs to do something on the LLVM side to make sure that there is the
relocation section '.rela.discard.tablejump_annotate' if LTO is enabled,
but in order to maintain compatibility for the current LLVM compiler,
this can be done in the kernel Makefile for now. Ensure it is aware of
linker with LTO, '--loongarch-annotate-tablejump' needs to be passed via
'-mllvm' to ld.lld.

Note that it should also pass the compiler option -mannotate-tablejump
rather than only pass '-mllvm --loongarch-annotate-tablejump' to ld.lld
if LTO is enabled, otherwise there are no jump info for some table jump
instructions.

Fixes: e20ab7d454ee ("LoongArch: Enable jump table for objtool")
Closes: https://lore.kernel.org/loongarch/20250731175655.GA1455142@ax162/
Reported-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Co-developed-by: WANG Rui <wangrui@loongson.cn>
Signed-off-by: WANG Rui <wangrui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/Makefile