History

objtool: Support asm jump tables

Objtool detection of asm jump tables would normally just work, except for the fact that asm retpolines use alternatives. Objtool thinks the alternative code path (a jump to the retpoline) is a sibling call. Don't treat alternative indirect branches as sibling calls when the original instruction has a jump table.

Josh Poimboeuf committed 5 years ago

Commit 99033461 parent 900b4df1 file · +13 −1Browse files

Showing the changes to tools/objtool (1 of 1 file). Show all

Unified · Split

tools/objtool/check.c+13−1
@@ -108,6 +108,18 @@ static struct instruction *prev_insn_same_sym(struct objtool_file *file, · 107 unmodified lines
108 for (insn = next_insn_same_sec(file, insn); insn; \108 for (insn = next_insn_same_sec(file, insn); insn; \
109 insn = next_insn_same_sec(file, insn))109 insn = next_insn_same_sec(file, insn))
110 110
111static bool is_jump_table_jump(struct instruction *insn)
112{
113 struct alt_group *alt_group = insn->alt_group;
114
115 if (insn->jump_table)
116 return true;
117
118 /* Retpoline alternative for a jump table? */
119 return alt_group && alt_group->orig_group &&
120 alt_group->orig_group->first_insn->jump_table;
121}
122
111static bool is_sibling_call(struct instruction *insn)123static bool is_sibling_call(struct instruction *insn)
112{124{
113 /*125 /*
@@ -120,7 +132,7 @@ static bool is_sibling_call(struct instruction *insn) · 6 unmodified lines
120 132
121 /* An indirect jump is either a sibling call or a jump to a table. */133 /* An indirect jump is either a sibling call or a jump to a table. */
122 if (insn->type == INSN_JUMP_DYNAMIC)134 if (insn->type == INSN_JUMP_DYNAMIC)
123 return list_empty(&insn->alts);135 return !is_jump_table_jump(insn);
124 136
125 /* add_jump_destinations() sets insn->call_dest for sibling calls. */137 /* add_jump_destinations() sets insn->call_dest for sibling calls. */
126 return (is_static_jump(insn) && insn->call_dest);138 return (is_static_jump(insn) && insn->call_dest);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t