This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Bogus code in coffgen.c?
On Thu, Nov 01, 2001 at 05:12:53PM -0800, Ian Lance Taylor wrote:
> >
> > We allocate a buffer of `aoutsz' bytes. Then we read `internal_f.f_opthdr'
> > bytes into it. Why?
>
> For a normal COFF target, f_opthdr should be either 0 or aoutsz.
> XCOFF is an irritating exception: XCOFF defines a large and a small
> aout header (I believe the small header is used for an object file
> while the large header is used for an executable), so for XCOFF you
> have to pay attention to f_opthdr, and not read more than that. But
> you still want to allocate aoutsz bytes. because that is what
> swap_aouthdr_in and friends expect, even for a small XCOFF header.
>
> The code does the right thing for a correct object, but it's obviously
> risky for a bad object. I think your proposed patch is appropriate;
> we may want to consider a call bfd_error_handler describing the
> problem.
BTW, the problem I run into is strings dumps core on a font file. I don't
want an error message just because a font file is not COFF :-).
H.J.