bfd/
[deliverable/binutils-gdb.git] / bfd / elf64-sparc.c
index 4224310267598ab0a637735b860bbcf7a16ca307..01b80cda4d5a6d043e5811fc7be2aa25c91a5557 100644 (file)
@@ -1,6 +1,6 @@
 /* SPARC-specific support for 64-bit ELF
    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003 Free Software Foundation, Inc.
+   2003, 2004 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -61,7 +61,7 @@ static bfd_boolean sparc64_elf_size_dynamic_sections
 static int sparc64_elf_get_symbol_type
   PARAMS (( Elf_Internal_Sym *, int));
 static bfd_boolean sparc64_elf_add_symbol_hook
-  PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
+  PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Sym *,
           const char **, flagword *, asection **, bfd_vma *));
 static bfd_boolean sparc64_elf_output_arch_syms
   PARAMS ((bfd *, struct bfd_link_info *, PTR,
@@ -478,7 +478,7 @@ sparc64_elf_slurp_reloc_table (abfd, asect, symbols, dynamic)
         case because relocations against this section may use the
         dynamic symbol table, and in that case bfd_section_from_shdr
         in elf.c does not update the RELOC_COUNT.  */
-      if (asect->_raw_size == 0)
+      if (asect->size == 0)
        return TRUE;
 
       rel_hdr = &d->this_hdr;
@@ -809,7 +809,7 @@ init_insn_reloc (abfd,
   if (output_bfd != NULL)
     return bfd_reloc_continue;
 
-  if (reloc_entry->address > input_section->_cooked_size)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   relocation = (symbol->value
@@ -1173,16 +1173,16 @@ sparc64_elf_check_relocs (abfd, info, sec, relocs)
                  /* We have already allocated space in the .got.  */
                  break;
                }
-             h->got.offset = sgot->_raw_size;
+             h->got.offset = sgot->size;
 
              /* Make sure this symbol is output as a dynamic symbol.  */
              if (h->dynindx == -1)
                {
-                 if (! bfd_elf64_link_record_dynamic_symbol (info, h))
+                 if (! bfd_elf_link_record_dynamic_symbol (info, h))
                    return FALSE;
                }
 
-             srelgot->_raw_size += sizeof (Elf64_External_Rela);
+             srelgot->size += sizeof (Elf64_External_Rela);
            }
          else
            {
@@ -1207,18 +1207,18 @@ sparc64_elf_check_relocs (abfd, info, sec, relocs)
                  /* We have already allocated space in the .got.  */
                  break;
                }
-             local_got_offsets[r_symndx] = sgot->_raw_size;
+             local_got_offsets[r_symndx] = sgot->size;
 
              if (info->shared)
                {
                  /* If we are generating a shared object, we need to
                      output a R_SPARC_RELATIVE reloc so that the
                      dynamic linker can adjust this GOT entry.  */
-                 srelgot->_raw_size += sizeof (Elf64_External_Rela);
+                 srelgot->size += sizeof (Elf64_External_Rela);
                }
            }
 
-         sgot->_raw_size += 8;
+         sgot->size += 8;
 
 #if 0
          /* Doesn't work for 64-bit -fPIC, since sethi/or builds
@@ -1229,7 +1229,7 @@ sparc64_elf_check_relocs (abfd, info, sec, relocs)
          /* If the .got section is more than 0x1000 bytes, we add
             0x1000 to the value of _GLOBAL_OFFSET_TABLE_, so that 13
             bit relocations have a greater chance of working.  */
-         if (sgot->_raw_size >= 0x1000
+         if (sgot->size >= 0x1000
              && elf_hash_table (info)->hgot->root.u.def.value == 0)
            elf_hash_table (info)->hgot->root.u.def.value = 0x1000;
 #endif
@@ -1261,11 +1261,11 @@ sparc64_elf_check_relocs (abfd, info, sec, relocs)
          /* Make sure this symbol is output as a dynamic symbol.  */
          if (h->dynindx == -1)
            {
-             if (! bfd_elf64_link_record_dynamic_symbol (info, h))
+             if (! bfd_elf_link_record_dynamic_symbol (info, h))
                return FALSE;
            }
 
-         h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+         h->needs_plt = 1;
          if (ELF64_R_TYPE_ID (rel->r_info) != R_SPARC_PLT32
              && ELF64_R_TYPE_ID (rel->r_info) != R_SPARC_PLT64)
            break;
@@ -1359,7 +1359,7 @@ sparc64_elf_check_relocs (abfd, info, sec, relocs)
                    info->flags |= DF_TEXTREL;
                }
 
