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]

[committed]: mach-o: avoid a crash if no symbols.


Hi,

the mach-o backend crashed when trying to canonicalize the symbols if there are none.

Fixed with this patch.

Tristan.

2011-08-03  Tristan Gingold  <gingold@adacore.com>

	* mach-o.c (bfd_mach_o_canonicalize_symtab): Handle no symbols case.
	(bfd_mach_o_read_symtab_symbols): Return if no symbols.

RCS file: /cvs/src/src/bfd/mach-o.c,v
retrieving revision 1.58
diff -c -r1.58 mach-o.c
*** bfd/mach-o.c	28 Jun 2011 07:45:53 -0000	1.58
--- bfd/mach-o.c	3 Aug 2011 08:10:33 -0000
***************
*** 376,381 ****
--- 376,388 ----
    if (nsyms < 0)
      return nsyms;
  
+   if (nsyms == 0)
+     {
+       /* Do not try to read symbols if there are none.  */
+       alocation[0] = NULL;
+       return 0;
+     }
+ 
    if (bfd_mach_o_read_symtab_symbols (abfd) != 0)
      {
        (*_bfd_error_handler) (_("bfd_mach_o_canonicalize_symtab: unable to load symbols"));
***************
*** 1830,1837 ****
    unsigned long i;
    int ret;
  
!   if (sym->symbols)
!     return 0;
  
    sym->symbols = bfd_alloc (abfd, sym->nsyms * sizeof (bfd_mach_o_asymbol));
  
--- 1837,1847 ----
    unsigned long i;
    int ret;
  
!   if (sym == NULL || sym->symbols)
!     {
!       /* Return now if there are no symbols or if already loaded.  */
!       return 0;
!     }
  
    sym->symbols = bfd_alloc (abfd, sym->nsyms * sizeof (bfd_mach_o_asymbol));
  


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