Thread (34 messages) 34 messages, 8 authors, 2022-05-23

Re: [RFC PATCH 2/3] objtool: Enable and implement 'mcount' subcommand

From: Christophe Leroy <hidden>
Date: 2022-03-21 07:06:22
Also in: lkml


Le 18/03/2022 à 11:51, Sathvika Vasireddy a écrit :
quoted hunk ↗ jump to hunk
This patch adds 'mcount' as a subcommand to objtool, and enables
the same for x86. objtool is built if CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
is selected. Additionally, architectures can select HAVE_NOP_MCOUNT
if they choose to nop out mcount call sites. If that config option is
selected, then --mnop is passed as an option to 'objtool mcount'

Signed-off-by: Sathvika Vasireddy <redacted>
---
  Makefile                                |   6 ++
  arch/x86/Kconfig                        |   3 +-
  scripts/Makefile.build                  |  12 +++
  tools/objtool/Build                     |   2 +
  tools/objtool/Makefile                  |   4 +-
  tools/objtool/builtin-mcount.c          |  74 +++++++++++++
  tools/objtool/include/objtool/builtin.h |   4 +-
  tools/objtool/include/objtool/objtool.h |   1 +
  tools/objtool/mcount.c                  | 138 ++++++++++++++++++++++++
  tools/objtool/objtool.c                 |   1 +
  tools/objtool/weak.c                    |   5 +
  11 files changed, 247 insertions(+), 3 deletions(-)
  create mode 100644 tools/objtool/builtin-mcount.c
  create mode 100644 tools/objtool/mcount.c
diff --git a/Makefile b/Makefile
index 55a30ca69350..316f7d08b30a 100644
--- a/Makefile
+++ b/Makefile
@@ -846,7 +846,9 @@ ifdef CONFIG_FTRACE_MCOUNT_USE_CC
    endif
  endif
  ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
+ ifdef CONFIG_HAVE_NOP_MCOUNT
    CC_FLAGS_USING	+= -DCC_USING_NOP_MCOUNT
+ endif
  endif
  ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
    ifdef CONFIG_HAVE_C_RECORDMCOUNT
@@ -1303,6 +1305,10 @@ ifdef CONFIG_STACK_VALIDATION
  prepare: tools/objtool
  endif
  
+ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
+prepare: tools/objtool
+endif
I don't think that will work for powerpc.

See arch/powerpc/Makefile

powerpc builds the VDSO under prepare: , and powerpc has 
CONFIG_HAVE_GENERIC_VDSO so there are some C files in that step that 
seem to use objtool, allthough that looks odd to me. Must be something 
to fix somewhere.

   powerpc64-linux-gcc 
-Wp,-MMD,arch/powerpc/kernel/vdso/.vgettimeofday-64.o.d -nostdinc 
-I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include 
-I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi 
-I./include/uapi -I./include/generated/uapi -include 
./include/linux/compiler-version.h -include ./include/linux/kconfig.h 
-include ./include/linux/compiler_types.h -D__KERNEL__ -I ./arch/powerpc 
-DHAVE_AS_ATHIGH=1 -fmacro-prefix-map=./= -Wall -Wundef 
-Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing 
-fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration 
-Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89 
-mbig-endian -m64 -msoft-float -pipe -mtraceback=no -mabi=elfv1 
-mcall-aixdesc -mcmodel=medium -mno-pointers-to-nested-functions 
-mtune=power7 -mcpu=power5 -mno-altivec -mno-vsx 
-fno-asynchronous-unwind-tables -mno-string -Wa,-maltivec -Wa,-mpower4 
-Wa,-many -mabi=elfv1 -mcall-aixdesc -mbig-endian 
-mstack-protector-guard=tls -mstack-protector-guard-reg=r13 
-fno-delete-null-pointer-checks -Wno-frame-address 
-Wno-format-truncation -Wno-format-overflow 
-Wno-address-of-packed-member -O2 -fno-allow-store-data-races 
-Wframe-larger-than=2048 -fstack-protector-strong 
-Wimplicit-fallthrough=5 -Wno-main -Wno-unused-but-set-variable 
-Wno-unused-const-variable -fno-stack-clash-protection 
-Wdeclaration-after-statement -Wvla -Wno-pointer-sign 
-Wcast-function-type -Wno-stringop-truncation -Wno-zero-length-bounds 
-Wno-array-bounds -Wno-stringop-overflow -Wno-restrict 
-Wno-maybe-uninitialized -Wno-alloc-size-larger-than 
-fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time 
-Werror=incompatible-pointer-types -Werror=designated-init 
-Wno-packed-not-aligned -mstack-protector-guard-offset=3200 -shared 
-fno-common -fno-builtin -nostdlib -Wl,--hash-style=both -include 
/home/chleroy/linux-powerpc/lib/vdso/gettimeofday.c -fno-stack-protector 
-DDISABLE_BRANCH_PROFILING -ffreestanding -fasynchronous-unwind-tables 
-ffixed-r30 
-DKBUILD_MODFILE='"arch/powerpc/kernel/vdso/vgettimeofday-64"' 
-DKBUILD_BASENAME='"vgettimeofday_64"' 
-DKBUILD_MODNAME='"vgettimeofday_64"' 
-D__KBUILD_MODNAME=kmod_vgettimeofday_64 -c -o 
arch/powerpc/kernel/vdso/vgettimeofday-64.o 
arch/powerpc/kernel/vdso/vgettimeofday.c  ; ./tools/objtool/objtool 
mcount arch/powerpc/kernel/vdso/vgettimeofday-64.o

+
  ifdef CONFIG_BPF
  ifdef CONFIG_DEBUG_INFO_BTF
  prepare: tools/bpf/resolve_btfids
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help