[RFC][PATCH v5 14/51] objtool: mcount: Move get_mcountsym

From: Matt Helsley
Date: Thu Jun 18 2020 - 16:41:22 EST


Now that it's been stripped of using the old recordmcount ELF
wrapper get_mcountsym() is ready to be promoted out of the
double-included wrapper header.

Signed-off-by: Matt Helsley <mhelsley@xxxxxxxxxx>
---
tools/objtool/recordmcount.c | 16 ++++++++++++++++
tools/objtool/recordmcount.h | 19 -------------------
2 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c
index dafa6dd10d04..d5f7c06afd57 100644
--- a/tools/objtool/recordmcount.c
+++ b/tools/objtool/recordmcount.c
@@ -422,6 +422,22 @@ static int is_mcounted_section_name(char const *const txtname)
strcmp(".cpuidle.text", txtname) == 0;
}

+static struct symbol *get_mcountsym(struct reloc *reloc)
+{
+ struct symbol *sym = reloc->sym;
+ char const *symname = sym->name;
+ char const *mcount = gpfx == '_' ? "_mcount" : "mcount";
+ char const *fentry = "__fentry__";
+
+ if (symname[0] == '.')
+ ++symname; /* ppc64 hack */
+ if (strcmp(mcount, symname) == 0 ||
+ (altmcount && strcmp(altmcount, symname) == 0) ||
+ (strcmp(fentry, symname) == 0))
+ return sym;
+ return NULL;
+}
+
static const unsigned int missing_sym = (unsigned int)-1;

/* 32 bit and 64 bit are very similar */
diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h
index 6ac120aa45af..210899819261 100644
--- a/tools/objtool/recordmcount.h
+++ b/tools/objtool/recordmcount.h
@@ -27,7 +27,6 @@
#undef find_section_sym_index
#undef has_rel_mcount
#undef tot_relsize
-#undef get_mcountsym
#undef get_shnum
#undef set_shnum
#undef get_shstrndx
@@ -56,7 +55,6 @@
# define set_shnum set_shnum64
# define get_shstrndx get_shstrndx64
# define do_func do64
-# define get_mcountsym get_mcountsym_64
# define is_fake_mcount is_fake_mcount64
# define fn_is_fake_mcount fn_is_fake_mcount64
# define MIPS_is_fake_mcount MIPS64_is_fake_mcount
@@ -84,7 +82,6 @@
# define set_shnum set_shnum32
# define get_shstrndx get_shstrndx32
# define do_func do32
-# define get_mcountsym get_mcountsym_32
# define is_fake_mcount is_fake_mcount32
# define fn_is_fake_mcount fn_is_fake_mcount32
# define MIPS_is_fake_mcount MIPS32_is_fake_mcount
@@ -271,22 +268,6 @@ static int append_func(Elf_Ehdr *const ehdr,
return elf_write(lf);
}

-static struct symbol *get_mcountsym(struct reloc *reloc)
-{
- struct symbol *sym = reloc->sym;
- char const *symname = sym->name;
- char const *mcount = gpfx == '_' ? "_mcount" : "mcount";
- char const *fentry = "__fentry__";
-
- if (symname[0] == '.')
- ++symname; /* ppc64 hack */
- if (strcmp(mcount, symname) == 0 ||
- (altmcount && strcmp(altmcount, symname) == 0) ||
- (strcmp(fentry, symname) == 0))
- return sym;
- return NULL;
-}
-
/*
* Look at the relocations in order to find the calls to mcount.
* Accumulate the section offsets that are found, and their relocation info,
--
2.20.1