aboutsummaryrefslogtreecommitdiff
path: root/bfd/libbfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/libbfd.c')
-rw-r--r--bfd/libbfd.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 6587fc1..cb9862c 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -1098,24 +1098,26 @@ bfd_mmap_local (bfd *abfd, size_t rsize, void **map_addr, size_t *map_size)
/* Mmap a memory region of RSIZE bytes at the current offset.
Return mmap address and size in MAP_ADDR and MAP_SIZE. Return NULL
- on invalid input and MAP_FAILED for mmap failure. */
+ on invalid input. */
void *
_bfd_mmap_temporary (bfd *abfd, size_t rsize, void **map_addr,
size_t *map_size)
{
/* Use mmap only if section size >= the minimum mmap section size. */
- if (rsize < _bfd_minimum_mmap_size)
+ if (rsize >= _bfd_minimum_mmap_size)
{
- void *mem = _bfd_malloc_and_read (abfd, rsize, rsize);
- /* NB: Set *MAP_ADDR to MEM and *MAP_SIZE to 0 to indicate that
- _bfd_malloc_and_read is called. */
- *map_addr = mem;
- *map_size = 0;
- return mem;
+ void *result = bfd_mmap_local (abfd, rsize, map_addr, map_size);
+ if (result != MAP_FAILED)
+ return result;
}
- return bfd_mmap_local (abfd, rsize, map_addr, map_size);
+ void *mem = _bfd_malloc_and_read (abfd, rsize, rsize);
+ /* NB: Set *MAP_ADDR to MEM and *MAP_SIZE to 0 to indicate that
+ _bfd_malloc_and_read is called. */
+ *map_addr = mem;
+ *map_size = 0;
+ return mem;
}
/* Munmap RSIZE bytes at PTR. */
@@ -1213,15 +1215,10 @@ _bfd_mmap_read_temporary (void **data_p, size_t *size_p,
if (use_mmmap)
{
void *mmaped = _bfd_mmap_temporary (abfd, size, mmap_base, size_p);
- /* MAP_FAILED is returned when called from GDB on an object with
- opncls_iovec. Use bfd_read in this case. */
- if (mmaped != MAP_FAILED)
- {
- if (mmaped == NULL)
- abort ();
- *data_p = mmaped;
- return true;
- }
+ if (mmaped == NULL)
+ return false;
+ *data_p = mmaped;
+ return true;
}
#endif