Re: [PATCH 4/5] objtool: Add per-function rate limiting for unreachable warnings

From: Miroslav Benes
Date: Tue Mar 28 2023 - 05:07:50 EST


On Mon, 27 Mar 2023, Josh Poimboeuf wrote:

> Unreachable instruction warnings are rate limited to once per object
> file. That no longer makes sense for vmlinux validation, which might
> have other unreachable instructions lurking in other places. Change it
> to once per function.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> ---
> tools/objtool/check.c | 4 ++++
> tools/objtool/include/objtool/elf.h | 1 +
> 2 files changed, 5 insertions(+)
>
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 73dd091c0075..67a684225702 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -4557,6 +4557,10 @@ static int validate_reachable_instructions(struct objtool_file *file)
> if (insn->visited || ignore_unreachable_insn(file, insn))
> continue;
>
> + if (insn->sym->warned)
> + continue;
> + insn->sym->warned = 1;
> +

Ok

> WARN_FUNC("unreachable instruction", insn->sec, insn->offset);
> return 1;

But we still return here when an unreachable instruction is encountered
and warned about. Or maybe I am just misunderstanding the purpose.

If not, would it be better to just collect the number of warnings per
object as we do elsewhere?

warnings++;

and then at the end

return warnings;

Miroslav