X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf32-msp430.c;h=c08f596d1ac211ebb89f3b82df672e3c6d6fdf9d;hb=77bf820f915a0c12108e266b185430fb73561c94;hp=879edf042db74a98ff884de6fd43043cf3536cdd;hpb=cd123cb70c845b890eed231a84e6e84c92c2ef92;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c index 879edf042d..c08f596d1a 100644 --- a/bfd/elf32-msp430.c +++ b/bfd/elf32-msp430.c @@ -1,5 +1,5 @@ /* MSP430-specific support for 32-bit ELF - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 + Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012 Free Software Foundation, Inc. Contributed by Dmitry Diky @@ -241,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; @@ -250,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++) @@ -343,8 +339,8 @@ msp430_final_link_relocate (reloc_howto_type * howto, bfd * input_bfd, bfd_put_16 (input_bfd, x, contents - 2); break; - case R_MSP430_16_PCREL: case R_MSP430_RL_PCREL: + case R_MSP430_16_PCREL: contents += rel->r_offset; srel = (bfd_signed_vma) relocation; srel += rel->r_addend; @@ -433,7 +429,7 @@ elf32_msp430_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, 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; @@ -458,16 +454,9 @@ elf32_msp430_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, unresolved_reloc, warned); } - 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 (sec != NULL && discarded_section (sec)) + RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, + rel, 1, relend, howto, 0, contents); if (info->relocatable) continue; @@ -678,7 +667,7 @@ elf32_msp430_object_p (bfd * abfd) Relaxation required only in two cases: - Bad hand coding like jumps from one section to another or from file to file. - - Sibling calls. This will affect onlu 'jump label' polymorph. Without + - Sibling calls. This will affect only 'jump label' polymorph. Without relaxing this enlarges code by 2 bytes. Sibcalls implemented but do not work in gcc's port by the reason I do not know. Anyway, if a relaxation required, user should pass -relax option to the @@ -805,7 +794,7 @@ msp430_elf_symbol_address_p (bfd * abfd, } /* Adjust all local symbols defined as '.section + 0xXXXX' (.section has sec_shndx) - referenced from current and other sections */ + referenced from current and other sections. */ static bfd_boolean msp430_elf_relax_adjust_locals(bfd * abfd, asection * sec, bfd_vma addr, int count, unsigned int sec_shndx, bfd_vma toaddr) @@ -819,18 +808,18 @@ msp430_elf_relax_adjust_locals(bfd * abfd, asection * sec, bfd_vma addr, irelend = irel + sec->reloc_count; symtab_hdr = & elf_tdata (abfd)->symtab_hdr; isym = (Elf_Internal_Sym *) symtab_hdr->contents; - + for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++) { int sidx = ELF32_R_SYM(irel->r_info); Elf_Internal_Sym *lsym = isym + sidx; - + /* Adjust symbols referenced by .sec+0xXX */ - if (irel->r_addend > addr && irel->r_addend < toaddr + if (irel->r_addend > addr && irel->r_addend < toaddr && lsym->st_shndx == sec_shndx) irel->r_addend -= count; } - + return TRUE; } @@ -845,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; @@ -858,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; @@ -884,7 +868,7 @@ msp430_elf_relax_delete_bytes (bfd * abfd, asection * sec, bfd_vma addr, for (p = abfd->sections; p != NULL; p = p->next) msp430_elf_relax_adjust_locals(abfd,p,addr,count,sec_shndx,toaddr); - + /* Adjust the local symbols defined in this section. */ symtab_hdr = & elf_tdata (abfd)->symtab_hdr; isym = (Elf_Internal_Sym *) symtab_hdr->contents; @@ -913,7 +897,6 @@ msp430_elf_relax_delete_bytes (bfd * abfd, asection * sec, bfd_vma addr, return TRUE; } - static bfd_boolean msp430_elf_relax_section (bfd * abfd, asection * sec, struct bfd_link_info * link_info, @@ -1029,7 +1012,7 @@ msp430_elf_relax_section (bfd * abfd, asection * sec, /* Try to turn a 16bit pc-relative branch into a 10bit pc-relative branch. */ - /* Paranoia? paranoia... */ + /* Paranoia? paranoia... */ if (ELF32_R_TYPE (irel->r_info) == (int) R_MSP430_RL_PCREL) { bfd_vma value = symval;