This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Refactor elf_x86_64_convert_mov_to_lea
- From: H.J.Lu <hjl at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 1 Jul 2015 16:33:36 -0000
- Subject: [binutils-gdb] Refactor elf_x86_64_convert_mov_to_lea
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dfc87947b5ac6d6382c225449d4fdce411c7ee66
commit dfc87947b5ac6d6382c225449d4fdce411c7ee66
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Jul 1 09:32:47 2015 -0700
Refactor elf_x86_64_convert_mov_to_lea
* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Refactor.
Diff:
---
bfd/ChangeLog | 4 ++++
bfd/elf64-x86-64.c | 13 +++++++++----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2dd71f2..5c1e94c 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,7 @@
+2015-07-01 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Refactor.
+
2015-06-30 Nick Clifton <nickc@redhat.com>
PR binutils/18570
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 3022deb..a4dfdc8 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2952,16 +2952,21 @@ elf_x86_64_convert_mov_to_lea (bfd *abfd, asection *sec,
enum {
none, local, global
} convert_mov_to_lea;
+ unsigned int opcode;
if (r_type != R_X86_64_GOTPCREL)
continue;
roff = irel->r_offset;
- /* Don't convert R_X86_64_GOTPCREL relocation if it isn't for mov
- instruction. */
- if (roff < 2
- || bfd_get_8 (abfd, contents + roff - 2) != 0x8b)
+ if (roff < 2)
+ continue;
+
+ opcode = bfd_get_8 (abfd, contents + roff - 2);
+
+ /* PR ld/18591: Don't convert R_X86_64_GOTPCREL relocation if it
+ isn't for mov instruction. */
+ if (opcode != 0x8b)
continue;
tsec = NULL;