bfd/
authorAlan Modra <amodra@gmail.com>
Mon, 1 Jul 2013 03:45:05 +0000 (03:45 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 1 Jul 2013 03:45:05 +0000 (03:45 +0000)
* elf64-ppc.h (ppc64_elf_toc): Delete.
(ppc64_elf_set_toc): Declare.
* elf64-ppc.c (ppc64_elf_toc_reloc): Replace call to ppc64_elf_toc
with call the ppc64_elf_set_toc.
(ppc64_elf_toc_ha_reloc, ppc64_elf_toc64_reloc): Likewise.
(ppc64_elf_start_multitoc_partition): Likewise.
(struct ppc_link_hash_table): Delete dot_toc_dot.  Replace all uses
with elf.hgot.
(ppc64_elf_process_dot_syms): Don't make a fake function descriptor
for ".TOC.".
(ppc64_elf_check_relocs): Mark sections with a reference to .TOC.
as needing a toc pointer.
(ppc64_elf_size_stubs): Don't set dot_toc_dot here.
(ppc64_elf_set_toc): Rename from ppc64_elf_toc.  Add info param.
Set elf.hgot value.
ld/
* emultempl/ppc64elf.em: (ppc_layout_sections_again): Call
ppc64_elf_set_toc rather than ppc64_elf_toc/_bfd_set_gp_value.
(gld${EMULATION_NAME}_after_allocation): Likewise.

bfd/ChangeLog
bfd/elf64-ppc.c
bfd/elf64-ppc.h
ld/ChangeLog
ld/emultempl/ppc64elf.em

index a5928171d6519e653ae3244a8ceca408c500a6b8..1bbbb87a2d5a1d854133552e0bb1d7783a0fb01a 100644 (file)
@@ -1,3 +1,21 @@
+2013-07-01  Alan Modra  <amodra@gmail.com>
+
+       * elf64-ppc.h (ppc64_elf_toc): Delete.
+       (ppc64_elf_set_toc): Declare.
+       * elf64-ppc.c (ppc64_elf_toc_reloc): Replace call to ppc64_elf_toc
+       with call the ppc64_elf_set_toc.
+       (ppc64_elf_toc_ha_reloc, ppc64_elf_toc64_reloc): Likewise.
+       (ppc64_elf_start_multitoc_partition): Likewise.
+       (struct ppc_link_hash_table): Delete dot_toc_dot.  Replace all uses
+       with elf.hgot.
+       (ppc64_elf_process_dot_syms): Don't make a fake function descriptor
+       for ".TOC.".
+       (ppc64_elf_check_relocs): Mark sections with a reference to .TOC.
+       as needing a toc pointer.
+       (ppc64_elf_size_stubs): Don't set dot_toc_dot here.
+       (ppc64_elf_set_toc): Rename from ppc64_elf_toc.  Add info param.
+       Set elf.hgot value.
+
 2013-06-28  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/15685
index d4415e4576b78d49dad056f5bc7eb9e672342c34..fb808d649fa87a4dc34538c6acc9a38a547888f4 100644 (file)
@@ -2472,7 +2472,7 @@ ppc64_elf_toc_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
 
   TOCstart = _bfd_get_gp_value (input_section->output_section->owner);
   if (TOCstart == 0)
-    TOCstart = ppc64_elf_toc (input_section->output_section->owner);
+    TOCstart = ppc64_elf_set_toc (NULL, input_section->output_section->owner);
 
   /* Subtract the TOC base address.  */
   reloc_entry->addend -= TOCstart + TOC_BASE_OFF;
@@ -2495,7 +2495,7 @@ ppc64_elf_toc_ha_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
 
   TOCstart = _bfd_get_gp_value (input_section->output_section->owner);
   if (TOCstart == 0)
-    TOCstart = ppc64_elf_toc (input_section->output_section->owner);
+    TOCstart = ppc64_elf_set_toc (NULL, input_section->output_section->owner);
 
   /* Subtract the TOC base address.  */
   reloc_entry->addend -= TOCstart + TOC_BASE_OFF;
@@ -2522,7 +2522,7 @@ ppc64_elf_toc64_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
 
   TOCstart = _bfd_get_gp_value (input_section->output_section->owner);
   if (TOCstart == 0)
-    TOCstart = ppc64_elf_toc (input_section->output_section->owner);
+    TOCstart = ppc64_elf_set_toc (NULL, input_section->output_section->owner);
 
   octets = reloc_entry->address * bfd_octets_per_byte (abfd);
   bfd_put_64 (abfd, TOCstart + TOC_BASE_OFF, (bfd_byte *) data + octets);
@@ -3772,9 +3772,6 @@ struct ppc_link_hash_table
   struct ppc_link_hash_entry *tls_get_addr;
   struct ppc_link_hash_entry *tls_get_addr_fd;
 
-  /* The special .TOC. symbol.  */
-  struct ppc_link_hash_entry *dot_toc_dot;
-
   /* The size of reliplt used by got entry relocs.  */
   bfd_size_type got_reli_size;
 
@@ -4774,7 +4771,12 @@ ppc64_elf_process_dot_syms (bfd *ibfd, struct bfd_link_info *info)
       while ((eh = *p) != NULL)
        {
          *p = NULL;
-         if (!add_symbol_adjust (eh, info))
+         if (&eh->elf == htab->elf.hgot)
+           ;
+         else if (htab->elf.hgot == NULL
+                  && strcmp (eh->elf.root.root.string, ".TOC.") == 0)
+           htab->elf.hgot = &eh->elf;
+         else if (!add_symbol_adjust (eh, info))
            return FALSE;
          p = &eh->u.next_dot_sym;
        }
@@ -5007,6 +5009,9 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
          /* PR15323, ref flags aren't set for references in the same
             object.  */
          h->root.non_ir_ref = 1;
+
+         if (h == htab->elf.hgot)
+           sec->has_toc_reloc = 1;
        }
 
       tls_type = 0;
