X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=bfd%2Felf32-m32c.c;h=4de500a1c4ef490bcfe9a48b10556e88685d2055;hb=88750007d7869f178f0ba528f41efd3b74c424cf;hp=6c9a82502cd2c20ef633d7f002070d0042771ea9;hpb=6df9443a374e2b81278c61b8afc0a1eef7db280b;p=msp430-binutils.git diff --git a/bfd/elf32-m32c.c b/bfd/elf32-m32c.c index 6c9a825..4de500a 100644 --- a/bfd/elf32-m32c.c +++ b/bfd/elf32-m32c.c @@ -1,5 +1,5 @@ /* M16C/M32C specific support for 32-bit ELF. - Copyright (C) 2005, 2006, 2007 + Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -597,7 +597,6 @@ m32c_elf_check_relocs { Elf_Internal_Shdr * symtab_hdr; struct elf_link_hash_entry ** sym_hashes; - struct elf_link_hash_entry ** sym_hashes_end; const Elf_Internal_Rela * rel; const Elf_Internal_Rela * rel_end; bfd_vma *local_plt_offsets; @@ -613,10 +612,6 @@ m32c_elf_check_relocs splt = NULL; dynobj = elf_hash_table(info)->dynobj; - 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++) { @@ -852,7 +847,7 @@ m32c_elf_print_private_bfd_data (bfd *abfd, PTR ptr) _bfd_elf_print_private_bfd_data (abfd, ptr); flags = elf_elfheader (abfd)->e_flags; - fprintf (file, _("private flags = 0x%lx:"), (long)flags); + fprintf (file, _("private flags = 0x%lx:"), (unsigned long) flags); switch (flags & EF_M32C_CPU_MASK) { @@ -1956,13 +1951,24 @@ m32c_elf_relax_delete_bytes for (; isym < isymend; isym++, shndx = (shndx ? shndx + 1 : NULL)) { - + /* If the symbol is in the range of memory we just moved, we + have to adjust its value. */ if ((int) isym->st_shndx == sec_shndx && isym->st_value > addr && isym->st_value < toaddr) { isym->st_value -= count; } + /* If the symbol *spans* the bytes we just deleted (i.e. it's + *end* is in the moved bytes but it's *start* isn't), then we + must adjust its size. */ + if ((int) isym->st_shndx == sec_shndx + && isym->st_value < addr + && isym->st_value + isym->st_size > addr + && isym->st_value + isym->st_size < toaddr) + { + isym->st_size -= count; + } } /* Now adjust the global symbols defined in this section. */ @@ -1977,22 +1983,41 @@ m32c_elf_relax_delete_bytes struct elf_link_hash_entry * sym_hash = * sym_hashes; if (sym_hash && - ( sym_hash->root.type == bfd_link_hash_defined + (sym_hash->root.type == bfd_link_hash_defined || sym_hash->root.type == bfd_link_hash_defweak) - && sym_hash->root.u.def.section == sec - && sym_hash->root.u.def.value > addr - && sym_hash->root.u.def.value < toaddr) + && sym_hash->root.u.def.section == sec) { - sym_hash->root.u.def.value -= count; + if (sym_hash->root.u.def.value > addr + && sym_hash->root.u.def.value < toaddr) + { + sym_hash->root.u.def.value -= count; + } + if (sym_hash->root.u.def.value < addr + && sym_hash->root.u.def.value + sym_hash->size > addr + && sym_hash->root.u.def.value + sym_hash->size < toaddr) + { + sym_hash->size -= count; + } } } return TRUE; } + +/* This is for versions of gcc prior to 4.3. */ +static unsigned int +_bfd_m32c_elf_eh_frame_address_size (bfd *abfd, asection *sec ATTRIBUTE_UNUSED) +{ + if ((elf_elfheader (abfd)->e_flags & EF_M32C_CPU_MASK) == EF_M32C_CPU_M16C) + return 2; + return 4; +} + #define ELF_ARCH bfd_arch_m32c #define ELF_MACHINE_CODE EM_M32C +#define ELF_MACHINE_ALT1 EM_M32C_OLD #define ELF_MAXPAGESIZE 0x1000 #if 0 @@ -2016,6 +2041,7 @@ m32c_elf_relax_delete_bytes m32c_elf_finish_dynamic_sections #define elf_backend_can_gc_sections 1 +#define elf_backend_eh_frame_address_size _bfd_m32c_elf_eh_frame_address_size #define bfd_elf32_bfd_reloc_type_lookup m32c_reloc_type_lookup #define bfd_elf32_bfd_reloc_name_lookup m32c_reloc_name_lookup