* elf32-sh.c (sh_elf_relax_delete_bytes): Handle R_SH_SWITCH32
authorJoern Rennecke <joern.rennecke@embecosm.com>
Thu, 3 Jun 1999 18:54:32 +0000 (18:54 +0000)
committerJoern Rennecke <joern.rennecke@embecosm.com>
Thu, 3 Jun 1999 18:54:32 +0000 (18:54 +0000)
in other text sections.

bfd/ChangeLog
bfd/elf32-sh.c

index 478477207ce6200738e1ef534263ab8a4f599e95..0cfee3d336378d9e707a690a2bf7963480b57d83 100644 (file)
@@ -1,3 +1,8 @@
+Fri Jun  4 02:53:13 1999  J"orn Rennecke <amylaar@cygnus.co.uk>
+
+       * elf32-sh.c (sh_elf_relax_delete_bytes): Handle R_SH_SWITCH32
+       in other text sections.
+
 Fri Jun  4 02:29:34 1999  J"orn Rennecke <amylaar@cygnus.co.uk>
 
        * libbfd.c (_bfd_generic_verify_endian_match): New function.
index aa9bc0068928b27a034486783e3f38c1761db6e2..b3670d0fcf10d556185b5bd225646075aa2d8607 100644 (file)
@@ -1307,6 +1307,56 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count)
        {
          Elf_Internal_Sym sym;
 
+         /* Dwarf line numbers use R_SH_SWITCH32 relocs.  */
+         if (ELF32_R_TYPE (irelscan->r_info) == (int) R_SH_SWITCH32)
+           {
+             bfd_vma start, stop;
+             bfd_signed_vma voff;
+
+             if (ocontents == NULL)
+               {
+                 if (elf_section_data (o)->this_hdr.contents != NULL)
+                   ocontents = elf_section_data (o)->this_hdr.contents;
+                 else
+                   {
+                     /* We always cache the section contents.
+                         Perhaps, if info->keep_memory is false, we
+                         should free them, if we are permitted to,
+                         when we leave sh_coff_relax_section.  */
+                     ocontents = (bfd_byte *) bfd_malloc (o->_raw_size);
+                     if (ocontents == NULL)
+                       return false;
+                     if (! bfd_get_section_contents (abfd, o, ocontents,
+                                                     (file_ptr) 0,
+                                                     o->_raw_size))
+                       return false;
+                     elf_section_data (o)->this_hdr.contents = ocontents;
+                   }
+               }
+
+             stop = irelscan->r_offset;
+             start
+               = (bfd_vma) ((bfd_signed_vma) stop - (long) irelscan->r_addend);
+
+             /* STOP is in a different section, so it won't change.  */
+             if (start > addr && start < toaddr)
+               irelscan->r_addend += count;
+
+             voff = bfd_get_signed_32 (abfd, ocontents + irelscan->r_offset);
+             stop = (bfd_vma) ((bfd_signed_vma) start + voff);
+
+             if (start > addr
+                 && start < toaddr
+                 && (stop <= addr || stop >= toaddr))
+               bfd_put_signed_32 (abfd, voff + count,
+                                  ocontents + irelscan->r_offset);
+             else if (stop > addr
+                      && stop < toaddr
+                      && (start <= addr || start >= toaddr))
+               bfd_put_signed_32 (abfd, voff - count,
+                                  ocontents + irelscan->r_offset);
+           }
+
          if (ELF32_R_TYPE (irelscan->r_info) != (int) R_SH_DIR32)
            continue;