@@ -10617,8 +10622,7 @@ ppc64_elf_start_multitoc_partition (struct bfd_link_info *info)
 {
   struct ppc_link_hash_table *htab = ppc_hash_table (info);
 
-  elf_gp (info->output_bfd) = ppc64_elf_toc (info->output_bfd);
-  htab->toc_curr = elf_gp (info->output_bfd);
+  htab->toc_curr = ppc64_elf_set_toc (info, info->output_bfd);
   htab->toc_bfd = NULL;
   htab->toc_first_sec = NULL;
 }
@@ -11450,9 +11454,6 @@ ppc64_elf_size_stubs (struct bfd_link_info *info, bfd_signed_vma group_size,
        }
     }
   htab->plt_thread_safe = plt_thread_safe;
-  htab->dot_toc_dot = ((struct ppc_link_hash_entry *)
-                      elf_link_hash_lookup (&htab->elf, ".TOC.",
-                                            FALSE, FALSE, TRUE));
   stubs_always_before_branch = group_size < 0;
   if (group_size < 0)
     stub_group_size = -group_size;
@@ -11853,7 +11854,7 @@ ppc64_elf_size_stubs (struct bfd_link_info *info, bfd_signed_vma group_size,
    move, we'll be called again.  Provide a value for TOCstart.  */
 
 bfd_vma
-ppc64_elf_toc (bfd *obfd)
+ppc64_elf_set_toc (struct bfd_link_info *info, bfd *obfd)
 {
   asection *s;
   bfd_vma TOCstart;
@@ -11904,6 +11905,20 @@ ppc64_elf_toc (bfd *obfd)
   if (s != NULL)
     TOCstart = s->output_section->vma + s->output_offset;
 
+  _bfd_set_gp_value (obfd, TOCstart);
+
+  if (info != NULL && s != NULL && is_ppc64_elf (obfd))
+    {
+      struct ppc_link_hash_table *htab = ppc_hash_table (info);
+
+      if (htab != NULL
+         && htab->elf.hgot != NULL)
+       {
+         htab->elf.hgot->root.type = bfd_link_hash_defined;
+         htab->elf.hgot->root.u.def.value = TOC_BASE_OFF;
+         htab->elf.hgot->root.u.def.section = s;
+       }
+    }
   return TOCstart;
 }
 
@@ -12452,7 +12467,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
                      }
                  }
            }
-         if (h_elf == &htab->dot_toc_dot->elf)
+         if (h_elf == htab->elf.hgot)
            {
              relocation = (TOCstart
                            + htab->stub_group[input_section->id].toc_off);
index 89495bcfc0fadcd66dc7a8c23973e074a53d0ce2..06c655f746a17b81c4da2c0bb061ee9b8f16114f 100644 (file)
@@ -31,8 +31,8 @@ bfd_boolean ppc64_elf_edit_toc
   (struct bfd_link_info *);
 bfd_boolean ppc64_elf_has_small_toc_reloc
   (asection *);
-bfd_vma ppc64_elf_toc
-  (bfd *);
+bfd_vma ppc64_elf_set_toc
+  (struct bfd_link_info *, bfd *);
 int ppc64_elf_setup_section_lists
   (struct bfd_link_info *, asection *(*) (const char *, asection *),
    void (*) (void));
index a42de634d0bb73b5541c541679ed24a0314e6a36..28bf16effbb55654c0a473c32562bc84e50fffb1 100644 (file)
@@ -1,3 +1,9 @@
+2013-07-01  Alan Modra  <amodra@gmail.com>
+
+       * emultempl/ppc64elf.em: (ppc_layout_sections_again): Call
+       ppc64_elf_set_toc rather than ppc64_elf_toc/_bfd_set_gp_value.
+       (gld${EMULATION_NAME}_after_allocation): Likewise.
+
 2013-06-26  Yufeng Zhang  <yufeng.zhang@arm.com>
 
        * emulparams/aarch64elf32.sh: New file.
index 43f9b6106fd3e02c0fe8d03b0b671573fc61345e..f2085d7dcf74c1eba9b600a0caaa8cec6d86add2 100644 (file)
@@ -423,8 +423,7 @@ ppc_layout_sections_again (void)
   gld${EMULATION_NAME}_map_segments (TRUE);
 
   if (!link_info.relocatable)
-    _bfd_set_gp_value (link_info.output_bfd,
-                      ppc64_elf_toc (link_info.output_bfd));
+    ppc64_elf_set_toc (&link_info, link_info.output_bfd);
 
   need_laying_out = -1;
 }
@@ -525,8 +524,7 @@ gld${EMULATION_NAME}_after_allocation (void)
       gld${EMULATION_NAME}_map_segments (need_laying_out);
 
       if (!link_info.relocatable)
-       _bfd_set_gp_value (link_info.output_bfd,
-                          ppc64_elf_toc (link_info.output_bfd));
+       ppc64_elf_set_toc (&link_info, link_info.output_bfd);
     }
 }
 
This page took 0.047958 seconds and 4 git commands to generate.