X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf32-m32c.c;h=4de500a1c4ef490bcfe9a48b10556e88685d2055;hb=24df9a516a709809b109f21ad302f61a3c76062a;hp=64b2103f51c77684406ba1ccef90d24357af0b54;hpb=157090f728a99fff42b3d3cc576b0c2a953e9916;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-m32c.c b/bfd/elf32-m32c.c index 64b2103f51..4de500a1c4 100644 --- a/bfd/elf32-m32c.c +++ b/bfd/elf32-m32c.c @@ -1,12 +1,12 @@ /* 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. 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, @@ -18,8 +18,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "bfd.h" #include "sysdep.h" +#include "bfd.h" #include "libbfd.h" #include "elf-bfd.h" #include "elf/m32c.h" @@ -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