mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Portability updates.
committer: mfx <mfx> 1042738038 +0000
This commit is contained in:
parent
e96ad21db1
commit
a2e3ceb8c8
93
src/Makefile
93
src/Makefile
|
@ -7,10 +7,11 @@
|
|||
# `make target=cygwin' # win32 - cygwin 1.3.x
|
||||
# `make target=mingw32' # win32 - mingw32
|
||||
# `make target=no-cygwin' # win32 - mingw32 as included in cygwin 1.3.x
|
||||
# `make target=bcc' # win32 - Borland C++ 5.5.1
|
||||
# `make target=dmc' # win32 - Digital Mars C++ 8.32
|
||||
# `make target=vc6' # win32 - Visual C++ 6.0
|
||||
# `make target=wcc' # win32 - Watcom C++ 11.0c
|
||||
# `make target=bc' # win32 - Borland C++ 5.5.1
|
||||
# `make target=dm' # win32 - Digital Mars C++ 8.32
|
||||
# `make target=ic' # win32 - Intel C++ 7.0
|
||||
# `make target=vc' # win32 - Visual C++ 6
|
||||
# `make target=wc' # win32 - Watcom C++ 11.0c
|
||||
# `make target=cross-m68k-linux' # m68k-linux cross compiler
|
||||
# `make target=cross-mingw32' # i586-mingw32msvc cross compiler
|
||||
# `make target=cross-mint' # m68k-atari-mint cross compiler
|
||||
|
@ -24,6 +25,7 @@ ifeq ($(strip $(UCLDIR)),)
|
|||
UCLDIR = $(HOME)/local/src/ucl-1.01
|
||||
endif
|
||||
|
||||
## you can set the default target here
|
||||
##target =
|
||||
|
||||
DEBUG = 0
|
||||
|
@ -47,12 +49,16 @@ VPATH = $(srcdir)
|
|||
|
||||
|
||||
# auto-detect the target unless given on the commandline
|
||||
ifeq ($(strip $(target)),)
|
||||
# try environment variable UPX_TARGET
|
||||
target := $(UPX_TARGET)
|
||||
endif
|
||||
ifeq ($(strip $(target)),)
|
||||
ifneq ($(strip $(wildcard /usr/include/linux)),)
|
||||
target = linux
|
||||
endif
|
||||
##ifneq ($(strip $(wildcard /platform/sun4?/kernel/unix)),)
|
||||
##target = sparc
|
||||
##target = sparc-sun-solaris
|
||||
##endif
|
||||
endif
|
||||
|
||||
|
@ -191,18 +197,18 @@ endif
|
|||
|
||||
|
||||
###
|
||||
### Linux
|
||||
### linux
|
||||
###
|
||||
|
||||
ifeq ($(target),linux)
|
||||
include $(srcdir)/Makedefs.gcc
|
||||
override arch := $(shell uname -m | sed -e 's/^i[3456789]86$$/i386/')
|
||||
DEFS += '-DUPX_CONFIG_H="config_h/linux.h"'
|
||||
DEFS += -D_FILE_OFFSET_BITS=64
|
||||
LDLIBS += -lmcheck
|
||||
include $(srcdir)/Makedefs.gcc
|
||||
ifeq ($(arch),i386)
|
||||
CCARCH += -march=i386 -mcpu=i686
|
||||
endif
|
||||
DEFS += '-DUPX_CONFIG_H="config_h/linux.h"'
|
||||
DEFS += -D_FILE_OFFSET_BITS=64
|
||||
LDLIBS += -lmcheck
|
||||
##CFLAGS_WERROR = -Werror
|
||||
|
||||
ifeq ($(DEBUG),0)
|
||||
|
@ -218,12 +224,13 @@ endif # linux
|
|||
|
||||
|
||||
###
|
||||
### Linux/i386 with Intel C++ 7.0
|
||||
### linux/i386 - Intel C++ 7.0
|
||||
###
|
||||
|
||||
ifeq ($(target),linux-intelc70)
|
||||
CC = icc
|
||||
CXX = icc
|
||||
CCARCH += -march=i386 -mcpu=i686
|
||||
CFLAGS_OUTPUT = -o $@
|
||||
LINK_EXE_OUTPUT = -o $@
|
||||
|
||||
|
@ -257,10 +264,10 @@ endif # cross-m68k-linux
|
|||
### sparc-sun-solaris2.8
|
||||
###
|
||||
|
||||
ifeq ($(target),sparc)
|
||||
ifeq ($(target),sparc-sun-solaris)
|
||||
include $(srcdir)/Makedefs.gcc
|
||||
DEFS += '-DUPX_CONFIG_H="config_h/sparc_sun_solaris28.h"'
|
||||
endif # sparc
|
||||
endif
|
||||
|
||||
|
||||
###
|
||||
|
@ -293,7 +300,7 @@ endif
|
|||
|
||||
|
||||
###
|
||||
### djgpp2
|
||||
### dos32 - djgpp2
|
||||
###
|
||||
|
||||
ifeq ($(target),djgpp2)
|
||||
|
@ -312,13 +319,13 @@ endif # djgpp2
|
|||
|
||||
|
||||
###
|
||||
### cygwin / mingw32
|
||||
### win32 - cygwin / mingw32
|
||||
###
|
||||
|
||||
ifeq ($(target),cygwin)
|
||||
include $(srcdir)/Makedefs.gcc
|
||||
e = .exe
|
||||
CCARCH += -march=i386 -mcpu=i686
|
||||
CCARCH += -mcygwin -march=i386 -mcpu=i686
|
||||
endif
|
||||
|
||||
ifeq ($(target),mingw32)
|
||||
|
@ -345,15 +352,15 @@ endif
|
|||
|
||||
|
||||
###
|
||||
### Borland C++ 5.5.1
|
||||
### win32 - Borland C++ 5.5.1
|
||||
###
|
||||
|
||||
ifeq ($(target),bcc)
|
||||
ifeq ($(target),bc)
|
||||
o = .obj
|
||||
a = .lib
|
||||
e = .exe
|
||||
CC = bcc32 -q -3
|
||||
CFLAGS = -w -w-aus -g1
|
||||
CFLAGS = -w -w-aus -w-inl -g1
|
||||
CXXFLAGS_2 = $(CXXFLAGS) -x- -xd- -RT-
|
||||
CFLAGS_OUTPUT = -o$@
|
||||
LDFLAGS =
|
||||
|
@ -375,10 +382,10 @@ endif # bcc
|
|||
|
||||
|
||||
###
|
||||
### Digital Mars C++ 8.32
|
||||
### win32 - Digital Mars C++ 8.32
|
||||
###
|
||||
|
||||
ifeq ($(target),dmc)
|
||||
ifeq ($(target),dm)
|
||||
o = .obj
|
||||
a = .lib
|
||||
e = .exe
|
||||
|
@ -406,10 +413,44 @@ endif # dmc
|
|||
|
||||
|
||||
###
|
||||
### Visual C++ 6 (aka Microsoft C/C++ Compiler 12.00)
|
||||
### win32 - Intel C++ 7.0
|
||||
###
|
||||
|
||||
ifeq ($(target),vc6)
|
||||
ifeq ($(target),ic)
|
||||
o = .obj
|
||||
a = .lib
|
||||
e = .exe
|
||||
CC = icl -nologo -MD
|
||||
CFLAGS = -W3 -WX
|
||||
CXXFLAGS_1 = $(CXXFLAGS) -EHac -GR
|
||||
LDFLAGS =
|
||||
LINK_EXE_OUTPUT = -Fe$@
|
||||
LDLIBS = $(DOS_LDLIBS) setargv.obj
|
||||
LINK_EXE_LDFLAGS = /link /map:$T.map
|
||||
##LINK_EXE_LDFLAGS += /verbose
|
||||
|
||||
ifneq ($(strip $(DOS_LIBDIRS)),)
|
||||
LIB := $(DOS_LIBDIRS);$(LIB)
|
||||
endif
|
||||
export LIB
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
CFLAGS += -Od -ZI
|
||||
LINK_EXE_LDFLAGS += /debug
|
||||
else
|
||||
CFLAGS += -O1 -GF
|
||||
LINK_EXE_LDFLAGS += /release
|
||||
endif
|
||||
RESOURCES = upx.res
|
||||
|
||||
endif # icl
|
||||
|
||||
|
||||
###
|
||||
### win32 - Visual C++ 6
|
||||
###
|
||||
|
||||
ifeq ($(target),vc)
|
||||
o = .obj
|
||||
a = .lib
|
||||
e = .exe
|
||||
|
@ -439,7 +480,7 @@ ifeq ($(DEBUG),1)
|
|||
CFLAGS += -Od -ZI
|
||||
LINK_EXE_LDFLAGS += /debug
|
||||
else
|
||||
CFLAGS += -O2 -GF
|
||||
CFLAGS += -O1 -GF
|
||||
LINK_EXE_LDFLAGS += /release
|
||||
endif
|
||||
RESOURCES = upx.res
|
||||
|
@ -448,10 +489,10 @@ endif # vc6
|
|||
|
||||
|
||||
###
|
||||
### Watcom C++ 11.0c / Open Watcom C++ 1.0
|
||||
### win32 - Watcom C++ 11.0c / Open Watcom C++ 1.0
|
||||
###
|
||||
|
||||
ifeq ($(target),wcc)
|
||||
ifeq ($(target),wc)
|
||||
o = .obj
|
||||
a = .lib
|
||||
e = .exe
|
||||
|
|
|
@ -355,7 +355,7 @@ int le32_compare_signed(const void *e1, const void *e2);
|
|||
|
||||
// just for testing...
|
||||
#if 0 && defined(__i386__) && defined(__GNUC_VERSION_HEX__)
|
||||
# if (__GNUC_VERSION_HEX__ >= 0x030100)
|
||||
# if (__GNUC_VERSION_HEX__ >= 0x030200)
|
||||
typedef unsigned short LE16_unaligned __attribute__((__packed__,__aligned__(1)));
|
||||
typedef unsigned int LE32_unaligned __attribute__((__packed__,__aligned__(1)));
|
||||
# define LE16 LE16_unaligned
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
# elif defined(__GNUC__) || defined(__DMC__)
|
||||
# define upx_int64l long long int
|
||||
# define upx_uint64l unsigned long long int
|
||||
# elif defined(__BORLANDC__) || defined(_MSC_VER) || defined(__WATCOMC__)
|
||||
# elif defined(__BORLANDC__) || defined(__INTEL_COMPILER) || defined(_MSC_VER) || defined(__WATCOMC__)
|
||||
# define upx_int64l __int64
|
||||
# define upx_uint64l unsigned __int64
|
||||
# else
|
||||
|
@ -350,7 +350,7 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int);
|
|||
|
||||
|
||||
#undef __attribute_packed
|
||||
#if defined(__GNUC__)
|
||||
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
|
||||
# if 1 && defined(__i386__)
|
||||
# define __attribute_packed
|
||||
# else
|
||||
|
|
|
@ -60,10 +60,7 @@ private:
|
|||
// disable assignment
|
||||
Throwable& operator= (Throwable const &);
|
||||
// disable dynamic allocation
|
||||
#ifndef new
|
||||
static void *operator new (size_t); // {}
|
||||
static void *operator new[] (size_t); // {}
|
||||
#endif
|
||||
DISABLE_NEW_DELETE
|
||||
|
||||
private:
|
||||
static long counter; // for debugging
|
||||
|
|
|
@ -1032,7 +1032,7 @@ void upx_sanity_check(void)
|
|||
COMPILE_TIME_ASSERT(sizeof(LE16) == 2);
|
||||
COMPILE_TIME_ASSERT(sizeof(LE32) == 4);
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
|
||||
COMPILE_TIME_ASSERT(__alignof__(BE16) == 1);
|
||||
COMPILE_TIME_ASSERT(__alignof__(BE32) == 1);
|
||||
COMPILE_TIME_ASSERT(__alignof__(LE16) == 1);
|
||||
|
|
|
@ -127,8 +127,9 @@ void MemBuffer::allocForUncompression(unsigned uncompressed_size, unsigned extra
|
|||
//
|
||||
**************************************************************************/
|
||||
|
||||
#define MAGIC1(p) (((unsigned)(p) & 0xffffffff) ^ 0xfefdbeeb)
|
||||
#define MAGIC2(p) (((unsigned)(p) & 0xffffffff) ^ 0xfefdbeeb ^ 0x80024001)
|
||||
#define PTR(p) ((unsigned)(p) & 0xffffffff)
|
||||
#define MAGIC1(p) (PTR(p) ^ 0xfefdbeeb)
|
||||
#define MAGIC2(p) (PTR(p) ^ 0xfefdbeeb ^ 0x80024001)
|
||||
|
||||
unsigned MemBuffer::global_alloc_counter = 0;
|
||||
|
||||
|
|
|
@ -67,14 +67,7 @@ private:
|
|||
MemBuffer& operator= (MemBuffer const &); // { return *this; }
|
||||
|
||||
// disable dynamic allocation
|
||||
#ifndef new
|
||||
static void *operator new (size_t); // {}
|
||||
static void *operator new[] (size_t); // {}
|
||||
#endif
|
||||
#ifndef delete
|
||||
//static void operator delete (void *) {}
|
||||
//static void operator delete[] (void *) {}
|
||||
#endif
|
||||
DISABLE_NEW_DELETE
|
||||
};
|
||||
|
||||
#endif /* already included */
|
||||
|
|
49
src/stdcxx.h
49
src/stdcxx.h
|
@ -32,7 +32,54 @@
|
|||
#ifdef __cplusplus
|
||||
|
||||
|
||||
//#define NOTHROW throw()
|
||||
#if !defined(NOTHROW)
|
||||
# define NOTHROW throw()
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// disable dynamic allocation of an object
|
||||
**************************************************************************/
|
||||
|
||||
#if defined(new) || defined(delete)
|
||||
|
||||
// debug
|
||||
# define DISABLE_NEW_DELETE
|
||||
|
||||
#else
|
||||
|
||||
# if 1
|
||||
# define DISABLE_NEW_DELETE_PLACEMENT_NEW \
|
||||
static void *operator new(size_t, void *);
|
||||
# else
|
||||
# define DISABLE_NEW_DELETE_PLACEMENT_NEW
|
||||
# endif
|
||||
# if defined(__GNUC__) && (__GNUC__ >= 3)
|
||||
# define DISABLE_NEW_DELETE_PLACEMENT_DELETE \
|
||||
static void operator delete(void *, void *) NOTHROW { }
|
||||
# elif defined(__INTEL_COMPILER)
|
||||
# define DISABLE_NEW_DELETE_PLACEMENT_DELETE \
|
||||
static void operator delete(void *, void *) NOTHROW { }
|
||||
# elif defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# define DISABLE_NEW_DELETE_PLACEMENT_DELETE \
|
||||
static void operator delete(void *, void *) NOTHROW { }
|
||||
# else
|
||||
# define DISABLE_NEW_DELETE_PLACEMENT_DELETE
|
||||
# endif
|
||||
|
||||
# define DISABLE_NEW_DELETE \
|
||||
private: \
|
||||
static void *operator new(size_t); \
|
||||
static void *operator new[](size_t); \
|
||||
DISABLE_NEW_DELETE_PLACEMENT_NEW \
|
||||
protected: \
|
||||
static void operator delete(void *) NOTHROW { } \
|
||||
static void operator delete[](void *) NOTHROW { } \
|
||||
DISABLE_NEW_DELETE_PLACEMENT_DELETE \
|
||||
private:
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
|
|
24
src/tailor.h
24
src/tailor.h
|
@ -134,7 +134,7 @@
|
|||
# define HAVE_UTIME 1
|
||||
#elif defined(__BORLANDC__)
|
||||
# if (__BORLANDC__ < 0x551)
|
||||
# error "need Borland C 5.5.1 or newer"
|
||||
# error "need Borland C++ 5.5.1 or newer"
|
||||
# endif
|
||||
# define __UPX_CDECL __cdecl
|
||||
# define SIGTYPEENTRY __cdecl
|
||||
|
@ -157,12 +157,30 @@
|
|||
# define HAVE_CHMOD 1
|
||||
# define HAVE_UTIME 1
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
# if (__INTEL_COMPILER >= 700)
|
||||
# if (__INTEL_COMPILER < 700)
|
||||
# error "need Intel C++ 7.0 or newer"
|
||||
# endif
|
||||
# if defined(_WIN32)
|
||||
# define __UPX_CDECL __cdecl
|
||||
# define SIGTYPEENTRY __cdecl
|
||||
# define HAVE_CONIO_H 1
|
||||
# define HAVE_IO_H 1
|
||||
# define HAVE_MALLOC_H 1
|
||||
# define HAVE_SHARE_H 1
|
||||
# define HAVE_SYS_UTIME_H 1
|
||||
# define HAVE_CHMOD 1
|
||||
# define HAVE_UTIME 1
|
||||
# define HAVE_VSNPRINTF 1
|
||||
# define vsnprintf _vsnprintf
|
||||
# else
|
||||
# pragma warning(disable: 810) // #810: conversion from "A" to "B" may lose significant bits
|
||||
# pragma warning(disable: 981) // #981: operands are evaluated in unspecified order
|
||||
# pragma warning(disable: 1418) // #1418: external definition with no prior declaration
|
||||
# endif
|
||||
#elif defined(_MSC_VER)
|
||||
# if (_MSC_VER < 1100)
|
||||
# error "need Visual C++ 5.0 or newer"
|
||||
# endif
|
||||
# define __UPX_CDECL __cdecl
|
||||
# define SIGTYPEENTRY __cdecl
|
||||
# define HAVE_CONIO_H 1
|
||||
|
@ -184,7 +202,7 @@
|
|||
# endif
|
||||
#elif defined(__WATCOMC__)
|
||||
# if (__WATCOMC__ < 1100)
|
||||
# error "need Watcom C 11.0c or newer"
|
||||
# error "need Watcom C++ 11.0c or newer"
|
||||
# define NO_BOOL 1
|
||||
# endif
|
||||
# define __UPX_CDECL __cdecl
|
||||
|
|
|
@ -158,7 +158,7 @@ static const char *mkline(unsigned long fu_len, unsigned long fc_len,
|
|||
strcpy(r, "999.99%");
|
||||
#endif
|
||||
else
|
||||
upx_snprintf(r, sizeof(r), "%3d.%02d%%", ratio / 10000, (ratio % 10000) / 100);
|
||||
upx_snprintf(r, sizeof(r), "%3u.%02u%%", ratio / 10000, (ratio % 10000) / 100);
|
||||
if (decompress)
|
||||
f = "%10ld <-%10ld %7s %13s %s";
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue
Block a user