This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: mainline ld on mingw32/pe is broken, returns 1 without error.
Alan Modra wrote:
> No, there's no easy way to debug this. I'd fire up gdb and see if we
> get to ldwrite. I'm guessing that the problem is in bfd_final_link,
> so that would mean tracing through _bfd_coff_final_link. Would you
> mind taking a look? If that doesn't sound easy, could you please tar
> and gzip the set of objects and libraries involved in the link and
> send them to me.
Well, I've found where the error is coming from, but I have no idea why. :)
_bfd_coff_link_input_bfd seems to be asking for more data than is in the
file. See the following:
#0 cache_bread (abfd=0x3df0c8, buf=0x8904e0, nbytes=480930)
at ../../../../../src/cvs/src/bfd/cache.c:100
#1 0x004326f1 in bfd_bread (ptr=0x8904e0, size=480930, abfd=0x3df0c8)
at ../../../../../src/cvs/src/bfd/bfdio.c:129
#2 0x0043236d in _bfd_generic_get_section_contents (abfd=0x3df0c8,
section=0x6d76ec, location=0x8904e0, offset=0, count=480930)
at ../../../../../src/cvs/src/bfd/libbfd.c:706
#3 0x00426310 in bfd_get_section_contents (abfd=0x3df0c8,
section=0x6d76ec,
location=0x8904e0, offset=0, count=480930)
at ../../../../../src/cvs/src/bfd/section.c:1355
#4 0x0044c080 in _bfd_coff_link_input_bfd (finfo=0x22fe50,
input_bfd=0x3df0c8)
at ../../../../../src/cvs/src/bfd/cofflink.c:2308
#5 0x0044934d in _bfd_coff_final_link (abfd=0x3dced8, info=<incomplete
type>)
at ../../../../../src/cvs/src/bfd/cofflink.c:899
#6 0x00414987 in ldwrite () at ../../../../../src/cvs/src/ld/ldwrite.c:554
#7 0x00411dcb in main (argc=12, argv=0x3d2710)
at ../../../../../src/cvs/src/ld/ldmain.c:481
96 nread = fread (buf, 1, nbytes, bfd_cache_lookup (abfd));
97 /* Set bfd_error if we did not read as much data as we
expected. If
98 the read failed due to an error set the bfd_error_system_call,
99 else set bfd_error_file_truncated. */
100 if (nread < nbytes && ferror (bfd_cache_lookup (abfd)))
101 {
102 bfd_set_error (bfd_error_system_call);
103 return -1;
104 }
nread = 182131
nbytes = 480930
There is a second latent bug here also. The comment indicates that
bfd_error_file_truncated should be set in this case, and as near as I
can tell, it is not being set, which is what is causing the mysterious
silent failure. This can be easily fixed.
On the other hand, I have no idea how to figure out what is actually
causing the size requested to be wrong.
What next? :)
Aaron W. LaFramboise