-             sreloc->_raw_size += sizeof (Elf64_External_Rela);
+             sreloc->size += sizeof (Elf64_External_Rela);
            }
          break;
 
@@ -1368,9 +1368,8 @@ sparc64_elf_check_relocs (abfd, info, sec, relocs)
          break;
 
        default:
-         (*_bfd_error_handler) (_("%s: check_relocs: unhandled reloc type %d"),
-                               bfd_archive_filename (abfd),
-                               ELF64_R_TYPE_ID (rel->r_info));
+         (*_bfd_error_handler) (_("%B: check_relocs: unhandled reloc type %d"),
+                               abfd, ELF64_R_TYPE_ID (rel->r_info));
          return FALSE;
        }
     }
@@ -1385,7 +1384,7 @@ static bfd_boolean
 sparc64_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
      bfd *abfd;
      struct bfd_link_info *info;
-     const Elf_Internal_Sym *sym;
+     Elf_Internal_Sym *sym;
      const char **namep;
      flagword *flagsp ATTRIBUTE_UNUSED;
      asection **secp ATTRIBUTE_UNUSED;
@@ -1405,8 +1404,8 @@ sparc64_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
        case 6: reg -= 4; break;
        default:
           (*_bfd_error_handler)
-            (_("%s: Only registers %%g[2367] can be declared using STT_REGISTER"),
-             bfd_archive_filename (abfd));
+            (_("%B: Only registers %%g[2367] can be declared using STT_REGISTER"),
+             abfd);
          return FALSE;
        }
 
@@ -1425,10 +1424,10 @@ sparc64_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
       if (p->name != NULL && strcmp (p->name, *namep))
        {
           (*_bfd_error_handler)
-            (_("Register %%g%d used incompatibly: %s in %s, previously %s in %s"),
-             (int) sym->st_value,
-             **namep ? *namep : "#scratch", bfd_archive_filename (abfd),
-             *p->name ? p->name : "#scratch", bfd_archive_filename (p->abfd));
+            (_("Register %%g%d used incompatibly: %s in %B, previously %s in %B"),
+             abfd, p->abfd, (int) sym->st_value,
+             **namep ? *namep : "#scratch",
+             *p->name ? p->name : "#scratch");
          return FALSE;
        }
 
@@ -1448,9 +1447,8 @@ sparc64_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
                  if (type > STT_FUNC)
                    type = 0;
                  (*_bfd_error_handler)
-                   (_("Symbol `%s' has differing types: REGISTER in %s, previously %s in %s"),
-                    *namep, bfd_archive_filename (abfd),
-                    stt_types[type], bfd_archive_filename (p->abfd));
+                   (_("Symbol `%s' has differing types: REGISTER in %B, previously %s in %B"),
+                    abfd, p->abfd, *namep, stt_types[type]);
                  return FALSE;
                }
 
@@ -1494,9 +1492,8 @@ sparc64_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
            if (type > STT_FUNC)
              type = 0;
            (*_bfd_error_handler)
-             (_("Symbol `%s' has differing types: %s in %s, previously REGISTER in %s"),
-              *namep, stt_types[type], bfd_archive_filename (abfd),
-              bfd_archive_filename (p->abfd));
+             (_("Symbol `%s' has differing types: %s in %B, previously REGISTER in %B"),
+              abfd, p->abfd, *namep, stt_types[type]);
            return FALSE;
          }
     }
