*** empty log message ***
[deliverable/binutils-gdb.git] / bfd / elf32-m32c.c
index dd4054118dfe1ee55d84c93ec4810df52083daf2..a706ac31175ac234f8b4408bec69eaaaa8e36939 100644 (file)
@@ -1,5 +1,5 @@
 /* M16C/M32C specific support for 32-bit ELF.
-   Copyright (C) 2005, 2006, 2007
+   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -847,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)
     {
@@ -1188,7 +1188,7 @@ static bfd_vma
 m32c_offset_for_reloc (bfd *abfd,
                       Elf_Internal_Rela *rel,
                       Elf_Internal_Shdr *symtab_hdr,
-                      Elf_External_Sym_Shndx *shndx_buf,
+                      Elf_External_Sym_Shndx *shndx_buf ATTRIBUTE_UNUSED,
                       Elf_Internal_Sym *intsyms)
 {
   bfd_vma symval;
@@ -1198,14 +1198,10 @@ m32c_offset_for_reloc (bfd *abfd,
     {
       /* A local symbol.  */
       Elf_Internal_Sym *isym;
-      Elf_External_Sym_Shndx *shndx;
       asection *ssec;
 
-
       isym = intsyms + ELF32_R_SYM (rel->r_info);
       ssec = bfd_section_from_elf_index (abfd, isym->st_shndx);
-      shndx = shndx_buf + (shndx_buf ? ELF32_R_SYM (rel->r_info) : 0);
-
       symval = isym->st_value;
       if (ssec)
        symval += ssec->output_section->vma
@@ -1870,7 +1866,6 @@ m32c_elf_relax_delete_bytes
   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;
@@ -1883,9 +1878,6 @@ m32c_elf_relax_delete_bytes
 
   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;
@@ -1951,13 +1943,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.  */
@@ -1972,13 +1975,21 @@ 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;
+           }
        }
     }
 
@@ -1998,6 +2009,7 @@ _bfd_m32c_elf_eh_frame_address_size (bfd *abfd, asection *sec ATTRIBUTE_UNUSED)
 
 #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
This page took 0.026777 seconds and 4 git commands to generate.