[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a191a5fb599889c3c64489adaf6adfe38746035d.1736955567.git.christophe.leroy@csgroup.eu>
Date: Wed, 15 Jan 2025 23:42:50 +0100
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: Josh Poimboeuf <jpoimboe@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Bill Wendling <morbo@...gle.com>,
Justin Stitt <justinstitt@...gle.com>,
Julien Thierry <jthierry@...hat.com>,
Miroslav Benes <mbenes@...e.cz>,
Raphael Gault <raphael.gault@....com>,
Michael Ellerman <mpe@...erman.id.au>,
Nicholas Piggin <npiggin@...il.com>,
Naveen N Rao <naveen@...nel.org>,
Madhavan Srinivasan <maddy@...ux.ibm.com>
Cc: Christophe Leroy <christophe.leroy@...roup.eu>,
linux-kernel@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org,
llvm@...ts.linux.dev
Subject: [PATCH v5 10/15] objtool: When looking for switch tables also follow conditional and dynamic jumps
When walking backward to find the base address of a switch table,
also take into account conditionnal branches and dynamic jumps from
a previous switch table.
To avoid mis-routing, break when stumbling on a function return.
Signed-off-by: Christophe Leroy <christophe.leroy@...roup.eu>
---
tools/objtool/check.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 0ad2bdd92232..87b81d8e01c0 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1998,6 +1998,8 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
alt->next = insn->alts;
insn->alts = alt;
prev_offset = reloc_offset(reloc);
+ if (!dest_insn->first_jump_src)
+ dest_insn->first_jump_src = insn;
}
if (!prev_offset) {
@@ -2032,6 +2034,9 @@ static void find_jump_table(struct objtool_file *file, struct symbol *func,
insn->gpr == orig_insn->gpr)
break;
+ if (insn->type == INSN_RETURN)
+ break;
+
/* allow small jumps within the range */
if (insn->type == INSN_JUMP_UNCONDITIONAL &&
insn->jump_dest &&
@@ -2093,8 +2098,7 @@ static int mark_add_func_jump_tables(struct objtool_file *file,
* that find_jump_table() can back-track using those and
* avoid some potentially confusing code.
*/
- if (insn->type == INSN_JUMP_UNCONDITIONAL && insn->jump_dest &&
- insn->offset > last->offset &&
+ if (is_static_jump(insn) && insn->jump_dest &&
insn->jump_dest->offset > insn->offset &&
!insn->jump_dest->first_jump_src) {
--
2.47.0
Powered by blists - more mailing lists