Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Alexandre Chartre and committed by
Peter Zijlstra
7e017720 78df4590

+32 -6
+32 -6
tools/objtool/disas.c
··· 639 639 return 0; 640 640 } 641 641 642 + static int disas_alt_jump(struct disas_alt *dalt) 643 + { 644 + struct instruction *orig_insn; 645 + struct instruction *dest_insn; 646 + char suffix[2] = { 0 }; 647 + char *str; 648 + 649 + orig_insn = dalt->orig_insn; 650 + dest_insn = dalt->alt->insn; 651 + 652 + if (orig_insn->type == INSN_NOP) { 653 + if (orig_insn->len == 5) 654 + suffix[0] = 'q'; 655 + str = strfmt("jmp%-3s %lx <%s+0x%lx>", suffix, 656 + dest_insn->offset, dest_insn->sym->name, 657 + dest_insn->offset - dest_insn->sym->offset); 658 + } else { 659 + str = strfmt("nop%d", orig_insn->len); 660 + } 661 + 662 + if (!str) 663 + return -1; 664 + 665 + disas_alt_add_insn(dalt, 0, str, 0); 666 + 667 + return 1; 668 + } 669 + 642 670 /* 643 671 * Disassemble an exception table alternative. 644 672 */ ··· 837 809 goto done; 838 810 } 839 811 840 - /* 841 - * Only group alternatives and exception tables are 842 - * supported at the moment. 843 - */ 812 + count = -1; 844 813 switch (dalt->alt->type) { 845 814 case ALT_TYPE_INSTRUCTIONS: 846 815 count = disas_alt_group(dctx, dalt); ··· 845 820 case ALT_TYPE_EX_TABLE: 846 821 count = disas_alt_extable(dalt); 847 822 break; 848 - default: 849 - count = 0; 823 + case ALT_TYPE_JUMP_TABLE: 824 + count = disas_alt_jump(dalt); 825 + break; 850 826 } 851 827 if (count < 0) { 852 828 WARN("%s: failed to disassemble alternative %s",