summaryrefslogtreecommitdiffstats
path: root/libelf/elf32_updatefile.c
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2013-11-05 16:27:32 +0100
committerMark Wielaard <mjw@redhat.com>2013-11-05 22:17:51 +0100
commit88ad5ddb71bd1fa8ed043a840157ebf23c0057b3 (patch)
tree8f586c9dafd72c118f29f287fc2b0cf4ff8ac232 /libelf/elf32_updatefile.c
parentcdc094394319969ba407e11efa06fefb31f5026b (diff)
downloadandroid_external_elfutils-88ad5ddb71bd1fa8ed043a840157ebf23c0057b3.tar.gz
android_external_elfutils-88ad5ddb71bd1fa8ed043a840157ebf23c0057b3.tar.bz2
android_external_elfutils-88ad5ddb71bd1fa8ed043a840157ebf23c0057b3.zip
libelf: Write all section headers if elf flags contains ELF_F_DIRTY.
When ehdr e_shoff changes, elf flags is set dirty. This indicates that the section header moved because sections were added/removed or changed in size. Reported-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'libelf/elf32_updatefile.c')
-rw-r--r--libelf/elf32_updatefile.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c
index 296b1ac9..c4af9c02 100644
--- a/libelf/elf32_updatefile.c
+++ b/libelf/elf32_updatefile.c
@@ -633,7 +633,8 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
#endif
ElfW2(LIBELFBITS,Shdr) *shdr_data;
- if (change_bo || elf->state.ELFW(elf,LIBELFBITS).shdr == NULL)
+ if (change_bo || elf->state.ELFW(elf,LIBELFBITS).shdr == NULL
+ || (elf->flags & ELF_F_DIRTY))
shdr_data = (ElfW2(LIBELFBITS,Shdr) *)
alloca (shnum * sizeof (ElfW2(LIBELFBITS,Shdr)));
else
@@ -764,7 +765,8 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
(*shdr_fctp) (&shdr_data[scn->index],
scn->shdr.ELFW(e,LIBELFBITS),
sizeof (ElfW2(LIBELFBITS,Shdr)), 1);
- else if (elf->state.ELFW(elf,LIBELFBITS).shdr == NULL)
+ else if (elf->state.ELFW(elf,LIBELFBITS).shdr == NULL
+ || (elf->flags & ELF_F_DIRTY))
memcpy (&shdr_data[scn->index], scn->shdr.ELFW(e,LIBELFBITS),
sizeof (ElfW2(LIBELFBITS,Shdr)));