@@ -1615,14 +1612,11 @@ sparc64_elf_adjust_dynamic_symbol (info, h)
 
   /* Make sure we know what is going on here.  */
   BFD_ASSERT (dynobj != NULL
-             && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
-                 || h->weakdef != NULL
-                 || ((h->elf_link_hash_flags
-                      & ELF_LINK_HASH_DEF_DYNAMIC) != 0
-                     && (h->elf_link_hash_flags
-                         & ELF_LINK_HASH_REF_REGULAR) != 0
-                     && (h->elf_link_hash_flags
-                         & ELF_LINK_HASH_DEF_REGULAR) == 0)));
+             && (h->needs_plt
+                 || h->u.weakdef != NULL
+                 || (h->def_dynamic
+                     && h->ref_regular
+                     && !h->def_regular)));
 
   /* If this is a function, put it in the procedure linkage table.  We
      will fill in the contents of the procedure linkage table later
@@ -1632,7 +1626,7 @@ sparc64_elf_adjust_dynamic_symbol (info, h)
      some of their functions as STT_NOTYPE when they really should be
      STT_FUNC.  */
   if (h->type == STT_FUNC
-      || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0
+      || h->needs_plt
       || (h->type == STT_NOTYPE
          && (h->root.type == bfd_link_hash_defined
              || h->root.type == bfd_link_hash_defweak)
@@ -1645,7 +1639,7 @@ sparc64_elf_adjust_dynamic_symbol (info, h)
              In such a case, we don't actually need to build a
              procedure linkage table, and we can just do a WDISP30
              reloc instead.  */
-         BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
+         BFD_ASSERT (h->needs_plt);
          return TRUE;
        }
 
@@ -1653,11 +1647,11 @@ sparc64_elf_adjust_dynamic_symbol (info, h)
       BFD_ASSERT (s != NULL);
 
       /* The first four bit in .plt is reserved.  */
-      if (s->_raw_size == 0)
-       s->_raw_size = PLT_HEADER_SIZE;
+      if (s->size == 0)
+       s->size = PLT_HEADER_SIZE;
 
       /* To simplify matters later, just store the plt index here.  */
-      h->plt.offset = s->_raw_size / PLT_ENTRY_SIZE;
+      h->plt.offset = s->size / PLT_ENTRY_SIZE;
 
       /* If this symbol is not defined in a regular file, and we are
         not generating a shared library, then set the symbol to this
@@ -1665,25 +1659,25 @@ sparc64_elf_adjust_dynamic_symbol (info, h)
         pointers compare as equal between the normal executable and
         the shared library.  */
       if (! info->shared
-         && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+         && !h->def_regular)
        {
          h->root.u.def.section = s;
          h->root.u.def.value = sparc64_elf_plt_entry_offset (h->plt.offset);
        }
 
       /* Make room for this entry.  */
-      s->_raw_size += PLT_ENTRY_SIZE;
+      s->size += PLT_ENTRY_SIZE;
 
       /* We also need to make an entry in the .rela.plt section.  */
 
       s = bfd_get_section_by_name (dynobj, ".rela.plt");
       BFD_ASSERT (s != NULL);
 
-      s->_raw_size += sizeof (Elf64_External_Rela);
+      s->size += sizeof (Elf64_External_Rela);
 
       /* The procedure linkage table size is bounded by the magnitude
         of the offset we can describe in the entry.  */
-      if (s->_raw_size >= (bfd_vma)1 << 32)
+      if (s->size >= (bfd_vma)1 << 32)
        {
          bfd_set_error (bfd_error_bad_value);
          return FALSE;
@@ -1695,12 +1689,12 @@ sparc64_elf_adjust_dynamic_symbol (info, h)
   /* If this is a weak symbol, and there is a real definition, the
      processor independent code will have arranged for us to see the
      real definition first, and we can just use the same value.  */
-  if (h->weakdef != NULL)
+  if (h->u.weakdef != NULL)
     {
-      BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
-                 || h->weakdef->root.type == bfd_link_hash_defweak);
-      h->root.u.def.section = h->weakdef->root.u.def.section;
-      h->root.u.def.value = h->weakdef->root.u.def.value;
+      BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
+                 || h->u.weakdef->root.type == bfd_link_hash_defweak);
+      h->root.u.def.section = h->u.weakdef->root.u.def.section;
+      h->root.u.def.value = h->u.weakdef->root.u.def.value;
       return TRUE;
     }
 
@@ -1737,8 +1731,8 @@ sparc64_elf_adjust_dynamic_symbol (info, h)
 
       srel = bfd_get_section_by_name (dynobj, ".rela.bss");
       BFD_ASSERT (srel != NULL);
-      srel->_raw_size += sizeof (Elf64_External_Rela);
-      h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
+      srel->size += sizeof (Elf64_External_Rela);
+      h->needs_copy = 1;
     }
 
   /* We need to figure out the alignment required for this symbol.  I
@@ -1749,8 +1743,7 @@ sparc64_elf_adjust_dynamic_symbol (info, h)
     power_of_two = 4;
 
   /* Apply the required alignment.  */
