Introduce Packer::bele.
This commit is contained in:
+2
-1
@@ -103,12 +103,13 @@ ElfLinker::Relocation::Relocation(const Section *s, unsigned o, const char *t,
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
ElfLinker::ElfLinker() :
|
ElfLinker::ElfLinker() :
|
||||||
|
bele(&N_BELE_RTP::le_policy),
|
||||||
input(NULL), output(NULL), head(NULL), tail(NULL),
|
input(NULL), output(NULL), head(NULL), tail(NULL),
|
||||||
sections(NULL), symbols(NULL), relocations(NULL),
|
sections(NULL), symbols(NULL), relocations(NULL),
|
||||||
nsections(0), nsections_capacity(0),
|
nsections(0), nsections_capacity(0),
|
||||||
nsymbols(0), nsymbols_capacity(0),
|
nsymbols(0), nsymbols_capacity(0),
|
||||||
nrelocations(0), nrelocations_capacity(0),
|
nrelocations(0), nrelocations_capacity(0),
|
||||||
reloc_done(false), bele_policy(&N_BELE_RTP::le_policy)
|
reloc_done(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
class ElfLinker : private nocopy
|
class ElfLinker : private nocopy
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
const N_BELE_RTP::AbstractPolicy *bele;
|
||||||
protected:
|
protected:
|
||||||
struct Section;
|
struct Section;
|
||||||
struct Symbol;
|
struct Symbol;
|
||||||
@@ -61,8 +63,6 @@ protected:
|
|||||||
unsigned nrelocations_capacity;
|
unsigned nrelocations_capacity;
|
||||||
|
|
||||||
bool reloc_done;
|
bool reloc_done;
|
||||||
public:
|
|
||||||
const N_BELE_RTP::AbstractPolicy *bele_policy;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void preprocessSections(char *start, const char *end);
|
void preprocessSections(char *start, const char *end);
|
||||||
@@ -159,7 +159,7 @@ class ElfLinkerArmBE : public ElfLinker
|
|||||||
{
|
{
|
||||||
typedef ElfLinker super;
|
typedef ElfLinker super;
|
||||||
public:
|
public:
|
||||||
ElfLinkerArmBE() { bele_policy = &N_BELE_RTP::be_policy; }
|
ElfLinkerArmBE() { bele = &N_BELE_RTP::be_policy; }
|
||||||
protected:
|
protected:
|
||||||
virtual void relocate1(const Relocation *, upx_byte *location,
|
virtual void relocate1(const Relocation *, upx_byte *location,
|
||||||
unsigned value, const char *type);
|
unsigned value, const char *type);
|
||||||
@@ -179,7 +179,7 @@ class ElfLinkerM68k : public ElfLinker
|
|||||||
{
|
{
|
||||||
typedef ElfLinker super;
|
typedef ElfLinker super;
|
||||||
public:
|
public:
|
||||||
ElfLinkerM68k() { bele_policy = &N_BELE_RTP::be_policy; }
|
ElfLinkerM68k() { bele = &N_BELE_RTP::be_policy; }
|
||||||
protected:
|
protected:
|
||||||
virtual void alignCode(unsigned len);
|
virtual void alignCode(unsigned len);
|
||||||
virtual void relocate1(const Relocation *, upx_byte *location,
|
virtual void relocate1(const Relocation *, upx_byte *location,
|
||||||
@@ -200,7 +200,7 @@ class ElfLinkerPpc32 : public ElfLinker
|
|||||||
{
|
{
|
||||||
typedef ElfLinker super;
|
typedef ElfLinker super;
|
||||||
public:
|
public:
|
||||||
ElfLinkerPpc32() { bele_policy = &N_BELE_RTP::be_policy; }
|
ElfLinkerPpc32() { bele = &N_BELE_RTP::be_policy; }
|
||||||
protected:
|
protected:
|
||||||
virtual void relocate1(const Relocation *, upx_byte *location,
|
virtual void relocate1(const Relocation *, upx_byte *location,
|
||||||
unsigned value, const char *type);
|
unsigned value, const char *type);
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ class PackCom : public Packer
|
|||||||
{
|
{
|
||||||
typedef Packer super;
|
typedef Packer super;
|
||||||
public:
|
public:
|
||||||
PackCom(InputFile *f) : super(f) { }
|
PackCom(InputFile *f) : super(f) { bele = &N_BELE_RTP::le_policy; }
|
||||||
virtual int getVersion() const { return 13; }
|
virtual int getVersion() const { return 13; }
|
||||||
virtual int getFormat() const { return UPX_F_DOS_COM; }
|
virtual int getFormat() const { return UPX_F_DOS_COM; }
|
||||||
virtual const char *getName() const { return "dos/com"; }
|
virtual const char *getName() const { return "dos/com"; }
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ static const
|
|||||||
PackDjgpp2::PackDjgpp2(InputFile *f) :
|
PackDjgpp2::PackDjgpp2(InputFile *f) :
|
||||||
super(f), coff_offset(0)
|
super(f), coff_offset(0)
|
||||||
{
|
{
|
||||||
|
bele = &N_BELE_RTP::le_policy;
|
||||||
COMPILE_TIME_ASSERT(sizeof(external_scnhdr_t) == 40);
|
COMPILE_TIME_ASSERT(sizeof(external_scnhdr_t) == 40);
|
||||||
COMPILE_TIME_ASSERT(sizeof(coff_header_t) == 0xa8);
|
COMPILE_TIME_ASSERT(sizeof(coff_header_t) == 0xa8);
|
||||||
COMPILE_TIME_ASSERT(sizeof(stubify_stub) == 2048);
|
COMPILE_TIME_ASSERT(sizeof(stubify_stub) == 2048);
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ static const
|
|||||||
PackExe::PackExe(InputFile *f) :
|
PackExe::PackExe(InputFile *f) :
|
||||||
super(f)
|
super(f)
|
||||||
{
|
{
|
||||||
|
bele = &N_BELE_RTP::le_policy;
|
||||||
COMPILE_TIME_ASSERT(sizeof(exe_header_t) == 32);
|
COMPILE_TIME_ASSERT(sizeof(exe_header_t) == 32);
|
||||||
ih_exesize = ih_imagesize = ih_overlay = 0;
|
ih_exesize = ih_imagesize = ih_overlay = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -233,7 +233,7 @@ class PackLinuxElf32Be : public PackLinuxElf32
|
|||||||
{
|
{
|
||||||
typedef PackLinuxElf32 super;
|
typedef PackLinuxElf32 super;
|
||||||
protected:
|
protected:
|
||||||
PackLinuxElf32Be(InputFile *f) : super(f) { }
|
PackLinuxElf32Be(InputFile *f) : super(f) { bele = &N_BELE_RTP::be_policy; }
|
||||||
|
|
||||||
virtual acc_uint64l_t get_native64(const void *b) const { return get_be64(b); }
|
virtual acc_uint64l_t get_native64(const void *b) const { return get_be64(b); }
|
||||||
virtual unsigned get_native32(const void *b) const { return get_be32(b); }
|
virtual unsigned get_native32(const void *b) const { return get_be32(b); }
|
||||||
@@ -247,7 +247,7 @@ class PackLinuxElf32Le : public PackLinuxElf32
|
|||||||
{
|
{
|
||||||
typedef PackLinuxElf32 super;
|
typedef PackLinuxElf32 super;
|
||||||
protected:
|
protected:
|
||||||
PackLinuxElf32Le(InputFile *f) : super(f) { }
|
PackLinuxElf32Le(InputFile *f) : super(f) { bele = &N_BELE_RTP::le_policy; }
|
||||||
|
|
||||||
virtual acc_uint64l_t get_native64(const void *b) const { return get_le64(b); }
|
virtual acc_uint64l_t get_native64(const void *b) const { return get_le64(b); }
|
||||||
virtual unsigned get_native32(const void *b) const { return get_le32(b); }
|
virtual unsigned get_native32(const void *b) const { return get_le32(b); }
|
||||||
@@ -261,7 +261,7 @@ class PackLinuxElf64Le : public PackLinuxElf64
|
|||||||
{
|
{
|
||||||
typedef PackLinuxElf64 super;
|
typedef PackLinuxElf64 super;
|
||||||
protected:
|
protected:
|
||||||
PackLinuxElf64Le(InputFile *f) : super(f) { }
|
PackLinuxElf64Le(InputFile *f) : super(f) { bele = &N_BELE_RTP::le_policy; }
|
||||||
|
|
||||||
virtual acc_uint64l_t get_native64(const void *b) const { return get_le64(b); }
|
virtual acc_uint64l_t get_native64(const void *b) const { return get_le64(b); }
|
||||||
virtual unsigned get_native32(const void *b) const { return get_le32(b); }
|
virtual unsigned get_native32(const void *b) const { return get_le32(b); }
|
||||||
|
|||||||
+2
-1
@@ -57,6 +57,7 @@
|
|||||||
PackLinuxI386::PackLinuxI386(InputFile *f) : super(f),
|
PackLinuxI386::PackLinuxI386(InputFile *f) : super(f),
|
||||||
ei_osabi(Elf32_Ehdr::ELFOSABI_LINUX), osabi_note(NULL)
|
ei_osabi(Elf32_Ehdr::ELFOSABI_LINUX), osabi_note(NULL)
|
||||||
{
|
{
|
||||||
|
bele = &N_BELE_RTP::le_policy;
|
||||||
}
|
}
|
||||||
|
|
||||||
PackBSDI386::PackBSDI386(InputFile *f) : super(f)
|
PackBSDI386::PackBSDI386(InputFile *f) : super(f)
|
||||||
@@ -378,7 +379,7 @@ PackLinuxI386::buildLinuxLoader(
|
|||||||
(res->lit_context_bits << 0) |
|
(res->lit_context_bits << 0) |
|
||||||
(res->lit_pos_bits << 8) |
|
(res->lit_pos_bits << 8) |
|
||||||
(res->pos_bits << 16);
|
(res->pos_bits << 16);
|
||||||
if (linker->bele_policy->isBE()) // big endian - bswap32
|
if (linker->bele->isBE()) // big endian - bswap32
|
||||||
acc_swab32s(&properties);
|
acc_swab32s(&properties);
|
||||||
linker->defineSymbol("lzma_properties", properties);
|
linker->defineSymbol("lzma_properties", properties);
|
||||||
// -2 for properties
|
// -2 for properties
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ PackPs1::PackPs1(InputFile *f) :
|
|||||||
buildPart2(0), foundBss(0), sa_cnt(0), overlap(0), sz_lunc(0), sz_lcpr(0),
|
buildPart2(0), foundBss(0), sa_cnt(0), overlap(0), sz_lunc(0), sz_lcpr(0),
|
||||||
pad_code(0), bss_start(0), bss_end(0)
|
pad_code(0), bss_start(0), bss_end(0)
|
||||||
{
|
{
|
||||||
|
bele = &N_BELE_RTP::le_policy;
|
||||||
COMPILE_TIME_ASSERT(sizeof(ps1_exe_t) == 136);
|
COMPILE_TIME_ASSERT(sizeof(ps1_exe_t) == 136);
|
||||||
COMPILE_TIME_ASSERT(sizeof(ps1_exe_hb_t) == 44);
|
COMPILE_TIME_ASSERT(sizeof(ps1_exe_hb_t) == 44);
|
||||||
COMPILE_TIME_ASSERT(sizeof(ps1_exe_chb_t) == 5);
|
COMPILE_TIME_ASSERT(sizeof(ps1_exe_chb_t) == 5);
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ static const
|
|||||||
|
|
||||||
PackTmt::PackTmt(InputFile *f) : super(f)
|
PackTmt::PackTmt(InputFile *f) : super(f)
|
||||||
{
|
{
|
||||||
|
bele = &N_BELE_RTP::le_policy;
|
||||||
COMPILE_TIME_ASSERT(sizeof(tmt_header_t) == 44);
|
COMPILE_TIME_ASSERT(sizeof(tmt_header_t) == 44);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ static const
|
|||||||
PackTos::PackTos(InputFile *f) :
|
PackTos::PackTos(InputFile *f) :
|
||||||
super(f)
|
super(f)
|
||||||
{
|
{
|
||||||
|
bele = &N_BELE_RTP::be_policy;
|
||||||
COMPILE_TIME_ASSERT(FH_SIZE == 28);
|
COMPILE_TIME_ASSERT(FH_SIZE == 28);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -141,7 +141,7 @@ class PackUnixBe32 : public PackUnix
|
|||||||
{
|
{
|
||||||
typedef PackUnix super;
|
typedef PackUnix super;
|
||||||
protected:
|
protected:
|
||||||
PackUnixBe32(InputFile *f) : super(f) { }
|
PackUnixBe32(InputFile *f) : super(f) { bele = &N_BELE_RTP::be_policy; }
|
||||||
virtual acc_uint64l_t get_native64(const void *b) const { return get_be64(b); }
|
virtual acc_uint64l_t get_native64(const void *b) const { return get_be64(b); }
|
||||||
virtual unsigned get_native32(const void *b) const { return get_be32(b); }
|
virtual unsigned get_native32(const void *b) const { return get_be32(b); }
|
||||||
virtual unsigned get_native16(const void *b) const { return get_be16(b); }
|
virtual unsigned get_native16(const void *b) const { return get_be16(b); }
|
||||||
@@ -182,7 +182,7 @@ class PackUnixLe32 : public PackUnix
|
|||||||
{
|
{
|
||||||
typedef PackUnix super;
|
typedef PackUnix super;
|
||||||
protected:
|
protected:
|
||||||
PackUnixLe32(InputFile *f) : super(f) { }
|
PackUnixLe32(InputFile *f) : super(f) { bele = &N_BELE_RTP::le_policy; }
|
||||||
virtual acc_uint64l_t get_native64(const void *b) const { return get_le64(b); }
|
virtual acc_uint64l_t get_native64(const void *b) const { return get_le64(b); }
|
||||||
virtual unsigned get_native32(const void *b) const { return get_le32(b); }
|
virtual unsigned get_native32(const void *b) const { return get_le32(b); }
|
||||||
virtual unsigned get_native16(const void *b) const { return get_le16(b); }
|
virtual unsigned get_native16(const void *b) const { return get_le16(b); }
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ static const
|
|||||||
PackVmlinuxI386::PackVmlinuxI386(InputFile *f) :
|
PackVmlinuxI386::PackVmlinuxI386(InputFile *f) :
|
||||||
super(f), n_ptload(0), phdri(NULL), shdri(NULL), shstrtab(NULL)
|
super(f), n_ptload(0), phdri(NULL), shdri(NULL), shstrtab(NULL)
|
||||||
{
|
{
|
||||||
|
bele = &N_BELE_RTP::le_policy;
|
||||||
}
|
}
|
||||||
|
|
||||||
PackVmlinuxI386::~PackVmlinuxI386()
|
PackVmlinuxI386::~PackVmlinuxI386()
|
||||||
|
|||||||
+2
-1
@@ -53,6 +53,7 @@ static const unsigned bzimage_offset = 0x100000;
|
|||||||
PackVmlinuzI386::PackVmlinuzI386(InputFile *f) :
|
PackVmlinuzI386::PackVmlinuzI386(InputFile *f) :
|
||||||
super(f), physical_start(0x100000)
|
super(f), physical_start(0x100000)
|
||||||
{
|
{
|
||||||
|
bele = &N_BELE_RTP::le_policy;
|
||||||
COMPILE_TIME_ASSERT(sizeof(boot_sect_t) == 0x218);
|
COMPILE_TIME_ASSERT(sizeof(boot_sect_t) == 0x218);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,7 +416,7 @@ void PackBvmlinuzI386::pack(OutputFile *fo)
|
|||||||
(res->lit_context_bits << 0) |
|
(res->lit_context_bits << 0) |
|
||||||
(res->lit_pos_bits << 8) |
|
(res->lit_pos_bits << 8) |
|
||||||
(res->pos_bits << 16);
|
(res->pos_bits << 16);
|
||||||
if (linker->bele_policy->isBE()) // big endian - bswap32
|
if (linker->bele->isBE()) // big endian - bswap32
|
||||||
acc_swab32s(&properties);
|
acc_swab32s(&properties);
|
||||||
linker->defineSymbol("lzma_properties", properties);
|
linker->defineSymbol("lzma_properties", properties);
|
||||||
// -2 for properties
|
// -2 for properties
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
PackW16Ne::PackW16Ne(InputFile *f) :
|
PackW16Ne::PackW16Ne(InputFile *f) :
|
||||||
super(f)
|
super(f)
|
||||||
{
|
{
|
||||||
|
bele = &N_BELE_RTP::le_policy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ class PackWcle : public Packer, public LeFile
|
|||||||
{
|
{
|
||||||
typedef Packer super;
|
typedef Packer super;
|
||||||
public:
|
public:
|
||||||
PackWcle(InputFile *f) : super(f), LeFile(f){};
|
PackWcle(InputFile *f) : super(f), LeFile(f) { bele = &N_BELE_RTP::le_policy; }
|
||||||
virtual int getVersion() const { return 13; }
|
virtual int getVersion() const { return 13; }
|
||||||
virtual int getFormat() const { return UPX_F_WATCOM_LE; }
|
virtual int getFormat() const { return UPX_F_WATCOM_LE; }
|
||||||
virtual const char *getName() const { return "watcom/le"; }
|
virtual const char *getName() const { return "watcom/le"; }
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
Packer::Packer(InputFile *f) :
|
Packer::Packer(InputFile *f) :
|
||||||
|
bele(NULL),
|
||||||
fi(f), file_size(-1), ph_format(-1), ph_version(-1),
|
fi(f), file_size(-1), ph_format(-1), ph_version(-1),
|
||||||
uip(NULL), linker(NULL),
|
uip(NULL), linker(NULL),
|
||||||
last_patch(NULL), last_patch_len(0), last_patch_off(0)
|
last_patch(NULL), last_patch_len(0), last_patch_off(0)
|
||||||
@@ -54,6 +55,29 @@ Packer::~Packer()
|
|||||||
{
|
{
|
||||||
delete uip; uip = NULL;
|
delete uip; uip = NULL;
|
||||||
delete linker; linker = NULL;
|
delete linker; linker = NULL;
|
||||||
|
#if 0
|
||||||
|
initLoader(NULL, 0);
|
||||||
|
delete linker; linker = NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// for PackMaster
|
||||||
|
void Packer::assertPacker()
|
||||||
|
{
|
||||||
|
assert(getFormat() > 0);
|
||||||
|
assert(getFormat() <= 255);
|
||||||
|
assert(getVersion() >= 11);
|
||||||
|
assert(getVersion() <= 14);
|
||||||
|
assert(strlen(getName()) <= 13);
|
||||||
|
if (bele == NULL) fprintf(stderr, "%s\n", getName());
|
||||||
|
assert(bele != NULL);
|
||||||
|
#if 1
|
||||||
|
Linker *l = newLinker();
|
||||||
|
if (bele != l->bele) fprintf(stderr, "%s\n", getName());
|
||||||
|
assert(bele == l->bele);
|
||||||
|
delete l;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -993,6 +1017,7 @@ void Packer::initLoader(const void *pdata, int plen, int small)
|
|||||||
{
|
{
|
||||||
delete linker;
|
delete linker;
|
||||||
linker = newLinker();
|
linker = newLinker();
|
||||||
|
assert(bele == linker->bele);
|
||||||
linker->init(pdata, plen);
|
linker->init(pdata, plen);
|
||||||
|
|
||||||
unsigned size;
|
unsigned size;
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ protected:
|
|||||||
Packer(InputFile *f);
|
Packer(InputFile *f);
|
||||||
public:
|
public:
|
||||||
virtual ~Packer();
|
virtual ~Packer();
|
||||||
|
virtual void assertPacker();
|
||||||
|
|
||||||
virtual int getVersion() const = 0;
|
virtual int getVersion() const = 0;
|
||||||
// A unique integer ID for this executable format. See conf.h.
|
// A unique integer ID for this executable format. See conf.h.
|
||||||
@@ -264,6 +265,7 @@ protected:
|
|||||||
static unsigned unoptimizeReloc32(upx_byte **in,upx_byte *image,MemBuffer *out,int bs);
|
static unsigned unoptimizeReloc32(upx_byte **in,upx_byte *image,MemBuffer *out,int bs);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
const N_BELE_RTP::AbstractPolicy *bele;
|
||||||
InputFile *fi;
|
InputFile *fi;
|
||||||
off_t file_size; // will get set by constructor
|
off_t file_size; // will get set by constructor
|
||||||
PackHeader ph; // must be filled by canUnpack()
|
PackHeader ph; // must be filled by canUnpack()
|
||||||
|
|||||||
+1
-1
@@ -257,7 +257,7 @@ void Packer::defineDecompressorSymbols()
|
|||||||
(res->lit_context_bits << 0) |
|
(res->lit_context_bits << 0) |
|
||||||
(res->lit_pos_bits << 8) |
|
(res->lit_pos_bits << 8) |
|
||||||
(res->pos_bits << 16);
|
(res->pos_bits << 16);
|
||||||
if (linker->bele_policy->isBE()) // big endian - bswap32
|
if (linker->bele->isBE()) // big endian - bswap32
|
||||||
acc_swab32s(&properties);
|
acc_swab32s(&properties);
|
||||||
linker->defineSymbol("lzma_properties", properties);
|
linker->defineSymbol("lzma_properties", properties);
|
||||||
// -2 for properties
|
// -2 for properties
|
||||||
|
|||||||
+8
-15
@@ -55,6 +55,7 @@
|
|||||||
#include "p_ps1.h"
|
#include "p_ps1.h"
|
||||||
#include "p_mach.h"
|
#include "p_mach.h"
|
||||||
#include "p_armpe.h"
|
#include "p_armpe.h"
|
||||||
|
#include "linker.h"
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -96,6 +97,7 @@ static Packer* try_pack(Packer *p, InputFile *f)
|
|||||||
{
|
{
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
p->assertPacker();
|
||||||
try {
|
try {
|
||||||
p->initPackHeader();
|
p->initPackHeader();
|
||||||
f->seek(0,SEEK_SET);
|
f->seek(0,SEEK_SET);
|
||||||
@@ -120,6 +122,7 @@ static Packer* try_unpack(Packer *p, InputFile *f)
|
|||||||
{
|
{
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
p->assertPacker();
|
||||||
try {
|
try {
|
||||||
p->initPackHeader();
|
p->initPackHeader();
|
||||||
f->seek(0,SEEK_SET);
|
f->seek(0,SEEK_SET);
|
||||||
@@ -279,16 +282,6 @@ static Packer *getUnpacker(InputFile *f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void assertPacker(const Packer *p)
|
|
||||||
{
|
|
||||||
assert(p->getFormat() > 0);
|
|
||||||
assert(p->getFormat() <= 255);
|
|
||||||
assert(p->getVersion() >= 11);
|
|
||||||
assert(p->getVersion() <= 14);
|
|
||||||
assert(strlen(p->getName()) <= 13);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// delegation
|
// delegation
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
@@ -296,7 +289,7 @@ static void assertPacker(const Packer *p)
|
|||||||
void PackMaster::pack(OutputFile *fo)
|
void PackMaster::pack(OutputFile *fo)
|
||||||
{
|
{
|
||||||
p = getPacker(fi);
|
p = getPacker(fi);
|
||||||
assertPacker(p);
|
p->assertPacker();
|
||||||
fi = NULL;
|
fi = NULL;
|
||||||
p->doPack(fo);
|
p->doPack(fo);
|
||||||
}
|
}
|
||||||
@@ -305,7 +298,7 @@ void PackMaster::pack(OutputFile *fo)
|
|||||||
void PackMaster::unpack(OutputFile *fo)
|
void PackMaster::unpack(OutputFile *fo)
|
||||||
{
|
{
|
||||||
p = getUnpacker(fi);
|
p = getUnpacker(fi);
|
||||||
assertPacker(p);
|
p->assertPacker();
|
||||||
fi = NULL;
|
fi = NULL;
|
||||||
p->doUnpack(fo);
|
p->doUnpack(fo);
|
||||||
}
|
}
|
||||||
@@ -314,7 +307,7 @@ void PackMaster::unpack(OutputFile *fo)
|
|||||||
void PackMaster::test()
|
void PackMaster::test()
|
||||||
{
|
{
|
||||||
p = getUnpacker(fi);
|
p = getUnpacker(fi);
|
||||||
assertPacker(p);
|
p->assertPacker();
|
||||||
fi = NULL;
|
fi = NULL;
|
||||||
p->doTest();
|
p->doTest();
|
||||||
}
|
}
|
||||||
@@ -323,7 +316,7 @@ void PackMaster::test()
|
|||||||
void PackMaster::list()
|
void PackMaster::list()
|
||||||
{
|
{
|
||||||
p = getUnpacker(fi);
|
p = getUnpacker(fi);
|
||||||
assertPacker(p);
|
p->assertPacker();
|
||||||
fi = NULL;
|
fi = NULL;
|
||||||
p->doList();
|
p->doList();
|
||||||
}
|
}
|
||||||
@@ -336,7 +329,7 @@ void PackMaster::fileInfo()
|
|||||||
p = try_packers(fi, try_pack);
|
p = try_packers(fi, try_pack);
|
||||||
if (!p)
|
if (!p)
|
||||||
throwUnknownExecutableFormat(NULL, 1); // make a warning here
|
throwUnknownExecutableFormat(NULL, 1); // make a warning here
|
||||||
assertPacker(p);
|
p->assertPacker();
|
||||||
fi = NULL;
|
fi = NULL;
|
||||||
p->doFileInfo();
|
p->doFileInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ static void xcheck(size_t poff, size_t plen, const void *b, size_t blen)
|
|||||||
|
|
||||||
PeFile::PeFile(InputFile *f) : super(f)
|
PeFile::PeFile(InputFile *f) : super(f)
|
||||||
{
|
{
|
||||||
|
bele = &N_BELE_RTP::le_policy;
|
||||||
//printf("pe_header_t %d\n", (int) sizeof(pe_header_t));
|
//printf("pe_header_t %d\n", (int) sizeof(pe_header_t));
|
||||||
//printf("pe_section_t %d\n", (int) sizeof(pe_section_t));
|
//printf("pe_section_t %d\n", (int) sizeof(pe_section_t));
|
||||||
COMPILE_TIME_ASSERT(sizeof(pe_header_t) == 248);
|
COMPILE_TIME_ASSERT(sizeof(pe_header_t) == 248);
|
||||||
|
|||||||
Reference in New Issue
Block a user