]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Change return value of _bfd_mmap_temporary
authorTom Tromey <tom@tromey.com>
Thu, 4 Sep 2025 20:12:52 +0000 (14:12 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 8 Sep 2025 14:44:48 +0000 (08:44 -0600)
commit8b50cc76f19d129b3887dbcb58f8286a7b36099f
treec59f10b87df27fb3ec5493414190f382a037895e
parente447f3a122cd90d99582475c9a18f7b4c23468dd
Change return value of _bfd_mmap_temporary

_bfd_mmap_temporary will return MAP_FAILED in some cases, but only one
caller was prepared for this.  This caused a couple of issues in gdb.

This patch chnages _bfd_mmap_temporary to always return NULL on
failure.  It also changes the logic to fall back to bfd_malloc if mmap
fails.

I took the opportunity to change some "(void *) -1" to MAP_FAILED
where appropriate.

Tested by "make check" in binutils, and also by applying a hack from
bug 33354 to gdb and testing something approximating the original
report.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32542
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33354
bfd/bfdio.c
bfd/libbfd.c
bfd/libbfd.h