summaryrefslogtreecommitdiff
path: root/libelf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-01-21 15:22:11 -0800
committerUlrich Drepper <drepper@redhat.com>2009-01-21 15:22:11 -0800
commit07ba31fc8249d8d0ff77b11e8ffc2df7fa775123 (patch)
treea9640d2d6d727ada75df59aeaac2384457f7a04c /libelf
parentf93ee8d7dcd0d58f7aab96773af084aca82d5798 (diff)
downloadelfutils-07ba31fc8249d8d0ff77b11e8ffc2df7fa775123.tar.gz
Fix accounting of last written position when updating ELF files.
Diffstat (limited to 'libelf')
-rw-r--r--libelf/ChangeLog7
-rw-r--r--libelf/elf32_updatefile.c20
2 files changed, 24 insertions, 3 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 36efd90e..38d352de 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,10 @@
+2009-01-21 Ulrich Drepper <drepper@redhat.com>
+
+ * 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 <drepper@redhat.com>
* libelfP.h (_): We only have one translation domain, elfutils.
diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c
index e88f4a45..111e1d2b 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. */