Skip to content

Commit c83e687

Browse files
seehearfeelgregkh
authored andcommitted
LoongArch: Pass annotate-tablejump option if LTO is enabled
[ Upstream commit 5dfea66 ] 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: e20ab7d ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4050d08 commit c83e687

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/loongarch/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,13 @@ KBUILD_CFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)
102102

103103
ifdef CONFIG_OBJTOOL
104104
ifdef CONFIG_CC_HAS_ANNOTATE_TABLEJUMP
105+
# The annotate-tablejump option can not be passed to LLVM backend when LTO is enabled.
106+
# Ensure it is aware of linker with LTO, '--loongarch-annotate-tablejump' also needs to
107+
# be passed via '-mllvm' to ld.lld.
105108
KBUILD_CFLAGS += -mannotate-tablejump
109+
ifdef CONFIG_LTO_CLANG
110+
KBUILD_LDFLAGS += -mllvm --loongarch-annotate-tablejump
111+
endif
106112
else
107113
KBUILD_CFLAGS += -fno-jump-tables # keep compatibility with older compilers
108114
endif

0 commit comments

Comments
 (0)