[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b5ee19c9cadd4e786cf64dea893b47b181d80089.1592510545.git.mhelsley@vmware.com>
Date: Thu, 18 Jun 2020 13:38:27 -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 41/51] objtool: mcount: Convert nop writes to elf_write_insn()
objtool's elf_write_insn() does extra checking when writing to
an instruction so use that rather than a plain memcpy().
Signed-off-by: Matt Helsley <mhelsley@...are.com>
---
tools/objtool/mcount.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/tools/objtool/mcount.c b/tools/objtool/mcount.c
index 629eb7222ef3..029e6e72c972 100644
--- a/tools/objtool/mcount.c
+++ b/tools/objtool/mcount.c
@@ -66,9 +66,7 @@ static int make_nop_x86(struct section *txts, size_t const offset)
if (memcmp(op, ip_relative_call_x86, 5) != 0)
return -1;
- /* convert to nop */
- memcpy(op, ideal_nop, 5);
- return 0;
+ return elf_write_insn(lf, txts, offset, 5, ideal_nop);
}
static const char ideal_nop4_arm_le[4] = { 0x00, 0x00, 0xa0, 0xe1 }; /* mov r0, r0 */
@@ -117,7 +115,8 @@ static int make_nop_arm(struct section *txts, size_t const offset)
/* Convert to nop */
do {
- memcpy(map + off, ideal_nop, nop_size);
+ if (elf_write_insn(lf, txts, off, nop_size, ideal_nop))
+ return -1;
off += nop_size;
} while (--cnt > 0);
@@ -136,8 +135,7 @@ static int make_nop_arm64(struct section *txts, size_t const offset)
return -1;
/* Convert to nop */
- memcpy(map + offset, ideal_nop, 4);
- return 0;
+ return elf_write_insn(lf, txts, offset, 4, ideal_nop);
}
/* Names of the sections that could contain calls to mcount. */
--
2.20.1
Powered by blists - more mailing lists