[PATCH v9 03/10] objtool: Always pass a section to validate_unwind_hints()

Valentin Schneider
2026-05-05T08:25:39Z

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 <vschneid@redhat.com>
---
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 ba943bbbc51db..2bb927aa34047 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4118,13 +4118,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;
}
@@ -4621,6 +4616,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))
@@ -5030,7 +5040,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