[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ede02c68-9a1b-8cd1-ae05-a1106b435e93@loongson.cn>
Date: Tue, 19 Nov 2024 18:47:23 +0800
From: Jinyang He <hejinyang@...ngson.cn>
To: Tiezhu Yang <yangtiezhu@...ngson.cn>, Huacai Chen
<chenhuacai@...nel.org>, Josh Poimboeuf <jpoimboe@...nel.org>,
Peter Zijlstra <peterz@...radead.org>
Cc: loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 03/10] objtool: Handle different entry size of rodata
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@...ngson.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) {
Powered by blists - more mailing lists