ld dumps core (from 2.9.4.0.8 on) - patch
Johannes Reisinger
jreising@frequentis.com
Mon Mar 6 08:01:00 GMT 2000
Bug report:
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?
The patch seems to apply well to the newest sources too.
-jr
---------------------- cut here ---------------------------
# This is a patch for binutils-2.9.4.0.8 to update it to binutils-2.9.4.0.8.patched.
# It was generated by makepatch 1.93 (2.0BETA) on Mon Mar 6 12:42:32 2000.
#
# To apply this patch, chdir to source directory binutils-2.9.4.0.8 and enter
#
# patch -p1 -N < <this-file>
exit
# End of preamble.
# Patch input follows.
__DATA__
Index: bfd/format.c
####### binutils-2.9.4.0.8.patched/ => binutils-2.9.4.0.8.patched
*** binutils-2.9.4.0.8.patched/bfd/format.c Mon Mar 6 11:28:29 2000
--- binutils-2.9.4.0.8.patched/bfd/format.c Mon Mar 6 12:32:19 2000
***************
*** 123,129 ****
char **matching_vector = NULL;
int match_count;
! if (!bfd_read_p (abfd) ||
((int)(abfd->format) < (int)bfd_unknown) ||
((int)(abfd->format) >= (int)bfd_type_end)) {
bfd_set_error (bfd_error_invalid_operation);
--- 123,130 ----
char **matching_vector = NULL;
int match_count;
! if (abfd == NULL ||
! !bfd_read_p (abfd) ||
((int)(abfd->format) < (int)bfd_unknown) ||
((int)(abfd->format) >= (int)bfd_type_end)) {
bfd_set_error (bfd_error_invalid_operation);
End of Patch.
---------------------- cut here ---------------------------
--
Dr. Johannes Reisinger
System Design
FREQUENTIS
A-1120 Wien, Spittelbreitengasse 34
http://www.frequentis.com
Tel: +43/1/81150-2329, Fax -2299
mailto:jreising@frequentis.com
More information about the Binutils
mailing list