This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH] On elf_update, remember when we mmap()
- From: Ulf Hermann <ulf dot hermann at qt dot io>
- To: <elfutils-devel at sourceware dot org>
- Date: Thu, 20 Apr 2017 16:57:41 +0200
- Subject: [PATCH] On elf_update, remember when we mmap()
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=qt.io;
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qtcompany.onmicrosoft.com; s=selector1-qt-io; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=RCp+hWFyKyEZJY3ySmQdY+TOcQ5w+44wZkKvys7lkpU=; b=QpKr8ww9RtNNBYQUzGLIGk9TZQVOPA8GmDH6mFE9EIg1088xFeuzaJtgiRxJrEGga+slzjB6IXJaznQmKOgZHTimFx+B1zN7Zxisa1KTCKpyPECwCW9/eLRLCT9UOPY7UCymGQhAx2e5sCUY2IWwcpgY/gWqnMWuJwXaopPEXVg=
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Otherwise we skip the munmap() later. This leaks resources.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
libelf/ChangeLog | 4 ++++
libelf/elf_update.c | 2 ++
2 files changed, 6 insertions(+)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index fa768f8..225c7c8 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,5 +1,9 @@
2017-04-20 Ulf Hermann <ulf.hermann@qt.io>
+ * elf_update.c: Set ELF_F_MMAPPED flag if we mmap from elf_update.
+
+2017-04-20 Ulf Hermann <ulf.hermann@qt.io>
+
* libelfP.h: Don't include config.h.
2017-04-20 Ulf Hermann <ulf.hermann@qt.io>
diff --git a/libelf/elf_update.c b/libelf/elf_update.c
index c635eb3..8ce0782 100644
--- a/libelf/elf_update.c
+++ b/libelf/elf_update.c
@@ -74,6 +74,8 @@ write_file (Elf *elf, off_t size, int change_bo, size_t shnum)
MAP_SHARED, elf->fildes, 0);
if (unlikely (elf->map_address == MAP_FAILED))
elf->map_address = NULL;
+ else
+ elf->flags |= ELF_F_MMAPPED;
}
if (elf->map_address != NULL)
--
2.1.4