* elf-m10300.c (_bfd_mn10300_elf_finish_dynamic_symbol): Use the
[deliverable/binutils-gdb.git] / bfd / elf32-hppa.c
index 7f20bd6aa235ac6d55dafc919bec106b8d95803e..b5d67140ecb268f9642ae8b1eb6c9ace45701023 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for HP PA-RISC ELF files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
    Original code by
        Center for Software Science
@@ -1004,7 +1004,7 @@ elf32_hppa_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
 /* Copy the extra info we tack onto an elf_link_hash_entry.  */
 
 static void
-elf32_hppa_copy_indirect_symbol (const struct elf_backend_data *bed,
+elf32_hppa_copy_indirect_symbol (struct bfd_link_info *info,
                                 struct elf_link_hash_entry *eh_dir,
                                 struct elf_link_hash_entry *eh_ind)
 {
@@ -1020,16 +1020,15 @@ elf32_hppa_copy_indirect_symbol (const struct elf_backend_data *bed,
          struct elf32_hppa_dyn_reloc_entry **hdh_pp;
          struct elf32_hppa_dyn_reloc_entry *hdh_p;
 
-         if (eh_ind->root.type == bfd_link_hash_indirect)
-           abort ();
-
-         /* Add reloc counts against the weak sym to the strong sym
+         /* Add reloc counts against the indirect sym to the direct sym
             list.  Merge any entries against the same section.  */
          for (hdh_pp = &hh_ind->dyn_relocs; (hdh_p = *hdh_pp) != NULL; )
            {
              struct elf32_hppa_dyn_reloc_entry *hdh_q;
 
-             for (hdh_q = hh_dir->dyn_relocs; hdh_q != NULL; hdh_q = hdh_q->hdh_next)
+             for (hdh_q = hh_dir->dyn_relocs;
+                  hdh_q != NULL;
+                  hdh_q = hdh_q->hdh_next)
                if (hdh_q->sec == hdh_p->sec)
                  {
 #if RELATIVE_DYNRELOCS
@@ -1062,7 +1061,7 @@ elf32_hppa_copy_indirect_symbol (const struct elf_backend_data *bed,
       eh_dir->needs_plt |= eh_ind->needs_plt;
     }
   else
-   _bfd_elf_link_hash_copy_indirect (bed, eh_dir, eh_ind);
+   _bfd_elf_link_hash_copy_indirect (info, eh_dir, eh_ind);
 }
 
 /* Look through the relocs for a section during the first phase, and
@@ -1446,13 +1445,15 @@ elf32_hppa_check_relocs (bfd *abfd,
                     easily.  Oh well.  */
 
                  asection *sr;
+                 void *vpp;
+
                  sr = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
                                                       sec, r_symndx);
                  if (sr == NULL)
                    return FALSE;
 
-                 hdh_head = ((struct elf32_hppa_dyn_reloc_entry **)
-                         &elf_section_data (sr)->local_dynrel);
+                 vpp = &elf_section_data (sr)->local_dynrel;
+                 hdh_head = (struct elf32_hppa_dyn_reloc_entry **) vpp;
                }
 
              hdh_p = *hdh_head;
@@ -2019,9 +2020,21 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
 
       /* Also discard relocs on undefined weak syms with non-default
         visibility.  */
-      if (ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT
+      if (hh->dyn_relocs != NULL
          && eh->root.type == bfd_link_hash_undefweak)
-       hh->dyn_relocs = NULL;
+       {
+         if (ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT)
+           hh->dyn_relocs = NULL;
+
+         /* Make sure undefined weak symbols are output as a dynamic
+            symbol in PIEs.  */
+         else if (eh->dynindx == -1
+                  && !eh->forced_local)
+           {
+             if (! bfd_elf_link_record_dynamic_symbol (info, eh))
+               return FALSE;
+           }
+       }
     }
   else
     {
@@ -2346,7 +2359,7 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
         must add the entries now so that we get the correct size for
         the .dynamic section.  The DT_DEBUG entry is filled in by the
         dynamic linker and used by the debugger.  */
-      if (!info->shared)
+      if (info->executable)
        {
          if (!add_dynamic_entry (DT_DEBUG, 0))
            return FALSE;
@@ -4044,7 +4057,7 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
   if (eh->root.root.string[0] == '_'
       && (strcmp (eh->root.root.string, "_DYNAMIC") == 0
-         || strcmp (eh->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0))
+         || eh == htab->etab.hgot))
     {
       sym->st_shndx = SHN_ABS;
     }
This page took 0.025128 seconds and 4 git commands to generate.