LoongArch: Fix LD check fails.
[binutils-gdb.git] / bfd / bfdwin.c
index 1aaee2cd8577cef5412d646528a2b07be4f70818..14cb33c23b09a78ae0988d5ddfeac28d8ce55919 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for memory-mapped windows into a BFD.
 /* Support for memory-mapped windows into a BFD.
-   Copyright (C) 1995-2016 Free Software Foundation, Inc.
+   Copyright (C) 1995-2022 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -104,12 +104,12 @@ bfd_free_window (bfd_window *windowp)
 
 static int ok_to_map = 1;
 
 
 static int ok_to_map = 1;
 
-bfd_boolean
+bool
 bfd_get_file_window (bfd *abfd,
                     file_ptr offset,
                     bfd_size_type size,
                     bfd_window *windowp,
 bfd_get_file_window (bfd *abfd,
                     file_ptr offset,
                     bfd_size_type size,
                     bfd_window *windowp,
-                    bfd_boolean writable)
+                    bool writable)
 {
   static size_t pagesize;
   bfd_window_internal *i = windowp->i;
 {
   static size_t pagesize;
   bfd_window_internal *i = windowp->i;
@@ -131,7 +131,7 @@ bfd_get_file_window (bfd *abfd,
     {
       i = bfd_zmalloc (sizeof (bfd_window_internal));
       if (i == NULL)
     {
       i = bfd_zmalloc (sizeof (bfd_window_internal));
       if (i == NULL)
-       return FALSE;
+       return false;
       i->data = NULL;
     }
 #ifdef HAVE_MMAP
       i->data = NULL;
     }
 #ifdef HAVE_MMAP
@@ -144,11 +144,13 @@ bfd_get_file_window (bfd *abfd,
       int fd;
 
       /* Find the real file and the real offset into it.  */
       int fd;
 
       /* Find the real file and the real offset into it.  */
-      while (abfd->my_archive != NULL)
+      while (abfd->my_archive != NULL
+            && !bfd_is_thin_archive (abfd->my_archive))
        {
          offset += abfd->origin;
          abfd = abfd->my_archive;
        }
        {
          offset += abfd->origin;
          abfd = abfd->my_archive;
        }
+      offset += abfd->origin;
 
       /* Seek into the file, to ensure it is open if cacheable.  */
       if (abfd->iostream == NULL
 
       /* Seek into the file, to ensure it is open if cacheable.  */
       if (abfd->iostream == NULL
@@ -197,7 +199,7 @@ bfd_get_file_window (bfd *abfd,
       i->mapped = 1;
       i->refcount = 1;
       windowp->i = i;
       i->mapped = 1;
       i->refcount = 1;
       windowp->i = i;
-      return TRUE;
+      return true;
     }
   else if (debug_windows)
     {
     }
   else if (debug_windows)
     {
@@ -229,7 +231,7 @@ bfd_get_file_window (bfd *abfd,
       if (size_to_alloc == 0)
        {
          windowp->i = i;
       if (size_to_alloc == 0)
        {
          windowp->i = i;
-         return TRUE;
+         return true;
        }
       goto free_and_fail;
     }
        }
       goto free_and_fail;
     }
@@ -252,12 +254,12 @@ bfd_get_file_window (bfd *abfd,
   windowp->data = i->data;
   windowp->size = i->size;
   windowp->i = i;
   windowp->data = i->data;
   windowp->size = i->size;
   windowp->i = i;
-  return TRUE;
+  return true;
 
  free_and_fail:
   /* We have a bfd_window_internal, but an error occurred.  Free it. */
   free (i);
 
  free_and_fail:
   /* We have a bfd_window_internal, but an error occurred.  Free it. */
   free (i);
-  return FALSE;
+  return false;
 }
 
 #endif /* USE_MMAP */
 }
 
 #endif /* USE_MMAP */