2005-10-27 Alan Modra <amodra@bigpond.net.au>
+ * bfdwin.c (bfd_get_file_window): Seek into file in place of
+ using bfd_cache_lookup.
+
* 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.
/* Support for memory-mapped windows into a BFD.
- Copyright 1995, 1996, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright 1995, 1996, 2001, 2002, 2003, 2005
+ Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
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)
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;