From: "tip-bot2 for Tiezhu Yang" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>,
Huacai Chen <chenhuacai@loongson.cn>,
Josh Poimboeuf <jpoimboe@kernel.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: objtool/core] objtool: Handle different entry size of rodata
Date: Fri, 14 Mar 2025 20:04:02 -0000 [thread overview]
Message-ID: <174198264291.14745.11158899791248573322.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20250211115016.26913-3-yangtiezhu@loongson.cn>
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 091bf313f8a852a7f30c3a8dcef569edfd06f5dc
Gitweb: https://git.kernel.org/tip/091bf313f8a852a7f30c3a8dcef569edfd06f5dc
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
AuthorDate: Tue, 11 Feb 2025 19:50:11 +08:00
Committer: Josh Poimboeuf <jpoimboe@kernel.org>
CommitterDate: Wed, 12 Mar 2025 15:43:38 -07:00
objtool: Handle different entry size of rodata
In the most cases, the entry size of rodata is 8 bytes because the
relocation type is 64 bit. There are also 32 bit relocation types,
the entry size of rodata should be 4 bytes in this case.
Add an arch-specific function arch_reloc_size() to assign the entry
size of rodata for x86, powerpc and LoongArch.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Link: https://lore.kernel.org/r/20250211115016.26913-3-yangtiezhu@loongson.cn
Acked-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
tools/objtool/arch/loongarch/decode.c | 11 +++++++++++
tools/objtool/arch/powerpc/decode.c | 14 ++++++++++++++
tools/objtool/arch/x86/decode.c | 13 +++++++++++++
tools/objtool/check.c | 2 +-
tools/objtool/include/objtool/arch.h | 2 ++
5 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/tools/objtool/arch/loongarch/decode.c b/tools/objtool/arch/loongarch/decode.c
index 69b6699..b64205b 100644
--- a/tools/objtool/arch/loongarch/decode.c
+++ b/tools/objtool/arch/loongarch/decode.c
@@ -363,3 +363,14 @@ void arch_initial_func_cfi_state(struct cfi_init_state *state)
state->cfa.base = CFI_SP;
state->cfa.offset = 0;
}
+
+unsigned int arch_reloc_size(struct reloc *reloc)
+{
+ switch (reloc_type(reloc)) {
+ case R_LARCH_32:
+ case R_LARCH_32_PCREL:
+ return 4;
+ default:
+ return 8;
+ }
+}
diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
index 53b5569..7c0bf24 100644
--- a/tools/objtool/arch/powerpc/decode.c
+++ b/tools/objtool/arch/powerpc/decode.c
@@ -106,3 +106,17 @@ void arch_initial_func_cfi_state(struct cfi_init_state *state)
state->regs[CFI_RA].base = CFI_CFA;
state->regs[CFI_RA].offset = 0;
}
+
+unsigned int arch_reloc_size(struct reloc *reloc)
+{
+ switch (reloc_type(reloc)) {
+ case R_PPC_REL32:
+ case R_PPC_ADDR32:
+ case R_PPC_UADDR32:
+ case R_PPC_PLT32:
+ case R_PPC_PLTREL32:
+ return 4;
+ default:
+ return 8;
+ }
+}
diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index fe1362c..fb9691a 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -852,3 +852,16 @@ bool arch_is_embedded_insn(struct symbol *sym)
return !strcmp(sym->name, "retbleed_return_thunk") ||
!strcmp(sym->name, "srso_safe_ret");
}
+
+unsigned int arch_reloc_size(struct reloc *reloc)
+{
+ switch (reloc_type(reloc)) {
+ case R_X86_64_32:
+ case R_X86_64_32S:
+ case R_X86_64_PC32:
+ case R_X86_64_PLT32:
+ return 4;
+ default:
+ return 8;
+ }
+}
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index cfab4a1..f762d23 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1969,7 +1969,7 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
break;
/* Make sure the table entries are consecutive: */
- if (prev_offset && reloc_offset(reloc) != prev_offset + 8)
+ if (prev_offset && reloc_offset(reloc) != prev_offset + arch_reloc_size(reloc))
break;
sym_offset = reloc->sym->offset + reloc_addend(reloc);
diff --git a/tools/objtool/include/objtool/arch.h b/tools/objtool/include/objtool/arch.h
index d63b46a..396f7c6 100644
--- a/tools/objtool/include/objtool/arch.h
+++ b/tools/objtool/include/objtool/arch.h
@@ -97,4 +97,6 @@ int arch_rewrite_retpolines(struct objtool_file *file);
bool arch_pc_relative_reloc(struct reloc *reloc);
+unsigned int arch_reloc_size(struct reloc *reloc);
+
#endif /* _ARCH_H */
next prev parent reply other threads:[~2025-03-14 20:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-11 11:50 [PATCH v7 0/7] Add jump table support for objtool on LoongArch Tiezhu Yang
2025-02-11 11:50 ` [PATCH v7 1/7] objtool: Handle various symbol types of rodata Tiezhu Yang
2025-03-14 20:04 ` [tip: objtool/core] " tip-bot2 for Tiezhu Yang
2025-02-11 11:50 ` [PATCH v7 2/7] objtool: Handle different entry size " Tiezhu Yang
2025-03-14 20:04 ` tip-bot2 for Tiezhu Yang [this message]
2025-02-11 11:50 ` [PATCH v7 3/7] objtool: Handle PC relative relocation type Tiezhu Yang
2025-03-14 20:04 ` [tip: objtool/core] " tip-bot2 for Tiezhu Yang
2025-02-11 11:50 ` [PATCH v7 4/7] objtool/LoongArch: Add support for switch table Tiezhu Yang
2025-03-14 20:04 ` [tip: objtool/core] " tip-bot2 for Tiezhu Yang
2025-02-11 11:50 ` [PATCH v7 5/7] objtool/LoongArch: Add support for goto table Tiezhu Yang
2025-03-14 20:04 ` [tip: objtool/core] " tip-bot2 for Tiezhu Yang
2025-02-11 11:50 ` [PATCH v7 6/7] LoongArch: Enable jump table for objtool Tiezhu Yang
2025-02-11 11:50 ` [PATCH v7 7/7] LoongArch: Convert unreachable() to BUG() Tiezhu Yang
2025-03-08 5:47 ` [PATCH v7 0/7] 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=174198264291.14745.11158899791248573322.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=chenhuacai@loongson.cn \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=x86@kernel.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®