X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf32-msp430.c;h=c0459f43945dd33beec4de50b1b43a845e9cef05;hb=fd885f3a4d85dc33d794ca359ea91f31e3082717;hp=af737714de29f9e03826478e83d38e76d8c45e6f;hpb=046aeb74904b71d136bc2c4a60f9ba1bc90064b5;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c index af737714de..c0459f4394 100644 --- a/bfd/elf32-msp430.c +++ b/bfd/elf32-msp430.c @@ -1,12 +1,13 @@ /* MSP430-specific support for 32-bit ELF - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012 + Free Software Foundation, Inc. Contributed by Dmitry Diky 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, @@ -16,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 "libiberty.h" #include "libbfd.h" #include "elf-bfd.h" @@ -199,6 +201,23 @@ bfd_elf32_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, return NULL; } +static reloc_howto_type * +bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, + const char *r_name) +{ + unsigned int i; + + for (i = 0; + i < (sizeof (elf_msp430_howto_table) + / sizeof (elf_msp430_howto_table[0])); + i++) + if (elf_msp430_howto_table[i].name != NULL + && strcasecmp (elf_msp430_howto_table[i].name, r_name) == 0) + return &elf_msp430_howto_table[i]; + + return NULL; +} + /* Set the howto pointer for an MSP430 ELF reloc. */ static void @@ -213,48 +232,6 @@ msp430_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, cache_ptr->howto = &elf_msp430_howto_table[r_type]; } -static asection * -elf32_msp430_gc_mark_hook (asection * sec, - struct bfd_link_info * info ATTRIBUTE_UNUSED, - Elf_Internal_Rela * rel, - struct elf_link_hash_entry * h, - Elf_Internal_Sym * sym) -{ - if (h != NULL) - { - switch (ELF32_R_TYPE (rel->r_info)) - { - default: - switch (h->root.type) - { - case bfd_link_hash_defined: - case bfd_link_hash_defweak: - return h->root.u.def.section; - - case bfd_link_hash_common: - return h->root.u.c.p->section; - - default: - break; - } - } - } - else - return bfd_section_from_elf_index (sec->owner, sym->st_shndx); - - return NULL; -} - -static bfd_boolean -elf32_msp430_gc_sweep_hook (bfd * abfd ATTRIBUTE_UNUSED, - struct bfd_link_info * info ATTRIBUTE_UNUSED, - asection * sec ATTRIBUTE_UNUSED, - const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED) -{ - /* We don't use got and plt entries for msp430. */ - return TRUE; -} - /* Look through the relocs for a section during the first phase. Since we don't do .gots or .plts, we just need to consider the virtual table relocs for gc. */ @@ -264,7 +241,7 @@ elf32_msp430_check_relocs (bfd * abfd, struct bfd_link_info * info, asection * sec, const Elf_Internal_Rela * relocs) { Elf_Internal_Shdr *symtab_hdr; - struct elf_link_hash_entry **sym_hashes, **sym_hashes_end; + struct elf_link_hash_entry **sym_hashes; const Elf_Internal_Rela *rel; const Elf_Internal_Rela *rel_end; @@ -273,10 +250,6 @@ elf32_msp430_check_relocs (bfd * abfd, struct bfd_link_info * info, symtab_hdr = &elf_tdata (abfd)->symtab_hdr; sym_hashes = elf_sym_hashes (abfd); - sym_hashes_end = - sym_hashes + symtab_hdr->sh_size / sizeof (Elf32_External_Sym); - if (!elf_bad_symtab (abfd)) - sym_hashes_end -= symtab_hdr->sh_info; rel_end = relocs + sec->reloc_count; for (rel = relocs; rel < rel_end; rel++) @@ -454,11 +427,9 @@ elf32_msp430_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, const char *name = NULL; int r_type; - /* This is a final link. */ - r_type = ELF32_R_TYPE (rel->r_info); r_symndx = ELF32_R_SYM (rel->r_info); - howto = elf_msp430_howto_table + ELF32_R_TYPE (rel->r_info); + howto = elf_msp430_howto_table + r_type; h = NULL; sym = NULL; sec = NULL; @@ -483,6 +454,13 @@ elf32_msp430_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, unresolved_reloc, warned); } + if (sec != NULL && discarded_section (sec)) + RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, + rel, 1, relend, howto, 0, contents); + + if (info->relocatable) + continue; + r = msp430_final_link_relocate (howto, input_bfd, input_section, contents, rel, relocation); @@ -685,21 +663,6 @@ elf32_msp430_object_p (bfd * abfd) return bfd_default_set_arch_mach (abfd, bfd_arch_msp430, e_set); } -static void -elf32_msp430_post_process_headers (bfd * abfd, - struct bfd_link_info * link_info ATTRIBUTE_UNUSED) -{ - Elf_Internal_Ehdr * i_ehdrp; /* ELF file header, internal form. */ - - i_ehdrp = elf_elfheader (abfd); - -#ifndef ELFOSABI_STANDALONE -#define ELFOSABI_STANDALONE 255 -#endif - - i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_STANDALONE; -} - /* These functions handle relaxing for the msp430. Relaxation required only in two cases: - Bad hand coding like jumps from one section to another or @@ -871,7 +834,6 @@ msp430_elf_relax_delete_bytes (bfd * abfd, asection * sec, bfd_vma addr, bfd_byte *contents; Elf_Internal_Rela *irel; Elf_Internal_Rela *irelend; - Elf_Internal_Rela *irelalign; bfd_vma toaddr; Elf_Internal_Sym *isym; Elf_Internal_Sym *isymend; @@ -884,10 +846,6 @@ msp430_elf_relax_delete_bytes (bfd * abfd, asection * sec, bfd_vma addr, contents = elf_section_data (sec)->this_hdr.contents; - /* The deletion must stop at the next ALIGN reloc for an aligment - power larger than the number of bytes we are deleting. */ - - irelalign = NULL; toaddr = sec->size; irel = elf_section_data (sec)->relocs; @@ -1203,6 +1161,7 @@ error_return: #define ELF_MACHINE_CODE EM_MSP430 #define ELF_MACHINE_ALT1 EM_MSP430_OLD #define ELF_MAXPAGESIZE 1 +#define ELF_OSABI ELFOSABI_STANDALONE #define TARGET_LITTLE_SYM bfd_elf32_msp430_vec #define TARGET_LITTLE_NAME "elf32-msp430" @@ -1210,13 +1169,11 @@ error_return: #define elf_info_to_howto msp430_info_to_howto_rela #define elf_info_to_howto_rel NULL #define elf_backend_relocate_section elf32_msp430_relocate_section -#define elf_backend_gc_mark_hook elf32_msp430_gc_mark_hook -#define elf_backend_gc_sweep_hook elf32_msp430_gc_sweep_hook #define elf_backend_check_relocs elf32_msp430_check_relocs #define elf_backend_can_gc_sections 1 #define elf_backend_final_write_processing bfd_elf_msp430_final_write_processing #define elf_backend_object_p elf32_msp430_object_p -#define elf_backend_post_process_headers elf32_msp430_post_process_headers +#define elf_backend_post_process_headers _bfd_elf_set_osabi #define bfd_elf32_bfd_relax_section msp430_elf_relax_section #include "elf32-target.h"