lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0cac2f36423a66cf981f66cc1710735602786225.1592510545.git.mhelsley@vmware.com>
Date:   Thu, 18 Jun 2020 13:38:34 -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 48/51] objtool: mcount: Eliminate first pass

Determine the size of the mcount relocations in objtool's
ELF reading code. This reduces the number of passes we make
through the list of sections (which can become large due to
things like -ffunction-sections).

Signed-off-by: Matt Helsley <mhelsley@...are.com>
---
 tools/objtool/elf.c    |  2 ++
 tools/objtool/elf.h    |  1 +
 tools/objtool/mcount.c | 16 +---------------
 3 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 12bd889a62ba..733e10d4a574 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -642,6 +642,8 @@ static int read_relocs(struct elf *elf)
 
 		sec->base->reloc = sec;
 		sec->mcountable = relocs_mcountable(sec);
+		if (sec->mcountable && !elf->mcount_rel_entsize)
+			elf->mcount_rel_entsize = sec->sh.sh_entsize;
 
 		nr_reloc = 0;
 		for (i = 0; i < sec->sh.sh_size / sec->sh.sh_entsize; i++) {
diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
index fb10f470d1a4..8ece1ca79cca 100644
--- a/tools/objtool/elf.h
+++ b/tools/objtool/elf.h
@@ -87,6 +87,7 @@ struct elf {
 	Elf *elf;
 	GElf_Ehdr ehdr;
 	int fd;
+	size_t mcount_rel_entsize;
 	bool changed;
 	char *name;
 	struct list_head sections;
diff --git a/tools/objtool/mcount.c b/tools/objtool/mcount.c
index 80daf0e17eab..9527924af56b 100644
--- a/tools/objtool/mcount.c
+++ b/tools/objtool/mcount.c
@@ -274,19 +274,6 @@ static int nop_mcount(struct section * const rels,
 	return 0;
 }
 
-static void tot_relsize(unsigned int *rel_entsize)
-{
-	const struct section *sec;
-
-	list_for_each_entry(sec, &lf->sections, list) {
-		if (sec->sh.sh_type != SHT_REL &&
-		    sec->sh.sh_type != SHT_RELA)
-			continue;
-		if (sec->mcountable)
-			*rel_entsize = sec->sh.sh_entsize;
-	}
-}
-
 /* zero or a small negative offset added to get the start of the call
  * instruction
  */
@@ -388,14 +375,13 @@ static int do_mcount(unsigned const reltype, size_t rela_size)
 	struct section *sec, *mlocs, *mrels;
 	const char * const mc_name =  "__mcount_loc";
 
-	unsigned int rel_entsize = 0;
+	const unsigned int rel_entsize = lf->mcount_rel_entsize;
 	int result = -1;
 	bool is_rela;
 
 	if (find_section_by_name(lf, "__mcount_loc") != NULL)
 		return 0;
 
-	tot_relsize(&rel_entsize);
 	is_rela = (rela_size == rel_entsize);
 
 	/* add section: __mcount_loc */
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