From fa1d4447b16f16ff9056a24163b175fcbc3a57cf Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 21 Jul 2009 21:04:47 -0700 Subject: [PATCH] Fix handling of gaps between sections when writing files in libelf. --- libelf/ChangeLog | 5 +++++ libelf/elf32_updatefile.c | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libelf/ChangeLog b/libelf/ChangeLog index ec6514b85..d6f341512 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,8 @@ +2009-07-21 Ulrich Drepper + + * elf32_updatefile.c (__elfXX_updatemmap): Fix handling of gaps between + sections. Patch by Lubomir Rintel . + 2009-07-08 Roland McGrath * libelfP.h (struct Elf): Remove unused ar.has_index field. diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c index a4d83a1c6..0539f03d0 100644 --- a/libelf/elf32_updatefile.c +++ b/libelf/elf32_updatefile.c @@ -336,10 +336,13 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum) /* 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) { -- 2.47.3