summaryrefslogtreecommitdiff
path: root/bfd/bfdio.c
diff options
context:
space:
mode:
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);
+}