Fix handling of gaps between sections when writing files in libelf.
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index ec6514b..d6f3415 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-21 Ulrich Drepper <drepper@redhat.com>
+
+ * elf32_updatefile.c (__elfXX_updatemmap): Fix handling of gaps between
+ sections. Patch by Lubomir Rintel <lkundrak@v3.sk>.
+
2009-07-08 Roland McGrath <roland@redhat.com>
* libelfP.h (struct Elf): Remove unused ar.has_index field.
diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c
index a4d83a1..0539f03 100644
--- a/libelf/elf32_updatefile.c
+++ b/libelf/elf32_updatefile.c
@@ -336,10 +336,13 @@
/* If there is a gap, fill it. */
if (scn_start + dl->data.d.d_off > last_position
- && ((previous_scn_changed && dl->data.d.d_off == 0)
+ && (dl->data.d.d_off == 0
|| ((scn->flags | dl->flags | elf->flags)
& ELF_F_DIRTY) != 0))
- fill_mmap (dl->data.d.d_off);
+ {
+ fill_mmap (dl->data.d.d_off);
+ last_position = scn_start + dl->data.d.d_off;
+ }
if ((scn->flags | dl->flags | elf->flags) & ELF_F_DIRTY)
{