From: Jinyang He <hejinyang@loongson.cn>
To: Tiezhu Yang <yangtiezhu@loongson.cn>,
Huacai Chen <chenhuacai@kernel.org>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 01/10] objtool: Handle various symbol types of rodata
Date: Tue, 19 Nov 2024 18:47:13 +0800 [thread overview]
Message-ID: <63446b99-84f6-a51b-bee0-2f3158ecb033@loongson.cn> (raw)
In-Reply-To: <20241119065655.21123-2-yangtiezhu@loongson.cn>
On 2024-11-19 14:56, Tiezhu Yang wrote:
> In the relocation section ".rela.rodata" of each .o file compiled with
> LoongArch toolchain, there are various symbol types such as STT_NOTYPE,
> STT_OBJECT, STT_FUNC in addition to the usual STT_SECTION, it needs to
> use reloc symbol offset instead of reloc addend to find the destination
> instruction in find_jump_table() and add_jump_table().
>
> This is preparation for later patch on LoongArch, there is no effect for
> the other archs with this patch.
Which patch it prepares for? Please merge some patches if it is not
independent. Otherwise I cannot find what problem it solves.
According to the commit message I think it solve some problems independent?
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
> tools/objtool/check.c | 26 ++++++++++++++++++++++----
> 1 file changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 6604f5d038aa..9601235e908d 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -2079,6 +2079,7 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
> unsigned int prev_offset = 0;
> struct reloc *reloc = table;
> struct alternative *alt;
> + unsigned long offset;
>
> /*
> * Each @reloc is a switch table relocation which points to the target
> @@ -2094,12 +2095,19 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
> if (prev_offset && reloc_offset(reloc) != prev_offset + 8)
> break;
>
> + if (reloc->sym->type == STT_SECTION) {
> + /* Addend field in the relocation entry associated with the symbol */
> + offset = reloc_addend(reloc);
> + } else {
> + /* The address of the symbol in the relocation entry */
> + offset = reloc->sym->offset;
> + }
Generally rela relocations use S + A.
> +
> /* Detect function pointers from contiguous objects: */
> - if (reloc->sym->sec == pfunc->sec &&
> - reloc_addend(reloc) == pfunc->offset)
> + if (reloc->sym->sec == pfunc->sec && offset == pfunc->offset)
> break;
>
> - dest_insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
> + dest_insn = find_insn(file, reloc->sym->sec, offset);
> if (!dest_insn)
> break;
>
> @@ -2137,6 +2145,7 @@ static struct reloc *find_jump_table(struct objtool_file *file,
> {
> struct reloc *table_reloc;
> struct instruction *dest_insn, *orig_insn = insn;
> + unsigned long offset;
>
> /*
> * Backward search using the @first_jump_src links, these help avoid
> @@ -2160,7 +2169,16 @@ static struct reloc *find_jump_table(struct objtool_file *file,
> table_reloc = arch_find_switch_table(file, insn);
> if (!table_reloc)
> continue;
> - dest_insn = find_insn(file, table_reloc->sym->sec, reloc_addend(table_reloc));
> +
> + if (table_reloc->sym->type == STT_SECTION) {
> + /* Addend field in the relocation entry associated with the symbol */
> + offset = reloc_addend(table_reloc);
> + } else {
> + /* The address of the symbol in the relocation entry */
> + offset = table_reloc->sym->offset;
> + }
> +
> + dest_insn = find_insn(file, table_reloc->sym->sec, offset);
> if (!dest_insn || !insn_func(dest_insn) || insn_func(dest_insn)->pfunc != func)
> continue;
>
next prev parent reply other threads:[~2024-11-19 10:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 6:56 [PATCH v3 00/10] Add jump table support for objtool on LoongArch Tiezhu Yang
2024-11-19 6:56 ` [PATCH v3 01/10] objtool: Handle various symbol types of rodata Tiezhu Yang
2024-11-19 10:47 ` Jinyang He [this message]
2024-11-19 6:56 ` [PATCH v3 02/10] objtool: Handle special cases of dead end insn Tiezhu Yang
2024-11-19 10:47 ` Jinyang He
2024-11-19 6:56 ` [PATCH v3 03/10] objtool: Handle different entry size of rodata Tiezhu Yang
2024-11-19 10:47 ` Jinyang He
2024-11-21 21:33 ` kernel test robot
2024-11-22 1:24 ` kernel test robot
2024-11-19 6:56 ` [PATCH v3 04/10] objtool: Handle PC relative relocation type Tiezhu Yang
2024-11-19 6:56 ` [PATCH v3 05/10] objtool: Handle unreachable entry of rodata Tiezhu Yang
2024-11-19 10:47 ` Jinyang He
2024-11-21 12:56 ` Huacai Chen
2024-11-19 6:56 ` [PATCH v3 06/10] objtool: Handle unsorted table offset " Tiezhu Yang
2024-11-19 6:56 ` [PATCH v3 07/10] objtool/LoongArch: Get each table size " Tiezhu Yang
2024-11-19 6:56 ` [PATCH v3 08/10] objtool/LoongArch: Add support for switch table Tiezhu Yang
2024-11-19 6:56 ` [PATCH v3 09/10] objtool/LoongArch: Add support for goto table Tiezhu Yang
2024-11-19 6:56 ` [PATCH v3 10/10] LoongArch: Enable jump table for objtool Tiezhu Yang
2024-11-19 8:48 ` [PATCH v3 00/10] Add jump table support for objtool on LoongArch 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=63446b99-84f6-a51b-bee0-2f3158ecb033@loongson.cn \
--to=hejinyang@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 \
--cc=yangtiezhu@loongson.cn \
/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®