Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
arch/loongarch/Kconfig | 8 +++++++-
arch/loongarch/Makefile | 6 ++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index ddc042895d01..57f28450a2ed 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -143,7 +143,7 @@ config LOONGARCH
select HAVE_LIVEPATCH
select HAVE_MOD_ARCH_SPECIFIC
select HAVE_NMI
- select HAVE_OBJTOOL if AS_HAS_EXPLICIT_RELOCS && AS_HAS_THIN_ADD_SUB && !CC_IS_CLANG
+ select HAVE_OBJTOOL if TOOLCHAIN_SUPPORTS_OBJTOOL && !CC_IS_CLANG
select HAVE_PCI
select HAVE_PERF_EVENTS
select HAVE_PERF_REGS
@@ -276,6 +276,12 @@ config AS_HAS_LBT_EXTENSION
config AS_HAS_LVZ_EXTENSION
def_bool $(as-instr,hvcl 0)
+config CC_HAS_ANNOTATE_TABLEJUMP
+ def_bool $(cc-option,-mannotate-tablejump)
+
+config TOOLCHAIN_SUPPORTS_OBJTOOL
+ def_bool AS_HAS_EXPLICIT_RELOCS && AS_HAS_THIN_ADD_SUB && CC_HAS_ANNOTATE_TABLEJUMP
+
menu "Kernel type and options"
source "kernel/Kconfig.hz"
diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
index 8674e7e24c4a..186c75c80daa 100644
--- a/arch/loongarch/Makefile
+++ b/arch/loongarch/Makefile
@@ -99,10 +99,8 @@ KBUILD_AFLAGS += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno
KBUILD_CFLAGS += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
KBUILD_AFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)-mthin-add-sub)
KBUILD_CFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)-mthin-add-sub)
-
-ifdef CONFIG_OBJTOOL
-KBUILD_CFLAGS += -fno-jump-tables
-endif
+KBUILD_AFLAGS += $(call cc-option,-mannotate-tablejump) $(call cc-option,-Wa$(comma)-mannotate-tablejump)
+KBUILD_CFLAGS += $(call cc-option,-mannotate-tablejump) $(call cc-option,-Wa$(comma)-mannotate-tablejump)
KBUILD_RUSTFLAGS += --target=loongarch64-unknown-none-softfloat
KBUILD_RUSTFLAGS_MODULE += -Crelocation-model=pic
--
2.42.0
On Fri, 2024-07-12 at 17:15 +0800, Tiezhu Yang wrote: > -ifdef CONFIG_OBJTOOL > -KBUILD_CFLAGS += -fno-jump-tables > -endif > +KBUILD_AFLAGS += $(call cc-option,-mannotate-tablejump) $(call cc-option,-Wa$(comma)-mannotate-tablejump) > +KBUILD_CFLAGS += $(call cc-option,-mannotate-tablejump) $(call cc-option,-Wa$(comma)-mannotate-tablejump) KBUILD_AFLAGS isn't needed, and $(call cc-option,-Wa$(comma)-mannotate- tablejump) will always expand to nothing because the assembler does not have -mannotate-tablejump. The assembler never creates a jump table itself. -- Xi Ruoyao <xry111@xry111.site> School of Aerospace Science and Technology, Xidian University
On Fri, 2024-07-12 at 17:49 +0800, Xi Ruoyao wrote: > On Fri, 2024-07-12 at 17:15 +0800, Tiezhu Yang wrote: > > -ifdef CONFIG_OBJTOOL > > -KBUILD_CFLAGS += -fno-jump-tables > > -endif > > +KBUILD_AFLAGS += $(call cc-option,-mannotate-tablejump) $(call cc-option,-Wa$(comma)-mannotate-tablejump) > > +KBUILD_CFLAGS += $(call cc-option,-mannotate-tablejump) $(call cc-option,-Wa$(comma)-mannotate-tablejump) > > KBUILD_AFLAGS isn't needed, and $(call cc-option,-Wa$(comma)-mannotate- > tablejump) will always expand to nothing because the assembler does not > have -mannotate-tablejump. > > The assembler never creates a jump table itself. BTW have you discussed with Lulu about the -mannotate-tablejump patch? I guess maybe an intra-Loongson discussion would be helpful. -- Xi Ruoyao <xry111@xry111.site> School of Aerospace Science and Technology, Xidian University
On 07/13/2024 05:10 PM, Xi Ruoyao wrote: > On Fri, 2024-07-12 at 17:49 +0800, Xi Ruoyao wrote: >> On Fri, 2024-07-12 at 17:15 +0800, Tiezhu Yang wrote: >>> -ifdef CONFIG_OBJTOOL >>> -KBUILD_CFLAGS += -fno-jump-tables >>> -endif >>> +KBUILD_AFLAGS += $(call cc-option,-mannotate-tablejump) $(call cc-option,-Wa$(comma)-mannotate-tablejump) >>> +KBUILD_CFLAGS += $(call cc-option,-mannotate-tablejump) $(call cc-option,-Wa$(comma)-mannotate-tablejump) >> >> KBUILD_AFLAGS isn't needed, and $(call cc-option,-Wa$(comma)-mannotate- >> tablejump) will always expand to nothing because the assembler does not >> have -mannotate-tablejump. >> >> The assembler never creates a jump table itself. Thanks, you are right, I will modify it in the formal v1 series. > BTW have you discussed with Lulu about the -mannotate-tablejump patch? > I guess maybe an intra-Loongson discussion would be helpful. Yes, I have discussed with Loongson compiler team some days ago and will discuss more to reach an agreement in the next few days. Thanks, Tiezhu
Hi, Tiezhu, On Fri, Jul 12, 2024 at 5:15 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote: > > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> > --- > arch/loongarch/Kconfig | 8 +++++++- > arch/loongarch/Makefile | 6 ++---- > 2 files changed, 9 insertions(+), 5 deletions(-) > > diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig > index ddc042895d01..57f28450a2ed 100644 > --- a/arch/loongarch/Kconfig > +++ b/arch/loongarch/Kconfig > @@ -143,7 +143,7 @@ config LOONGARCH > select HAVE_LIVEPATCH > select HAVE_MOD_ARCH_SPECIFIC > select HAVE_NMI > - select HAVE_OBJTOOL if AS_HAS_EXPLICIT_RELOCS && AS_HAS_THIN_ADD_SUB && !CC_IS_CLANG > + select HAVE_OBJTOOL if TOOLCHAIN_SUPPORTS_OBJTOOL && !CC_IS_CLANG > select HAVE_PCI > select HAVE_PERF_EVENTS > select HAVE_PERF_REGS > @@ -276,6 +276,12 @@ config AS_HAS_LBT_EXTENSION > config AS_HAS_LVZ_EXTENSION > def_bool $(as-instr,hvcl 0) > > +config CC_HAS_ANNOTATE_TABLEJUMP > + def_bool $(cc-option,-mannotate-tablejump) > + > +config TOOLCHAIN_SUPPORTS_OBJTOOL > + def_bool AS_HAS_EXPLICIT_RELOCS && AS_HAS_THIN_ADD_SUB && CC_HAS_ANNOTATE_TABLEJUMP Can AS_HAS_THIN_ADD_SUB be removed now? Huacai > + > menu "Kernel type and options" > > source "kernel/Kconfig.hz" > diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile > index 8674e7e24c4a..186c75c80daa 100644 > --- a/arch/loongarch/Makefile > +++ b/arch/loongarch/Makefile > @@ -99,10 +99,8 @@ KBUILD_AFLAGS += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno > KBUILD_CFLAGS += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax) > KBUILD_AFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)-mthin-add-sub) > KBUILD_CFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)-mthin-add-sub) > - > -ifdef CONFIG_OBJTOOL > -KBUILD_CFLAGS += -fno-jump-tables > -endif > +KBUILD_AFLAGS += $(call cc-option,-mannotate-tablejump) $(call cc-option,-Wa$(comma)-mannotate-tablejump) > +KBUILD_CFLAGS += $(call cc-option,-mannotate-tablejump) $(call cc-option,-Wa$(comma)-mannotate-tablejump) > > KBUILD_RUSTFLAGS += --target=loongarch64-unknown-none-softfloat > KBUILD_RUSTFLAGS_MODULE += -Crelocation-model=pic > -- > 2.42.0 > >
On 07/12/2024 05:40 PM, Huacai Chen wrote: > Hi, Tiezhu, > > On Fri, Jul 12, 2024 at 5:15 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote: >> >> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> >> --- >> arch/loongarch/Kconfig | 8 +++++++- >> arch/loongarch/Makefile | 6 ++---- >> 2 files changed, 9 insertions(+), 5 deletions(-) >> >> diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig >> index ddc042895d01..57f28450a2ed 100644 >> --- a/arch/loongarch/Kconfig >> +++ b/arch/loongarch/Kconfig >> @@ -143,7 +143,7 @@ config LOONGARCH >> select HAVE_LIVEPATCH >> select HAVE_MOD_ARCH_SPECIFIC >> select HAVE_NMI >> - select HAVE_OBJTOOL if AS_HAS_EXPLICIT_RELOCS && AS_HAS_THIN_ADD_SUB && !CC_IS_CLANG >> + select HAVE_OBJTOOL if TOOLCHAIN_SUPPORTS_OBJTOOL && !CC_IS_CLANG >> select HAVE_PCI >> select HAVE_PERF_EVENTS >> select HAVE_PERF_REGS >> @@ -276,6 +276,12 @@ config AS_HAS_LBT_EXTENSION >> config AS_HAS_LVZ_EXTENSION >> def_bool $(as-instr,hvcl 0) >> >> +config CC_HAS_ANNOTATE_TABLEJUMP >> + def_bool $(cc-option,-mannotate-tablejump) >> + >> +config TOOLCHAIN_SUPPORTS_OBJTOOL >> + def_bool AS_HAS_EXPLICIT_RELOCS && AS_HAS_THIN_ADD_SUB && CC_HAS_ANNOTATE_TABLEJUMP > Can AS_HAS_THIN_ADD_SUB be removed now? If the following patch can be accepted, then objtool will not rely on AS_HAS_THIN_ADD_SUB, I will try to send this patch again. objtool: Add skipped member in struct reloc https://lore.kernel.org/loongarch/1690272910-11869-6-git-send-email-yangtiezhu@loongson.cn/ Thanks, Tiezhu
© 2016 - 2026 Red Hat, Inc.