X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bfd%2Felf32-vax.c;h=9caa47d19a573061b3358d1b965cd17cad01a837;hb=4daadc0d02d6b55962e561882f4768c0c9699010;hp=2572b689819673c2b3299a808fd97a08572a8709;hpb=74541ad4c01323646d5bebe7ff10828f84af0f49;p=external%2Fbinutils.git diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index 2572b68..9caa47d 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -1,13 +1,13 @@ /* VAX series support for 32-bit ELF Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2006 Free Software Foundation, Inc. + 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. Contributed by Matt Thomas . This file is part of BFD, the Binary File Descriptor library. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -17,10 +17,11 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ -#include "bfd.h" #include "sysdep.h" +#include "bfd.h" #include "bfdlink.h" #include "libbfd.h" #include "elf-bfd.h" @@ -322,7 +323,22 @@ reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_type code) return 0; } +static reloc_howto_type * +reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, + const char *r_name) +{ + unsigned int i; + + for (i = 0; i < sizeof (howto_table) / sizeof (howto_table[0]); i++) + if (howto_table[i].name != NULL + && strcasecmp (howto_table[i].name, r_name) == 0) + return &howto_table[i]; + + return NULL; +} + #define bfd_elf32_bfd_reloc_type_lookup reloc_type_lookup +#define bfd_elf32_bfd_reloc_name_lookup reloc_name_lookup #define ELF_ARCH bfd_arch_vax /* end code generated by elf.el */ @@ -583,8 +599,10 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, switch (ELF32_R_TYPE (rel->r_info)) { case R_VAX_GOT32: - if (h != NULL - && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) + BFD_ASSERT (h != NULL); + if (h->forced_local + || h == elf_hash_table (info)->hgot + || h == elf_hash_table (info)->hplt) break; /* This symbol requires a global offset table entry. */ @@ -638,10 +656,11 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, h->got.refcount++; if (eh->got_addend != (bfd_vma) rel->r_addend) (*_bfd_error_handler) - (_("%s: warning: GOT addend of %ld to `%s' does not match previous GOT addend of %ld"), - bfd_get_filename (abfd), rel->r_addend, - h->root.root.string, - eh->got_addend); + (_("%s: warning: GOT addend of %ld to `%s' does" + " not match previous GOT addend of %ld"), + bfd_get_filename (abfd), rel->r_addend, + h->root.root.string, + eh->got_addend); } } @@ -657,8 +676,9 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, /* If this is a local symbol, we resolve it directly without creating a procedure linkage table entry. */ - if (h == NULL) - continue; + BFD_ASSERT (h != NULL); + if (h->forced_local) + break; h->needs_plt = 1; if (h->plt.refcount == -1) @@ -686,7 +706,7 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, && (!info->symbolic || !h->def_regular))) { - if (h != NULL) + if (h != NULL && !h->forced_local) { /* Make sure a plt entry is created for this symbol if it turns out to be a function defined by a dynamic @@ -698,6 +718,9 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, } break; } + if (h != NULL && h->forced_local) + break; + /* Fall through. */ case R_VAX_8: case R_VAX_16: @@ -722,34 +745,12 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, section in dynobj and make room for this reloc. */ if (sreloc == NULL) { - const char *name; + sreloc = _bfd_elf_make_dynamic_reloc_section + (sec, dynobj, 2, abfd, /*rela?*/ TRUE); - name = (bfd_elf_string_from_elf_section - (abfd, - elf_elfheader (abfd)->e_shstrndx, - elf_section_data (sec)->rel_hdr.sh_name)); - if (name == NULL) + if (sreloc == NULL) return FALSE; - BFD_ASSERT (CONST_STRNEQ (name, ".rela") - && strcmp (bfd_get_section_name (abfd, sec), - name + 5) == 0); - - sreloc = bfd_get_section_by_name (dynobj, name); - if (sreloc == NULL) - { - sreloc = bfd_make_section_with_flags (dynobj, - name, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)); - if (sreloc == NULL - || !bfd_set_section_alignment (dynobj, sreloc, 2)) - return FALSE; - } if (sec->flags & SEC_READONLY) info->flags |= DF_TEXTREL; } @@ -805,7 +806,9 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, /* This relocation describes which C++ vtable entries are actually used. Record for later use during GC. */ case R_VAX_GNU_VTENTRY: - if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) + BFD_ASSERT (h != NULL); + if (h != NULL + && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) return FALSE; break; @@ -849,6 +852,9 @@ elf_vax_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info, asection *sec, const Elf_Internal_Rela *rel, *relend; bfd *dynobj; + if (info->relocatable) + return TRUE; + dynobj = elf_hash_table (info)->dynobj; if (dynobj == NULL) return TRUE; @@ -910,7 +916,6 @@ elf_vax_adjust_dynamic_symbol (info, h) { bfd *dynobj; asection *s; - unsigned int power_of_two; dynobj = elf_hash_table (info)->dynobj; @@ -1064,28 +1069,7 @@ elf_vax_adjust_dynamic_symbol (info, h) h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 3) - power_of_two = 3; - - /* Apply the required alignment. */ - 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)) - return FALSE; - } - - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Set the sizes of the dynamic sections. */ @@ -1328,7 +1312,8 @@ elf_vax_instantiate_got_entries (struct elf_link_hash_entry *h, PTR infoptr) srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); if (!elf_hash_table (info)->dynamic_sections_created - || (info->shared && info->symbolic)) + || (info->shared && info->symbolic) + || h->forced_local) { h->got.refcount = 0; h->got.offset = (bfd_vma) -1; @@ -1377,9 +1362,6 @@ elf_vax_relocate_section (bfd *output_bfd, Elf_Internal_Rela *rel; Elf_Internal_Rela *relend; - if (info->relocatable) - return TRUE; - dynobj = elf_hash_table (info)->dynobj; symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); @@ -1411,7 +1393,6 @@ elf_vax_relocate_section (bfd *output_bfd, } howto = howto_table + r_type; - /* This is a final link. */ r_symndx = ELF32_R_SYM (rel->r_info); h = NULL; sym = NULL; @@ -1436,10 +1417,11 @@ elf_vax_relocate_section (bfd *output_bfd, || h->root.type == bfd_link_hash_defweak) && ((r_type == R_VAX_PLT32 && h->plt.offset != (bfd_vma) -1 + && !h->forced_local && elf_hash_table (info)->dynamic_sections_created) || (r_type == R_VAX_GOT32 - && strcmp (h->root.root.string, - "_GLOBAL_OFFSET_TABLE_") != 0 + && h->got.offset != (bfd_vma) -1 + && !h->forced_local && elf_hash_table (info)->dynamic_sections_created && (! info->shared || (! info->symbolic && h->dynindx != -1) @@ -1457,22 +1439,33 @@ elf_vax_relocate_section (bfd *output_bfd, && h->def_dynamic)) && (r_type == R_VAX_8 || r_type == R_VAX_16 - || r_type == R_VAX_32 - || r_type == R_VAX_PC8 - || r_type == R_VAX_PC16 - || r_type == R_VAX_PC32)))) + || r_type == R_VAX_32)))) /* In these cases, we don't need the relocation value. We check specially because in some obscure cases sec->output_section will be NULL. */ relocation = 0; } + if (sec != NULL && elf_discarded_section (sec)) + { + /* For relocs against symbols from removed linkonce sections, + or sections discarded by a linker script, we just want the + section contents zeroed. Avoid any special processing. */ + _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset); + rel->r_info = 0; + rel->r_addend = 0; + continue; + } + + if (info->relocatable) + continue; + switch (r_type) { case R_VAX_GOT32: /* Relocation is to the address of the entry for this symbol in the global offset table. */ - if (h == NULL || h->got.offset == (bfd_vma) -1) + if (h == NULL || h->got.offset == (bfd_vma) -1 || h->forced_local) break; /* Relocation is the offset of the entry for this symbol in @@ -1534,7 +1527,7 @@ elf_vax_relocate_section (bfd *output_bfd, /* Resolve a PLTxx reloc against a local symbol directly, without using the procedure linkage table. */ - if (h == NULL) + if (h == NULL || h->forced_local) break; if (h->plt.offset == (bfd_vma) -1 @@ -1588,7 +1581,7 @@ elf_vax_relocate_section (bfd *output_bfd, case R_VAX_PC8: case R_VAX_PC16: case R_VAX_PC32: - if (h == NULL) + if (h == NULL || h->forced_local) break; /* Fall through. */ case R_VAX_8: @@ -1600,8 +1593,9 @@ elf_vax_relocate_section (bfd *output_bfd, && ((r_type != R_VAX_PC8 && r_type != R_VAX_PC16 && r_type != R_VAX_PC32) - || (!info->symbolic - || !h->def_regular))) + || ((input_section->flags & SEC_CODE) + && (!info->symbolic + || (!h->def_regular && h->type != STT_SECTION))))) { Elf_Internal_Rela outrel; bfd_byte *loc; @@ -1612,22 +1606,10 @@ elf_vax_relocate_section (bfd *output_bfd, time. */ if (sreloc == NULL) { - const char *name; - - name = (bfd_elf_string_from_elf_section - (input_bfd, - elf_elfheader (input_bfd)->e_shstrndx, - elf_section_data (input_section)->rel_hdr.sh_name)); - if (name == NULL) + sreloc = _bfd_elf_get_dynamic_reloc_section + (input_bfd, input_section, /*rela?*/ TRUE); + if (sreloc == NULL) return FALSE; - - BFD_ASSERT (CONST_STRNEQ (name, ".rela") - && strcmp (bfd_get_section_name (input_bfd, - input_section), - name + 5) == 0); - - sreloc = bfd_get_section_by_name (dynobj, name); - BFD_ASSERT (sreloc != NULL); } skip = FALSE;