From: Ulrich Drepper Date: Wed, 21 Jan 2009 23:22:11 +0000 (-0800) Subject: Fix accounting of last written position when updating ELF files. X-Git-Tag: elfutils-0.139~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07ba31fc8249d8d0ff77b11e8ffc2df7fa775123;p=thirdparty%2Felfutils.git Fix accounting of last written position when updating ELF files. --- diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 36efd90e2..38d352de3 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,10 @@ +2009-01-21 Ulrich Drepper + + * elf32_updatefile.c (elfXX_updatemmap): When skipping non-NOBITS + sections we haven't loaded, update last_position based on scn_start, + not based on old value. Don't run the loop for the dummy section 0. + (elfXX_updatefile): Don't run the loop for the dummy section 0. + 2009-01-10 Ulrich Drepper * libelfP.h (_): We only have one translation domain, elfutils. diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c index e88f4a45e..111e1d2bb 100644 --- a/libelf/elf32_updatefile.c +++ b/libelf/elf32_updatefile.c @@ -283,6 +283,13 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum) for (size_t cnt = 0; cnt < shnum; ++cnt) { Elf_Scn *scn = scns[cnt]; + if (scn->index == 0) + { + /* The dummy section header entry. It should not be + possible to make this "section" as dirty. */ + assert ((scn->flags & ELF_F_DIRTY) == 0); + continue; + } ElfW2(LIBELFBITS,Shdr) *shdr = scn->shdr.ELFW(e,LIBELFBITS); @@ -362,9 +369,9 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum) dl = dl->next; } while (dl != NULL); - else if (shdr->sh_type != SHT_NOBITS && scn->index != 0) + else if (shdr->sh_type != SHT_NOBITS) /* We have to trust the existing section header information. */ - last_position += shdr->sh_size; + last_position = scn_start + shdr->sh_size; scn->flags &= ~ELF_F_DIRTY; } @@ -616,6 +623,13 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum) for (size_t cnt = 0; cnt < shnum; ++cnt) { Elf_Scn *scn = scns[cnt]; + if (scn->index == 0) + { + /* The dummy section header entry. It should not be + possible to make this "section" as dirty. */ + assert ((scn->flags & ELF_F_DIRTY) == 0); + continue; + } ElfW2(LIBELFBITS,Shdr) *shdr = scn->shdr.ELFW(e,LIBELFBITS); @@ -695,7 +709,7 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum) dl = dl->next; } while (dl != NULL); - else if (shdr->sh_type != SHT_NOBITS && scn->index != 0) + else if (shdr->sh_type != SHT_NOBITS) last_offset = scn_start + shdr->sh_size; /* Collect the section header table information. */