summaryrefslogtreecommitdiff
path: root/bfd/elf-eh-frame.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2002-01-04 17:02:30 +0000
committerJakub Jelinek <jakub@redhat.com>2002-01-04 17:02:30 +0000
commitd03e400a5652bc26a4c1fcca3548a5e3f54ef796 (patch)
tree12509d17787a33437a3969ee3d662641d15f7174 /bfd/elf-eh-frame.c
parentd2f77cb45bb915a828f5f19680e474caeb037633 (diff)
downloadbinutils-redhat-d03e400a5652bc26a4c1fcca3548a5e3f54ef796.tar.gz
* 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.
Diffstat (limited to 'bfd/elf-eh-frame.c')
-rw-r--r--bfd/elf-eh-frame.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index cc653f7c81..56a59da410 100644
--- a/bfd/elf-eh-frame.c
+++ b/bfd/elf-eh-frame.c
@@ -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 */