summaryrefslogtreecommitdiff
path: root/bfd/bfdio.c
diff options
context:
space:
mode:
authorPaul Pluzhnikov <ppluzhnikov@google.com>2009-06-11 00:41:03 +0000
committerPaul Pluzhnikov <ppluzhnikov@google.com>2009-06-11 00:41:03 +0000
commitfbae753168b4aacde18476202392298c309049ae (patch)
treed80fd12d3ff22d369f745eac46d9b75134e01ecc /bfd/bfdio.c
parent376728930cd7373bc0c3f222198c513a5c4f8c7d (diff)
downloadbinutils-redhat-fbae753168b4aacde18476202392298c309049ae.tar.gz
2009-06-10 Paul Pluzhnikov <ppluzhnikov@google.com>
* bfd-in2.h: bfd_mmap prototype * bfdio.c (bfd_mmap): New function. * libbfd.h (bfd_iovec): Add bmmap. * cache.c (cache_bmap): New function. (cache_iovec): Initialize bmmap member. * opencls.c (opncls_bmmap): New function. (opncls_iovec): Initialize bmmap member.
Diffstat (limited to 'bfd/bfdio.c')
-rw-r--r--bfd/bfdio.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 16bbf03a69..9b853389cc 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -158,6 +158,8 @@ DESCRIPTION
. int (*bclose) (struct bfd *abfd);
. int (*bflush) (struct bfd *abfd);
. int (*bstat) (struct bfd *abfd, struct stat *sb);
+. void* (*bmmap) (struct bfd *abfd, void *addr, bfd_size_type len,
+. int prot, int flags, file_ptr offset);
.};
*/
@@ -511,3 +513,31 @@ bfd_get_size (bfd *abfd)
return buf.st_size;
}
+
+
+/*
+FUNCTION
+ bfd_mmap
+
+SYNOPSIS
+ void *bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
+ int prot, int flags, file_ptr offset);
+
+DESCRIPTION
+ Return mmap()ed region of the file, if possible and implemented.
+
+*/
+
+void *
+bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
+ int prot, int flags, file_ptr offset)
+{
+ void *ret = (void *)-1;
+ if ((abfd->flags & BFD_IN_MEMORY) != 0)
+ return ret;
+
+ if (abfd->iovec == NULL)
+ return ret;
+
+ return abfd->iovec->bmmap (abfd, addr, len, prot, flags, offset);
+}