Commit 350994bf authored by Peter Zijlstra's avatar Peter Zijlstra

objtool: Re-arrange validate_functions()

In preparation to adding a vmlinux.o specific pass, rearrange some
code. No functional changes intended.
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarMiroslav Benes <mbenes@suse.cz>
Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/20200324160924.924304616@infradead.org
parent 74b873e4
...@@ -2395,9 +2395,8 @@ static bool ignore_unreachable_insn(struct instruction *insn) ...@@ -2395,9 +2395,8 @@ static bool ignore_unreachable_insn(struct instruction *insn)
return false; 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 symbol *func;
struct instruction *insn; struct instruction *insn;
struct insn_state state; struct insn_state state;
...@@ -2410,36 +2409,45 @@ static int validate_functions(struct objtool_file *file) ...@@ -2410,36 +2409,45 @@ static int validate_functions(struct objtool_file *file)
CFI_NUM_REGS * sizeof(struct cfi_reg)); CFI_NUM_REGS * sizeof(struct cfi_reg));
state.stack_size = initial_func_cfi.cfa.offset; state.stack_size = initial_func_cfi.cfa.offset;
for_each_sec(file, sec) { list_for_each_entry(func, &sec->symbol_list, list) {
list_for_each_entry(func, &sec->symbol_list, list) { if (func->type != STT_FUNC)
if (func->type != STT_FUNC) continue;
continue;
if (!func->len) { if (!func->len) {
WARN("%s() is missing an ELF size annotation", WARN("%s() is missing an ELF size annotation",
func->name); func->name);
warnings++; warnings++;
} }
if (func->pfunc != func || func->alias != func) if (func->pfunc != func || func->alias != func)
continue; continue;
insn = find_insn(file, sec, func->offset); insn = find_insn(file, sec, func->offset);
if (!insn || insn->ignore || insn->visited) if (!insn || insn->ignore || insn->visited)
continue; continue;
state.uaccess = func->uaccess_safe; state.uaccess = func->uaccess_safe;
ret = validate_branch(file, func, insn, state); ret = validate_branch(file, func, insn, state);
if (ret && backtrace) if (ret && backtrace)
BT_FUNC("<=== (func)", insn); BT_FUNC("<=== (func)", insn);
warnings += ret; warnings += ret;
}
} }
return warnings; 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) static int validate_reachable_instructions(struct objtool_file *file)
{ {
struct instruction *insn; struct instruction *insn;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment