* cris.h (R_CRIS_32_GOT_GD, R_CRIS_16_GOT_GD, R_CRIS_32_GD)
[deliverable/binutils-gdb.git] / bfd / elf64-ppc.c
index 9b11c37eb136f7d709a0189454bbe82911f0041a..86fe3c3de84f015c80b8d41bb16a1e12bbd9195c 100644 (file)
@@ -2954,6 +2954,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
              size_t len;
 
              *s = *syms[i];
+             s->flags |= BSF_SYNTHETIC;
              s->section = sym->section;
              s->value = sym->value + r->addend;
              s->name = names;
@@ -3124,6 +3125,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
                  if ((sec->flags & SEC_CODE) != 0)
                    s->section = sec;
                }
+             s->flags |= BSF_SYNTHETIC;
              s->value = ent - s->section->vma;
              s->name = names;
              *names++ = '.';
@@ -3143,9 +3145,9 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
          if (resolv_vma)
            {
              /* Add a symbol for the main glink trampoline.  */
-             memset (s, sizeof *s, 0);
+             memset (s, 0, sizeof *s);
              s->the_bfd = abfd;
-             s->flags = BSF_GLOBAL;
+             s->flags = BSF_GLOBAL | BSF_SYNTHETIC;
              s->section = glink;
              s->value = resolv_vma - glink->vma;
              s->name = names;
@@ -3181,6 +3183,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
                 we are defining a symbol, ensure one of them is set.  */
              if ((s->flags & BSF_LOCAL) == 0)
                s->flags |= BSF_GLOBAL;
+             s->flags |= BSF_SYNTHETIC;
              s->section = glink;
              s->value = glink_vma - glink->vma;
              s->name = names;
@@ -7888,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;
@@ -7922,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
@@ -7979,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.
@@ -8708,6 +8712,8 @@ ppc_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
          if (r == NULL)
            return FALSE;
          r[0].r_offset = loc - stub_entry->stub_sec->contents;
+         if (bfd_big_endian (info->output_bfd))
+           r[0].r_offset += 2;
          if (stub_entry->stub_type == ppc_stub_plt_branch_r2off)
            r[0].r_offset += 4;
          r[0].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_DS);
@@ -8829,6 +8835,8 @@ ppc_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
          if (r == NULL)
            return FALSE;
          r[0].r_offset = loc - stub_entry->stub_sec->contents;
+         if (bfd_big_endian (info->output_bfd))
+           r[0].r_offset += 2;
          r[0].r_addend = dest;
        }
       p = build_plt_stub (htab->stub_bfd, loc, off, r);
@@ -9177,6 +9185,7 @@ toc_adjusting_stub_needed (struct bfd_link_info *info, asection *isec)
       enum elf_ppc64_reloc_type r_type;
       unsigned long r_symndx;
       struct elf_link_hash_entry *h;
+      struct ppc_link_hash_entry *eh;
       Elf_Internal_Sym *sym;
       asection *sym_sec;
       struct _opd_sec_data *opd;
@@ -9199,24 +9208,21 @@ toc_adjusting_stub_needed (struct bfd_link_info *info, asection *isec)
        }
 
       /* Calls to dynamic lib functions go through a plt call stub
-        that uses r2.  Branches to undefined symbols might be a call
-        using old-style dot symbols that can be satisfied by a plt
-        call into a new-style dynamic library.  */
-      if (sym_sec == NULL)
+        that uses r2.  */
+      eh = (struct ppc_link_hash_entry *) h;
+      if (eh != NULL
+         && (eh->elf.plt.plist != NULL
+             || (eh->oh != NULL
+                 && eh->oh->elf.plt.plist != NULL)))
        {
-         struct ppc_link_hash_entry *eh = (struct ppc_link_hash_entry *) h;
-         if (eh != NULL
-             && eh->oh != NULL
-             && eh->oh->elf.plt.plist != NULL)
-           {
-             ret = 1;
-             break;
-           }
-
-         /* Ignore other undefined symbols.  */
-         continue;
+         ret = 1;
+         break;
        }
 
+      if (sym_sec == NULL)
+       /* Ignore other undefined symbols.  */
+       continue;
+
       /* Assume branches to other sections not included in the link need
         stubs too, to cover -R and absolute syms.  */
       if (sym_sec->output_section == NULL)
@@ -11246,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.029852 seconds and 4 git commands to generate.