ftrace: Add arm64 support to recordmcount
authorAKASHI Takahiro <takahiro.akashi@linaro.org>
Wed, 30 Apr 2014 09:54:32 +0000 (18:54 +0900)
committerMark Brown <broonie@linaro.org>
Fri, 30 May 2014 17:15:42 +0000 (18:15 +0100)
Recordmcount utility under scripts is run, after compiling each object,
to find out all the locations of calling _mcount() and put them into
specific seciton named __mcount_loc.
Then linker collects all such information into a table in the kernel image
(between __start_mcount_loc and __stop_mcount_loc) for later use by ftrace.

This patch adds arm64 specific definitions to identify such locations.
There are two types of implementation, C and Perl. On arm64, only C version
is used to build the kernel now that CONFIG_HAVE_C_RECORDMCOUNT is on.
But Perl version is also maintained.

This patch also contains a workaround just in case where a header file,
elf.h, on host machine doesn't have definitions of EM_AARCH64 nor
R_AARCH64_ABS64. Without them, compiling C version of recordmcount will
fail.

Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
arch/arm64/Kconfig
scripts/recordmcount.c
scripts/recordmcount.pl

index 8a3aa8f7729fa941fb2a316704a01e303ecc26c0..3074a2db94254fe9d53ea0ebe52e796d9c9a3ab2 100644 (file)
@@ -18,10 +18,12 @@ config ARM64
        select HARDIRQS_SW_RESEND
        select HAVE_ARCH_JUMP_LABEL
        select HAVE_ARCH_TRACEHOOK
+       select HAVE_C_RECORDMCOUNT
        select HAVE_DEBUG_BUGVERBOSE
        select HAVE_DEBUG_KMEMLEAK
        select HAVE_DMA_API_DEBUG
        select HAVE_DMA_ATTRS
+       select HAVE_FTRACE_MCOUNT_RECORD
        select HAVE_GENERIC_DMA_COHERENT
        select HAVE_GENERIC_HARDIRQS
        select HAVE_HW_BREAKPOINT if PERF_EVENTS
index 9c22317778eb7e3f995c73845cfcceba15062739..e11aa4a156d2d26df48706d0da0a7970813e9798 100644 (file)
 #define R_METAG_NONE                     3
 #endif
 
+#ifndef EM_AARCH64
+#define EM_AARCH64     183
+#define R_AARCH64_ABS64        257
+#endif
+
 static int fd_map;     /* File descriptor for file being modified. */
 static int mmap_failed; /* Boolean flag. */
 static void *ehdr_curr; /* current ElfXX_Ehdr *  for resource cleanup */
@@ -347,6 +352,8 @@ do_file(char const *const fname)
        case EM_ARM:     reltype = R_ARM_ABS32;
                         altmcount = "__gnu_mcount_nc";
                         break;
+       case EM_AARCH64:
+                        reltype = R_AARCH64_ABS64; gpfx = '_'; break;
        case EM_IA_64:   reltype = R_IA64_IMM64;   gpfx = '_'; break;
        case EM_METAG:   reltype = R_METAG_ADDR32;
                         altmcount = "_mcount_wrapper";
index 858966ab019cc1951724b3a2f47b4bfd5b892bf6..151739b4e4814aece1f0d8747994f3be1bd888bf 100755 (executable)
@@ -279,6 +279,11 @@ if ($arch eq "x86_64") {
     $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_ARM_(CALL|PC24|THM_CALL)" .
                        "\\s+(__gnu_mcount_nc|mcount)\$";
 
+} elsif ($arch eq "arm64") {
+    $alignment = 3;
+    $section_type = '%progbits';
+    $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_AARCH64_CALL26\\s+_mcount\$";
+    $type = ".quad";
 } elsif ($arch eq "ia64") {
     $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
     $type = "data8";