[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241015113915.12623-7-yangtiezhu@loongson.cn>
Date: Tue, 15 Oct 2024 19:39:15 +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,
bpf@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v1 6/6] objtool/LoongArch: Add support for goto table
If find_reloc_by_table_annotate() failed, it means that there
is no relocation info of switch table address in the section
".rela.discard.tablejump_annotate", then objtool can find the
relocation against the nearest instruction before the jump
instruction with find_reloc_by_dest_range(), which points to
the goto table.
Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
---
tools/objtool/arch/loongarch/special.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/objtool/arch/loongarch/special.c b/tools/objtool/arch/loongarch/special.c
index 65b1ed297d57..d2a6071d772f 100644
--- a/tools/objtool/arch/loongarch/special.c
+++ b/tools/objtool/arch/loongarch/special.c
@@ -47,8 +47,18 @@ struct reloc *arch_find_switch_table(struct objtool_file *file,
unsigned long table_offset;
annotate_reloc = find_reloc_by_table_annotate(file, insn);
- if (!annotate_reloc)
- return NULL;
+ if (!annotate_reloc) {
+ annotate_reloc = find_reloc_by_dest_range(file->elf, insn->sec,
+ insn->offset, insn->len);
+ if (!annotate_reloc)
+ return NULL;
+
+ if (!annotate_reloc->sym->sec->rodata)
+ return NULL;
+
+ if (reloc_type(annotate_reloc) != R_LARCH_NONE)
+ return NULL;
+ }
table_sec = annotate_reloc->sym->sec;
table_offset = annotate_reloc->sym->offset;
--
2.42.0
Powered by blists - more mailing lists