X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Felf32-m68k.c;h=842f38cd725620f321ca1bbde9aa2305fe4e988a;hb=80df85b5d4fa8c68fdbfad0babaf5a4a5226335d;hp=849bfe8fb18ad2dcceb214f4d69151bc0445874b;hpb=8517fae7a54a3d541aecc6be63e22d6ef5d51a66;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 849bfe8fb1..842f38cd72 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -1,6 +1,6 @@ /* Motorola 68k series support for 32-bit ELF - Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. + Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, + 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -508,14 +508,14 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) if (h->dynindx == -1 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) { - if (!bfd_elf32_link_record_dynamic_symbol (info, h)) + if (!bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; } /* Allocate space in the .got section. */ - sgot->_raw_size += 4; + sgot->size += 4; /* Allocate relocation space. */ - srelgot->_raw_size += sizeof (Elf32_External_Rela); + srelgot->size += sizeof (Elf32_External_Rela); } h->got.refcount++; } @@ -536,13 +536,13 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) } if (local_got_refcounts[r_symndx] == 0) { - sgot->_raw_size += 4; + sgot->size += 4; if (info->shared) { /* If we are generating a shared object, we need to output a R_68K_RELATIVE reloc so that the dynamic linker can adjust this GOT entry. */ - srelgot->_raw_size += sizeof (Elf32_External_Rela); + srelgot->size += sizeof (Elf32_External_Rela); } } local_got_refcounts[r_symndx]++; @@ -586,7 +586,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) if (h->dynindx == -1 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) { - if (!bfd_elf32_link_record_dynamic_symbol (info, h)) + if (!bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; } @@ -684,7 +684,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) || ELF32_R_TYPE (rel->r_info) == R_68K_PC32)) info->flags |= DF_TEXTREL; - sreloc->_raw_size += sizeof (Elf32_External_Rela); + sreloc->size += sizeof (Elf32_External_Rela); /* We count the number of PC relative relocations we have entered for this symbol, so that we can discard them @@ -745,14 +745,14 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) /* This relocation describes the C++ object vtable hierarchy. Reconstruct it for later use during GC. */ case R_68K_GNU_VTINHERIT: - if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) + if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) return FALSE; break; /* This relocation describes which C++ vtable entries are actually used. Record for later use during GC. */ case R_68K_GNU_VTENTRY: - if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend)) + if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) return FALSE; break; @@ -817,26 +817,27 @@ elf_m68k_gc_sweep_hook (abfd, info, sec, relocs) struct elf_link_hash_entry **sym_hashes; bfd_signed_vma *local_got_refcounts; const Elf_Internal_Rela *rel, *relend; - unsigned long r_symndx; - struct elf_link_hash_entry *h; bfd *dynobj; asection *sgot; asection *srelgot; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; - sym_hashes = elf_sym_hashes (abfd); - local_got_refcounts = elf_local_got_refcounts (abfd); - dynobj = elf_hash_table (info)->dynobj; if (dynobj == NULL) return TRUE; + symtab_hdr = &elf_tdata (abfd)->symtab_hdr; + sym_hashes = elf_sym_hashes (abfd); + local_got_refcounts = elf_local_got_refcounts (abfd); + sgot = bfd_get_section_by_name (dynobj, ".got"); srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); relend = relocs + sec->reloc_count; for (rel = relocs; rel < relend; rel++) { + unsigned long r_symndx; + struct elf_link_hash_entry *h; + switch (ELF32_R_TYPE (rel->r_info)) { case R_68K_GOT8: @@ -855,8 +856,8 @@ elf_m68k_gc_sweep_hook (abfd, info, sec, relocs) if (h->got.refcount == 0) { /* We don't need the .got entry any more. */ - sgot->_raw_size -= 4; - srelgot->_raw_size -= sizeof (Elf32_External_Rela); + sgot->size -= 4; + srelgot->size -= sizeof (Elf32_External_Rela); } } } @@ -868,9 +869,9 @@ elf_m68k_gc_sweep_hook (abfd, info, sec, relocs) if (local_got_refcounts[r_symndx] == 0) { /* We don't need the .got entry any more. */ - sgot->_raw_size -= 4; + sgot->size -= 4; if (info->shared) - srelgot->_raw_size -= sizeof (Elf32_External_Rela); + srelgot->size -= sizeof (Elf32_External_Rela); } } } @@ -969,7 +970,7 @@ elf_m68k_adjust_dynamic_symbol (info, h) if (h->dynindx == -1 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) { - if (! bfd_elf32_link_record_dynamic_symbol (info, h)) + if (! bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; } @@ -978,12 +979,12 @@ elf_m68k_adjust_dynamic_symbol (info, h) /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) + if (s->size == 0) { if (CPU32_FLAG (dynobj)) - s->_raw_size += PLT_CPU32_ENTRY_SIZE; + s->size += PLT_CPU32_ENTRY_SIZE; else - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; } /* If this symbol is not defined in a regular file, and we are @@ -995,27 +996,27 @@ elf_m68k_adjust_dynamic_symbol (info, h) && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) { h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; } - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* Make room for this entry. */ if (CPU32_FLAG (dynobj)) - s->_raw_size += PLT_CPU32_ENTRY_SIZE; + s->size += PLT_CPU32_ENTRY_SIZE; else - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ s = bfd_get_section_by_name (dynobj, ".got.plt"); BFD_ASSERT (s != NULL); - s->_raw_size += 4; + s->size += 4; /* 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 (Elf32_External_Rela); + s->size += sizeof (Elf32_External_Rela); return TRUE; } @@ -1069,7 +1070,7 @@ elf_m68k_adjust_dynamic_symbol (info, h) srel = bfd_get_section_by_name (dynobj, ".rela.bss"); 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; } @@ -1080,8 +1081,7 @@ elf_m68k_adjust_dynamic_symbol (info, h) power_of_two = 3; /* 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)) @@ -1090,25 +1090,14 @@ elf_m68k_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; } -/* This is the condition under which elf_m68k_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 elf_m68k_relocate_section. */ -#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H) \ - ((DYN) \ - && ((SHARED) \ - || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \ - && ((H)->dynindx != -1 \ - || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)) - /* Set the sizes of the dynamic sections. */ static bfd_boolean @@ -1127,11 +1116,11 @@ elf_m68k_size_dynamic_sections (output_bfd, info) if (elf_hash_table (info)->dynamic_sections_created) { /* Set the contents of the .interp section to the interpreter. */ - if (!info->shared) + if (info->executable) { 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; } } @@ -1144,7 +1133,7 @@ elf_m68k_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; } /* If this is a -Bsymbolic shared link, then we need to discard all @@ -1179,7 +1168,7 @@ elf_m68k_size_dynamic_sections (output_bfd, info) if (strcmp (name, ".plt") == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* Strip this section if we don't need it; see the comment below. */ @@ -1193,7 +1182,7 @@ elf_m68k_size_dynamic_sections (output_bfd, info) } else 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 mostly to handle .rela.bss and @@ -1233,8 +1222,8 @@ elf_m68k_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; } @@ -1246,7 +1235,7 @@ elf_m68k_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_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (!info->shared) { @@ -1329,7 +1318,7 @@ elf_m68k_discard_copies (h, inf) for (s = elf_m68k_hash_entry (h)->pcrel_relocs_copied; s != NULL; s = s->next) - s->section->_raw_size -= s->count * sizeof (Elf32_External_Rela); + s->section->size -= s->count * sizeof (Elf32_External_Rela); return TRUE; } @@ -1409,7 +1398,10 @@ elf_m68k_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); } switch (r_type) @@ -1977,7 +1969,7 @@ elf_m68k_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; @@ -2006,10 +1998,7 @@ elf_m68k_finish_dynamic_sections (output_bfd, info) case DT_PLTRELSZ: s = bfd_get_section_by_name (output_bfd, ".rela.plt"); BFD_ASSERT (s != NULL); - 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); break; @@ -2023,19 +2012,14 @@ elf_m68k_finish_dynamic_sections (output_bfd, info) about changing the DT_RELA entry. */ s = bfd_get_section_by_name (output_bfd, ".rela.plt"); if (s != NULL) - { - 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); break; } } /* Fill in the first entry in the procedure linkage table. */ - if (splt->_raw_size > 0) + if (splt->size > 0) { if (!CPU32_FLAG (output_bfd)) { @@ -2073,7 +2057,7 @@ elf_m68k_finish_dynamic_sections (output_bfd, info) } /* Fill in the first three entries in the global offset table. */ - if (sgot->_raw_size > 0) + if (sgot->size > 0) { if (sdyn == NULL) bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); @@ -2238,7 +2222,7 @@ elf32_m68k_reloc_type_class (rela) _bfd_elf_create_dynamic_sections #define bfd_elf32_bfd_link_hash_table_create \ elf_m68k_link_hash_table_create -#define bfd_elf32_bfd_final_link _bfd_elf32_gc_common_final_link +#define bfd_elf32_bfd_final_link bfd_elf_gc_common_final_link #define elf_backend_check_relocs elf_m68k_check_relocs #define elf_backend_adjust_dynamic_symbol \