Skip to content

Commit 07d8b59

Browse files
Martin Schwidefskyrostedt
authored andcommitted
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>
1 parent 41b402a commit 07d8b59

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎scripts/recordmcount.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#undef is_fake_mcount
2323
#undef fn_is_fake_mcount
2424
#undef MIPS_is_fake_mcount
25+
#undef mcount_adjust
2526
#undef sift_rel_mcount
2627
#undef nop_mcount
2728
#undef find_secsym_ndx
@@ -63,6 +64,7 @@
6364
# define is_fake_mcount is_fake_mcount64
6465
# define fn_is_fake_mcount fn_is_fake_mcount64
6566
# define MIPS_is_fake_mcount MIPS64_is_fake_mcount
67+
# define mcount_adjust mcount_adjust_64
6668
# define Elf_Addr Elf64_Addr
6769
# define Elf_Ehdr Elf64_Ehdr
6870
# define Elf_Shdr Elf64_Shdr
@@ -94,6 +96,7 @@
9496
# define is_fake_mcount is_fake_mcount32
9597
# define fn_is_fake_mcount fn_is_fake_mcount32
9698
# define MIPS_is_fake_mcount MIPS32_is_fake_mcount
99+
# define mcount_adjust mcount_adjust_32
97100
# define Elf_Addr Elf32_Addr
98101
# define Elf_Ehdr Elf32_Ehdr
99102
# define Elf_Shdr Elf32_Shdr
@@ -132,6 +135,8 @@ static void fn_ELF_R_INFO(Elf_Rel *const rp, unsigned sym, unsigned type)
132135
}
133136
static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_ELF_R_INFO;
134137

138+
static int mcount_adjust = 0;
139+
135140
/*
136141
* MIPS mcount long call has 2 _mcount symbols, only the position of the 1st
137142
* _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,
317322
mcountsym = get_mcountsym(sym0, relp, str0);
318323

319324
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);
322327
mrelp->r_offset = _w(offbase
323328
+ ((void *)mlocp - (void *)mloc0));
324329
Elf_r_info(mrelp, recsym, reltype);

0 commit comments

Comments
 (0)