lkml.org 
[lkml]   [2020]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC][PATCH v4 18/32] objtool: mcount: Move nop_mcount()
Date
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 <mhelsley@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 89762908290e..88998a505859 100644
--- a/tools/objtool/recordmcount.c
+++ b/tools/objtool/recordmcount.c
@@ -398,6 +398,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);
+ unsigned mcountsym = 0;
+ int once = 0;
+
+ list_for_each_entry(reloc, &rels->reloc_list, list) {
+ int ret = -1;
+
+ if (!mcountsym)
+ mcountsym = get_mcountsym(reloc);
+
+ if (mcountsym == GELF_R_INFO(reloc->sym->idx, reloc->type) && !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 6754bde0bacc..e033b600bd61 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
@@ -171,53 +168,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);
- unsigned mcountsym = 0;
- int once = 0;
-
- list_for_each_entry(reloc, &rels->reloc_list, list) {
- int ret = -1;
-
- if (!mcountsym)
- mcountsym = get_mcountsym(reloc);
-
- if (mcountsym == GELF_R_INFO(reloc->sym->idx, reloc->type) && !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
\
 
 \ /
  Last update: 2020-06-02 21:52    [W:2.019 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site