Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

objtool: Limit unreachable warnings to once per function

Unreachable instruction warnings are limited to once per object file.
That no longer makes sense for vmlinux validation, which might have
more unreachable instructions lurking in other places. Change it to
once per function.

Note this affects some other (much rarer) non-fatal warnings as well.
In general I think one-warning-per-function makes sense, as related
warnings can accumulate quickly and we want to eventually get back to
failing the build with -Werror anyway.

Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lore.kernel.org/r/9d38f881bfc34e031c74e4e90064ccb3e49f599a.1681853186.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

+10 -3
+3 -2
tools/objtool/check.c
··· 4514 4514 static int validate_reachable_instructions(struct objtool_file *file) 4515 4515 { 4516 4516 struct instruction *insn; 4517 + int warnings = 0; 4517 4518 4518 4519 if (file->ignore_unreachables) 4519 4520 return 0; ··· 4524 4523 continue; 4525 4524 4526 4525 WARN_INSN(insn, "unreachable instruction"); 4527 - return 1; 4526 + warnings++; 4528 4527 } 4529 4528 4530 - return 0; 4529 + return warnings; 4531 4530 } 4532 4531 4533 4532 int check(struct objtool_file *file)
+1
tools/objtool/include/objtool/elf.h
··· 61 61 u8 return_thunk : 1; 62 62 u8 fentry : 1; 63 63 u8 profiling_func : 1; 64 + u8 warned : 1; 64 65 struct list_head pv_target; 65 66 struct list_head reloc_list; 66 67 };
+6 -1
tools/objtool/include/objtool/warn.h
··· 55 55 56 56 #define WARN_INSN(insn, format, ...) \ 57 57 ({ \ 58 - WARN_FUNC(format, insn->sec, insn->offset, ##__VA_ARGS__); \ 58 + struct instruction *_insn = (insn); \ 59 + if (!_insn->sym || !_insn->sym->warned) \ 60 + WARN_FUNC(format, _insn->sec, _insn->offset, \ 61 + ##__VA_ARGS__); \ 62 + if (_insn->sym) \ 63 + _insn->sym->warned = 1; \ 59 64 }) 60 65 61 66 #define BT_FUNC(format, insn, ...) \