daily update
[deliverable/binutils-gdb.git] / bfd / elf32-sh.c
index 364ef237dd130c430da9c335bb4cb2998ef623e8..cf59095ed4773ccf70452bf9f3ae13c2de9732e2 100644 (file)
@@ -1,6 +1,6 @@
 /* Renesas / SuperH SH specific support for 32-bit ELF
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-   Free Software Foundation, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+   2006 Free Software Foundation, Inc.
    Contributed by Ian Lance Taylor, Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -3612,8 +3612,9 @@ sh_elf_link_hash_table_create (bfd *abfd)
   if (ret == (struct elf_sh_link_hash_table *) NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                      sh_elf_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+                                     sh_elf_link_hash_newfunc,
+                                     sizeof (struct elf_sh_link_hash_entry)))
     {
       free (ret);
       return NULL;
@@ -3726,6 +3727,7 @@ sh_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
       h = (struct elf_link_hash_entry *) bh;
       h->def_regular = 1;
       h->type = STT_OBJECT;
+      htab->root.hplt = h;
 
       if (info->shared
          && ! bfd_elf_link_record_dynamic_symbol (info, h))
@@ -4160,9 +4162,21 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 
       /* Also discard relocs on undefined weak syms with non-default
         visibility.  */
-      if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+      if (eh->dyn_relocs != NULL
          && h->root.type == bfd_link_hash_undefweak)
-       eh->dyn_relocs = NULL;
+       {
+         if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+           eh->dyn_relocs = NULL;
+
+         /* Make sure undefined weak symbols are output as a dynamic
+            symbol in PIEs.  */
+         else if (h->dynindx == -1
+                  && !h->forced_local)
+           {
+             if (! bfd_elf_link_record_dynamic_symbol (info, h))
+               return FALSE;
+           }
+       }
     }
   else
     {
@@ -4693,7 +4707,8 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                          || !h->def_regular)
                      && ((r_type == R_SH_DIR32
                           && !h->forced_local)
-                         || r_type == R_SH_REL32)
+                         || (r_type == R_SH_REL32
+                             && !SYMBOL_CALLS_LOCAL (info, h)))
                      && ((input_section->flags & SEC_ALLOC) != 0
                          /* DWARF will emit R_SH_DIR32 relocations in its
                             sections against symbols defined externally
@@ -4714,8 +4729,12 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
              else if (sec->output_section == NULL)
                {
                  (*_bfd_error_handler)
-                   (_("%B(%A): unresolvable relocation against symbol `%s'"),
-                    input_bfd, input_section, h->root.root.string);
+                   (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+                    input_bfd,
+                    input_section,
+                    (long) rel->r_offset,
+                    howto->name,
+                    h->root.root.string);
                  return FALSE;
                }
              else
@@ -6059,14 +6078,11 @@ sh_elf_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info,
 /* Copy the extra info we tack onto an elf_link_hash_entry.  */
 
 static void
-sh_elf_copy_indirect_symbol (const struct elf_backend_data *bed,
+sh_elf_copy_indirect_symbol (struct bfd_link_info *info,
                             struct elf_link_hash_entry *dir,
                             struct elf_link_hash_entry *ind)
 {
   struct elf_sh_link_hash_entry *edir, *eind;
-#ifdef INCLUDE_SHMEDIA
-  bfd_signed_vma tmp;
-#endif
 
   edir = (struct elf_sh_link_hash_entry *) dir;
   eind = (struct elf_sh_link_hash_entry *) ind;
@@ -6078,9 +6094,7 @@ sh_elf_copy_indirect_symbol (const struct elf_backend_data *bed,
          struct elf_sh_dyn_relocs **pp;
          struct elf_sh_dyn_relocs *p;
 
-         BFD_ASSERT (ind->root.type != bfd_link_hash_indirect);
-
-         /* 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 (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
            {
@@ -6106,14 +6120,8 @@ sh_elf_copy_indirect_symbol (const struct elf_backend_data *bed,
   edir->gotplt_refcount = eind->gotplt_refcount;
   eind->gotplt_refcount = 0;
 #ifdef INCLUDE_SHMEDIA
-  tmp = edir->datalabel_got.refcount;
-  if (tmp < 1)
-    {
-      edir->datalabel_got.refcount = eind->datalabel_got.refcount;
-      eind->datalabel_got.refcount = tmp;
-    }
-  else
-    BFD_ASSERT (eind->datalabel_got.refcount < 1);
+  edir->datalabel_got.refcount += eind->datalabel_got.refcount;
+  eind->datalabel_got.refcount = 0;
 #endif
 
   if (ind->root.type == bfd_link_hash_indirect
@@ -6135,7 +6143,7 @@ sh_elf_copy_indirect_symbol (const struct elf_backend_data *bed,
       dir->needs_plt |= ind->needs_plt;
     }
   else
-    _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
+    _bfd_elf_link_hash_copy_indirect (info, dir, ind);
 }
 
 static int
@@ -6561,6 +6569,7 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
              else
                {
                  asection *s;
+                 void *vpp;
 
                  /* Track dynamic relocs needed for local syms too.  */
                  s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
@@ -6568,8 +6577,8 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
                  if (s == NULL)
                    return FALSE;
 
-                 head = ((struct elf_sh_dyn_relocs **)
-                         &elf_section_data (s)->local_dynrel);
+                 vpp = &elf_section_data (s)->local_dynrel;
+                 head = (struct elf_sh_dyn_relocs **) vpp;
                }
 
              p = *head;
@@ -6651,7 +6660,7 @@ sh_elf_set_mach_from_flags (bfd *abfd)
 int
 sh_elf_get_flags_from_mach (unsigned long mach)
 {
-  int i = ARRAY_SIZE (sh_ef_bfd_table);
+  int i = ARRAY_SIZE (sh_ef_bfd_table) - 1;
   
   for (; i>0; i--)
     if (sh_ef_bfd_table[i] == mach)
@@ -7028,7 +7037,7 @@ sh_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
   if (strcmp (h->root.root.string, "_DYNAMIC") == 0
-      || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+      || h == htab->root.hgot)
     sym->st_shndx = SHN_ABS;
 
   return TRUE;
@@ -7362,6 +7371,7 @@ sh_elf_plt_sym_val (bfd_vma i, const asection *plt,
 #define        TARGET_LITTLE_NAME              "elf32-shl-nbsd"
 #undef ELF_MAXPAGESIZE
 #define        ELF_MAXPAGESIZE                 0x10000
+#undef ELF_COMMONPAGESIZE
 #undef elf_symbol_leading_char
 #define        elf_symbol_leading_char         0
 #undef elf32_bed
@@ -7379,6 +7389,8 @@ sh_elf_plt_sym_val (bfd_vma i, const asection *plt,
 #define        TARGET_LITTLE_SYM               bfd_elf32_shlin_vec
 #undef TARGET_LITTLE_NAME
 #define        TARGET_LITTLE_NAME              "elf32-sh-linux"
+#undef ELF_COMMONPAGESIZE
+#define        ELF_COMMONPAGESIZE              0x1000
 
 #undef elf_backend_grok_prstatus
 #define        elf_backend_grok_prstatus       elf32_shlin_grok_prstatus
This page took 0.030067 seconds and 4 git commands to generate.