mirror of https://github.com/upx/upx.git
Updates for latest ACC changes.
committer: mfx <mfx> 1058050328 +0000
This commit is contained in:
parent
48846c7226
commit
a3bb8f00fd
|
@ -29,7 +29,7 @@ CXXFLAGS = $(CXXFLAGS_W) $(EXTRA_CXXFLAGS_W) $(CXXFLAGS_M) $(CXXFLAGS_O) $(EXTR
|
|||
##CFLAGS_WERROR = -Werror
|
||||
CFLAGS_WERROR =
|
||||
CFLAGS_W = $(CFLAGS_WERROR) -Wall -W -Wbad-function-cast -Wcast-align -Wcast-qual -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wshadow -Wwrite-strings
|
||||
CXXFLAGS_W = $(CFLAGS_WERROR) -Wall -W -Wcast-align -Wcast-qual -Winline -Wmissing-prototypes -Woverloaded-virtual -Wpointer-arith -Wshadow -Wsign-promo -Wsynth -Wwrite-strings
|
||||
CXXFLAGS_W = $(CFLAGS_WERROR) -Wall -W -Wcast-align -Wcast-qual -Winline -Woverloaded-virtual -Wpointer-arith -Wshadow -Wsign-promo -Wsynth -Wwrite-strings
|
||||
|
||||
##CFLAGS_M += -fno-builtin
|
||||
##CFLAGS_M += -malign-functions=0 -malign-jumps=0 -malign-loops=0
|
||||
|
|
20
src/Makefile
20
src/Makefile
|
@ -3,19 +3,19 @@
|
|||
#
|
||||
# usage:
|
||||
# `make target=linux' # linux
|
||||
# `make target=djggp2' # dos32 - djggp2 2.03
|
||||
# `make target=djggp2' # dos32 - djggp2
|
||||
# `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=no-cygwin' # win32 - mingw32 as included in cygwin
|
||||
# `make target=rsxnt' # win32 - rsxnt
|
||||
# `make target=bc' # win32 - Borland C++ 5.5.1
|
||||
# `make target=dm' # win32 - Digital Mars C++ 8.33
|
||||
# `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=bc' # win32 - Borland C++
|
||||
# `make target=dm' # win32 - Digital Mars C++
|
||||
# `make target=ic' # win32 - Intel C++
|
||||
# `make target=vc' # win32 - Visual C++
|
||||
# `make target=wc' # win32 - Watcom C++
|
||||
# `make target=cross-mingw32' # i586-mingw32msvc cross compiler
|
||||
# `make target=cross-mint' # m68k-atari-mint cross compiler
|
||||
# `make target=gcc' # generic gcc
|
||||
#
|
||||
|
||||
|
||||
|
@ -72,13 +72,13 @@ RESOURCES =
|
|||
|
||||
override WITH_ZLIB = 1
|
||||
|
||||
include $(srcdir)/Makedefs.upx
|
||||
include $(srcdir)/Makefile.bld
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# // dependencies
|
||||
# ************************************************************************/
|
||||
|
||||
-include $(srcdir)/Makedefs.dep
|
||||
include $(srcdir)/Makedefs.dep
|
||||
|
||||
# vi:nowrap
|
||||
|
|
|
@ -136,8 +136,8 @@ endif
|
|||
###
|
||||
|
||||
ifeq ($(target),linux)
|
||||
override arch := $(shell uname -m | sed -e 's/^i[3456789]86$$/i386/')
|
||||
include $(srcdir)/Makedefs.gcc
|
||||
override arch := $(shell uname -m | sed -e 's/^i[3456789]86$$/i386/')
|
||||
ifeq ($(arch),i386)
|
||||
CCARCH += -march=i386 -mcpu=i686
|
||||
endif
|
||||
|
@ -161,7 +161,7 @@ endif # linux
|
|||
### linux/i386 - Intel C++ 7.x
|
||||
###
|
||||
|
||||
ifeq ($(target),linux-intelc70)
|
||||
ifeq ($(target),linux-intelc)
|
||||
DEPMODE := intelc_linux
|
||||
CC = icc
|
||||
CXX = icpc
|
||||
|
@ -190,20 +190,21 @@ endif
|
|||
ifeq ($(target),linux-bc57)
|
||||
##DEPMODE := XXX_linux
|
||||
CC = bc++ -q -3
|
||||
CFLAGS = -w -w-aus -w-inl -w!
|
||||
CFLAGS = -w -w-aus -w-inl '-w!'
|
||||
CFLAGS_OUTPUT = -o$@
|
||||
LDFLAGS += -ls
|
||||
LINK_EXE_OUTPUT = -e$@
|
||||
ifeq ($(WITH_ZLIB),1)
|
||||
LDLIBS += -lz
|
||||
endif
|
||||
# warning: do _not_ use option `-d' --> incorrect string merging will happen
|
||||
ifeq ($(DEBUG),1)
|
||||
CFLAGS += -Od -d
|
||||
CFLAGS += -Od -dc
|
||||
else
|
||||
CFLAGS += -O2 -d
|
||||
CFLAGS += -O2 -dc
|
||||
endif
|
||||
# transform `-lxx -lyy' into `libxx.a libyy.a'
|
||||
LDLIBS := $(shell echo "$(LDLIBS)" | perl -pe 's/-l(.*?)\b/lib\1.a/g')
|
||||
LDLIBS := $(shell echo "$(LDLIBS)" | perl -pe 's/-l(.+?)\b/lib\1.a/g')
|
||||
endif
|
||||
|
||||
|
||||
|
@ -229,7 +230,7 @@ endif
|
|||
|
||||
|
||||
###
|
||||
### Atari cross compiler
|
||||
### Atari cross compilers
|
||||
###
|
||||
|
||||
ifeq ($(target),cross-mint)
|
||||
|
@ -270,7 +271,7 @@ CFLAGS_WERROR = -Werror
|
|||
STUBEDIT_EXE = stubedit $@ bufsize=0xfc00
|
||||
ifneq ($(strip $(wildcard $(DJDIR)/bin/mfxdjstubify.ex[eE])),)
|
||||
ifneq ($(strip $(wildcard $(DJDIR)/bin/cwsdstub.ex[eE])),)
|
||||
STUBIFY_EXE = mfxdjstubify -v -s $(DJDIR)/bin/cwsdstub.exe $(upx_exe)
|
||||
STUBIFY_EXE = mfxdjstubify -v -s $(DJDIR)/bin/cwsdstub.exe $@
|
||||
endif
|
||||
endif
|
||||
endif # djgpp2
|
||||
|
@ -387,12 +388,11 @@ ifeq ($(target),ic)
|
|||
o = .obj
|
||||
a = .lib
|
||||
e = .exe
|
||||
CC = icl -nologo -MD
|
||||
CC = icl -nologo
|
||||
CFLAGS = -W3 -WX
|
||||
CXXFLAGS = $(CFLAGS) -EHac -GR
|
||||
LDFLAGS =
|
||||
LINK_EXE_OUTPUT = -Fe$@
|
||||
LDLIBS = $(DOS_LDLIBS) setargv.obj
|
||||
LINK_EXE_LDFLAGS = /link /map:$T.map
|
||||
##LINK_EXE_LDFLAGS += /verbose
|
||||
|
||||
|
@ -401,6 +401,15 @@ LIB := $(DOS_LIBDIRS);$(LIB)
|
|||
endif
|
||||
export LIB
|
||||
|
||||
ifeq (1,2)
|
||||
# statically link libc.lib
|
||||
CC += -ML
|
||||
LDLIBS = $(DOS_LDLIBS:.lib=_ml.lib) setargv.obj
|
||||
else
|
||||
# link against msvcrt.dll
|
||||
CC += -MD
|
||||
LDLIBS = $(DOS_LDLIBS) setargv.obj
|
||||
endif
|
||||
ifeq ($(DEBUG),1)
|
||||
CFLAGS += -Od -ZI
|
||||
LINK_EXE_LDFLAGS += /debug
|
||||
|
@ -525,14 +534,11 @@ endif
|
|||
|
||||
all: $(upx_exe)
|
||||
|
||||
.PHONY: all mostlyclean clean distclean maintainer-clean untabify tags
|
||||
|
||||
$(upx_exe): $(OBJECTS) $(LIBS) $(RESOURCES)
|
||||
$(strip $(CXX_LINK_EXE))
|
||||
$(STUBEDIT_EXE)
|
||||
$(STUBIFY_EXE)
|
||||
$(CHMOD_EXE)
|
||||
|
||||
$(strip $(STUBEDIT_EXE))
|
||||
$(strip $(STUBIFY_EXE))
|
||||
$(strip $(CHMOD_EXE))
|
||||
|
||||
mostlyclean:
|
||||
-rm -f *.d *.err *.i *.log *.map *~ gdb-trans*
|
||||
|
@ -541,12 +547,14 @@ clean: mostlyclean
|
|||
-rm -f *.a *.lib *.o *.obj *.res *.tds tags TAGS ID
|
||||
-rm -f *.idb *.pdb
|
||||
-rm -f $(upx_exe) upx upx.exe upx.ttp upx_nrv upx_nrv.exe upx_nrv.ttp upx_ucl upx_ucl.exe upx_ucl.ttp
|
||||
-rm -rf .deps
|
||||
-rm -rf .deps _deps
|
||||
|
||||
distclean: clean
|
||||
|
||||
maintainer-clean: distclean
|
||||
|
||||
.PHONY: all mostlyclean clean distclean maintainer-clean
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# // rules
|
24
src/bele.h
24
src/bele.h
|
@ -339,18 +339,18 @@ inline T* operator - (T* ptr, const LE32& v) { return ptr - (unsigned) v; }
|
|||
**************************************************************************/
|
||||
|
||||
// for use with qsort()
|
||||
int __UPX_CDECL be16_compare(const void *e1, const void *e2);
|
||||
int __UPX_CDECL be24_compare(const void *e1, const void *e2);
|
||||
int __UPX_CDECL be32_compare(const void *e1, const void *e2);
|
||||
int __UPX_CDECL le16_compare(const void *e1, const void *e2);
|
||||
int __UPX_CDECL le24_compare(const void *e1, const void *e2);
|
||||
int __UPX_CDECL le32_compare(const void *e1, const void *e2);
|
||||
int __UPX_CDECL be16_compare_signed(const void *e1, const void *e2);
|
||||
int __UPX_CDECL be24_compare_signed(const void *e1, const void *e2);
|
||||
int __UPX_CDECL be32_compare_signed(const void *e1, const void *e2);
|
||||
int __UPX_CDECL le16_compare_signed(const void *e1, const void *e2);
|
||||
int __UPX_CDECL le24_compare_signed(const void *e1, const void *e2);
|
||||
int __UPX_CDECL le32_compare_signed(const void *e1, const void *e2);
|
||||
int __acc_cdecl_qsort be16_compare(const void *e1, const void *e2);
|
||||
int __acc_cdecl_qsort be24_compare(const void *e1, const void *e2);
|
||||
int __acc_cdecl_qsort be32_compare(const void *e1, const void *e2);
|
||||
int __acc_cdecl_qsort le16_compare(const void *e1, const void *e2);
|
||||
int __acc_cdecl_qsort le24_compare(const void *e1, const void *e2);
|
||||
int __acc_cdecl_qsort le32_compare(const void *e1, const void *e2);
|
||||
int __acc_cdecl_qsort be16_compare_signed(const void *e1, const void *e2);
|
||||
int __acc_cdecl_qsort be24_compare_signed(const void *e1, const void *e2);
|
||||
int __acc_cdecl_qsort be32_compare_signed(const void *e1, const void *e2);
|
||||
int __acc_cdecl_qsort le16_compare_signed(const void *e1, const void *e2);
|
||||
int __acc_cdecl_qsort le24_compare_signed(const void *e1, const void *e2);
|
||||
int __acc_cdecl_qsort le32_compare_signed(const void *e1, const void *e2);
|
||||
|
||||
|
||||
// just for testing...
|
||||
|
|
|
@ -88,7 +88,7 @@ static screen_t *do_construct(screen_t *s, int fd)
|
|||
|
||||
static screen_t *screen = NULL;
|
||||
|
||||
static void __UPX_CDECL do_destroy(void)
|
||||
static void __acc_cdecl_atexit do_destroy(void)
|
||||
{
|
||||
if (screen)
|
||||
{
|
||||
|
|
123
src/conf.h
123
src/conf.h
|
@ -41,30 +41,30 @@
|
|||
#endif
|
||||
#include "acc/acc.h"
|
||||
#include "acc/acc_ince.h"
|
||||
#if !defined(acc_int64l_t) || !defined(acc_uint64l_t)
|
||||
# error "need a 64-bit integer type"
|
||||
#endif
|
||||
#if defined(INVALID_HANDLE_VALUE) || defined(MAKEWORD) || defined(RT_CURSOR)
|
||||
# error "something pulled in <windows.h>"
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
#if (ACC_CC_BORLANDC)
|
||||
# if (__BORLANDC__ < 0x550)
|
||||
# error "need Borland C++ 5.5 or newer"
|
||||
# endif
|
||||
# define __UPX_CDECL __cdecl
|
||||
# define SIGTYPEENTRY __cdecl
|
||||
# if (__BORLANDC__ >= 0x560)
|
||||
# pragma warn -use
|
||||
# endif
|
||||
#elif defined(__DMC__)
|
||||
#elif (ACC_CC_DMC)
|
||||
# define __UPX_CDECL __cdecl
|
||||
# define SIGTYPEENTRY __cdecl
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
#elif (ACC_CC_INTELC)
|
||||
# if (__INTEL_COMPILER < 450)
|
||||
# error "need Intel C++ 4.5 or newer"
|
||||
# endif
|
||||
# if defined(_WIN32)
|
||||
# if (ACC_CC_WIN32 || ACC_CC_WIN64)
|
||||
# define __UPX_CDECL __cdecl
|
||||
# define SIGTYPEENTRY __cdecl
|
||||
# elif defined(__linux__)
|
||||
# pragma warning(error: 424) // #424: extra ";" ignored
|
||||
# pragma warning(disable: 193) // #193: zero used for undefined preprocessing identifier
|
||||
|
@ -74,19 +74,18 @@
|
|||
# else
|
||||
# error "untested platform"
|
||||
# endif
|
||||
#elif defined(_MSC_VER)
|
||||
#elif (ACC_CC_MSC)
|
||||
# if (_MSC_VER < 1100)
|
||||
# error "need Visual C++ 5.0 or newer"
|
||||
# endif
|
||||
# define __UPX_CDECL __cdecl
|
||||
# define SIGTYPEENTRY __cdecl
|
||||
# pragma warning(disable: 4096) // __cdecl + '...'
|
||||
# pragma warning(disable: 4097) // W3: typedef-name 'A' used as synonym for class-name 'B'
|
||||
# pragma warning(disable: 4511) // W3: 'class': copy constructor could not be generated
|
||||
# pragma warning(disable: 4512) // W4: 'class': assignment operator could not be generated
|
||||
# pragma warning(disable: 4514) // W4: 'function' : unreferenced inline function has been removed
|
||||
# pragma warning(disable: 4710) // W4: 'function': function not inlined
|
||||
#elif defined(__WATCOMC__)
|
||||
#elif (ACC_CC_WATCOMC)
|
||||
# if (__WATCOMC__ < 1100)
|
||||
# error "need Watcom C++ 11.0c or newer"
|
||||
# endif
|
||||
|
@ -104,22 +103,6 @@
|
|||
//
|
||||
**************************************************************************/
|
||||
|
||||
// upx_int64l is int_least64_t in <stdint.h> terminology
|
||||
#if !defined(upx_int64l)
|
||||
# if (SIZEOF_LONG >= 8)
|
||||
# define upx_int64l long int
|
||||
# define upx_uint64l unsigned long int
|
||||
# elif (SIZEOF_LONG_LONG >= 8)
|
||||
# define upx_int64l acc_llong_t
|
||||
# define upx_uint64l acc_ullong_t
|
||||
# elif (SIZEOF___INT64 >= 8)
|
||||
# define upx_int64l acc_int64_t
|
||||
# define upx_uint64l acc_uint64_t
|
||||
# else
|
||||
# error "need a 64-bit integer type"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && !defined(__unix__)
|
||||
# define __unix__ 1
|
||||
#endif
|
||||
|
@ -131,7 +114,11 @@
|
|||
#undef small
|
||||
#undef tos
|
||||
#undef unix
|
||||
#if defined(__DMC__)
|
||||
# undef tell
|
||||
#endif
|
||||
#if defined(__DJGPP__)
|
||||
# undef sopen
|
||||
# undef __unix__
|
||||
# undef __unix
|
||||
#endif
|
||||
|
@ -219,47 +206,6 @@
|
|||
// portab
|
||||
**************************************************************************/
|
||||
|
||||
#if !defined(PATH_MAX)
|
||||
# define PATH_MAX 512
|
||||
#elif (PATH_MAX < 512)
|
||||
# undef PATH_MAX
|
||||
# define PATH_MAX 512
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef RETSIGTYPE
|
||||
# define RETSIGTYPE void
|
||||
#endif
|
||||
#ifndef SIGTYPEENTRY
|
||||
# define SIGTYPEENTRY
|
||||
#endif
|
||||
typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int);
|
||||
|
||||
|
||||
#undef MODE_T
|
||||
#if defined(HAVE_MODE_T)
|
||||
# define MODE_T mode_t
|
||||
#else
|
||||
# define MODE_T int
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(HAVE_STRCASECMP)
|
||||
# if defined(HAVE_STRICMP)
|
||||
# define strcasecmp stricmp
|
||||
# else
|
||||
# define strcasecmp strcmp
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(HAVE_STRNCASECMP)
|
||||
# if defined(HAVE_STRNICMP)
|
||||
# define strncasecmp strnicmp
|
||||
# else
|
||||
# define strncasecmp strncmp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef STDIN_FILENO
|
||||
# define STDIN_FILENO (fileno(stdin))
|
||||
#endif
|
||||
|
@ -271,6 +217,14 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int);
|
|||
#endif
|
||||
|
||||
|
||||
#if !defined(HAVE_STRCASECMP) && defined(HAVE_STRICMP)
|
||||
# define strcasecmp stricmp
|
||||
#endif
|
||||
#if !defined(HAVE_STRNCASECMP) && defined(HAVE_STRNICMP)
|
||||
# define strncasecmp strnicmp
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(S_IWUSR) && defined(_S_IWUSR)
|
||||
# define S_IWUSR _S_IWUSR
|
||||
#elif !defined(S_IWUSR) && defined(_S_IWRITE)
|
||||
|
@ -294,14 +248,14 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int);
|
|||
# if defined(S_IFMT) && defined(S_IFREG)
|
||||
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
# else
|
||||
# error S_ISREG
|
||||
# error "S_ISREG"
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(S_ISDIR)
|
||||
# if defined(S_IFMT) && defined(S_IFDIR)
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
# else
|
||||
# error S_ISDIR
|
||||
# error "S_ISDIR"
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(S_ISCHR)
|
||||
|
@ -317,24 +271,6 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int);
|
|||
#define outp upx_outp
|
||||
|
||||
|
||||
#if 0
|
||||
# define COMPILE_TIME_ASSERT(expr) \
|
||||
{ typedef char __upx_compile_time_assert_fail[1 - 2 * !(expr)]; \
|
||||
switch (sizeof(__upx_compile_time_assert_fail)) { \
|
||||
case 1: case !(expr): break; \
|
||||
} }
|
||||
#elif defined(__SC__)
|
||||
# define COMPILE_TIME_ASSERT(expr) \
|
||||
{ switch (1) { case 1: case !(expr): break; } }
|
||||
#elif 0
|
||||
# define COMPILE_TIME_ASSERT(expr) \
|
||||
{ typedef int __upx_compile_time_assert_fail[1 - 2 * !(expr)]; typedef int a[sizeof(__upx_compile_time_assert_fail]; }
|
||||
#else
|
||||
# define COMPILE_TIME_ASSERT(expr) \
|
||||
{ typedef int __upx_compile_time_assert_fail[1 - 2 * !(expr)]; }
|
||||
#endif
|
||||
|
||||
|
||||
#undef __attribute_packed
|
||||
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
|
||||
# if (1 && ACC_ARCH_IA32)
|
||||
|
@ -354,22 +290,10 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int);
|
|||
# define NOTHROW
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// file io
|
||||
**************************************************************************/
|
||||
|
||||
#if !defined(O_BINARY)
|
||||
# define O_BINARY 0
|
||||
#endif
|
||||
|
||||
#if defined(__DMC__)
|
||||
# undef tell
|
||||
#endif
|
||||
#if defined(__DJGPP__)
|
||||
# undef sopen
|
||||
#endif
|
||||
|
||||
#ifndef OPTIONS_VAR
|
||||
# define OPTIONS_VAR "UPX"
|
||||
#endif
|
||||
|
@ -380,6 +304,7 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int);
|
|||
**************************************************************************/
|
||||
|
||||
#define UNUSED ACC_UNUSED
|
||||
#define COMPILE_TIME_ASSERT ACC_COMPILE_TIME_ASSERT
|
||||
|
||||
#define TABLESIZE(table) ((sizeof(table)/sizeof((table)[0])))
|
||||
|
||||
|
|
65
src/main.cpp
65
src/main.cpp
|
@ -208,7 +208,7 @@ void e_envopt(const char *n)
|
|||
#endif /* defined(OPTIONS_VAR) */
|
||||
|
||||
|
||||
RETSIGTYPE SIGTYPEENTRY e_sighandler(int signum)
|
||||
void __acc_cdecl_sighandler e_sighandler(int signum)
|
||||
{
|
||||
UNUSED(signum);
|
||||
e_exit(EXIT_FATAL);
|
||||
|
@ -321,7 +321,7 @@ static void set_output_name(const char *n, bool allow_m)
|
|||
fprintf(stderr,"%s: missing output name\n",argv0);
|
||||
e_usage();
|
||||
}
|
||||
if (strlen(n) >= PATH_MAX - 4)
|
||||
if (strlen(n) >= ACC_FN_PATH_MAX - 4)
|
||||
{
|
||||
fprintf(stderr,"%s: output name too long\n",argv0);
|
||||
e_usage();
|
||||
|
@ -1018,9 +1018,9 @@ void upx_sanity_check(void)
|
|||
COMPILE_TIME_ASSERT(sizeof(void *) >= 4);
|
||||
COMPILE_TIME_ASSERT(sizeof(long) >= sizeof(void *));
|
||||
|
||||
COMPILE_TIME_ASSERT(sizeof(upx_int64l) >= 8);
|
||||
COMPILE_TIME_ASSERT(sizeof(upx_int64l) >= sizeof(long));
|
||||
COMPILE_TIME_ASSERT(sizeof(upx_int64l) == sizeof(upx_uint64l));
|
||||
COMPILE_TIME_ASSERT(sizeof(acc_int64l_t) >= 8);
|
||||
COMPILE_TIME_ASSERT(sizeof(acc_int64l_t) >= sizeof(long));
|
||||
COMPILE_TIME_ASSERT(sizeof(acc_int64l_t) == sizeof(acc_uint64l_t));
|
||||
|
||||
COMPILE_TIME_ASSERT(sizeof(off_t) >= sizeof(long));
|
||||
COMPILE_TIME_ASSERT(((off_t) -1) < 0);
|
||||
|
@ -1034,50 +1034,24 @@ void upx_sanity_check(void)
|
|||
COMPILE_TIME_ASSERT(sizeof(LE16) == 2);
|
||||
COMPILE_TIME_ASSERT(sizeof(LE32) == 4);
|
||||
|
||||
#if defined(__GNUC__) || (ACC_CC_INTELC >= 700)
|
||||
#if (ACC_CC_GNUC) || (ACC_CC_INTELC && __INTEL_COMPILER >= 700)
|
||||
COMPILE_TIME_ASSERT(__alignof__(BE16) == 1);
|
||||
COMPILE_TIME_ASSERT(__alignof__(BE32) == 1);
|
||||
COMPILE_TIME_ASSERT(__alignof__(LE16) == 1);
|
||||
COMPILE_TIME_ASSERT(__alignof__(LE32) == 1);
|
||||
#endif
|
||||
|
||||
COMPILE_TIME_ASSERT((((unsigned)1 << 31) >> 31) == 1);
|
||||
COMPILE_TIME_ASSERT((((upx_uint64l)1 << 63) >> 63) == 1);
|
||||
|
||||
#if !defined(__WATCOMC__) // Watcom C does not support inner classes
|
||||
struct align_assertion_1a_t
|
||||
{
|
||||
struct foo_t {
|
||||
char c1;
|
||||
LE16 v[4];
|
||||
} __attribute_packed;
|
||||
foo_t d[3];
|
||||
} __attribute_packed;
|
||||
struct align_assertion_1b_t
|
||||
{
|
||||
struct foo_t {
|
||||
char c1;
|
||||
char v[4*2];
|
||||
} __attribute_packed;
|
||||
foo_t d[3];
|
||||
} __attribute_packed;
|
||||
struct align_assertion_2a_t
|
||||
{
|
||||
struct foo_t {
|
||||
char c1;
|
||||
LE32 v[4];
|
||||
} __attribute_packed;
|
||||
foo_t d[3];
|
||||
} __attribute_packed;
|
||||
struct align_assertion_2b_t
|
||||
{
|
||||
struct foo_t {
|
||||
char c1;
|
||||
char v[4*4];
|
||||
} __attribute_packed;
|
||||
foo_t d[3];
|
||||
} __attribute_packed;
|
||||
COMPILE_TIME_ASSERT(((((unsigned)1 << 31) + 1) >> 31) == 1);
|
||||
COMPILE_TIME_ASSERT(((((acc_uint64l_t)1 << 63) + 1) >> 63) == 1);
|
||||
|
||||
struct foo1a_t { char c1; LE16 v[4]; } __attribute_packed;
|
||||
struct align_assertion_1a_t { foo1a_t d[3]; } __attribute_packed;
|
||||
struct foo1b_t { char c1; char v[4*2]; } __attribute_packed;
|
||||
struct align_assertion_1b_t { foo1b_t d[3]; } __attribute_packed;
|
||||
struct foo2a_t { char c1; LE32 v[4]; } __attribute_packed;
|
||||
struct align_assertion_2a_t { foo2a_t d[3]; } __attribute_packed;
|
||||
struct foo2b_t { char c1; char v[4*4]; } __attribute_packed;
|
||||
struct align_assertion_2b_t { foo2b_t d[3]; } __attribute_packed;
|
||||
//printf("%d\n", (int) sizeof(align_assertion_1a_t));
|
||||
//printf("%d\n", (int) sizeof(align_assertion_1b_t));
|
||||
//printf("%d\n", (int) sizeof(align_assertion_2a_t));
|
||||
|
@ -1086,13 +1060,16 @@ void upx_sanity_check(void)
|
|||
COMPILE_TIME_ASSERT(sizeof(align_assertion_2a_t) == sizeof(align_assertion_2b_t));
|
||||
COMPILE_TIME_ASSERT(sizeof(align_assertion_1a_t) == 3*9);
|
||||
COMPILE_TIME_ASSERT(sizeof(align_assertion_2a_t) == 3*17);
|
||||
#endif
|
||||
|
||||
COMPILE_TIME_ASSERT(sizeof(UPX_VERSION_STRING4) == 4 + 1);
|
||||
assert(strlen(UPX_VERSION_STRING4) == 4);
|
||||
assert(memcmp(UPX_VERSION_STRING4, UPX_VERSION_STRING, 4) == 0);
|
||||
|
||||
const unsigned char dd[4] = { 0xff, 0xfe, 0xfd, 0xfc };
|
||||
assert(upx_adler32(dd, 4) == 0x09f003f7);
|
||||
assert(upx_adler32(dd, 4, 0) == 0x09ec03f6);
|
||||
assert(upx_adler32(dd, 4, 1) == 0x09f003f7);
|
||||
|
||||
assert(get_be16(dd) == 0xfffe);
|
||||
assert(get_be16_signed(dd) == -2);
|
||||
assert(get_be24(dd) == 0xfffefd);
|
||||
|
@ -1118,7 +1095,7 @@ void upx_sanity_check(void)
|
|||
|
||||
#if !defined(WITH_GUI)
|
||||
|
||||
int __UPX_CDECL main(int argc, char *argv[])
|
||||
int __acc_cdecl_main main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
static char default_argv0[] = "upx";
|
||||
|
|
|
@ -227,7 +227,7 @@ public:
|
|||
void dump() const;
|
||||
|
||||
private:
|
||||
static int compare(const void *p1,const void *p2)
|
||||
static int __acc_cdecl_qsort compare(const void *p1,const void *p2)
|
||||
{
|
||||
const interval *i1 = (const interval*) p1;
|
||||
const interval *i2 = (const interval*) p2;
|
||||
|
@ -514,7 +514,7 @@ unsigned PackW32Pe::processImports() // pass 1
|
|||
bool isk32;
|
||||
unsigned _; // padding to 32
|
||||
|
||||
static int compare(const void *p1, const void *p2)
|
||||
static int __acc_cdecl_qsort compare(const void *p1, const void *p2)
|
||||
{
|
||||
const udll *u1 = * (const udll * const *) p1;
|
||||
const udll *u2 = * (const udll * const *) p2;
|
||||
|
|
|
@ -72,9 +72,9 @@
|
|||
|
||||
#undef LLONG
|
||||
#undef ULLONG
|
||||
#if 1 && defined(upx_int64l)
|
||||
# define LLONG upx_int64l
|
||||
# define ULLONG upx_uint64l
|
||||
#if 1 && defined(acc_int64l_t)
|
||||
# define LLONG acc_int64l_t
|
||||
# define ULLONG acc_uint64l_t
|
||||
#else
|
||||
# define LLONG long int
|
||||
# define ULLONG unsigned long int
|
||||
|
|
|
@ -26,12 +26,18 @@
|
|||
*/
|
||||
|
||||
|
||||
#if 0 && defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# define _Nomemory UNUSED_Nomemory
|
||||
# include <xstddef>
|
||||
# undef _Nomemory
|
||||
#endif
|
||||
|
||||
//#define WANT_STL
|
||||
#include "conf.h"
|
||||
#include "stdcxx.h"
|
||||
|
||||
|
||||
#if 0
|
||||
#if 0 && defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
#undef _Nomemory
|
||||
namespace std {
|
||||
void __cdecl _Nomemory() {
|
||||
|
@ -42,6 +48,20 @@ void __cdecl _Nomemory() {
|
|||
#endif
|
||||
|
||||
|
||||
#if 1 && defined(__linux__) && (ACC_CC_GNUC >= 0x030400)
|
||||
/* this is used by __gnu_cxx::__verbose_terminate_handler() */
|
||||
extern "C" {
|
||||
char * __attribute__((__weak__)) __cxa_demangle(const char *, char *, size_t *, int *);
|
||||
char *__cxa_demangle(const char *mangled_name, char *buf, size_t *n, int *status)
|
||||
{
|
||||
UNUSED(mangled_name); UNUSED(buf); UNUSED(n);
|
||||
if (status) *status = -1; /* memory_allocation_failure */
|
||||
return NULL;
|
||||
}
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WANT_STL
|
||||
|
||||
#if defined(__GNUC__)
|
||||
|
|
|
@ -89,7 +89,7 @@ private:
|
|||
// exceptions & RTTI
|
||||
**************************************************************************/
|
||||
|
||||
#if defined(__DMC__)
|
||||
#if defined(__DMC__) && (__DMC__ < 0x834)
|
||||
|
||||
#include <new.h>
|
||||
#include <typeinfo.h>
|
||||
|
@ -102,8 +102,7 @@ public:
|
|||
virtual ~exception() NOTHROW { }
|
||||
virtual const char* what() const NOTHROW { return "exception"; }
|
||||
};
|
||||
class bad_alloc { };
|
||||
};
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
@ -116,6 +115,8 @@ class bad_alloc { };
|
|||
|
||||
#if defined(__BORLANDC__)
|
||||
using namespace std;
|
||||
#elif defined(__DMC__)
|
||||
namespace std { class bad_alloc { }; }
|
||||
#elif defined(__EMX__)
|
||||
#define std
|
||||
#elif defined(__WATCOMC__)
|
||||
|
|
18
src/util.cpp
18
src/util.cpp
|
@ -42,28 +42,28 @@
|
|||
// qsort() util
|
||||
**************************************************************************/
|
||||
|
||||
int __UPX_CDECL be16_compare(const void *e1, const void *e2)
|
||||
int __acc_cdecl_qsort be16_compare(const void *e1, const void *e2)
|
||||
{
|
||||
const unsigned d1 = get_be16(e1);
|
||||
const unsigned d2 = get_be16(e2);
|
||||
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
||||
}
|
||||
|
||||
int __UPX_CDECL be32_compare(const void *e1, const void *e2)
|
||||
int __acc_cdecl_qsort be32_compare(const void *e1, const void *e2)
|
||||
{
|
||||
const unsigned d1 = get_be32(e1);
|
||||
const unsigned d2 = get_be32(e2);
|
||||
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
||||
}
|
||||
|
||||
int __UPX_CDECL le16_compare(const void *e1, const void *e2)
|
||||
int __acc_cdecl_qsort le16_compare(const void *e1, const void *e2)
|
||||
{
|
||||
const unsigned d1 = get_le16(e1);
|
||||
const unsigned d2 = get_le16(e2);
|
||||
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
||||
}
|
||||
|
||||
int __UPX_CDECL le32_compare(const void *e1, const void *e2)
|
||||
int __acc_cdecl_qsort le32_compare(const void *e1, const void *e2)
|
||||
{
|
||||
const unsigned d1 = get_le32(e1);
|
||||
const unsigned d2 = get_le32(e2);
|
||||
|
@ -71,28 +71,28 @@ int __UPX_CDECL le32_compare(const void *e1, const void *e2)
|
|||
}
|
||||
|
||||
|
||||
int __UPX_CDECL be16_compare_signed(const void *e1, const void *e2)
|
||||
int __acc_cdecl_qsort be16_compare_signed(const void *e1, const void *e2)
|
||||
{
|
||||
const int d1 = get_be16_signed(e1);
|
||||
const int d2 = get_be16_signed(e2);
|
||||
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
||||
}
|
||||
|
||||
int __UPX_CDECL be32_compare_signed(const void *e1, const void *e2)
|
||||
int __acc_cdecl_qsort be32_compare_signed(const void *e1, const void *e2)
|
||||
{
|
||||
const int d1 = get_be32_signed(e1);
|
||||
const int d2 = get_be32_signed(e2);
|
||||
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
||||
}
|
||||
|
||||
int __UPX_CDECL le16_compare_signed(const void *e1, const void *e2)
|
||||
int __acc_cdecl_qsort le16_compare_signed(const void *e1, const void *e2)
|
||||
{
|
||||
const int d1 = get_le16_signed(e1);
|
||||
const int d2 = get_le16_signed(e2);
|
||||
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
|
||||
}
|
||||
|
||||
int __UPX_CDECL le32_compare_signed(const void *e1, const void *e2)
|
||||
int __acc_cdecl_qsort le32_compare_signed(const void *e1, const void *e2)
|
||||
{
|
||||
const int d1 = get_le32_signed(e1);
|
||||
const int d2 = get_le32_signed(e2);
|
||||
|
@ -533,7 +533,7 @@ unsigned get_ratio(unsigned u_len, unsigned c_len)
|
|||
const unsigned n = 1000000;
|
||||
if (u_len <= 0)
|
||||
return c_len <= 0 ? 0 : n;
|
||||
return (unsigned) ((c_len * (upx_uint64l)n) / u_len) + 5;
|
||||
return (unsigned) ((c_len * (acc_uint64l_t)n) / u_len) + 5;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ void do_one_file(const char *iname, char *oname)
|
|||
}
|
||||
else
|
||||
{
|
||||
char tname[PATH_MAX+1];
|
||||
char tname[ACC_FN_PATH_MAX+1];
|
||||
if (opt->output_name)
|
||||
strcpy(tname,opt->output_name);
|
||||
else
|
||||
|
@ -201,7 +201,7 @@ void do_one_file(const char *iname, char *oname)
|
|||
else
|
||||
{
|
||||
// make backup
|
||||
char bakname[PATH_MAX+1];
|
||||
char bakname[ACC_FN_PATH_MAX+1];
|
||||
if (!makebakname(bakname, sizeof(bakname), iname))
|
||||
throwIOException("could not create a backup file name");
|
||||
File::rename(iname,bakname);
|
||||
|
@ -268,7 +268,7 @@ void do_files(int i, int argc, char *argv[])
|
|||
infoHeader();
|
||||
|
||||
const char *iname = argv[i];
|
||||
char oname[PATH_MAX+1];
|
||||
char oname[ACC_FN_PATH_MAX+1];
|
||||
oname[0] = 0;
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue