bfd_read and bfd_write
Alan Modra
amodra@bigpond.net.au
Tue Sep 4 22:20:00 GMT 2001
I have a (rather large) patch to clean up a few things in bfd that I'd
like to apply in the next day or so, but first thought I'd better give
people fair warning and a chance to object.
One of the changes I've made is to bfd_read, and similarly bfd_write.
bfd_size_type
-bfd_read (ptr, size, nitems, abfd)
+bfd_read (ptr, size, abfd)
PTR ptr;
bfd_size_type size;
- bfd_size_type nitems;
bfd *abfd;
Why the change? Well, in having both "size" and "nitems", you'd expect
bfd_read to behave like fread, but it doesn't. bfd_read returns
"size * nitems" on success, whereas fread returns "nitems". Additionally,
many places in bfd swap the "size" and "nitems" args, and technically
we should always have size == 1 since we are operating on files of bytes.
This doesn't really matter as bfd_read does the multiplication and
passes size == 1 down to fread, but we're breaking the fread abstraction.
This change will of course break gdb, for which I have patches, and
any uncontributed ports.
Comments/flames?
Alan
More information about the Binutils
mailing list