-  s->_raw_size = BFD_ALIGN (s->_raw_size,
-                           (bfd_size_type) (1 << power_of_two));
+  s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two));
   if (power_of_two > bfd_get_section_alignment (dynobj, s))
     {
       if (! bfd_set_section_alignment (dynobj, s, power_of_two))
@@ -1759,10 +1752,10 @@ sparc64_elf_adjust_dynamic_symbol (info, h)
 
   /* Define the symbol as being at this point in the section.  */
   h->root.u.def.section = s;
-  h->root.u.def.value = s->_raw_size;
+  h->root.u.def.value = s->size;
 
   /* Increment the section size to make room for the symbol.  */
-  s->_raw_size += h->size;
+  s->size += h->size;
 
   return TRUE;
 }
@@ -1788,7 +1781,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
-         s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
+         s->size = sizeof ELF_DYNAMIC_INTERPRETER;
          s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
        }
     }
@@ -1801,7 +1794,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info)
          below.  */
       s = bfd_get_section_by_name (dynobj, ".rela.got");
       if (s != NULL)
-       s->_raw_size = 0;
+       s->size = 0;
     }
 
   /* The check_relocs and adjust_dynamic_symbol entry points have
@@ -1824,7 +1817,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info)
 
       if (strncmp (name, ".rela", 5) == 0)
        {
-         if (s->_raw_size == 0)
+         if (s->size == 0)
            {
              /* If we don't need this section, strip it from the
                 output file.  This is to handle .rela.bss and
@@ -1863,8 +1856,8 @@ sparc64_elf_size_dynamic_sections (output_bfd, info)
       /* Allocate memory for the section contents.  Zero the memory
         for the benefit of .rela.plt, which has 4 unused entries
         at the beginning, and we don't want garbage.  */
-      s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
-      if (s->contents == NULL && s->_raw_size != 0)
+      s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
+      if (s->contents == NULL && s->size != 0)
        return FALSE;
     }
 
@@ -1876,7 +1869,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info)
         the .dynamic section.  The DT_DEBUG entry is filled in by the
         dynamic linker and used by the debugger.  */
 #define add_dynamic_entry(TAG, VAL) \
-  bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+  _bfd_elf_add_dynamic_entry (info, TAG, VAL)
 
       int reg;
       struct sparc64_elf_app_reg * app_regs;
@@ -1989,17 +1982,6 @@ sparc64_elf_relax_section (abfd, section, link_info, again)
   return TRUE;
 }
 \f
