[PATCH] Don't crash if .eh_frame CIE is removed because of no FDEs referencing it and no CIEs preceede it
Jakub Jelinek
jakub@redhat.com
Thu Jan 3 08:57:00 GMT 2002
Hi!
This patch fixes NetBSD x86_64 libc build ld segfault.
If a CIE was removed because of no references to it, there is no need for
cie_offset either.
Ok to commit?
2002-01-03 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.
--- bfd/elf-eh-frame.c.jj Mon Dec 31 14:07:53 2001
+++ bfd/elf-eh-frame.c Thu Jan 3 19:09:44 2002
@@ -919,14 +919,23 @@ _bfd_elf_write_section_eh_frame (abfd, s
{
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 */
Jakub
More information about the Binutils
mailing list