[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241119065655.21123-5-yangtiezhu@loongson.cn>
Date: Tue, 19 Nov 2024 14:56:49 +0800
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
To: 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: [PATCH v3 04/10] objtool: Handle PC relative relocation type
When compling with Clang on LoongArch, there exists 32 bit PC relative
relocation type, it needs to get the offset with "S + A - PC" according
to the spec of "ELF for the LoongArch Architecture".
This is preparation for later patch on LoongArch, there is no effect for
the other archs with this patch.
Link: https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc
Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
---
tools/objtool/check.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index af824bfd0973..eb4c89501493 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2118,6 +2118,11 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
if (reloc->sym->type == STT_SECTION) {
/* Addend field in the relocation entry associated with the symbol */
offset = reloc_addend(reloc);
+ /* Handle the special cases compiled with Clang on LoongArch */
+ if (file->elf->ehdr.e_machine == EM_LOONGARCH &&
+ reloc_type(reloc) == R_LARCH_32_PCREL)
+ offset = reloc->sym->offset + reloc_addend(reloc) -
+ (reloc_offset(reloc) - reloc_offset(table));
} else {
/* The address of the symbol in the relocation entry */
offset = reloc->sym->offset;
--
2.42.0
Powered by blists - more mailing lists