This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
.eh_frame related ld segfault
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sourceware dot org
- Date: Mon, 21 Jul 2008 17:19:04 +0930
- Subject: .eh_frame related ld segfault
Someone sent me a testcase with a .eh_frame section that caused ld to
hit the assertion shown on the last line of the diff below, then
segfault a little later. It turned out to be caused by a zero
terminator in the input file, which isn't a nice thing to have since
it can cause following .eh_frame info to be lost.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Drop
unwanted zero terminators.
Index: bfd/elf-eh-frame.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-eh-frame.c,v
retrieving revision 1.70
diff -u -p -r1.70 elf-eh-frame.c
--- bfd/elf-eh-frame.c 9 Jan 2008 09:36:11 -0000 1.70
+++ bfd/elf-eh-frame.c 21 Jul 2008 07:16:59 -0000
@@ -1077,7 +1077,11 @@ _bfd_elf_discard_section_eh_frame
hdr_info = &elf_hash_table (info)->eh_info;
for (ent = sec_info->entry; ent < sec_info->entry + sec_info->count; ++ent)
- if (!ent->cie)
+ if (ent->size == 4)
+ /* There should only be one zero terminator, on the last input
+ file supplying .eh_frame (crtend.o). Remove any others. */
+ ent->removed = sec->map_head.s != NULL;
+ else if (!ent->cie)
{
cookie->rel = cookie->rels + ent->reloc_index;
BFD_ASSERT (cookie->rel < cookie->relend
--
Alan Modra
Australia Development Lab, IBM