aboutsummaryrefslogtreecommitdiff
path: root/bfd/libbfd.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2024-04-04 06:52:27 -0700
committerH.J. Lu <hjl.tools@gmail.com>2024-04-04 15:35:31 -0700
commit360d244b24e84c50f2c6054908cfafb370a1f13c (patch)
tree4d8fc1290ac9ecfe74cbf02f2bd7b9db4ee48494 /bfd/libbfd.c
parentc2d698fe03a6092d58a07de96068b87836daced0 (diff)
downloadgdb-360d244b24e84c50f2c6054908cfafb370a1f13c.zip
gdb-360d244b24e84c50f2c6054908cfafb370a1f13c.tar.gz
gdb-360d244b24e84c50f2c6054908cfafb370a1f13c.tar.bz2
bfd: Handle bmmap failure in _bfd_mmap_read_temporary
iovec->bmmap may return MAP_FAILED, which happens in GDB on objects with iovec == opncls_iovec. Update _bfd_mmap_read_temporary to handle iovec->bmmap failure. * libbfd.c (_bfd_mmap_read_temporary): Handle iovec->bmmap failure.
Diffstat (limited to 'bfd/libbfd.c')
-rw-r--r--bfd/libbfd.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 869f0ed..5126ee2 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -1205,12 +1205,18 @@ _bfd_mmap_read_temporary (void **data_p, size_t *size_p,
&& (abfd->flags & BFD_PLUGIN) == 0);
if (use_mmmap)
{
- data = _bfd_mmap_readonly_temporary (abfd, size, mmap_base,
- size_p);
- if (data == NULL || data == MAP_FAILED)
- abort ();
- *data_p = data;
- return true;
+ void *mmaped = _bfd_mmap_readonly_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;
+ }
}
#endif