Refactor elf_x86_64_convert_mov_to_lea
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 1 Jul 2015 16:32:47 +0000 (09:32 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 1 Jul 2015 16:33:27 +0000 (09:33 -0700)
* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Refactor.

bfd/ChangeLog
bfd/elf64-x86-64.c

index 2dd71f26cb78377ce05142bb695df4f5cad2c574..5c1e94ce96160f9f0677dbe9d16943598b8ba3dd 100644 (file)
@@ -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
index 3022debb99dcb163ec13d990266b63a6034eb173..a4dfdc830cc649fc349f2c1c79a01d46c05dc4a0 100644 (file)
@@ -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;