objtool: Rearrange validate_section()
In preparation of further changes, once again break out the loop body. No functional changes intended. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Miroslav Benes <mbenes@suse.cz> Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Link: https://lkml.kernel.org/r/20200416115119.405863817@infradead.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Родитель
da837bd6f1
Коммит
4b5e2e7ffe
|
@ -2486,12 +2486,37 @@ static bool ignore_unreachable_insn(struct instruction *insn)
|
|||
return false;
|
||||
}
|
||||
|
||||
static int validate_symbol(struct objtool_file *file, struct section *sec,
|
||||
struct symbol *sym, struct insn_state *state)
|
||||
{
|
||||
struct instruction *insn;
|
||||
int ret;
|
||||
|
||||
if (!sym->len) {
|
||||
WARN("%s() is missing an ELF size annotation", sym->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (sym->pfunc != sym || sym->alias != sym)
|
||||
return 0;
|
||||
|
||||
insn = find_insn(file, sec, sym->offset);
|
||||
if (!insn || insn->ignore || insn->visited)
|
||||
return 0;
|
||||
|
||||
state->uaccess = sym->uaccess_safe;
|
||||
|
||||
ret = validate_branch(file, insn->func, insn, *state);
|
||||
if (ret && backtrace)
|
||||
BT_FUNC("<=== (sym)", insn);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int validate_section(struct objtool_file *file, struct section *sec)
|
||||
{
|
||||
struct symbol *func;
|
||||
struct instruction *insn;
|
||||
struct insn_state state;
|
||||
int ret, warnings = 0;
|
||||
struct symbol *func;
|
||||
int warnings = 0;
|
||||
|
||||
/*
|
||||
* We need the full vmlinux for noinstr validation, otherwise we can
|
||||
|
@ -2505,31 +2530,13 @@ static int validate_section(struct objtool_file *file, struct section *sec)
|
|||
if (func->type != STT_FUNC)
|
||||
continue;
|
||||
|
||||
if (!func->len) {
|
||||
WARN("%s() is missing an ELF size annotation",
|
||||
func->name);
|
||||
warnings++;
|
||||
}
|
||||
|
||||
if (func->pfunc != func || func->alias != func)
|
||||
continue;
|
||||
|
||||
insn = find_insn(file, sec, func->offset);
|
||||
if (!insn || insn->ignore || insn->visited)
|
||||
continue;
|
||||
|
||||
clear_insn_state(&state);
|
||||
state.cfi.cfa = initial_func_cfi.cfa;
|
||||
memcpy(&state.cfi.regs, &initial_func_cfi.regs,
|
||||
CFI_NUM_REGS * sizeof(struct cfi_reg));
|
||||
state.cfi.stack_size = initial_func_cfi.cfa.offset;
|
||||
|
||||
state.uaccess = func->uaccess_safe;
|
||||
|
||||
ret = validate_branch(file, func, insn, state);
|
||||
if (ret && backtrace)
|
||||
BT_FUNC("<=== (func)", insn);
|
||||
warnings += ret;
|
||||
warnings += validate_symbol(file, sec, func, &state);
|
||||
}
|
||||
|
||||
return warnings;
|
||||
|
|
Загрузка…
Ссылка в новой задаче