summaryrefslogtreecommitdiffstats
path: root/libelf/elf32_updatenull.c
diff options
context:
space:
mode:
authorUlrich Drepper <[email protected]>2006-04-04 21:07:28 +0000
committerUlrich Drepper <[email protected]>2006-04-04 21:07:28 +0000
commit697d8d283e5fda32c1930135ff884dd276499e4a (patch)
tree35ec910f7033a71c524053dae6528aa0b4271d68 /libelf/elf32_updatenull.c
parentdd7e22b4a0e47dfab08a14e7fa9bd1fa8b1a968c (diff)
Fix read/write of existing file using mmap and different layout of the ELF
file.
Diffstat (limited to 'libelf/elf32_updatenull.c')
-rw-r--r--libelf/elf32_updatenull.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
index ed7242b2..9c61cd77 100644
--- a/libelf/elf32_updatenull.c
+++ b/libelf/elf32_updatenull.c
@@ -1,5 +1,5 @@
/* Update data structures for changes.
- Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
+ Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
Written by Ulrich Drepper <[email protected]>, 2000.
This program is free software; you can redistribute it and/or modify
@@ -319,8 +319,18 @@ __elfw2(LIBELFBITS,updatenull) (Elf *elf, int *change_bop, size_t shnum)
scn->shdr_flags);
size = (size + sh_align - 1) & ~(sh_align - 1);
+ int offset_changed = 0;
update_if_changed (shdr->sh_offset, (GElf_Word) size,
- changed);
+ offset_changed);
+ changed |= offset_changed;
+
+ if (offset_changed && scn->data_list_rear == NULL)
+ {
+ /* The position of the section in the file
+ changed. Create the section data list. */
+ if (INTUSE(elf_getdata) (scn, NULL) == NULL)
+ return -1;
+ }
/* See whether the section size is correct. */
update_if_changed (shdr->sh_size, (GElf_Word) offset,