Minor cleanups.

committer: mfx <mfx> 968538234 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2000-09-09 22:23:54 +00:00
parent 8c7835fd33
commit 8f3e1e7688
5 changed files with 25 additions and 15 deletions

View File

@ -43,7 +43,7 @@ MemBuffer::MemBuffer(unsigned size=0) :
MemBuffer::~MemBuffer()
{
free();
this->free();
}
@ -68,8 +68,11 @@ unsigned MemBuffer::getSize() const
void MemBuffer::alloc(unsigned size, unsigned base_offset)
{
#if 0
// don't automaticlly free a used buffer
this->free();
#endif
assert(alloc_ptr == NULL);
//free();
assert((int)size > 0);
size = base_offset + size;
alloc_ptr = (unsigned char *) malloc(size);
@ -94,7 +97,7 @@ void MemBuffer::allocForCompression(unsigned uncompressed_size)
// Idea:
// We allocate the buffer at an offset of 4096 so
// 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.
//
// See Packer::verifyOverlappingDecompression().
@ -105,7 +108,8 @@ void MemBuffer::allocForCompression(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
}

View File

@ -111,7 +111,7 @@ void PackDjgpp2::handleStub(OutputFile *fo)
}
static bool is_dlm(InputFile *fi,long coff_offset)
static bool is_dlm(InputFile *fi, long coff_offset)
{
unsigned char buf[4];
long off;
@ -132,7 +132,7 @@ static bool is_dlm(InputFile *fi,long coff_offset)
}
static void handle_allegropak(InputFile *fi,OutputFile *fo)
static void handle_allegropak(InputFile *fi, OutputFile *fo)
{
unsigned char buf[0x4000];
unsigned pfsize=0, ic;
@ -285,6 +285,7 @@ void PackDjgpp2::pack(OutputFile *fo)
ft.verifyUnfilter();
#else
// new version using compressWithFilters()
// prepare packheader
ph.u_len = usize;
ph.filter = 0;

View File

@ -34,7 +34,7 @@
static const
#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 MAXRELOCS (0x8000-MAXMATCH)
@ -120,7 +120,7 @@ bool PackExe::canPack()
static
unsigned optimize_relocs(upx_byte *b, const unsigned size,
const upx_byte *relocs, const unsigned nrelocs,
upx_byte *crel,bool *has_9a)
upx_byte *crel, bool *has_9a)
{
upx_byte *crel_save = crel;
unsigned i;
@ -270,7 +270,7 @@ void PackExe::pack(OutputFile *fo)
fi->seek(ih.headsize16*16,SEEK_SET);
fi->readx(ibuf,imagesize);
if (find_le32(ibuf,imagesize < 127 ? imagesize : 127,UPX_MAGIC_LE32))
if (find_le32(ibuf,imagesize < 127 ? imagesize : 127, UPX_MAGIC_LE32))
throwAlreadyPacked();
// relocations
@ -308,7 +308,7 @@ void PackExe::pack(OutputFile *fo)
relocsize = 0;
}
ph.u_len = imagesize+relocsize;
ph.u_len = imagesize + relocsize;
if (!compress(ibuf,obuf,0,MAXMATCH))
throwNotCompressible();
const unsigned overlapoh = findOverlapOverhead(obuf,32);
@ -452,11 +452,13 @@ void PackExe::pack(OutputFile *fo)
}
putPackHeader(loader,lsize);
upx_bytep p = find_le32(loader,lsize,get_le32("IPCS"));
if (p == NULL && (flag & USEJUMP))
throwBadLoader();
if (flag & USEJUMP)
{
upx_bytep p = find_le32(loader,lsize,get_le32("IPCS"));
if (p == NULL)
throwBadLoader();
memcpy(p,&ih.ip,4);
}
else
{
patch_le16(loader,lsize,"IP",ih.ip);
@ -495,6 +497,7 @@ void PackExe::pack(OutputFile *fo)
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);
// write header + write loader + compressed file
#ifdef TESTING
if (opt->debug)

View File

@ -33,9 +33,11 @@
#ifdef WANT_STL
#if defined(__DJGPP__) || defined(__MINGW32__) || defined(__sparc__)
// provide missing oom_handler
void (*__malloc_alloc_template<0>::__malloc_alloc_oom_handler)() = 0;
# if !defined(__USE_MALLOC)
template class __default_alloc_template<false, 0>;
// instantiate default allocator
template class __default_alloc_template<false, 0>;
# endif
#endif

View File

@ -71,7 +71,7 @@ typedef unsigned upx_uint32;
#define UPX_F_DJGPP2_COFF 4
#define UPX_F_WC_LE 5
#define UPX_F_VXD_LE 6
#define UPX_F_DOS_EXEH 7 /* OBSOLETE */
#define UPX_F_DOS_EXEH 7 /* OBSOLETE */
#define UPX_F_TMT_ADAM 8
#define UPX_F_W32_PE 9
#define UPX_F_LINUX_i386 10