[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20537f77-e105-317b-7f95-8a72533c8e43@loongson.cn>
Date: Tue, 26 Nov 2024 19:04:39 +0800
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
To: Josh Poimboeuf <jpoimboe@...nel.org>
Cc: Huacai Chen <chenhuacai@...nel.org>, Peter Zijlstra
<peterz@...radead.org>, loongarch@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 05/10] objtool: Handle unreachable entry of rodata
On 11/26/2024 03:25 PM, Josh Poimboeuf wrote:
> On Fri, Nov 22, 2024 at 12:50:00PM +0800, Tiezhu Yang wrote:
>> When compling with Clang on LoongArch, there exists unreachable entry of
>> rodata which points to a position after the function return instruction,
>> this is generated by compiler to fill the non-existent switch case, just
>> skip the entry when parsing the relocation section of rodata.
>>
>> 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 | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
>> index 8733ca620cca..b21e47d8d3d1 100644
>> --- a/tools/objtool/check.c
>> +++ b/tools/objtool/check.c
>> @@ -2144,6 +2144,13 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
>> if (!dest_insn)
>> break;
>>
>> + /* Handle the special cases compiled with Clang on LoongArch */
>> + if (file->elf->ehdr.e_machine == EM_LOONGARCH && reloc->sym->type == STT_SECTION &&
>> + (!insn_func(dest_insn) || insn_func(dest_insn)->pfunc != pfunc)) {
>> + prev_offset = reloc_offset(reloc);
>> + continue;
>
> Are you sure this is specific to loongarch?
I am not sure, I only found this issue on LoongArch compiled with Clang,
but I think there is no effect if make it generic, like this:
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index f7586f82b967..87302e6fc07f 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2103,9 +2103,10 @@ static int add_jump_table(struct objtool_file
*file, struct instruction *insn,
if (!dest_insn)
break;
- /* Make sure the destination is in the same function: */
- if (!insn_func(dest_insn) || insn_func(dest_insn)->pfunc
!= pfunc)
- break;
+ if (!insn_func(dest_insn) || insn_func(dest_insn)->pfunc
!= pfunc) {
+ prev_offset = reloc_offset(reloc);
+ continue;
+ }
alt = malloc(sizeof(*alt));
if (!alt) {
If you are OK, I will modify it.
Thanks,
Tiezhu
Powered by blists - more mailing lists