From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [COMMITTED] libelf: Check for mremap, elf_update needs it for ELF_C_RDWR_MMAP
Date: Sun, 24 Apr 2022 19:49:03 +0200 [thread overview]
Message-ID: <20220424174903.340864-1-mark@klomp.org> (raw)
Add a AC_CHECK_FUNCS configure check for mremap. Some systems like
KFreeBSD and the Hurd don't have it. Also add a configure warning
because without mremap elf_update will often fail when ELF_C_RDWR_MMAP
is used. ELF_C_RDWR_MMAP is an elfutils extension to libelf.
https://sourceware.org/bugzilla/show_bug.cgi?id=27337
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
ChangeLog | 4 ++++
configure.ac | 5 ++++-
libelf/ChangeLog | 4 ++++
libelf/elf_update.c | 2 ++
4 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 3357f69b..f0cd28a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2022-04-24 Mark Wielaard <mark@klomp.org>
+
+ * configure.ac (AC_CHECK_FUNCS): Add mremap.
+
2021-03-20 Mark Wielaard <mark@klomp.org>
* configure.ac: Remove -m64 on 32bit target comments for
diff --git a/configure.ac b/configure.ac
index 2418d474..33c4b5e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -435,7 +435,10 @@ AC_CHECK_DECLS([reallocarray],[],[],
[#define _GNU_SOURCE
#include <stdlib.h>])
-AC_CHECK_FUNCS([process_vm_readv])
+AC_CHECK_FUNCS([process_vm_readv mremap])
+
+AS_IF([test "x$ac_cv_func_mremap" = "xno"],
+ [AC_MSG_WARN([elf_update needs mremap to support ELF_C_RDWR_MMAP])])
AC_CHECK_HEADERS([error.h])
AC_CHECK_HEADERS([err.h])
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 985f795d..00d4ac0f 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2022-04-24 Mark Wielaard <mark@klomp.org>
+
+ * elf_update.c (write_file): Check HAVE_MREMAP.
+
2022-04-01 Mark Wielaard <mark@klomp.org>
* libelfP.h (struct Elf_Data_Chunk): Add an int64_t offset field.
diff --git a/libelf/elf_update.c b/libelf/elf_update.c
index 9b8867ce..97ca9ca9 100644
--- a/libelf/elf_update.c
+++ b/libelf/elf_update.c
@@ -106,8 +106,10 @@ write_file (Elf *elf, int64_t size, int change_bo, size_t shnum)
if (elf->cmd == ELF_C_RDWR_MMAP
&& (size_t) size > elf->maximum_size)
{
+#ifdef HAVE_MREMAP
if (mremap (elf->map_address, elf->maximum_size,
size, 0) == MAP_FAILED)
+#endif
{
__libelf_seterrno (ELF_E_WRITE_ERROR);
return -1;
--
2.30.2
reply other threads:[~2022-04-24 17:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220424174903.340864-1-mark@klomp.org \
--to=mark@klomp.org \
--cc=elfutils-devel@sourceware.org \
/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).