* [committed]: mach-o: avoid a crash if no symbols.
@ 2011-08-03 8:12 Tristan Gingold
0 siblings, 0 replies; only message in thread
From: Tristan Gingold @ 2011-08-03 8:12 UTC (permalink / raw)
To: binutils Development
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));
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-08-03 8:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-03 8:12 [committed]: mach-o: avoid a crash if no symbols Tristan Gingold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).