[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <19fca156c1171bb723ea98f911b4f0e38ec4d8f0.1592510545.git.mhelsley@vmware.com>
Date: Thu, 18 Jun 2020 13:38:17 -0700
From: Matt Helsley <mhelsley@...are.com>
To: <linux-kernel@...r.kernel.org>
CC: Josh Poimboeuf <jpoimboe@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Steven Rostedt <rostedt@...dmis.org>,
Julien Thierry <jthierry@...hat.com>,
Kamalesh Babulal <kamalesh@...ux.vnet.ibm.com>,
Matt Helsley <mhelsley@...are.com>
Subject: [RFC][PATCH v5 31/51] objtool: mcount: Use objtool relocation section
Now that we add an initially-empty relocation section and share
the libelf data buffer from the beginning, we can safely use
objtools elf_create_reloc_section() function to simplify the
code further -- use the anticipated base section name, avoid
the need to set sh_info, etc. The only remaining difference
between this and the old recordmcount code is we didn't set
SHF_INFO_LINK so we clear the sh_flags as before.
Signed-off-by: Matt Helsley <mhelsley@...are.com>
---
tools/objtool/recordmcount.h | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h
index 1d11dfc40d09..fc6346a7eaf5 100644
--- a/tools/objtool/recordmcount.h
+++ b/tools/objtool/recordmcount.h
@@ -92,7 +92,7 @@ static int do_func(unsigned const reltype)
GElf_Sxword r_offset = 0;
struct section *sec, *mlocs, *mrels;
- const char *mc_name;
+ const char * const mc_name = "__mcount_loc";
unsigned int rel_entsize = 0;
int result = -1;
@@ -119,12 +119,9 @@ static int do_func(unsigned const reltype)
}
is_rela = (sizeof(Elf_Rela) == rel_entsize);
- mc_name = is_rela
- ? ".rela__mcount_loc"
- : ".rel__mcount_loc";
/* add section: __mcount_loc */
- mlocs = elf_create_section(lf, mc_name + (is_rela ? 1 : 0) + strlen(".rel"), sizeof(*mloc0), 0);
+ mlocs = elf_create_section(lf, mc_name, sizeof(*mloc0), 0);
if (!mlocs)
goto out;
mlocs->sh.sh_link = 0;
@@ -134,17 +131,12 @@ static int do_func(unsigned const reltype)
mlocs->data->d_type = ELF_T_ADDR; /* elf_xlatetof() conversion */
/* add section .rel[a]__mcount_loc */
- mrels = elf_create_section(lf, mc_name, rel_entsize, 0);
+ mrels = elf_create_reloc_section(lf, mlocs,
+ is_rela ? SHT_RELA : SHT_REL);
if (!mrels)
goto out;
- /* Like elf_create_rela_section() without the name bits */
- mrels->sh.sh_type = is_rela ? SHT_RELA : SHT_REL;
- mrels->sh.sh_flags = 0; /* clear SHF_ALLOC */
- mrels->sh.sh_link = find_section_by_name(lf, ".symtab")->idx;
- mrels->sh.sh_info = mlocs->idx;
- mrels->sh.sh_addralign = 8;
+ mrels->sh.sh_flags = 0; /* clear SHF_INFO_LINK */
mrels->data->d_buf = mrel0;
- mrels->data->d_type = is_rela ? ELF_T_RELA : ELF_T_REL; /* elf_xlatetof() conversion */
list_for_each_entry(sec, &lf->sections, list) {
char const *txtname;
--
2.20.1
Powered by blists - more mailing lists