]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
strip don't mmap debug output file.
authorMark Wielaard <mark@klomp.org>
Mon, 4 Mar 2019 19:04:18 +0000 (20:04 +0100)
committerMark Wielaard <mark@klomp.org>
Mon, 24 Jun 2019 21:53:02 +0000 (23:53 +0200)
Using ELF_C_WRITE_MMAP sometimes causes unexpected errors when disk
space is low. When writing out the file, the output file is first
extended so that it covers the whole file/mmap size. But it might
be that the file system allowed the extension as a sparse file. In
that case writing to the file through the mmap might still fail and
produce a SIGBUS if the disk is full. This is confusing to the user.

Using ELF_C_WRITE will produce "normal" errors when the file cannot
be written out. It also seems to use less memory because the debug
file is created from scratch. So the memory is first read into the
ELF data structure buffers, then written out as a whole. In this case
the mmap output buffer is just overhead.

Signed-off-by: Mark Wielaard <mark@klomp.org>
src/ChangeLog
src/strip.c

index 580eea9b2cc7257ea1621a376cf261dba779ec38..2cde63ce6ba361d7f99868a196f101bdf2e8d7c8 100644 (file)
@@ -1,3 +1,8 @@
+2019-06-18  Mark Wielaard  <mark@klomp.org>
+
+       * strip.c (handle_elf): Use elf_begin ELF_C_WRITE, instead of
+       ELF_C_WRITE_MMAP.
+
 2019-05-10  Mark Wielaard  <mark@klomp.org>
 
        * readelf.c (struct attrcb_args): Rename die to dies.
index 4cd87506e8213fe68b5c40a258113eabbd189344..48792a70c80c8b085202aa3bd56e7f20c6fc33ae 100644 (file)
@@ -1097,7 +1097,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
   if (debug_fname != NULL)
     {
       /* Also create an ELF descriptor for the debug file */
-      debugelf = elf_begin (debug_fd, ELF_C_WRITE_MMAP, NULL);
+      debugelf = elf_begin (debug_fd, ELF_C_WRITE, NULL);
       if (unlikely (gelf_newehdr (debugelf, gelf_getclass (elf)) == 0))
        {
          error (0, 0, gettext ("cannot create new ehdr for file '%s': %s"),