Minor cleanups.
committer: mfx <mfx> 968538234 +0000
This commit is contained in:
+8
-4
@@ -43,7 +43,7 @@ MemBuffer::MemBuffer(unsigned size=0) :
|
|||||||
|
|
||||||
MemBuffer::~MemBuffer()
|
MemBuffer::~MemBuffer()
|
||||||
{
|
{
|
||||||
free();
|
this->free();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -68,8 +68,11 @@ unsigned MemBuffer::getSize() const
|
|||||||
|
|
||||||
void MemBuffer::alloc(unsigned size, unsigned base_offset)
|
void MemBuffer::alloc(unsigned size, unsigned base_offset)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
// don't automaticlly free a used buffer
|
||||||
|
this->free();
|
||||||
|
#endif
|
||||||
assert(alloc_ptr == NULL);
|
assert(alloc_ptr == NULL);
|
||||||
//free();
|
|
||||||
assert((int)size > 0);
|
assert((int)size > 0);
|
||||||
size = base_offset + size;
|
size = base_offset + size;
|
||||||
alloc_ptr = (unsigned char *) malloc(size);
|
alloc_ptr = (unsigned char *) malloc(size);
|
||||||
@@ -94,7 +97,7 @@ void MemBuffer::allocForCompression(unsigned uncompressed_size)
|
|||||||
// Idea:
|
// Idea:
|
||||||
// We allocate the buffer at an offset of 4096 so
|
// We allocate the buffer at an offset of 4096 so
|
||||||
// that we could do an in-place decompression for
|
// that we could do an in-place decompression for
|
||||||
// verifying our overlap overhead at the end
|
// verifying our overlap_overhead at the end
|
||||||
// of packing.
|
// of packing.
|
||||||
//
|
//
|
||||||
// See Packer::verifyOverlappingDecompression().
|
// See Packer::verifyOverlappingDecompression().
|
||||||
@@ -105,7 +108,8 @@ void MemBuffer::allocForCompression(unsigned uncompressed_size)
|
|||||||
|
|
||||||
void MemBuffer::allocForUncompression(unsigned uncompressed_size)
|
void MemBuffer::allocForUncompression(unsigned uncompressed_size)
|
||||||
{
|
{
|
||||||
alloc(uncompressed_size + 512, 0); // 512 safety bytes
|
//alloc(uncompressed_size + 512, 0); // 512 safety bytes
|
||||||
|
alloc(uncompressed_size + 3, 0); // 3 safety bytes for asm_fast
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -285,6 +285,7 @@ void PackDjgpp2::pack(OutputFile *fo)
|
|||||||
ft.verifyUnfilter();
|
ft.verifyUnfilter();
|
||||||
#else
|
#else
|
||||||
// new version using compressWithFilters()
|
// new version using compressWithFilters()
|
||||||
|
|
||||||
// prepare packheader
|
// prepare packheader
|
||||||
ph.u_len = usize;
|
ph.u_len = usize;
|
||||||
ph.filter = 0;
|
ph.filter = 0;
|
||||||
|
|||||||
+7
-4
@@ -34,7 +34,7 @@
|
|||||||
static const
|
static const
|
||||||
#include "stub/l_exe.h"
|
#include "stub/l_exe.h"
|
||||||
|
|
||||||
#define RSFCRI 4096 // reserved space for compressed relocation info
|
#define RSFCRI 4096 // Reserved Space For Compressed Relocation Info
|
||||||
#define MAXMATCH 0x2000
|
#define MAXMATCH 0x2000
|
||||||
#define MAXRELOCS (0x8000-MAXMATCH)
|
#define MAXRELOCS (0x8000-MAXMATCH)
|
||||||
|
|
||||||
@@ -452,11 +452,13 @@ void PackExe::pack(OutputFile *fo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
putPackHeader(loader,lsize);
|
putPackHeader(loader,lsize);
|
||||||
upx_bytep p = find_le32(loader,lsize,get_le32("IPCS"));
|
|
||||||
if (p == NULL && (flag & USEJUMP))
|
|
||||||
throwBadLoader();
|
|
||||||
if (flag & USEJUMP)
|
if (flag & USEJUMP)
|
||||||
|
{
|
||||||
|
upx_bytep p = find_le32(loader,lsize,get_le32("IPCS"));
|
||||||
|
if (p == NULL)
|
||||||
|
throwBadLoader();
|
||||||
memcpy(p,&ih.ip,4);
|
memcpy(p,&ih.ip,4);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
patch_le16(loader,lsize,"IP",ih.ip);
|
patch_le16(loader,lsize,"IP",ih.ip);
|
||||||
@@ -495,6 +497,7 @@ void PackExe::pack(OutputFile *fo)
|
|||||||
oh.p512 = (outputlen + 511) >> 9;
|
oh.p512 = (outputlen + 511) >> 9;
|
||||||
|
|
||||||
//fprintf(stderr,"\ne_len=%x d_len=%x clen=%x oo=%x ulen=%x destp=%x copys=%x images=%x",e_len,d_len,packedsize,overlapoh,ph.u_len,destpara,copysize,imagesize);
|
//fprintf(stderr,"\ne_len=%x d_len=%x clen=%x oo=%x ulen=%x destp=%x copys=%x images=%x",e_len,d_len,packedsize,overlapoh,ph.u_len,destpara,copysize,imagesize);
|
||||||
|
|
||||||
// write header + write loader + compressed file
|
// write header + write loader + compressed file
|
||||||
#ifdef TESTING
|
#ifdef TESTING
|
||||||
if (opt->debug)
|
if (opt->debug)
|
||||||
|
|||||||
@@ -33,8 +33,10 @@
|
|||||||
#ifdef WANT_STL
|
#ifdef WANT_STL
|
||||||
|
|
||||||
#if defined(__DJGPP__) || defined(__MINGW32__) || defined(__sparc__)
|
#if defined(__DJGPP__) || defined(__MINGW32__) || defined(__sparc__)
|
||||||
|
// provide missing oom_handler
|
||||||
void (*__malloc_alloc_template<0>::__malloc_alloc_oom_handler)() = 0;
|
void (*__malloc_alloc_template<0>::__malloc_alloc_oom_handler)() = 0;
|
||||||
# if !defined(__USE_MALLOC)
|
# if !defined(__USE_MALLOC)
|
||||||
|
// instantiate default allocator
|
||||||
template class __default_alloc_template<false, 0>;
|
template class __default_alloc_template<false, 0>;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user