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
commit25b88f335af1b8c7a4428710ffd9066338b167c0 (patch)
treefd707bda1bcc8d4d609622b5da49451b5c2e3303 /bfd/bfdio.c
parente433f867b0ffb2181886a9c2b3281ad5931ef31b (diff)
downloadbinutils-gdb-25b88f335af1b8c7a4428710ffd9066338b167c0.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 16bbf03a697..9b853389cc0 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);
+}