This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: cache.c reorg
On Thu, Oct 27, 2005 at 01:06:56PM +0930, Alan Modra wrote:
> * hppabsd-core.c (hppabsd_core_core_file_p): Use bfd_stat, not fstat.
> * sco5-core.c (sco5_core_file_p): Likewise.
> * trad-core.c (trad_unix_core_file_p): Likewise.
>
> The above allows the following.
>
> * cache.c (BFD_CACHE_MAX_OPEN): Make private to this file.
> (bfd_last_cache, bfd_cache_lookup, bfd_cache_lookup_worker): Likewise.
> * libbfd-in.h (bfd_cache_lookup_worker, bfd_last_cache): Delete.
> * libbfd.h: Regenerate.
Bah, missed this one.
* bfdwin.c (bfd_get_file_window): Seek into file in place of
using bfd_cache_lookup.
Index: bfd/bfdwin.c
===================================================================
RCS file: /cvs/src/src/bfd/bfdwin.c,v
retrieving revision 1.7
diff -u -p -r1.7 bfdwin.c
--- bfd/bfdwin.c 26 Oct 2005 12:17:42 -0000 1.7
+++ bfd/bfdwin.c 27 Oct 2005 04:04:24 -0000
@@ -144,7 +145,6 @@ bfd_get_file_window (bfd *abfd,
file_ptr file_offset, offset2;
size_t real_size;
int fd;
- FILE *f;
/* Find the real file and the real offset into it. */
while (abfd->my_archive != NULL)
@@ -152,10 +152,13 @@ bfd_get_file_window (bfd *abfd,
offset += abfd->origin;
abfd = abfd->my_archive;
}
- f = bfd_cache_lookup (abfd);
- if (f == NULL)
+
+ /* Seek into the file, to ensure it is open if cacheable. */
+ if (abfd->iostream == NULL
+ && (abfd->iovec == NULL
+ || abfd->iovec->bseek (abfd, offset, SEEK_SET) != 0))
return FALSE;
- fd = fileno (f);
+ fd = fileno ((FILE *) abfd->iostream);
/* Compute offsets and size for mmap and for the user's data. */
offset2 = offset % pagesize;
--
Alan Modra
IBM OzLabs - Linux Technology Centre