Commit 37762cb9977626343b3cd1aab9146313c94748c2
Committed by
Steven Rostedt
1 parent
2895cd2ab8
Exists in
master
and in
20 other branches
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>
Showing 1 changed file with 27 additions and 24 deletions Side-by-side Diff
scripts/recordmcount.h
... | ... | @@ -28,6 +28,7 @@ |
28 | 28 | #undef __has_rel_mcount |
29 | 29 | #undef has_rel_mcount |
30 | 30 | #undef tot_relsize |
31 | +#undef get_mcountsym | |
31 | 32 | #undef do_func |
32 | 33 | #undef Elf_Addr |
33 | 34 | #undef Elf_Ehdr |
... | ... | @@ -56,6 +57,7 @@ |
56 | 57 | # define has_rel_mcount has64_rel_mcount |
57 | 58 | # define tot_relsize tot64_relsize |
58 | 59 | # define do_func do64 |
60 | +# define get_mcountsym get_mcountsym_64 | |
59 | 61 | # define is_fake_mcount is_fake_mcount64 |
60 | 62 | # define fn_is_fake_mcount fn_is_fake_mcount64 |
61 | 63 | # define MIPS_is_fake_mcount MIPS64_is_fake_mcount |
... | ... | @@ -85,6 +87,7 @@ |
85 | 87 | # define has_rel_mcount has32_rel_mcount |
86 | 88 | # define tot_relsize tot32_relsize |
87 | 89 | # define do_func do32 |
90 | +# define get_mcountsym get_mcountsym_32 | |
88 | 91 | # define is_fake_mcount is_fake_mcount32 |
89 | 92 | # define fn_is_fake_mcount fn_is_fake_mcount32 |
90 | 93 | # define MIPS_is_fake_mcount MIPS32_is_fake_mcount |
... | ... | @@ -237,6 +240,26 @@ |
237 | 240 | uwrite(fd_map, ehdr, sizeof(*ehdr)); |
238 | 241 | } |
239 | 242 | |
243 | +static 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 | 264 | * Look at the relocations in order to find the calls to mcount. |
242 | 265 | * Accumulate the section offsets that are found, and their relocation info, |
243 | 266 | |
... | ... | @@ -274,19 +297,9 @@ |
274 | 297 | unsigned t; |
275 | 298 | |
276 | 299 | for (t = nrel; t; --t) { |
277 | - if (!mcountsym) { | |
278 | - Elf_Sym const *const symp = | |
279 | - &sym0[Elf_r_sym(relp)]; | |
280 | - char const *symname = &str0[w(symp->st_name)]; | |
281 | - char const *mcount = gpfx == '_' ? "_mcount" : "mcount"; | |
300 | + if (!mcountsym) | |
301 | + mcountsym = get_mcountsym(sym0, relp, str0); | |
282 | 302 | |
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 | - | |
290 | 303 | if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) { |
291 | 304 | uint_t const addend = _w(_w(relp->r_offset) - recval); |
292 | 305 | |
... | ... | @@ -342,18 +355,8 @@ |
342 | 355 | for (t = nrel; t; --t) { |
343 | 356 | int ret = -1; |
344 | 357 | |
345 | - if (!mcountsym) { | |
346 | - Elf_Sym const *const symp = | |
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 | - } | |
358 | + if (!mcountsym) | |
359 | + mcountsym = get_mcountsym(sym0, relp, str0); | |
357 | 360 | |
358 | 361 | if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) { |
359 | 362 | if (make_nop) |