* elf-eh-frame.c (_bfd_elf_write_section_eh_frame): Don't crash if
authorJakub Jelinek <jakub@redhat.com>
Fri, 4 Jan 2002 17:02:30 +0000 (17:02 +0000)
committerJakub Jelinek <jakub@redhat.com>
Fri, 4 Jan 2002 17:02:30 +0000 (17:02 +0000)
CIE at .eh_frame start is removed due to no FDEs referencing it.

bfd/ChangeLog
bfd/elf-eh-frame.c

index 66f0da9495707631605c3dde5d2530f1b04e5631..4695b895c30b3cba11f9520ee80cb844efd44b8f 100644 (file)
@@ -1,3 +1,8 @@
+2002-01-04  Jakub Jelinek  <jakub@redhat.com>
+
+       * elf-eh-frame.c (_bfd_elf_write_section_eh_frame): Don't crash if
+       CIE at .eh_frame start is removed due to no FDEs referencing it.
+
 2002-01-04  Jason Thorpe  <thorpej@wasabisystems.com>
 
        * config.bfd (x86_64-*-netbsd*): New target.
index cc653f7c81ed430de2ac5b1f9bc640b0957760f6..56a59da410c2b2a366da3891a30de491bb5fe2aa 100644 (file)
@@ -919,14 +919,23 @@ _bfd_elf_write_section_eh_frame (abfd, sec, ehdrsec, contents)
        {
          if (sec_info->entry[i].cie)
            {
-             cie_offset = sec_info->entry[i].new_offset;
-             cie_offset += (sec_info->entry[i].sec->output_section->vma
-                            + sec_info->entry[i].sec->output_offset
-                            - sec->output_section->vma
-                            - sec->output_offset);
+             /* If CIE is removed due to no remaining FDEs referencing it
+                and there were no CIEs kept before it, sec_info->entry[i].sec
+                will be zero.  */
+             if (sec_info->entry[i].sec == NULL)
+               cie_offset = 0;
+             else
+               {
+                 cie_offset = sec_info->entry[i].new_offset;
+                 cie_offset += (sec_info->entry[i].sec->output_section->vma
+                                + sec_info->entry[i].sec->output_offset
+                                - sec->output_section->vma
+                                - sec->output_offset);
+               }
            }
          continue;
        }
+
       if (sec_info->entry[i].cie)
        {
          /* CIE */