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 Makefile | 6 + arch/powerpc/Kconfig | 1 + arch/x86/Kconfig | 3 +- scripts/Makefile.build | 12 + tools/objtool/Build | 3 + tools/objtool/Makefile | 8 +- tools/objtool/arch/powerpc/Build | 1 + tools/objtool/arch/powerpc/decode.c | 51 +++++ .../arch/powerpc/include/arch/cfi_regs.h | 37 +++ tools/objtool/arch/powerpc/include/arch/elf.h | 8 + tools/objtool/builtin-mcount.c | 74 ++++++ tools/objtool/check.c | 178 +-------------- tools/objtool/include/objtool/builtin.h | 4 +- tools/objtool/include/objtool/check.h | 2 - tools/objtool/include/objtool/objtool.h | 1 + tools/objtool/include/objtool/utils.h | 28 +++ tools/objtool/mcount.c | 138 ++++++++++++ tools/objtool/objtool.c | 1 + tools/objtool/orc_gen.c | 1 + tools/objtool/utils.c | 210 ++++++++++++++++++ tools/objtool/weak.c | 5 + 21 files changed, 590 insertions(+), 182 deletions(-) create mode 100644 tools/objtool/arch/powerpc/Build create mode 100644 tools/objtool/arch/powerpc/decode.c create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h create mode 100644 tools/objtool/builtin-mcount.c create mode 100644 tools/objtool/include/objtool/utils.h create mode 100644 tools/objtool/mcount.c create mode 100644 tools/objtool/utils.c -- 2.31.1