Introduced Packer::patchDecompressorGetExtraStacksize().

This commit is contained in:
Markus F.X.J. Oberhumer
2006-06-22 15:35:38 +02:00
parent 8020c52c48
commit bcd738ebbb
3 changed files with 21 additions and 6 deletions
+15 -2
View File
@@ -208,6 +208,20 @@ const char *Packer::getDecompressorSections() const
}
unsigned Packer::patchDecompressorGetExtraStacksize()
{
unsigned stack = 0;
if (ph.method == M_LZMA)
{
const lzma_compress_result_t *res = &ph.compress_result.result_lzma;
// FIXME - this is for i386 only
stack = 8 + 4 + ALIGN_UP(2 * res->num_probs, 4);
stack = ALIGN_UP(stack, 16);
}
return stack;
}
void Packer::patchDecompressor(void *loader, int lsize)
{
if (ph.method == M_LZMA)
@@ -221,8 +235,7 @@ void Packer::patchDecompressor(void *loader, int lsize)
patch_le32(loader, lsize, "UPXd", properties);
patch_le32(loader, lsize, "UPXc", ph.c_len - 1);
patch_le32(loader, lsize, "UPXb", ph.u_len);
unsigned stack = 8 + 4 + ALIGN_UP(2 * res->num_probs, 4);
stack = ALIGN_UP(stack, 16);
unsigned stack = patchDecompressorGetExtraStacksize();
patch_le32(loader, lsize, "UPXa", 0u - stack);
}
}