Re: [RFC PATCH 0/3] objtool: Add mcount sub-command

From: Josh Poimboeuf
Date: Fri Mar 18 2022 - 21:53:01 EST


On Fri, Mar 18, 2022 at 04:21:37PM +0530, Sathvika Vasireddy wrote:
> This patchset adds support to implement 'objtool mcount' command.
>
> Right now, objtool is built if CONFIG_STACK_VALIDATION is enabled.
> And, '__mcount_loc' section is generated by objtool when --mcount
> option is passed to check sub-command.
>
> For architectures to be able to generate '__mcount_loc' section
> without having to do stack validation, introduce 'mcount' as
> a sub-command to objtool. This way, objtool is built for mcount
> if CONFIG_FTRACE_MCOUNT_USE_OBJTOOL is enabled. Additionally,
> architectures can select HAVE_NOP_MCOUNT to be able to nop out
> mcount call sites.
>
> TODO: Enable "objtool mcount" for clang LTO builds.
>
> Sathvika Vasireddy (3):
> objtool: Move common code to utils.c
> objtool: Enable and implement 'mcount' subcommand
> objtool/mcount: Add powerpc specific functions

Hi Sathvika,

Thanks for the patches!

I have some other patches in progress which will rework the objtool
interface by modularizing the cmdline options, so that each option can
be specified either individually or in combination. Even stack
validation itself will be its own separate option.

I think it will help your situation as well: "objtool run --mcount" will
only do '__mcount_loc' generation and nothing else.

Something like so:

$ ./objtool run --help

Usage: objtool run [<options>] file.o

Commands (at least one required):
-a, --uaccess validate uaccess
-c, --static-call annotate static calls
-i, --ibt validate and annotate IBT
-m, --mcount generate '__mcount_loc' section
-n, --noinstr validate noinstr
-o, --orc generate ORC metadata
-r, --retpoline validate retpoline usage
-S, --sls validate straight-line-speculation mitigation
-s, --stack-val validate stack metadata

Options:
--backtrace unwind on error
--backup create .orig files before modification
--dry-run don't write the modifications
--fp object uses frame pointers
--module object will be part of a kernel module
--no-unreachable skip 'unreachable instruction' warnings
--stats print statistics
--vmlinux object is vmlinux.o


Hopefully I'll have the patches ready soon.

--
Josh