[PATCH 14/15] ftrace/x86: mcount offset calculation

From: Steven Rostedt
Date: Wed May 18 2011 - 12:09:53 EST


From: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>

Do the mcount offset adjustment in the recordmcount.pl/recordmcount.[ch]
at compile time and not in ftrace_call_adjust at run time.

Signed-off-by: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
arch/x86/include/asm/ftrace.h | 7 +++----
scripts/recordmcount.c | 2 ++
scripts/recordmcount.pl | 2 ++
3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
index db24c22..268c783 100644
--- a/arch/x86/include/asm/ftrace.h
+++ b/arch/x86/include/asm/ftrace.h
@@ -38,11 +38,10 @@ extern void mcount(void);
static inline unsigned long ftrace_call_adjust(unsigned long addr)
{
/*
- * call mcount is "e8 <4 byte offset>"
- * The addr points to the 4 byte offset and the caller of this
- * function wants the pointer to e8. Simply subtract one.
+ * addr is the address of the mcount call instruction.
+ * recordmcount does the necessary offset calculation.
*/
- return addr - 1;
+ return addr;
}

#ifdef CONFIG_DYNAMIC_FTRACE
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 0e18975..7648a5d 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -335,6 +335,7 @@ do_file(char const *const fname)
reltype = R_386_32;
make_nop = make_nop_x86;
ideal_nop = ideal_nop5_x86_32;
+ mcount_adjust_32 = -1;
break;
case EM_ARM: reltype = R_ARM_ABS32;
altmcount = "__gnu_mcount_nc";
@@ -350,6 +351,7 @@ do_file(char const *const fname)
make_nop = make_nop_x86;
ideal_nop = ideal_nop5_x86_64;
reltype = R_X86_64_64;
+ mcount_adjust_64 = -1;
break;
} /* end switch */

diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index a871cd4..414e7f5 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -223,6 +223,7 @@ if ($arch eq "x86_64") {
$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$";
$type = ".quad";
$alignment = 8;
+ $mcount_adjust = -1;

# force flags for this arch
$ld .= " -m elf_x86_64";
@@ -232,6 +233,7 @@ if ($arch eq "x86_64") {

} elsif ($arch eq "i386") {
$alignment = 4;
+ $mcount_adjust = -1;

# force flags for this arch
$ld .= " -m elf_i386";
--
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/