This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, COMMITTED]: Fix seg fault in elf32.em:_after_open


Hi Guys,

  Whilst working on another bug I came across a seg-fault in the
  _after_open() function in elf32.em.  If the target is not an ELF
  binary then get_elf_backend_data will return NULL, but the code was
  not checking for this.  Fixed by applying the following patch.

Cheers
  Nick

ld/ChangeLog
2010-08-20  Nick Clifton  <nickc@redhat.com>

	* emultempl/elf32.em (_after_open): Check for get_elf_backend_data
	returning NULL.

Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.209
diff -c -3 -p -r1.209 elf32.em
*** ld/emultempl/elf32.em	25 Jun 2010 04:46:05 -0000	1.209
--- ld/emultempl/elf32.em	20 Aug 2010 14:57:18 -0000
*************** gld${EMULATION_NAME}_after_open (void)
*** 1134,1142 ****
  	  const struct elf_backend_data *bed;
  
  	  bed = get_elf_backend_data (abfd);
! 	  s = bfd_make_section_with_flags (abfd, ".eh_frame_hdr",
! 					   bed->dynamic_sec_flags
! 					   | SEC_READONLY);
  	  if (s != NULL
  	      && bfd_set_section_alignment (abfd, s, 2))
  	    htab->eh_info.hdr_sec = s;
--- 1134,1145 ----
  	  const struct elf_backend_data *bed;
  
  	  bed = get_elf_backend_data (abfd);
! 	  if (bed == NULL)
! 	    s = NULL;
! 	  else
! 	    s = bfd_make_section_with_flags (abfd, ".eh_frame_hdr",
! 					     bed->dynamic_sec_flags
! 					     | SEC_READONLY);
  	  if (s != NULL
  	      && bfd_set_section_alignment (abfd, s, 2))
  	    htab->eh_info.hdr_sec = s;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]