This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [rfa] Add the bfd_iovec
- From: Andrew Cagney <cagney at gnu dot org>
- To: Ian Lance Taylor <ian at wasabisystems dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Mon, 12 Apr 2004 18:32:30 -0400
- Subject: Re: [rfa] Add the bfd_iovec
- References: <407AC9D8.9040906@gnu.org> <m3wu4l59vk.fsf@gossamer.airs.com>
Andrew Cagney <cagney@gnu.org> writes:
Following up on earlier threads:
http://sources.redhat.com/ml/binutils/2004-02/msg00167.html
This adds an IOVEC to BFD. The IOVEC lets the client open a BFD on an
arbitrary object (file, memory, GDB inferior, ...). The attached
implements the iovec and then converts the file-io backend.
Converting the memory bfd to an IOVEC is a follow-on change.
In general, I like it, but:
* bfd_iovec needs each entry point to be clearly documented,
particularly how error conditions are handled.
I'll give it a go.
* I'm not crazy about the berror entry point. Right now it is used in
exactly one place, to indicate whether a short read is an error or
simply a truncated file. Since bfd_iovec is only going to be called
by BFD routines, I think it would be quite reasonable to make the
bread entry point responsible for calling bfd_set_error. Then the
caller does not need to go back in to find out what a short read
means. Note also that berror is the only function which doesn't
have an obvious mapping to a Unix system call.
There are three cases here:
- error
- eof
- partial read (as in the next read should yield more data)
I guess BFD isn't set up for partial transfers and retrys so the third
case doesn't apply?
* The same error handling principle could apply to all the other
bfd_iovec routines as well, of course. Compare with bfd_malloc, for
example: it just calls malloc and bfd_set_error, to centralize error
handling. I think we should use these routines to put the error
handling in the place which really knows what the error is. But I'm
certainly open to a counter argument.
Andrew