Skip to content

Commit 22c8542

Browse files
samitolvanenkees
authored andcommitted
tracing: add support for objtool mcount
This change adds build support for using objtool to generate __mcount_loc sections. Signed-off-by: Sami Tolvanen <[email protected]>
1 parent 0e731db commit 22c8542

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,9 @@ ifdef CONFIG_FTRACE_MCOUNT_USE_CC
860860
endif
861861
endif
862862
endif
863+
ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
864+
CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
865+
endif
863866
ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
864867
ifdef CONFIG_HAVE_C_RECORDMCOUNT
865868
BUILD_C_RECORDMCOUNT := y
@@ -1236,6 +1239,10 @@ uapi-asm-generic:
12361239
PHONY += prepare-objtool prepare-resolve_btfids
12371240
prepare-objtool: $(objtool_target)
12381241
ifeq ($(SKIP_STACK_VALIDATION),1)
1242+
ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
1243+
@echo "error: Cannot generate __mcount_loc for CONFIG_DYNAMIC_FTRACE=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
1244+
@false
1245+
endif
12391246
ifdef CONFIG_UNWINDER_ORC
12401247
@echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
12411248
@false

kernel/trace/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ config HAVE_NOP_MCOUNT
6060
help
6161
Arch supports the gcc options -pg with -mrecord-mcount and -nop-mcount
6262

63+
config HAVE_OBJTOOL_MCOUNT
64+
bool
65+
help
66+
Arch supports objtool --mcount
67+
6368
config HAVE_C_RECORDMCOUNT
6469
bool
6570
help
@@ -612,10 +617,18 @@ config FTRACE_MCOUNT_USE_CC
612617
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
613618
depends on FTRACE_MCOUNT_RECORD
614619

620+
config FTRACE_MCOUNT_USE_OBJTOOL
621+
def_bool y
622+
depends on HAVE_OBJTOOL_MCOUNT
623+
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
624+
depends on !FTRACE_MCOUNT_USE_CC
625+
depends on FTRACE_MCOUNT_RECORD
626+
615627
config FTRACE_MCOUNT_USE_RECORDMCOUNT
616628
def_bool y
617629
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
618630
depends on !FTRACE_MCOUNT_USE_CC
631+
depends on !FTRACE_MCOUNT_USE_OBJTOOL
619632
depends on FTRACE_MCOUNT_RECORD
620633

621634
config TRACING_MAP

scripts/Makefile.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ endif
238238
ifdef CONFIG_X86_SMAP
239239
objtool_args += --uaccess
240240
endif
241+
ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
242+
objtool_args += --mcount
243+
endif
241244

242245
# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
243246
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file

0 commit comments

Comments
 (0)