From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: binutils@sourceware.org, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] bfd: Handle bmmap failure in _bfd_mmap_read_temporary
Date: Fri, 5 Apr 2024 08:54:38 +1030 [thread overview]
Message-ID: <Zg8opu7ddmV35rBa@squeak.grove.modra.org> (raw)
In-Reply-To: <20240404135227.204529-1-hjl.tools@gmail.com>
On Thu, Apr 04, 2024 at 06:52:27AM -0700, H.J. Lu wrote:
> 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.
OK.
> 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
>
> --
> 2.44.0
--
Alan Modra
Australia Development Lab, IBM
prev parent reply other threads:[~2024-04-04 22:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 13:52 H.J. Lu
2024-04-04 22:24 ` Alan Modra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zg8opu7ddmV35rBa@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=gdb-patches@sourceware.org \
--cc=hjl.tools@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).