-/* This is the condition under which finish_dynamic_symbol will be called
-   from elflink.h.  If elflink.h doesn't call our finish_dynamic_symbol
-   routine, we'll need to do something about initializing any .plt and
-   .got entries in relocate_section.  */
-#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H)                  \
-  ((DYN)                                                               \
-   && ((INFO)->shared                                                  \
-       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)     \
-   && ((H)->dynindx != -1                                              \
-       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
-
 /* Relocate a SPARC64 ELF section.  */
 
 static bfd_boolean
@@ -2039,6 +2021,8 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
     got_base = elf_hash_table (info)->hgot->root.u.def.value;
 
   sgot = splt = sreloc = NULL;
+  if (dynobj != NULL)
+    splt = bfd_get_section_by_name (dynobj, ".plt");
 
   rel = relocs;
   relend = relocs + NUM_SHDR_ENTRIES (& elf_section_data (input_section)->rel_hdr);
@@ -2079,10 +2063,10 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          bfd_boolean warned;
 
-         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx,
-                                  symtab_hdr, relocation, sec,
-                                  unresolved_reloc, info,
-                                  warned);
+         RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+                                  r_symndx, symtab_hdr, sym_hashes,
+                                  h, sec, relocation,
+                                  unresolved_reloc, warned);
          if (warned)
            {
              /* To avoid generating warning messages about truncated
@@ -2222,14 +2206,20 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                    break;
                  }
 
+               /* FIXME: Dynamic reloc handling really needs to be rewritten.  */
+               if (!skip
+                   && h != NULL
+                   && ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+                   && h->root.type == bfd_link_hash_undefweak)
+                 skip = TRUE, relocate = TRUE;
+
                if (skip)
                  memset (&outrel, 0, sizeof outrel);
                /* h->dynindx may be -1 if the symbol was marked to
                   become local.  */
                else if (h != NULL && ! is_plt
                         && ((! info->symbolic && h->dynindx != -1)
-                            || (h->elf_link_hash_flags
-                                & ELF_LINK_HASH_DEF_REGULAR) == 0))
+                            || !h->def_regular))
                  {
                    BFD_ASSERT (h->dynindx != -1);
                    outrel.r_info
@@ -2278,8 +2268,8 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                              {
                                BFD_FAIL ();
                                (*_bfd_error_handler)
-                                 (_("%s: probably compiled without -fPIC?"),
-                                  bfd_archive_filename (input_bfd));
+                                 (_("%B: probably compiled without -fPIC?"),
+                                  input_bfd);
                                bfd_set_error (bfd_error_bad_value);
                                return FALSE;
                              }
@@ -2327,12 +2317,12 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
              BFD_ASSERT (off != (bfd_vma) -1);
              dyn = elf_hash_table (info)->dynamic_sections_created;
 
-             if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
+             if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
                  || (info->shared
                      && (info->symbolic
                          || h->dynindx == -1
-                         || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
-                     && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+                         || h->forced_local)
+                     && h->def_regular))
                {
                  /* This is actually a static link, or it is a -Bsymbolic
                     link and the symbol is defined locally, or the symbol
@@ -2420,7 +2410,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
              procedure linkage table.  */
          BFD_ASSERT (h != NULL);
 
-         if (h->plt.offset == (bfd_vma) -1)
+         if (h->plt.offset == (bfd_vma) -1 || splt == NULL)
            {
              /* We didn't make a PLT entry for this symbol.  This
                 happens when statically linking PIC code, or when
@@ -2428,12 +2418,6 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
              goto do_default;
            }
 
-         if (splt == NULL)
-           {
-             splt = bfd_get_section_by_name (dynobj, ".plt");
-             BFD_ASSERT (splt != NULL);
-           }
-
          relocation = (splt->output_section->vma
                        + splt->output_offset
                        + sparc64_elf_plt_entry_offset (h->plt.offset));
@@ -2525,7 +2509,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        case R_SPARC_WDISP30:
        do_wplt30:
          if (sec_do_relax (input_section)
-             && rel->r_offset + 4 < input_section->_raw_size)
+             && rel->r_offset + 4 < input_section->size)
            {
 #define G0             0
 #define O7             15
@@ -2626,11 +2610,10 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
         not process them.  */
       if (unresolved_reloc
          && !((input_section->flags & SEC_DEBUGGING) != 0
-              && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
+              && h->def_dynamic))
        (*_bfd_error_handler)
-         (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"),
-          bfd_archive_filename (input_bfd),
-          bfd_get_section_name (input_bfd, input_section),
+         (_("%B(%A+0x%lx): unresolvable relocation against symbol `%s'"),
+          input_bfd, input_section,
           (long) rel->r_offset,
           h->root.root.string);
 
@@ -2669,7 +2652,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                    break;
                  }
 
-               name = h->root.root.string;
+               name = NULL;
              }
            else
              {
@@ -2683,8 +2666,9 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                  name = bfd_section_name (input_bfd, sec);
              }
            if (! ((*info->callbacks->reloc_overflow)
-                  (info, name, howto->name, (bfd_vma) 0,
-                   input_bfd, input_section, rel->r_offset)))
+                  (info, (h ? &h->root : NULL), name, howto->name,
+                   (bfd_vma) 0, input_bfd, input_section,
+                   rel->r_offset)))
              return FALSE;
          }
        break;
@@ -2732,7 +2716,7 @@ sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
        }
       else
        {
-         bfd_vma max = splt->_raw_size / PLT_ENTRY_SIZE;
+         bfd_vma max = splt->size / PLT_ENTRY_SIZE;
          rela.r_offset = sparc64_elf_plt_ptr_offset (h->plt.offset, max);
          rela.r_addend = -(sparc64_elf_plt_entry_offset (h->plt.offset) + 4)
                          -(splt->output_section->vma + splt->output_offset);
@@ -2749,7 +2733,7 @@ sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
       loc += (h->plt.offset - 4) * sizeof (Elf64_External_Rela);
       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
 
-      if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+      if (!h->def_regular)
        {
          /* Mark the symbol as undefined, rather than as defined in
             the .plt section.  Leave the value alone.  */
@@ -2758,8 +2742,7 @@ sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
             Otherwise, the PLT entry would provide a definition for
             the symbol even if the symbol wasn't defined anywhere,
             and so the symbol would never be NULL.  */
-         if ((h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR_NONWEAK)
-             == 0)
+         if (!h->ref_regular_nonweak)
            sym->st_value = 0;
        }
     }
@@ -2788,7 +2771,7 @@ sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
         initialized in the relocate_section function.  */
       if (info->shared
          && (info->symbolic || h->dynindx == -1)
-         && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+         && h->def_regular)
        {
          asection *sec = h->root.u.def.section;
          rela.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
@@ -2809,7 +2792,7 @@ sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
     }
 
