Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1500609
| From | Josh Poimboeuf <jpoimboe@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/2] objtool: improve rare switch jump table pattern detection |
| Date | 2016-10-14 00:20 +0200 |
| Message-ID | <srWw1-14D-3@gated-at.bofh.it> (permalink) |
| References | <srVJE-u5-23@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
gcc 6 added a new switch statement jump table optimization which makes
objtool's life harder. It looks like:
mov [rodata addr],%reg1
... some instructions ...
jmpq *(%reg1,%reg2,8)
The optimization is quite rare, but objtool still needs to be able to
identify the pattern so that it can follow all possible control flow
paths related to the switch statement.
In order to detect the pattern, objtool starts from the indirect jump
and scans backwards through the function until it finds the first
instruction in the pattern. If it encounters an unconditional jump
along the way, it stops and considers the pattern to be not found.
As it turns out, unconditional jumps can happen, as long as they are
small forward jumps within the range being scanned.
This fixes the following warnings:
drivers/infiniband/sw/rxe/rxe_comp.o: warning: objtool: rxe_completer()+0x2f4: sibling call from callable instruction with changed frame pointer
drivers/infiniband/sw/rxe/rxe_resp.o: warning: objtool: rxe_responder()+0x10f: sibling call from callable instruction with changed frame pointer
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
tools/objtool/builtin-check.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index 143b6cd..a00a05d 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -713,6 +713,7 @@ static struct rela *find_switch_table(struct objtool_file *file,
struct instruction *insn)
{
struct rela *text_rela, *rodata_rela;
+ struct instruction *orig_insn = insn;
text_rela = find_rela_by_dest_range(insn->sec, insn->offset, insn->len);
if (text_rela && text_rela->sym == file->rodata->sym) {
@@ -733,10 +734,16 @@ static struct rela *find_switch_table(struct objtool_file *file,
/* case 3 */
func_for_each_insn_continue_reverse(file, func, insn) {
- if (insn->type == INSN_JUMP_UNCONDITIONAL ||
- insn->type == INSN_JUMP_DYNAMIC)
+ if (insn->type == INSN_JUMP_DYNAMIC)
break;
+ /* allow small jumps within the range */
+ if (insn->type == INSN_JUMP_UNCONDITIONAL &&
+ insn->jump_dest &&
+ (insn->jump_dest->offset <= insn->offset ||
+ insn->jump_dest->offset >= orig_insn->offset))
+ break;
+
text_rela = find_rela_by_dest_range(insn->sec, insn->offset,
insn->len);
if (text_rela && text_rela->sym == file->rodata->sym)
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/2] objtool: a couple of minor fixes Josh Poimboeuf <jpoimboe@redhat.com> - 2016-10-13 23:30 +0200
[PATCH 2/2] objtool: skip all "unreachable instruction" warnings for gcov kernels Josh Poimboeuf <jpoimboe@redhat.com> - 2016-10-14 00:20 +0200
[tip:core/urgent] objtool: Skip all "unreachable instruction" warnings for gcov kernels tip-bot for Josh Poimboeuf <tipbot@zytor.com> - 2016-10-16 13:30 +0200
[PATCH 1/2] objtool: improve rare switch jump table pattern detection Josh Poimboeuf <jpoimboe@redhat.com> - 2016-10-14 00:20 +0200
[tip:core/urgent] objtool: Improve rare switch jump table pattern detection tip-bot for Josh Poimboeuf <tipbot@zytor.com> - 2016-10-16 13:30 +0200
Re: [PATCH 0/2] objtool: a couple of minor fixes Arnd Bergmann <arnd@arndb.de> - 2016-10-26 11:20 +0200
Re: [PATCH 0/2] objtool: a couple of minor fixes Josh Poimboeuf <jpoimboe@redhat.com> - 2016-10-26 14:50 +0200
Re: [PATCH 0/2] objtool: a couple of minor fixes Josh Poimboeuf <jpoimboe@redhat.com> - 2016-10-26 15:20 +0200
Re: [PATCH 0/2] objtool: a couple of minor fixes Josh Poimboeuf <jpoimboe@redhat.com> - 2016-10-26 14:50 +0200
[PATCH] objtool: fix rare switch jump table pattern detection Josh Poimboeuf <jpoimboe@redhat.com> - 2016-10-26 17:40 +0200
Re: [PATCH] objtool: fix rare switch jump table pattern detection Arnd Bergmann <arnd@arndb.de> - 2016-10-26 18:10 +0200
Re: [PATCH] objtool: fix rare switch jump table pattern detection Josh Poimboeuf <jpoimboe@redhat.com> - 2016-10-26 18:50 +0200
csiph-web