This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Bogus code in coffgen.c?
On Fri, Nov 02, 2001 at 07:31:30AM -0800, Ian Lance Taylor wrote:
> "H . J . Lu" <hjl@lucon.org> writes:
>
> > 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.
> > >
> >
> > How about this patch? It will catch more bad files.
>
> No, that patch is wrong, because it will not work on XCOFF. On XCOFF,
> f_opthdr may be 0, or aoutsz, or SMALL_AOUTSZ (a constant not
> available in coffgen.c).
>
Ok. Go back to my original patch.
H.J.