riscv/ftrace: Add RECORD_MCOUNT support
authorAlan Kao <alankao@andestech.com>
Tue, 13 Feb 2018 05:13:16 +0000 (13:13 +0800)
committerPalmer Dabbelt <palmer@sifive.com>
Tue, 3 Apr 2018 02:59:10 +0000 (19:59 -0700)
Now recordmcount.pl recognizes RISC-V object files. For the mechanism to
work, we have to disable the linker relaxation.

Cc: Greentime Hu <greentime@andestech.com>
Signed-off-by: Alan Kao <alankao@andestech.com>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
arch/riscv/Kconfig
arch/riscv/Makefile
scripts/recordmcount.pl

index 04807c7f64cc58f7b2e4be1ec1d10b4cf1b018a8..c9ccc6ea43710bdbb44201dcb393ccb9dcaa441c 100644 (file)
@@ -114,6 +114,7 @@ config ARCH_RV64I
        select 64BIT
        select HAVE_FUNCTION_TRACER
        select HAVE_FUNCTION_GRAPH_TRACER
+       select HAVE_FTRACE_MCOUNT_RECORD
 
 endchoice
 
index 6719dd30ec5b847b58faa3521ea3ccd74fd6dddc..899226e0da7d3328e152e614af3c6fa03ee8c495 100644 (file)
@@ -11,6 +11,9 @@
 LDFLAGS         :=
 OBJCOPYFLAGS    := -O binary
 LDFLAGS_vmlinux :=
+ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
+       LDFLAGS_vmlinux := --no-relax
+endif
 KBUILD_AFLAGS_MODULE += -fPIC
 KBUILD_CFLAGS_MODULE += -fPIC
 
index 2033af758173c7c02ed02b77b8c8686a43201ad6..d44d55db7c0675b28dac5e5cb8749d9d0265fa31 100755 (executable)
@@ -376,6 +376,11 @@ if ($arch eq "x86_64") {
     $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s__mcount\$";
     $type = ".quad";
     $alignment = 8;
+} elsif ($arch eq "riscv") {
+    $function_regex = "^([0-9a-fA-F]+)\\s+<([^.0-9][0-9a-zA-Z_\\.]+)>:";
+    $mcount_regex = "^\\s*([0-9a-fA-F]+):\\sR_RISCV_CALL\\s_mcount\$";
+    $type = ".quad";
+    $alignment = 2;
 } else {
     die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD";
 }