summaryrefslogtreecommitdiffstats
path: root/lib/libelf/elf_update.c
diff options
context:
space:
mode:
authorkaiw <kaiw@FreeBSD.org>2010-07-21 09:47:14 +0000
committerkaiw <kaiw@FreeBSD.org>2010-07-21 09:47:14 +0000
commit57795d0388546ee51a052ad6d144abc3288508f5 (patch)
tree89fecbe337348ce494507450a43cc6a12c9ff80c /lib/libelf/elf_update.c
parentf349ce0e9e0d9b00fd5fa016a5b7cd1ec528a01c (diff)
downloadFreeBSD-src-57795d0388546ee51a052ad6d144abc3288508f5.zip
FreeBSD-src-57795d0388546ee51a052ad6d144abc3288508f5.tar.gz
Allow an application that updates only the ELF Ehdr to work.
Obtained from: elftoolchain MFC after: 1 month
Diffstat (limited to 'lib/libelf/elf_update.c')
-rw-r--r--lib/libelf/elf_update.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/libelf/elf_update.c b/lib/libelf/elf_update.c
index a429036..2d7681f 100644
--- a/lib/libelf/elf_update.c
+++ b/lib/libelf/elf_update.c
@@ -472,6 +472,11 @@ _libelf_resync_elf(Elf *e)
* file.
*/
+ if (e->e_cmd != ELF_C_WRITE &&
+ (e->e_flags & LIBELF_F_SHDRS_LOADED) == 0 &&
+ _libelf_load_scn(e, ehdr) == 0)
+ return ((off_t) -1);
+
if ((rc = _libelf_resync_sections(e, rc)) < 0)
return ((off_t) -1);
@@ -726,14 +731,9 @@ _libelf_write_elf(Elf *e, off_t newsize)
assert(phoff % _libelf_falign(ELF_T_PHDR, ec) == 0);
assert(fsz > 0);
+ src.d_buf = _libelf_getphdr(e, ec);
src.d_version = dst.d_version = e->e_version;
src.d_type = ELF_T_PHDR;
-
- if (ec == ELFCLASS32)
- src.d_buf = e->e_u.e_elf.e_phdr.e_phdr32;
- else
- src.d_buf = e->e_u.e_elf.e_phdr.e_phdr64;
-
src.d_size = phnum * _libelf_msize(ELF_T_PHDR, ec,
e->e_version);
OpenPOWER on IntegriCloud