Re: [PATCH v6 02/25] objtool: Add a pass for generating __mcount_loc
From: Ingo Molnar
Date: Wed Oct 14 2020 - 12:50:10 EST
* Sami Tolvanen <samitolvanen@xxxxxxxxxx> wrote:
> From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
>
> Add the --mcount option for generating __mcount_loc sections
> needed for dynamic ftrace. Using this pass requires the kernel to
> be compiled with -mfentry and CC_USING_NOP_MCOUNT to be defined
> in Makefile.
>
> Link: https://lore.kernel.org/lkml/20200625200235.GQ4781@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
> Signed-off-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> [Sami: rebased, dropped config changes, fixed to actually use --mcount,
> and wrote a commit message.]
> Signed-off-by: Sami Tolvanen <samitolvanen@xxxxxxxxxx>
> Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>
> ---
> tools/objtool/builtin-check.c | 3 +-
> tools/objtool/builtin.h | 2 +-
> tools/objtool/check.c | 82 +++++++++++++++++++++++++++++++++++
> tools/objtool/check.h | 1 +
> tools/objtool/objtool.c | 1 +
> tools/objtool/objtool.h | 1 +
> 6 files changed, 88 insertions(+), 2 deletions(-)
>
> diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
> index c6d199bfd0ae..e92e76f69176 100644
> --- a/tools/objtool/builtin-check.c
> +++ b/tools/objtool/builtin-check.c
> @@ -18,7 +18,7 @@
> #include "builtin.h"
> #include "objtool.h"
>
> -bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats, validate_dup, vmlinux;
> +bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats, validate_dup, vmlinux, mcount;
>
> static const char * const check_usage[] = {
> "objtool check [<options>] file.o",
> @@ -35,6 +35,7 @@ const struct option check_options[] = {
> OPT_BOOLEAN('s', "stats", &stats, "print statistics"),
> OPT_BOOLEAN('d', "duplicate", &validate_dup, "duplicate validation for vmlinux.o"),
> OPT_BOOLEAN('l', "vmlinux", &vmlinux, "vmlinux.o validation"),
> + OPT_BOOLEAN('M', "mcount", &mcount, "generate __mcount_loc"),
> OPT_END(),
> };
Meh, adding --mcount as an option to 'objtool check' was a valid hack for a
prototype patchset, but please turn this into a proper subcommand, just
like 'objtool orc' is.
'objtool check' should ... keep checking. :-)
Thanks,
Ingo