mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
objtool: Disassemble jump table alternatives
When using the --disas option, also disassemble jump tables. Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org> Link: https://patch.msgid.link/20251121095340.464045-24-alexandre.chartre@oracle.com
This commit is contained in:
committed by
Peter Zijlstra
parent
78df4590c5
commit
7e017720aa
@@ -639,6 +639,34 @@ static int disas_alt_add_insn(struct disas_alt *dalt, int index, char *insn_str,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int disas_alt_jump(struct disas_alt *dalt)
|
||||
{
|
||||
struct instruction *orig_insn;
|
||||
struct instruction *dest_insn;
|
||||
char suffix[2] = { 0 };
|
||||
char *str;
|
||||
|
||||
orig_insn = dalt->orig_insn;
|
||||
dest_insn = dalt->alt->insn;
|
||||
|
||||
if (orig_insn->type == INSN_NOP) {
|
||||
if (orig_insn->len == 5)
|
||||
suffix[0] = 'q';
|
||||
str = strfmt("jmp%-3s %lx <%s+0x%lx>", suffix,
|
||||
dest_insn->offset, dest_insn->sym->name,
|
||||
dest_insn->offset - dest_insn->sym->offset);
|
||||
} else {
|
||||
str = strfmt("nop%d", orig_insn->len);
|
||||
}
|
||||
|
||||
if (!str)
|
||||
return -1;
|
||||
|
||||
disas_alt_add_insn(dalt, 0, str, 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disassemble an exception table alternative.
|
||||
*/
|
||||
@@ -809,10 +837,7 @@ static void *disas_alt(struct disas_context *dctx,
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Only group alternatives and exception tables are
|
||||
* supported at the moment.
|
||||
*/
|
||||
count = -1;
|
||||
switch (dalt->alt->type) {
|
||||
case ALT_TYPE_INSTRUCTIONS:
|
||||
count = disas_alt_group(dctx, dalt);
|
||||
@@ -820,8 +845,9 @@ static void *disas_alt(struct disas_context *dctx,
|
||||
case ALT_TYPE_EX_TABLE:
|
||||
count = disas_alt_extable(dalt);
|
||||
break;
|
||||
default:
|
||||
count = 0;
|
||||
case ALT_TYPE_JUMP_TABLE:
|
||||
count = disas_alt_jump(dalt);
|
||||
break;
|
||||
}
|
||||
if (count < 0) {
|
||||
WARN("%s: failed to disassemble alternative %s",
|
||||
|
||||
Reference in New Issue
Block a user