aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-04-20 20:47:34 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-05-16 14:48:02 -0400
commit37762cb9977626343b3cd1aab9146313c94748c2 (patch)
tree32e47221487d6f889494a6ba90c2ff476610922a /scripts
parent2895cd2ab81dfb7bc22637bc110857db44a30b4a (diff)
ftrace/recordmcount: Remove duplicate code to find mcount symbol
The code in sift_rel_mcount() and nop_mcount() to get the mcount symbol number is identical. Replace the two locations with a call to a function that does the work. Cc: John Reiser <jreiser@bitwagon.com> Link: http://lkml.kernel.org/r/20110421023739.488093407@goodmis.org Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/recordmcount.h51
1 files changed, 27 insertions, 24 deletions
diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
index 22033d563bcd..deb6a517638c 100644
--- a/scripts/recordmcount.h
+++ b/scripts/recordmcount.h
@@ -28,6 +28,7 @@
28#undef __has_rel_mcount 28#undef __has_rel_mcount
29#undef has_rel_mcount 29#undef has_rel_mcount
30#undef tot_relsize 30#undef tot_relsize
31#undef get_mcountsym
31#undef do_func 32#undef do_func
32#undef Elf_Addr 33#undef Elf_Addr
33#undef Elf_Ehdr 34#undef Elf_Ehdr
@@ -56,6 +57,7 @@
56# define has_rel_mcount has64_rel_mcount 57# define has_rel_mcount has64_rel_mcount
57# define tot_relsize tot64_relsize 58# define tot_relsize tot64_relsize
58# define do_func do64 59# define do_func do64
60# define get_mcountsym get_mcountsym_64
59# define is_fake_mcount is_fake_mcount64 61# define is_fake_mcount is_fake_mcount64
60# define fn_is_fake_mcount fn_is_fake_mcount64 62# define fn_is_fake_mcount fn_is_fake_mcount64
61# define MIPS_is_fake_mcount MIPS64_is_fake_mcount 63# define MIPS_is_fake_mcount MIPS64_is_fake_mcount
@@ -85,6 +87,7 @@
85# define has_rel_mcount has32_rel_mcount 87# define has_rel_mcount has32_rel_mcount
86# define tot_relsize tot32_relsize 88# define tot_relsize tot32_relsize
87# define do_func do32 89# define do_func do32
90# define get_mcountsym get_mcountsym_32
88# define is_fake_mcount is_fake_mcount32 91# define is_fake_mcount is_fake_mcount32
89# define fn_is_fake_mcount fn_is_fake_mcount32 92# define fn_is_fake_mcount fn_is_fake_mcount32
90# define MIPS_is_fake_mcount MIPS32_is_fake_mcount 93# define MIPS_is_fake_mcount MIPS32_is_fake_mcount
@@ -237,6 +240,26 @@ static void append_func(Elf_Ehdr *const ehdr,
237 uwrite(fd_map, ehdr, sizeof(*ehdr)); 240 uwrite(fd_map, ehdr, sizeof(*ehdr));
238} 241}
239 242
243static unsigned get_mcountsym(Elf_Sym const *const sym0,
244 Elf_Rel const *relp,
245 char const *const str0)
246{
247 unsigned mcountsym = 0;
248
249 Elf_Sym const *const symp =
250 &sym0[Elf_r_sym(relp)];
251 char const *symname = &str0[w(symp->st_name)];
252 char const *mcount = gpfx == '_' ? "_mcount" : "mcount";
253
254 if (symname[0] == '.')
255 ++symname; /* ppc64 hack */
256 if (strcmp(mcount, symname) == 0 ||
257 (altmcount && strcmp(altmcount, symname) == 0))
258 mcountsym = Elf_r_sym(relp);
259
260 return mcountsym;
261}
262
240/* 263/*
241 * Look at the relocations in order to find the calls to mcount. 264 * Look at the relocations in order to find the calls to mcount.
242 * Accumulate the section offsets that are found, and their relocation info, 265 * Accumulate the section offsets that are found, and their relocation info,
@@ -274,18 +297,8 @@ static uint_t *sift_rel_mcount(uint_t *mlocp,
274 unsigned t; 297 unsigned t;
275 298
276 for (t = nrel; t; --t) { 299 for (t = nrel; t; --t) {
277 if (!mcountsym) { 300 if (!mcountsym)
278 Elf_Sym const *const symp = 301 mcountsym = get_mcountsym(sym0, relp, str0);
279 &sym0[Elf_r_sym(relp)];
280 char const *symname = &str0[w(symp->st_name)];
281 char const *mcount = gpfx == '_' ? "_mcount" : "mcount";
282
283 if (symname[0] == '.')
284 ++symname; /* ppc64 hack */
285 if (strcmp(mcount, symname) == 0 ||
286 (altmcount && strcmp(altmcount, symname) == 0))
287 mcountsym = Elf_r_sym(relp);
288 }
289 302
290 if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) { 303 if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) {
291 uint_t const addend = _w(_w(relp->r_offset) - recval); 304 uint_t const addend = _w(_w(relp->r_offset) - recval);
@@ -342,18 +355,8 @@ static void nop_mcount(Elf_Shdr const *const relhdr,
342 for (t = nrel; t; --t) { 355 for (t = nrel; t; --t) {
343 int ret = -1; 356 int ret = -1;
344 357
345 if (!mcountsym) { 358 if (!mcountsym)
346 Elf_Sym const *const symp = 359 mcountsym = get_mcountsym(sym0, relp, str0);
347 &sym0[Elf_r_sym(relp)];
348 char const *symname = &str0[w(symp->st_name)];
349 char const *mcount = gpfx == '_' ? "_mcount" : "mcount";
350
351 if (symname[0] == '.')
352 ++symname; /* ppc64 hack */
353 if (strcmp(mcount, symname) == 0 ||
354 (altmcount && strcmp(altmcount, symname) == 0))
355 mcountsym = Elf_r_sym(relp);
356 }
357 360
358 if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) { 361 if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) {
359 if (make_nop) 362 if (make_nop)