]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/bfdwin.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / bfd / bfdwin.c
index 49b751cbbda2725a0e21b0f1b05fd68a0a952dd2..beb17398744d8c3522516d7bae4133691dbbd29c 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for memory-mapped windows into a BFD.
-   Copyright (C) 1995-2023 Free Software Foundation, Inc.
+   Copyright (C) 1995-2024 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -47,15 +47,47 @@ static int debug_windows;
    though.  */
 
 /*
-INTERNAL_DEFINITION
-
-.struct _bfd_window_internal {
+INTERNAL
+.typedef struct _bfd_window_internal
+.{
 .  struct _bfd_window_internal *next;
 .  void *data;
 .  bfd_size_type size;
 .  int refcount : 31;          {* should be enough...  *}
 .  unsigned mapped : 1;                {* 1 = mmap, 0 = malloc *}
-.};
+.}
+.bfd_window_internal;
+.
+
+EXTERNAL
+.struct _bfd_window_internal;
+.
+.typedef struct _bfd_window
+.{
+.  {* What the user asked for.  *}
+.  void *data;
+.  bfd_size_type size;
+.  {* The actual window used by BFD.  Small user-requested read-only
+.     regions sharing a page may share a single window into the object
+.     file.  Read-write versions shouldn't until I've fixed things to
+.     keep track of which portions have been claimed by the
+.     application; don't want to give the same region back when the
+.     application wants two writable copies!  *}
+.  struct _bfd_window_internal *i;
+.}
+.bfd_window;
+.
+*/
+
+/*
+FUNCTION
+       bfd_init_window
+
+SYNOPSIS
+       void bfd_init_window (bfd_window *);
+
+DESCRIPTION
+       Initialise mmap window.
 */
 
 void
@@ -66,6 +98,17 @@ bfd_init_window (bfd_window *windowp)
   windowp->size = 0;
 }
 
+/*
+FUNCTION
+       bfd_free_window
+
+SYNOPSIS
+       void bfd_free_window (bfd_window *);
+
+DESCRIPTION
+       Finalise mmap window struct.
+*/
+
 void
 bfd_free_window (bfd_window *windowp)
 {
@@ -102,7 +145,17 @@ bfd_free_window (bfd_window *windowp)
   free (i);
 }
 
-static int ok_to_map = 1;
+/*
+FUNCTION
+       bfd_get_file_window
+
+SYNOPSIS
+       bool bfd_get_file_window
+         (bfd *, file_ptr, bfd_size_type, bfd_window *, bool {*writable*});
+
+DESCRIPTION
+       mmap from a bfd's iostream.
+*/
 
 bool
 bfd_get_file_window (bfd *abfd,
@@ -111,6 +164,7 @@ bfd_get_file_window (bfd *abfd,
                     bfd_window *windowp,
                     bool writable)
 {
+  static int ok_to_map = 1;
   static size_t pagesize;
   bfd_window_internal *i = windowp->i;
   bfd_size_type size_to_alloc = size;
@@ -238,7 +292,7 @@ bfd_get_file_window (bfd *abfd,
   i->refcount = 1;
   if (bfd_seek (abfd, offset, SEEK_SET) != 0)
     goto free_and_fail;
-  i->size = bfd_bread (i->data, size, abfd);
+  i->size = bfd_read (i->data, size, abfd);
   if (i->size != size)
     goto free_and_fail;
   i->mapped = 0;