Commit 07d8b595f367f4604e6027ad4cba33cbe3f55e10

Authored by Martin Schwidefsky
Committed by Steven Rostedt
1 parent 41b402a201

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: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Showing 1 changed file with 7 additions and 2 deletions Side-by-side Diff

scripts/recordmcount.h
... ... @@ -22,6 +22,7 @@
22 22 #undef is_fake_mcount
23 23 #undef fn_is_fake_mcount
24 24 #undef MIPS_is_fake_mcount
  25 +#undef mcount_adjust
25 26 #undef sift_rel_mcount
26 27 #undef nop_mcount
27 28 #undef find_secsym_ndx
... ... @@ -63,6 +64,7 @@
63 64 # define is_fake_mcount is_fake_mcount64
64 65 # define fn_is_fake_mcount fn_is_fake_mcount64
65 66 # define MIPS_is_fake_mcount MIPS64_is_fake_mcount
  67 +# define mcount_adjust mcount_adjust_64
66 68 # define Elf_Addr Elf64_Addr
67 69 # define Elf_Ehdr Elf64_Ehdr
68 70 # define Elf_Shdr Elf64_Shdr
... ... @@ -94,6 +96,7 @@
94 96 # define is_fake_mcount is_fake_mcount32
95 97 # define fn_is_fake_mcount fn_is_fake_mcount32
96 98 # define MIPS_is_fake_mcount MIPS32_is_fake_mcount
  99 +# define mcount_adjust mcount_adjust_32
97 100 # define Elf_Addr Elf32_Addr
98 101 # define Elf_Ehdr Elf32_Ehdr
99 102 # define Elf_Shdr Elf32_Shdr
... ... @@ -132,6 +135,8 @@
132 135 }
133 136 static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_ELF_R_INFO;
134 137  
  138 +static int mcount_adjust = 0;
  139 +
135 140 /*
136 141 * MIPS mcount long call has 2 _mcount symbols, only the position of the 1st
137 142 * _mcount symbol is needed for dynamic function tracer, with it, to disable
... ... @@ -317,8 +322,8 @@
317 322 mcountsym = get_mcountsym(sym0, relp, str0);
318 323  
319 324 if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) {
320   - uint_t const addend = _w(_w(relp->r_offset) - recval);
321   -
  325 + uint_t const addend =
  326 + _w(_w(relp->r_offset) - recval + mcount_adjust);
322 327 mrelp->r_offset = _w(offbase
323 328 + ((void *)mlocp - (void *)mloc0));
324 329 Elf_r_info(mrelp, recsym, reltype);