This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[RFC] Split I/O routines into two new files, bfdio.c and bfdwin.c
- From: Klee Dienes <klee at apple dot com>
- To: binutils at sources dot redhat dot com
- Date: Tue, 12 Nov 2002 21:19:30 -0500
- Subject: [RFC] Split I/O routines into two new files, bfdio.c and bfdwin.c
The next batch of patches I hope to submit are some extensions to be
core I/O layer of BFD.
They basically offer three improvements over the current core:
* Support for mutliply-nested layers of archives (for example, an
'ar'-format library that contains other 'ar'-format libraries, or
Mach-O fat binaries).
* Support for "user-defined" I/O routines for BFDs --- the user passes
in a struct containing a set of function pointers to implement
read/write/seek/close/flush/stat, and have that be used as the basis of
a BFD. We use this in our GDB support to allow treating sections of
memory in the inferior as a BFD, by dispatching the BFD I/O calls
through the GDB target read/write calls.
* Improved support for "in-memory" BFDs, allowing clients to create
BFDs out of memory regions and/or mmap, and access them via
get_section_in_window.
I've got a bit of work to do to clean them up and split them into
manageable patches; I'll post more on each as I submit them. One issue
that arises though:
When I did the work, I found that it was much easier for me to manage
the I/O code and mmap code if I split it out into separate files
(particularly the I/O code, as I could iterate through it to make sure
I'd handle all the clients of a given interface when making a
modification).
So for example, our bfdio.c contains the following functions:
bfd_bread, bfd_bwrite, bfd_flush, bfd_tell, bfd_stat, bfd_seek,
_bfd_io_close, bfd_get_mtime, bfd_get_size (we've removed some of the
functions from the original implementation, like real_read).
Unfortunately for us, it's not very practical to make diffs between
source trees where functions have been moved from one file to another.
So we either need to convince you to make the equivalent split of
source files, or re-merge our sources into one big file again.
What would your opinion be on a patch to split the existing I/O and
window code from libbfd.c, opncls.c, and bfd.c into two new files,
bfdio.c and bfdwin.c? It would be a purely mechanical patch, just
moving functions and headers wholesale to the appropriate files.