summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@kernel.org>2025-09-17 09:03:30 -0700
committerJosh Poimboeuf <jpoimboe@kernel.org>2025-10-14 14:45:24 -0700
commit4cdee7888f42f5573b380ddfa9da43208e759bdc (patch)
tree27ab0f46e3f55c486a454912b04872ab27bd976b /tools
parent68245893cf447cca478e6bd71c02741656053ef4 (diff)
objtool: Fix "unexpected end of section" warning for alternatives
Due to the short circuiting logic in next_insn_to_validate(), control flow may silently transition from .altinstr_replacement to .text without a corresponding nested call to validate_branch(). As a result the validate_branch() 'sec' variable doesn't get reinitialized, which can trigger a confusing "unexpected end of section" warning which blames .altinstr_replacement rather than the offending fallthrough function. Fix that by not caching the section. There's no point in doing that anyway. Acked-by: Petr Mladek <pmladek@suse.com> Tested-by: Joe Lawrence <joe.lawrence@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/objtool/check.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 65eb90034d3e..c2e46f901a53 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -3512,15 +3512,12 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
{
struct alternative *alt;
struct instruction *next_insn, *prev_insn = NULL;
- struct section *sec;
u8 visited;
int ret;
if (func && func->ignore)
return 0;
- sec = insn->sec;
-
while (1) {
next_insn = next_insn_to_validate(file, insn);
@@ -3760,7 +3757,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
WARN("%s%sunexpected end of section %s",
func ? func->name : "", func ? "(): " : "",
- sec->name);
+ insn->sec->name);
return 1;
}