* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Don't attempt to
[deliverable/binutils-gdb.git] / bfd / elf64-ppc.c
index 3ee3f69e2870e5690e2d72b5e28e9dae15633afe..523d1374a7fa60e3691e0ed848e062750c3344b6 100644 (file)
@@ -3005,8 +3005,8 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
        }
 
       /* Get start of .glink stubs from DT_PPC64_GLINK.  */
-      dynamic = bfd_get_section_by_name (abfd, ".dynamic");
-      if (dynamic != NULL)
+      if (dyn_count != 0
+         && (dynamic = bfd_get_section_by_name (abfd, ".dynamic")) != NULL)
        {
          bfd_byte *dynbuf, *extdyn, *extdynend;
          size_t extdynsize;
@@ -3061,21 +3061,21 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
 
          if (resolv_vma)
            size += sizeof (asymbol) + sizeof ("__glink_PLTresolve");
-       }
 
-      relplt = bfd_get_section_by_name (abfd, ".rela.plt");
-      if (glink != NULL && relplt != NULL)
-       {
-         slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
-         if (! (*slurp_relocs) (abfd, relplt, dyn_syms, TRUE))
-           goto free_contents_and_exit;
+         relplt = bfd_get_section_by_name (abfd, ".rela.plt");
+         if (relplt != NULL)
+           {
+             slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
+             if (! (*slurp_relocs) (abfd, relplt, dyn_syms, TRUE))
+               goto free_contents_and_exit;
        
-         plt_count = relplt->size / sizeof (Elf64_External_Rela);
-         size += plt_count * sizeof (asymbol);
+             plt_count = relplt->size / sizeof (Elf64_External_Rela);
+             size += plt_count * sizeof (asymbol);
 
-         p = relplt->relocation;
-         for (i = 0; i < plt_count; i++, p++)
-           size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
+             p = relplt->relocation;
+             for (i = 0; i < plt_count; i++, p++)
+               size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
+           }
        }
 
       s = *ret = bfd_malloc (size);
@@ -7891,7 +7891,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
           Undefined weak syms won't yet be marked as dynamic,
           nor will all TLS symbols.  */
        if (h->dynindx == -1
-           && !h->forced_local)
+           && !h->forced_local
+           && htab->elf.dynamic_sections_created)
          {
            if (! bfd_elf_link_record_dynamic_symbol (info, h))
              return FALSE;
@@ -7925,7 +7926,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
     else
       gent->got.offset = (bfd_vma) -1;
 
-  if (eh->dyn_relocs == NULL)
+  if (eh->dyn_relocs == NULL
+      || !htab->elf.dynamic_sections_created)
     return TRUE;
 
   /* In the shared -Bsymbolic case, discard space allocated for
@@ -7982,7 +7984,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
         dynamic.  */
 
       if (!h->non_got_ref
-         && h->def_dynamic
          && !h->def_regular)
        {
          /* Make sure this symbol is output as a dynamic symbol.
@@ -11251,7 +11252,6 @@ ppc64_elf_relocate_section (bfd *output_bfd,
                  && h != NULL
                  && h->elf.dynindx != -1
                  && !h->elf.non_got_ref
-                 && h->elf.def_dynamic
                  && !h->elf.def_regular))
            {
              Elf_Internal_Rela outrel;
This page took 0.032893 seconds and 4 git commands to generate.