All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Helsley <mhelsley@vmware.com>
To: <linux-kernel@vger.kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Julien Thierry <jthierry@redhat.com>,
	Ingo Molnar <mingo@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Miroslav Benes <mbenes@suse.cz>,
	Matt Helsley <mhelsley@vmware.com>
Subject: [RFC][PATCH 25/36] objtool: mcount: Move relocation entry size detection
Date: Fri, 10 Apr 2020 12:35:48 -0700	[thread overview]
Message-ID: <4ae840c9f019d1014426b0f4f9b32c253c3cd5e9.1586468801.git.mhelsley@vmware.com> (raw)
In-Reply-To: <cover.1586468801.git.mhelsley@vmware.com>

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@vmware.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


  parent reply	other threads:[~2020-04-10 19:38 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-10 19:35 [RFC][PATCH 00/36] objtool: Make recordmcount a subcommand Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 01/36] objtool: Exit successfully when requesting help Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 02/36] objtool: Move struct objtool_file into arch-independent header Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 03/36] objtool: Enable compilation of objtool for all architectures Matt Helsley
2020-04-14  7:39   ` Julien Thierry
2020-04-14 13:41     ` Steven Rostedt
2020-04-14 14:01       ` Julien Thierry
2020-04-14 20:56     ` Matt Helsley
2020-04-15  7:05       ` Julien Thierry
2020-04-10 19:35 ` [RFC][PATCH 04/36] objtool: Report missing support for subcommands Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 05/36] objtool: Add support for relocations without addends Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 06/36] objtool: Prepare to merge recordmcount Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 07/36] objtool: Make recordmcount into mcount subcmd Matt Helsley
2020-04-10 23:07   ` kbuild test robot
2020-04-11  1:09   ` kbuild test robot
2020-04-10 19:35 ` [RFC][PATCH 08/36] objtool: recordmcount: Start using objtool's elf wrapper Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 09/36] objtool: recordmcount: Search for __mcount_loc before walking the sections Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 10/36] objtool: recordmcount: Convert do_func() relhdrs Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 11/36] objtool: mcount: Remove unused fname parameter Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 12/36] objtool: mcount: Use libelf for section header names Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 13/36] objtool: mcount: Walk objtool Elf structs in find_secsym_ndx Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 14/36] objtool: mcount: Use symbol structs to find mcount relocations Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 15/36] objtool: mcount: Walk relocation lists Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 16/36] objtool: mcount: Move get_mcountsym Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 17/36] objtool: mcount: Replace MIPS offset types Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 18/36] objtool: mcount: Move is_fake_mcount() Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 19/36] objtool: mcount: Stop using ehdr in find_section_sym_index Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 20/36] objtool: mcount: Move find_section_sym_index() Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 21/36] objtool: mcount: Restrict using ehdr in append_func() Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 22/36] objtool: mcount: Use objtool ELF to write Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 23/36] objtool: mcount: Move nop_mcount() Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 24/36] objtool: mcount: Move helpers out of ELF wrapper Matt Helsley
2020-04-10 19:35 ` Matt Helsley [this message]
2020-04-10 19:35 ` [RFC][PATCH 26/36] objtool: mcount: Only keep ELF file size Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 27/36] objtool: mcount: Use ELF header from objtool Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 28/36] objtool: mcount: Remove unused file mapping Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 29/36] objtool: mcount: Reduce usage of _size wrapper Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 30/36] objtool: mcount: Move mcount_adjust out of wrapper Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 31/36] objtool: mcount: Pre-allocate new ELF sections Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 32/36] objtool: mcount: Generic location and relocation table types Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 33/36] objtool: mcount: Move sift_rel_mcount out of wrapper file Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 34/36] objtool: mcount: Remove wrapper for ELF relocation type Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 35/36] objtool: mcount: Remove wrapper double-include trick Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 36/36] objtool: mcount: Remove wordsized endian wrappers Matt Helsley
2020-04-14  7:24 ` [RFC][PATCH 00/36] objtool: Make recordmcount a subcommand Julien Thierry
2020-04-14 13:35   ` Steven Rostedt
2020-04-14 14:17     ` Julien Thierry
2020-04-14 15:54       ` Steven Rostedt
2020-04-14 20:09         ` Matt Helsley
2020-04-14 20:47           ` Peter Zijlstra
2020-04-14 21:05             ` Steven Rostedt
2020-04-14 21:17               ` Peter Zijlstra
2020-04-14 21:47                 ` Steven Rostedt
2020-04-14 22:25                   ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ae840c9f019d1014426b0f4f9b32c253c3cd5e9.1586468801.git.mhelsley@vmware.com \
    --to=mhelsley@vmware.com \
    --cc=jpoimboe@redhat.com \
    --cc=jthierry@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.