Check SEC_ALLOC before allocating dynamic relocation
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 16 Jun 2016 01:42:56 +0000 (18:42 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 16 Jun 2016 01:42:56 +0000 (18:42 -0700)
* elf32-i386.c (elf_i386_check_relocs): Check SEC_ALLOC before
allocating dynamic relocation.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.

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

index 38d28f32da678671217ce5229bb58dddacc0ffac..344e08b93b97f61706c5e408d6247c0281da7d66 100644 (file)
@@ -1,3 +1,9 @@
+2016-06-15  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf32-i386.c (elf_i386_check_relocs): Check SEC_ALLOC before
+       allocating dynamic relocation.
+       * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
+
 2016-06-14  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
 
        PR ld/20254
index 686c0682fb0e0f666b2a108e65173b50887cd8d7..793fb39dfa400fc4060a6e7491e0a98ab5606b7a 100644 (file)
@@ -2202,20 +2202,19 @@ do_size:
             may need to keep relocations for symbols satisfied by a
             dynamic library if we manage to avoid copy relocs for the
             symbol.  */
-         if ((bfd_link_pic (info)
-              && (sec->flags & SEC_ALLOC) != 0
-              && (r_type != R_386_PC32
-                  || (h != NULL
-                      && (! (bfd_link_pie (info)
-                             || SYMBOLIC_BIND (info, h))
-                          || h->root.type == bfd_link_hash_defweak
-                          || !h->def_regular))))
-             || (ELIMINATE_COPY_RELOCS
-                 && !bfd_link_pic (info)
-                 && (sec->flags & SEC_ALLOC) != 0
-                 && h != NULL
-                 && (h->root.type == bfd_link_hash_defweak
-                     || !h->def_regular)))
+         if ((sec->flags & SEC_ALLOC) != 0
+             && ((bfd_link_pic (info)
+                  && (r_type != R_386_PC32
+                      || (h != NULL
+                          && (! (bfd_link_pie (info)
+                                 || SYMBOLIC_BIND (info, h))
+                              || h->root.type == bfd_link_hash_defweak
+                              || !h->def_regular))))
+                 || (ELIMINATE_COPY_RELOCS
+                     && !bfd_link_pic (info)
+                     && h != NULL
+                     && (h->root.type == bfd_link_hash_defweak
+                         || !h->def_regular))))
            {
              struct elf_dyn_relocs *p;
              struct elf_dyn_relocs **head;
index b2096044a10175d944aa51c7229dee5838d3df4f..8c8bcce5d72714ea4c38bc3bf3d0361dd5fbcc1b 100644 (file)
@@ -2601,20 +2601,19 @@ do_size:
             may need to keep relocations for symbols satisfied by a
             dynamic library if we manage to avoid copy relocs for the
             symbol.  */
-         if ((bfd_link_pic (info)
-              && (sec->flags & SEC_ALLOC) != 0
-              && (! IS_X86_64_PCREL_TYPE (r_type)
-                  || (h != NULL
-                      && (! (bfd_link_pie (info)
-                             || SYMBOLIC_BIND (info, h))
-                          || h->root.type == bfd_link_hash_defweak
-                          || !h->def_regular))))
-             || (ELIMINATE_COPY_RELOCS
-                 && !bfd_link_pic (info)
-                 && (sec->flags & SEC_ALLOC) != 0
-                 && h != NULL
-                 && (h->root.type == bfd_link_hash_defweak
-                     || !h->def_regular)))
+         if ((sec->flags & SEC_ALLOC) != 0
+             && ((bfd_link_pic (info)
+                  && (! IS_X86_64_PCREL_TYPE (r_type)
+                      || (h != NULL
+                          && (! (bfd_link_pie (info)
+                                 || SYMBOLIC_BIND (info, h))
+                              || h->root.type == bfd_link_hash_defweak
+                              || !h->def_regular))))
+                 || (ELIMINATE_COPY_RELOCS
+                     && !bfd_link_pic (info)
+                     && h != NULL
+                     && (h->root.type == bfd_link_hash_defweak
+                         || !h->def_regular))))
            {
              struct elf_dyn_relocs *p;
              struct elf_dyn_relocs **head;