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 18/36] objtool: mcount: Move is_fake_mcount()
Date: Fri, 10 Apr 2020 12:35:41 -0700 [thread overview]
Message-ID: <2ba56706710215ddbcc73d1b7cb4045c4e1a11a4.1586468801.git.mhelsley@vmware.com> (raw)
In-Reply-To: <cover.1586468801.git.mhelsley@vmware.com>
Promote this now-bit-independent code out of the old
recordmcount ELF wrapper.
Signed-off-by: Matt Helsley <mhelsley@vmware.com>
---
tools/objtool/recordmcount.c | 48 +++++++++++++++++++++++++++++++---
tools/objtool/recordmcount.h | 50 ------------------------------------
2 files changed, 45 insertions(+), 53 deletions(-)
diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c
index 91d14743218a..6c499fe86132 100644
--- a/tools/objtool/recordmcount.c
+++ b/tools/objtool/recordmcount.c
@@ -438,6 +438,48 @@ static unsigned get_mcountsym(struct rela *rela)
return 0;
}
+/*
+ * MIPS mcount long call has 2 _mcount symbols, only the position of the 1st
+ * _mcount symbol is needed for dynamic function tracer, with it, to disable
+ * tracing(ftrace_make_nop), the instruction in the position is replaced with
+ * the "b label" instruction, to enable tracing(ftrace_make_call), replace the
+ * instruction back. So, here, we set the 2nd one as fake and filter it.
+ *
+ * c: 3c030000 lui v1,0x0 <--> b label
+ * c: R_MIPS_HI16 _mcount
+ * c: R_MIPS_NONE *ABS*
+ * c: R_MIPS_NONE *ABS*
+ * 10: 64630000 daddiu v1,v1,0
+ * 10: R_MIPS_LO16 _mcount
+ * 10: R_MIPS_NONE *ABS*
+ * 10: R_MIPS_NONE *ABS*
+ * 14: 03e0082d move at,ra
+ * 18: 0060f809 jalr v1
+ * label:
+ */
+#define MIPS_FAKEMCOUNT_OFFSET 4
+
+static int MIPS_is_fake_mcount(struct rela const *rela)
+{
+ unsigned long old_r_offset = ~0UL;
+ unsigned long current_r_offset = rela->offset;
+ int is_fake;
+
+ is_fake = (old_r_offset != ~0UL) &&
+ (current_r_offset - old_r_offset == MIPS_FAKEMCOUNT_OFFSET);
+ old_r_offset = current_r_offset;
+
+ return is_fake;
+}
+
+/* Functions and pointers that do_file() may override for specific e_machine. */
+static int fn_is_fake_mcount(struct rela const *rela)
+{
+ return 0;
+}
+
+static int (*is_fake_mcount)(struct rela const *rela) = fn_is_fake_mcount;
+
static const unsigned int missing_sym = (unsigned int)-1;
/* 32 bit and 64 bit are very similar */
@@ -557,7 +599,7 @@ static int do_file(char const *const fname)
altmcount = "__gnu_mcount_nc";
make_nop = make_nop_arm;
rel_type_nop = R_ARM_NONE;
- is_fake_mcount32 = arm_is_fake_mcount;
+ is_fake_mcount = arm_is_fake_mcount;
gpfx = 0;
break;
case EM_AARCH64:
@@ -597,7 +639,7 @@ static int do_file(char const *const fname)
}
if (w2(ehdr->e_machine) == EM_MIPS) {
reltype = R_MIPS_32;
- is_fake_mcount32 = MIPS32_is_fake_mcount;
+ is_fake_mcount = MIPS_is_fake_mcount;
}
if (do32(ehdr, reltype) < 0)
goto out;
@@ -617,7 +659,7 @@ static int do_file(char const *const fname)
if (w2(ghdr->e_machine) == EM_MIPS) {
reltype = R_MIPS_64;
Elf64_r_info = MIPS64_r_info;
- is_fake_mcount64 = MIPS64_is_fake_mcount;
+ is_fake_mcount = MIPS_is_fake_mcount;
}
if (do64(ghdr, reltype) < 0)
goto out;
diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h
index f99851034fa8..d61892597731 100644
--- a/tools/objtool/recordmcount.h
+++ b/tools/objtool/recordmcount.h
@@ -18,9 +18,6 @@
* Copyright 2010 Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.
*/
#undef append_func
-#undef is_fake_mcount
-#undef fn_is_fake_mcount
-#undef MIPS_is_fake_mcount
#undef mcount_adjust
#undef sift_rel_mcount
#undef nop_mcount
@@ -48,9 +45,6 @@
# define has_rel_mcount has64_rel_mcount
# define tot_relsize tot64_relsize
# define do_func do64
-# define is_fake_mcount is_fake_mcount64
-# define fn_is_fake_mcount fn_is_fake_mcount64
-# define MIPS_is_fake_mcount MIPS64_is_fake_mcount
# define mcount_adjust mcount_adjust_64
# define Elf_Ehdr Elf64_Ehdr
# define Elf_Shdr Elf64_Shdr
@@ -71,9 +65,6 @@
# define has_rel_mcount has32_rel_mcount
# define tot_relsize tot32_relsize
# define do_func do32
-# define is_fake_mcount is_fake_mcount32
-# define fn_is_fake_mcount fn_is_fake_mcount32
-# define MIPS_is_fake_mcount MIPS32_is_fake_mcount
# define mcount_adjust mcount_adjust_32
# define Elf_Ehdr Elf32_Ehdr
# define Elf_Shdr Elf32_Shdr
@@ -88,13 +79,6 @@
# define _size 4
#endif
-/* Functions and pointers that do_file() may override for specific e_machine. */
-static int fn_is_fake_mcount(struct rela const *rela)
-{
- return 0;
-}
-static int (*is_fake_mcount)(struct rela const *rela) = fn_is_fake_mcount;
-
static void fn_ELF_R_INFO(Elf_Rel *const rp, unsigned sym, unsigned type)
{
rp->r_info = _w(ELF_R_INFO(sym, type));
@@ -103,40 +87,6 @@ static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_E
static int mcount_adjust = 0;
-/*
- * MIPS mcount long call has 2 _mcount symbols, only the position of the 1st
- * _mcount symbol is needed for dynamic function tracer, with it, to disable
- * tracing(ftrace_make_nop), the instruction in the position is replaced with
- * the "b label" instruction, to enable tracing(ftrace_make_call), replace the
- * instruction back. So, here, we set the 2nd one as fake and filter it.
- *
- * c: 3c030000 lui v1,0x0 <--> b label
- * c: R_MIPS_HI16 _mcount
- * c: R_MIPS_NONE *ABS*
- * c: R_MIPS_NONE *ABS*
- * 10: 64630000 daddiu v1,v1,0
- * 10: R_MIPS_LO16 _mcount
- * 10: R_MIPS_NONE *ABS*
- * 10: R_MIPS_NONE *ABS*
- * 14: 03e0082d move at,ra
- * 18: 0060f809 jalr v1
- * label:
- */
-#define MIPS_FAKEMCOUNT_OFFSET 4
-
-static int MIPS_is_fake_mcount(struct rela const *rela)
-{
- static unsigned long old_r_offset = ~0UL;
- unsigned long current_r_offset = rela->offset;
- int is_fake;
-
- is_fake = (old_r_offset != ~0UL) &&
- (current_r_offset - old_r_offset == MIPS_FAKEMCOUNT_OFFSET);
- old_r_offset = current_r_offset;
-
- return is_fake;
-}
-
/* Append the new shstrtab, Elf_Shdr[], __mcount_loc and its relocations. */
static int append_func(Elf_Ehdr *const ehdr,
Elf_Shdr *const shstr,
--
2.20.1
next prev parent reply other threads:[~2020-04-10 19:37 UTC|newest]
Thread overview: 52+ 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 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 ` Matt Helsley [this message]
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 ` [RFC][PATCH 25/36] objtool: mcount: Move relocation entry size detection Matt Helsley
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=2ba56706710215ddbcc73d1b7cb4045c4e1a11a4.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®