The nop_mcount() function overwrites mcount calls that should be ignored with no-ops. This operation varies by architecture and wordsize so we retain the function pointers used to implement the fundamental operation while nop_mcount() itself is responsible for walking the relocations, determining if they should be turned into no-ops, then calling the arch-specific code. Since none of these use the recordmcount ELF wrappers anymore we can move it out of the wrapper.
Signed-off-by: Matt Helsley <mhels...@vmware.com> --- tools/objtool/recordmcount.c | 47 +++++++++++++++++++++++++++++++++ tools/objtool/recordmcount.h | 50 ------------------------------------ 2 files changed, 47 insertions(+), 50 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c index c015091a8a8c..fae0b15d0632 100644 --- a/tools/objtool/recordmcount.c +++ b/tools/objtool/recordmcount.c @@ -399,6 +399,53 @@ static int find_section_sym_index(unsigned const txtndx, return missing_sym; } +/* + * Read the relocation table again, but this time its called on sections + * that are not going to be traced. The mcount calls here will be converted + * into nops. + */ +static int nop_mcount(struct section * const rels, + const char *const txtname) +{ + struct reloc *reloc; + struct section *txts = find_section_by_index(lf, rels->sh.sh_info); + struct symbol *mcountsym = NULL; + int once = 0; + + list_for_each_entry(reloc, &rels->reloc_list, list) { + int ret = -1; + + if (!mcountsym) + mcountsym = get_mcountsym(reloc); + + if (mcountsym == reloc->sym && !is_fake_mcount(reloc)) { + if (make_nop) { + ret = make_nop(txts, reloc->offset); + if (ret < 0) + return -1; + } + if (warn_on_notrace_sect && !once) { + printf("Section %s has mcount callers being ignored\n", + txtname); + once = 1; + /* just warn? */ + if (!make_nop) + return 0; + } + } + + /* + * If we successfully removed the mcount, mark the relocation + * as a nop (don't do anything with it). + */ + if (!ret) { + reloc->type = rel_type_nop; + rels->changed = true; + } + } + return 0; +} + /* 32 bit and 64 bit are very similar */ #include "recordmcount.h" #define RECORD_MCOUNT_64 diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h index 1f14c64ed484..25028c61da2b 100644 --- a/tools/objtool/recordmcount.h +++ b/tools/objtool/recordmcount.h @@ -20,7 +20,6 @@ #undef append_func #undef mcount_adjust #undef sift_rel_mcount -#undef nop_mcount #undef has_rel_mcount #undef tot_relsize #undef do_func @@ -37,7 +36,6 @@ #ifdef RECORD_MCOUNT_64 # define append_func append64 # define sift_rel_mcount sift64_rel_mcount -# define nop_mcount nop_mcount_64 # define has_rel_mcount has64_rel_mcount # define tot_relsize tot64_relsize # define do_func do64 @@ -53,7 +51,6 @@ #else # define append_func append32 # define sift_rel_mcount sift32_rel_mcount -# define nop_mcount nop_mcount_32 # define has_rel_mcount has32_rel_mcount # define tot_relsize tot32_relsize # define do_func do32 @@ -168,53 +165,6 @@ static uint_t *sift_rel_mcount(uint_t *mlocp, return mlocp; } -/* - * Read the relocation table again, but this time its called on sections - * that are not going to be traced. The mcount calls here will be converted - * into nops. - */ -static int nop_mcount(struct section * const rels, - const char *const txtname) -{ - struct reloc *reloc; - struct section *txts = find_section_by_index(lf, rels->sh.sh_info); - struct symbol *mcountsym = NULL; - int once = 0; - - list_for_each_entry(reloc, &rels->reloc_list, list) { - int ret = -1; - - if (!mcountsym) - mcountsym = get_mcountsym(reloc); - - if (mcountsym == reloc->sym && !is_fake_mcount(reloc)) { - if (make_nop) { - ret = make_nop(txts, reloc->offset); - if (ret < 0) - return -1; - } - if (warn_on_notrace_sect && !once) { - printf("Section %s has mcount callers being ignored\n", - txtname); - once = 1; - /* just warn? */ - if (!make_nop) - return 0; - } - } - - /* - * If we successfully removed the mcount, mark the relocation - * as a nop (don't do anything with it). - */ - if (!ret) { - reloc->type = rel_type_nop; - rels->changed = true; - } - } - return 0; -} - static char const *has_rel_mcount(const struct section * const rels) { const struct section *txts; -- 2.20.1