summaryrefslogtreecommitdiff
path: root/elfutils
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2002-11-12 20:09:04 +0000
committerjbj <devnull@localhost>2002-11-12 20:09:04 +0000
commit937ba6c27ce37057fed550927e1f5c523475d33f (patch)
tree1f1fc167806af6d39ec9ec6238ce01181b51fcf8 /elfutils
parent4b68a64e6b866f54fd5f396605dc9a5ca63979bb (diff)
downloadlibrpm-tizen-937ba6c27ce37057fed550927e1f5c523475d33f.tar.gz
librpm-tizen-937ba6c27ce37057fed550927e1f5c523475d33f.tar.bz2
librpm-tizen-937ba6c27ce37057fed550927e1f5c523475d33f.zip
Elfutils fiddles fo fix striptofile.
CVS patchset: 5847 CVS date: 2002/11/12 20:09:04
Diffstat (limited to 'elfutils')
-rw-r--r--elfutils/libelf/elf32_newphdr.c3
-rw-r--r--elfutils/libelf/elf32_updatefile.c15
-rw-r--r--elfutils/libelf/elf_newscn.c1
3 files changed, 11 insertions, 8 deletions
diff --git a/elfutils/libelf/elf32_newphdr.c b/elfutils/libelf/elf32_newphdr.c
index 05aa7a17a..1f48009fe 100644
--- a/elfutils/libelf/elf32_newphdr.c
+++ b/elfutils/libelf/elf32_newphdr.c
@@ -86,7 +86,8 @@ elfw2(LIBELFBITS,newphdr) (Elf *elf, size_t count)
result = NULL;
}
- else if (elf->state.ELFW(elf,LIBELFBITS).ehdr->e_phnum != count)
+ else if (elf->state.ELFW(elf,LIBELFBITS).ehdr->e_phnum != count ||
+ elf->state.ELFW(elf,LIBELFBITS).phdr == NULL)
{
/* Allocate a new program header with the appropriate number of
elements. */
diff --git a/elfutils/libelf/elf32_updatefile.c b/elfutils/libelf/elf32_updatefile.c
index 36b3f0d13..f84ec75a2 100644
--- a/elfutils/libelf/elf32_updatefile.c
+++ b/elfutils/libelf/elf32_updatefile.c
@@ -257,19 +257,19 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum)
on the stack. */
#define MAX_TMPBUF 32768
-
/* Helper function to write out fill bytes. */
static int
fill (int fd, off_t pos, size_t len, char *fillbuf, size_t *filledp)
/*@modifies fillbuf, filledp @*/
{
size_t filled = *filledp;
+ size_t fill_len = MIN (len, FILLBUFSIZE);
- if (unlikely (len > filled) && filled < FILLBUFSIZE)
+ if (unlikely (fill_len > filled) && (filled < FILLBUFSIZE))
{
/* Initialize a few more bytes. */
- memset (fillbuf + filled, __libelf_fill_byte, len - filled);
- *filledp = filled = len;
+ memset (fillbuf + filled, __libelf_fill_byte, fill_len - filled);
+ *filledp = filled = fill_len;
}
do
@@ -353,7 +353,8 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
== elf_typesize (LIBELFBITS, ELF_T_PHDR, 1));
/* Write out the program header table. */
- if ((elf->state.ELFW(elf,LIBELFBITS).phdr_flags | elf->flags) & ELF_F_DIRTY)
+ if (elf->state.ELFW(elf,LIBELFBITS).phdr != NULL
+ && (elf->state.ELFW(elf,LIBELFBITS).phdr_flags | elf->flags) & ELF_F_DIRTY)
{
ElfW2(LIBELFBITS,Phdr) tmp_phdr;
ElfW2(LIBELFBITS,Phdr) *out_phdr = elf->state.ELFW(elf,LIBELFBITS).phdr;
@@ -539,8 +540,8 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
}
while ((list = list->next) != NULL);
-
- assert (shdr_data == &shdr_data_begin[shnum]);
+ if (change_bo || elf->state.ELFW(elf,LIBELFBITS).shdr == NULL)
+ assert (shdr_data == &shdr_data_begin[shnum]);
/* Write out the section header table. */
if (shdr_flags & ELF_F_DIRTY
diff --git a/elfutils/libelf/elf_newscn.c b/elfutils/libelf/elf_newscn.c
index 8f84988c3..1d8d2e132 100644
--- a/elfutils/libelf/elf_newscn.c
+++ b/elfutils/libelf/elf_newscn.c
@@ -121,6 +121,7 @@ elf_newscn (Elf *elf)
result->elf = elf;
result->shdr_flags = ELF_F_DIRTY | ELF_F_MALLOCED;
+ result->list = elf->state.elf.scns_last;
/* Initialize the data part. */
result->data_read = 1;