Prepared for 1.10 release.

committer: mfx <mfx> 977233750 +0000
This commit is contained in:
Markus F.X.J. Oberhumer
2000-12-19 13:49:10 +00:00
parent e5647cb0aa
commit fa772703d4
21 changed files with 110 additions and 53 deletions
+5 -5
View File
@@ -85,7 +85,7 @@ INCLUDES = -I$(srcdir)
CFLAGS_OUTPUT = -o $@
CXXFLAGS_OUTPUT = $(CFLAGS_OUTPUT)
LINK_EXE = $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
LINK_EXE = $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^ $(LDLIBS)
STUBEDIT_EXE =
o = .o
@@ -257,7 +257,7 @@ else
endif
##LINK_LDFLAGS += /verbose
LINK_EXE = $(CC) $(LDFLAGS) -Fe$@ $^ $(LDLIBS) $(LINK_LDFLAGS)
LINK_EXE = $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) -Fe$@ $^ $(LDLIBS) $(LINK_LDFLAGS)
endif # vc6
@@ -284,10 +284,10 @@ endif
ifeq (1,2) # purify
DEFS += -D__PURIFY__
LDFLAGS = -g -L/home/ethmola/local/lib
LINK_EXE = purify $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
LINK_EXE = purify $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^ $(LDLIBS)
else
LDFLAGS += -g -L/home/ethmola/local/lib
LINK_EXE = $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
LINK_EXE = $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^ $(LDLIBS)
endif
endif # sparc
@@ -320,7 +320,7 @@ else
CFLAGS += -O2 -d
endif
LINK_EXE = $(CC) $(LDFLAGS) -e$@ $^ $(LDLIBS)
LINK_EXE = $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) -e$@ $^ $(LDLIBS)
endif # bcc
+4 -3
View File
@@ -42,17 +42,18 @@ void init_options(struct options_t *o)
o->cmd = CMD_NONE;
o->method = -1;
o->level = 7;
o->level = -1;
o->mem_level = -1;
o->filter = -1;
o->backup = -1;
o->overlay = -1;
o->console = CON_FILE;
#if defined(__MFX_DOS) || defined(__MFX_WIN)
o->console = CON_INIT;
#else
o->console = CON_FILE;
#elif 1 && defined(__linux__)
o->console = CON_INIT;
#endif
o->verbose = 2;
+4 -5
View File
@@ -113,6 +113,7 @@ void PackLinuxI386elf::updateLoader(OutputFile *fo)
#undef PAGE_MASK
}
void PackLinuxI386elf::patchLoader()
{
lsize = getLoaderSize();
@@ -170,6 +171,8 @@ bool PackLinuxI386elf::canPack()
{
unsigned char buf[512];
// FIXME: add special checks for uncompresed "vmlinux" kernel
fi->readx(buf,512);
fi->seek(0,0);
if (0==memcmp(buf, "\x7f\x45\x4c\x46\x01\x01\x01", 7)) { // ELF 32-bit LSB
@@ -188,6 +191,7 @@ bool PackLinuxI386elf::canPack()
break;
}
}
exetype = 1;
return super::canPack();
}
return false;
@@ -406,11 +410,6 @@ void PackLinuxI386elf::unpackExtent(unsigned wanted, OutputFile *fo,
}
bool PackLinuxI386elf::canUnpackFormat(int format) const
{
return UPX_F_LINUX_ELF_i386==format || UPX_F_LINUX_SEP_i386==format;
}
void PackLinuxI386elf::unpack(OutputFile *fo)
{
#define MAX_ELF_HDR 512
+7 -4
View File
@@ -33,8 +33,10 @@
#ifndef __UPX_P_LX_ELF_H //{
#define __UPX_P_LX_ELF_H
#include "p_unix.h"
#include "p_elf.h"
/*************************************************************************
// linux/elf386
**************************************************************************/
class PackLinuxI386elf : public PackLinuxI386
{
@@ -51,10 +53,10 @@ public:
virtual void unpack(OutputFile *fo);
virtual bool canPack();
virtual bool canUnpackFormat(int format) const;
virtual bool canUnpackVersion(int version) const
{ return (version >= 11); }
protected:
struct Extent {
off_t offset;
off_t size;
@@ -76,7 +78,8 @@ protected:
Elf_LE32_Phdr *phdri; // for input file
};
#endif //}__UPX_P_LX_ELF_H
#endif /*} already included */
/*
+3
View File
@@ -34,6 +34,9 @@
#include "file.h"
#include "packer.h"
#include "p_elf.h"
#include "p_unix.h"
#include "p_lx_elf.h"
#include "p_lx_sep.h"
+6 -2
View File
@@ -26,10 +26,14 @@
jreiser@BitWagon.com
*/
#ifndef __UPX_P_LX_SEP_H //{
#define __UPX_P_LX_SEP_H
#include "p_lx_elf.h"
/*************************************************************************
// linux/sep386
**************************************************************************/
class PackLinuxI386sep : public PackLinuxI386elf
{
@@ -49,7 +53,7 @@ protected:
};
#endif //}__UPX_P_LX_SEP_H
#endif /*} already included */
/*
vi:ts=4:et
-6
View File
@@ -167,12 +167,6 @@ bool PackLinuxI386sh::getShellName(char *buf)
}
bool PackLinuxI386sh::canUnpackFormat(int format) const
{
return UPX_F_LINUX_SH_i386==format;
}
bool PackLinuxI386sh::canPack()
{
#if defined(__linux__) //{
+7 -3
View File
@@ -33,6 +33,11 @@
#ifndef __UPX_P_LX_SH_H //{
#define __UPX_P_LX_SH_H
/*************************************************************************
// linux/sh386
**************************************************************************/
class PackLinuxI386sh : public PackLinuxI386
{
typedef PackLinuxI386 super;
@@ -47,8 +52,6 @@ public:
virtual bool canPack();
virtual void pack(OutputFile *fo);
// virtual void unpack(OutputFile *fo) { super::unpack(fo); }
virtual bool canUnpackFormat(int format) const;
virtual bool canUnpackVersion(int version) const
{ return (version >= 11); }
@@ -65,7 +68,8 @@ protected:
int l_shname; // length of name_of_shell
};
#endif //}__UPX_P_LX_SH_H
#endif /*} already included */
/*
+1
View File
@@ -186,6 +186,7 @@ unsigned PackTos::patch_d0_subq(void *b, int blen, unsigned d0,
// patch a "subq.l #1,d0" or "subq.w #1,d0".
// also convert into "dbra" if possible
assert((int)d0 > 0);
int boff = find_be16(b, blen, get_be16(subq_marker));
if (boff < 0)
throwBadLoader();
+15 -2
View File
@@ -322,7 +322,7 @@ void PackUnix::unpack(OutputFile *fo)
/*************************************************************************
// Linux/i386 specific (execve format)
// linux/i386 (generic "execve" format)
**************************************************************************/
static const
@@ -350,6 +350,7 @@ const upx_byte *PackLinuxI386::getLoader() const
return NULL;
}
int PackLinuxI386::getLoaderSize() const
{
if (0!=lsize) {
@@ -362,13 +363,18 @@ int PackLinuxI386::getLoaderSize() const
return 0;
}
int PackLinuxI386::getLoaderPrefixSize() const
{
return 116;
}
bool PackLinuxI386::canPack()
{
if (exetype != 0)
return super::canPack();
Elf_LE32_Ehdr ehdr;
unsigned char *buf = ehdr.e_ident;
@@ -377,8 +383,11 @@ bool PackLinuxI386::canPack()
exetype = 0;
const unsigned l = get_le32(buf);
#if 0
// NOTE: ELF executables are now handled by p_lx_elf.cpp.
if (!memcmp(buf, "\x7f\x45\x4c\x46\x01\x01\x01", 7)) // ELF 32-bit LSB
{
// FIXME: add special checks for uncompresed "vmlinux" kernel
exetype = 1;
// now check the ELF header
if (!memcmp(buf+8, "FreeBSD", 7)) // branded
@@ -390,7 +399,9 @@ bool PackLinuxI386::canPack()
if (ehdr.e_version != 1) // version
exetype = 0;
}
else if (l == 0x00640107 || l == 0x00640108 || l == 0x0064010b || l == 0x006400cc)
else
#endif
if (l == 0x00640107 || l == 0x00640108 || l == 0x0064010b || l == 0x006400cc)
{
// OMAGIC / NMAGIC / ZMAGIC / QMAGIC
exetype = 2;
@@ -506,6 +517,8 @@ void PackLinuxI386::updateLoader(OutputFile *fo)
fo->rewrite(loader, 0x80);
#undef PAGE_MASK
}
/*
vi:ts=4:et
*/
+1 -1
View File
@@ -127,7 +127,7 @@ protected:
/*************************************************************************
// linux/i386 (execve format)
// linux/i386 (generic "execve" format)
**************************************************************************/
class PackLinuxI386 : public PackUnixLe32
+4 -1
View File
@@ -345,7 +345,7 @@ void PackBvmlinuzI386::pack(OutputFile *fo)
int PackVmlinuzI386::canUnpack()
{
return false;
return readFileHeader() == getFormat();
}
@@ -353,6 +353,9 @@ void PackVmlinuzI386::unpack(OutputFile *)
{
// no uncompression support for this format, so that
// it is possible to remove the original deflate code (>10KB)
// FIXME: but we could write the uncompressed "vmlinux" image
throwCantUnpack("build a new kernel instead :-)");
}
+1 -1
View File
@@ -73,7 +73,7 @@ protected:
unsigned char hdrs[4]; // "HdrS"
LE16 version; // boot protocol
char _____[9];
unsigned char load_flags;
unsigned char load_flags;
char ______[2];
LE32 code32_start;
+1
View File
@@ -25,6 +25,7 @@
markus.oberhumer@jk.uni-linz.ac.at ml1050@cdata.tvnet.hu
*/
#include "conf.h"
#include "file.h"
#include "filter.h"
+1 -1
View File
@@ -510,7 +510,7 @@ void PackWcle::pack(OutputFile *fo)
ic = (OOT(0,virtual_size) - d_len) &~ 15;
assert(ic > ((ph.u_len + overlapoh + 31) &~ 15));
upx_byte *p = oimage+soimage-d_len;
upx_byte * const p = oimage + soimage - d_len;
patch_le32(p,d_len,"JMPO",ih.init_eip_offset+text_vaddr-(ic+d_len));
patch_le32(p,d_len,"ESP0",ih.init_esp_offset+IOT(ih.init_ss_object-1,my_base_address));
if (patchFilter32(p, d_len, &ft) && text_vaddr)
+6 -4
View File
@@ -569,11 +569,13 @@ void Packer::initPackHeader()
// this is called directly after canPack() from class PackMaster
void Packer::updatePackHeader()
{
ph.method = getCompressionMethod();
ph.level = getCompressionLevel();
// update our local options
opt->method = ph.method;
opt->level = ph.level;
if (opt->level < 0)
opt->level = file_size < 512*1024 ? 8 : 7;
opt->method = getCompressionMethod();
// set ph
ph.level = opt->level;
ph.method = opt->method;
}
-1
View File
@@ -108,7 +108,6 @@ public:
virtual int getFormat() const = 0;
virtual const char *getName() const = 0;
virtual int getCompressionMethod() const = 0;
virtual int getCompressionLevel() const { return opt->level; }
virtual const int *getFilters() const = 0;
// PackMaster entries
+16
View File
@@ -144,6 +144,10 @@ static Packer* try_packers(InputFile *f, try_function func)
Packer *p = NULL;
// note: order of tries is important !
//
// .exe
//
if (!opt->dos.force_stub)
{
if ((p = func(new PackDjgpp2(f),f)) != NULL)
@@ -161,8 +165,16 @@ static Packer* try_packers(InputFile *f, try_function func)
}
if ((p = func(new PackExe(f),f)) != NULL)
return p;
//
// atari
//
if ((p = func(new PackTos(f),f)) != NULL)
return p;
//
// linux
//
#if 0
if (opt->unix.script_name)
{
@@ -180,6 +192,10 @@ static Packer* try_packers(InputFile *f, try_function func)
return p;
if ((p = func(new PackLinuxI386(f),f)) != NULL)
return p;
//
// .sys and .com
//
if ((p = func(new PackSys(f),f)) != NULL)
return p;
if ((p = func(new PackCom(f),f)) != NULL)