diff options
author | Peter Zijlstra <peterz@infradead.org> | 2020-03-23 22:57:13 +0300 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2020-03-25 20:28:31 +0300 |
commit | 350994bf95414d6da67a72f27d7ac3832ce3725d (patch) | |
tree | ba494eb8b3363966b29986534bf4443a5d925d61 /tools/objtool | |
parent | 74b873e49d92f90deb41d1a2a8fbb70328aebd67 (diff) | |
download | linux-350994bf95414d6da67a72f27d7ac3832ce3725d.tar.xz |
objtool: Re-arrange validate_functions()
In preparation to adding a vmlinux.o specific pass, rearrange some
code. No functional changes intended.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/20200324160924.924304616@infradead.org
Diffstat (limited to 'tools/objtool')
-rw-r--r-- | tools/objtool/check.c | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 0c9c9ad47467..0bfcb390ca73 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2395,9 +2395,8 @@ static bool ignore_unreachable_insn(struct instruction *insn) return false; } -static int validate_functions(struct objtool_file *file) +static int validate_section(struct objtool_file *file, struct section *sec) { - struct section *sec; struct symbol *func; struct instruction *insn; struct insn_state state; @@ -2410,36 +2409,45 @@ static int validate_functions(struct objtool_file *file) CFI_NUM_REGS * sizeof(struct cfi_reg)); state.stack_size = initial_func_cfi.cfa.offset; - for_each_sec(file, sec) { - list_for_each_entry(func, &sec->symbol_list, list) { - if (func->type != STT_FUNC) - continue; + list_for_each_entry(func, &sec->symbol_list, list) { + if (func->type != STT_FUNC) + continue; - if (!func->len) { - WARN("%s() is missing an ELF size annotation", - func->name); - warnings++; - } + if (!func->len) { + WARN("%s() is missing an ELF size annotation", + func->name); + warnings++; + } - if (func->pfunc != func || func->alias != func) - continue; + if (func->pfunc != func || func->alias != func) + continue; - insn = find_insn(file, sec, func->offset); - if (!insn || insn->ignore || insn->visited) - continue; + insn = find_insn(file, sec, func->offset); + if (!insn || insn->ignore || insn->visited) + continue; - state.uaccess = func->uaccess_safe; + state.uaccess = func->uaccess_safe; - ret = validate_branch(file, func, insn, state); - if (ret && backtrace) - BT_FUNC("<=== (func)", insn); - warnings += ret; - } + ret = validate_branch(file, func, insn, state); + if (ret && backtrace) + BT_FUNC("<=== (func)", insn); + warnings += ret; } return warnings; } +static int validate_functions(struct objtool_file *file) +{ + struct section *sec; + int warnings = 0; + + for_each_sec(file, sec) + warnings += validate_section(file, sec); + + return warnings; +} + static int validate_reachable_instructions(struct objtool_file *file) { struct instruction *insn; |