OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [bfd/] [cache.c] - Diff between revs 14 and 161

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 14 Rev 161
Line 43... Line 43...
 
 
#include "sysdep.h"
#include "sysdep.h"
#include "bfd.h"
#include "bfd.h"
#include "libbfd.h"
#include "libbfd.h"
#include "libiberty.h"
#include "libiberty.h"
 
#include "bfd_stdint.h"
 
 
#ifdef HAVE_MMAP
#ifdef HAVE_MMAP
#include <sys/mman.h>
#include <sys/mman.h>
#endif
#endif
 
 
Line 396... Line 397...
cache_bmmap (struct bfd *abfd ATTRIBUTE_UNUSED,
cache_bmmap (struct bfd *abfd ATTRIBUTE_UNUSED,
             void *addr ATTRIBUTE_UNUSED,
             void *addr ATTRIBUTE_UNUSED,
             bfd_size_type len ATTRIBUTE_UNUSED,
             bfd_size_type len ATTRIBUTE_UNUSED,
             int prot ATTRIBUTE_UNUSED,
             int prot ATTRIBUTE_UNUSED,
             int flags ATTRIBUTE_UNUSED,
             int flags ATTRIBUTE_UNUSED,
             file_ptr offset ATTRIBUTE_UNUSED)
             file_ptr offset ATTRIBUTE_UNUSED,
 
             void **map_addr ATTRIBUTE_UNUSED,
 
             bfd_size_type *map_len ATTRIBUTE_UNUSED)
{
{
  void *ret = (void *) -1;
  void *ret = (void *) -1;
 
 
  if ((abfd->flags & BFD_IN_MEMORY) != 0)
  if ((abfd->flags & BFD_IN_MEMORY) != 0)
    abort ();
    abort ();
#ifdef HAVE_MMAP
#ifdef HAVE_MMAP
  else
  else
    {
    {
      FILE *f = bfd_cache_lookup (abfd, CACHE_NO_SEEK_ERROR);
      static uintptr_t pagesize_m1;
 
      FILE *f;
 
      file_ptr pg_offset;
 
      bfd_size_type pg_len;
 
 
 
      f = bfd_cache_lookup (abfd, CACHE_NO_SEEK_ERROR);
      if (f == NULL)
      if (f == NULL)
        return ret;
        return ret;
 
 
      ret = mmap (addr, len, prot, flags, fileno (f), offset);
      if (pagesize_m1 == 0)
 
        pagesize_m1 = getpagesize () - 1;
 
 
 
      /* Handle archive members.  */
 
      if (abfd->my_archive != NULL)
 
        offset += abfd->origin;
 
 
 
      /* Align.  */
 
      pg_offset = offset & ~pagesize_m1;
 
      pg_len = (len + (offset - pg_offset) + pagesize_m1) & ~pagesize_m1;
 
 
 
      ret = mmap (addr, pg_len, prot, flags, fileno (f), pg_offset);
      if (ret == (void *) -1)
      if (ret == (void *) -1)
        bfd_set_error (bfd_error_system_call);
        bfd_set_error (bfd_error_system_call);
 
      else
 
        {
 
          *map_addr = ret;
 
          *map_len = pg_len;
 
          ret += offset & pagesize_m1;
 
        }
    }
    }
#endif
#endif
 
 
  return ret;
  return ret;
}
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.