summaryrefslogtreecommitdiffstats
path: root/lib/libelf
diff options
context:
space:
mode:
authorjkoshy <jkoshy@FreeBSD.org>2008-03-19 06:06:34 +0000
committerjkoshy <jkoshy@FreeBSD.org>2008-03-19 06:06:34 +0000
commitf8600f40e7fcf241985d8a978c63889de0969bfb (patch)
tree6027b6421652fe36e79cf73a76e3ca05cc22b9a8 /lib/libelf
parentaf7049a2cd634329f9ecfa4396debd4b31d6da5c (diff)
downloadFreeBSD-src-f8600f40e7fcf241985d8a978c63889de0969bfb.zip
FreeBSD-src-f8600f40e7fcf241985d8a978c63889de0969bfb.tar.gz
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
Diffstat (limited to 'lib/libelf')
-rw-r--r--lib/libelf/elf_update.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libelf/elf_update.c b/lib/libelf/elf_update.c
index 64a38ea..988609b 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;
}
OpenPOWER on IntegriCloud