* [binutils-gdb] bfd: Handle bmmap failure in _bfd_mmap_read_temporary
@ 2024-04-04 22:36 H.J. Lu
0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2024-04-04 22:36 UTC (permalink / raw)
To: binutils-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=360d244b24e84c50f2c6054908cfafb370a1f13c
commit 360d244b24e84c50f2c6054908cfafb370a1f13c
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Apr 4 06:52:27 2024 -0700
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.
Diff:
---
bfd/libbfd.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 869f0ed5c66..5126ee207a8 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-04 22:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-04 22:36 [binutils-gdb] bfd: Handle bmmap failure in _bfd_mmap_read_temporary H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).