mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Huacai Chen <chenhuacai@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	loongarch@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 05/10] objtool: Handle unreachable entry of rodata
Date: Tue, 26 Nov 2024 19:04:39 +0800	[thread overview]
Message-ID: <20537f77-e105-317b-7f95-8a72533c8e43@loongson.cn> (raw)
In-Reply-To: <20241126072557.b6qt7jaiikvkcswn@jpoimboe>

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@loongson.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


  reply	other threads:[~2024-11-26 11:04 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-22  4:49 [PATCH v4 00/10] Add jump table support for objtool on LoongArch Tiezhu Yang
2024-11-22  4:49 ` [PATCH v4 01/10] objtool: Handle various symbol types of rodata Tiezhu Yang
2024-11-26  6:44   ` Josh Poimboeuf
2024-11-26 10:41     ` Tiezhu Yang
2024-11-27  0:52       ` Josh Poimboeuf
2024-11-27  6:39         ` Tiezhu Yang
2024-11-27 18:53           ` Josh Poimboeuf
2024-11-28  2:26             ` Tiezhu Yang
2024-11-22  4:49 ` [PATCH v4 02/10] objtool: Handle special cases of dead end insn Tiezhu Yang
2024-11-26  6:45   ` Josh Poimboeuf
2024-11-26 10:42     ` Tiezhu Yang
2024-11-26 14:32       ` Peter Zijlstra
2024-11-26 15:22         ` Peter Zijlstra
2024-11-27  5:45           ` Tiezhu Yang
2024-11-22  4:49 ` [PATCH v4 03/10] objtool: Handle different entry size of rodata Tiezhu Yang
2024-11-26  7:02   ` Josh Poimboeuf
2024-11-26 10:59     ` Tiezhu Yang
2024-11-26 13:22       ` Tiezhu Yang
2024-11-27  0:57         ` Josh Poimboeuf
2024-11-27  6:59           ` Tiezhu Yang
2024-11-27  0:53       ` Josh Poimboeuf
2024-11-22  4:49 ` [PATCH v4 04/10] objtool: Handle PC relative relocation type Tiezhu Yang
2024-11-26  7:19   ` Josh Poimboeuf
2024-11-26 11:00     ` Tiezhu Yang
2024-11-26 13:24       ` Tiezhu Yang
2024-11-27  0:58         ` Josh Poimboeuf
2024-11-22  4:50 ` [PATCH v4 05/10] objtool: Handle unreachable entry of rodata Tiezhu Yang
2024-11-26  7:25   ` Josh Poimboeuf
2024-11-26 11:04     ` Tiezhu Yang [this message]
2024-11-27  0:55       ` Josh Poimboeuf
2024-11-22  4:50 ` [PATCH v4 06/10] objtool: Handle unsorted table offset " Tiezhu Yang
2024-11-26 13:28   ` Tiezhu Yang
2024-11-27  1:20     ` Josh Poimboeuf
2024-11-27  7:01       ` Tiezhu Yang
2024-11-28  0:10         ` Josh Poimboeuf
2024-11-28  0:16           ` Josh Poimboeuf
2024-11-28  1:00             ` Josh Poimboeuf
2024-11-28  2:28               ` Tiezhu Yang
2024-12-02  7:42                 ` Tiezhu Yang
2024-12-03 15:58                 ` Peter Zijlstra
2024-11-22  4:50 ` [PATCH v4 07/10] objtool/LoongArch: Get each table size " Tiezhu Yang
2024-11-22  4:50 ` [PATCH v4 08/10] objtool/LoongArch: Add support for switch table Tiezhu Yang
2024-11-22  4:50 ` [PATCH v4 09/10] objtool/LoongArch: Add support for goto table Tiezhu Yang
2024-11-22  4:50 ` [PATCH v4 10/10] LoongArch: Enable jump table for objtool Tiezhu Yang
2024-11-24  5:33 ` [PATCH v4 00/10] Add jump table support for objtool on LoongArch Huacai Chen
2024-11-26  7:29   ` Josh Poimboeuf
2024-11-26  9:18     ` Huacai Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20537f77-e105-317b-7f95-8a72533c8e43@loongson.cn \
    --to=yangtiezhu@loongson.cn \
    --cc=chenhuacai@kernel.org \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®