In the most cases, the entry size of rodata is 8 bytes because the
relocation type is 64 bit, but when compling with Clang on LoongArch,
there exists 32 bit relocation type, the entry size of rodata should
be 4 bytes in this case.
This is preparation for later patch on LoongArch, there is no effect
for the other archs with this patch.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
tools/objtool/check.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 6607cd56459b..af824bfd0973 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2092,6 +2092,7 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
struct reloc *reloc = table;
struct alternative *alt;
unsigned long offset;
+ unsigned long rodata_entry_size;
/*
* Each @reloc is a switch table relocation which points to the target
@@ -2103,8 +2104,15 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
if (reloc != table && reloc == next_table)
break;
+ /* Handle the special cases compiled with Clang on LoongArch */
+ if (file->elf->ehdr.e_machine == EM_LOONGARCH &&
+ reloc_type(reloc) == R_LARCH_32_PCREL)
+ rodata_entry_size = 4;
+ else
+ rodata_entry_size = 8;
+
/* Make sure the table entries are consecutive: */
- if (prev_offset && reloc_offset(reloc) != prev_offset + 8)
+ if (prev_offset && reloc_offset(reloc) != prev_offset + rodata_entry_size)
break;
if (reloc->sym->type == STT_SECTION) {
--
2.42.0
Hi Tiezhu,
kernel test robot noticed the following build errors:
[auto build test ERROR on v6.12-rc7]
[also build test ERROR on next-20241121]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Tiezhu-Yang/objtool-Handle-various-symbol-types-of-rodata/20241121-131412
base: v6.12-rc7
patch link: https://lore.kernel.org/r/20241119065655.21123-4-yangtiezhu%40loongson.cn
patch subject: [PATCH v3 03/10] objtool: Handle different entry size of rodata
config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20241122/202411220727.UfLx4PU8-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241122/202411220727.UfLx4PU8-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411220727.UfLx4PU8-lkp@intel.com/
All errors (new ones prefixed by >>):
check.c: In function 'add_jump_table':
>> check.c:2109:42: error: 'R_LARCH_32_PCREL' undeclared (first use in this function); did you mean 'R_ARC_B22_PCREL'?
2109 | reloc_type(reloc) == R_LARCH_32_PCREL)
| ^~~~~~~~~~~~~~~~
| R_ARC_B22_PCREL
check.c:2109:42: note: each undeclared identifier is reported only once for each function it appears in
make[5]: *** [tools/build/Makefile.build:105: tools/objtool/check.o] Error 1
make[5]: *** Waiting for unfinished jobs....
make[4]: *** [Makefile:70: tools/objtool/objtool-in.o] Error 2
make[3]: *** [Makefile:73: objtool] Error 2
make[2]: *** [Makefile:1370: tools/objtool] Error 2
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:224: __sub-make] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:224: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Tiezhu,
kernel test robot noticed the following build errors:
[auto build test ERROR on v6.12-rc7]
[also build test ERROR on next-20241121]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Tiezhu-Yang/objtool-Handle-various-symbol-types-of-rodata/20241121-131412
base: v6.12-rc7
patch link: https://lore.kernel.org/r/20241119065655.21123-4-yangtiezhu%40loongson.cn
patch subject: [PATCH v3 03/10] objtool: Handle different entry size of rodata
config: x86_64-allnoconfig (https://download.01.org/0day-ci/archive/20241122/202411220519.OK6FYVwq-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241122/202411220519.OK6FYVwq-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411220519.OK6FYVwq-lkp@intel.com/
All errors (new ones prefixed by >>):
>> check.c:2109:28: error: use of undeclared identifier 'R_LARCH_32_PCREL'
2109 | reloc_type(reloc) == R_LARCH_32_PCREL)
| ^
1 error generated.
make[5]: *** [tools/build/Makefile.build:105: tools/objtool/check.o] Error 1
make[5]: *** Waiting for unfinished jobs....
make[4]: *** [Makefile:70: tools/objtool/objtool-in.o] Error 2
make[3]: *** [Makefile:73: objtool] Error 2
make[2]: *** [Makefile:1370: tools/objtool] Error 2
In file included from arch/x86/kernel/asm-offsets.c:14:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:21:
In file included from include/linux/mm.h:2213:
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
1 warning generated.
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:224: __sub-make] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:224: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On 2024-11-19 14:56, Tiezhu Yang wrote:
> In the most cases, the entry size of rodata is 8 bytes because the
> relocation type is 64 bit, but when compling with Clang on LoongArch,
> there exists 32 bit relocation type, the entry size of rodata should
> be 4 bytes in this case.
>
> This is preparation for later patch on LoongArch, there is no effect
> for the other archs with this patch.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
> tools/objtool/check.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 6607cd56459b..af824bfd0973 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -2092,6 +2092,7 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
> struct reloc *reloc = table;
> struct alternative *alt;
> unsigned long offset;
> + unsigned long rodata_entry_size;
>
> /*
> * Each @reloc is a switch table relocation which points to the target
> @@ -2103,8 +2104,15 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
> if (reloc != table && reloc == next_table)
> break;
>
> + /* Handle the special cases compiled with Clang on LoongArch */
> + if (file->elf->ehdr.e_machine == EM_LOONGARCH &&
> + reloc_type(reloc) == R_LARCH_32_PCREL)
It is arch-specific. I'd prefer to rewrite an interface in arch directory
to get the entry size in rodata by arch different relocation types.
And I think this patch should merge to other patches e.g. [07/10].
> + rodata_entry_size = 4;
> + else
> + rodata_entry_size = 8;
> +
> /* Make sure the table entries are consecutive: */
> - if (prev_offset && reloc_offset(reloc) != prev_offset + 8)
> + if (prev_offset && reloc_offset(reloc) != prev_offset + rodata_entry_size)
> break;
>
> if (reloc->sym->type == STT_SECTION) {
© 2016 - 2026 Red Hat, Inc.