[RFC][PATCH v5 17/51] objtool: mcount: Stop using ehdr in find_section_sym_index

From: Matt Helsley
Date: Thu Jun 18 2020 - 16:39:55 EST


We can use the objtool GElf_Ehdr structure to access ehdr here.
This makes the function completely independent of the old
recordmcount ELF wrapper. The next step will be to promote it
to the C file.

Signed-off-by: Matt Helsley <mhelsley@xxxxxxxxxx>
---
tools/objtool/recordmcount.h | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h
index 941f96e4f74b..cf420f9f64b0 100644
--- a/tools/objtool/recordmcount.h
+++ b/tools/objtool/recordmcount.h
@@ -225,7 +225,7 @@ static uint_t *sift_rel_mcount(uint_t *mlocp,
Elf_Rel **const mrelpp,
const struct section * const rels,
unsigned const recsym_index,
- uint_t const recval,
+ unsigned long const recval,
unsigned const reltype)
{
uint_t *const mloc0 = mlocp;
@@ -319,9 +319,8 @@ static int nop_mcount(struct section * const rels,
*/
static int find_section_sym_index(unsigned const txtndx,
char const *const txtname,
- uint_t *const recvalp,
- unsigned int *sym_index,
- Elf_Ehdr const *const ehdr)
+ unsigned long *const recvalp,
+ unsigned int *sym_index)
{
struct symbol *sym;
struct section *txts = find_section_by_index(lf, txtndx);
@@ -336,7 +335,7 @@ static int find_section_sym_index(unsigned const txtndx,
/* avoid symbols with weak binding */
if ((sym->bind == STB_LOCAL) || (sym->bind == STB_GLOBAL)) {
/* function symbols on ARM have quirks, avoid them */
- if (w2(ehdr->e_machine) == EM_ARM
+ if (lf->ehdr.e_machine == EM_ARM
&& sym->type == STT_FUNC)
continue;

@@ -424,12 +423,12 @@ static int do_func(Elf_Ehdr *const ehdr,

txtname = has_rel_mcount(sec);
if (txtname && is_mcounted_section_name(txtname)) {
+ unsigned long recval = 0;
unsigned int recsym;
- uint_t recval = 0;

symsec_sh_link = sec->sh.sh_link;
result = find_section_sym_index(sec->sh.sh_info,
- txtname, &recval, &recsym, ehdr);
+ txtname, &recval, &recsym);
if (result)
goto out;

--
2.20.1