diff --git a/src/p_lx_exc.cpp b/src/p_lx_exc.cpp index 51359761..63478df8 100644 --- a/src/p_lx_exc.cpp +++ b/src/p_lx_exc.cpp @@ -93,7 +93,7 @@ PackLinuxI386::generateElfHdr( #if 0 //{ unsigned identsize; - char const *const ident = identstr(identsize); + char const *const ident = getIdentstr(&identsize); #endif //} h2->phdr[0].p_filesz = sizeof(*h2); // + identsize; h2->phdr[0].p_memsz = h2->phdr[0].p_filesz; diff --git a/src/p_w32pe.cpp b/src/p_w32pe.cpp index baebcc6b..d6c5d2b8 100644 --- a/src/p_w32pe.cpp +++ b/src/p_w32pe.cpp @@ -1483,7 +1483,7 @@ bool PackW32Pe::canPack() int PackW32Pe::buildLoader(const Filter *ft) { // prepare loader - initLoader(nrv_loader,sizeof(nrv_loader)); + initLoader(nrv_loader, sizeof(nrv_loader), -1, 2); addLoader(isdll ? "PEISDLL1" : "", "PEMAIN01", icondir_count > 1 ? (icondir_count == 2 ? "PEICONS1" : "PEICONS2") : "", diff --git a/src/packer.cpp b/src/packer.cpp index 440df68d..f590db48 100644 --- a/src/packer.cpp +++ b/src/packer.cpp @@ -965,7 +965,7 @@ const int *Packer::getDefaultCompressionMethods_LE32(int method, int level, int // loader util **************************************************************************/ -char const *Packer::identstr(unsigned &size) +char const *Packer::getIdentstr(unsigned *size, int small) { static const char identbig[] = "\n\0" @@ -981,20 +981,28 @@ char const *Packer::identstr(unsigned &size) "$Id: UPX " "(C) 1996-2002 the UPX Team. All Rights Reserved. http://upx.sf.net $" "\n"; -// static const char identtiny[] = UPX_VERSION_STRING4; -// FIXME + static const char identtiny[] = UPX_VERSION_STRING4; - if (opt->small) { - size = sizeof(identsmall); + if (small < 0) + small = opt->small; + if (small >= 2) + { + *size = sizeof(identtiny); + return identtiny; + } + else if (small >= 1) + { + *size = sizeof(identsmall); return identsmall; } - else { - size = sizeof(identbig); + else + { + *size = sizeof(identbig); return identbig; } } -void Packer::initLoader(const void *pdata, int plen, int pinfo) +void Packer::initLoader(const void *pdata, int plen, int pinfo, int small) { if (pinfo < 0) { @@ -1009,8 +1017,8 @@ void Packer::initLoader(const void *pdata, int plen, int pinfo) linker = new BeLinker(pdata, plen, pinfo); // big endian unsigned size; - char const *const ident = identstr(size); - linker->addSection("IDENTSTR",ident,size); + char const * const ident = getIdentstr(&size, small); + linker->addSection("IDENTSTR", ident, size); } diff --git a/src/packer.h b/src/packer.h index b255c7b1..3a58bd13 100644 --- a/src/packer.h +++ b/src/packer.h @@ -207,12 +207,12 @@ protected: virtual int buildLoader(const Filter *) { return getLoaderSize(); } virtual const upx_byte *getLoader() const; virtual int getLoaderSize() const; - virtual void initLoader(const void *pdata, int plen, int pinfo=-1); + virtual void initLoader(const void *pdata, int plen, int pinfo=-1, int small=-1); virtual void addLoader(const char *s, ...); virtual int getLoaderSection(const char *name, int *slen=NULL) const; virtual int getLoaderSectionStart(const char *name, int *slen=NULL) const; virtual const char *getDecompressor() const; - char const *identstr(unsigned &size); + virtual const char *getIdentstr(unsigned *size, int small=-1); // stub and overlay util static void handleStub(InputFile *fi, OutputFile *fo, long size);