[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5b0c55a54fec946cbbea4a3e0e87485d71123e47.1592510545.git.mhelsley@vmware.com>
Date: Thu, 18 Jun 2020 13:38:36 -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 50/51] objtool: mcount: Remove useless lookup
Since the relocation section's sh_info points back to the text
section it applies to and we already have that we can just pass
it in and greatly simplify find_section_sym_index().
Signed-off-by: Matt Helsley <mhelsley@...are.com>
---
tools/objtool/mcount.c | 39 +++++++++++++++------------------------
1 file changed, 15 insertions(+), 24 deletions(-)
diff --git a/tools/objtool/mcount.c b/tools/objtool/mcount.c
index 084bbc02de0c..a74625aed09b 100644
--- a/tools/objtool/mcount.c
+++ b/tools/objtool/mcount.c
@@ -198,35 +198,27 @@ static const unsigned int missing_sym = (unsigned int)-1;
* Num: Value Size Type Bind Vis Ndx Name
* 2: 00000000 0 SECTION LOCAL DEFAULT 1
*/
-static int find_section_sym_index(unsigned const txtndx,
- char const *const txtname,
- unsigned long *const recvalp,
- unsigned int *sym_index)
+static int find_section_sym_index(const struct section * const txts,
+ unsigned long *const recvalp,
+ unsigned int *sym_index)
{
struct symbol *sym;
- struct section *txts = find_section_by_index(lf, txtndx);
-
- if (!txts) {
- fprintf(stderr, "Cannot find section %u: %s.\n",
- txtndx, txtname);
- return missing_sym;
- }
list_for_each_entry(sym, &txts->symbol_list, list) {
/* avoid symbols with weak binding */
- if ((sym->bind == STB_LOCAL) || (sym->bind == STB_GLOBAL)) {
- /* function symbols on ARM have quirks, avoid them */
- if (lf->ehdr.e_machine == EM_ARM
- && sym->type == STT_FUNC)
- continue;
-
- *recvalp = sym->sym.st_value;
- *sym_index = sym->idx;
- return 0;
- }
+ if ((sym->bind != STB_LOCAL) && (sym->bind != STB_GLOBAL))
+ continue;
+
+ /* function symbols on ARM have quirks, avoid them */
+ if (lf->ehdr.e_machine == EM_ARM && sym->type == STT_FUNC)
+ continue;
+
+ *recvalp = sym->sym.st_value;
+ *sym_index = sym->idx;
+ return 0;
}
fprintf(stderr, "Cannot find symbol for section %u: %s.\n",
- txtndx, txtname);
+ txts->idx, txts->name);
return missing_sym;
}
@@ -414,8 +406,7 @@ static int do_mcount(unsigned const reltype)
unsigned long recval = 0;
unsigned int recsym;
- if (find_section_sym_index(sec->sh.sh_info,
- txts->name, &recval, &recsym))
+ if (find_section_sym_index(txts, &recval, &recsym))
goto out;
sift_rel_mcount(&r_offset, sec, mrels, mlocs,
--
2.20.1
Powered by blists - more mailing lists