diff options
author | Roland McGrath <roland@redhat.com> | 2007-08-13 22:58:36 +0000 |
---|---|---|
committer | Roland McGrath <roland@redhat.com> | 2007-08-13 22:58:36 +0000 |
commit | 099dd52727f2ce1a2c73cde82af8cd5e06368aec (patch) | |
tree | 65df96e401bdf9cc978a9ff655dd9819b9ac1f8b /libelf/elf32_updatefile.c | |
parent | d82217264c4ac9108dbda1502a545ea25f6d22fe (diff) | |
download | elfutils-099dd52727f2ce1a2c73cde82af8cd5e06368aec.tar.gz |
missed testdata files
Diffstat (limited to 'libelf/elf32_updatefile.c')
-rw-r--r-- | libelf/elf32_updatefile.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c index 68253651..e94de831 100644 --- a/libelf/elf32_updatefile.c +++ b/libelf/elf32_updatefile.c @@ -1,5 +1,5 @@ /* Write changed data structures. - Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006 Red Hat, Inc. + Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 2007 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper <drepper@redhat.com>, 2000. @@ -85,6 +85,14 @@ compare_sections (const void *a, const void *b) > (*scnb)->shdr.ELFW(e,LIBELFBITS)->sh_offset) return 1; + if ((*scna)->shdr.ELFW(e,LIBELFBITS)->sh_size + < (*scnb)->shdr.ELFW(e,LIBELFBITS)->sh_size) + return -1; + + if ((*scna)->shdr.ELFW(e,LIBELFBITS)->sh_size + > (*scnb)->shdr.ELFW(e,LIBELFBITS)->sh_size) + return 1; + if ((*scna)->index < (*scnb)->index) return -1; @@ -97,7 +105,10 @@ compare_sections (const void *a, const void *b) /* Insert the sections in the list into the provided array and sort them according to their start offsets. For sections with equal - start offsets the section index is used. */ + start offsets, the size is used; for sections with equal start + offsets and sizes, the section index is used. Sorting by size + ensures that zero-length sections are processed first, which + is what we want since they do not advance our file writing position. */ static void sort_sections (Elf_Scn **scns, Elf_ScnList *list) { @@ -684,7 +695,7 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum) sizeof (ElfW2(LIBELFBITS,Shdr))); shdr_flags |= scn->shdr_flags; - scn->shdr_flags &= ~ELF_F_DIRTY; + scn->shdr_flags &= ~ELF_F_DIRTY; } /* Fill the gap between last section and section header table if |