OSDN Git Service

bfd/
[pf3gnuchains/pf3gnuchains3x.git] / bfd / elf32-sparc.c
index 3809567..f895220 100644 (file)
@@ -374,6 +374,7 @@ sparc_elf_wdisp16_reloc (abfd,
 {
   bfd_vma relocation;
   bfd_vma x;
+  bfd_size_type sz;
 
   if (output_bfd != (bfd *) NULL
       && (symbol->flags & BSF_SECTION_SYM) == 0
@@ -387,7 +388,8 @@ sparc_elf_wdisp16_reloc (abfd,
   if (output_bfd != NULL)
     return bfd_reloc_continue;
 
-  if (reloc_entry->address > input_section->_cooked_size)
+  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
+  if (reloc_entry->address > sz)
     return bfd_reloc_outofrange;
 
   relocation = (symbol->value
@@ -430,6 +432,7 @@ sparc_elf_hix22_reloc (abfd,
 {
   bfd_vma relocation;
   bfd_vma insn;
+  bfd_size_type sz;
 
   if (output_bfd != (bfd *) NULL
       && (symbol->flags & BSF_SECTION_SYM) == 0)
@@ -441,7 +444,8 @@ sparc_elf_hix22_reloc (abfd,
   if (output_bfd != NULL)
     return bfd_reloc_continue;
 
-  if (reloc_entry->address > input_section->_cooked_size)
+  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
+  if (reloc_entry->address > sz)
     return bfd_reloc_outofrange;
 
   relocation = (symbol->value
@@ -476,6 +480,7 @@ sparc_elf_lox10_reloc (abfd,
 {
   bfd_vma relocation;
   bfd_vma insn;
+  bfd_size_type sz;
 
   if (output_bfd != (bfd *) NULL
       && (symbol->flags & BSF_SECTION_SYM) == 0)
@@ -487,7 +492,8 @@ sparc_elf_lox10_reloc (abfd,
   if (output_bfd != NULL)
     return bfd_reloc_continue;
 
-  if (reloc_entry->address > input_section->_cooked_size)
+  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
+  if (reloc_entry->address > sz)
     return bfd_reloc_outofrange;
 
   relocation = (symbol->value
@@ -1562,7 +1568,7 @@ elf32_sparc_adjust_dynamic_symbol (info, h)
      .rel.bss section we are going to use.  */
   if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
     {
-      htab->srelbss->_raw_size += sizeof (Elf32_External_Rela);
+      htab->srelbss->size += sizeof (Elf32_External_Rela);
       h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
     }
 
@@ -1574,8 +1580,7 @@ elf32_sparc_adjust_dynamic_symbol (info, h)
 
   /* Apply the required alignment.  */
   s = htab->sdynbss;
-  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))
@@ -1584,10 +1589,10 @@ elf32_sparc_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;
 }
@@ -1634,17 +1639,17 @@ allocate_dynrelocs (h, inf)
          asection *s = htab->splt;
 
          /* The first four entries in .plt are reserved.  */
-         if (s->_raw_size == 0)
-           s->_raw_size = 4 * PLT_ENTRY_SIZE;
+         if (s->size == 0)
+           s->size = 4 * PLT_ENTRY_SIZE;
 
          /* The procedure linkage table has a maximum size.  */
-         if (s->_raw_size >= 0x400000)
+         if (s->size >= 0x400000)
            {
              bfd_set_error (bfd_error_bad_value);
              return FALSE;
            }
 
-         h->plt.offset = s->_raw_size;
+         h->plt.offset = s->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
@@ -1659,10 +1664,10 @@ allocate_dynrelocs (h, inf)
            }
 
          /* 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.  */
-         htab->srelplt->_raw_size += sizeof (Elf32_External_Rela);
+         htab->srelplt->size += sizeof (Elf32_External_Rela);
        }
       else
        {
@@ -1699,22 +1704,22 @@ allocate_dynrelocs (h, inf)
        }
 
       s = htab->sgot;
-      h->got.offset = s->_raw_size;
-      s->_raw_size += 4;
+      h->got.offset = s->size;
+      s->size += 4;
       /* R_SPARC_TLS_GD_HI{22,LO10} needs 2 consecutive GOT slots.  */
       if (tls_type == GOT_TLS_GD)
-       s->_raw_size += 4;
+       s->size += 4;
       dyn = htab->elf.dynamic_sections_created;
       /* R_SPARC_TLS_IE_{HI22,LO10} needs one dynamic relocation,
         R_SPARC_TLS_GD_{HI22,LO10} needs one if local symbol and two if
         global.  */
       if ((tls_type == GOT_TLS_GD && h->dynindx == -1)
          || tls_type == GOT_TLS_IE)
-       htab->srelgot->_raw_size += sizeof (Elf32_External_Rela);
+       htab->srelgot->size += sizeof (Elf32_External_Rela);
       else if (tls_type == GOT_TLS_GD)
-       htab->srelgot->_raw_size += 2 * sizeof (Elf32_External_Rela);
+       htab->srelgot->size += 2 * sizeof (Elf32_External_Rela);
       else if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h))
-       htab->srelgot->_raw_size += sizeof (Elf32_External_Rela);
+       htab->srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
     h->got.offset = (bfd_vma) -1;
@@ -1785,7 +1790,7 @@ allocate_dynrelocs (h, inf)
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
     {
       asection *sreloc = elf_section_data (p->sec)->sreloc;
-      sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela);
+      sreloc->size += p->count * sizeof (Elf32_External_Rela);
     }
 
   return TRUE;
@@ -1845,7 +1850,7 @@ elf32_sparc_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;
        }
     }
@@ -1884,7 +1889,7 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
              else if (p->count != 0)
                {
                  srel = elf_section_data (p->sec)->sreloc;
-                 srel->_raw_size += p->count * sizeof (Elf32_External_Rela);
+                 srel->size += p->count * sizeof (Elf32_External_Rela);
                  if ((p->sec->output_section->flags & SEC_READONLY) != 0)
                    info->flags |= DF_TEXTREL;
                }
@@ -1905,14 +1910,14 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
        {
          if (*local_got > 0)
            {
-             *local_got = s->_raw_size;
-             s->_raw_size += 4;
+             *local_got = s->size;
+             s->size += 4;
              if (*local_tls_type == GOT_TLS_GD)
-               s->_raw_size += 4;
+               s->size += 4;
              if (info->shared
                  || *local_tls_type == GOT_TLS_GD
                  || *local_tls_type == GOT_TLS_IE)
-               srel->_raw_size += sizeof (Elf32_External_Rela);
+               srel->size += sizeof (Elf32_External_Rela);
            }
          else
            *local_got = (bfd_vma) -1;
@@ -1923,9 +1928,9 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
     {
       /* Allocate 2 got entries and 1 dynamic reloc for
         R_SPARC_TLS_LDM_{HI22,LO10} relocs.  */
-      htab->tls_ldm_got.offset = htab->sgot->_raw_size;
-      htab->sgot->_raw_size += 8;
-      htab->srelgot->_raw_size += sizeof (Elf32_External_Rela);
+      htab->tls_ldm_got.offset = htab->sgot->size;
+      htab->sgot->size += 8;
+      htab->srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
     htab->tls_ldm_got.offset = -1;
@@ -1937,13 +1942,13 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Make space for the trailing nop in .plt.  */
-      if (htab->splt->_raw_size > 0)
-       htab->splt->_raw_size += 4;
+      if (htab->splt->size > 0)
+       htab->splt->size += 4;
 
       /* 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 (htab->sgot->_raw_size >= 0x1000
+      if (htab->sgot->size >= 0x1000
          && elf_hash_table (info)->hgot->root.u.def.value == 0)
        elf_hash_table (info)->hgot->root.u.def.value = 0x1000;
     }
@@ -1965,7 +1970,7 @@ elf32_sparc_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
@@ -2003,8 +2008,8 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
         are written out, but at the moment this does not happen.  Thus in
         order to prevent writing out garbage, we initialise the section's
         contents to zero.  */
-      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;
     }
 
@@ -2024,7 +2029,7 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
            return FALSE;
        }
 
-      if (htab->srelplt->_raw_size != 0)
+      if (htab->srelplt->size != 0)
        {
          if (!add_dynamic_entry (DT_PLTGOT, 0)
              || !add_dynamic_entry (DT_PLTRELSZ, 0)
@@ -2921,7 +2926,7 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
        }
       else if ((r_type == R_SPARC_WDISP30 || r_type == R_SPARC_WPLT30)
               && 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
@@ -3223,7 +3228,7 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info)
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
-      dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+      dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
       for (; dyncon < dynconend; dyncon++)
        {
          Elf_Internal_Dyn dyn;
@@ -3252,12 +3257,7 @@ elf32_sparc_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_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
            }
@@ -3265,11 +3265,11 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info)
 
       /* Clear the first four entries in the procedure linkage table,
         and put a nop in the last four bytes.  */
-      if (splt->_raw_size > 0)
+      if (splt->size > 0)
        {
          memset (splt->contents, 0, 4 * PLT_ENTRY_SIZE);
          bfd_put_32 (output_bfd, (bfd_vma) SPARC_NOP,
-                     splt->contents + splt->_raw_size - 4);
+                     splt->contents + splt->size - 4);
        }
 
       elf_section_data (splt->output_section)->this_hdr.sh_entsize = 0;
@@ -3277,7 +3277,7 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info)
 
   /* Set the first entry in the global offset table to the address of
      the dynamic section.  */
-  if (htab->sgot && htab->sgot->_raw_size > 0)
+  if (htab->sgot && htab->sgot->size > 0)
     {
       if (sdyn == NULL)
        bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgot->contents);