[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4ae840c9f019d1014426b0f4f9b32c253c3cd5e9.1586468801.git.mhelsley@vmware.com>
Date: Fri, 10 Apr 2020 12:35:48 -0700
From: Matt Helsley <mhelsley@...are.com>
To: <linux-kernel@...r.kernel.org>
CC: Josh Poimboeuf <jpoimboe@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Julien Thierry <jthierry@...hat.com>,
Ingo Molnar <mingo@...hat.com>,
Steven Rostedt <rostedt@...dmis.org>,
Miroslav Benes <mbenes@...e.cz>,
Matt Helsley <mhelsley@...are.com>
Subject: [RFC][PATCH 25/36] objtool: mcount: Move relocation entry size detection
Move where we detect the size of relocation entries we wish to
use into the first loop over the sections. This will allow us
to allocate the mcount location and relocation sections before
the next loop that collects them.
Signed-off-by: Matt Helsley <mhelsley@...are.com>
---
tools/objtool/recordmcount.c | 8 +++++---
tools/objtool/recordmcount.h | 5 ++---
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c
index f39919e1ea7e..95b93767d6eb 100644
--- a/tools/objtool/recordmcount.c
+++ b/tools/objtool/recordmcount.c
@@ -457,7 +457,7 @@ static char const *has_rel_mcount(const struct section * const rels)
return txts->name;
}
-static unsigned tot_relsize(void)
+static unsigned tot_relsize(unsigned int *rel_entsize)
{
const struct section *sec;
unsigned totrelsz = 0;
@@ -465,8 +465,10 @@ static unsigned tot_relsize(void)
list_for_each_entry(sec, &lf->sections, list) {
txtname = has_rel_mcount(sec);
- if (txtname && is_mcounted_section_name(txtname))
- totrelsz += sec->sh.sh_size;
+ if (!(txtname && is_mcounted_section_name(txtname)))
+ continue;
+ totrelsz += sec->sh.sh_size;
+ *rel_entsize = sec->sh.sh_entsize;
}
return totrelsz;
}
diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h
index e6efdd34958e..084f1eff0df0 100644
--- a/tools/objtool/recordmcount.h
+++ b/tools/objtool/recordmcount.h
@@ -175,7 +175,7 @@ static int do_func(unsigned const reltype)
uint_t * mloc0;
uint_t * mlocp;
- unsigned rel_entsize = 0;
+ unsigned int rel_entsize = 0;
unsigned symsec_sh_link = 0;
struct section *sec;
@@ -185,7 +185,7 @@ static int do_func(unsigned const reltype)
if (find_section_by_name(lf, "__mcount_loc") != NULL)
return 0;
- totrelsz = tot_relsize();
+ totrelsz = tot_relsize(&rel_entsize);
if (totrelsz == 0)
return 0;
mrel0 = umalloc(totrelsz);
@@ -215,7 +215,6 @@ static int do_func(unsigned const reltype)
if (result)
goto out;
- rel_entsize = sec->sh.sh_entsize;
mlocp = sift_rel_mcount(mlocp,
(void *)mlocp - (void *)mloc0, &mrelp,
sec, recsym, (uint_t)recval, reltype);
--
2.20.1
Powered by blists - more mailing lists