From b23372cd8ee7abcc1b32caf4cf72d5bd12f7102f Mon Sep 17 00:00:00 2001 From: Joseph Koshy Date: Wed, 19 Mar 2008 06:06:34 +0000 Subject: [PATCH] Ensure that the section header table is written out in an order consistent with the section indices returned to the application by elf_ndxscn(). Submitted by: kaiw --- lib/libelf/elf_update.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/libelf/elf_update.c b/lib/libelf/elf_update.c index 64a38ea1ac4..988609b29fa 100644 --- a/lib/libelf/elf_update.c +++ b/lib/libelf/elf_update.c @@ -788,15 +788,14 @@ _libelf_write_elf(Elf *e, off_t newsize) src.d_buf = &scn->s_shdr.s_shdr64; dst.d_size = fsz; - dst.d_buf = newfile + rc; + dst.d_buf = newfile + rc + scn->s_ndx * fsz; if (_libelf_xlate(&dst, &src, e->e_byteorder, ec, ELF_TOFILE) != &dst) goto error; - - rc += fsz; } + rc += e->e_u.e_elf.e_nscn * fsz; if (maxrc > rc) rc = maxrc; }