Support building with OpenWatcom 1.8. Silence some compiler warnings.
This commit is contained in:
+18
-36
@@ -282,12 +282,12 @@ inline unsigned acc_swap32p(const acc_uint32e_t *p)
|
|||||||
|
|
||||||
inline void acc_swab16s(acc_uint16e_t *p)
|
inline void acc_swab16s(acc_uint16e_t *p)
|
||||||
{
|
{
|
||||||
*p = acc_swab16(*p);
|
*p = (acc_uint16e_t) acc_swab16(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void acc_swab32s(acc_uint32e_t *p)
|
inline void acc_swab32s(acc_uint32e_t *p)
|
||||||
{
|
{
|
||||||
*p = acc_swab32(*p);
|
*p = (acc_uint32e_t) acc_swab32(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -313,8 +313,7 @@ inline void acc_ua_swab32s(void *p)
|
|||||||
// to have gcc bug 17519 fixed - see http://gcc.gnu.org/PR17519 ]
|
// to have gcc bug 17519 fixed - see http://gcc.gnu.org/PR17519 ]
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
struct BE16
|
__packed_struct(BE16)
|
||||||
{
|
|
||||||
unsigned char d[2];
|
unsigned char d[2];
|
||||||
|
|
||||||
//inline BE16() { }
|
//inline BE16() { }
|
||||||
@@ -332,12 +331,10 @@ struct BE16
|
|||||||
BE16& operator >>= (unsigned v) { set_be16(d, get_be16(d) >> v); return *this; }
|
BE16& operator >>= (unsigned v) { set_be16(d, get_be16(d) >> v); return *this; }
|
||||||
|
|
||||||
operator unsigned () const { return get_be16(d); }
|
operator unsigned () const { return get_be16(d); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
struct BE32
|
__packed_struct(BE32)
|
||||||
{
|
|
||||||
unsigned char d[4];
|
unsigned char d[4];
|
||||||
|
|
||||||
//inline BE32() { }
|
//inline BE32() { }
|
||||||
@@ -355,12 +352,10 @@ struct BE32
|
|||||||
BE32& operator >>= (unsigned v) { set_be32(d, get_be32(d) >> v); return *this; }
|
BE32& operator >>= (unsigned v) { set_be32(d, get_be32(d) >> v); return *this; }
|
||||||
|
|
||||||
operator unsigned () const { return get_be32(d); }
|
operator unsigned () const { return get_be32(d); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
struct BE64
|
__packed_struct(BE64)
|
||||||
{
|
|
||||||
unsigned char d[8];
|
unsigned char d[8];
|
||||||
|
|
||||||
//inline BE64() { }
|
//inline BE64() { }
|
||||||
@@ -378,12 +373,10 @@ struct BE64
|
|||||||
BE64& operator >>= (unsigned v) { set_be64(d, get_be64(d) >> v); return *this; }
|
BE64& operator >>= (unsigned v) { set_be64(d, get_be64(d) >> v); return *this; }
|
||||||
|
|
||||||
operator acc_uint64l_t () const { return get_be64(d); }
|
operator acc_uint64l_t () const { return get_be64(d); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
struct LE16
|
__packed_struct(LE16)
|
||||||
{
|
|
||||||
unsigned char d[2];
|
unsigned char d[2];
|
||||||
|
|
||||||
//inline LE16() { }
|
//inline LE16() { }
|
||||||
@@ -401,12 +394,10 @@ struct LE16
|
|||||||
LE16& operator >>= (unsigned v) { set_le16(d, get_le16(d) >> v); return *this; }
|
LE16& operator >>= (unsigned v) { set_le16(d, get_le16(d) >> v); return *this; }
|
||||||
|
|
||||||
operator unsigned () const { return get_le16(d); }
|
operator unsigned () const { return get_le16(d); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
struct LE32
|
__packed_struct(LE32)
|
||||||
{
|
|
||||||
unsigned char d[4];
|
unsigned char d[4];
|
||||||
|
|
||||||
//inline LE32() { }
|
//inline LE32() { }
|
||||||
@@ -424,12 +415,10 @@ struct LE32
|
|||||||
LE32& operator >>= (unsigned v) { set_le32(d, get_le32(d) >> v); return *this; }
|
LE32& operator >>= (unsigned v) { set_le32(d, get_le32(d) >> v); return *this; }
|
||||||
|
|
||||||
operator unsigned () const { return get_le32(d); }
|
operator unsigned () const { return get_le32(d); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
struct LE64
|
__packed_struct(LE64)
|
||||||
{
|
|
||||||
unsigned char d[8];
|
unsigned char d[8];
|
||||||
|
|
||||||
//inline LE64() { }
|
//inline LE64() { }
|
||||||
@@ -447,8 +436,7 @@ struct LE64
|
|||||||
LE64& operator >>= (unsigned v) { set_le64(d, get_le64(d) >> v); return *this; }
|
LE64& operator >>= (unsigned v) { set_le64(d, get_le64(d) >> v); return *this; }
|
||||||
|
|
||||||
operator acc_uint64l_t () const { return get_le64(d); }
|
operator acc_uint64l_t () const { return get_le64(d); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -623,16 +611,10 @@ namespace N_BELE_RTP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace N_BELE_CTP {
|
namespace N_BELE_CTP {
|
||||||
|
inline const N_BELE_RTP::AbstractPolicy* getRTP(const BEPolicy*)
|
||||||
template <class T>
|
{ return &N_BELE_RTP::be_policy; }
|
||||||
inline const N_BELE_RTP::AbstractPolicy* getRTP();
|
inline const N_BELE_RTP::AbstractPolicy* getRTP(const LEPolicy*)
|
||||||
template <>
|
{ return &N_BELE_RTP::le_policy; }
|
||||||
inline const N_BELE_RTP::AbstractPolicy* getRTP<BEPolicy>()
|
|
||||||
{ return &N_BELE_RTP::be_policy; }
|
|
||||||
template <>
|
|
||||||
inline const N_BELE_RTP::AbstractPolicy* getRTP<LEPolicy>()
|
|
||||||
{ return &N_BELE_RTP::le_policy; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ static int convert_errno_from_ucl(int r)
|
|||||||
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static void wrap_nprogress_ucl(ucl_uint a, ucl_uint b, int state, ucl_voidp user)
|
static void __UCL_CDECL wrap_nprogress_ucl(ucl_uint a, ucl_uint b, int state, ucl_voidp user)
|
||||||
{
|
{
|
||||||
if (state != -1 && state != 3) return;
|
if (state != -1 && state != 3) return;
|
||||||
upx_callback_p cb = (upx_callback_p) user;
|
upx_callback_p cb = (upx_callback_p) user;
|
||||||
|
|||||||
+23
-7
@@ -111,6 +111,9 @@
|
|||||||
# error "need Watcom C++ 11.0c or newer"
|
# error "need Watcom C++ 11.0c or newer"
|
||||||
# endif
|
# endif
|
||||||
# if defined(__cplusplus)
|
# if defined(__cplusplus)
|
||||||
|
# pragma warning 367 9 // w3: conditional expression in if statement is always true
|
||||||
|
# pragma warning 368 9 // w3: conditional expression in if statement is always false
|
||||||
|
# pragma warning 389 9 // w3: integral value may be truncated
|
||||||
# pragma warning 656 9 // w5: define this function inside its class definition (may improve code quality)
|
# pragma warning 656 9 // w5: define this function inside its class definition (may improve code quality)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
@@ -160,6 +163,9 @@
|
|||||||
#if 0 && !defined(WITH_LZMA)
|
#if 0 && !defined(WITH_LZMA)
|
||||||
# define WITH_LZMA 1
|
# define WITH_LZMA 1
|
||||||
#endif
|
#endif
|
||||||
|
#if 1 && (ACC_CC_WATCOMC)
|
||||||
|
# undef WITH_LZMA
|
||||||
|
#endif
|
||||||
#if defined(UPX_OFFICIAL_BUILD)
|
#if defined(UPX_OFFICIAL_BUILD)
|
||||||
# if !defined(WITH_LZMA) || !defined(WITH_NRV) || !defined(WITH_UCL)
|
# if !defined(WITH_LZMA) || !defined(WITH_NRV) || !defined(WITH_UCL)
|
||||||
# error
|
# error
|
||||||
@@ -302,16 +308,25 @@
|
|||||||
|
|
||||||
|
|
||||||
#undef __attribute_packed
|
#undef __attribute_packed
|
||||||
#if (ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE)
|
#if (ACC_CC_INTELC && (__INTEL_COMPILER < 800))
|
||||||
# if (ACC_ARCH_I386) && (ACC_CC_INTELC && (__INTEL_COMPILER < 800))
|
#elif (0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386))
|
||||||
# elif (0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386))
|
#elif (ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE)
|
||||||
# else
|
# define __attribute_packed __attribute__((__packed__,__aligned__(1)))
|
||||||
# define __attribute_packed __attribute__((__packed__,__aligned__(1)))
|
# define __packed_struct(s) struct s {
|
||||||
# endif
|
# define __packed_struct_end() } __attribute_packed;
|
||||||
|
#elif (ACC_CC_WATCOMC)
|
||||||
|
# define __attribute_packed
|
||||||
|
# define __packed_struct(s) _Packed struct s {
|
||||||
|
# define __packed_struct_end() };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(__attribute_packed)
|
#if !defined(__attribute_packed)
|
||||||
# define __attribute_packed
|
# define __attribute_packed
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(__packed_struct)
|
||||||
|
# define __packed_struct(s) struct s {
|
||||||
|
# define __packed_struct_end() };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -323,8 +338,9 @@
|
|||||||
|
|
||||||
#define __COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) { \
|
#define __COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) { \
|
||||||
typedef a acc_tmp_a_t; typedef b acc_tmp_b_t; \
|
typedef a acc_tmp_a_t; typedef b acc_tmp_b_t; \
|
||||||
struct acc_tmp_t { acc_tmp_b_t x; acc_tmp_a_t y; acc_tmp_b_t z; } __attribute_packed; \
|
__packed_struct(acc_tmp_t) acc_tmp_b_t x; acc_tmp_a_t y; acc_tmp_b_t z; __packed_struct_end() \
|
||||||
COMPILE_TIME_ASSERT(sizeof(struct acc_tmp_t) == 2*sizeof(b)+sizeof(a)) \
|
COMPILE_TIME_ASSERT(sizeof(struct acc_tmp_t) == 2*sizeof(b)+sizeof(a)) \
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(((acc_tmp_t*)0)->x)+sizeof(((acc_tmp_t*)0)->y)+sizeof(((acc_tmp_t*)0)->z) == 2*sizeof(b)+sizeof(a)) \
|
||||||
}
|
}
|
||||||
#if defined(__acc_alignof)
|
#if defined(__acc_alignof)
|
||||||
# define __COMPILE_TIME_ASSERT_ALIGNOF(a,b) \
|
# define __COMPILE_TIME_ASSERT_ALIGNOF(a,b) \
|
||||||
|
|||||||
+9
-6
@@ -47,7 +47,7 @@ static int F(Filter *f)
|
|||||||
// scan
|
// scan
|
||||||
const upx_byte *b = f->buf;
|
const upx_byte *b = f->buf;
|
||||||
#endif
|
#endif
|
||||||
const unsigned size = umin(f->buf_len, -(~0u<<(32 - (6+ W_CTO))));
|
const unsigned size = umin(f->buf_len, 0u - (~0u<<(32 - (6+ W_CTO))));
|
||||||
const unsigned size4 = size -4;
|
const unsigned size4 = size -4;
|
||||||
|
|
||||||
unsigned ic;
|
unsigned ic;
|
||||||
@@ -72,9 +72,11 @@ static int F(Filter *f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getcto(f, buf) < 0) {
|
if (getcto(f, buf) < 0) {
|
||||||
if (0!=W_CTO) // FIXME: what is this ???
|
#if (W_CTO != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
#else
|
||||||
f->cto = 0;
|
f->cto = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const unsigned char cto8 = f->cto;
|
const unsigned char cto8 = f->cto;
|
||||||
@@ -95,8 +97,9 @@ static int F(Filter *f)
|
|||||||
lastcall = ic;
|
lastcall = ic;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(0==W_CTO // FIXME: what is this ???
|
#if (W_CTO != 0)
|
||||||
|| (~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) != cto8); // this should not happen
|
assert((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) != cto8); // this should not happen
|
||||||
|
#endif
|
||||||
lastnoncall = ic;
|
lastnoncall = ic;
|
||||||
noncalls++;
|
noncalls++;
|
||||||
}
|
}
|
||||||
@@ -122,7 +125,7 @@ static int F(Filter *f)
|
|||||||
static int U(Filter *f)
|
static int U(Filter *f)
|
||||||
{
|
{
|
||||||
upx_byte *b = f->buf;
|
upx_byte *b = f->buf;
|
||||||
const unsigned size4 = umin(f->buf_len - 4, -(~0u<<(32 - (6+ W_CTO))));
|
const unsigned size4 = umin(f->buf_len - 4, 0u - (~0u<<(32 - (6+ W_CTO))));
|
||||||
const unsigned addvalue = f->addvalue;
|
const unsigned addvalue = f->addvalue;
|
||||||
|
|
||||||
unsigned ic;
|
unsigned ic;
|
||||||
|
|||||||
+7
-3
@@ -1257,8 +1257,8 @@ template <class T> struct TestBELE {
|
|||||||
static bool test(void)
|
static bool test(void)
|
||||||
{
|
{
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(T)
|
COMPILE_TIME_ASSERT_ALIGNED1(T)
|
||||||
struct test1_t { char a; T b; } __attribute_packed;
|
__packed_struct(test1_t) char a; T b; __packed_struct_end()
|
||||||
struct test2_t { char a; T b[3]; } __attribute_packed;
|
__packed_struct(test2_t) char a; T b[3]; __packed_struct_end()
|
||||||
test1_t t1[7]; UNUSED(t1); test2_t t2[7]; UNUSED(t2);
|
test1_t t1[7]; UNUSED(t1); test2_t t2[7]; UNUSED(t2);
|
||||||
COMPILE_TIME_ASSERT(sizeof(test1_t) == 1 + sizeof(T))
|
COMPILE_TIME_ASSERT(sizeof(test1_t) == 1 + sizeof(T))
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(test1_t)
|
COMPILE_TIME_ASSERT_ALIGNED1(test1_t)
|
||||||
@@ -1270,7 +1270,11 @@ static bool test(void)
|
|||||||
COMPILE_TIME_ASSERT(__acc_alignof(t1) == 1)
|
COMPILE_TIME_ASSERT(__acc_alignof(t1) == 1)
|
||||||
COMPILE_TIME_ASSERT(__acc_alignof(t2) == 1)
|
COMPILE_TIME_ASSERT(__acc_alignof(t2) == 1)
|
||||||
#endif
|
#endif
|
||||||
#if 1 && !defined(xUPX_OFFICIAL_BUILD)
|
#if 1 && (ACC_CC_WATCOMC)
|
||||||
|
test1_t t11; COMPILE_TIME_ASSERT(sizeof(t11.a) <= sizeof(t11.b))
|
||||||
|
test2_t t22; COMPILE_TIME_ASSERT(sizeof(t22.a) <= sizeof(t22.b))
|
||||||
|
#endif
|
||||||
|
#if 1 && !defined(UPX_OFFICIAL_BUILD)
|
||||||
T allbits; allbits = 0; allbits -= 1;
|
T allbits; allbits = 0; allbits -= 1;
|
||||||
//++allbits; allbits++; --allbits; allbits--;
|
//++allbits; allbits++; --allbits; allbits--;
|
||||||
T v1; v1 = 1; v1 *= 2; v1 -= 1;
|
T v1; v1 = 1; v1 *= 2; v1 -= 1;
|
||||||
|
|||||||
+18
-36
@@ -52,8 +52,7 @@ struct ElfITypes
|
|||||||
|
|
||||||
// The ELF file header. This appears at the start of every ELF file.
|
// The ELF file header. This appears at the start of every ELF file.
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
struct Ehdr
|
__packed_struct(Ehdr)
|
||||||
{
|
|
||||||
typedef typename TElfITypes::Half Half;
|
typedef typename TElfITypes::Half Half;
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
@@ -76,13 +75,11 @@ struct Ehdr
|
|||||||
|
|
||||||
# define WANT_EHDR_ENUM 1
|
# define WANT_EHDR_ENUM 1
|
||||||
# include "p_elf_enum.h"
|
# include "p_elf_enum.h"
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
struct Dyn
|
__packed_struct(Dyn)
|
||||||
{
|
|
||||||
typedef typename TElfITypes::Xword Xword;
|
typedef typename TElfITypes::Xword Xword;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
|
||||||
@@ -91,13 +88,11 @@ struct Dyn
|
|||||||
|
|
||||||
# define WANT_DYN_ENUM 1
|
# define WANT_DYN_ENUM 1
|
||||||
# include "p_elf_enum.h"
|
# include "p_elf_enum.h"
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
struct External_Note
|
__packed_struct(External_Note)
|
||||||
{
|
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
|
|
||||||
Word xn_namesz; // includes terminating '\0'
|
Word xn_namesz; // includes terminating '\0'
|
||||||
@@ -105,8 +100,7 @@ struct External_Note
|
|||||||
Word xn_type;
|
Word xn_type;
|
||||||
//char xn_name[N]; // terminate with '\0'
|
//char xn_name[N]; // terminate with '\0'
|
||||||
//char xn_data[M]; // aligned to 0 mod 4
|
//char xn_data[M]; // aligned to 0 mod 4
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace N_Elf
|
} // namespace N_Elf
|
||||||
@@ -119,8 +113,7 @@ __attribute_packed;
|
|||||||
namespace N_Elf32 {
|
namespace N_Elf32 {
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
struct Phdr
|
__packed_struct(Phdr)
|
||||||
{
|
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
typedef typename TElfITypes::Off Off;
|
typedef typename TElfITypes::Off Off;
|
||||||
@@ -136,13 +129,11 @@ struct Phdr
|
|||||||
|
|
||||||
# define WANT_PHDR_ENUM 1
|
# define WANT_PHDR_ENUM 1
|
||||||
# include "p_elf_enum.h"
|
# include "p_elf_enum.h"
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
struct Shdr
|
__packed_struct(Shdr)
|
||||||
{
|
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
typedef typename TElfITypes::Off Off;
|
typedef typename TElfITypes::Off Off;
|
||||||
@@ -160,13 +151,11 @@ struct Shdr
|
|||||||
|
|
||||||
# define WANT_SHDR_ENUM 1
|
# define WANT_SHDR_ENUM 1
|
||||||
# include "p_elf_enum.h"
|
# include "p_elf_enum.h"
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
struct Sym
|
__packed_struct(Sym)
|
||||||
{
|
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
typedef typename TElfITypes::Section Section;
|
typedef typename TElfITypes::Section Section;
|
||||||
@@ -184,8 +173,7 @@ struct Sym
|
|||||||
static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); }
|
static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); }
|
||||||
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
||||||
static unsigned char make_st_info(unsigned bind, unsigned type) { return (bind<<4) + (0xf & type); }
|
static unsigned char make_st_info(unsigned bind, unsigned type) { return (bind<<4) + (0xf & type); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace N_Elf32
|
} // namespace N_Elf32
|
||||||
@@ -198,8 +186,7 @@ __attribute_packed;
|
|||||||
namespace N_Elf64 {
|
namespace N_Elf64 {
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
struct Phdr
|
__packed_struct(Phdr)
|
||||||
{
|
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Xword Xword;
|
typedef typename TElfITypes::Xword Xword;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
@@ -216,13 +203,11 @@ struct Phdr
|
|||||||
|
|
||||||
# define WANT_PHDR_ENUM 1
|
# define WANT_PHDR_ENUM 1
|
||||||
# include "p_elf_enum.h"
|
# include "p_elf_enum.h"
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
struct Shdr
|
__packed_struct(Shdr)
|
||||||
{
|
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Xword Xword;
|
typedef typename TElfITypes::Xword Xword;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
@@ -241,13 +226,11 @@ struct Shdr
|
|||||||
|
|
||||||
# define WANT_SHDR_ENUM 1
|
# define WANT_SHDR_ENUM 1
|
||||||
# include "p_elf_enum.h"
|
# include "p_elf_enum.h"
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
struct Sym
|
__packed_struct(Sym)
|
||||||
{
|
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Xword Xword;
|
typedef typename TElfITypes::Xword Xword;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
@@ -266,8 +249,7 @@ struct Sym
|
|||||||
static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); }
|
static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); }
|
||||||
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
||||||
static unsigned char make_st_info(unsigned bind, unsigned type) { return (bind<<4) + (0xf & type); }
|
static unsigned char make_st_info(unsigned bind, unsigned type) { return (bind<<4) + (0xf & type); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace N_Elf64
|
} // namespace N_Elf64
|
||||||
|
|||||||
+2
-1
@@ -51,7 +51,8 @@ PackExe::PackExe(InputFile *f) :
|
|||||||
super(f)
|
super(f)
|
||||||
{
|
{
|
||||||
bele = &N_BELE_RTP::le_policy;
|
bele = &N_BELE_RTP::le_policy;
|
||||||
COMPILE_TIME_ASSERT(sizeof(exe_header_t) == 32);
|
COMPILE_TIME_ASSERT(sizeof(exe_header_t) == 32)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(exe_header_t)
|
||||||
ih_exesize = ih_imagesize = ih_overlay = 0;
|
ih_exesize = ih_imagesize = ih_overlay = 0;
|
||||||
stack_for_lzma = 0;
|
stack_for_lzma = 0;
|
||||||
use_clear_dirty_stack = false;
|
use_clear_dirty_stack = false;
|
||||||
|
|||||||
+2
-4
@@ -74,8 +74,7 @@ protected:
|
|||||||
virtual Linker* newLinker() const;
|
virtual Linker* newLinker() const;
|
||||||
void addLoaderEpilogue(int flag);
|
void addLoaderEpilogue(int flag);
|
||||||
|
|
||||||
struct exe_header_t
|
__packed_struct(exe_header_t)
|
||||||
{
|
|
||||||
LE16 ident;
|
LE16 ident;
|
||||||
LE16 m512;
|
LE16 m512;
|
||||||
LE16 p512;
|
LE16 p512;
|
||||||
@@ -91,8 +90,7 @@ protected:
|
|||||||
LE16 relocoffs;
|
LE16 relocoffs;
|
||||||
char __[2]; // overlnum
|
char __[2]; // overlnum
|
||||||
LE32 firstreloc;
|
LE32 firstreloc;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
exe_header_t ih, oh;
|
exe_header_t ih, oh;
|
||||||
|
|
||||||
|
|||||||
+21
-21
@@ -846,14 +846,14 @@ bool PackLinuxElf32::canPack()
|
|||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
unsigned char buf[sizeof(Elf32_Ehdr) + 14*sizeof(Elf32_Phdr)];
|
unsigned char buf[sizeof(Elf32_Ehdr) + 14*sizeof(Elf32_Phdr)];
|
||||||
struct { Elf32_Ehdr ehdr; Elf32_Phdr phdr; } e;
|
//struct { U_Elf32_Ehdr ehdr; U_Elf32_Phdr phdr; } e;
|
||||||
} u;
|
} u;
|
||||||
COMPILE_TIME_ASSERT(sizeof(u.buf) <= 512);
|
COMPILE_TIME_ASSERT(sizeof(u.buf) <= 512);
|
||||||
|
|
||||||
fi->seek(0, SEEK_SET);
|
fi->seek(0, SEEK_SET);
|
||||||
fi->readx(u.buf, sizeof(u.buf));
|
fi->readx(u.buf, sizeof(u.buf));
|
||||||
fi->seek(0, SEEK_SET);
|
fi->seek(0, SEEK_SET);
|
||||||
Elf32_Ehdr const *const ehdr = &u.e.ehdr;
|
Elf32_Ehdr const *const ehdr = (Elf32_Ehdr *) u.buf;
|
||||||
|
|
||||||
// now check the ELF header
|
// now check the ELF header
|
||||||
if (checkEhdr(ehdr) != 0)
|
if (checkEhdr(ehdr) != 0)
|
||||||
@@ -897,7 +897,7 @@ bool PackLinuxElf32::canPack()
|
|||||||
&& 1==get_te32(¬e.type)
|
&& 1==get_te32(¬e.type)
|
||||||
&& 0==note.end
|
&& 0==note.end
|
||||||
&& (1+ strlen(osabi_note))==get_te32(¬e.namesz)
|
&& (1+ strlen(osabi_note))==get_te32(¬e.namesz)
|
||||||
&& 0==strcmp(osabi_note, (char const *)¬e.text)
|
&& 0==strcmp(osabi_note, (char const *)note.text)
|
||||||
) {
|
) {
|
||||||
osabi0 = ei_osabi; // Specified by PT_NOTE.
|
osabi0 = ei_osabi; // Specified by PT_NOTE.
|
||||||
}
|
}
|
||||||
@@ -937,7 +937,7 @@ bool PackLinuxElf32::canPack()
|
|||||||
file_image = new char[file_size];
|
file_image = new char[file_size];
|
||||||
fi->seek(0, SEEK_SET);
|
fi->seek(0, SEEK_SET);
|
||||||
fi->readx(file_image, file_size);
|
fi->readx(file_image, file_size);
|
||||||
ehdri= *ehdr;
|
memcpy(&ehdri, ehdr, sizeof(Elf32_Ehdr));
|
||||||
phdri= (Elf32_Phdr *)(e_phoff + file_image); // do not free() !!
|
phdri= (Elf32_Phdr *)(e_phoff + file_image); // do not free() !!
|
||||||
shdri= (Elf32_Shdr *)(e_shoff + file_image); // do not free() !!
|
shdri= (Elf32_Shdr *)(e_shoff + file_image); // do not free() !!
|
||||||
|
|
||||||
@@ -1007,13 +1007,13 @@ PackLinuxElf64amd::canPack()
|
|||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
unsigned char buf[sizeof(Elf64_Ehdr) + 14*sizeof(Elf64_Phdr)];
|
unsigned char buf[sizeof(Elf64_Ehdr) + 14*sizeof(Elf64_Phdr)];
|
||||||
struct { Elf64_Ehdr ehdr; Elf64_Phdr phdr; } e;
|
//struct { Elf64_Ehdr ehdr; Elf64_Phdr phdr; } e;
|
||||||
} u;
|
} u;
|
||||||
COMPILE_TIME_ASSERT(sizeof(u) <= 1024);
|
COMPILE_TIME_ASSERT(sizeof(u) <= 1024);
|
||||||
|
|
||||||
fi->readx(u.buf, sizeof(u.buf));
|
fi->readx(u.buf, sizeof(u.buf));
|
||||||
fi->seek(0, SEEK_SET);
|
fi->seek(0, SEEK_SET);
|
||||||
Elf64_Ehdr const *const ehdr = &u.e.ehdr;
|
Elf64_Ehdr const *const ehdr = (Elf64_Ehdr *) u.buf;
|
||||||
|
|
||||||
// now check the ELF header
|
// now check the ELF header
|
||||||
if (checkEhdr(ehdr) != 0)
|
if (checkEhdr(ehdr) != 0)
|
||||||
@@ -1895,11 +1895,11 @@ void PackLinuxElf32::unpack(OutputFile *fo)
|
|||||||
{
|
{
|
||||||
#define MAX_ELF_HDR 512
|
#define MAX_ELF_HDR 512
|
||||||
union {
|
union {
|
||||||
char buf[MAX_ELF_HDR];
|
unsigned char buf[MAX_ELF_HDR];
|
||||||
struct { Elf32_Ehdr ehdr; Elf32_Phdr phdr; } e;
|
//struct { Elf32_Ehdr ehdr; Elf32_Phdr phdr; } e;
|
||||||
} u;
|
} u;
|
||||||
Elf32_Ehdr *const ehdr = &u.e.ehdr;
|
Elf32_Ehdr *const ehdr = (Elf32_Ehdr *) u.buf;
|
||||||
Elf32_Phdr const *phdr = &u.e.phdr;
|
Elf32_Phdr const *phdr = (Elf32_Phdr *) (u.buf + sizeof(*ehdr));
|
||||||
|
|
||||||
unsigned szb_info = sizeof(b_info);
|
unsigned szb_info = sizeof(b_info);
|
||||||
{
|
{
|
||||||
@@ -1958,7 +1958,7 @@ void PackLinuxElf32::unpack(OutputFile *fo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr = &u.e.phdr;
|
phdr = (Elf32_Phdr *) (u.buf + sizeof(*ehdr));
|
||||||
for (unsigned j = 0; j < phnum; ++j) {
|
for (unsigned j = 0; j < phnum; ++j) {
|
||||||
unsigned const size = find_LOAD_gap(phdr, j, phnum);
|
unsigned const size = find_LOAD_gap(phdr, j, phnum);
|
||||||
if (size) {
|
if (size) {
|
||||||
@@ -2003,11 +2003,11 @@ void PackLinuxElf64::unpack(OutputFile *fo)
|
|||||||
{
|
{
|
||||||
#define MAX_ELF_HDR 1024
|
#define MAX_ELF_HDR 1024
|
||||||
union {
|
union {
|
||||||
char buf[MAX_ELF_HDR];
|
unsigned char buf[MAX_ELF_HDR];
|
||||||
struct { Elf64_Ehdr ehdr; Elf64_Phdr phdr; } e;
|
//struct { Elf64_Ehdr ehdr; Elf64_Phdr phdr; } e;
|
||||||
} u;
|
} u;
|
||||||
Elf64_Ehdr *const ehdr = &u.e.ehdr;
|
Elf64_Ehdr *const ehdr = (Elf64_Ehdr *) u.buf;
|
||||||
Elf64_Phdr const *phdr = &u.e.phdr;
|
Elf64_Phdr const *phdr = (Elf64_Phdr *) (u.buf + sizeof(*ehdr));
|
||||||
|
|
||||||
unsigned szb_info = sizeof(b_info);
|
unsigned szb_info = sizeof(b_info);
|
||||||
{
|
{
|
||||||
@@ -2066,7 +2066,7 @@ void PackLinuxElf64::unpack(OutputFile *fo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr = &u.e.phdr;
|
phdr = (Elf64_Phdr *) (u.buf + sizeof(*ehdr));
|
||||||
for (unsigned j = 0; j < phnum; ++j) {
|
for (unsigned j = 0; j < phnum; ++j) {
|
||||||
unsigned const size = find_LOAD_gap(phdr, j, phnum);
|
unsigned const size = find_LOAD_gap(phdr, j, phnum);
|
||||||
if (size) {
|
if (size) {
|
||||||
@@ -2367,11 +2367,11 @@ void PackLinuxElf32x86::unpack(OutputFile *fo)
|
|||||||
{
|
{
|
||||||
#define MAX_ELF_HDR 512
|
#define MAX_ELF_HDR 512
|
||||||
union {
|
union {
|
||||||
char buf[MAX_ELF_HDR];
|
unsigned char buf[MAX_ELF_HDR];
|
||||||
struct { Elf32_Ehdr ehdr; Elf32_Phdr phdr; } e;
|
//struct { Elf32_Ehdr ehdr; Elf32_Phdr phdr; } e;
|
||||||
} u;
|
} u;
|
||||||
Elf32_Ehdr *const ehdr = &u.e.ehdr;
|
Elf32_Ehdr *const ehdr = (Elf32_Ehdr *) u.buf;
|
||||||
Elf32_Phdr const *phdr = &u.e.phdr;
|
Elf32_Phdr const *phdr = (Elf32_Phdr *) (u.buf + sizeof(*ehdr));
|
||||||
|
|
||||||
unsigned szb_info = sizeof(b_info);
|
unsigned szb_info = sizeof(b_info);
|
||||||
{
|
{
|
||||||
@@ -2430,7 +2430,7 @@ void PackLinuxElf32x86::unpack(OutputFile *fo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr = &u.e.phdr;
|
phdr = (Elf32_Phdr *) (u.buf + sizeof(*ehdr));
|
||||||
for (unsigned j = 0; j < phnum; ++j) {
|
for (unsigned j = 0; j < phnum; ++j) {
|
||||||
unsigned const size = find_LOAD_gap(phdr, j, phnum);
|
unsigned const size = find_LOAD_gap(phdr, j, phnum);
|
||||||
if (size) {
|
if (size) {
|
||||||
|
|||||||
+5
-5
@@ -529,13 +529,13 @@ bool PackLinuxI386::canPack()
|
|||||||
unsigned const e_phnum = get_te16(&ehdr.e_phnum);
|
unsigned const e_phnum = get_te16(&ehdr.e_phnum);
|
||||||
if (e_phnum<=(512/sizeof(Elf32_Phdr))) {
|
if (e_phnum<=(512/sizeof(Elf32_Phdr))) {
|
||||||
union {
|
union {
|
||||||
char buf2[512];
|
unsigned char buf2[512];
|
||||||
Elf32_Phdr phdr;
|
//Elf32_Phdr phdr;
|
||||||
} u;
|
} u;
|
||||||
fi->seek(get_te32(&ehdr.e_phoff), SEEK_SET);
|
fi->seek(get_te32(&ehdr.e_phoff), SEEK_SET);
|
||||||
fi->readx(u.buf2, sizeof(u.buf2));
|
fi->readx(u.buf2, sizeof(u.buf2));
|
||||||
fi->seek(0, SEEK_SET);
|
fi->seek(0, SEEK_SET);
|
||||||
Elf32_Phdr const *phdr = &u.phdr;
|
Elf32_Phdr const *phdr = (Elf32_Phdr *) u.buf2;
|
||||||
for (unsigned j=0; j < e_phnum; ++phdr, ++j) {
|
for (unsigned j=0; j < e_phnum; ++phdr, ++j) {
|
||||||
if (phdr->PT_NOTE == get_te32(&phdr->p_type)) {
|
if (phdr->PT_NOTE == get_te32(&phdr->p_type)) {
|
||||||
unsigned const offset = get_te32(&phdr->p_offset);
|
unsigned const offset = get_te32(&phdr->p_offset);
|
||||||
@@ -546,11 +546,11 @@ bool PackLinuxI386::canPack()
|
|||||||
if (4==get_te32(¬e.descsz)
|
if (4==get_te32(¬e.descsz)
|
||||||
&& 1==get_te32(¬e.type)
|
&& 1==get_te32(¬e.type)
|
||||||
&& 0==note.end ) {
|
&& 0==note.end ) {
|
||||||
if (0==strcmp("NetBSD", (char const *)¬e.text)) {
|
if (0==strcmp("NetBSD", (char const *)note.text)) {
|
||||||
ei_osabi = Elf32_Ehdr::ELFOSABI_NETBSD;
|
ei_osabi = Elf32_Ehdr::ELFOSABI_NETBSD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (0==strcmp("OpenBSD", (char const *)¬e.text)) {
|
if (0==strcmp("OpenBSD", (char const *)note.text)) {
|
||||||
ei_osabi = Elf32_Ehdr::ELFOSABI_OPENBSD;
|
ei_osabi = Elf32_Ehdr::ELFOSABI_OPENBSD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -198,11 +198,11 @@ void PackLinuxElf32x86interp::unpack(OutputFile *fo)
|
|||||||
{
|
{
|
||||||
#define MAX_INTERP_HDR 512
|
#define MAX_INTERP_HDR 512
|
||||||
union {
|
union {
|
||||||
char buf[MAX_INTERP_HDR];
|
unsigned char buf[MAX_INTERP_HDR];
|
||||||
struct { Elf32_Ehdr ehdr; Elf32_Phdr phdr; } e;
|
//struct { Elf32_Ehdr ehdr; Elf32_Phdr phdr; } e;
|
||||||
} u;
|
} u;
|
||||||
Elf32_Ehdr *const ehdr = &u.e.ehdr;
|
Elf32_Ehdr *const ehdr = (Elf32_Ehdr *) u.buf;
|
||||||
Elf32_Phdr const *phdr = &u.e.phdr;
|
Elf32_Phdr const *phdr = (Elf32_Phdr *) (u.buf + sizeof(*ehdr));
|
||||||
|
|
||||||
unsigned szb_info = sizeof(b_info);
|
unsigned szb_info = sizeof(b_info);
|
||||||
{
|
{
|
||||||
|
|||||||
+4
-4
@@ -57,7 +57,7 @@ PackMachBase<T>::PackMachBase(InputFile *f, unsigned cputype, unsigned flavor,
|
|||||||
n_segment(0), rawmseg(NULL), msegcmd(NULL)
|
n_segment(0), rawmseg(NULL), msegcmd(NULL)
|
||||||
{
|
{
|
||||||
MachClass::compileTimeAssertions();
|
MachClass::compileTimeAssertions();
|
||||||
bele = N_BELE_CTP::getRTP<BeLePolicy>();
|
bele = N_BELE_CTP::getRTP((const BeLePolicy*) NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -574,7 +574,7 @@ void PackMachBase<T>::pack1(OutputFile *const fo, Filter &/*ft*/) // generate e
|
|||||||
|
|
||||||
segcmdo.cmd = Mach_segment_command::LC_SEGMENT;
|
segcmdo.cmd = Mach_segment_command::LC_SEGMENT;
|
||||||
segcmdo.cmdsize = sizeof(segcmdo);
|
segcmdo.cmdsize = sizeof(segcmdo);
|
||||||
strncpy((char *)&segcmdo.segname, "__TEXT", sizeof(segcmdo.segname));
|
strncpy((char *)segcmdo.segname, "__TEXT", sizeof(segcmdo.segname));
|
||||||
segcmdo.vmaddr = PAGE_MASK & (~PAGE_MASK +
|
segcmdo.vmaddr = PAGE_MASK & (~PAGE_MASK +
|
||||||
msegcmd[n_segment -1].vmsize + msegcmd[n_segment -1].vmaddr );
|
msegcmd[n_segment -1].vmsize + msegcmd[n_segment -1].vmaddr );
|
||||||
segcmdo.vmsize = 0; // adjust later
|
segcmdo.vmsize = 0; // adjust later
|
||||||
@@ -683,10 +683,10 @@ bool PackMachBase<T>::canPack()
|
|||||||
)
|
)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
rawmseg = (Mach_segment_command *)new char[mhdri.sizeofcmds];
|
rawmseg = (Mach_segment_command *)new char[(unsigned) mhdri.sizeofcmds];
|
||||||
fi->readx(rawmseg, mhdri.sizeofcmds);
|
fi->readx(rawmseg, mhdri.sizeofcmds);
|
||||||
|
|
||||||
msegcmd = new Mach_segment_command[mhdri.ncmds];
|
msegcmd = new Mach_segment_command[(unsigned) mhdri.ncmds];
|
||||||
unsigned char *ptr = (unsigned char *)rawmseg;
|
unsigned char *ptr = (unsigned char *)rawmseg;
|
||||||
for (unsigned j= 0; j < mhdri.ncmds; ++j) {
|
for (unsigned j= 0; j < mhdri.ncmds; ++j) {
|
||||||
msegcmd[j] = *(Mach_segment_command *)ptr;
|
msegcmd[j] = *(Mach_segment_command *)ptr;
|
||||||
|
|||||||
+45
-69
@@ -30,24 +30,22 @@
|
|||||||
#define __UPX_P_MACHO_H
|
#define __UPX_P_MACHO_H
|
||||||
|
|
||||||
|
|
||||||
struct Mach_fat_header {
|
__packed_struct(Mach_fat_header)
|
||||||
BE32 magic;
|
BE32 magic;
|
||||||
enum { // note conflict with java bytecode PackLinuxI386
|
enum { // note conflict with java bytecode PackLinuxI386
|
||||||
FAT_MAGIC = 0xcafebabe,
|
FAT_MAGIC = 0xcafebabe,
|
||||||
FAT_MAGIC_SWAB = 0xbebafeca
|
FAT_MAGIC_SWAB = 0xbebafeca
|
||||||
};
|
};
|
||||||
BE32 nfat_arch; // Number of Mach_fat_arch which follow.
|
BE32 nfat_arch; // Number of Mach_fat_arch which follow.
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct Mach_fat_arch {
|
__packed_struct(Mach_fat_arch)
|
||||||
BE32 cputype;
|
BE32 cputype;
|
||||||
BE32 cpusubtype;
|
BE32 cpusubtype;
|
||||||
BE32 offset;
|
BE32 offset;
|
||||||
BE32 size;
|
BE32 size;
|
||||||
BE32 align; /* shift count; log base 2 */
|
BE32 align; /* shift count; log base 2 */
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -68,8 +66,7 @@ struct MachITypes
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
struct Mach_header
|
__packed_struct(Mach_header)
|
||||||
{
|
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word magic;
|
Word magic;
|
||||||
@@ -81,12 +78,11 @@ struct Mach_header
|
|||||||
Word flags;
|
Word flags;
|
||||||
#define WANT_MACH_HEADER_ENUM 1
|
#define WANT_MACH_HEADER_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
struct Mach_header64
|
__packed_struct(Mach_header64)
|
||||||
{ // only difference is padding to 0 mod 8
|
// only difference is padding to 0 mod 8
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word magic;
|
Word magic;
|
||||||
@@ -99,12 +95,10 @@ struct Mach_header64
|
|||||||
Word reserved; // pad to 0 mod 8
|
Word reserved; // pad to 0 mod 8
|
||||||
#define WANT_MACH_HEADER_ENUM 1
|
#define WANT_MACH_HEADER_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
struct Mach_segment_command
|
__packed_struct(Mach_segment_command)
|
||||||
{
|
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Addr Addr;
|
typedef typename TMachITypes::Addr Addr;
|
||||||
typedef typename TMachITypes::Off Off;
|
typedef typename TMachITypes::Off Off;
|
||||||
@@ -122,12 +116,10 @@ struct Mach_segment_command
|
|||||||
Word flags;
|
Word flags;
|
||||||
#define WANT_MACH_SEGMENT_ENUM 1
|
#define WANT_MACH_SEGMENT_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
struct Mach_section_command
|
__packed_struct(Mach_section_command)
|
||||||
{
|
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Addr Addr;
|
typedef typename TMachITypes::Addr Addr;
|
||||||
typedef typename TMachITypes::Off Off;
|
typedef typename TMachITypes::Off Off;
|
||||||
@@ -145,12 +137,10 @@ struct Mach_section_command
|
|||||||
Word reserved2;
|
Word reserved2;
|
||||||
#define WANT_MACH_SECTION_ENUM 1
|
#define WANT_MACH_SECTION_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
struct Mach_ppc_thread_state
|
__packed_struct(Mach_ppc_thread_state)
|
||||||
{
|
|
||||||
typedef typename TMachITypes::Addr Addr;
|
typedef typename TMachITypes::Addr Addr;
|
||||||
|
|
||||||
Addr srr0; /* Instruction address register (PC; entry addr) */
|
Addr srr0; /* Instruction address register (PC; entry addr) */
|
||||||
@@ -167,12 +157,10 @@ struct Mach_ppc_thread_state
|
|||||||
Addr mq; /* MQ register (601 only) */
|
Addr mq; /* MQ register (601 only) */
|
||||||
|
|
||||||
Addr vrsave; /* Vector Save Register */
|
Addr vrsave; /* Vector Save Register */
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
struct Mach_i386_thread_state
|
__packed_struct(Mach_i386_thread_state)
|
||||||
{
|
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word eax, ebx, ecx, edx;
|
Word eax, ebx, ecx, edx;
|
||||||
@@ -181,12 +169,10 @@ struct Mach_i386_thread_state
|
|||||||
Word eflags;
|
Word eflags;
|
||||||
Word eip, cs;
|
Word eip, cs;
|
||||||
Word ds, es, fs, gs;
|
Word ds, es, fs, gs;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
struct Mach_i386_new_thread_state
|
__packed_struct(Mach_i386_new_thread_state)
|
||||||
{
|
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word gs, fs, es, ds;
|
Word gs, fs, es, ds;
|
||||||
@@ -194,12 +180,10 @@ struct Mach_i386_new_thread_state
|
|||||||
Word ebx, edx, ecx, eax;
|
Word ebx, edx, ecx, eax;
|
||||||
Word eip, cs, efl;
|
Word eip, cs, efl;
|
||||||
Word uesp, ss;
|
Word uesp, ss;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
struct Mach_ARM_thread_state
|
__packed_struct(Mach_ARM_thread_state)
|
||||||
{
|
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word r[13]; // r0-r12
|
Word r[13]; // r0-r12
|
||||||
@@ -207,8 +191,7 @@ struct Mach_ARM_thread_state
|
|||||||
Word lr; // r14
|
Word lr; // r14
|
||||||
Word pc; // r15
|
Word pc; // r15
|
||||||
Word cpsr;
|
Word cpsr;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
} // namespace N_Mach
|
} // namespace N_Mach
|
||||||
|
|
||||||
@@ -219,8 +202,7 @@ namespace N_Mach32 {
|
|||||||
namespace N_Mach64 {
|
namespace N_Mach64 {
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
struct Mach_ppc_thread_state64
|
__packed_struct(Mach_ppc_thread_state64)
|
||||||
{
|
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Xword Xword;
|
typedef typename TMachITypes::Xword Xword;
|
||||||
|
|
||||||
@@ -237,8 +219,7 @@ struct Mach_ppc_thread_state64
|
|||||||
Xword ctr; /* Count register */
|
Xword ctr; /* Count register */
|
||||||
|
|
||||||
Word vrsave; /* Vector Save Register */
|
Word vrsave; /* Vector Save Register */
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
} // namespace N_Mach64
|
} // namespace N_Mach64
|
||||||
|
|
||||||
@@ -395,30 +376,28 @@ protected:
|
|||||||
Mach_header mhdro;
|
Mach_header mhdro;
|
||||||
Mach_segment_command segcmdo;
|
Mach_segment_command segcmdo;
|
||||||
|
|
||||||
struct b_info { // 12-byte header before each compressed block
|
__packed_struct(b_info) // 12-byte header before each compressed block
|
||||||
TE32 sz_unc; // uncompressed_size
|
TE32 sz_unc; // uncompressed_size
|
||||||
TE32 sz_cpr; // compressed_size
|
TE32 sz_cpr; // compressed_size
|
||||||
unsigned char b_method; // compression algorithm
|
unsigned char b_method; // compression algorithm
|
||||||
unsigned char b_ftid; // filter id
|
unsigned char b_ftid; // filter id
|
||||||
unsigned char b_cto8; // filter parameter
|
unsigned char b_cto8; // filter parameter
|
||||||
unsigned char b_unused;
|
unsigned char b_unused;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
struct l_info { // 12-byte trailer in header for loader
|
__packed_struct(l_info) // 12-byte trailer in header for loader
|
||||||
TE32 l_checksum;
|
TE32 l_checksum;
|
||||||
LE32 l_magic;
|
LE32 l_magic;
|
||||||
TE16 l_lsize;
|
TE16 l_lsize;
|
||||||
unsigned char l_version;
|
unsigned char l_version;
|
||||||
unsigned char l_format;
|
unsigned char l_format;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct p_info { // 12-byte packed program header
|
__packed_struct(p_info) // 12-byte packed program header
|
||||||
TE32 p_progid;
|
TE32 p_progid;
|
||||||
TE32 p_filesize;
|
TE32 p_filesize;
|
||||||
TE32 p_blocksize;
|
TE32 p_blocksize;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct l_info linfo;
|
struct l_info linfo;
|
||||||
|
|
||||||
@@ -456,8 +435,7 @@ protected:
|
|||||||
virtual Linker* newLinker() const;
|
virtual Linker* newLinker() const;
|
||||||
virtual void buildLoader(const Filter *ft);
|
virtual void buildLoader(const Filter *ft);
|
||||||
|
|
||||||
struct Mach_thread_command
|
__packed_struct(Mach_thread_command)
|
||||||
{
|
|
||||||
BE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
BE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
||||||
BE32 cmdsize; /* total size of this command */
|
BE32 cmdsize; /* total size of this command */
|
||||||
BE32 flavor;
|
BE32 flavor;
|
||||||
@@ -465,8 +443,8 @@ protected:
|
|||||||
Mach_ppc_thread_state state;
|
Mach_ppc_thread_state state;
|
||||||
#define WANT_MACH_THREAD_ENUM
|
#define WANT_MACH_THREAD_ENUM
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
Mach_thread_command threado;
|
Mach_thread_command threado;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -492,8 +470,7 @@ protected:
|
|||||||
virtual void buildLoader(const Filter *ft);
|
virtual void buildLoader(const Filter *ft);
|
||||||
virtual void addStubEntrySections(Filter const *);
|
virtual void addStubEntrySections(Filter const *);
|
||||||
|
|
||||||
struct Mach_thread_command
|
__packed_struct(Mach_thread_command)
|
||||||
{
|
|
||||||
LE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
LE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
||||||
LE32 cmdsize; /* total size of this command */
|
LE32 cmdsize; /* total size of this command */
|
||||||
LE32 flavor;
|
LE32 flavor;
|
||||||
@@ -501,8 +478,8 @@ protected:
|
|||||||
Mach_i386_thread_state state;
|
Mach_i386_thread_state state;
|
||||||
#define WANT_MACH_THREAD_ENUM
|
#define WANT_MACH_THREAD_ENUM
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
Mach_thread_command threado;
|
Mach_thread_command threado;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -529,8 +506,7 @@ protected:
|
|||||||
virtual void buildLoader(const Filter *ft);
|
virtual void buildLoader(const Filter *ft);
|
||||||
virtual void addStubEntrySections(Filter const *);
|
virtual void addStubEntrySections(Filter const *);
|
||||||
|
|
||||||
struct Mach_thread_command
|
__packed_struct(Mach_thread_command)
|
||||||
{
|
|
||||||
LE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
LE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
||||||
LE32 cmdsize; /* total size of this command */
|
LE32 cmdsize; /* total size of this command */
|
||||||
LE32 flavor;
|
LE32 flavor;
|
||||||
@@ -538,8 +514,8 @@ protected:
|
|||||||
Mach_ARM_thread_state state;
|
Mach_ARM_thread_state state;
|
||||||
#define WANT_MACH_THREAD_ENUM
|
#define WANT_MACH_THREAD_ENUM
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
Mach_thread_command threado;
|
Mach_thread_command threado;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -577,11 +553,11 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
enum { N_FAT_ARCH = 5 };
|
enum { N_FAT_ARCH = 5 };
|
||||||
protected:
|
protected:
|
||||||
struct Fat_head {
|
__packed_struct(Fat_head)
|
||||||
struct Mach_fat_header fat;
|
struct Mach_fat_header fat;
|
||||||
struct Mach_fat_arch arch[N_FAT_ARCH];
|
struct Mach_fat_arch arch[N_FAT_ARCH];
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
Fat_head fat_head;
|
Fat_head fat_head;
|
||||||
|
|
||||||
// UI handler
|
// UI handler
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 2007 John F. Reiser
|
Copyright (C) 2007-2007 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+2
-2
@@ -127,8 +127,8 @@ int PackPs1::readFileHeader()
|
|||||||
{
|
{
|
||||||
fi->seek(0, SEEK_SET);
|
fi->seek(0, SEEK_SET);
|
||||||
fi->readx(&ih, sizeof(ih));
|
fi->readx(&ih, sizeof(ih));
|
||||||
if (memcmp(&ih.id, "PS-X EXE", 8) != 0 &&
|
if (memcmp(&ih.id[0], "PS-X EXE", 8) != 0 &&
|
||||||
memcmp(&ih.id, "EXE X-SP", 8) != 0)
|
memcmp(&ih.id[0], "EXE X-SP", 8) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (ih.text != 0 || ih.data != 0)
|
if (ih.text != 0 || ih.data != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+2
-2
@@ -64,7 +64,7 @@ PackVmlinuxBase<T>::PackVmlinuxBase(InputFile *f,
|
|||||||
n_ptload(0), phdri(NULL), shdri(NULL), shstrtab(NULL)
|
n_ptload(0), phdri(NULL), shdri(NULL), shstrtab(NULL)
|
||||||
{
|
{
|
||||||
ElfClass::compileTimeAssertions();
|
ElfClass::compileTimeAssertions();
|
||||||
bele = N_BELE_CTP::getRTP<BeLePolicy>();
|
bele = N_BELE_CTP::getRTP((const BeLePolicy*) NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -628,7 +628,7 @@ void prep_kernel(unsigned long a1, unsigned long a2)
|
|||||||
|
|
||||||
fo->seek(0, SEEK_SET);
|
fo->seek(0, SEEK_SET);
|
||||||
fo->write(&ehdro, sizeof(ehdro));
|
fo->write(&ehdro, sizeof(ehdro));
|
||||||
fo->write(&shdro, sizeof(shdro));
|
fo->write(&shdro[0], sizeof(shdro));
|
||||||
if (Ehdr::EM_PPC==my_e_machine) {
|
if (Ehdr::EM_PPC==my_e_machine) {
|
||||||
fo->seek(sizeof(unsigned), SEEK_CUR);
|
fo->seek(sizeof(unsigned), SEEK_CUR);
|
||||||
set_be32(&ppc32_extra, ppc32_extra - 2*sizeof(unsigned) + txt_c_len);
|
set_be32(&ppc32_extra, ppc32_extra - 2*sizeof(unsigned) + txt_c_len);
|
||||||
|
|||||||
+1
-1
@@ -744,7 +744,7 @@ int PackVmlinuzARMEL::readFileHeader()
|
|||||||
{
|
{
|
||||||
unsigned int hdr[8];
|
unsigned int hdr[8];
|
||||||
|
|
||||||
fi->readx(&hdr, sizeof(hdr));
|
fi->readx(hdr, sizeof(hdr));
|
||||||
for (int j=0; j < 8; ++j) {
|
for (int j=0; j < 8; ++j) {
|
||||||
if (0xe1a00000!=get_te32(&hdr[j])) {
|
if (0xe1a00000!=get_te32(&hdr[j])) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+1
-1
@@ -164,7 +164,7 @@ int PackW32Pe::readFileHeader()
|
|||||||
char buf[6];
|
char buf[6];
|
||||||
fi->seek(0x200, SEEK_SET);
|
fi->seek(0x200, SEEK_SET);
|
||||||
fi->readx(buf, 6);
|
fi->readx(buf, 6);
|
||||||
isrtm = memcmp(&buf, "32STUB" ,6) == 0;
|
isrtm = memcmp(buf, "32STUB" ,6) == 0;
|
||||||
return super::readFileHeader();
|
return super::readFileHeader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -485,7 +485,7 @@ void PackWcle::pack(OutputFile *fo)
|
|||||||
const unsigned text_vaddr = IOT(ih.init_cs_object-1,my_base_address);
|
const unsigned text_vaddr = IOT(ih.init_cs_object-1,my_base_address);
|
||||||
|
|
||||||
// attach some useful data at the end of preprocessed fixups
|
// attach some useful data at the end of preprocessed fixups
|
||||||
ifixups[sofixups++] = (unsigned char) ih.automatic_data_object;
|
ifixups[sofixups++] = (unsigned char) (ih.automatic_data_object & 0xff);
|
||||||
unsigned ic = objects*sizeof(*iobject_table);
|
unsigned ic = objects*sizeof(*iobject_table);
|
||||||
memcpy(ifixups+sofixups,iobject_desc,ic);
|
memcpy(ifixups+sofixups,iobject_desc,ic);
|
||||||
iobject_desc.dealloc();
|
iobject_desc.dealloc();
|
||||||
|
|||||||
+8
-8
@@ -287,21 +287,21 @@ Packer* PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const optio
|
|||||||
|
|
||||||
Packer *PackMaster::getPacker(InputFile *f)
|
Packer *PackMaster::getPacker(InputFile *f)
|
||||||
{
|
{
|
||||||
Packer *p = visitAllPackers(try_pack, f, opt, f);
|
Packer *pp = visitAllPackers(try_pack, f, opt, f);
|
||||||
if (!p)
|
if (!pp)
|
||||||
throwUnknownExecutableFormat();
|
throwUnknownExecutableFormat();
|
||||||
p->assertPacker();
|
pp->assertPacker();
|
||||||
return p;
|
return pp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Packer *PackMaster::getUnpacker(InputFile *f)
|
Packer *PackMaster::getUnpacker(InputFile *f)
|
||||||
{
|
{
|
||||||
Packer *p = visitAllPackers(try_unpack, f, opt, f);
|
Packer *pp = visitAllPackers(try_unpack, f, opt, f);
|
||||||
if (!p)
|
if (!pp)
|
||||||
throwNotPacked();
|
throwNotPacked();
|
||||||
p->assertPacker();
|
pp->assertPacker();
|
||||||
return p;
|
return pp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+37
-40
@@ -106,7 +106,7 @@ PeFile::PeFile(InputFile *f) : super(f)
|
|||||||
COMPILE_TIME_ASSERT_ALIGNED1(pe_header_t)
|
COMPILE_TIME_ASSERT_ALIGNED1(pe_header_t)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(pe_header_t::ddirs_t)
|
COMPILE_TIME_ASSERT_ALIGNED1(pe_header_t::ddirs_t)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(pe_section_t)
|
COMPILE_TIME_ASSERT_ALIGNED1(pe_section_t)
|
||||||
COMPILE_TIME_ASSERT(RT_LAST == TABLESIZE(opt->win32_pe.compress_rt));
|
COMPILE_TIME_ASSERT(RT_LAST == TABLESIZE(opt->win32_pe.compress_rt))
|
||||||
|
|
||||||
isection = NULL;
|
isection = NULL;
|
||||||
oimport = NULL;
|
oimport = NULL;
|
||||||
@@ -158,8 +158,7 @@ bool PeFile::testUnpackVersion(int version) const
|
|||||||
|
|
||||||
int PeFile::readFileHeader()
|
int PeFile::readFileHeader()
|
||||||
{
|
{
|
||||||
struct exe_header_t
|
__packed_struct(exe_header_t)
|
||||||
{
|
|
||||||
LE16 mz;
|
LE16 mz;
|
||||||
LE16 m512;
|
LE16 m512;
|
||||||
LE16 p512;
|
LE16 p512;
|
||||||
@@ -167,9 +166,12 @@ int PeFile::readFileHeader()
|
|||||||
LE16 relocoffs;
|
LE16 relocoffs;
|
||||||
char __[34];
|
char __[34];
|
||||||
LE32 nexepos;
|
LE32 nexepos;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
COMPILE_TIME_ASSERT(sizeof(exe_header_t) == 64);
|
COMPILE_TIME_ASSERT(sizeof(exe_header_t) == 64)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(exe_header_t)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(((exe_header_t*)0)->_) == 18)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(((exe_header_t*)0)->__) == 34)
|
||||||
|
|
||||||
exe_header_t h;
|
exe_header_t h;
|
||||||
int ic;
|
int ic;
|
||||||
@@ -286,12 +288,10 @@ void PeFile::Interval::dump() const
|
|||||||
// relocation handling
|
// relocation handling
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
struct PeFile::Reloc::reloc
|
__packed_struct(PeFile::Reloc::reloc)
|
||||||
{
|
|
||||||
LE32 pagestart;
|
LE32 pagestart;
|
||||||
LE32 size;
|
LE32 size;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
void PeFile::Reloc::newRelocPos(void *p)
|
void PeFile::Reloc::newRelocPos(void *p)
|
||||||
{
|
{
|
||||||
@@ -302,7 +302,8 @@ void PeFile::Reloc::newRelocPos(void *p)
|
|||||||
PeFile::Reloc::Reloc(upx_byte *s,unsigned si) :
|
PeFile::Reloc::Reloc(upx_byte *s,unsigned si) :
|
||||||
start(s), size(si), rel(NULL), rel1(NULL)
|
start(s), size(si), rel(NULL), rel1(NULL)
|
||||||
{
|
{
|
||||||
COMPILE_TIME_ASSERT(sizeof(reloc) == 8);
|
COMPILE_TIME_ASSERT(sizeof(reloc) == 8)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(reloc)
|
||||||
memset(counts,0,sizeof(counts));
|
memset(counts,0,sizeof(counts));
|
||||||
unsigned pos,type;
|
unsigned pos,type;
|
||||||
while (next(pos,type))
|
while (next(pos,type))
|
||||||
@@ -460,18 +461,17 @@ void PeFile::processRelocs() // pass1
|
|||||||
// import handling
|
// import handling
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
struct import_desc
|
__packed_struct(import_desc)
|
||||||
{
|
|
||||||
LE32 oft; // orig first thunk
|
LE32 oft; // orig first thunk
|
||||||
char _[8];
|
char _[8];
|
||||||
LE32 dllname;
|
LE32 dllname;
|
||||||
LE32 iat; // import address table
|
LE32 iat; // import address table
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
void PeFile::processImports(unsigned myimport, unsigned iat_off) // pass 2
|
void PeFile::processImports(unsigned myimport, unsigned iat_off) // pass 2
|
||||||
{
|
{
|
||||||
COMPILE_TIME_ASSERT(sizeof(import_desc) == 20);
|
COMPILE_TIME_ASSERT(sizeof(import_desc) == 20)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(import_desc)
|
||||||
|
|
||||||
// adjust import data
|
// adjust import data
|
||||||
for (import_desc *im = (import_desc*) oimpdlls; im->dllname; im++)
|
for (import_desc *im = (import_desc*) oimpdlls; im->dllname; im++)
|
||||||
@@ -755,7 +755,8 @@ unsigned PeFile::processImports() // pass 1
|
|||||||
|
|
||||||
PeFile::Export::Export(char *_base) : base(_base), iv(_base)
|
PeFile::Export::Export(char *_base) : base(_base), iv(_base)
|
||||||
{
|
{
|
||||||
COMPILE_TIME_ASSERT(sizeof(export_dir_t) == 40);
|
COMPILE_TIME_ASSERT(sizeof(export_dir_t) == 40)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(export_dir_t)
|
||||||
ename = functionptrs = ordinals = NULL;
|
ename = functionptrs = ordinals = NULL;
|
||||||
names = NULL;
|
names = NULL;
|
||||||
memset(&edir,0,sizeof(edir));
|
memset(&edir,0,sizeof(edir));
|
||||||
@@ -903,19 +904,18 @@ void PeFile::processExports(Export *xport,unsigned newoffs) // pass2
|
|||||||
// the virtual memory manager only for pages which are not yet loaded.
|
// the virtual memory manager only for pages which are not yet loaded.
|
||||||
// of course it was impossible to debug this ;-)
|
// of course it was impossible to debug this ;-)
|
||||||
|
|
||||||
struct tls
|
__packed_struct(tls)
|
||||||
{
|
|
||||||
LE32 datastart; // VA tls init data start
|
LE32 datastart; // VA tls init data start
|
||||||
LE32 dataend; // VA tls init data end
|
LE32 dataend; // VA tls init data end
|
||||||
LE32 tlsindex; // VA tls index
|
LE32 tlsindex; // VA tls index
|
||||||
LE32 callbacks; // VA tls callbacks
|
LE32 callbacks; // VA tls callbacks
|
||||||
char _[8]; // zero init, characteristics
|
char _[8]; // zero init, characteristics
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
void PeFile::processTls(Interval *iv) // pass 1
|
void PeFile::processTls(Interval *iv) // pass 1
|
||||||
{
|
{
|
||||||
COMPILE_TIME_ASSERT(sizeof(tls) == 24);
|
COMPILE_TIME_ASSERT(sizeof(tls) == 24)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(tls)
|
||||||
|
|
||||||
if ((sotls = ALIGN_UP(IDSIZE(PEDIR_TLS),4)) == 0)
|
if ((sotls = ALIGN_UP(IDSIZE(PEDIR_TLS),4)) == 0)
|
||||||
return;
|
return;
|
||||||
@@ -997,15 +997,12 @@ void PeFile::processTls(Reloc *rel,const Interval *iv,unsigned newaddr) // pass
|
|||||||
// resource handling
|
// resource handling
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
struct PeFile::Resource::res_dir_entry
|
__packed_struct(PeFile::Resource::res_dir_entry)
|
||||||
{
|
|
||||||
LE32 tnl; // Type | Name | Language id - depending on level
|
LE32 tnl; // Type | Name | Language id - depending on level
|
||||||
LE32 child;
|
LE32 child;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct PeFile::Resource::res_dir
|
__packed_struct(PeFile::Resource::res_dir)
|
||||||
{
|
|
||||||
char _[12]; // flags, timedate, version
|
char _[12]; // flags, timedate, version
|
||||||
LE16 namedentr;
|
LE16 namedentr;
|
||||||
LE16 identr;
|
LE16 identr;
|
||||||
@@ -1014,16 +1011,13 @@ struct PeFile::Resource::res_dir
|
|||||||
res_dir_entry entries[1];
|
res_dir_entry entries[1];
|
||||||
// it's usually safe to assume that every res_dir contains
|
// it's usually safe to assume that every res_dir contains
|
||||||
// at least one res_dir_entry - check() complains otherwise
|
// at least one res_dir_entry - check() complains otherwise
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct PeFile::Resource::res_data
|
__packed_struct(PeFile::Resource::res_data)
|
||||||
{
|
|
||||||
LE32 offset;
|
LE32 offset;
|
||||||
LE32 size;
|
LE32 size;
|
||||||
char _[8]; // codepage, reserved
|
char _[8]; // codepage, reserved
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct PeFile::Resource::upx_rnode
|
struct PeFile::Resource::upx_rnode
|
||||||
{
|
{
|
||||||
@@ -1032,14 +1026,14 @@ struct PeFile::Resource::upx_rnode
|
|||||||
upx_rnode *parent;
|
upx_rnode *parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PeFile::Resource::upx_rbranch : public upx_rnode
|
struct PeFile::Resource::upx_rbranch : public PeFile::Resource::upx_rnode
|
||||||
{
|
{
|
||||||
unsigned nc;
|
unsigned nc;
|
||||||
upx_rnode **children;
|
upx_rnode **children;
|
||||||
res_dir data;
|
res_dir data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PeFile::Resource::upx_rleaf : public upx_rnode
|
struct PeFile::Resource::upx_rleaf : public PeFile::Resource::upx_rnode
|
||||||
{
|
{
|
||||||
upx_rleaf *next;
|
upx_rleaf *next;
|
||||||
unsigned newoffset;
|
unsigned newoffset;
|
||||||
@@ -1534,14 +1528,17 @@ unsigned PeFile::stripDebug(unsigned overlaystart)
|
|||||||
if (IDADDR(PEDIR_DEBUG) == 0)
|
if (IDADDR(PEDIR_DEBUG) == 0)
|
||||||
return overlaystart;
|
return overlaystart;
|
||||||
|
|
||||||
struct debug_dir_t
|
__packed_struct(debug_dir_t)
|
||||||
{
|
|
||||||
char _[16]; // flags, time/date, version, type
|
char _[16]; // flags, time/date, version, type
|
||||||
LE32 size;
|
LE32 size;
|
||||||
char __[4]; // rva
|
char __[4]; // rva
|
||||||
LE32 fpos;
|
LE32 fpos;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(debug_dir_t) == 28)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(debug_dir_t)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(((debug_dir_t*)0)->_) == 16)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(((debug_dir_t*)0)->__) == 4)
|
||||||
|
|
||||||
const debug_dir_t *dd = (const debug_dir_t*) (ibuf + IDADDR(PEDIR_DEBUG));
|
const debug_dir_t *dd = (const debug_dir_t*) (ibuf + IDADDR(PEDIR_DEBUG));
|
||||||
for (unsigned ic = 0; ic < IDSIZE(PEDIR_DEBUG) / sizeof(debug_dir_t); ic++, dd++)
|
for (unsigned ic = 0; ic < IDSIZE(PEDIR_DEBUG) / sizeof(debug_dir_t); ic++, dd++)
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ namespace std { class bad_alloc { }; }
|
|||||||
#elif (ACC_CC_SYMANTECC)
|
#elif (ACC_CC_SYMANTECC)
|
||||||
#define std
|
#define std
|
||||||
class bad_alloc { };
|
class bad_alloc { };
|
||||||
|
#elif (ACC_CC_WATCOMC && (__WATCOMC__ >= 1280))
|
||||||
#elif (ACC_CC_WATCOMC)
|
#elif (ACC_CC_WATCOMC)
|
||||||
#define std
|
#define std
|
||||||
class bad_alloc { };
|
class bad_alloc { };
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#
|
#
|
||||||
# This file is part of the UPX executable compressor.
|
# This file is part of the UPX executable compressor.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 John F. Reiser
|
# Copyright (C) 2008-2008 John F. Reiser
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
#
|
#
|
||||||
# UPX and the UCL library are free software; you can redistribute them
|
# UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
;
|
;
|
||||||
; This file is part of the UPX executable compressor.
|
; This file is part of the UPX executable compressor.
|
||||||
;
|
;
|
||||||
; Copyright (C) 2006 John F. Reiser
|
; Copyright (C) 2006-2006 John F. Reiser
|
||||||
; All Rights Reserved.
|
; All Rights Reserved.
|
||||||
;
|
;
|
||||||
; UPX and the UCL library are free software; you can redistribute them
|
; UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
;
|
;
|
||||||
; This file is part of the UPX executable compressor.
|
; This file is part of the UPX executable compressor.
|
||||||
;
|
;
|
||||||
; Copyright (C) 2006 John Reiser
|
; Copyright (C) 2006-2006 John Reiser
|
||||||
; All Rights Reserved.
|
; All Rights Reserved.
|
||||||
;
|
;
|
||||||
; UPX and the UCL library are free software; you can redistribute them
|
; UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
;
|
;
|
||||||
; This file is part of the UPX executable compressor.
|
; This file is part of the UPX executable compressor.
|
||||||
;
|
;
|
||||||
; Copyright (C) 2007 John Reiser
|
; Copyright (C) 2007-2007 John Reiser
|
||||||
; All Rights Reserved.
|
; All Rights Reserved.
|
||||||
;
|
;
|
||||||
; UPX and the UCL library are free software; you can redistribute them
|
; UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
@@ -36,10 +36,12 @@
|
|||||||
# pragma warning(disable: 4201 4214 4514)
|
# pragma warning(disable: 4201 4214 4514)
|
||||||
#endif
|
#endif
|
||||||
#define ACC_WANT_ACC_INCI_H 1
|
#define ACC_WANT_ACC_INCI_H 1
|
||||||
|
#include "miniacc.h"
|
||||||
#define ACC_WANT_ACCLIB_HSREAD 1
|
#define ACC_WANT_ACCLIB_HSREAD 1
|
||||||
#define ACC_WANT_ACCLIB_MISC 1
|
#define ACC_WANT_ACCLIB_MISC 1
|
||||||
#define ACC_WANT_ACCLIB_UA 1
|
#define ACC_WANT_ACCLIB_UA 1
|
||||||
#define ACC_WANT_ACCLIB_WILDARGV 1
|
#define ACC_WANT_ACCLIB_WILDARGV 1
|
||||||
|
#undef HAVE_MKDIR
|
||||||
#include "miniacc.h"
|
#include "miniacc.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user