[RFC][PATCH 34/36] objtool: mcount: Remove wrapper for ELF relocation type

From: Matt Helsley
Date: Fri Apr 10 2020 - 15:41:36 EST


Remove the last use of the Elf_Rela wrapper #defines by passing
the size of the relocations we're dealing with as a parameter.

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

diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c
index a16611a352e5..e6aa1feb234d 100644
--- a/tools/objtool/recordmcount.c
+++ b/tools/objtool/recordmcount.c
@@ -574,7 +574,7 @@ static int do_file(char const *const fname)
is_fake_mcount = MIPS_is_fake_mcount;
}
loc_size = 4;
- rc = do32(reltype);
+ rc = do32(reltype, sizeof(Elf32_Rela));
break;
case ELFCLASS64: {
if (lf->ehdr.e_ehsize != sizeof(Elf64_Ehdr)
@@ -592,7 +592,7 @@ static int do_file(char const *const fname)
is_fake_mcount = MIPS_is_fake_mcount;
}
loc_size = 8;
- rc = do64(reltype);
+ rc = do64(reltype, sizeof(Elf64_Rela));
break;
}
} /* end switch */
diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h
index 7db08ad9b4a7..d116032522e1 100644
--- a/tools/objtool/recordmcount.h
+++ b/tools/objtool/recordmcount.h
@@ -18,18 +18,15 @@
* Copyright 2010 Steven Rostedt <srostedt@xxxxxxxxxx>, Red Hat Inc.
*/
#undef do_func
-#undef Elf_Rela

#ifdef RECORD_MCOUNT_64
# define do_func do64
-# define Elf_Rela Elf64_Rela
#else
# define do_func do32
-# define Elf_Rela Elf32_Rela
#endif

/* Overall supervision for Elf32 ET_REL file. */
-static int do_func(unsigned const reltype)
+static int do_func(unsigned const reltype, size_t rela_size)
{
/* Upper bound on space: assume all relevant relocs are for mcount. */
unsigned totrelsz;
@@ -70,7 +67,7 @@ static int do_func(unsigned const reltype)
return -1;
}

- is_rela = (sizeof(Elf_Rela) == rel_entsize);
+ is_rela = (rela_size == rel_entsize);
mc_name = is_rela
? ".rela__mcount_loc"
: ".rel__mcount_loc";
--
2.20.1