Start using the new intergral type names.
This commit is contained in:
+43
-43
@@ -88,7 +88,7 @@ inline void set_be32(void *p, unsigned v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline acc_uint64l_t get_be64(const void *p)
|
inline upx_uint64_t get_be64(const void *p)
|
||||||
{
|
{
|
||||||
#if defined(ACC_UA_GET_BE64)
|
#if defined(ACC_UA_GET_BE64)
|
||||||
return ACC_UA_GET_BE64(p);
|
return ACC_UA_GET_BE64(p);
|
||||||
@@ -97,7 +97,7 @@ inline acc_uint64l_t get_be64(const void *p)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void set_be64(void *p, acc_uint64l_t v)
|
inline void set_be64(void *p, upx_uint64_t v)
|
||||||
{
|
{
|
||||||
#if defined(ACC_UA_SET_BE64)
|
#if defined(ACC_UA_SET_BE64)
|
||||||
ACC_UA_SET_BE64(p, v);
|
ACC_UA_SET_BE64(p, v);
|
||||||
@@ -160,7 +160,7 @@ inline void set_le32(void *p, unsigned v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline acc_uint64l_t get_le64(const void *p)
|
inline upx_uint64_t get_le64(const void *p)
|
||||||
{
|
{
|
||||||
#if defined(ACC_UA_GET_LE64)
|
#if defined(ACC_UA_GET_LE64)
|
||||||
return ACC_UA_GET_LE64(p);
|
return ACC_UA_GET_LE64(p);
|
||||||
@@ -169,7 +169,7 @@ inline acc_uint64l_t get_le64(const void *p)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void set_le64(void *p, acc_uint64l_t v)
|
inline void set_le64(void *p, upx_uint64_t v)
|
||||||
{
|
{
|
||||||
#if defined(ACC_UA_SET_LE64)
|
#if defined(ACC_UA_SET_LE64)
|
||||||
ACC_UA_SET_LE64(p, v);
|
ACC_UA_SET_LE64(p, v);
|
||||||
@@ -192,13 +192,13 @@ inline int sign_extend(unsigned v, unsigned bits)
|
|||||||
return (int) v;
|
return (int) v;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline acc_int64l_t sign_extend(acc_uint64l_t v, unsigned bits)
|
inline upx_int64_t sign_extend(upx_uint64_t v, unsigned bits)
|
||||||
{
|
{
|
||||||
const acc_uint64l_t sign_bit = ACC_UINT64_C(1) << (bits - 1);
|
const upx_uint64_t sign_bit = UPX_UINT64_C(1) << (bits - 1);
|
||||||
v &= sign_bit | (sign_bit - 1);
|
v &= sign_bit | (sign_bit - 1);
|
||||||
//v = (v ^ sign_bit) - sign_bit;
|
//v = (v ^ sign_bit) - sign_bit;
|
||||||
v |= 0 - (v & sign_bit);
|
v |= 0 - (v & sign_bit);
|
||||||
return (acc_int64l_t) v;
|
return (upx_int64_t) v;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int get_be16_signed(const void *p)
|
inline int get_be16_signed(const void *p)
|
||||||
@@ -219,9 +219,9 @@ inline int get_be32_signed(const void *p)
|
|||||||
return sign_extend(v, 32);
|
return sign_extend(v, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline acc_int64l_t get_be64_signed(const void *p)
|
inline upx_int64_t get_be64_signed(const void *p)
|
||||||
{
|
{
|
||||||
acc_uint64l_t v = get_be64(p);
|
upx_uint64_t v = get_be64(p);
|
||||||
return sign_extend(v, 64);
|
return sign_extend(v, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,9 +243,9 @@ inline int get_le32_signed(const void *p)
|
|||||||
return sign_extend(v, 32);
|
return sign_extend(v, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline acc_int64l_t get_le64_signed(const void *p)
|
inline upx_int64_t get_le64_signed(const void *p)
|
||||||
{
|
{
|
||||||
acc_uint64l_t v = get_le64(p);
|
upx_uint64_t v = get_le64(p);
|
||||||
return sign_extend(v, 64);
|
return sign_extend(v, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,25 +269,25 @@ inline unsigned acc_swab32(unsigned v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline unsigned acc_swab16p(const acc_uint16e_t *p)
|
inline unsigned acc_swab16p(const upx_uint16_t *p)
|
||||||
{
|
{
|
||||||
return acc_swab16(*p);
|
return acc_swab16(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned acc_swap32p(const acc_uint32e_t *p)
|
inline unsigned acc_swap32p(const upx_uint32_t *p)
|
||||||
{
|
{
|
||||||
return acc_swab32(*p);
|
return acc_swab32(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void acc_swab16s(acc_uint16e_t *p)
|
inline void acc_swab16s(upx_uint16_t *p)
|
||||||
{
|
{
|
||||||
*p = (acc_uint16e_t) acc_swab16(*p);
|
*p = (upx_uint16_t) acc_swab16(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void acc_swab32s(acc_uint32e_t *p)
|
inline void acc_swab32s(upx_uint32_t *p)
|
||||||
{
|
{
|
||||||
*p = (acc_uint32e_t) acc_swab32(*p);
|
*p = (upx_uint32_t) acc_swab32(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -359,20 +359,20 @@ __packed_struct(BE64)
|
|||||||
unsigned char d[8];
|
unsigned char d[8];
|
||||||
|
|
||||||
//inline BE64() { }
|
//inline BE64() { }
|
||||||
//BE64(acc_uint64l_t v) { set_be64(d, v); }
|
//BE64(upx_uint64_t v) { set_be64(d, v); }
|
||||||
|
|
||||||
BE64& operator = (acc_uint64l_t v) { set_be64(d, v); return *this; }
|
BE64& operator = (upx_uint64_t v) { set_be64(d, v); return *this; }
|
||||||
BE64& operator += (acc_uint64l_t v) { set_be64(d, get_be64(d) + v); return *this; }
|
BE64& operator += (upx_uint64_t v) { set_be64(d, get_be64(d) + v); return *this; }
|
||||||
BE64& operator -= (acc_uint64l_t v) { set_be64(d, get_be64(d) - v); return *this; }
|
BE64& operator -= (upx_uint64_t v) { set_be64(d, get_be64(d) - v); return *this; }
|
||||||
BE64& operator *= (acc_uint64l_t v) { set_be64(d, get_be64(d) * v); return *this; }
|
BE64& operator *= (upx_uint64_t v) { set_be64(d, get_be64(d) * v); return *this; }
|
||||||
BE64& operator /= (acc_uint64l_t v) { set_be64(d, get_be64(d) / v); return *this; }
|
BE64& operator /= (upx_uint64_t v) { set_be64(d, get_be64(d) / v); return *this; }
|
||||||
BE64& operator &= (acc_uint64l_t v) { set_be64(d, get_be64(d) & v); return *this; }
|
BE64& operator &= (upx_uint64_t v) { set_be64(d, get_be64(d) & v); return *this; }
|
||||||
BE64& operator |= (acc_uint64l_t v) { set_be64(d, get_be64(d) | v); return *this; }
|
BE64& operator |= (upx_uint64_t v) { set_be64(d, get_be64(d) | v); return *this; }
|
||||||
BE64& operator ^= (acc_uint64l_t v) { set_be64(d, get_be64(d) ^ v); return *this; }
|
BE64& operator ^= (upx_uint64_t v) { set_be64(d, get_be64(d) ^ v); return *this; }
|
||||||
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; }
|
||||||
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 upx_uint64_t () const { return get_be64(d); }
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
|
|
||||||
@@ -422,20 +422,20 @@ __packed_struct(LE64)
|
|||||||
unsigned char d[8];
|
unsigned char d[8];
|
||||||
|
|
||||||
//inline LE64() { }
|
//inline LE64() { }
|
||||||
//LE64(acc_uint64l_t v) { set_le64(d, v); }
|
//LE64(upx_uint64_t v) { set_le64(d, v); }
|
||||||
|
|
||||||
LE64& operator = (acc_uint64l_t v) { set_le64(d, v); return *this; }
|
LE64& operator = (upx_uint64_t v) { set_le64(d, v); return *this; }
|
||||||
LE64& operator += (acc_uint64l_t v) { set_le64(d, get_le64(d) + v); return *this; }
|
LE64& operator += (upx_uint64_t v) { set_le64(d, get_le64(d) + v); return *this; }
|
||||||
LE64& operator -= (acc_uint64l_t v) { set_le64(d, get_le64(d) - v); return *this; }
|
LE64& operator -= (upx_uint64_t v) { set_le64(d, get_le64(d) - v); return *this; }
|
||||||
LE64& operator *= (acc_uint64l_t v) { set_le64(d, get_le64(d) * v); return *this; }
|
LE64& operator *= (upx_uint64_t v) { set_le64(d, get_le64(d) * v); return *this; }
|
||||||
LE64& operator /= (acc_uint64l_t v) { set_le64(d, get_le64(d) / v); return *this; }
|
LE64& operator /= (upx_uint64_t v) { set_le64(d, get_le64(d) / v); return *this; }
|
||||||
LE64& operator &= (acc_uint64l_t v) { set_le64(d, get_le64(d) & v); return *this; }
|
LE64& operator &= (upx_uint64_t v) { set_le64(d, get_le64(d) & v); return *this; }
|
||||||
LE64& operator |= (acc_uint64l_t v) { set_le64(d, get_le64(d) | v); return *this; }
|
LE64& operator |= (upx_uint64_t v) { set_le64(d, get_le64(d) | v); return *this; }
|
||||||
LE64& operator ^= (acc_uint64l_t v) { set_le64(d, get_le64(d) ^ v); return *this; }
|
LE64& operator ^= (upx_uint64_t v) { set_le64(d, get_le64(d) ^ v); return *this; }
|
||||||
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; }
|
||||||
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 upx_uint64_t () const { return get_le64(d); }
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
|
|
||||||
@@ -545,8 +545,8 @@ int __acc_cdecl_qsort le64_compare_signed(const void *, const void *);
|
|||||||
// just for testing...
|
// just for testing...
|
||||||
#if !(ACC_CFG_NO_UNALIGNED)
|
#if !(ACC_CFG_NO_UNALIGNED)
|
||||||
#if 0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_CC_GNUC >= 0x030200)
|
#if 0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_CC_GNUC >= 0x030200)
|
||||||
typedef acc_uint16e_t LE16_unaligned __attribute__((__aligned__(1)));
|
typedef upx_uint16_t LE16_unaligned __attribute__((__aligned__(1)));
|
||||||
typedef acc_uint32e_t LE32_unaligned __attribute__((__aligned__(1)));
|
typedef upx_uint32_t LE32_unaligned __attribute__((__aligned__(1)));
|
||||||
# ifndef LE16
|
# ifndef LE16
|
||||||
# define LE16 LE16_unaligned
|
# define LE16 LE16_unaligned
|
||||||
# endif
|
# endif
|
||||||
@@ -555,8 +555,8 @@ int __acc_cdecl_qsort le64_compare_signed(const void *, const void *);
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#if 0 && (ACC_ARCH_I386) && (ACC_CC_INTELC)
|
#if 0 && (ACC_ARCH_I386) && (ACC_CC_INTELC)
|
||||||
typedef __declspec(align(1)) acc_uint16e_t LE16_unaligned;
|
typedef __declspec(align(1)) upx_uint16_t LE16_unaligned;
|
||||||
typedef __declspec(align(1)) acc_uint32e_t LE32_unaligned;
|
typedef __declspec(align(1)) upx_uint32_t LE32_unaligned;
|
||||||
# ifndef LE16
|
# ifndef LE16
|
||||||
# define LE16 LE16_unaligned
|
# define LE16 LE16_unaligned
|
||||||
# endif
|
# endif
|
||||||
@@ -565,8 +565,8 @@ int __acc_cdecl_qsort le64_compare_signed(const void *, const void *);
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#if 0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_CC_MSC) && (_MSC_VER >= 1200)
|
#if 0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_CC_MSC) && (_MSC_VER >= 1200)
|
||||||
typedef __declspec(align(1)) acc_uint16e_t LE16_unaligned;
|
typedef __declspec(align(1)) upx_uint16_t LE16_unaligned;
|
||||||
typedef __declspec(align(1)) acc_uint32e_t LE32_unaligned;
|
typedef __declspec(align(1)) upx_uint32_t LE32_unaligned;
|
||||||
# ifndef LE16
|
# ifndef LE16
|
||||||
# define LE16 LE16_unaligned
|
# define LE16 LE16_unaligned
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
+12
-12
@@ -61,17 +61,17 @@ struct AbstractPolicy
|
|||||||
V unsigned get16(const void *p) C = 0;
|
V unsigned get16(const void *p) C = 0;
|
||||||
V unsigned get24(const void *p) C = 0;
|
V unsigned get24(const void *p) C = 0;
|
||||||
V unsigned get32(const void *p) C = 0;
|
V unsigned get32(const void *p) C = 0;
|
||||||
V acc_uint64l_t get64(const void *p) C = 0;
|
V upx_uint64_t get64(const void *p) C = 0;
|
||||||
|
|
||||||
V void set16(void *p, unsigned v) C = 0;
|
V void set16(void *p, unsigned v) C = 0;
|
||||||
V void set24(void *p, unsigned v) C = 0;
|
V void set24(void *p, unsigned v) C = 0;
|
||||||
V void set32(void *p, unsigned v) C = 0;
|
V void set32(void *p, unsigned v) C = 0;
|
||||||
V void set64(void *p, acc_uint64l_t v) C = 0;
|
V void set64(void *p, upx_uint64_t v) C = 0;
|
||||||
|
|
||||||
V unsigned get16_signed(const void *p) C = 0;
|
V unsigned get16_signed(const void *p) C = 0;
|
||||||
V unsigned get24_signed(const void *p) C = 0;
|
V unsigned get24_signed(const void *p) C = 0;
|
||||||
V unsigned get32_signed(const void *p) C = 0;
|
V unsigned get32_signed(const void *p) C = 0;
|
||||||
V acc_uint64l_t get64_signed(const void *p) C = 0;
|
V upx_uint64_t get64_signed(const void *p) C = 0;
|
||||||
|
|
||||||
S u16_compare(const void *a, const void *b) C = 0;
|
S u16_compare(const void *a, const void *b) C = 0;
|
||||||
S u24_compare(const void *a, const void *b) C = 0;
|
S u24_compare(const void *a, const void *b) C = 0;
|
||||||
@@ -113,7 +113,7 @@ struct BEPolicy
|
|||||||
{ return get_be24(p); }
|
{ return get_be24(p); }
|
||||||
V unsigned get32(const void *p) C
|
V unsigned get32(const void *p) C
|
||||||
{ return get_be32(p); }
|
{ return get_be32(p); }
|
||||||
V acc_uint64l_t get64(const void *p) C
|
V upx_uint64_t get64(const void *p) C
|
||||||
{ return get_be64(p); }
|
{ return get_be64(p); }
|
||||||
|
|
||||||
V void set16(void *p, unsigned v) C
|
V void set16(void *p, unsigned v) C
|
||||||
@@ -122,7 +122,7 @@ struct BEPolicy
|
|||||||
{ set_be24(p, v); }
|
{ set_be24(p, v); }
|
||||||
V void set32(void *p, unsigned v) C
|
V void set32(void *p, unsigned v) C
|
||||||
{ set_be32(p, v); }
|
{ set_be32(p, v); }
|
||||||
V void set64(void *p, acc_uint64l_t v) C
|
V void set64(void *p, upx_uint64_t v) C
|
||||||
{ set_be64(p, v); }
|
{ set_be64(p, v); }
|
||||||
|
|
||||||
V unsigned get16_signed(const void *p) C
|
V unsigned get16_signed(const void *p) C
|
||||||
@@ -131,7 +131,7 @@ struct BEPolicy
|
|||||||
{ return get_be24_signed(p); }
|
{ return get_be24_signed(p); }
|
||||||
V unsigned get32_signed(const void *p) C
|
V unsigned get32_signed(const void *p) C
|
||||||
{ return get_be32_signed(p); }
|
{ return get_be32_signed(p); }
|
||||||
V acc_uint64l_t get64_signed(const void *p) C
|
V upx_uint64_t get64_signed(const void *p) C
|
||||||
{ return get_be64_signed(p); }
|
{ return get_be64_signed(p); }
|
||||||
|
|
||||||
S u16_compare(const void *a, const void *b) C
|
S u16_compare(const void *a, const void *b) C
|
||||||
@@ -190,7 +190,7 @@ struct LEPolicy
|
|||||||
{ return get_le24(p); }
|
{ return get_le24(p); }
|
||||||
V unsigned get32(const void *p) C
|
V unsigned get32(const void *p) C
|
||||||
{ return get_le32(p); }
|
{ return get_le32(p); }
|
||||||
V acc_uint64l_t get64(const void *p) C
|
V upx_uint64_t get64(const void *p) C
|
||||||
{ return get_le64(p); }
|
{ return get_le64(p); }
|
||||||
|
|
||||||
V void set16(void *p, unsigned v) C
|
V void set16(void *p, unsigned v) C
|
||||||
@@ -199,7 +199,7 @@ struct LEPolicy
|
|||||||
{ set_le24(p, v); }
|
{ set_le24(p, v); }
|
||||||
V void set32(void *p, unsigned v) C
|
V void set32(void *p, unsigned v) C
|
||||||
{ set_le32(p, v); }
|
{ set_le32(p, v); }
|
||||||
V void set64(void *p, acc_uint64l_t v) C
|
V void set64(void *p, upx_uint64_t v) C
|
||||||
{ set_le64(p, v); }
|
{ set_le64(p, v); }
|
||||||
|
|
||||||
V unsigned get16_signed(const void *p) C
|
V unsigned get16_signed(const void *p) C
|
||||||
@@ -208,7 +208,7 @@ struct LEPolicy
|
|||||||
{ return get_le24_signed(p); }
|
{ return get_le24_signed(p); }
|
||||||
V unsigned get32_signed(const void *p) C
|
V unsigned get32_signed(const void *p) C
|
||||||
{ return get_le32_signed(p); }
|
{ return get_le32_signed(p); }
|
||||||
V acc_uint64l_t get64_signed(const void *p) C
|
V upx_uint64_t get64_signed(const void *p) C
|
||||||
{ return get_le64_signed(p); }
|
{ return get_le64_signed(p); }
|
||||||
|
|
||||||
S u16_compare(const void *a, const void *b) C
|
S u16_compare(const void *a, const void *b) C
|
||||||
@@ -259,9 +259,9 @@ struct HostAlignedPolicy
|
|||||||
enum { isBE = HostPolicy::isBE, isLE = HostPolicy::isLE };
|
enum { isBE = HostPolicy::isBE, isLE = HostPolicy::isLE };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef acc_uint16e_t U16;
|
typedef upx_uint16_t U16;
|
||||||
typedef acc_uint32e_t U32;
|
typedef upx_uint32_t U32;
|
||||||
typedef acc_uint64l_t U64;
|
typedef upx_uint64_t U64;
|
||||||
|
|
||||||
static void compileTimeAssertions() {
|
static void compileTimeAssertions() {
|
||||||
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
|
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
|
||||||
|
|||||||
+22
-22
@@ -84,7 +84,7 @@ ElfLinker::Section::~Section()
|
|||||||
// Symbol
|
// Symbol
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
ElfLinker::Symbol::Symbol(const char *n, Section *s, u64 o) :
|
ElfLinker::Symbol::Symbol(const char *n, Section *s, upx_uint64_t o) :
|
||||||
name(NULL), section(s), offset(o)
|
name(NULL), section(s), offset(o)
|
||||||
{
|
{
|
||||||
name = strdup(n);
|
name = strdup(n);
|
||||||
@@ -103,7 +103,7 @@ ElfLinker::Symbol::~Symbol()
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
ElfLinker::Relocation::Relocation(const Section *s, unsigned o, const char *t,
|
ElfLinker::Relocation::Relocation(const Section *s, unsigned o, const char *t,
|
||||||
const Symbol *v, u64 a) :
|
const Symbol *v, upx_uint64_t a) :
|
||||||
section(s), offset(o), type(t), value(v), add(a)
|
section(s), offset(o), type(t), value(v), add(a)
|
||||||
{
|
{
|
||||||
assert(section != NULL);
|
assert(section != NULL);
|
||||||
@@ -294,7 +294,7 @@ void ElfLinker::preprocessRelocations(char *start, char *end)
|
|||||||
char *t = strstr(start, type);
|
char *t = strstr(start, type);
|
||||||
t[strlen(type)] = 0;
|
t[strlen(type)] = 0;
|
||||||
|
|
||||||
u64 add = 0;
|
upx_uint64_t add = 0;
|
||||||
char *p = strstr(symbol, "+0x");
|
char *p = strstr(symbol, "+0x");
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
p = strstr(symbol, "-0x");
|
p = strstr(symbol, "-0x");
|
||||||
@@ -306,8 +306,8 @@ void ElfLinker::preprocessRelocations(char *start, char *end)
|
|||||||
|
|
||||||
assert(strlen(p) == 8 || strlen(p) == 16);
|
assert(strlen(p) == 8 || strlen(p) == 16);
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
acc_uint64l_t ull = strtoull(p, &endptr, 16);
|
upx_uint64_t ull = strtoull(p, &endptr, 16);
|
||||||
add = (u64) ull;
|
add = (upx_uint64_t) ull;
|
||||||
assert(add == ull);
|
assert(add == ull);
|
||||||
assert(endptr && *endptr == '\0');
|
assert(endptr && *endptr == '\0');
|
||||||
if (sign == '-')
|
if (sign == '-')
|
||||||
@@ -356,7 +356,7 @@ ElfLinker::Section *ElfLinker::addSection(const char *sname, const void *sdata,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ElfLinker::Symbol *ElfLinker::addSymbol(const char *name, const char *section,
|
ElfLinker::Symbol *ElfLinker::addSymbol(const char *name, const char *section,
|
||||||
u64 offset)
|
upx_uint64_t offset)
|
||||||
{
|
{
|
||||||
//printf("addSymbol: %s %s 0x%x\n", name, section, offset);
|
//printf("addSymbol: %s %s 0x%x\n", name, section, offset);
|
||||||
if (update_capacity(nsymbols, &nsymbols_capacity))
|
if (update_capacity(nsymbols, &nsymbols_capacity))
|
||||||
@@ -371,7 +371,7 @@ ElfLinker::Symbol *ElfLinker::addSymbol(const char *name, const char *section,
|
|||||||
|
|
||||||
ElfLinker::Relocation *ElfLinker::addRelocation(const char *section, unsigned off,
|
ElfLinker::Relocation *ElfLinker::addRelocation(const char *section, unsigned off,
|
||||||
const char *type, const char *symbol,
|
const char *type, const char *symbol,
|
||||||
u64 add)
|
upx_uint64_t add)
|
||||||
{
|
{
|
||||||
if (update_capacity(nrelocations, &nrelocations_capacity))
|
if (update_capacity(nrelocations, &nrelocations_capacity))
|
||||||
relocations = static_cast<Relocation **>(realloc(relocations, (nrelocations_capacity) * sizeof(Relocation *)));
|
relocations = static_cast<Relocation **>(realloc(relocations, (nrelocations_capacity) * sizeof(Relocation *)));
|
||||||
@@ -497,7 +497,7 @@ void ElfLinker::relocate()
|
|||||||
for (unsigned ic = 0; ic < nrelocations; ic++)
|
for (unsigned ic = 0; ic < nrelocations; ic++)
|
||||||
{
|
{
|
||||||
const Relocation *rel = relocations[ic];
|
const Relocation *rel = relocations[ic];
|
||||||
u64 value = 0;
|
upx_uint64_t value = 0;
|
||||||
|
|
||||||
if (rel->section->output == NULL)
|
if (rel->section->output == NULL)
|
||||||
continue;
|
continue;
|
||||||
@@ -524,7 +524,7 @@ void ElfLinker::relocate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElfLinker::defineSymbol(const char *name, u64 value)
|
void ElfLinker::defineSymbol(const char *name, upx_uint64_t value)
|
||||||
{
|
{
|
||||||
Symbol *symbol = findSymbol(name);
|
Symbol *symbol = findSymbol(name);
|
||||||
if (strcmp(symbol->section->name, "*ABS*") == 0)
|
if (strcmp(symbol->section->name, "*ABS*") == 0)
|
||||||
@@ -550,8 +550,8 @@ void ElfLinker::dumpSymbol(const Symbol *symbol, unsigned flags, FILE *fp) const
|
|||||||
if ((flags & 1) && symbol->section->output == NULL)
|
if ((flags & 1) && symbol->section->output == NULL)
|
||||||
return;
|
return;
|
||||||
char d0[16+1], d1[16+1];
|
char d0[16+1], d1[16+1];
|
||||||
upx_snprintf(d0, sizeof(d0), "%016llx", (acc_uint64_t) symbol->offset);
|
upx_snprintf(d0, sizeof(d0), "%016llx", (upx_uint64_t) symbol->offset);
|
||||||
upx_snprintf(d1, sizeof(d1), "%016llx", (acc_uint64_t) symbol->section->offset);
|
upx_snprintf(d1, sizeof(d1), "%016llx", (upx_uint64_t) symbol->section->offset);
|
||||||
fprintf(fp, "%-28s 0x%-16s | %-28s 0x%-16s\n",
|
fprintf(fp, "%-28s 0x%-16s | %-28s 0x%-16s\n",
|
||||||
symbol->name, d0, symbol->section->name, d1);
|
symbol->name, d0, symbol->section->name, d1);
|
||||||
}
|
}
|
||||||
@@ -565,7 +565,7 @@ void ElfLinker::dumpSymbols(unsigned flags, FILE *fp) const
|
|||||||
for (const Section *section = head; section; section = section->next)
|
for (const Section *section = head; section; section = section->next)
|
||||||
{
|
{
|
||||||
char d1[16+1];
|
char d1[16+1];
|
||||||
upx_snprintf(d1, sizeof(d1), "%016llx", (acc_uint64_t) section->offset);
|
upx_snprintf(d1, sizeof(d1), "%016llx", (upx_uint64_t) section->offset);
|
||||||
fprintf(fp, "%-42s%-28s 0x%-16s\n", "", section->name, d1);
|
fprintf(fp, "%-42s%-28s 0x%-16s\n", "", section->name, d1);
|
||||||
for (unsigned ic = 0; ic < nsymbols; ic++)
|
for (unsigned ic = 0; ic < nsymbols; ic++)
|
||||||
{
|
{
|
||||||
@@ -583,7 +583,7 @@ void ElfLinker::dumpSymbols(unsigned flags, FILE *fp) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ElfLinker::u64 ElfLinker::getSymbolOffset(const char *name) const
|
upx_uint64_t ElfLinker::getSymbolOffset(const char *name) const
|
||||||
{
|
{
|
||||||
const Symbol *symbol = findSymbol(name);
|
const Symbol *symbol = findSymbol(name);
|
||||||
if (symbol->section->output == NULL)
|
if (symbol->section->output == NULL)
|
||||||
@@ -598,7 +598,7 @@ void ElfLinker::alignWithByte(unsigned len, unsigned char b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ElfLinker::relocate1(const Relocation *rel, upx_byte *,
|
void ElfLinker::relocate1(const Relocation *rel, upx_byte *,
|
||||||
u64, const char *)
|
upx_uint64_t, const char *)
|
||||||
{
|
{
|
||||||
internal_error("unknown relocation type '%s\n", rel->type);
|
internal_error("unknown relocation type '%s\n", rel->type);
|
||||||
}
|
}
|
||||||
@@ -624,7 +624,7 @@ static void check8(const Relocation *rel, const upx_byte *location, int v, int d
|
|||||||
|
|
||||||
|
|
||||||
void ElfLinkerAMD64::relocate1(const Relocation *rel, upx_byte *location,
|
void ElfLinkerAMD64::relocate1(const Relocation *rel, upx_byte *location,
|
||||||
u64 value, const char *type)
|
upx_uint64_t value, const char *type)
|
||||||
{
|
{
|
||||||
if (strncmp(type, "R_X86_64_", 9))
|
if (strncmp(type, "R_X86_64_", 9))
|
||||||
return super::relocate1(rel, location, value, type);
|
return super::relocate1(rel, location, value, type);
|
||||||
@@ -662,7 +662,7 @@ void ElfLinkerAMD64::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
|
|
||||||
|
|
||||||
void ElfLinkerArmBE::relocate1(const Relocation *rel, upx_byte *location,
|
void ElfLinkerArmBE::relocate1(const Relocation *rel, upx_byte *location,
|
||||||
u64 value, const char *type)
|
upx_uint64_t value, const char *type)
|
||||||
{
|
{
|
||||||
if (strcmp(type, "R_ARM_PC24") == 0)
|
if (strcmp(type, "R_ARM_PC24") == 0)
|
||||||
{
|
{
|
||||||
@@ -697,7 +697,7 @@ void ElfLinkerArmBE::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
|
|
||||||
|
|
||||||
void ElfLinkerArmLE::relocate1(const Relocation *rel, upx_byte *location,
|
void ElfLinkerArmLE::relocate1(const Relocation *rel, upx_byte *location,
|
||||||
u64 value, const char *type)
|
upx_uint64_t value, const char *type)
|
||||||
{
|
{
|
||||||
if (strcmp(type, "R_ARM_PC24") == 0)
|
if (strcmp(type, "R_ARM_PC24") == 0)
|
||||||
{
|
{
|
||||||
@@ -741,7 +741,7 @@ void ElfLinkerM68k::alignCode(unsigned len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ElfLinkerM68k::relocate1(const Relocation *rel, upx_byte *location,
|
void ElfLinkerM68k::relocate1(const Relocation *rel, upx_byte *location,
|
||||||
u64 value, const char *type)
|
upx_uint64_t value, const char *type)
|
||||||
{
|
{
|
||||||
if (strncmp(type, "R_68K_", 6))
|
if (strncmp(type, "R_68K_", 6))
|
||||||
return super::relocate1(rel, location, value, type);
|
return super::relocate1(rel, location, value, type);
|
||||||
@@ -767,7 +767,7 @@ void ElfLinkerM68k::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
|
|
||||||
|
|
||||||
void ElfLinkerMipsBE::relocate1(const Relocation *rel, upx_byte *location,
|
void ElfLinkerMipsBE::relocate1(const Relocation *rel, upx_byte *location,
|
||||||
u64 value, const char *type)
|
upx_uint64_t value, const char *type)
|
||||||
{
|
{
|
||||||
#define MIPS_HI(a) (((a) >> 16) + (((a) & 0x8000) >> 15))
|
#define MIPS_HI(a) (((a) >> 16) + (((a) & 0x8000) >> 15))
|
||||||
#define MIPS_LO(a) ((a) & 0xffff)
|
#define MIPS_LO(a) ((a) & 0xffff)
|
||||||
@@ -798,7 +798,7 @@ void ElfLinkerMipsBE::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
|
|
||||||
|
|
||||||
void ElfLinkerMipsLE::relocate1(const Relocation *rel, upx_byte *location,
|
void ElfLinkerMipsLE::relocate1(const Relocation *rel, upx_byte *location,
|
||||||
u64 value, const char *type)
|
upx_uint64_t value, const char *type)
|
||||||
{
|
{
|
||||||
#define MIPS_HI(a) (((a) >> 16) + (((a) & 0x8000) >> 15))
|
#define MIPS_HI(a) (((a) >> 16) + (((a) & 0x8000) >> 15))
|
||||||
#define MIPS_LO(a) ((a) & 0xffff)
|
#define MIPS_LO(a) ((a) & 0xffff)
|
||||||
@@ -829,7 +829,7 @@ void ElfLinkerMipsLE::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
|
|
||||||
|
|
||||||
void ElfLinkerPpc32::relocate1(const Relocation *rel, upx_byte *location,
|
void ElfLinkerPpc32::relocate1(const Relocation *rel, upx_byte *location,
|
||||||
u64 value, const char *type)
|
upx_uint64_t value, const char *type)
|
||||||
{
|
{
|
||||||
if (strncmp(type, "R_PPC_", 6))
|
if (strncmp(type, "R_PPC_", 6))
|
||||||
return super::relocate1(rel, location, value, type);
|
return super::relocate1(rel, location, value, type);
|
||||||
@@ -870,7 +870,7 @@ void ElfLinkerPpc32::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
|
|
||||||
|
|
||||||
void ElfLinkerX86::relocate1(const Relocation *rel, upx_byte *location,
|
void ElfLinkerX86::relocate1(const Relocation *rel, upx_byte *location,
|
||||||
u64 value, const char *type)
|
upx_uint64_t value, const char *type)
|
||||||
{
|
{
|
||||||
if (strncmp(type, "R_386_", 6))
|
if (strncmp(type, "R_386_", 6))
|
||||||
return super::relocate1(rel, location, value, type);
|
return super::relocate1(rel, location, value, type);
|
||||||
|
|||||||
+24
-25
@@ -40,7 +40,6 @@ class ElfLinker : private noncopyable
|
|||||||
public:
|
public:
|
||||||
const N_BELE_RTP::AbstractPolicy *bele; // target endianness
|
const N_BELE_RTP::AbstractPolicy *bele; // target endianness
|
||||||
protected:
|
protected:
|
||||||
typedef acc_uint64l_t u64;
|
|
||||||
struct Section;
|
struct Section;
|
||||||
struct Symbol;
|
struct Symbol;
|
||||||
struct Relocation;
|
struct Relocation;
|
||||||
@@ -73,9 +72,9 @@ protected:
|
|||||||
Section *findSection(const char *name, bool fatal=true) const;
|
Section *findSection(const char *name, bool fatal=true) const;
|
||||||
Symbol *findSymbol(const char *name, bool fatal=true) const;
|
Symbol *findSymbol(const char *name, bool fatal=true) const;
|
||||||
|
|
||||||
Symbol *addSymbol(const char *name, const char *section, u64 offset);
|
Symbol *addSymbol(const char *name, const char *section, upx_uint64_t offset);
|
||||||
Relocation *addRelocation(const char *section, unsigned off, const char *type,
|
Relocation *addRelocation(const char *section, unsigned off, const char *type,
|
||||||
const char *symbol, u64 add);
|
const char *symbol, upx_uint64_t add);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ElfLinker();
|
ElfLinker();
|
||||||
@@ -94,8 +93,8 @@ public:
|
|||||||
virtual int getSection(const char *sname, int *slen=NULL) const;
|
virtual int getSection(const char *sname, int *slen=NULL) const;
|
||||||
virtual int getSectionSize(const char *sname) const;
|
virtual int getSectionSize(const char *sname) const;
|
||||||
virtual upx_byte *getLoader(int *llen=NULL) const;
|
virtual upx_byte *getLoader(int *llen=NULL) const;
|
||||||
virtual void defineSymbol(const char *name, u64 value);
|
virtual void defineSymbol(const char *name, upx_uint64_t value);
|
||||||
virtual u64 getSymbolOffset(const char *) const;
|
virtual upx_uint64_t getSymbolOffset(const char *) const;
|
||||||
|
|
||||||
virtual void dumpSymbol(const Symbol *, unsigned flags, FILE *fp) const;
|
virtual void dumpSymbol(const Symbol *, unsigned flags, FILE *fp) const;
|
||||||
virtual void dumpSymbols(unsigned flags=0, FILE *fp=NULL) const;
|
virtual void dumpSymbols(unsigned flags=0, FILE *fp=NULL) const;
|
||||||
@@ -107,15 +106,15 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual void relocate();
|
virtual void relocate();
|
||||||
virtual void relocate1(const Relocation *, upx_byte *location,
|
virtual void relocate1(const Relocation *, upx_byte *location,
|
||||||
u64 value, const char *type);
|
upx_uint64_t value, const char *type);
|
||||||
|
|
||||||
// target endianness abstraction
|
// target endianness abstraction
|
||||||
unsigned get_te16(const void *p) const { return bele->get16(p); }
|
unsigned get_te16(const void *p) const { return bele->get16(p); }
|
||||||
unsigned get_te32(const void *p) const { return bele->get32(p); }
|
unsigned get_te32(const void *p) const { return bele->get32(p); }
|
||||||
u64 get_te64(const void *p) const { return bele->get64(p); }
|
upx_uint64_t get_te64(const void *p) const { return bele->get64(p); }
|
||||||
void set_te16(void *p, unsigned v) const { bele->set16(p, v); }
|
void set_te16(void *p, unsigned v) const { bele->set16(p, v); }
|
||||||
void set_te32(void *p, unsigned v) const { bele->set32(p, v); }
|
void set_te32(void *p, unsigned v) const { bele->set32(p, v); }
|
||||||
void set_te64(void *p, u64 v) const { bele->set64(p, v); }
|
void set_te64(void *p, upx_uint64_t v) const { bele->set64(p, v); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -125,7 +124,7 @@ struct ElfLinker::Section : private noncopyable
|
|||||||
void *input;
|
void *input;
|
||||||
upx_byte *output;
|
upx_byte *output;
|
||||||
unsigned size;
|
unsigned size;
|
||||||
u64 offset;
|
upx_uint64_t offset;
|
||||||
unsigned p2align; // log2
|
unsigned p2align; // log2
|
||||||
Section *next;
|
Section *next;
|
||||||
|
|
||||||
@@ -138,9 +137,9 @@ struct ElfLinker::Symbol : private noncopyable
|
|||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
Section *section;
|
Section *section;
|
||||||
u64 offset;
|
upx_uint64_t offset;
|
||||||
|
|
||||||
Symbol(const char *n, Section *s, u64 o);
|
Symbol(const char *n, Section *s, upx_uint64_t o);
|
||||||
~Symbol();
|
~Symbol();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -151,10 +150,10 @@ struct ElfLinker::Relocation : private noncopyable
|
|||||||
unsigned offset;
|
unsigned offset;
|
||||||
const char *type;
|
const char *type;
|
||||||
const Symbol *value;
|
const Symbol *value;
|
||||||
u64 add; // used in .rela relocations
|
upx_uint64_t add; // used in .rela relocations
|
||||||
|
|
||||||
Relocation(const Section *s, unsigned o, const char *t,
|
Relocation(const Section *s, unsigned o, const char *t,
|
||||||
const Symbol *v, u64 a);
|
const Symbol *v, upx_uint64_t a);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -168,7 +167,7 @@ class ElfLinkerAMD64 : public ElfLinker
|
|||||||
protected:
|
protected:
|
||||||
virtual void alignCode(unsigned len) { alignWithByte(len, 0x90); }
|
virtual void alignCode(unsigned len) { alignWithByte(len, 0x90); }
|
||||||
virtual void relocate1(const Relocation *, upx_byte *location,
|
virtual void relocate1(const Relocation *, upx_byte *location,
|
||||||
u64 value, const char *type);
|
upx_uint64_t value, const char *type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -179,7 +178,7 @@ public:
|
|||||||
ElfLinkerArmBE() { bele = &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,
|
||||||
u64 value, const char *type);
|
upx_uint64_t value, const char *type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -188,7 +187,7 @@ class ElfLinkerArmLE : public ElfLinker
|
|||||||
typedef ElfLinker super;
|
typedef ElfLinker super;
|
||||||
protected:
|
protected:
|
||||||
virtual void relocate1(const Relocation *, upx_byte *location,
|
virtual void relocate1(const Relocation *, upx_byte *location,
|
||||||
u64 value, const char *type);
|
upx_uint64_t value, const char *type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -200,7 +199,7 @@ public:
|
|||||||
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,
|
||||||
u64 value, const char *type);
|
upx_uint64_t value, const char *type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -211,7 +210,7 @@ public:
|
|||||||
ElfLinkerMipsBE() { bele = &N_BELE_RTP::be_policy; }
|
ElfLinkerMipsBE() { bele = &N_BELE_RTP::be_policy; }
|
||||||
protected:
|
protected:
|
||||||
virtual void relocate1(const Relocation *, upx_byte *location,
|
virtual void relocate1(const Relocation *, upx_byte *location,
|
||||||
u64 value, const char *type);
|
upx_uint64_t value, const char *type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -220,7 +219,7 @@ class ElfLinkerMipsLE : public ElfLinker
|
|||||||
typedef ElfLinker super;
|
typedef ElfLinker super;
|
||||||
protected:
|
protected:
|
||||||
virtual void relocate1(const Relocation *, upx_byte *location,
|
virtual void relocate1(const Relocation *, upx_byte *location,
|
||||||
u64 value, const char *type);
|
upx_uint64_t value, const char *type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -231,7 +230,7 @@ public:
|
|||||||
ElfLinkerPpc32() { bele = &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,
|
||||||
u64 value, const char *type);
|
upx_uint64_t value, const char *type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -241,7 +240,7 @@ class ElfLinkerX86 : public ElfLinker
|
|||||||
protected:
|
protected:
|
||||||
virtual void alignCode(unsigned len) { alignWithByte(len, 0x90); }
|
virtual void alignCode(unsigned len) { alignWithByte(len, 0x90); }
|
||||||
virtual void relocate1(const Relocation *, upx_byte *location,
|
virtual void relocate1(const Relocation *, upx_byte *location,
|
||||||
u64 value, const char *type);
|
upx_uint64_t value, const char *type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1408,7 +1408,7 @@ void upx_sanity_check(void)
|
|||||||
assert(get_le32(d) == 0xfcfdfeff);
|
assert(get_le32(d) == 0xfcfdfeff);
|
||||||
assert(bele->get32(d) == 0xfcfdfeff);
|
assert(bele->get32(d) == 0xfcfdfeff);
|
||||||
assert(get_le32_signed(d) == -50462977);
|
assert(get_le32_signed(d) == -50462977);
|
||||||
assert(get_le64_signed(d) == ACC_INT64_C(-506097522914230529));
|
assert(get_le64_signed(d) == UPX_INT64_C(-506097522914230529));
|
||||||
assert(find_be16(d, 2, 0xfffe) == 0);
|
assert(find_be16(d, 2, 0xfffe) == 0);
|
||||||
assert(find_le16(d, 2, 0xfeff) == 0);
|
assert(find_le16(d, 2, 0xfeff) == 0);
|
||||||
assert(find_be32(d, 4, 0xfffefdfc) == 0);
|
assert(find_be32(d, 4, 0xfffefdfc) == 0);
|
||||||
@@ -1417,7 +1417,7 @@ void upx_sanity_check(void)
|
|||||||
assert(get_be16_signed(d) == 32638);
|
assert(get_be16_signed(d) == 32638);
|
||||||
assert(get_be24_signed(d) == 8355453);
|
assert(get_be24_signed(d) == 8355453);
|
||||||
assert(get_be32_signed(d) == 2138996092);
|
assert(get_be32_signed(d) == 2138996092);
|
||||||
assert(get_be64_signed(d) == ACC_INT64_C(9186918263483431288));
|
assert(get_be64_signed(d) == UPX_INT64_C(9186918263483431288));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -154,7 +154,7 @@ void MemBuffer::fill(unsigned off, unsigned len, int value)
|
|||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#define PTR(p) ((unsigned) ((acc_uintptr_t)(p) & 0xffffffff))
|
#define PTR(p) ((unsigned) ((upx_uintptr_t)(p) & 0xffffffff))
|
||||||
#define MAGIC1(p) (PTR(p) ^ 0xfefdbeeb)
|
#define MAGIC1(p) (PTR(p) ^ 0xfefdbeeb)
|
||||||
#define MAGIC2(p) (PTR(p) ^ 0xfefdbeeb ^ 0x80024001)
|
#define MAGIC2(p) (PTR(p) ^ 0xfefdbeeb ^ 0x80024001)
|
||||||
|
|
||||||
|
|||||||
+33
-33
@@ -63,8 +63,8 @@ umin(unsigned a, unsigned b)
|
|||||||
return (a < b) ? a : b;
|
return (a < b) ? a : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
static acc_uint64l_t
|
static upx_uint64_t
|
||||||
umin64(acc_uint64l_t a, acc_uint64l_t b)
|
umin64(upx_uint64_t a, upx_uint64_t b)
|
||||||
{
|
{
|
||||||
return (a < b) ? a : b;
|
return (a < b) ? a : b;
|
||||||
}
|
}
|
||||||
@@ -173,7 +173,7 @@ PackLinuxElf64::checkEhdr(Elf64_Ehdr const *ehdr) const
|
|||||||
|
|
||||||
if (type == Elf64_Ehdr::ET_EXEC) {
|
if (type == Elf64_Ehdr::ET_EXEC) {
|
||||||
// check for Linux kernels
|
// check for Linux kernels
|
||||||
acc_uint64l_t const entry = get_te64(&ehdr->e_entry);
|
upx_uint64_t const entry = get_te64(&ehdr->e_entry);
|
||||||
if (entry == 0xC0100000) // uncompressed vmlinux
|
if (entry == 0xC0100000) // uncompressed vmlinux
|
||||||
return 1000;
|
return 1000;
|
||||||
if (entry == 0x00001000) // compressed vmlinux
|
if (entry == 0x00001000) // compressed vmlinux
|
||||||
@@ -364,13 +364,13 @@ void PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
|
|||||||
Elf64_Phdr *phdr = phdri;
|
Elf64_Phdr *phdr = phdri;
|
||||||
unsigned off = fo->st_size();
|
unsigned off = fo->st_size();
|
||||||
unsigned off_init = 0; // where in file
|
unsigned off_init = 0; // where in file
|
||||||
acc_uint64l_t va_init = sz_pack2; // virtual address
|
upx_uint64_t va_init = sz_pack2; // virtual address
|
||||||
acc_uint64l_t rel = 0;
|
upx_uint64_t rel = 0;
|
||||||
acc_uint64l_t old_dtinit = 0;
|
upx_uint64_t old_dtinit = 0;
|
||||||
for (int j = e_phnum; --j>=0; ++phdr) {
|
for (int j = e_phnum; --j>=0; ++phdr) {
|
||||||
acc_uint64l_t const len = get_te64(&phdr->p_filesz);
|
upx_uint64_t const len = get_te64(&phdr->p_filesz);
|
||||||
acc_uint64l_t const ioff = get_te64(&phdr->p_offset);
|
upx_uint64_t const ioff = get_te64(&phdr->p_offset);
|
||||||
acc_uint64l_t align= get_te64(&phdr->p_align);
|
upx_uint64_t align= get_te64(&phdr->p_align);
|
||||||
unsigned const type = get_te32(&phdr->p_type);
|
unsigned const type = get_te32(&phdr->p_type);
|
||||||
if (phdr->PT_INTERP==type) {
|
if (phdr->PT_INTERP==type) {
|
||||||
// Rotate to highest position, so it can be lopped
|
// Rotate to highest position, so it can be lopped
|
||||||
@@ -428,7 +428,7 @@ void PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
|
|||||||
}
|
}
|
||||||
if (off_init) { // change DT_INIT.d_val
|
if (off_init) { // change DT_INIT.d_val
|
||||||
fo->seek(off_init, SEEK_SET);
|
fo->seek(off_init, SEEK_SET);
|
||||||
acc_uint64l_t word; set_te64(&word, va_init);
|
upx_uint64_t word; set_te64(&word, va_init);
|
||||||
fo->rewrite(&word, sizeof(word));
|
fo->rewrite(&word, sizeof(word));
|
||||||
fo->seek(0, SEEK_END);
|
fo->seek(0, SEEK_END);
|
||||||
}
|
}
|
||||||
@@ -860,22 +860,22 @@ PackLinuxElf64amd::defineSymbols(Filter const *)
|
|||||||
// know the final total compressed size yet, so use the uncompressed
|
// know the final total compressed size yet, so use the uncompressed
|
||||||
// size (total over all PT_LOAD64) as an upper bound.
|
// size (total over all PT_LOAD64) as an upper bound.
|
||||||
unsigned len = 0;
|
unsigned len = 0;
|
||||||
acc_uint64l_t lo_va_user = ~0ull; // infinity
|
upx_uint64_t lo_va_user = ~0ull; // infinity
|
||||||
for (int j= e_phnum; --j>=0; ) {
|
for (int j= e_phnum; --j>=0; ) {
|
||||||
if (PT_LOAD64 == get_te32(&phdri[j].p_type)) {
|
if (PT_LOAD64 == get_te32(&phdri[j].p_type)) {
|
||||||
len += (unsigned)get_te64(&phdri[j].p_filesz);
|
len += (unsigned)get_te64(&phdri[j].p_filesz);
|
||||||
acc_uint64l_t const va = get_te64(&phdri[j].p_vaddr);
|
upx_uint64_t const va = get_te64(&phdri[j].p_vaddr);
|
||||||
if (va < lo_va_user) {
|
if (va < lo_va_user) {
|
||||||
lo_va_user = va;
|
lo_va_user = va;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lsize = /*getLoaderSize()*/ 64 * 1024; // XXX: upper bound; avoid circularity
|
lsize = /*getLoaderSize()*/ 64 * 1024; // XXX: upper bound; avoid circularity
|
||||||
acc_uint64l_t lo_va_stub = get_te64(&elfout.phdr[0].p_vaddr);
|
upx_uint64_t lo_va_stub = get_te64(&elfout.phdr[0].p_vaddr);
|
||||||
acc_uint64l_t adrc;
|
upx_uint64_t adrc;
|
||||||
acc_uint64l_t adrm;
|
upx_uint64_t adrm;
|
||||||
acc_uint64l_t adru;
|
upx_uint64_t adru;
|
||||||
acc_uint64l_t adrx;
|
upx_uint64_t adrx;
|
||||||
unsigned cntc;
|
unsigned cntc;
|
||||||
unsigned lenm;
|
unsigned lenm;
|
||||||
unsigned lenu;
|
unsigned lenu;
|
||||||
@@ -1479,8 +1479,8 @@ PackLinuxElf64amd::canPack()
|
|||||||
throwCantPack("invalid Ehdr e_ehsize; try '--force-execve'");
|
throwCantPack("invalid Ehdr e_ehsize; try '--force-execve'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
acc_uint64l_t const e_shoff = get_te64(&ehdr->e_shoff);
|
upx_uint64_t const e_shoff = get_te64(&ehdr->e_shoff);
|
||||||
acc_uint64l_t const e_phoff = get_te64(&ehdr->e_phoff);
|
upx_uint64_t const e_phoff = get_te64(&ehdr->e_phoff);
|
||||||
if (e_phoff != sizeof(*ehdr)) {// Phdrs not contiguous with Ehdr
|
if (e_phoff != sizeof(*ehdr)) {// Phdrs not contiguous with Ehdr
|
||||||
throwCantPack("non-contiguous Ehdr/Phdr; try '--force-execve'");
|
throwCantPack("non-contiguous Ehdr/Phdr; try '--force-execve'");
|
||||||
return false;
|
return false;
|
||||||
@@ -1588,8 +1588,8 @@ PackLinuxElf64amd::canPack()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Rely on 0==elf_unsigned_dynamic(tag) if no such tag.
|
// Rely on 0==elf_unsigned_dynamic(tag) if no such tag.
|
||||||
acc_uint64l_t const va_gash = elf_unsigned_dynamic(Elf64_Dyn::DT_GNU_HASH);
|
upx_uint64_t const va_gash = elf_unsigned_dynamic(Elf64_Dyn::DT_GNU_HASH);
|
||||||
acc_uint64l_t const va_hash = elf_unsigned_dynamic(Elf64_Dyn::DT_HASH);
|
upx_uint64_t const va_hash = elf_unsigned_dynamic(Elf64_Dyn::DT_HASH);
|
||||||
if (xct_va < va_gash || (0==va_gash && xct_va < va_hash)
|
if (xct_va < va_gash || (0==va_gash && xct_va < va_hash)
|
||||||
|| xct_va < elf_unsigned_dynamic(Elf64_Dyn::DT_STRTAB)
|
|| xct_va < elf_unsigned_dynamic(Elf64_Dyn::DT_STRTAB)
|
||||||
|| xct_va < elf_unsigned_dynamic(Elf64_Dyn::DT_SYMTAB)
|
|| xct_va < elf_unsigned_dynamic(Elf64_Dyn::DT_SYMTAB)
|
||||||
@@ -1605,7 +1605,7 @@ PackLinuxElf64amd::canPack()
|
|||||||
goto abandon;
|
goto abandon;
|
||||||
}
|
}
|
||||||
for ((shdr= shdri), (j= n_elf_shnum); --j>=0; ++shdr) {
|
for ((shdr= shdri), (j= n_elf_shnum); --j>=0; ++shdr) {
|
||||||
acc_uint64l_t const sh_addr = get_te64(&shdr->sh_addr);
|
upx_uint64_t const sh_addr = get_te64(&shdr->sh_addr);
|
||||||
if ( sh_addr==va_gash
|
if ( sh_addr==va_gash
|
||||||
|| (sh_addr==va_hash && 0==va_gash) ) {
|
|| (sh_addr==va_hash && 0==va_gash) ) {
|
||||||
shdr= &shdri[get_te32(&shdr->sh_link)]; // the associated SHT_SYMTAB
|
shdr= &shdri[get_te32(&shdr->sh_link)]; // the associated SHT_SYMTAB
|
||||||
@@ -2871,7 +2871,7 @@ void PackLinuxElf64::pack4(OutputFile *fo, Filter &ft)
|
|||||||
|
|
||||||
// rewrite Elf header
|
// rewrite Elf header
|
||||||
if (Elf64_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
|
if (Elf64_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
|
||||||
acc_uint64l_t const base= get_te64(&elfout.phdr[0].p_vaddr);
|
upx_uint64_t const base= get_te64(&elfout.phdr[0].p_vaddr);
|
||||||
set_te16(&elfout.ehdr.e_type, Elf64_Ehdr::ET_DYN);
|
set_te16(&elfout.ehdr.e_type, Elf64_Ehdr::ET_DYN);
|
||||||
set_te16(&elfout.ehdr.e_phnum, 1);
|
set_te16(&elfout.ehdr.e_phnum, 1);
|
||||||
set_te64( &elfout.ehdr.e_entry,
|
set_te64( &elfout.ehdr.e_entry,
|
||||||
@@ -2889,7 +2889,7 @@ void PackLinuxElf64::pack4(OutputFile *fo, Filter &ft)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (Elf64_Phdr::PT_NOTE==get_te64(&elfout.phdr[2].p_type)) {
|
if (Elf64_Phdr::PT_NOTE==get_te64(&elfout.phdr[2].p_type)) {
|
||||||
acc_uint64l_t const reloc = get_te64(&elfout.phdr[0].p_vaddr);
|
upx_uint64_t const reloc = get_te64(&elfout.phdr[0].p_vaddr);
|
||||||
set_te64( &elfout.phdr[2].p_vaddr,
|
set_te64( &elfout.phdr[2].p_vaddr,
|
||||||
reloc + get_te64(&elfout.phdr[2].p_vaddr));
|
reloc + get_te64(&elfout.phdr[2].p_vaddr));
|
||||||
set_te64( &elfout.phdr[2].p_paddr,
|
set_te64( &elfout.phdr[2].p_paddr,
|
||||||
@@ -2918,7 +2918,7 @@ void PackLinuxElf64::unpack(OutputFile *fo)
|
|||||||
{
|
{
|
||||||
fi->seek(0, SEEK_SET);
|
fi->seek(0, SEEK_SET);
|
||||||
fi->readx(u.buf, MAX_ELF_HDR);
|
fi->readx(u.buf, MAX_ELF_HDR);
|
||||||
acc_uint64l_t const e_entry = get_te64(&ehdr->e_entry);
|
upx_uint64_t const e_entry = get_te64(&ehdr->e_entry);
|
||||||
if (e_entry < 0x401180
|
if (e_entry < 0x401180
|
||||||
&& ehdr->e_machine==Elf64_Ehdr::EM_386) { /* old style, 8-byte b_info */
|
&& ehdr->e_machine==Elf64_Ehdr::EM_386) { /* old style, 8-byte b_info */
|
||||||
szb_info = 2*sizeof(unsigned);
|
szb_info = 2*sizeof(unsigned);
|
||||||
@@ -2961,8 +2961,8 @@ void PackLinuxElf64::unpack(OutputFile *fo)
|
|||||||
fi->seek(- (off_t) (szb_info + ph.c_len), SEEK_CUR);
|
fi->seek(- (off_t) (szb_info + ph.c_len), SEEK_CUR);
|
||||||
for (unsigned j=0; j < u_phnum; ++phdr, ++j) {
|
for (unsigned j=0; j < u_phnum; ++phdr, ++j) {
|
||||||
if (PT_LOAD64==get_te32(&phdr->p_type)) {
|
if (PT_LOAD64==get_te32(&phdr->p_type)) {
|
||||||
acc_uint64l_t const filesz = get_te64(&phdr->p_filesz);
|
upx_uint64_t const filesz = get_te64(&phdr->p_filesz);
|
||||||
acc_uint64l_t const offset = get_te64(&phdr->p_offset);
|
upx_uint64_t const offset = get_te64(&phdr->p_offset);
|
||||||
if (fo)
|
if (fo)
|
||||||
fo->seek(offset, SEEK_SET);
|
fo->seek(offset, SEEK_SET);
|
||||||
if (Elf64_Phdr::PF_X & get_te32(&phdr->p_flags)) {
|
if (Elf64_Phdr::PF_X & get_te32(&phdr->p_flags)) {
|
||||||
@@ -3221,7 +3221,7 @@ PackLinuxElf32::elf_find_dynamic(unsigned int const key) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
acc_uint64l_t
|
upx_uint64_t
|
||||||
PackLinuxElf32::elf_unsigned_dynamic(unsigned int const key) const
|
PackLinuxElf32::elf_unsigned_dynamic(unsigned int const key) const
|
||||||
{
|
{
|
||||||
Elf32_Dyn const *dynp= dynseg;
|
Elf32_Dyn const *dynp= dynseg;
|
||||||
@@ -3232,13 +3232,13 @@ PackLinuxElf32::elf_unsigned_dynamic(unsigned int const key) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
acc_uint64l_t
|
upx_uint64_t
|
||||||
PackLinuxElf64::elf_get_offset_from_address(acc_uint64l_t const addr) const
|
PackLinuxElf64::elf_get_offset_from_address(upx_uint64_t const addr) const
|
||||||
{
|
{
|
||||||
Elf64_Phdr const *phdr = phdri;
|
Elf64_Phdr const *phdr = phdri;
|
||||||
int j = e_phnum;
|
int j = e_phnum;
|
||||||
for (; --j>=0; ++phdr) if (PT_LOAD64 == get_te32(&phdr->p_type)) {
|
for (; --j>=0; ++phdr) if (PT_LOAD64 == get_te32(&phdr->p_type)) {
|
||||||
acc_uint64l_t const t = addr - get_te64(&phdr->p_vaddr);
|
upx_uint64_t const t = addr - get_te64(&phdr->p_vaddr);
|
||||||
if (t < get_te64(&phdr->p_filesz)) {
|
if (t < get_te64(&phdr->p_filesz)) {
|
||||||
return t + get_te64(&phdr->p_offset);
|
return t + get_te64(&phdr->p_offset);
|
||||||
}
|
}
|
||||||
@@ -3263,7 +3263,7 @@ PackLinuxElf64::elf_find_dynamic(unsigned int const key) const
|
|||||||
Elf64_Dyn const *dynp= dynseg;
|
Elf64_Dyn const *dynp= dynseg;
|
||||||
if (dynp)
|
if (dynp)
|
||||||
for (; Elf64_Dyn::DT_NULL!=dynp->d_tag; ++dynp) if (get_te64(&dynp->d_tag)==key) {
|
for (; Elf64_Dyn::DT_NULL!=dynp->d_tag; ++dynp) if (get_te64(&dynp->d_tag)==key) {
|
||||||
acc_uint64l_t const t= elf_get_offset_from_address(get_te64(&dynp->d_val));
|
upx_uint64_t const t= elf_get_offset_from_address(get_te64(&dynp->d_val));
|
||||||
if (t) {
|
if (t) {
|
||||||
return (size_t)t + file_image;
|
return (size_t)t + file_image;
|
||||||
}
|
}
|
||||||
@@ -3272,7 +3272,7 @@ PackLinuxElf64::elf_find_dynamic(unsigned int const key) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
acc_uint64l_t
|
upx_uint64_t
|
||||||
PackLinuxElf64::elf_unsigned_dynamic(unsigned int const key) const
|
PackLinuxElf64::elf_unsigned_dynamic(unsigned int const key) const
|
||||||
{
|
{
|
||||||
Elf64_Dyn const *dynp= dynseg;
|
Elf64_Dyn const *dynp= dynseg;
|
||||||
|
|||||||
+7
-7
@@ -64,7 +64,7 @@ protected:
|
|||||||
virtual void unpack(OutputFile *fo);
|
virtual void unpack(OutputFile *fo);
|
||||||
|
|
||||||
//virtual void const *elf_find_dynamic(unsigned) const = 0;
|
//virtual void const *elf_find_dynamic(unsigned) const = 0;
|
||||||
virtual acc_uint64l_t elf_unsigned_dynamic(unsigned) const = 0;
|
virtual upx_uint64_t elf_unsigned_dynamic(unsigned) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
unsigned e_phnum; /* Program header table entry count */
|
unsigned e_phnum; /* Program header table entry count */
|
||||||
@@ -79,8 +79,8 @@ protected:
|
|||||||
unsigned page_size; // 1u<<lg2_page
|
unsigned page_size; // 1u<<lg2_page
|
||||||
unsigned xct_off; // shared library: file offset of SHT_EXECINSTR
|
unsigned xct_off; // shared library: file offset of SHT_EXECINSTR
|
||||||
unsigned hatch_off; // file offset of escape hatch
|
unsigned hatch_off; // file offset of escape hatch
|
||||||
acc_uint64l_t load_va; // PT_LOAD[0].p_vaddr
|
upx_uint64_t load_va; // PT_LOAD[0].p_vaddr
|
||||||
acc_uint64l_t xct_va; // minimum SHT_EXECINSTR virtual address
|
upx_uint64_t xct_va; // minimum SHT_EXECINSTR virtual address
|
||||||
|
|
||||||
unsigned short e_machine;
|
unsigned short e_machine;
|
||||||
unsigned char ei_class;
|
unsigned char ei_class;
|
||||||
@@ -142,7 +142,7 @@ protected:
|
|||||||
Elf32_Shdr const *elf_find_section_type(unsigned) const;
|
Elf32_Shdr const *elf_find_section_type(unsigned) const;
|
||||||
void const *elf_find_dynamic(unsigned) const;
|
void const *elf_find_dynamic(unsigned) const;
|
||||||
Elf32_Dyn const *elf_has_dynamic(unsigned) const;
|
Elf32_Dyn const *elf_has_dynamic(unsigned) const;
|
||||||
acc_uint64l_t elf_unsigned_dynamic(unsigned) const;
|
upx_uint64_t elf_unsigned_dynamic(unsigned) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Elf32_Ehdr ehdri; // from input file
|
Elf32_Ehdr ehdri; // from input file
|
||||||
@@ -250,12 +250,12 @@ protected:
|
|||||||
virtual unsigned find_LOAD_gap(Elf64_Phdr const *const phdri, unsigned const k,
|
virtual unsigned find_LOAD_gap(Elf64_Phdr const *const phdri, unsigned const k,
|
||||||
unsigned const e_phnum);
|
unsigned const e_phnum);
|
||||||
|
|
||||||
virtual acc_uint64l_t elf_get_offset_from_address(acc_uint64l_t) const;
|
virtual upx_uint64_t elf_get_offset_from_address(upx_uint64_t) const;
|
||||||
Elf64_Shdr const *elf_find_section_name(char const *) const;
|
Elf64_Shdr const *elf_find_section_name(char const *) const;
|
||||||
Elf64_Shdr const *elf_find_section_type(unsigned) const;
|
Elf64_Shdr const *elf_find_section_type(unsigned) const;
|
||||||
void const *elf_find_dynamic(unsigned) const;
|
void const *elf_find_dynamic(unsigned) const;
|
||||||
Elf64_Dyn const *elf_has_dynamic(unsigned) const;
|
Elf64_Dyn const *elf_has_dynamic(unsigned) const;
|
||||||
acc_uint64l_t elf_unsigned_dynamic(unsigned) const;
|
upx_uint64_t elf_unsigned_dynamic(unsigned) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Elf64_Ehdr ehdri; // from input file
|
Elf64_Ehdr ehdri; // from input file
|
||||||
@@ -263,7 +263,7 @@ protected:
|
|||||||
unsigned char *note_body; // concatenated contents of PT_NOTEs, if any
|
unsigned char *note_body; // concatenated contents of PT_NOTEs, if any
|
||||||
unsigned note_size; // total size of PT_NOTEs
|
unsigned note_size; // total size of PT_NOTEs
|
||||||
Elf64_Shdr const *shdri; // from input file
|
Elf64_Shdr const *shdri; // from input file
|
||||||
acc_uint64l_t page_mask; // AND clears the offset-within-page
|
upx_uint64_t page_mask; // AND clears the offset-within-page
|
||||||
|
|
||||||
Elf64_Dyn const *dynseg; // from PT_DYNAMIC
|
Elf64_Dyn const *dynseg; // from PT_DYNAMIC
|
||||||
unsigned int const *hashtab; // from DT_HASH
|
unsigned int const *hashtab; // from DT_HASH
|
||||||
|
|||||||
+1
-1
@@ -375,7 +375,7 @@ PackLinuxI386::buildLinuxLoader(
|
|||||||
addLoader("FOLDEXEC", NULL);
|
addLoader("FOLDEXEC", NULL);
|
||||||
if (M_IS_LZMA(ph.method)) {
|
if (M_IS_LZMA(ph.method)) {
|
||||||
const lzma_compress_result_t *res = &ph.compress_result.result_lzma;
|
const lzma_compress_result_t *res = &ph.compress_result.result_lzma;
|
||||||
acc_uint32e_t properties = // lc, lp, pb, dummy
|
upx_uint32_t properties = // lc, lp, pb, dummy
|
||||||
(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);
|
||||||
|
|||||||
+2
-2
@@ -470,8 +470,8 @@ PackMachBase<T>::compare_segment_command(void const *const aa, void const *const
|
|||||||
|
|
||||||
#undef PAGE_MASK64
|
#undef PAGE_MASK64
|
||||||
#undef PAGE_SIZE64
|
#undef PAGE_SIZE64
|
||||||
#define PAGE_MASK64 (~(acc_uint64l_t)0<<12)
|
#define PAGE_MASK64 (~(upx_uint64_t)0<<12)
|
||||||
#define PAGE_SIZE64 ((acc_uint64l_t)0-PAGE_MASK64)
|
#define PAGE_SIZE64 ((upx_uint64_t)0-PAGE_MASK64)
|
||||||
|
|
||||||
// At 2013-02-03 part of the source for codesign was
|
// At 2013-02-03 part of the source for codesign was
|
||||||
// http://opensource.apple.com/source/cctools/cctools-836/libstuff/ofile.c
|
// http://opensource.apple.com/source/cctools/cctools-836/libstuff/ofile.c
|
||||||
|
|||||||
+1
-1
@@ -608,7 +608,7 @@ protected:
|
|||||||
Mach_segment_command *rawmseg; // as input, with sections
|
Mach_segment_command *rawmseg; // as input, with sections
|
||||||
Mach_segment_command *msegcmd; // LC_SEGMENT first, without sections
|
Mach_segment_command *msegcmd; // LC_SEGMENT first, without sections
|
||||||
unsigned o_routines_cmd; // file offset to LC_ROUINTES
|
unsigned o_routines_cmd; // file offset to LC_ROUINTES
|
||||||
acc_uint64l_t prev_init_address;
|
upx_uint64_t prev_init_address;
|
||||||
Mach_header mhdri;
|
Mach_header mhdri;
|
||||||
|
|
||||||
Mach_header mhdro;
|
Mach_header mhdro;
|
||||||
|
|||||||
+1
-1
@@ -591,7 +591,7 @@ void PackBvmlinuzI386::pack(OutputFile *fo)
|
|||||||
|
|
||||||
if (M_IS_LZMA(ph.method)) {
|
if (M_IS_LZMA(ph.method)) {
|
||||||
const lzma_compress_result_t *res = &ph.compress_result.result_lzma;
|
const lzma_compress_result_t *res = &ph.compress_result.result_lzma;
|
||||||
acc_uint32e_t properties = // lc, lp, pb, dummy
|
upx_uint32_t properties = // lc, lp, pb, dummy
|
||||||
(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);
|
||||||
|
|||||||
+2
-2
@@ -512,7 +512,7 @@ void PackW64Pep::processTls(Interval *iv) // pass 1
|
|||||||
throwCantPack("invalid TLS callback");
|
throwCantPack("invalid TLS callback");
|
||||||
else if (tlsp->callbacks - ih.imagebase + 4 >= ih.imagesize)
|
else if (tlsp->callbacks - ih.imagebase + 4 >= ih.imagesize)
|
||||||
throwCantPack("invalid TLS callback");
|
throwCantPack("invalid TLS callback");
|
||||||
acc_uint64l_t v = get_le64(ibuf + (tlsp->callbacks - ih.imagebase));
|
upx_uint64_t v = get_le64(ibuf + (tlsp->callbacks - ih.imagebase));
|
||||||
if (v != 0)
|
if (v != 0)
|
||||||
{
|
{
|
||||||
//count number of callbacks, just for information string - Stefan Widmann
|
//count number of callbacks, just for information string - Stefan Widmann
|
||||||
@@ -580,7 +580,7 @@ void PackW64Pep::processTls(Reloc *rel,const Interval *iv,unsigned newaddr) // p
|
|||||||
for (ic = 0; ic < iv->ivnum; ic += 4)
|
for (ic = 0; ic < iv->ivnum; ic += 4)
|
||||||
{
|
{
|
||||||
void *p = otls + iv->ivarr[ic].start - (tlsp->datastart - ih.imagebase) + sizeof(tls);
|
void *p = otls + iv->ivarr[ic].start - (tlsp->datastart - ih.imagebase) + sizeof(tls);
|
||||||
acc_uint64l_t kc = get_le64(p); //changed to LE64 - Stefan Widmann
|
upx_uint64_t kc = get_le64(p); //changed to LE64 - Stefan Widmann
|
||||||
if (kc < tlsp->dataend && kc >= tlsp->datastart)
|
if (kc < tlsp->dataend && kc >= tlsp->datastart)
|
||||||
{
|
{
|
||||||
kc += newaddr + sizeof(tls) - tlsp->datastart;
|
kc += newaddr + sizeof(tls) - tlsp->datastart;
|
||||||
|
|||||||
+6
-6
@@ -292,12 +292,12 @@ protected:
|
|||||||
static unsigned unoptimizeReloc64(upx_byte **in,upx_byte *image,MemBuffer *out,int bs);
|
static unsigned unoptimizeReloc64(upx_byte **in,upx_byte *image,MemBuffer *out,int bs);
|
||||||
|
|
||||||
// target endianness abstraction
|
// target endianness abstraction
|
||||||
unsigned get_te16(const void *p) const { return bele->get16(p); }
|
unsigned get_te16(const void *p) const { return bele->get16(p); }
|
||||||
unsigned get_te32(const void *p) const { return bele->get32(p); }
|
unsigned get_te32(const void *p) const { return bele->get32(p); }
|
||||||
acc_uint64l_t get_te64(const void *p) const { return bele->get64(p); }
|
upx_uint64_t get_te64(const void *p) const { return bele->get64(p); }
|
||||||
void set_te16(void *p, unsigned v) const { bele->set16(p, v); }
|
void set_te16(void *p, unsigned v) const { bele->set16(p, v); }
|
||||||
void set_te32(void *p, unsigned v) const { bele->set32(p, v); }
|
void set_te32(void *p, unsigned v) const { bele->set32(p, v); }
|
||||||
void set_te64(void *p, acc_uint64l_t v) const { bele->set64(p, v); }
|
void set_te64(void *p, upx_uint64_t v) const { bele->set64(p, v); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const N_BELE_RTP::AbstractPolicy *bele; // target endianness
|
const N_BELE_RTP::AbstractPolicy *bele; // target endianness
|
||||||
|
|||||||
+1
-1
@@ -266,7 +266,7 @@ void Packer::defineDecompressorSymbols()
|
|||||||
if (M_IS_LZMA(ph.method))
|
if (M_IS_LZMA(ph.method))
|
||||||
{
|
{
|
||||||
const lzma_compress_result_t *res = &ph.compress_result.result_lzma;
|
const lzma_compress_result_t *res = &ph.compress_result.result_lzma;
|
||||||
acc_uint32e_t properties = // lc, lp, pb, dummy
|
upx_uint32_t properties = // lc, lp, pb, dummy
|
||||||
(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);
|
||||||
|
|||||||
+4
-4
@@ -72,9 +72,9 @@
|
|||||||
|
|
||||||
#undef LLONG
|
#undef LLONG
|
||||||
#undef ULLONG
|
#undef ULLONG
|
||||||
#if 1 && defined(acc_int64l_t)
|
#if 1 && defined(upx_int64_t)
|
||||||
# define LLONG acc_int64l_t
|
# define LLONG upx_int64_t
|
||||||
# define ULLONG acc_uint64l_t
|
# define ULLONG upx_uint64_t
|
||||||
#else
|
#else
|
||||||
# define LLONG long int
|
# define LLONG long int
|
||||||
# define ULLONG unsigned long int
|
# define ULLONG unsigned long int
|
||||||
@@ -713,7 +713,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args
|
|||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
strvalue = (const char *) va_arg (args, const void *);
|
strvalue = (const char *) va_arg (args, const void *);
|
||||||
fmtint (buffer, &currlen, maxlen, (LLONG) (acc_uintptr_t) strvalue, 16, min, max, flags);
|
fmtint (buffer, &currlen, maxlen, (LLONG) (upx_uintptr_t) strvalue, 16, min, max, flags);
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
if (cflags == DP_C_SHORT) {
|
if (cflags == DP_C_SHORT) {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ void *VirtualAlloc(void *address, unsigned size, unsigned type, unsigned protect
|
|||||||
# define PAGE_EXECUTE_READWRITE 0x0040
|
# define PAGE_EXECUTE_READWRITE 0x0040
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef size_t acc_uintptr_t;
|
typedef size_t upx_uintptr_t;
|
||||||
typedef unsigned short LE16;
|
typedef unsigned short LE16;
|
||||||
typedef unsigned int LE32;
|
typedef unsigned int LE32;
|
||||||
#define get_le32(p) (* (const unsigned *) (p))
|
#define get_le32(p) (* (const unsigned *) (p))
|
||||||
|
|||||||
+12
-12
@@ -88,8 +88,8 @@ int __acc_cdecl_qsort be32_compare(const void *e1, const void *e2)
|
|||||||
|
|
||||||
int __acc_cdecl_qsort be64_compare(const void *e1, const void *e2)
|
int __acc_cdecl_qsort be64_compare(const void *e1, const void *e2)
|
||||||
{
|
{
|
||||||
const acc_uint64l_t d1 = get_be64(e1);
|
const upx_uint64_t d1 = get_be64(e1);
|
||||||
const acc_uint64l_t d2 = get_be64(e2);
|
const upx_uint64_t d2 = get_be64(e2);
|
||||||
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,8 +116,8 @@ int __acc_cdecl_qsort le32_compare(const void *e1, const void *e2)
|
|||||||
|
|
||||||
int __acc_cdecl_qsort le64_compare(const void *e1, const void *e2)
|
int __acc_cdecl_qsort le64_compare(const void *e1, const void *e2)
|
||||||
{
|
{
|
||||||
const acc_uint64l_t d1 = get_le64(e1);
|
const upx_uint64_t d1 = get_le64(e1);
|
||||||
const acc_uint64l_t d2 = get_le64(e2);
|
const upx_uint64_t d2 = get_le64(e2);
|
||||||
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,8 +145,8 @@ int __acc_cdecl_qsort be32_compare_signed(const void *e1, const void *e2)
|
|||||||
|
|
||||||
int __acc_cdecl_qsort be64_compare_signed(const void *e1, const void *e2)
|
int __acc_cdecl_qsort be64_compare_signed(const void *e1, const void *e2)
|
||||||
{
|
{
|
||||||
const acc_int64l_t d1 = get_be64_signed(e1);
|
const upx_int64_t d1 = get_be64_signed(e1);
|
||||||
const acc_int64l_t d2 = get_be64_signed(e2);
|
const upx_int64_t d2 = get_be64_signed(e2);
|
||||||
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,8 +173,8 @@ int __acc_cdecl_qsort le32_compare_signed(const void *e1, const void *e2)
|
|||||||
|
|
||||||
int __acc_cdecl_qsort le64_compare_signed(const void *e1, const void *e2)
|
int __acc_cdecl_qsort le64_compare_signed(const void *e1, const void *e2)
|
||||||
{
|
{
|
||||||
const acc_int64l_t d1 = get_le64_signed(e1);
|
const upx_int64_t d1 = get_le64_signed(e1);
|
||||||
const acc_int64l_t d2 = get_le64_signed(e2);
|
const upx_int64_t d2 = get_le64_signed(e2);
|
||||||
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ int find_be32(const void *b, int blen, unsigned what)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int find_be64(const void *b, int blen, acc_uint64l_t what)
|
int find_be64(const void *b, int blen, upx_uint64_t what)
|
||||||
{
|
{
|
||||||
unsigned char w[8];
|
unsigned char w[8];
|
||||||
set_be64(w, what);
|
set_be64(w, what);
|
||||||
@@ -241,7 +241,7 @@ int find_le32(const void *b, int blen, unsigned what)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int find_le64(const void *b, int blen, acc_uint64l_t what)
|
int find_le64(const void *b, int blen, upx_uint64_t what)
|
||||||
{
|
{
|
||||||
unsigned char w[8];
|
unsigned char w[8];
|
||||||
set_le64(w, what);
|
set_le64(w, what);
|
||||||
@@ -562,8 +562,8 @@ unsigned get_ratio(unsigned u_len, unsigned c_len)
|
|||||||
const unsigned n = 1000000;
|
const unsigned n = 1000000;
|
||||||
if (u_len <= 0)
|
if (u_len <= 0)
|
||||||
return c_len <= 0 ? 0 : n;
|
return c_len <= 0 ? 0 : n;
|
||||||
#if defined(acc_uint64l_t)
|
#if defined(upx_uint64_t)
|
||||||
return (unsigned) ((c_len * (acc_uint64l_t)n) / u_len);
|
return (unsigned) ((c_len * (upx_uint64_t)n) / u_len);
|
||||||
#else
|
#else
|
||||||
# if 0
|
# if 0
|
||||||
return (unsigned) acc_umuldiv32(c_len, n, u_len);
|
return (unsigned) acc_umuldiv32(c_len, n, u_len);
|
||||||
|
|||||||
+2
-2
@@ -53,10 +53,10 @@ void center_string(char *buf, size_t size, const char *s);
|
|||||||
int find(const void *b, int blen, const void *what, int wlen);
|
int find(const void *b, int blen, const void *what, int wlen);
|
||||||
int find_be16(const void *b, int blen, unsigned what);
|
int find_be16(const void *b, int blen, unsigned what);
|
||||||
int find_be32(const void *b, int blen, unsigned what);
|
int find_be32(const void *b, int blen, unsigned what);
|
||||||
int find_be64(const void *b, int blen, acc_uint64l_t what);
|
int find_be64(const void *b, int blen, upx_uint64_t what);
|
||||||
int find_le16(const void *b, int blen, unsigned what);
|
int find_le16(const void *b, int blen, unsigned what);
|
||||||
int find_le32(const void *b, int blen, unsigned what);
|
int find_le32(const void *b, int blen, unsigned what);
|
||||||
int find_le64(const void *b, int blen, acc_uint64l_t what);
|
int find_le64(const void *b, int blen, upx_uint64_t what);
|
||||||
|
|
||||||
int mem_replace(void *b, int blen, const void *what, int wlen, const void *r);
|
int mem_replace(void *b, int blen, const void *what, int wlen, const void *r);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user