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:
emaste 2014-12-15 18:18:57 +00:00
parent 93ef12f586
commit 50872743f9

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