[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <173986419190.10177.8150784597022966817.tip-bot2@tip-bot2>
Date: Tue, 18 Feb 2025 07:36:31 -0000
From: "tip-bot2 for Tiezhu Yang" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Josh Poimboeuf <jpoimboe@...nel.org>, Tiezhu Yang <yangtiezhu@...ngson.cn>,
x86@...nel.org, linux-kernel@...r.kernel.org
Subject: [tip: objtool/urgent] objtool: Rename ".rodata..c_jump_table" to
"..rodata.c_jump_table"
The following commit has been merged into the objtool/urgent branch of tip:
Commit-ID: b8bd16a0ae060862ff6215b27ab626dd7ff12484
Gitweb: https://git.kernel.org/tip/b8bd16a0ae060862ff6215b27ab626dd7ff12484
Author: Tiezhu Yang <yangtiezhu@...ngson.cn>
AuthorDate: Fri, 14 Feb 2025 20:51:35 +08:00
Committer: Josh Poimboeuf <jpoimboe@...nel.org>
CommitterDate: Sun, 16 Feb 2025 18:57:47 -08:00
objtool: Rename ".rodata..c_jump_table" to "..rodata.c_jump_table"
Specify the attribute like ".rodata..c_jump_table,\"a\",@progbits #"
explicitly works for GCC, but this hack apparently doesn't work with
Clang, the generated section name is wrong, resulting in a warning
and missing ORC for x86. This is because there is only one arg for
section name in LLVM, even if the so called attribute is specified,
it will be recognized as a whole for section name, so it is not a
good way to specify the attribute for this section.
In the top Makefile, there is "-fno-PIE" build flag. For x86, there
is no "-fPIE" build flag in arch/x86/Makefile for 64 bit kernel. But
for LoongArch, there is "-fPIE" build flag in arch/loongarch/Makefile
to override "-fno-PIE" in top Makefile. After some test with GCC and
Clang on x86 and LoongArch, it shows that the generated "W" (writable)
attribute of the section ".rodata..c_jump_table" is related with the
compiler option "-fPIE", and then lead to the GNU assembler warning:
"setting incorrect section attributes for .rodata..c_jump_table".
Based on the above analysis, in order to avoid changing the behavior
of GNU assembler and silence the GNU assembler warning, it is better
to rename ".rodata..c_jump_table" to "..rodata.c_jump_table" without
section attribute, it works well with GCC and Clang, no GNU assembler
warning for GCC and the section name is normal for Clang.
Fixes: c5b1184decc8 ("compiler.h: specify correct attribute for .rodata..c_jump_table")
Reported-by: Josh Poimboeuf <jpoimboe@...nel.org>
Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
Link: https://lore.kernel.org/r/20250214125135.2172-1-yangtiezhu@loongson.cn
Signed-off-by: Josh Poimboeuf <jpoimboe@...nel.org>
---
include/asm-generic/vmlinux.lds.h | 2 +-
include/linux/compiler.h | 2 +-
tools/objtool/check.c | 5 +++--
tools/objtool/include/objtool/special.h | 2 +-
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 5450401..91a7e82 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -457,7 +457,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
. = ALIGN((align)); \
.rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
__start_rodata = .; \
- *(.rodata) *(.rodata.*) \
+ *(.rodata) *(.rodata.*) *(..rodata.*) \
SCHED_DATA \
RO_AFTER_INIT_DATA /* Read only after init */ \
. = ALIGN(8); \
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index b087de2..3d013f1 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -110,7 +110,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
/* Unreachable code */
#ifdef CONFIG_OBJTOOL
/* Annotate a C jump table to allow objtool to follow the code flow */
-#define __annotate_jump_table __section(".rodata..c_jump_table,\"a\",@progbits #")
+#define __annotate_jump_table __section("..rodata.c_jump_table")
#else /* !CONFIG_OBJTOOL */
#define __annotate_jump_table
#endif /* CONFIG_OBJTOOL */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 497cb8d..1398ffc 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2471,12 +2471,13 @@ static void mark_rodata(struct objtool_file *file)
*
* - .rodata: can contain GCC switch tables
* - .rodata.<func>: same, if -fdata-sections is being used
- * - .rodata..c_jump_table: contains C annotated jump tables
+ * - ..rodata.c_jump_table: contains C annotated jump tables
*
* .rodata.str1.* sections are ignored; they don't contain jump tables.
*/
for_each_sec(file, sec) {
- if (!strncmp(sec->name, ".rodata", 7) &&
+ if ((!strncmp(sec->name, ".rodata", 7) ||
+ !strncmp(sec->name, "..rodata", 8)) &&
!strstr(sec->name, ".str1.")) {
sec->rodata = true;
found = true;
diff --git a/tools/objtool/include/objtool/special.h b/tools/objtool/include/objtool/special.h
index e7ee7ff..34acf4a 100644
--- a/tools/objtool/include/objtool/special.h
+++ b/tools/objtool/include/objtool/special.h
@@ -10,7 +10,7 @@
#include <objtool/check.h>
#include <objtool/elf.h>
-#define C_JUMP_TABLE_SECTION ".rodata..c_jump_table"
+#define C_JUMP_TABLE_SECTION "..rodata.c_jump_table"
struct special_alt {
struct list_head list;
Powered by blists - more mailing lists