[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240712091506.28140-2-yangtiezhu@loongson.cn>
Date: Fri, 12 Jul 2024 17:15:03 +0800
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
To: Josh Poimboeuf <jpoimboe@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Huacai Chen <chenhuacai@...nel.org>
Cc: Xi Ruoyao <xry111@...111.site>,
loongarch@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH 1/4] objtool: Check local label in find_jump_table()
Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
---
tools/objtool/check.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 0a33d9195b7a..c89c0d8c35d7 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2085,6 +2085,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
@@ -2108,7 +2109,18 @@ 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) {
+ offset = reloc_addend(table_reloc);
+ } else if (table_reloc->sym->local_label) {
+ offset = table_reloc->sym->offset;
+ } else {
+ WARN("unexpected relocation symbol type in %s: %d",
+ table_reloc->sec->name, table_reloc->sym->type);
+ return NULL;
+ }
+
+ dest_insn = find_insn(file, table_reloc->sym->sec, offset);
if (!dest_insn || !insn_func(dest_insn) || insn_func(dest_insn)->pfunc != func)
continue;
--
2.42.0
Powered by blists - more mailing lists