]> git.baikalelectronics.ru Git - kernel.git/commitdiff
tracing: add support for objtool mcount
authorSami Tolvanen <samitolvanen@google.com>
Fri, 25 Sep 2020 23:43:53 +0000 (16:43 -0700)
committerKees Cook <keescook@chromium.org>
Tue, 23 Feb 2021 20:46:57 +0000 (12:46 -0800)
This change adds build support for using objtool to generate
__mcount_loc sections.

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Makefile
kernel/trace/Kconfig
scripts/Makefile.build

index 2233951666f76eb9d6142475d49e70d40eb80f2a..3189eacf3185921af015f74635f7dfb06d733560 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -860,6 +860,9 @@ ifdef CONFIG_FTRACE_MCOUNT_USE_CC
     endif
   endif
 endif
+ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
+  CC_FLAGS_USING       += -DCC_USING_NOP_MCOUNT
+endif
 ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
   ifdef CONFIG_HAVE_C_RECORDMCOUNT
     BUILD_C_RECORDMCOUNT := y
@@ -1236,6 +1239,10 @@ uapi-asm-generic:
 PHONY += prepare-objtool prepare-resolve_btfids
 prepare-objtool: $(objtool_target)
 ifeq ($(SKIP_STACK_VALIDATION),1)
+ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
+       @echo "error: Cannot generate __mcount_loc for CONFIG_DYNAMIC_FTRACE=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
+       @false
+endif
 ifdef CONFIG_UNWINDER_ORC
        @echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
        @false
index 3985a31a49b7f1355d4632af760ce98d611c8b67..936ccab1b938eeda4a0243bf08250f984abefe4e 100644 (file)
@@ -60,6 +60,11 @@ config HAVE_NOP_MCOUNT
        help
          Arch supports the gcc options -pg with -mrecord-mcount and -nop-mcount
 
+config HAVE_OBJTOOL_MCOUNT
+       bool
+       help
+         Arch supports objtool --mcount
+
 config HAVE_C_RECORDMCOUNT
        bool
        help
@@ -612,10 +617,18 @@ config FTRACE_MCOUNT_USE_CC
        depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
        depends on FTRACE_MCOUNT_RECORD
 
+config FTRACE_MCOUNT_USE_OBJTOOL
+       def_bool y
+       depends on HAVE_OBJTOOL_MCOUNT
+       depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
+       depends on !FTRACE_MCOUNT_USE_CC
+       depends on FTRACE_MCOUNT_RECORD
+
 config FTRACE_MCOUNT_USE_RECORDMCOUNT
        def_bool y
        depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
        depends on !FTRACE_MCOUNT_USE_CC
+       depends on !FTRACE_MCOUNT_USE_OBJTOOL
        depends on FTRACE_MCOUNT_RECORD
 
 config TRACING_MAP
index d94fc9ab819d30c6b24c5d657098a4cb61b0d69b..59fabd9685eeca5057e034afd7691f85f3d854c6 100644 (file)
@@ -238,6 +238,9 @@ endif
 ifdef CONFIG_X86_SMAP
   objtool_args += --uaccess
 endif
+ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
+  objtool_args += --mcount
+endif
 
 # 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file