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
This commit is contained in:
Joseph Koshy 2008-03-19 06:06:34 +00:00
parent df7d1e2023
commit b23372cd8e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=177367

View File

@ -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;
}