When passing a NULL @sec to validate_unwind_hints(), it is unable to properly initialize the insn_state->noinstr passed down during validation. This means we lose noinstr validation of the hints. That validation currently happens when 'opts.noinstr' is true but 'validate_branch_enabled()' isn't. In other words, this will run noinstr validation of hints: $ objtool --noinstr --link [...] but this won't: $ objtool --noinstr --link --uaccess [...] Always pass a valid section to validate_unwind_hints(), so that noinstr validation of hints happens regardless of the value of validate_branch_enabled(). Signed-off-by: Valentin Schneider --- tools/objtool/check.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 418dce921e48d..b6e63d5beecc3 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4064,13 +4064,8 @@ static int validate_unwind_hints(struct objtool_file *file, struct section *sec) init_insn_state(file, &state, sec); - if (sec) { - sec_for_each_insn(file, sec, insn) - warnings += validate_unwind_hint(file, insn, &state); - } else { - for_each_insn(file, insn) - warnings += validate_unwind_hint(file, insn, &state); - } + sec_for_each_insn(file, sec, insn) + warnings += validate_unwind_hint(file, insn, &state); return warnings; } @@ -4567,6 +4562,21 @@ static int validate_functions(struct objtool_file *file) return warnings; } +static int validate_file_unwind_hints(struct objtool_file *file) +{ + struct section *sec; + int warnings = 0; + + for_each_sec(file->elf, sec) { + if (!is_text_sec(sec)) + continue; + + warnings += validate_unwind_hints(file, sec); + } + + return warnings; +} + static void mark_endbr_used(struct instruction *insn) { if (!list_empty(&insn->call_node)) @@ -4976,7 +4986,8 @@ int check(struct objtool_file *file) int w = 0; w += validate_functions(file); - w += validate_unwind_hints(file, NULL); + w += validate_file_unwind_hints(file); + if (!w) w += validate_reachable_instructions(file); -- 2.52.0