Commit 07d8b595 authored by Martin Schwidefsky's avatar Martin Schwidefsky Committed by Steven Rostedt

ftrace/recordmcount: mcount address adjustment

Introduce mcount_adjust{,_32,_64} to the C implementation of
recordmcount analog to $mcount_adjust in the perl script.
The adjustment is added to the address of the relocations
against the mcount symbol. If this adjustment is done by
recordmcount at compile time the ftrace_call_adjust function
can be turned into a nop.

Cc: John Reiser <jreiser@bitwagon.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 41b402a2
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#undef is_fake_mcount #undef is_fake_mcount
#undef fn_is_fake_mcount #undef fn_is_fake_mcount
#undef MIPS_is_fake_mcount #undef MIPS_is_fake_mcount
#undef mcount_adjust
#undef sift_rel_mcount #undef sift_rel_mcount
#undef nop_mcount #undef nop_mcount
#undef find_secsym_ndx #undef find_secsym_ndx
...@@ -63,6 +64,7 @@ ...@@ -63,6 +64,7 @@
# define is_fake_mcount is_fake_mcount64 # define is_fake_mcount is_fake_mcount64
# define fn_is_fake_mcount fn_is_fake_mcount64 # define fn_is_fake_mcount fn_is_fake_mcount64
# define MIPS_is_fake_mcount MIPS64_is_fake_mcount # define MIPS_is_fake_mcount MIPS64_is_fake_mcount
# define mcount_adjust mcount_adjust_64
# define Elf_Addr Elf64_Addr # define Elf_Addr Elf64_Addr
# define Elf_Ehdr Elf64_Ehdr # define Elf_Ehdr Elf64_Ehdr
# define Elf_Shdr Elf64_Shdr # define Elf_Shdr Elf64_Shdr
...@@ -94,6 +96,7 @@ ...@@ -94,6 +96,7 @@
# define is_fake_mcount is_fake_mcount32 # define is_fake_mcount is_fake_mcount32
# define fn_is_fake_mcount fn_is_fake_mcount32 # define fn_is_fake_mcount fn_is_fake_mcount32
# define MIPS_is_fake_mcount MIPS32_is_fake_mcount # define MIPS_is_fake_mcount MIPS32_is_fake_mcount
# define mcount_adjust mcount_adjust_32
# define Elf_Addr Elf32_Addr # define Elf_Addr Elf32_Addr
# define Elf_Ehdr Elf32_Ehdr # define Elf_Ehdr Elf32_Ehdr
# define Elf_Shdr Elf32_Shdr # define Elf_Shdr Elf32_Shdr
...@@ -132,6 +135,8 @@ static void fn_ELF_R_INFO(Elf_Rel *const rp, unsigned sym, unsigned type) ...@@ -132,6 +135,8 @@ static void fn_ELF_R_INFO(Elf_Rel *const rp, unsigned sym, unsigned type)
} }
static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_ELF_R_INFO; static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_ELF_R_INFO;
static int mcount_adjust = 0;
/* /*
* MIPS mcount long call has 2 _mcount symbols, only the position of the 1st * MIPS mcount long call has 2 _mcount symbols, only the position of the 1st
* _mcount symbol is needed for dynamic function tracer, with it, to disable * _mcount symbol is needed for dynamic function tracer, with it, to disable
...@@ -317,8 +322,8 @@ static uint_t *sift_rel_mcount(uint_t *mlocp, ...@@ -317,8 +322,8 @@ static uint_t *sift_rel_mcount(uint_t *mlocp,
mcountsym = get_mcountsym(sym0, relp, str0); mcountsym = get_mcountsym(sym0, relp, str0);
if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) { if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) {
uint_t const addend = _w(_w(relp->r_offset) - recval); uint_t const addend =
_w(_w(relp->r_offset) - recval + mcount_adjust);
mrelp->r_offset = _w(offbase mrelp->r_offset = _w(offbase
+ ((void *)mlocp - (void *)mloc0)); + ((void *)mlocp - (void *)mloc0));
Elf_r_info(mrelp, recsym, reltype); Elf_r_info(mrelp, recsym, reltype);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment