src: minor cleanups
This commit is contained in:
parent
9fbe95ad48
commit
67548a4d9a
@ -118,7 +118,7 @@ tribool PackWinCeArm::canPack() {
|
|||||||
if (ih.cpu != IMAGE_FILE_MACHINE_ARM && ih.cpu != IMAGE_FILE_MACHINE_THUMB)
|
if (ih.cpu != IMAGE_FILE_MACHINE_ARM && ih.cpu != IMAGE_FILE_MACHINE_THUMB)
|
||||||
return false;
|
return false;
|
||||||
use_thumb_stub |= ih.cpu == IMAGE_FILE_MACHINE_THUMB || (ih.entry & 1) == 1;
|
use_thumb_stub |= ih.cpu == IMAGE_FILE_MACHINE_THUMB || (ih.entry & 1) == 1;
|
||||||
// FIXME later: don't misuse opt->cpu_x86, need an extra option for thumb
|
// HACK FIXME later: don't misuse opt->cpu_x86, need an extra option to force thumb stub
|
||||||
use_thumb_stub |= (opt->cpu_x86 == opt->CPU_8086);
|
use_thumb_stub |= (opt->cpu_x86 == opt->CPU_8086);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
2
src/stub/i386-dos32.djgpp2-stubify.h
generated
2
src/stub/i386-dos32.djgpp2-stubify.h
generated
@ -1,3 +1,5 @@
|
|||||||
|
/* clang-format off */
|
||||||
|
|
||||||
#define STUB_I386_DOS32_DJGPP2_STUBIFY_SIZE 2048
|
#define STUB_I386_DOS32_DJGPP2_STUBIFY_SIZE 2048
|
||||||
#define STUB_I386_DOS32_DJGPP2_STUBIFY_ADLER32 0xbf689ba8
|
#define STUB_I386_DOS32_DJGPP2_STUBIFY_ADLER32 0xbf689ba8
|
||||||
#define STUB_I386_DOS32_DJGPP2_STUBIFY_CRC32 0x2ae982b2
|
#define STUB_I386_DOS32_DJGPP2_STUBIFY_CRC32 0x2ae982b2
|
||||||
|
|||||||
@ -75,7 +75,6 @@ def w_header_c(w, ifile, ofile, n):
|
|||||||
John F. Reiser
|
John F. Reiser
|
||||||
<jreiser@users.sourceforge.net>
|
<jreiser@users.sourceforge.net>
|
||||||
*/\n\n""")
|
*/\n\n""")
|
||||||
w("/* clang" + "-format off */\n\n")
|
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
@ -347,9 +346,10 @@ def main(argv):
|
|||||||
else:
|
else:
|
||||||
ofp = open(ofile, "wb")
|
ofp = open(ofile, "wb")
|
||||||
w = ofp.write
|
w = ofp.write
|
||||||
if opts.verbose >= 0:
|
if opts.mode == "c":
|
||||||
if opts.mode == "c":
|
if opts.verbose >= 0:
|
||||||
w_header_c(w, ifile, ofile, len(idata))
|
w_header_c(w, ifile, ofile, len(idata))
|
||||||
|
w("/* clang" + "-format off */\n\n")
|
||||||
for i in range(len(mdata)):
|
for i in range(len(mdata)):
|
||||||
write_stub(w, mdata_odata[mdata[i]], i, mdata)
|
write_stub(w, mdata_odata[mdata[i]], i, mdata)
|
||||||
if ofp:
|
if ofp:
|
||||||
|
|||||||
@ -128,7 +128,7 @@ static void init_global_constants(void) noexcept {
|
|||||||
static const char *mkline(upx_uint64_t fu_len, upx_uint64_t fc_len, upx_uint64_t u_len,
|
static const char *mkline(upx_uint64_t fu_len, upx_uint64_t fc_len, upx_uint64_t u_len,
|
||||||
upx_uint64_t c_len, const char *format_name, const char *filename,
|
upx_uint64_t c_len, const char *format_name, const char *filename,
|
||||||
bool decompress = false) {
|
bool decompress = false) {
|
||||||
static char buf[2048]; // static!
|
static char buf[2048]; // static! // TODO later: check if affected by WITH_THREADS
|
||||||
char r[7 + 1];
|
char r[7 + 1];
|
||||||
char fn[15 + 1];
|
char fn[15 + 1];
|
||||||
const char *f;
|
const char *f;
|
||||||
|
|||||||
@ -34,11 +34,11 @@
|
|||||||
// #define XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(A, B, RType)
|
// #define XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(A, B, RType)
|
||||||
// std::enable_if_t<std::is_convertible_v<A *, B *> || std::is_convertible_v<B *, A *>, RType>
|
// std::enable_if_t<std::is_convertible_v<A *, B *> || std::is_convertible_v<B *, A *>, RType>
|
||||||
|
|
||||||
// requires convertible T to U, or U to T
|
// requires convertible T* to U* or U* to T*
|
||||||
#define XSPAN_FWD_TU_CONVERTIBLE(RType) \
|
#define XSPAN_FWD_TU_CONVERTIBLE(RType) \
|
||||||
template <class T, class U> \
|
template <class T, class U> \
|
||||||
inline XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(T, U, RType)
|
inline XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(T, U, RType)
|
||||||
// any pointer type, matching automatic conversion to "void *"
|
// requires convertible to void* (i.e. any pointer type matches)
|
||||||
#define XSPAN_FWD_TU_VOIDPTR(RType) \
|
#define XSPAN_FWD_TU_VOIDPTR(RType) \
|
||||||
template <class T, class U> \
|
template <class T, class U> \
|
||||||
inline RType
|
inline RType
|
||||||
@ -54,10 +54,8 @@ template <class T, class U>
|
|||||||
inline typename std::enable_if<std::is_integral<U>::value, void *>::type operator+(U, const C<T> &)
|
inline typename std::enable_if<std::is_integral<U>::value, void *>::type operator+(U, const C<T> &)
|
||||||
XSPAN_DELETED_FUNCTION;
|
XSPAN_DELETED_FUNCTION;
|
||||||
|
|
||||||
#if 0 // handled by member functions
|
#if 0 // already handled by member functions
|
||||||
XSPAN_FWD_TU_CONVERTIBLE(bool) operator==(const C<T> &a, const U *b) {
|
XSPAN_FWD_TU_CONVERTIBLE(bool) operator==(const C<T> &a, const U *b) { return a.raw_bytes(0) == b; }
|
||||||
return a.raw_bytes(0) == b;
|
|
||||||
}
|
|
||||||
XSPAN_FWD_TU_CONVERTIBLE(bool) operator==(const C<T> &a, const C<U> &b) {
|
XSPAN_FWD_TU_CONVERTIBLE(bool) operator==(const C<T> &a, const C<U> &b) {
|
||||||
return a.raw_bytes(0) == b.raw_bytes(0);
|
return a.raw_bytes(0) == b.raw_bytes(0);
|
||||||
}
|
}
|
||||||
@ -72,9 +70,7 @@ XSPAN_FWD_TU_CONVERTIBLE(bool) operator==(const C<T> &a, const E<U> &b) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XSPAN_FWD_TU_CONVERTIBLE(bool) operator!=(const C<T> &a, const U *b) {
|
XSPAN_FWD_TU_CONVERTIBLE(bool) operator!=(const C<T> &a, const U *b) { return a.raw_bytes(0) != b; }
|
||||||
return a.raw_bytes(0) != b;
|
|
||||||
}
|
|
||||||
XSPAN_FWD_TU_CONVERTIBLE(bool) operator!=(const C<T> &a, const C<U> &b) {
|
XSPAN_FWD_TU_CONVERTIBLE(bool) operator!=(const C<T> &a, const C<U> &b) {
|
||||||
return a.raw_bytes(0) != b.raw_bytes(0);
|
return a.raw_bytes(0) != b.raw_bytes(0);
|
||||||
}
|
}
|
||||||
@ -88,7 +84,7 @@ XSPAN_FWD_TU_CONVERTIBLE(bool) operator!=(const C<T> &a, const E<U> &b) {
|
|||||||
return a.raw_bytes(0) != b.raw_bytes(0);
|
return a.raw_bytes(0) != b.raw_bytes(0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif // if 0 // handled by member functions
|
#endif // if 0 // already handled by member functions
|
||||||
|
|
||||||
#endif // XSPAN_FWD_C_IS_MEMBUFFER
|
#endif // XSPAN_FWD_C_IS_MEMBUFFER
|
||||||
|
|
||||||
@ -177,7 +173,7 @@ inline void *memset(const C<T> &a, int v, size_t n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// overloads for UPX extras
|
// overloads for UPX extras 1
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@ -224,96 +220,100 @@ XSPAN_FWD_TU_VOIDPTR(unsigned) ptr_udiff_bytes(const C<T> &a, const E<U> &b) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// overloads for UPX extras 2
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
#ifdef UPX_VERSION_HEX
|
#ifdef UPX_VERSION_HEX
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
unsigned upx_adler32(const C<T> &a, unsigned n, unsigned adler = 1) {
|
inline unsigned upx_adler32(const C<T> &a, unsigned n, unsigned adler = 1) {
|
||||||
return upx_adler32(a.raw_bytes(n), n, adler);
|
return upx_adler32(a.raw_bytes(n), n, adler);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
unsigned get_ne16(const C<T> &a) {
|
inline unsigned get_ne16(const C<T> &a) {
|
||||||
return get_ne16(a.raw_bytes(2));
|
return get_ne16(a.raw_bytes(2));
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
unsigned get_ne32(const C<T> &a) {
|
inline unsigned get_ne32(const C<T> &a) {
|
||||||
return get_ne32(a.raw_bytes(4));
|
return get_ne32(a.raw_bytes(4));
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
upx_uint64_t get_ne64(const C<T> &a) {
|
inline upx_uint64_t get_ne64(const C<T> &a) {
|
||||||
return get_ne64(a.raw_bytes(8));
|
return get_ne64(a.raw_bytes(8));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
unsigned get_be16(const C<T> &a) {
|
inline unsigned get_be16(const C<T> &a) {
|
||||||
return get_be16(a.raw_bytes(2));
|
return get_be16(a.raw_bytes(2));
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
unsigned get_be32(const C<T> &a) {
|
inline unsigned get_be32(const C<T> &a) {
|
||||||
return get_be32(a.raw_bytes(4));
|
return get_be32(a.raw_bytes(4));
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
upx_uint64_t get_be64(const C<T> &a) {
|
inline upx_uint64_t get_be64(const C<T> &a) {
|
||||||
return get_be64(a.raw_bytes(8));
|
return get_be64(a.raw_bytes(8));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
unsigned get_le16(const C<T> &a) {
|
inline unsigned get_le16(const C<T> &a) {
|
||||||
return get_le16(a.raw_bytes(2));
|
return get_le16(a.raw_bytes(2));
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
unsigned get_le24(const C<T> &a) {
|
inline unsigned get_le24(const C<T> &a) {
|
||||||
return get_le24(a.raw_bytes(3));
|
return get_le24(a.raw_bytes(3));
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
unsigned get_le32(const C<T> &a) {
|
inline unsigned get_le32(const C<T> &a) {
|
||||||
return get_le32(a.raw_bytes(4));
|
return get_le32(a.raw_bytes(4));
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
upx_uint64_t get_le64(const C<T> &a) {
|
inline upx_uint64_t get_le64(const C<T> &a) {
|
||||||
return get_le64(a.raw_bytes(8));
|
return get_le64(a.raw_bytes(8));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void set_ne16(const C<T> &a, unsigned v) {
|
inline void set_ne16(const C<T> &a, unsigned v) {
|
||||||
return set_ne16(a.raw_bytes(2), v);
|
return set_ne16(a.raw_bytes(2), v);
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
void set_ne32(const C<T> &a, unsigned v) {
|
inline void set_ne32(const C<T> &a, unsigned v) {
|
||||||
return set_ne32(a.raw_bytes(4), v);
|
return set_ne32(a.raw_bytes(4), v);
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
void set_ne64(const C<T> &a, upx_uint64_t v) {
|
inline void set_ne64(const C<T> &a, upx_uint64_t v) {
|
||||||
return set_ne64(a.raw_bytes(8), v);
|
return set_ne64(a.raw_bytes(8), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void set_be16(const C<T> &a, unsigned v) {
|
inline void set_be16(const C<T> &a, unsigned v) {
|
||||||
return set_be16(a.raw_bytes(2), v);
|
return set_be16(a.raw_bytes(2), v);
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
void set_be32(const C<T> &a, unsigned v) {
|
inline void set_be32(const C<T> &a, unsigned v) {
|
||||||
return set_be32(a.raw_bytes(4), v);
|
return set_be32(a.raw_bytes(4), v);
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
void set_be64(const C<T> &a, upx_uint64_t v) {
|
inline void set_be64(const C<T> &a, upx_uint64_t v) {
|
||||||
return set_be64(a.raw_bytes(8), v);
|
return set_be64(a.raw_bytes(8), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void set_le16(const C<T> &a, unsigned v) {
|
inline void set_le16(const C<T> &a, unsigned v) {
|
||||||
return set_le16(a.raw_bytes(2), v);
|
return set_le16(a.raw_bytes(2), v);
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
void set_le24(const C<T> &a, unsigned v) {
|
inline void set_le24(const C<T> &a, unsigned v) {
|
||||||
return set_le24(a.raw_bytes(3), v);
|
return set_le24(a.raw_bytes(3), v);
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
void set_le32(const C<T> &a, unsigned v) {
|
inline void set_le32(const C<T> &a, unsigned v) {
|
||||||
return set_le32(a.raw_bytes(4), v);
|
return set_le32(a.raw_bytes(4), v);
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
void set_le64(const C<T> &a, upx_uint64_t v) {
|
inline void set_le64(const C<T> &a, upx_uint64_t v) {
|
||||||
return set_le64(a.raw_bytes(8), v);
|
return set_le64(a.raw_bytes(8), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user