-  if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
+  if (h->needs_copy)
     {
       asection *s;
       Elf_Internal_Rela rela;
@@ -2865,7 +2848,7 @@ sparc64_elf_finish_dynamic_sections (output_bfd, info)
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf64_External_Dyn *) sdyn->contents;
-      dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+      dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size);
       for (; dyncon < dynconend; dyncon++)
        {
          Elf_Internal_Dyn dyn;
@@ -2905,21 +2888,16 @@ sparc64_elf_finish_dynamic_sections (output_bfd, info)
                  if (! size)
                    dyn.d_un.d_ptr = s->vma;
                  else
-                   {
-                     if (s->_cooked_size != 0)
-                       dyn.d_un.d_val = s->_cooked_size;
-                     else
-                       dyn.d_un.d_val = s->_raw_size;
-                   }
+                   dyn.d_un.d_val = s->size;
                }
              bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
            }
        }
 
       /* Initialize the contents of the .plt section.  */
-      if (splt->_raw_size > 0)
+      if (splt->size > 0)
        sparc64_elf_build_plt (output_bfd, splt->contents,
-                              (int) (splt->_raw_size / PLT_ENTRY_SIZE));
+                              (int) (splt->size / PLT_ENTRY_SIZE));
 
       elf_section_data (splt->output_section)->this_hdr.sh_entsize =
        PLT_ENTRY_SIZE;
@@ -2929,7 +2907,7 @@ sparc64_elf_finish_dynamic_sections (output_bfd, info)
      the dynamic section.  */
   sgot = bfd_get_section_by_name (dynobj, ".got");
   BFD_ASSERT (sgot != NULL);
-  if (sgot->_raw_size > 0)
+  if (sgot->size > 0)
     {
       if (sdyn == NULL)
        bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents);
@@ -3017,8 +2995,8 @@ sparc64_elf_merge_private_bfd_data (ibfd, obfd)
            {
              error = TRUE;
              (*_bfd_error_handler)
-               (_("%s: linking UltraSPARC specific with HAL specific code"),
-                bfd_archive_filename (ibfd));
+               (_("%B: linking UltraSPARC specific with HAL specific code"),
+                ibfd);
            }
          /* Choose the most restrictive memory ordering.  */
          old_mm = (old_flags & EF_SPARCV9_MM);
@@ -3036,8 +3014,8 @@ sparc64_elf_merge_private_bfd_data (ibfd, obfd)
         {
           error = TRUE;
           (*_bfd_error_handler)
-            (_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
-             bfd_archive_filename (ibfd), (long) new_flags, (long) old_flags);
+            (_("%B: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
+             ibfd, (long) new_flags, (long) old_flags);
         }
 
       elf_elfheader (obfd)->e_flags = old_flags;
@@ -3115,6 +3093,24 @@ sparc64_elf_object_p (abfd)
   return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, mach);
 }
 
+/* Return address for Ith PLT stub in section PLT, for relocation REL
+   or (bfd_vma) -1 if it should not be included.  */
+
+static bfd_vma
+sparc64_elf_plt_sym_val (bfd_vma i, const asection *plt,
+                        const arelent *rel ATTRIBUTE_UNUSED)
+{
+  bfd_vma j;
+
+  i += PLT_HEADER_SIZE / PLT_ENTRY_SIZE;
+  if (i < LARGE_PLT_THRESHOLD)
+    return plt->vma + i * PLT_ENTRY_SIZE;
+
+  j = (i - LARGE_PLT_THRESHOLD) % 160;
+  i -= j;
+  return plt->vma + i * PLT_ENTRY_SIZE + j * 4 * 6;
+}
+
 /* Relocations in the 64 bit SPARC ELF ABI are more complex than in
    standard ELF, because R_SPARC_OLO10 has secondary addend in
    ELF64_R_TYPE_DATA field.  This structure is used to redirect the
@@ -3214,6 +3210,8 @@ const struct elf_size_info sparc64_elf_size_info =
   sparc64_elf_merge_private_bfd_data
 #define elf_backend_fake_sections \
   sparc64_elf_fake_sections
+#define elf_backend_plt_sym_val        \
+  sparc64_elf_plt_sym_val
 
 #define elf_backend_size_info \
   sparc64_elf_size_info
This page took 0.035921 seconds and 4 git commands to generate.