Skip extra relocations in .rel.plt/.rela.plt
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 20 May 2015 14:55:45 +0000 (07:55 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 20 May 2015 14:55:45 +0000 (07:55 -0700)
Extra relocations may be added to the .rel.plt/.rela.plt section, which
are unrelated to PLT.  We should skip them when retrieving PLT entry
symbol values.

PR binutils/18437
* elf32-i386.c (elf_i386_get_plt_sym_val): Skip extra relocations
in .rel.plt/.rela.plt.
* elf64-x86-64.c (elf_x86_64_get_plt_sym_val): Likewise.

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

index b5e4f39718dd5d4f612b2463cac4243c2b924c32..87a0bffb45945601f6030a6561eeaf9b7a06e5a8 100644 (file)
@@ -1,3 +1,10 @@
+2015-05-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/18437
+       * elf32-i386.c (elf_i386_get_plt_sym_val): Skip extra relocations
+       in .rel.plt/.rela.plt.
+       * elf64-x86-64.c (elf_x86_64_get_plt_sym_val): Likewise.
+
 2015-05-19  Jiong Wang  <jiong.wang@arm.com>
 
        * elfnn-aarch64.c (aarch64_tls_transition_without_check): Sort
index c6ff7463a359ebf7299c485239d56a3fcbb689ef..23d50e1193dee6cd5416684545164d4b3e87aff8 100644 (file)
@@ -5260,6 +5260,11 @@ bad_return:
        abort ();
       plt_sym_val[reloc_index] = plt->vma + plt_offset;
       plt_offset += bed->plt->plt_entry_size;
+
+      /* PR binutils/18437: Skip extra relocations in the .rel.plt
+        section.  */
+      if (plt_offset >= plt->size)
+       break;
     }
 
   free (plt_contents);
index 01df2308ea4b90a5decf49e07c75ffb102a0b26d..4428f97e9b4773acdbfbaecf96889d106d9d8afc 100644 (file)
@@ -5649,6 +5649,11 @@ bad_return:
       else
        plt_sym_val[reloc_index] = plt->vma + plt_offset;
       plt_offset += bed->plt_entry_size;
+
+      /* PR binutils/18437: Skip extra relocations in the .rela.plt
+        section.  */
+      if (plt_offset >= plt->size)
+       break;
     }
 
   free (plt_contents);