This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: ld dumps core (from 2.9.4.0.8 on) - patch
- To: jreising at frequentis dot com
- Subject: Re: ld dumps core (from 2.9.4.0.8 on) - patch
- From: Ian Lance Taylor <ian at zembu dot com>
- Date: 6 Mar 2000 13:10:26 -0500
- CC: binutils at sourceware dot cygnus dot com
- References: <20000306170005.A6728@frequentis.com>
From: jreising@frequentis.com (Johannes Reisinger)
Date: Mon, 6 Mar 2000 17:00:05 +0100
In binutils-2.9.4.0.8 (sorry, I don't know the original version number - only
the one from ftp.varesearch.com) a bug was introduced which causes ld to dump
core in my appliation.
The reason was a newly introduced piece of code in ld/ldfile.c:
..
141 if (bfd_check_format (entry->the_bfd, bfd_archive))
142 check = bfd_openr_next_archived_file (entry->the_bfd, NULL);
143 else
144 check = entry->the_bfd;
145
146 if (! bfd_check_format (check, bfd_object))
147 return true;
..
bfd_check_format assumes that its first element is non-NULL, but
bfd_openr_next_archived_file returns NULL in some cases.
I believe that it is best to fix the bug in bfd_check_format by
checking its first argument against NULL.
Please can anyone check my patch and, if it is correct, apply it to
the sources?
Thanks for the bug report and patch.
I think your patch is to the wrong place; I don't see any reason that
bfd_check_format should check for a NULL pointer, and in any case an
empty archive should not cause an error here.
I instead changed the code in ldfile_try_open_bfd to check for a NULL
return from bfd_openr_next_archived_file.
Ian