Skip to content

Commit 350994b

Browse files
author
Peter Zijlstra
committed
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) <[email protected]> Reviewed-by: Miroslav Benes <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 74b873e commit 350994b

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

tools/objtool/check.c

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,9 +2395,8 @@ static bool ignore_unreachable_insn(struct instruction *insn)
23952395
return false;
23962396
}
23972397

2398-
static int validate_functions(struct objtool_file *file)
2398+
static int validate_section(struct objtool_file *file, struct section *sec)
23992399
{
2400-
struct section *sec;
24012400
struct symbol *func;
24022401
struct instruction *insn;
24032402
struct insn_state state;
@@ -2410,36 +2409,45 @@ static int validate_functions(struct objtool_file *file)
24102409
CFI_NUM_REGS * sizeof(struct cfi_reg));
24112410
state.stack_size = initial_func_cfi.cfa.offset;
24122411

2413-
for_each_sec(file, sec) {
2414-
list_for_each_entry(func, &sec->symbol_list, list) {
2415-
if (func->type != STT_FUNC)
2416-
continue;
2412+
list_for_each_entry(func, &sec->symbol_list, list) {
2413+
if (func->type != STT_FUNC)
2414+
continue;
24172415

2418-
if (!func->len) {
2419-
WARN("%s() is missing an ELF size annotation",
2420-
func->name);
2421-
warnings++;
2422-
}
2416+
if (!func->len) {
2417+
WARN("%s() is missing an ELF size annotation",
2418+
func->name);
2419+
warnings++;
2420+
}
24232421

2424-
if (func->pfunc != func || func->alias != func)
2425-
continue;
2422+
if (func->pfunc != func || func->alias != func)
2423+
continue;
24262424

2427-
insn = find_insn(file, sec, func->offset);
2428-
if (!insn || insn->ignore || insn->visited)
2429-
continue;
2425+
insn = find_insn(file, sec, func->offset);
2426+
if (!insn || insn->ignore || insn->visited)
2427+
continue;
24302428

2431-
state.uaccess = func->uaccess_safe;
2429+
state.uaccess = func->uaccess_safe;
24322430

2433-
ret = validate_branch(file, func, insn, state);
2434-
if (ret && backtrace)
2435-
BT_FUNC("<=== (func)", insn);
2436-
warnings += ret;
2437-
}
2431+
ret = validate_branch(file, func, insn, state);
2432+
if (ret && backtrace)
2433+
BT_FUNC("<=== (func)", insn);
2434+
warnings += ret;
24382435
}
24392436

24402437
return warnings;
24412438
}
24422439

2440+
static int validate_functions(struct objtool_file *file)
2441+
{
2442+
struct section *sec;
2443+
int warnings = 0;
2444+
2445+
for_each_sec(file, sec)
2446+
warnings += validate_section(file, sec);
2447+
2448+
return warnings;
2449+
}
2450+
24432451
static int validate_reachable_instructions(struct objtool_file *file)
24442452
{
24452453
struct instruction *insn;

0 commit comments

Comments
 (0)