Keep .plt section and DT_PLTGOT for prelink
[deliverable/binutils-gdb.git] / bfd / elf64-x86-64.c
index f7aea98d6bf9f9aba0722b05829f784216d60836..fb22602ed56152c97312e139e79ecbd770bbb577 100644 (file)
@@ -2571,14 +2571,16 @@ elf_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
          asection *bnd_s = htab->plt_bnd;
          asection *got_s = htab->plt_got;
 
+         /* If this is the first .plt entry, make room for the special
+            first entry.  The .plt section is used by prelink to undo
+            prelinking for dynamic relocations.  */
+         if (s->size == 0)
+           s->size = plt_entry_size;
+
          if (use_plt_got)
            eh->plt_got.offset = got_s->size;
          else
            {
-             /* If this is the first .plt entry, make room for the
-                special first entry.  */
-             if (s->size == 0)
-               s->size = plt_entry_size;
              h->plt.offset = s->size;
              if (bnd_s)
                eh->plt_bnd.offset = bnd_s->size;
@@ -3464,12 +3466,19 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd,
 
       if (htab->elf.splt->size != 0)
        {
-         if (!add_dynamic_entry (DT_PLTGOT, 0)
-             || !add_dynamic_entry (DT_PLTRELSZ, 0)
-             || !add_dynamic_entry (DT_PLTREL, DT_RELA)
-             || !add_dynamic_entry (DT_JMPREL, 0))
+         /* DT_PLTGOT is used by prelink even if there is no PLT
+            relocation.  */
+         if (!add_dynamic_entry (DT_PLTGOT, 0))
            return FALSE;
 
+         if (htab->elf.srelplt->size != 0)
+           {
+             if (!add_dynamic_entry (DT_PLTRELSZ, 0)
+                 || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+                 || !add_dynamic_entry (DT_JMPREL, 0))
+               return FALSE;
+           }
+
          if (htab->tlsdesc_plt
              && (!add_dynamic_entry (DT_TLSDESC_PLT, 0)
                  || !add_dynamic_entry (DT_TLSDESC_GOT, 0)))
This page took 0.024326 seconds and 4 git commands to generate.