Skip to content

Commit 4b5e2e7

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
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) <[email protected]> Reviewed-by: Miroslav Benes <[email protected]> Reviewed-by: Alexandre Chartre <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent da837bd commit 4b5e2e7

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

tools/objtool/check.c

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,12 +2486,37 @@ static bool ignore_unreachable_insn(struct instruction *insn)
24862486
return false;
24872487
}
24882488

2489-
static int validate_section(struct objtool_file *file, struct section *sec)
2489+
static int validate_symbol(struct objtool_file *file, struct section *sec,
2490+
struct symbol *sym, struct insn_state *state)
24902491
{
2491-
struct symbol *func;
24922492
struct instruction *insn;
2493+
int ret;
2494+
2495+
if (!sym->len) {
2496+
WARN("%s() is missing an ELF size annotation", sym->name);
2497+
return 1;
2498+
}
2499+
2500+
if (sym->pfunc != sym || sym->alias != sym)
2501+
return 0;
2502+
2503+
insn = find_insn(file, sec, sym->offset);
2504+
if (!insn || insn->ignore || insn->visited)
2505+
return 0;
2506+
2507+
state->uaccess = sym->uaccess_safe;
2508+
2509+
ret = validate_branch(file, insn->func, insn, *state);
2510+
if (ret && backtrace)
2511+
BT_FUNC("<=== (sym)", insn);
2512+
return ret;
2513+
}
2514+
2515+
static int validate_section(struct objtool_file *file, struct section *sec)
2516+
{
24932517
struct insn_state state;
2494-
int ret, warnings = 0;
2518+
struct symbol *func;
2519+
int warnings = 0;
24952520

24962521
/*
24972522
* 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)
25052530
if (func->type != STT_FUNC)
25062531
continue;
25072532

2508-
if (!func->len) {
2509-
WARN("%s() is missing an ELF size annotation",
2510-
func->name);
2511-
warnings++;
2512-
}
2513-
2514-
if (func->pfunc != func || func->alias != func)
2515-
continue;
2516-
2517-
insn = find_insn(file, sec, func->offset);
2518-
if (!insn || insn->ignore || insn->visited)
2519-
continue;
2520-
25212533
clear_insn_state(&state);
25222534
state.cfi.cfa = initial_func_cfi.cfa;
25232535
memcpy(&state.cfi.regs, &initial_func_cfi.regs,
25242536
CFI_NUM_REGS * sizeof(struct cfi_reg));
25252537
state.cfi.stack_size = initial_func_cfi.cfa.offset;
25262538

2527-
state.uaccess = func->uaccess_safe;
2528-
2529-
ret = validate_branch(file, func, insn, state);
2530-
if (ret && backtrace)
2531-
BT_FUNC("<=== (func)", insn);
2532-
warnings += ret;
2539+
warnings += validate_symbol(file, sec, func, &state);
25332540
}
25342541

25352542
return warnings;

0 commit comments

Comments
 (0)