Correct elftoolchain strip(1) memory size calculation

Calculate the segment's memory size (p_memsz) using the virtual
addresses, not the file offsets. Otherwise padding preceeding SHT_NOBITS
sections may be excluded from the calculation, resulting in a segment
that is too small.

PR:		195653
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Ed Maste 2014-12-15 18:18:57 +00:00
parent 5ad25ceb41
commit 30568ad37e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=275810

View File

@ -439,7 +439,7 @@ copy_phdr(struct elfcopy *ecp)
seg->fsz = seg->msz = 0;
for (i = 0; i < seg->nsec; i++) {
s = seg->v_sec[i];
seg->msz = s->off + s->sz - seg->off;
seg->msz = s->vma + s->sz - seg->addr;
if (s->type != SHT_NOBITS)
seg->fsz = seg->msz;
}