]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
objtool: Disassemble jump table alternatives
authorAlexandre Chartre <alexandre.chartre@oracle.com>
Fri, 21 Nov 2025 09:53:33 +0000 (10:53 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 21 Nov 2025 14:30:14 +0000 (15:30 +0100)
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
tools/objtool/disas.c

index 018aba37b996b39759c68950d9cdeaf5490e0eb6..326e16c9f30a82440befd79c2ff8d2edc015bb0f 100644 (file)
@@ -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",