This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PR 12887, invalid .eh_frame ld segfault
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Tue, 14 Jun 2011 22:27:23 +0930
- Subject: PR 12887, invalid .eh_frame ld segfault
It's amazing what people manage to feed ld. This PR is about a
.eh_frame section with SHF_MERGE and SHF_STRINGS set.
PR ld/12887
* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Check sec_info_type
before doing anything.
(_bfd_elf_discard_section_eh_frame): Likewise.
Index: bfd/elf-eh-frame.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-eh-frame.c,v
retrieving revision 1.85
diff -u -p -r1.85 elf-eh-frame.c
--- bfd/elf-eh-frame.c 23 Nov 2010 23:30:04 -0000 1.85
+++ bfd/elf-eh-frame.c 14 Jun 2011 12:48:12 -0000
@@ -490,7 +490,8 @@ _bfd_elf_parse_eh_frame (bfd *abfd, stru
if (hdr_info->parsed_eh_frames)
return;
- if (sec->size == 0)
+ if (sec->size == 0
+ || sec->sec_info_type != ELF_INFO_TYPE_NONE)
{
/* This file does not contain .eh_frame information. */
return;
@@ -1133,6 +1134,9 @@ _bfd_elf_discard_section_eh_frame
struct eh_frame_hdr_info *hdr_info;
unsigned int ptr_size, offset;
+ if (sec->sec_info_type != ELF_INFO_TYPE_EH_FRAME)
+ return FALSE;
+
sec_info = (struct eh_frame_sec_info *) elf_section_data (sec)->sec_info;
if (sec_info == NULL)
return FALSE;
--
Alan Modra
Australia Development Lab, IBM