diff --git a/src/p_djgpp2.cpp b/src/p_djgpp2.cpp index 41f19f45..7bec0ad8 100644 --- a/src/p_djgpp2.cpp +++ b/src/p_djgpp2.cpp @@ -300,8 +300,7 @@ void PackDjgpp2::pack(OutputFile *fo) text->size = lsize; // new size of .text data->size = ph.c_len; // new size of .data - unsigned stack = 1024 + ph.overlap_overhead + - patchDecompressorGetExtraStacksize(); + unsigned stack = 1024 + ph.overlap_overhead + getDecompressorWrkmemSize(); stack = ALIGN_UP(stack, 16); if (bss->size < stack) // give it a .bss bss->size = stack; diff --git a/src/packer.h b/src/packer.h index 83d6817e..0be2250a 100644 --- a/src/packer.h +++ b/src/packer.h @@ -224,8 +224,8 @@ protected: const int *getDefaultCompressionMethods_8(int method, int level, int small=-1) const; const int *getDefaultCompressionMethods_le32(int method, int level, int small=-1) const; virtual const char *getDecompressorSections() const; + virtual unsigned getDecompressorWrkmemSize() const; virtual void patchDecompressor(void *, int); - virtual unsigned patchDecompressorGetExtraStacksize(); // filter handling [see packer_f.cpp] virtual bool isValidFilter(int filter_id) const; diff --git a/src/packer_c.cpp b/src/packer_c.cpp index 0fc8397e..c2b05e01 100644 --- a/src/packer_c.cpp +++ b/src/packer_c.cpp @@ -208,17 +208,18 @@ const char *Packer::getDecompressorSections() const } -unsigned Packer::patchDecompressorGetExtraStacksize() +unsigned Packer::getDecompressorWrkmemSize() const { - unsigned stack = 0; + unsigned size = 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); + size = 8 + 4 + ALIGN_UP(2 * res->num_probs, 4); + size = ALIGN_UP(size, 16); } - return stack; + assert((int)size >= 0); + return size; } @@ -235,7 +236,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 = patchDecompressorGetExtraStacksize(); + unsigned stack = getDecompressorWrkmemSize(); patch_le32(loader, lsize, "UPXa", 0u - stack); } }