[committed]: mach-o: avoid a crash if no symbols.
Tristan Gingold
gingold@adacore.com
Wed Aug 3 08:12:00 GMT 2011
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));
More information about the Binutils
mailing list