merge
This commit is contained in:
commit
ec5ff4e973
6
NEWS
6
NEWS
@ -7,8 +7,10 @@ Changes in 2.90 (xx Aug 2006):
|
||||
* new executable format BSD/elf386 supports FreeBSD, NetBSD, OpenBSD [how?]
|
||||
* lzma algorithm support (--lzma; --brute [?])
|
||||
|
||||
Changes in 2.02 (xx Aug 2006):
|
||||
* work around Linux kernel bug (".bss" requires PF_W)
|
||||
Changes in 2.02 (13 Aug 2006):
|
||||
* linux/386: work around Linux kernel bug (".bss" requires PF_W)
|
||||
* linux/ppc32, mach/ppc32: compressed programs now work on a 405 CPU
|
||||
* vmlinuz/386: fixed zlib uncompression problem on dos
|
||||
|
||||
Changes in 2.01 (06 Jun 2006):
|
||||
* arm/pe: better DLL support
|
||||
|
||||
175
src/bele.h
175
src/bele.h
@ -477,165 +477,32 @@ int __acc_cdecl_qsort le64_compare_signed(const void *, const void *);
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// Provide namespaces and classes to abtract endianness policies.
|
||||
//
|
||||
// CTP - Compile-Time Polymorphism (templates)
|
||||
// RTP - Run-Time Polymorphism (virtual functions)
|
||||
**************************************************************************/
|
||||
|
||||
namespace NBELE {
|
||||
// forward declarations
|
||||
namespace N_BELE_CTP {
|
||||
class BEPolicy; class LEPolicy;
|
||||
}
|
||||
namespace N_BELE_RTP {
|
||||
class AbstractPolicy;
|
||||
class BEPolicy; class LEPolicy;
|
||||
}
|
||||
|
||||
struct BEPolicy
|
||||
{
|
||||
enum { isBE = 1, isLE = 0 };
|
||||
namespace N_BELE_CTP {
|
||||
#define BELE_CTP 1
|
||||
#include "bele_policy.h"
|
||||
#undef BELE_CTP
|
||||
}
|
||||
|
||||
typedef BE16 U16;
|
||||
typedef BE32 U32;
|
||||
typedef BE64 U64;
|
||||
|
||||
static inline unsigned get16(const void *p)
|
||||
{ return get_be16(p); }
|
||||
static inline unsigned get24(const void *p)
|
||||
{ return get_be24(p); }
|
||||
static inline unsigned get32(const void *p)
|
||||
{ return get_be32(p); }
|
||||
static inline acc_uint64l_t get64(const void *p)
|
||||
{ return get_be64(p); }
|
||||
|
||||
static inline void set16(void *p, unsigned v)
|
||||
{ set_be16(p, v); }
|
||||
static inline void set24(void *p, unsigned v)
|
||||
{ set_be24(p, v); }
|
||||
static inline void set32(void *p, unsigned v)
|
||||
{ set_be32(p, v); }
|
||||
static inline void set64(void *p, acc_uint64l_t v)
|
||||
{ set_be64(p, v); }
|
||||
|
||||
static inline unsigned get16_signed(const void *p)
|
||||
{ return get_be16_signed(p); }
|
||||
static inline unsigned get24_signed(const void *p)
|
||||
{ return get_be24_signed(p); }
|
||||
static inline unsigned get32_signed(const void *p)
|
||||
{ return get_be32_signed(p); }
|
||||
static inline acc_uint64l_t get64_signed(const void *p)
|
||||
{ return get_be64_signed(p); }
|
||||
|
||||
static int __acc_cdecl_qsort u16_compare(const void *a, const void *b)
|
||||
{ return be16_compare(a, b); }
|
||||
static int __acc_cdecl_qsort u24_compare(const void *a, const void *b)
|
||||
{ return be24_compare(a, b); }
|
||||
static int __acc_cdecl_qsort u32_compare(const void *a, const void *b)
|
||||
{ return be32_compare(a, b); }
|
||||
static int __acc_cdecl_qsort u64_compare(const void *a, const void *b)
|
||||
{ return be64_compare(a, b); }
|
||||
|
||||
static int __acc_cdecl_qsort u16_compare_signed(const void *a, const void *b)
|
||||
{ return be16_compare_signed(a, b); }
|
||||
static int __acc_cdecl_qsort u24_compare_signed(const void *a, const void *b)
|
||||
{ return be24_compare_signed(a, b); }
|
||||
static int __acc_cdecl_qsort u32_compare_signed(const void *a, const void *b)
|
||||
{ return be32_compare_signed(a, b); }
|
||||
static int __acc_cdecl_qsort u64_compare_signed(const void *a, const void *b)
|
||||
{ return be64_compare_signed(a, b); }
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
|
||||
COMPILE_TIME_ASSERT(sizeof(U32) == 4)
|
||||
COMPILE_TIME_ASSERT(sizeof(U64) == 8)
|
||||
COMPILE_TIME_ASSERT_ALIGNOF(U16, char)
|
||||
COMPILE_TIME_ASSERT_ALIGNOF(U32, char)
|
||||
COMPILE_TIME_ASSERT_ALIGNOF(U64, char)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct LEPolicy
|
||||
{
|
||||
enum { isBE = 0, isLE = 1 };
|
||||
|
||||
typedef LE16 U16;
|
||||
typedef LE32 U32;
|
||||
typedef LE64 U64;
|
||||
|
||||
static inline unsigned get16(const void *p)
|
||||
{ return get_le16(p); }
|
||||
static inline unsigned get24(const void *p)
|
||||
{ return get_le24(p); }
|
||||
static inline unsigned get32(const void *p)
|
||||
{ return get_le32(p); }
|
||||
static inline acc_uint64l_t get64(const void *p)
|
||||
{ return get_le64(p); }
|
||||
|
||||
static inline void set16(void *p, unsigned v)
|
||||
{ set_le16(p, v); }
|
||||
static inline void set24(void *p, unsigned v)
|
||||
{ set_le24(p, v); }
|
||||
static inline void set32(void *p, unsigned v)
|
||||
{ set_le32(p, v); }
|
||||
static inline void set64(void *p, acc_uint64l_t v)
|
||||
{ set_le64(p, v); }
|
||||
|
||||
static inline unsigned get16_signed(const void *p)
|
||||
{ return get_le16_signed(p); }
|
||||
static inline unsigned get24_signed(const void *p)
|
||||
{ return get_le24_signed(p); }
|
||||
static inline unsigned get32_signed(const void *p)
|
||||
{ return get_le32_signed(p); }
|
||||
static inline acc_uint64l_t get64_signed(const void *p)
|
||||
{ return get_le64_signed(p); }
|
||||
|
||||
static int __acc_cdecl_qsort u16_compare(const void *a, const void *b)
|
||||
{ return le16_compare(a, b); }
|
||||
static int __acc_cdecl_qsort u24_compare(const void *a, const void *b)
|
||||
{ return le24_compare(a, b); }
|
||||
static int __acc_cdecl_qsort u32_compare(const void *a, const void *b)
|
||||
{ return le32_compare(a, b); }
|
||||
static int __acc_cdecl_qsort u64_compare(const void *a, const void *b)
|
||||
{ return le64_compare(a, b); }
|
||||
|
||||
static int __acc_cdecl_qsort u16_compare_signed(const void *a, const void *b)
|
||||
{ return le16_compare_signed(a, b); }
|
||||
static int __acc_cdecl_qsort u24_compare_signed(const void *a, const void *b)
|
||||
{ return le24_compare_signed(a, b); }
|
||||
static int __acc_cdecl_qsort u32_compare_signed(const void *a, const void *b)
|
||||
{ return le32_compare_signed(a, b); }
|
||||
static int __acc_cdecl_qsort u64_compare_signed(const void *a, const void *b)
|
||||
{ return le64_compare_signed(a, b); }
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
|
||||
COMPILE_TIME_ASSERT(sizeof(U32) == 4)
|
||||
COMPILE_TIME_ASSERT(sizeof(U64) == 8)
|
||||
COMPILE_TIME_ASSERT_ALIGNOF(U16, char)
|
||||
COMPILE_TIME_ASSERT_ALIGNOF(U32, char)
|
||||
COMPILE_TIME_ASSERT_ALIGNOF(U64, char)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if (ACC_ABI_BIG_ENDIAN)
|
||||
typedef BEPolicy HostPolicy;
|
||||
#elif (ACC_ABI_LITTLE_ENDIAN)
|
||||
typedef LEPolicy HostPolicy;
|
||||
#else
|
||||
# error "ACC_ABI_ENDIAN"
|
||||
#endif
|
||||
|
||||
|
||||
struct HostAlignedPolicy
|
||||
{
|
||||
enum { isBE = HostPolicy::isBE, isLE = HostPolicy::isLE };
|
||||
|
||||
typedef acc_uint16e_t U16;
|
||||
typedef acc_uint32e_t U32;
|
||||
typedef acc_uint64l_t U64;
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
|
||||
COMPILE_TIME_ASSERT(sizeof(U32) == 4)
|
||||
COMPILE_TIME_ASSERT(sizeof(U64) == 8)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace NBELE
|
||||
namespace N_BELE_RTP {
|
||||
#define BELE_RTP 1
|
||||
#include "bele_policy.h"
|
||||
#undef BELE_RTP
|
||||
}
|
||||
|
||||
|
||||
#endif /* already included */
|
||||
|
||||
273
src/bele_policy.h
Normal file
273
src/bele_policy.h
Normal file
@ -0,0 +1,273 @@
|
||||
/* bele_policy.h -- access memory in BigEndian and LittleEndian byte order
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2006 Laszlo Molnar
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
and/or modify them under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __UPX_BELE_H
|
||||
# error "this is an internal include file"
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
#if defined(BELE_CTP)
|
||||
// CTP - Compile-Time Polymorphism (templates)
|
||||
# define V static inline
|
||||
# define S static int __acc_cdecl_qsort
|
||||
# define C
|
||||
#elif defined(BELE_RTP)
|
||||
// RTP - Run-Time Polymorphism (virtual functions)
|
||||
# define V virtual
|
||||
# define S virtual int
|
||||
# define C const
|
||||
#else
|
||||
# error
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(BELE_RTP)
|
||||
struct AbstractPolicy
|
||||
{
|
||||
virtual inline ~AbstractPolicy() {}
|
||||
V bool isBE() C = 0;
|
||||
V bool isLE() C = 0;
|
||||
|
||||
V unsigned get16(const void *p) C = 0;
|
||||
V unsigned get24(const void *p) C = 0;
|
||||
V unsigned get32(const void *p) C = 0;
|
||||
V acc_uint64l_t get64(const void *p) C = 0;
|
||||
|
||||
V void set16(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 set64(void *p, acc_uint64l_t v) C = 0;
|
||||
|
||||
V unsigned get16_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 acc_uint64l_t get64_signed(const void *p) 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 u32_compare(const void *a, const void *b) C = 0;
|
||||
S u64_compare(const void *a, const void *b) C = 0;
|
||||
|
||||
S u16_compare_signed(const void *a, const void *b) C = 0;
|
||||
S u24_compare_signed(const void *a, const void *b) C = 0;
|
||||
S u32_compare_signed(const void *a, const void *b) C = 0;
|
||||
S u64_compare_signed(const void *a, const void *b) C = 0;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
struct BEPolicy
|
||||
#if defined(BELE_RTP)
|
||||
: public AbstractPolicy
|
||||
#endif
|
||||
{
|
||||
#if defined(BELE_CTP)
|
||||
typedef N_BELE_RTP::BEPolicy RTP_Policy;
|
||||
enum { isBE = 1, isLE = 0 };
|
||||
#elif defined(BELE_RTP)
|
||||
typedef N_BELE_CTP::BEPolicy CTP_Policy;
|
||||
V bool isBE() C { return CTP_Policy::isBE; }
|
||||
V bool isLE() C { return CTP_Policy::isLE; }
|
||||
#endif
|
||||
|
||||
typedef BE16 U16;
|
||||
typedef BE32 U32;
|
||||
typedef BE64 U64;
|
||||
|
||||
V unsigned get16(const void *p) C
|
||||
{ return get_be16(p); }
|
||||
V unsigned get24(const void *p) C
|
||||
{ return get_be24(p); }
|
||||
V unsigned get32(const void *p) C
|
||||
{ return get_be32(p); }
|
||||
V acc_uint64l_t get64(const void *p) C
|
||||
{ return get_be64(p); }
|
||||
|
||||
V void set16(void *p, unsigned v) C
|
||||
{ set_be16(p, v); }
|
||||
V void set24(void *p, unsigned v) C
|
||||
{ set_be24(p, v); }
|
||||
V void set32(void *p, unsigned v) C
|
||||
{ set_be32(p, v); }
|
||||
V void set64(void *p, acc_uint64l_t v) C
|
||||
{ set_be64(p, v); }
|
||||
|
||||
V unsigned get16_signed(const void *p) C
|
||||
{ return get_be16_signed(p); }
|
||||
V unsigned get24_signed(const void *p) C
|
||||
{ return get_be24_signed(p); }
|
||||
V unsigned get32_signed(const void *p) C
|
||||
{ return get_be32_signed(p); }
|
||||
V acc_uint64l_t get64_signed(const void *p) C
|
||||
{ return get_be64_signed(p); }
|
||||
|
||||
S u16_compare(const void *a, const void *b) C
|
||||
{ return be16_compare(a, b); }
|
||||
S u24_compare(const void *a, const void *b) C
|
||||
{ return be24_compare(a, b); }
|
||||
S u32_compare(const void *a, const void *b) C
|
||||
{ return be32_compare(a, b); }
|
||||
S u64_compare(const void *a, const void *b) C
|
||||
{ return be64_compare(a, b); }
|
||||
|
||||
S u16_compare_signed(const void *a, const void *b) C
|
||||
{ return be16_compare_signed(a, b); }
|
||||
S u24_compare_signed(const void *a, const void *b) C
|
||||
{ return be24_compare_signed(a, b); }
|
||||
S u32_compare_signed(const void *a, const void *b) C
|
||||
{ return be32_compare_signed(a, b); }
|
||||
S u64_compare_signed(const void *a, const void *b) C
|
||||
{ return be64_compare_signed(a, b); }
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
|
||||
COMPILE_TIME_ASSERT(sizeof(U32) == 4)
|
||||
COMPILE_TIME_ASSERT(sizeof(U64) == 8)
|
||||
COMPILE_TIME_ASSERT_ALIGNOF(U16, char)
|
||||
COMPILE_TIME_ASSERT_ALIGNOF(U32, char)
|
||||
COMPILE_TIME_ASSERT_ALIGNOF(U64, char)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct LEPolicy
|
||||
#if defined(BELE_RTP)
|
||||
: public AbstractPolicy
|
||||
#endif
|
||||
{
|
||||
#if defined(BELE_CTP)
|
||||
typedef N_BELE_RTP::LEPolicy RTP_Policy;
|
||||
enum { isBE = 0, isLE = 1 };
|
||||
#elif defined(BELE_RTP)
|
||||
typedef N_BELE_CTP::LEPolicy CTP_Policy;
|
||||
V bool isBE() C { return CTP_Policy::isBE; }
|
||||
V bool isLE() C { return CTP_Policy::isLE; }
|
||||
#endif
|
||||
|
||||
typedef LE16 U16;
|
||||
typedef LE32 U32;
|
||||
typedef LE64 U64;
|
||||
|
||||
V unsigned get16(const void *p) C
|
||||
{ return get_le16(p); }
|
||||
V unsigned get24(const void *p) C
|
||||
{ return get_le24(p); }
|
||||
V unsigned get32(const void *p) C
|
||||
{ return get_le32(p); }
|
||||
V acc_uint64l_t get64(const void *p) C
|
||||
{ return get_le64(p); }
|
||||
|
||||
V void set16(void *p, unsigned v) C
|
||||
{ set_le16(p, v); }
|
||||
V void set24(void *p, unsigned v) C
|
||||
{ set_le24(p, v); }
|
||||
V void set32(void *p, unsigned v) C
|
||||
{ set_le32(p, v); }
|
||||
V void set64(void *p, acc_uint64l_t v) C
|
||||
{ set_le64(p, v); }
|
||||
|
||||
V unsigned get16_signed(const void *p) C
|
||||
{ return get_le16_signed(p); }
|
||||
V unsigned get24_signed(const void *p) C
|
||||
{ return get_le24_signed(p); }
|
||||
V unsigned get32_signed(const void *p) C
|
||||
{ return get_le32_signed(p); }
|
||||
V acc_uint64l_t get64_signed(const void *p) C
|
||||
{ return get_le64_signed(p); }
|
||||
|
||||
S u16_compare(const void *a, const void *b) C
|
||||
{ return le16_compare(a, b); }
|
||||
S u24_compare(const void *a, const void *b) C
|
||||
{ return le24_compare(a, b); }
|
||||
S u32_compare(const void *a, const void *b) C
|
||||
{ return le32_compare(a, b); }
|
||||
S u64_compare(const void *a, const void *b) C
|
||||
{ return le64_compare(a, b); }
|
||||
|
||||
S u16_compare_signed(const void *a, const void *b) C
|
||||
{ return le16_compare_signed(a, b); }
|
||||
S u24_compare_signed(const void *a, const void *b) C
|
||||
{ return le24_compare_signed(a, b); }
|
||||
S u32_compare_signed(const void *a, const void *b) C
|
||||
{ return le32_compare_signed(a, b); }
|
||||
S u64_compare_signed(const void *a, const void *b) C
|
||||
{ return le64_compare_signed(a, b); }
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
|
||||
COMPILE_TIME_ASSERT(sizeof(U32) == 4)
|
||||
COMPILE_TIME_ASSERT(sizeof(U64) == 8)
|
||||
COMPILE_TIME_ASSERT_ALIGNOF(U16, char)
|
||||
COMPILE_TIME_ASSERT_ALIGNOF(U32, char)
|
||||
COMPILE_TIME_ASSERT_ALIGNOF(U64, char)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if (ACC_ABI_BIG_ENDIAN)
|
||||
typedef BEPolicy HostPolicy;
|
||||
#elif (ACC_ABI_LITTLE_ENDIAN)
|
||||
typedef LEPolicy HostPolicy;
|
||||
#else
|
||||
# error "ACC_ABI_ENDIAN"
|
||||
#endif
|
||||
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
struct HostAlignedPolicy
|
||||
{
|
||||
#if defined(BELE_CTP)
|
||||
enum { isBE = HostPolicy::isBE, isLE = HostPolicy::isLE };
|
||||
#endif
|
||||
|
||||
typedef acc_uint16e_t U16;
|
||||
typedef acc_uint32e_t U32;
|
||||
typedef acc_uint64l_t U64;
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
|
||||
COMPILE_TIME_ASSERT(sizeof(U32) == 4)
|
||||
COMPILE_TIME_ASSERT(sizeof(U64) == 8)
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#undef V
|
||||
#undef S
|
||||
#undef C
|
||||
|
||||
|
||||
/*
|
||||
vi:ts=4:et:nowrap
|
||||
*/
|
||||
|
||||
@ -112,8 +112,8 @@ struct TDefaultLinker : public DefaultLinker
|
||||
virtual void set32(void *b, unsigned v) const { T::set32(b, v); }
|
||||
};
|
||||
|
||||
typedef TDefaultLinker<NBELE::BEPolicy> DefaultBELinker;
|
||||
typedef TDefaultLinker<NBELE::LEPolicy> DefaultLELinker;
|
||||
typedef TDefaultLinker<N_BELE_CTP::BEPolicy> DefaultBELinker;
|
||||
typedef TDefaultLinker<N_BELE_CTP::LEPolicy> DefaultLELinker;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
@ -147,8 +147,8 @@ struct TSimpleLinker : public SimpleLinker
|
||||
virtual void set32(void *b, unsigned v) const { T::set32(b, v); }
|
||||
};
|
||||
|
||||
typedef TSimpleLinker<NBELE::BEPolicy> SimpleBELinker;
|
||||
typedef TSimpleLinker<NBELE::LEPolicy> SimpleLELinker;
|
||||
typedef TSimpleLinker<N_BELE_CTP::BEPolicy> SimpleBELinker;
|
||||
typedef TSimpleLinker<N_BELE_CTP::LEPolicy> SimpleLELinker;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
78
src/p_elf.h
78
src/p_elf.h
@ -34,7 +34,7 @@
|
||||
// Some ELF type definitinons
|
||||
**************************************************************************/
|
||||
|
||||
namespace TT_Elf {
|
||||
namespace N_Elf {
|
||||
|
||||
// The ELF file header. This appears at the start of every ELF file.
|
||||
template <class Word, class Addr, class Off, class Half>
|
||||
@ -116,10 +116,10 @@ struct Dyn
|
||||
}
|
||||
__attribute_packed;
|
||||
|
||||
} // namespace TT_Elf
|
||||
} // namespace N_Elf
|
||||
|
||||
|
||||
namespace TT_Elf32 {
|
||||
namespace N_Elf32 {
|
||||
|
||||
// Program segment header.
|
||||
template <class Word, class Addr, class Off>
|
||||
@ -243,10 +243,10 @@ struct Sym
|
||||
}
|
||||
__attribute_packed;
|
||||
|
||||
} // namespace TT_Elf32
|
||||
} // namespace N_Elf32
|
||||
|
||||
|
||||
namespace TT_Elf64 {
|
||||
namespace N_Elf64 {
|
||||
|
||||
// Program segment header.
|
||||
template <class Word, class Xword, class Addr, class Off>
|
||||
@ -314,56 +314,56 @@ struct Shdr
|
||||
}
|
||||
__attribute_packed;
|
||||
|
||||
} // namespace TT_Elf64
|
||||
} // namespace N_Elf64
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// now for the actual types
|
||||
**************************************************************************/
|
||||
|
||||
#define P NBELE::HostPolicy
|
||||
typedef TT_Elf ::Ehdr<P::U32,P::U32,P::U32,P::U16> Elf32_Ehdr;
|
||||
typedef TT_Elf32::Phdr<P::U32,P::U32,P::U32> Elf32_Phdr;
|
||||
typedef TT_Elf32::Shdr<P::U32,P::U32,P::U32> Elf32_Shdr;
|
||||
typedef TT_Elf ::Dyn <P::U32,P::U32> Elf32_Dyn;
|
||||
typedef TT_Elf32::Sym <P::U16,P::U32> Elf32_Sym;
|
||||
#define P N_BELE_CTP::HostPolicy
|
||||
typedef N_Elf ::Ehdr<P::U32,P::U32,P::U32,P::U16> Elf32_Ehdr;
|
||||
typedef N_Elf32::Phdr<P::U32,P::U32,P::U32> Elf32_Phdr;
|
||||
typedef N_Elf32::Shdr<P::U32,P::U32,P::U32> Elf32_Shdr;
|
||||
typedef N_Elf ::Dyn <P::U32,P::U32> Elf32_Dyn;
|
||||
typedef N_Elf32::Sym <P::U16,P::U32> Elf32_Sym;
|
||||
#undef P
|
||||
|
||||
#define P NBELE::BEPolicy
|
||||
typedef TT_Elf ::Ehdr<P::U32,P::U32,P::U32,P::U16> Elf_BE32_Ehdr;
|
||||
typedef TT_Elf32::Phdr<P::U32,P::U32,P::U32> Elf_BE32_Phdr;
|
||||
typedef TT_Elf32::Shdr<P::U32,P::U32,P::U32> Elf_BE32_Shdr;
|
||||
typedef TT_Elf ::Dyn <P::U32,P::U32> Elf_BE32_Dyn;
|
||||
typedef TT_Elf32::Sym <P::U16,P::U32> Elf_BE32_Sym;
|
||||
#define P N_BELE_CTP::BEPolicy
|
||||
typedef N_Elf ::Ehdr<P::U32,P::U32,P::U32,P::U16> Elf_BE32_Ehdr;
|
||||
typedef N_Elf32::Phdr<P::U32,P::U32,P::U32> Elf_BE32_Phdr;
|
||||
typedef N_Elf32::Shdr<P::U32,P::U32,P::U32> Elf_BE32_Shdr;
|
||||
typedef N_Elf ::Dyn <P::U32,P::U32> Elf_BE32_Dyn;
|
||||
typedef N_Elf32::Sym <P::U16,P::U32> Elf_BE32_Sym;
|
||||
#undef P
|
||||
|
||||
#define P NBELE::LEPolicy
|
||||
typedef TT_Elf ::Ehdr<P::U32,P::U32,P::U32,P::U16> Elf_LE32_Ehdr;
|
||||
typedef TT_Elf32::Phdr<P::U32,P::U32,P::U32> Elf_LE32_Phdr;
|
||||
typedef TT_Elf32::Shdr<P::U32,P::U32,P::U32> Elf_LE32_Shdr;
|
||||
typedef TT_Elf ::Dyn <P::U32,P::U32> Elf_LE32_Dyn;
|
||||
typedef TT_Elf32::Sym <P::U16,P::U32> Elf_LE32_Sym;
|
||||
#define P N_BELE_CTP::LEPolicy
|
||||
typedef N_Elf ::Ehdr<P::U32,P::U32,P::U32,P::U16> Elf_LE32_Ehdr;
|
||||
typedef N_Elf32::Phdr<P::U32,P::U32,P::U32> Elf_LE32_Phdr;
|
||||
typedef N_Elf32::Shdr<P::U32,P::U32,P::U32> Elf_LE32_Shdr;
|
||||
typedef N_Elf ::Dyn <P::U32,P::U32> Elf_LE32_Dyn;
|
||||
typedef N_Elf32::Sym <P::U16,P::U32> Elf_LE32_Sym;
|
||||
#undef P
|
||||
|
||||
#define P NBELE::HostPolicy
|
||||
typedef TT_Elf ::Ehdr<P::U32,P::U64,P::U64,P::U16> Elf64_Ehdr;
|
||||
typedef TT_Elf64::Phdr<P::U32,P::U64,P::U64,P::U64> Elf64_Phdr;
|
||||
typedef TT_Elf64::Shdr<P::U32,P::U64,P::U64,P::U64> Elf64_Shdr;
|
||||
typedef TT_Elf ::Dyn <P::U64,P::U64> Elf64_Dyn;
|
||||
#define P N_BELE_CTP::HostPolicy
|
||||
typedef N_Elf ::Ehdr<P::U32,P::U64,P::U64,P::U16> Elf64_Ehdr;
|
||||
typedef N_Elf64::Phdr<P::U32,P::U64,P::U64,P::U64> Elf64_Phdr;
|
||||
typedef N_Elf64::Shdr<P::U32,P::U64,P::U64,P::U64> Elf64_Shdr;
|
||||
typedef N_Elf ::Dyn <P::U64,P::U64> Elf64_Dyn;
|
||||
#undef P
|
||||
|
||||
#define P NBELE::BEPolicy
|
||||
typedef TT_Elf ::Ehdr<P::U32,P::U64,P::U64,P::U16> Elf_BE64_Ehdr;
|
||||
typedef TT_Elf64::Phdr<P::U32,P::U64,P::U64,P::U64> Elf_BE64_Phdr;
|
||||
typedef TT_Elf64::Shdr<P::U32,P::U64,P::U64,P::U64> Elf_BE64_Shdr;
|
||||
typedef TT_Elf ::Dyn <P::U64,P::U64> Elf_BE64_Dyn;
|
||||
#define P N_BELE_CTP::BEPolicy
|
||||
typedef N_Elf ::Ehdr<P::U32,P::U64,P::U64,P::U16> Elf_BE64_Ehdr;
|
||||
typedef N_Elf64::Phdr<P::U32,P::U64,P::U64,P::U64> Elf_BE64_Phdr;
|
||||
typedef N_Elf64::Shdr<P::U32,P::U64,P::U64,P::U64> Elf_BE64_Shdr;
|
||||
typedef N_Elf ::Dyn <P::U64,P::U64> Elf_BE64_Dyn;
|
||||
#undef P
|
||||
|
||||
#define P NBELE::LEPolicy
|
||||
typedef TT_Elf ::Ehdr<P::U32,P::U64,P::U64,P::U16> Elf_LE64_Ehdr;
|
||||
typedef TT_Elf64::Phdr<P::U32,P::U64,P::U64,P::U64> Elf_LE64_Phdr;
|
||||
typedef TT_Elf64::Shdr<P::U32,P::U64,P::U64,P::U64> Elf_LE64_Shdr;
|
||||
typedef TT_Elf ::Dyn <P::U64,P::U64> Elf_LE64_Dyn;
|
||||
#define P N_BELE_CTP::LEPolicy
|
||||
typedef N_Elf ::Ehdr<P::U32,P::U64,P::U64,P::U16> Elf_LE64_Ehdr;
|
||||
typedef N_Elf64::Phdr<P::U32,P::U64,P::U64,P::U64> Elf_LE64_Phdr;
|
||||
typedef N_Elf64::Shdr<P::U32,P::U64,P::U64,P::U64> Elf_LE64_Shdr;
|
||||
typedef N_Elf ::Dyn <P::U64,P::U64> Elf_LE64_Dyn;
|
||||
#undef P
|
||||
|
||||
|
||||
|
||||
@ -551,7 +551,7 @@ PackLinuxElf64amd::addLinkerSymbols(Filter const *)
|
||||
|
||||
#define PAGE_MASK (~0u<<12)
|
||||
#define PAGE_SIZE (-PAGE_MASK)
|
||||
lsize = /*getLoaderSize()*/ 64 * 1024; // upper bound; avoid circularity
|
||||
lsize = /*getLoaderSize()*/ 64 * 1024; // upper bound; avoid circularity
|
||||
acc_uint64l_t const lo_va_user = 0x400000; // XXX
|
||||
acc_uint64l_t lo_va_stub = elfout.phdr[0].p_vaddr;
|
||||
acc_uint64l_t adrc;
|
||||
@ -1125,7 +1125,7 @@ PackOpenBSDElf32x86::generateElfHdr(
|
||||
set_native32(&elfnote.type, 1);
|
||||
strcpy(elfnote.text, "OpenBSD");
|
||||
elfnote.end = 0;
|
||||
|
||||
|
||||
if (ph.format==getFormat()) {
|
||||
memset(&h3->linfo, 0, sizeof(h3->linfo));
|
||||
fo->write(h3, sizeof(*h3) - sizeof(h3->linfo));
|
||||
@ -1481,7 +1481,7 @@ void PackLinuxElf64::pack2(OutputFile *fo, Filter &ft)
|
||||
}
|
||||
|
||||
#include "bele.h"
|
||||
using namespace NBELE;
|
||||
using namespace N_BELE_CTP;
|
||||
|
||||
// Filter 0x50, 0x51 assume HostPolicy::isLE
|
||||
static const int *
|
||||
|
||||
156
src/p_ps1.cpp
156
src/p_ps1.cpp
@ -40,7 +40,6 @@
|
||||
static const
|
||||
#include "stub/mipsel.r3000-ps1.h"
|
||||
|
||||
|
||||
#define CD_SEC 2048
|
||||
#define PS_HDR_SIZE CD_SEC
|
||||
#define PS_RAM_SIZE ram_size
|
||||
@ -48,24 +47,17 @@ static const
|
||||
#define PS_MAX_SIZE ((PS_RAM_SIZE*95) / 100)
|
||||
|
||||
#define SZ_IH_BKUP (10 * sizeof(LE32))
|
||||
#define HD_CODE_OFS (sizeof(ps1_exe_t))
|
||||
|
||||
#if 0
|
||||
// lui / ori
|
||||
# define MIPS_HI(a) ((a) >> 16)
|
||||
#else
|
||||
// lui / addiu
|
||||
# define MIPS_HI(a) (((a) >> 16) + (((a) & 0x8000) >> 15))
|
||||
#endif
|
||||
#define MIPS_LO(a) ((a) & 0xffff)
|
||||
//#define MIPS_JP(a) ((0x08 << 24) | (((a) & 0x0fffffff) >> 2))
|
||||
#define MIPS_PC16(a) ((a) >> 2)
|
||||
#define MIPS_PC26(a) (((a) & 0x0fffffff) >> 2)
|
||||
#define HD_CODE_OFS (sizeof(ps1_exe_t) + sz_cbh)
|
||||
|
||||
#define K0_BS (0x80000000)
|
||||
#define K1_BS (0xa0000000)
|
||||
#define FIX_PSVR (K1_BS - (ih.epc & K0_BS)) + (PS_HDR_SIZE - HD_CODE_OFS)
|
||||
|
||||
// lui / addiu
|
||||
#define MIPS_HI(a) (((a) >> 16) + (((a) & 0x8000) >> 15))
|
||||
#define MIPS_LO(a) ((a) & 0xffff)
|
||||
#define MIPS_PC16(a) ((a) >> 2)
|
||||
#define MIPS_PC26(a) (((a) & 0x0fffffff) >> 2)
|
||||
|
||||
/*************************************************************************
|
||||
// ps1 exe looks like this:
|
||||
@ -83,11 +75,12 @@ static const
|
||||
|
||||
PackPs1::PackPs1(InputFile *f) :
|
||||
super(f),
|
||||
build_Loader(0), isCon(!opt->ps1_exe.boot_only), is32Bit(!opt->ps1_exe.do_8bit),
|
||||
sa_cnt(0), overlap(0), sz_unc(0), sz_cpr(0), pad_code(0)
|
||||
isCon(!opt->ps1_exe.boot_only), is32Bit(!opt->ps1_exe.do_8bit),
|
||||
build_Loader(0), sa_cnt(0), overlap(0), sz_lunc(0), sz_lcpr(0), pad_code(0)
|
||||
{
|
||||
COMPILE_TIME_ASSERT(sizeof(ps1_exe_t) == 136);
|
||||
COMPILE_TIME_ASSERT(sizeof(ps1_exe_cp_t) == 44);
|
||||
COMPILE_TIME_ASSERT(sizeof(ps1_exe_hb_t) == 44);
|
||||
COMPILE_TIME_ASSERT(sizeof(ps1_exe_chb_t) == 5);
|
||||
|
||||
COMPILE_TIME_ASSERT(PS_HDR_SIZE > sizeof(ps1_exe_t));
|
||||
COMPILE_TIME_ASSERT(SZ_IH_BKUP == 40);
|
||||
@ -99,7 +92,6 @@ PackPs1::PackPs1(InputFile *f) :
|
||||
ram_size = !opt->ps1_exe.do_8mb ? 0x200000 : 0x800000;
|
||||
}
|
||||
|
||||
|
||||
const int *PackPs1::getCompressionMethods(int method, int level) const
|
||||
{
|
||||
if (is32Bit)
|
||||
@ -108,13 +100,11 @@ const int *PackPs1::getCompressionMethods(int method, int level) const
|
||||
return Packer::getDefaultCompressionMethods_8(method, level);
|
||||
}
|
||||
|
||||
|
||||
const int *PackPs1::getFilters() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Linker* PackPs1::newLinker() const
|
||||
{
|
||||
class ElfLinkerMipsLE : public ElfLinker
|
||||
@ -141,7 +131,6 @@ Linker* PackPs1::newLinker() const
|
||||
super::relocate1(rel, location, value, type);
|
||||
}
|
||||
};
|
||||
|
||||
return new ElfLinkerMipsLE;
|
||||
}
|
||||
|
||||
@ -155,8 +144,8 @@ int PackPs1::readFileHeader()
|
||||
{
|
||||
fi->seek(0, SEEK_SET);
|
||||
fi->readx(&ih, sizeof(ih));
|
||||
if (memcmp(&ih.id,"PS-X EXE",8) != 0 &&
|
||||
memcmp(&ih.id,"EXE X-SP",8) != 0)
|
||||
if (memcmp(&ih.id, "PS-X EXE", 8) != 0 &&
|
||||
memcmp(&ih.id, "EXE X-SP", 8) != 0)
|
||||
return 0;
|
||||
if (ih.text != 0 || ih.data != 0)
|
||||
return 0;
|
||||
@ -165,20 +154,76 @@ int PackPs1::readFileHeader()
|
||||
|
||||
bool PackPs1::readBkupHeader()
|
||||
{
|
||||
fi->seek(sizeof(ps1_exe_t), SEEK_SET);
|
||||
fi->seek(sizeof(ps1_exe_t)+8, SEEK_SET);
|
||||
fi->readx(&bh, sizeof(bh));
|
||||
|
||||
if (bh.ih_csum != upx_adler32(&bh, SZ_IH_BKUP))
|
||||
{
|
||||
// Compatibility
|
||||
fi->seek(sizeof(ps1_exe_t)+8, SEEK_SET);
|
||||
fi->readx(&bh, sizeof(bh));
|
||||
if (bh.ih_csum != upx_adler32(&bh, SZ_IH_BKUP))
|
||||
unsigned char buf[sizeof(bh)];
|
||||
fi->seek(sizeof(ps1_exe_t), SEEK_SET);
|
||||
fi->readx(buf, sizeof(bh));
|
||||
if (!getBkupHeader(buf, (unsigned char *)&bh))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#define INIT_BH_BKUP(p, l) {(p)->id = '1'; (p)->len = l;}
|
||||
#define ADLER16(a) ((a) >> 16 ^ ((a) & 0xffff))
|
||||
|
||||
void PackPs1::putBkupHeader(const unsigned char *src, unsigned char *dst, unsigned *len)
|
||||
{
|
||||
unsigned sz_cbh;
|
||||
|
||||
if (src && dst)
|
||||
{
|
||||
unsigned char *cpr_bh = new unsigned char[MemBuffer::getSizeForCompression(SZ_IH_BKUP)];
|
||||
|
||||
ps1_exe_chb_t * p = (ps1_exe_chb_t * )cpr_bh;
|
||||
|
||||
int r = upx_compress(src, SZ_IH_BKUP,
|
||||
&p->ih_bkup, &sz_cbh, NULL, M_NRV2E_8, 10, NULL, NULL );
|
||||
if (r != UPX_E_OK || sz_cbh >= SZ_IH_BKUP)
|
||||
throwInternalError("header compression failed");
|
||||
INIT_BH_BKUP(p, sz_cbh);
|
||||
*len = ALIGN_UP(sz_cbh + sizeof(ps1_exe_chb_t) - 1, 4);
|
||||
p->ih_csum = ADLER16(upx_adler32(&ih.epc, SZ_IH_BKUP));
|
||||
memcpy(dst, cpr_bh, SZ_IH_BKUP);
|
||||
delete [] cpr_bh;
|
||||
}
|
||||
else
|
||||
throwInternalError("failed to create backup header");
|
||||
}
|
||||
|
||||
#define ADLER16_HI(a,b) ((((a) & 0xffff) ^ (b)) << 16)
|
||||
#define ADLER16_LO(a,b) (((a) >> 16) ^ (b))
|
||||
#define RE_ADLER16(a,b) (ADLER16_HI(a,b) | ADLER16_LO(a,b))
|
||||
|
||||
bool PackPs1::getBkupHeader(unsigned char *p, unsigned char *dst)
|
||||
{
|
||||
ps1_exe_chb_t *src = (ps1_exe_chb_t*)p;
|
||||
|
||||
if (src && src->id == '1' && dst)
|
||||
{
|
||||
unsigned char *unc_bh = new unsigned char[MemBuffer::getSizeForUncompression(SZ_IH_BKUP)];
|
||||
|
||||
unsigned sz_bh = SZ_IH_BKUP;
|
||||
int r = upx_decompress((const unsigned char *)&src->ih_bkup, src->len,
|
||||
unc_bh, &sz_bh, M_NRV2E_8, NULL );
|
||||
if (r != UPX_E_OK || sz_bh != SZ_IH_BKUP)
|
||||
throwInternalError("header decompression failed");
|
||||
unsigned ad = upx_adler32(unc_bh, SZ_IH_BKUP);
|
||||
unsigned ch = src->ih_csum;
|
||||
if (ad != RE_ADLER16(ad,ch))
|
||||
throwInternalError("backup header damaged");
|
||||
memcpy(dst, unc_bh, SZ_IH_BKUP);
|
||||
delete [] unc_bh;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PackPs1::checkFileHeader()
|
||||
{
|
||||
if (fdata_size != ih.tx_len || (ih.tx_len & 3))
|
||||
@ -215,7 +260,7 @@ bool PackPs1::checkFileHeader()
|
||||
|
||||
bool PackPs1::canPack()
|
||||
{
|
||||
unsigned char buf[PS_HDR_SIZE-HD_CODE_OFS];
|
||||
unsigned char buf[PS_HDR_SIZE - sizeof(ps1_exe_t)];
|
||||
|
||||
if (!readFileHeader())
|
||||
return false;
|
||||
@ -276,7 +321,7 @@ void PackPs1::buildPS1Loader(const Filter *)
|
||||
else
|
||||
throwInternalError("unknown compression method");
|
||||
|
||||
if ((gap = ALIGN_GAP((ph.c_len + (isCon ? sz_cpr : 0)),4)))
|
||||
if ((gap = ALIGN_GAP((ph.c_len + (isCon ? sz_lcpr : 0)),4)))
|
||||
pad_code = gap;
|
||||
else
|
||||
pad_code = 0;
|
||||
@ -328,24 +373,27 @@ int PackPs1::buildLoader(const Filter *)
|
||||
if (ph.method == M_LZMA && !build_Loader)
|
||||
{
|
||||
initLoader(nrv_loader,sizeof(nrv_loader));
|
||||
addLoader("LZMA_DEC10", "lzma.init", NULL);
|
||||
addLoader(isCon ? "LZMA_DEC20" : "LZMA_DEC10", "lzma.init", NULL);
|
||||
addLoader(sa_tmp > (0x10000 << 2) ? "memset.long" : "memset.short",
|
||||
"con.exit", NULL);
|
||||
}
|
||||
else if (ph.method == M_LZMA && build_Loader)
|
||||
{
|
||||
unsigned char *cprLoader = new unsigned char[MemBuffer::getSizeForCompression(sz_unc)];
|
||||
int r = upx_compress(getLoader(), sz_unc, cprLoader, &sz_cpr, NULL, M_NRV2B_8, 10, NULL, NULL );
|
||||
if (r != UPX_E_OK || sz_cpr >= sz_unc)
|
||||
unsigned char *cprLoader = new unsigned char[MemBuffer::getSizeForCompression(sz_lunc)];
|
||||
int r = upx_compress(getLoader(), sz_lunc, cprLoader, &sz_lcpr,
|
||||
NULL, M_NRV2B_8, 10, NULL, NULL );
|
||||
if (r != UPX_E_OK || sz_lcpr >= sz_lunc)
|
||||
throwInternalError("loader compression failed");
|
||||
initLoader(nrv_loader,sizeof(nrv_loader), 0, (ph.method != M_LZMA || isCon) ? 0 : 1);
|
||||
linker->addSection("lzma.exec", cprLoader, sz_cpr, 0);
|
||||
initLoader(nrv_loader,sizeof(nrv_loader), 0,
|
||||
(ph.method != M_LZMA || isCon) ? 0 : 1);
|
||||
linker->addSection("lzma.exec", cprLoader, sz_lcpr, 0);
|
||||
delete [] cprLoader;
|
||||
buildPS1Loader();
|
||||
}
|
||||
else
|
||||
{
|
||||
initLoader(nrv_loader,sizeof(nrv_loader), 0, (ph.method != M_LZMA || isCon) ? 0 : 1);
|
||||
initLoader(nrv_loader,sizeof(nrv_loader), 0,
|
||||
(ph.method != M_LZMA || isCon) ? 0 : 1);
|
||||
buildPS1Loader();
|
||||
}
|
||||
}
|
||||
@ -394,7 +442,7 @@ void PackPs1::pack(OutputFile *fo)
|
||||
if (overlap)
|
||||
{
|
||||
opt->info_mode += !opt->info_mode ? 1 : 0;
|
||||
infoWarning("%s: memory overlap %d bytes",fi->getName(),overlap);
|
||||
infoWarning("%s: memory overlap %d bytes", fi->getName(), overlap);
|
||||
sa_cnt += overlap;
|
||||
}
|
||||
|
||||
@ -402,11 +450,11 @@ void PackPs1::pack(OutputFile *fo)
|
||||
|
||||
if (ph.method == M_LZMA)
|
||||
{
|
||||
sz_unc = getLoaderSize();
|
||||
sz_lunc = getLoaderSize();
|
||||
|
||||
lzma_init = 0u-(sz_unc-linker->getSymbolOffset("lzma.init"));
|
||||
lzma_init = 0u - (sz_lunc - linker->getSymbolOffset("lzma.init"));
|
||||
defineDecompressorSymbols();
|
||||
linker->defineSymbol("lzma_decoder", linker->getSymbolOffset("LZMA_DEC10"));
|
||||
linker->defineSymbol("lzma_decoder", linker->getSymbolOffset(isCon ? "LZMA_DEC20" : "LZMA_DEC10"));
|
||||
linker->defineSymbol("entry", ih.epc);
|
||||
linker->defineSymbol("SC",
|
||||
sa_cnt > (0x10000 << 2) ? sa_cnt >> 5 : sa_cnt >> 2);
|
||||
@ -417,8 +465,9 @@ void PackPs1::pack(OutputFile *fo)
|
||||
}
|
||||
|
||||
memcpy(&oh, &ih, sizeof(ih));
|
||||
memcpy(&bh, &ih.epc, SZ_IH_BKUP);
|
||||
bh.ih_csum = upx_adler32(&ih.epc, SZ_IH_BKUP);
|
||||
|
||||
unsigned sz_cbh;
|
||||
putBkupHeader((const unsigned char *)&ih.epc, (unsigned char *)&bh, &sz_cbh);
|
||||
|
||||
if (ih.is_ptr == 0)
|
||||
oh.is_ptr = PS_RAM_SIZE-0x10;
|
||||
@ -457,7 +506,7 @@ void PackPs1::pack(OutputFile *fo)
|
||||
sa_cnt >> 5 : sa_cnt >> 2));
|
||||
linker->defineSymbol("DECO",decomp_data_start);
|
||||
|
||||
linker->defineSymbol("LS", (ph.method == M_LZMA ? sz_unc+16 : (d_len-pad_code)));
|
||||
linker->defineSymbol("LS", (ph.method == M_LZMA ? sz_lunc + 16 : (d_len-pad_code)));
|
||||
|
||||
const unsigned entry = comp_data_start - e_len;
|
||||
oh.epc = oh.tx_ptr = entry;
|
||||
@ -491,12 +540,6 @@ void PackPs1::pack(OutputFile *fo)
|
||||
linker->relocate();
|
||||
memcpy(loader, getLoader(), lsize);
|
||||
patchPackHeader(loader, lsize);
|
||||
|
||||
// ps1_exe_t structure
|
||||
fo->write(&oh,sizeof(oh));
|
||||
fo->write(&bh,sizeof(bh));
|
||||
// id & upx header
|
||||
fo->write(loader + e_len, h_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -509,14 +552,14 @@ void PackPs1::pack(OutputFile *fo)
|
||||
linker->relocate();
|
||||
memcpy(loader, getLoader(), lsize);
|
||||
patchPackHeader(loader,lsize);
|
||||
|
||||
// ps1_exe_t structure
|
||||
fo->write(&oh,sizeof(oh));
|
||||
fo->write(&bh,sizeof(bh));
|
||||
// decompressor
|
||||
fo->write(loader + e_len, d_len + h_len);
|
||||
}
|
||||
|
||||
// ps1_exe_t structure
|
||||
fo->write(&oh, sizeof(oh));
|
||||
fo->write(&bh, sz_cbh);
|
||||
// decompressor
|
||||
fo->write(loader + e_len, isCon ? h_len : (d_len + h_len));
|
||||
|
||||
// header size is 2048 bytes + sector alignment
|
||||
fo->write(paddata, (pad + PS_HDR_SIZE) - fo->getBytesWritten());
|
||||
// entry
|
||||
@ -532,6 +575,7 @@ void PackPs1::pack(OutputFile *fo)
|
||||
printf("%-13s: uncompressed : %8ld bytes\n", getName(), (long) ph.u_len);
|
||||
printf("%-13s: compressed : %8ld bytes\n", getName(), (long) ph.c_len);
|
||||
printf("%-13s: decompressor : %8ld bytes\n", getName(), (long) lsize - h_len);
|
||||
printf("%-13s: header comp : %8ld bytes\n", getName(), (long) sz_cbh);
|
||||
printf("%-13s: code entry : %08X bytes\n", getName(), (unsigned int) oh.epc);
|
||||
printf("%-13s: load address : %08X bytes\n", getName(), (unsigned int) oh.tx_ptr);
|
||||
printf("%-13s: eof in mem IF: %08X bytes\n", getName(), (unsigned int) ih.tx_ptr+ih.tx_len);
|
||||
|
||||
24
src/p_ps1.h
24
src/p_ps1.h
@ -42,7 +42,7 @@ class PackPs1 : public Packer
|
||||
{
|
||||
typedef Packer super;
|
||||
public:
|
||||
PackPs1(InputFile *f);
|
||||
PackPs1(InputFile *f);
|
||||
virtual int getVersion() const { return 13; }
|
||||
virtual int getFormat() const { return UPX_F_PS1_EXE; }
|
||||
virtual const char *getName() const { return "ps1/exe"; }
|
||||
@ -56,6 +56,8 @@ public:
|
||||
virtual int canUnpack();
|
||||
|
||||
protected:
|
||||
virtual void putBkupHeader(const unsigned char *src, unsigned char *dst, unsigned *len);
|
||||
virtual bool getBkupHeader(unsigned char *src, unsigned char * dst);
|
||||
virtual bool readBkupHeader();
|
||||
virtual void buildPS1Loader(const Filter *ft=0);
|
||||
virtual int buildLoader(const Filter *ft);
|
||||
@ -91,7 +93,8 @@ protected:
|
||||
}
|
||||
__attribute_packed;
|
||||
|
||||
struct ps1_exe_cp_t
|
||||
// for unpack
|
||||
struct ps1_exe_hb_t
|
||||
{
|
||||
LE32 ih_bkup[10];
|
||||
// plus checksum for the backup
|
||||
@ -99,17 +102,24 @@ protected:
|
||||
}
|
||||
__attribute_packed;
|
||||
|
||||
// unpack_only
|
||||
ps1_exe_cp_t bh;
|
||||
struct ps1_exe_chb_t
|
||||
{
|
||||
unsigned char id;
|
||||
unsigned char len;
|
||||
LE16 ih_csum;
|
||||
unsigned char ih_bkup;
|
||||
}
|
||||
__attribute_packed;
|
||||
|
||||
ps1_exe_t ih, oh;
|
||||
ps1_exe_hb_t bh;
|
||||
|
||||
bool build_Loader;
|
||||
bool isCon;
|
||||
bool is32Bit;
|
||||
bool build_Loader;
|
||||
unsigned ram_size;
|
||||
unsigned sa_cnt, overlap;
|
||||
unsigned sz_unc, sz_cpr;
|
||||
unsigned sz_lunc, sz_lcpr;
|
||||
unsigned pad_code;
|
||||
// filesize-PS_HDR_SIZE
|
||||
unsigned fdata_size;
|
||||
@ -122,5 +132,3 @@ protected:
|
||||
/*
|
||||
vi:ts=4:et
|
||||
*/
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -54,11 +54,11 @@ section lzma.init
|
||||
bal lzma_decoder
|
||||
sw tmp,0(CLzmaDecoderState)
|
||||
lw dst,dst_save(sp)
|
||||
lw outSize,outSizeProcessed(sp)
|
||||
li tmp,%lo(UPXa-lzma_args_sz)
|
||||
addu dst,t3
|
||||
addu dst,outSize
|
||||
subu sp,tmp
|
||||
|
||||
|
||||
section LZMA_DEC10
|
||||
#include "lzma_d_cs.S"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user