diff options
Diffstat (limited to 'bfd/elf32-ppc.c')
-rw-r--r-- | bfd/elf32-ppc.c | 164 |
1 files changed, 80 insertions, 84 deletions
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index c4b46f6..f971033 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -1679,11 +1679,7 @@ ppc_elf_relax_section (bfd *abfd, if ((isec->flags & SEC_RELOC) == 0 || isec->reloc_count == 0) return TRUE; - /* If needed, initialize this section's cooked size. */ - if (isec->_cooked_size == 0) - isec->_cooked_size = isec->_raw_size; - - trampoff = (isec->_cooked_size + 3) & (bfd_vma) -4; + trampoff = (isec->size + 3) & (bfd_vma) -4; /* Space for a branch around any trampolines. */ trampoff += 4; @@ -1698,21 +1694,6 @@ ppc_elf_relax_section (bfd *abfd, ppc_info = ppc_elf_hash_table (link_info); irelend = internal_relocs + isec->reloc_count; - /* Get the section contents. */ - /* Get cached copy if it exists. */ - if (elf_section_data (isec)->this_hdr.contents != NULL) - contents = elf_section_data (isec)->this_hdr.contents; - else - { - /* Go get them off disk. */ - contents = bfd_malloc (isec->_raw_size); - if (contents == NULL) - goto error_return; - - if (!bfd_get_section_contents (abfd, isec, contents, 0, isec->_raw_size)) - goto error_return; - } - for (irel = internal_relocs; irel < irelend; irel++) { unsigned long r_type = ELF32_R_TYPE (irel->r_info); @@ -1911,6 +1892,20 @@ ppc_elf_relax_section (bfd *abfd, irel->r_info = ELF32_R_INFO (0, R_PPC_NONE); } + /* Get the section contents. */ + if (contents == NULL) + { + /* Get cached copy if it exists. */ + if (elf_section_data (isec)->this_hdr.contents != NULL) + contents = elf_section_data (isec)->this_hdr.contents; + else + { + /* Go get them off disk. */ + if (!bfd_malloc_and_get_section (abfd, isec, &contents)) + goto error_return; + } + } + /* Fix up the existing branch to hit the trampoline. */ hit_addr = contents + roff; switch (r_type) @@ -1956,11 +1951,11 @@ ppc_elf_relax_section (bfd *abfd, if (contents == NULL) goto error_return; - isec->_cooked_size = (isec->_cooked_size + 3) & (bfd_vma) -4; + isec->size = (isec->size + 3) & (bfd_vma) -4; /* Branch around the trampolines. */ - val = trampoff - isec->_cooked_size + 0x48000000; - dest = contents + isec->_cooked_size; - isec->_cooked_size = trampoff; + val = trampoff - isec->size + 0x48000000; + dest = contents + isec->size; + isec->size = trampoff; bfd_put_32 (abfd, val, dest); dest += 4; @@ -2162,6 +2157,7 @@ ppc_elf_addr16_ha_reloc (bfd *abfd ATTRIBUTE_UNUSED, char **error_message ATTRIBUTE_UNUSED) { bfd_vma relocation; + bfd_size_type sz; if (output_bfd != NULL) { @@ -2169,7 +2165,8 @@ ppc_elf_addr16_ha_reloc (bfd *abfd ATTRIBUTE_UNUSED, return bfd_reloc_ok; } - 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; if (bfd_is_com_section (symbol->section)) @@ -2431,7 +2428,7 @@ elf_create_pointer_linker_section (bfd *abfd, } if (lsect->rel_section) - lsect->rel_section->_raw_size += sizeof (Elf32_External_Rela); + lsect->rel_section->size += sizeof (Elf32_External_Rela); } else { @@ -2467,7 +2464,7 @@ elf_create_pointer_linker_section (bfd *abfd, output a R_<xxx>_RELATIVE reloc so that the dynamic linker can adjust this GOT entry. */ BFD_ASSERT (lsect->rel_section != NULL); - lsect->rel_section->_raw_size += sizeof (Elf32_External_Rela); + lsect->rel_section->size += sizeof (Elf32_External_Rela); } } @@ -2486,14 +2483,14 @@ elf_create_pointer_linker_section (bfd *abfd, linker_section_ptr->written_address_p = FALSE; *ptr_linker_section_ptr = linker_section_ptr; - linker_section_ptr->offset = lsect->section->_raw_size; - lsect->section->_raw_size += 4; + linker_section_ptr->offset = lsect->section->size; + lsect->section->size += 4; #ifdef DEBUG fprintf (stderr, "Create pointer in linker section %s, offset = %ld, section size = %ld\n", lsect->name, (long) linker_section_ptr->offset, - (long) lsect->section->_raw_size); + (long) lsect->section->size); #endif return TRUE; @@ -2692,11 +2689,11 @@ ppc_elf_create_linker_section (bfd *abfd, && !bfd_set_section_alignment (htab->elf.dynobj, s, 2)) return NULL; - s->_raw_size = align_power (s->_raw_size, 2); + s->size = align_power (s->size, 2); #ifdef DEBUG fprintf (stderr, "Creating section %s, current size = %ld\n", - name, (long) s->_raw_size); + name, (long) s->size); #endif if (sym_name) @@ -2756,11 +2753,11 @@ ppc_elf_additional_program_headers (bfd *abfd) ++ret; s = bfd_get_section_by_name (abfd, ".sbss2"); - if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->_raw_size > 0) + if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->size > 0) ++ret; s = bfd_get_section_by_name (abfd, ".PPC.EMB.sbss0"); - if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->_raw_size > 0) + if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->size > 0) ++ret; return ret; @@ -3000,7 +2997,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, else srel = htab->relbss; BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -3011,8 +3008,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, 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 (htab->elf.dynobj, s)) { if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) @@ -3021,10 +3017,10 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* 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; } @@ -3078,15 +3074,15 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) - s->_raw_size += PLT_INITIAL_ENTRY_SIZE; + if (s->size == 0) + s->size += PLT_INITIAL_ENTRY_SIZE; /* The PowerPC PLT is actually composed of two parts, the first part is 2 words (for a load and a jump), and then there is a remaining word available at the end. */ h->plt.offset = (PLT_INITIAL_ENTRY_SIZE + (PLT_SLOT_SIZE - * ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE) + * ((s->size - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE))); /* If this symbol is not defined in a regular file, and we @@ -3103,13 +3099,13 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* Make room for this entry. After the 8192nd entry, room for two entries is allocated. */ - s->_raw_size += PLT_ENTRY_SIZE; - if ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE + s->size += PLT_ENTRY_SIZE; + if ((s->size - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE > PLT_NUM_SINGLE_ENTRIES) - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .rela.plt section. */ - htab->relplt->_raw_size += sizeof (Elf32_External_Rela); + htab->relplt->size += sizeof (Elf32_External_Rela); } else { @@ -3141,20 +3137,20 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) else { bfd_boolean dyn; - eh->elf.got.offset = htab->got->_raw_size; + eh->elf.got.offset = htab->got->size; if ((eh->tls_mask & TLS_TLS) != 0) { if ((eh->tls_mask & TLS_LD) != 0) - htab->got->_raw_size += 8; + htab->got->size += 8; if ((eh->tls_mask & TLS_GD) != 0) - htab->got->_raw_size += 8; + htab->got->size += 8; if ((eh->tls_mask & (TLS_TPREL | TLS_TPRELGD)) != 0) - htab->got->_raw_size += 4; + htab->got->size += 4; if ((eh->tls_mask & TLS_DTPREL) != 0) - htab->got->_raw_size += 4; + htab->got->size += 4; } else - htab->got->_raw_size += 4; + htab->got->size += 4; dyn = htab->elf.dynamic_sections_created; if ((info->shared || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, &eh->elf)) @@ -3162,12 +3158,12 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) || eh->elf.root.type != bfd_link_hash_undefweak)) { /* All the entries we allocated need relocs. */ - htab->relgot->_raw_size - += ((htab->got->_raw_size - eh->elf.got.offset) / 4 + htab->relgot->size + += ((htab->got->size - eh->elf.got.offset) / 4 * sizeof (Elf32_External_Rela)); /* Except LD only needs one. */ if ((eh->tls_mask & TLS_LD) != 0) - htab->relgot->_raw_size -= sizeof (Elf32_External_Rela); + htab->relgot->size -= sizeof (Elf32_External_Rela); } } } @@ -3258,7 +3254,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *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; @@ -3319,17 +3315,17 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, { s = bfd_get_section_by_name (htab->elf.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; } } if (htab->tlsld_got.refcount > 0) { - htab->tlsld_got.offset = htab->got->_raw_size; - htab->got->_raw_size += 8; + htab->tlsld_got.offset = htab->got->size; + htab->got->size += 8; if (info->shared) - htab->relgot->_raw_size += sizeof (Elf32_External_Rela); + htab->relgot->size += sizeof (Elf32_External_Rela); } else htab->tlsld_got.offset = (bfd_vma) -1; @@ -3367,7 +3363,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, } else if (p->count != 0) { - elf_section_data (p->sec)->sreloc->_raw_size + elf_section_data (p->sec)->sreloc->size += p->count * sizeof (Elf32_External_Rela); if ((p->sec->output_section->flags & (SEC_READONLY | SEC_ALLOC)) @@ -3396,30 +3392,30 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, htab->tlsld_got.offset. */ if (htab->tlsld_got.offset == (bfd_vma) -1) { - htab->tlsld_got.offset = s->_raw_size; - s->_raw_size += 8; + htab->tlsld_got.offset = s->size; + s->size += 8; if (info->shared) - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); } *local_got = (bfd_vma) -1; } else { - *local_got = s->_raw_size; + *local_got = s->size; if ((*lgot_masks & TLS_TLS) != 0) { if ((*lgot_masks & TLS_GD) != 0) - s->_raw_size += 8; + s->size += 8; if ((*lgot_masks & (TLS_TPREL | TLS_TPRELGD)) != 0) - s->_raw_size += 4; + s->size += 4; if ((*lgot_masks & TLS_DTPREL) != 0) - s->_raw_size += 4; + s->size += 4; } else - s->_raw_size += 4; + s->size += 4; if (info->shared) - srel->_raw_size += ((s->_raw_size - *local_got) / 4 - * sizeof (Elf32_External_Rela)); + srel->size += ((s->size - *local_got) / 4 + * sizeof (Elf32_External_Rela)); } } else @@ -3447,7 +3443,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, } else if (strncmp (bfd_get_section_name (dynobj, s), ".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 mostly to handle .rela.bss and @@ -3475,14 +3471,14 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, continue; } - if (s->_raw_size == 0) + if (s->size == 0) { _bfd_strip_section_from_output (info, s); continue; } /* Allocate memory for the section contents. */ - s->contents = bfd_zalloc (htab->elf.dynobj, s->_raw_size); + s->contents = bfd_zalloc (htab->elf.dynobj, s->size); if (s->contents == NULL) return FALSE; } @@ -3503,7 +3499,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, return FALSE; } - if (htab->plt != NULL && htab->plt->_raw_size != 0) + if (htab->plt != NULL && htab->plt->size != 0) { if (!add_dynamic_entry (DT_PLTGOT, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0) @@ -4567,7 +4563,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd, BFD_ASSERT (htab->plt != 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; @@ -4583,7 +4579,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd, break; case DT_PLTRELSZ: - dyn.d_un.d_val = htab->relplt->_raw_size; + dyn.d_un.d_val = htab->relplt->size; break; case DT_JMPREL: @@ -5825,7 +5821,7 @@ static bfd_boolean ppc_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) { int offset; - unsigned int raw_size; + unsigned int size; switch (note->descsz) { @@ -5841,14 +5837,14 @@ ppc_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) /* pr_reg */ offset = 72; - raw_size = 192; + size = 192; break; } /* Make a ".reg/999" section. */ return _bfd_elfcore_make_pseudosection (abfd, ".reg", - raw_size, note->descpos + offset); + size, note->descpos + offset); } static bfd_boolean @@ -5994,7 +5990,7 @@ ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info) if (asec) { ++ num_input_sections; - output_section_size += asec->_raw_size; + output_section_size += asec->size; } } @@ -6026,7 +6022,7 @@ ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info) if (asec == NULL) continue; - length = asec->_raw_size; + length = asec->size; if (length < 24) { error_message = _("corrupt or empty %s section in %s"); @@ -6127,7 +6123,7 @@ ppc_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) if (apuinfo_list_length () == 0) return; - length = asec->_raw_size; + length = asec->size; if (length < 20) return; @@ -6153,7 +6149,7 @@ ppc_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) length += 4; } - if (length != asec->_raw_size) + if (length != asec->size) (*_bfd_error_handler) (_("failed to compute new APUinfo section.")); if (! bfd_set_section_contents (abfd, asec, buffer, (file_ptr) 0, length)) |