lkml.org 
[lkml]   [2018]   [Jan]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 10/10] objtool: More complex static jump implementation
On Tue, Jan 16, 2018 at 03:28:35PM +0100, Peter Zijlstra wrote:
> +static int grow_static_blocks(struct objtool_file *file)
> +{
> + struct instruction *insn;
> + bool static_block = false;
> +
> + for_each_insn(file, insn) {
> + if (!static_block && !insn->static_jump_dest)
> + continue;
> +
> + if (insn->static_jump_dest) {
> + static_block = true;
> + continue;
> + }
> +
> + if (insn->branch_target) {
> + static_block = false;
> + continue;
> + } else switch (insn->type) {
> + case INSN_JUMP_CONDITIONAL:
> + case INSN_JUMP_DYNAMIC:

Hmm, I think I also should have added INSN_JUMP_UNCONDITIONAL here,
because the for_each_insn() iteration simply iterates through the entire
file in linear order, it doesn't actually _follow_ the jumps.

So this would result in code after the unconditional jump also being
marked static (although very likely it ends up being a branch target and
thus stops it through that).

/me updates.

> + case INSN_CALL:
> + case INSN_CALL_DYNAMIC:
> + case INSN_RETURN:
> + case INSN_BUG:
> + static_block = false;
> + continue;
> + }
> +
> + insn->static_jump_dest = static_block;
> + }
> +
> + return 0;
> +}

\
 
 \ /
  Last update: 2018-01-16 16:21    [W:0.147 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site