mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Updates.
committer: mfx <mfx> 1050612607 +0000
This commit is contained in:
parent
390cdbba2d
commit
5c7bca5b3e
|
@ -284,6 +284,17 @@ CXX = i586-mingw32msvc-g++
|
|||
CCARCH += -march=i386 -mcpu=i686
|
||||
endif
|
||||
|
||||
# rsxnt (g++ 2.8.1)
|
||||
ifeq ($(target),rsxnt)
|
||||
include $(srcdir)/Makedefs.gcc
|
||||
e = .exe
|
||||
CXX = gcc
|
||||
CFLAGS_O = -O0
|
||||
CCARCH += -Zwin32 -Zsys -mno-probe
|
||||
LDFLAGS = -s
|
||||
STUBEDIT_EXE = pestack -s1024 -c1024 $@
|
||||
endif
|
||||
|
||||
|
||||
###
|
||||
### win32 - Borland C++ 5.5.1
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
# `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=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
|
||||
|
|
|
@ -354,13 +354,11 @@ int le32_compare_signed(const void *e1, const void *e2);
|
|||
|
||||
|
||||
// just for testing...
|
||||
#if 0 && defined(__GNUC_VERSION_HEX__) && (ACC_ARCH_IA32)
|
||||
# if (__GNUC_VERSION_HEX__ >= 0x030200)
|
||||
#if (1 && ACC_ARCH_IA32 && ACC_CC_GNUC >= 0x030200)
|
||||
typedef unsigned short LE16_unaligned __attribute__((__packed__,__aligned__(1)));
|
||||
typedef unsigned int LE32_unaligned __attribute__((__packed__,__aligned__(1)));
|
||||
# define LE16 LE16_unaligned
|
||||
# define LE32 LE32_unaligned
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ static int do_init(FILE *f)
|
|||
if (opt->console == CON_NONE || opt->to_stdout)
|
||||
return con_mode;
|
||||
try_init(&console_file,f);
|
||||
if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO) || !isatty(STDERR_FILENO))
|
||||
if (!acc_isatty(STDIN_FILENO) || !acc_isatty(STDOUT_FILENO) || !acc_isatty(STDERR_FILENO))
|
||||
return con_mode;
|
||||
|
||||
#if defined(USE_ANSI)
|
||||
|
|
|
@ -130,7 +130,7 @@ static int init(FILE *f, int o, int now)
|
|||
if (!screen)
|
||||
screen = do_construct(screen_djgpp2_construct(),fd);
|
||||
#endif
|
||||
#if (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||
#if defined(USE_SCREEN_WIN32)
|
||||
if (!screen)
|
||||
screen = do_construct(screen_win32_construct(),fd);
|
||||
#endif
|
||||
|
|
87
src/conf.h
87
src/conf.h
|
@ -36,14 +36,11 @@
|
|||
// ACC
|
||||
**************************************************************************/
|
||||
|
||||
#if 0 && defined(__EMX__)
|
||||
# include <sys/emx.h>
|
||||
#endif
|
||||
|
||||
#if 0 && defined(UPX_CONFIG_HEADER)
|
||||
# define ACC_CONFIG_HEADER UPX_CONFIG_HEADER
|
||||
#endif
|
||||
#include "acc/acc.h"
|
||||
#include "acc/acc_ince.h"
|
||||
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
|
@ -102,18 +99,15 @@
|
|||
|
||||
// upx_int64l is int_least64_t in <stdint.h> terminology
|
||||
#if !defined(upx_int64l)
|
||||
# if defined(HAVE_STDINT_H)
|
||||
# define upx_int64l int_least64_t
|
||||
# define upx_uint64l uint_least64_t
|
||||
# elif (ULONG_MAX > 0xffffffffL)
|
||||
# if (SIZEOF_LONG >= 8)
|
||||
# define upx_int64l long int
|
||||
# define upx_uint64l unsigned long int
|
||||
# elif defined(__GNUC__) || defined(__DMC__)
|
||||
# define upx_int64l long long int
|
||||
# define upx_uint64l unsigned long long int
|
||||
# elif defined(__BORLANDC__) || defined(__INTEL_COMPILER) || defined(_MSC_VER) || defined(__WATCOMC__)
|
||||
# define upx_int64l __int64
|
||||
# define upx_uint64l unsigned __int64
|
||||
# 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
|
||||
|
@ -130,6 +124,10 @@
|
|||
#undef small
|
||||
#undef tos
|
||||
#undef unix
|
||||
#if defined(__DJGPP__)
|
||||
#undef __unix__
|
||||
#undef __unix
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(WITH_UCL)
|
||||
|
@ -174,46 +172,6 @@
|
|||
// system includes
|
||||
**************************************************************************/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#if defined(HAVE_ERRNO_H)
|
||||
# include <errno.h>
|
||||
#endif
|
||||
#if defined(HAVE_FCNTL_H)
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
#if defined(HAVE_IO_H)
|
||||
# include <io.h>
|
||||
#endif
|
||||
#if defined(HAVE_DOS_H)
|
||||
# include <dos.h>
|
||||
#endif
|
||||
#if defined(HAVE_MALLOC_H)
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
#if defined(HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
#endif
|
||||
#if defined(HAVE_SIGNAL_H)
|
||||
# include <signal.h>
|
||||
#endif
|
||||
#if defined(TIME_WITH_SYS_TIME)
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# include <time.h>
|
||||
#endif
|
||||
#if defined(HAVE_UTIME_H)
|
||||
# include <utime.h>
|
||||
#elif defined(HAVE_SYS_UTIME_H)
|
||||
# include <sys/utime.h>
|
||||
#endif
|
||||
#if defined(HAVE_SHARE_H)
|
||||
# include <share.h>
|
||||
#endif
|
||||
|
||||
|
||||
// malloc debuggers
|
||||
#if defined(WITH_VALGRIND)
|
||||
# include <valgrind.h>
|
||||
|
@ -254,18 +212,6 @@
|
|||
// portab
|
||||
**************************************************************************/
|
||||
|
||||
#if defined(__GNUC__) && !defined(__GNUC_VERSION_HEX__)
|
||||
# if !defined(__GNUC_MINOR__)
|
||||
# error
|
||||
# endif
|
||||
# if !defined(__GNUC_PATCHLEVEL__)
|
||||
# define __GNUC_PATCHLEVEL__ 0
|
||||
# endif
|
||||
# define __GNUC_VERSION_HEX__ \
|
||||
(__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(PATH_MAX)
|
||||
# define PATH_MAX 512
|
||||
#elif (PATH_MAX < 512)
|
||||
|
@ -406,13 +352,6 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int);
|
|||
// file io
|
||||
**************************************************************************/
|
||||
|
||||
#if defined(HAVE_SETMODE)
|
||||
# if !defined(O_BINARY)
|
||||
# error "setmode without O_BINARY"
|
||||
# endif
|
||||
# define USE_SETMODE 1
|
||||
#endif
|
||||
|
||||
#if !defined(O_BINARY)
|
||||
# define O_BINARY 0
|
||||
#endif
|
||||
|
@ -420,10 +359,8 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int);
|
|||
#if defined(__DMC__)
|
||||
# undef tell
|
||||
#endif
|
||||
|
||||
#if defined(__DJGPP__)
|
||||
# undef sopen
|
||||
# undef USE_SETMODE
|
||||
#endif
|
||||
|
||||
#ifndef OPTIONS_VAR
|
||||
|
|
|
@ -34,8 +34,9 @@
|
|||
#undef USE_CONSOLE
|
||||
#undef USE_ANSI
|
||||
#undef USE_SCREEN
|
||||
#undef USE_SCREEN_VCSA
|
||||
#undef USE_SCREEN_CURSES
|
||||
#undef USE_SCREEN_VCSA
|
||||
#undef USE_SCREEN_WIN32
|
||||
#undef USE_FRAMES
|
||||
|
||||
#if defined(WITH_GUI) && !defined(NO_CONSOLE)
|
||||
|
@ -57,9 +58,12 @@
|
|||
|
||||
#if 1 && defined(__DJGPP__)
|
||||
# define USE_SCREEN
|
||||
#endif
|
||||
#if 1 && (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||
#elif 1 && (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||
# define USE_SCREEN
|
||||
# define USE_SCREEN_WIN32
|
||||
#elif 1 && (ACC_OS_EMX && defined(__RSXNT__))
|
||||
# define USE_SCREEN
|
||||
# define USE_SCREEN_WIN32
|
||||
#endif
|
||||
|
||||
|
||||
|
|
31
src/file.cpp
31
src/file.cpp
|
@ -46,7 +46,7 @@ void File::chmod(const char *name, int mode)
|
|||
|
||||
void File::rename(const char *old_, const char *new_)
|
||||
{
|
||||
#if 1 && defined(__DJGPP__)
|
||||
#if defined(__DJGPP__)
|
||||
if (::_rename(old_,new_) != 0)
|
||||
#else
|
||||
if (::rename(old_,new_) != 0)
|
||||
|
@ -135,7 +135,7 @@ int FileBase::read(void *buf, int len)
|
|||
return 0;
|
||||
for (;;)
|
||||
{
|
||||
#if 1 && defined(__DJGPP__)
|
||||
#if defined(__DJGPP__)
|
||||
l = ::_read(_fd, buf, len);
|
||||
#else
|
||||
l = ::read(_fd, buf, len);
|
||||
|
@ -172,7 +172,7 @@ void FileBase::write(const void *buf, int len)
|
|||
return;
|
||||
for (;;)
|
||||
{
|
||||
#if 1 && defined(__DJGPP__)
|
||||
#if defined(__DJGPP__)
|
||||
l = ::_write(_fd,buf,len);
|
||||
#else
|
||||
l = ::write(_fd,buf,len);
|
||||
|
@ -337,29 +337,16 @@ void OutputFile::sopen(const char *name, int flags, int shflags, int mode)
|
|||
bool OutputFile::openStdout(int flags, bool force)
|
||||
{
|
||||
close();
|
||||
if (!force)
|
||||
{
|
||||
if (!isafile(STDOUT_FILENO))
|
||||
return false;
|
||||
}
|
||||
_fd = STDOUT_FILENO;
|
||||
int fd = STDOUT_FILENO;
|
||||
if (!force && acc_isatty(fd))
|
||||
return false;
|
||||
_name = "<stdout>";
|
||||
_flags = flags;
|
||||
_shflags = -1;
|
||||
_mode = 0;
|
||||
if (flags != 0)
|
||||
{
|
||||
assert(flags == O_BINARY);
|
||||
#if defined(__MINT__)
|
||||
__set_binmode(stdout, 1);
|
||||
#elif defined(HAVE_SETMODE) && defined(USE_SETMODE)
|
||||
if (setmode(_fd, O_BINARY) == -1)
|
||||
throwIOException(_name,errno);
|
||||
#if defined(__DJGPP__)
|
||||
__djgpp_set_ctrl_c(1);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
if (flags && acc_set_binmode(fd, 1) == -1)
|
||||
throwIOException(_name, errno);
|
||||
_fd = fd;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -326,8 +326,8 @@ void show_version(int x)
|
|||
FILE *f = stdout;
|
||||
UNUSED(x);
|
||||
|
||||
#if 0 && defined(__GNUC__)
|
||||
fprintf(f,"upx %s (gcc 0x%lx)\n", UPX_VERSION_STRING, __GNUC_VERSION_HEX__);
|
||||
#if (0 && ACC_CC_GNUC)
|
||||
fprintf(f,"upx %s (gcc 0x%06lx)\n", UPX_VERSION_STRING, ACC_CC_GNUC);
|
||||
#else
|
||||
fprintf(f,"upx %s\n", UPX_VERSION_STRING);
|
||||
#endif
|
||||
|
|
|
@ -56,7 +56,9 @@ void init_options(struct options_t *o)
|
|||
o->overlay = -1;
|
||||
|
||||
o->console = CON_FILE;
|
||||
#if (ACC_OS_CYGWIN || ACC_OS_DOS32 || ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||
#if defined(__DJGPP__)
|
||||
o->console = CON_INIT;
|
||||
#elif defined(USE_SCREEN_WIN32)
|
||||
o->console = CON_INIT;
|
||||
#elif 1 && defined(__linux__)
|
||||
o->console = CON_INIT;
|
||||
|
@ -278,7 +280,7 @@ static void set_term(FILE *f)
|
|||
if (f)
|
||||
con_term = f;
|
||||
else
|
||||
con_term = isafile(STDIN_FILENO) ? stderr : stdout;
|
||||
con_term = acc_isatty(STDIN_FILENO) ? stderr : stdout;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ static void pr_error(const char *iname, const char *msg, bool is_warning)
|
|||
// This hack is needed, otherwise error messages may get lost
|
||||
// when the cursor is not yet at the bottom of the screen.
|
||||
// At least I can use some colors then...
|
||||
bool c = isatty(STDERR_FILENO) ? 1 : 0;
|
||||
bool c = acc_isatty(STDERR_FILENO) ? 1 : 0;
|
||||
|
||||
int fg = con_fg(stderr,FG_BRTRED);
|
||||
upx_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),"%s: ", progname);
|
||||
|
|
|
@ -437,8 +437,8 @@ void PackExe::pack(OutputFile *fo)
|
|||
|
||||
// set oh.min & oh.max
|
||||
ic = ih.min*16 + ih_imagesize;
|
||||
if (ic < oh.ss*16 + oh.sp)
|
||||
ic = oh.ss*16 + oh.sp;
|
||||
if (ic < oh.ss*16u + oh.sp)
|
||||
ic = oh.ss*16u + oh.sp;
|
||||
oh.min = (ic - (packedsize + lsize)) / 16;
|
||||
ic = oh.min + (ih.max - ih.min);
|
||||
oh.max = ic < 0xffff && ih.max != 0xffff ? ic : 0xffff;
|
||||
|
|
|
@ -309,7 +309,7 @@ static int init(screen_t *this, int fd)
|
|||
this->data->sb_base = 0;
|
||||
this->data->sb_sp = 0;
|
||||
#endif
|
||||
if (fd < 0 || !isatty(fd))
|
||||
if (fd < 0 || !acc_isatty(fd))
|
||||
return -1;
|
||||
if (getPage(this) != 0)
|
||||
return -1;
|
||||
|
|
|
@ -316,7 +316,7 @@ static int init(screen_t *this, int fd)
|
|||
this->data->sb_base = 0;
|
||||
this->data->sb_sp = 0;
|
||||
#endif
|
||||
if (fd < 0 || !isatty(fd))
|
||||
if (fd < 0 || !acc_isatty(fd))
|
||||
return -1;
|
||||
if (fstat(fd,&st) != 0)
|
||||
return -1;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "conf.h"
|
||||
|
||||
#if defined(USE_SCREEN) && (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||
#if defined(USE_SCREEN_WIN32)
|
||||
|
||||
#include "screen.h"
|
||||
|
||||
|
@ -46,6 +46,9 @@
|
|||
# pragma warning(disable: 4201) // nonstandard extension used: nameless struct/union
|
||||
#endif
|
||||
|
||||
#if defined(__RSXNT__)
|
||||
# define timeval win32_timeval /* struct timeval already in <sys/time.h> */
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#if defined(HAVE_CONIO_H)
|
||||
# include <conio.h>
|
||||
|
@ -289,7 +292,7 @@ static int init(screen_t *this, int fd)
|
|||
this->data->hi = INVALID_HANDLE_VALUE;
|
||||
this->data->ho = INVALID_HANDLE_VALUE;
|
||||
this->data->mode = -1;
|
||||
if (fd < 0 || !isatty(fd))
|
||||
if (fd < 0 || !acc_isatty(fd))
|
||||
return -1;
|
||||
|
||||
hi = GetStdHandle(STD_INPUT_HANDLE);
|
||||
|
@ -443,15 +446,16 @@ static int getScrollCounter(const screen_t *this)
|
|||
|
||||
static int s_kbhit(screen_t *this)
|
||||
{
|
||||
#if defined(HAVE_CONIO_H)
|
||||
UNUSED(this);
|
||||
# if defined(__BORLANDC__) || defined(__WATCOMC__)
|
||||
#if defined(HAVE_CONIO_H)
|
||||
# if defined(__RSXNT__)
|
||||
return 0;
|
||||
# elif defined(__BORLANDC__) || defined(__WATCOMC__)
|
||||
return kbhit();
|
||||
# else
|
||||
return _kbhit();
|
||||
# endif
|
||||
#else
|
||||
UNUSED(this);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
|
30
src/stdcxx.h
30
src/stdcxx.h
|
@ -41,7 +41,7 @@
|
|||
// disable dynamic allocation of an object
|
||||
**************************************************************************/
|
||||
|
||||
#if defined(new) || defined(delete)
|
||||
#if defined(new) || defined(delete) || defined(__EMX__)
|
||||
|
||||
// debug
|
||||
# define DISABLE_NEW_DELETE private:
|
||||
|
@ -102,36 +102,26 @@ public:
|
|||
virtual ~exception() NOTHROW { }
|
||||
virtual const char* what() const NOTHROW { return "exception"; }
|
||||
};
|
||||
class bad_alloc : public exception
|
||||
{
|
||||
public:
|
||||
bad_alloc() NOTHROW { }
|
||||
virtual ~bad_alloc() NOTHROW { }
|
||||
virtual const char* what() const NOTHROW { return "bad_alloc"; }
|
||||
};
|
||||
};
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
|
||||
#define std
|
||||
|
||||
#include <exception>
|
||||
//#include <stdexcept>
|
||||
#include <new>
|
||||
#include <typeinfo>
|
||||
|
||||
class bad_alloc { };
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
#include <exception>
|
||||
//#include <stdexcept>
|
||||
#include <new>
|
||||
#include <typeinfo>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__EMX__)
|
||||
#define std
|
||||
#elif defined(__WATCOMC__)
|
||||
#define std
|
||||
class bad_alloc { };
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// STL
|
||||
**************************************************************************/
|
||||
|
|
|
@ -109,7 +109,9 @@ static char progress_filler[] = ".*[]";
|
|||
|
||||
static void init_global_constants(void)
|
||||
{
|
||||
#ifdef __MSDOS__
|
||||
#if 0 && (ACC_OS_DOS16 || ACC_OS_DOS32)
|
||||
// FIXME: should test codepage here
|
||||
|
||||
static bool done = false;
|
||||
if (done)
|
||||
return;
|
||||
|
@ -193,7 +195,7 @@ UiPacker::UiPacker(const Packer *p_) :
|
|||
|
||||
if (opt->verbose < 0)
|
||||
s->mode = M_QUIET;
|
||||
else if (opt->verbose == 0 || !isatty(STDOUT_FILENO))
|
||||
else if (opt->verbose == 0 || !acc_isatty(STDOUT_FILENO))
|
||||
s->mode = M_INFO;
|
||||
else if (opt->verbose == 1 || opt->no_progress)
|
||||
s->mode = M_MSG;
|
||||
|
|
21
src/util.cpp
21
src/util.cpp
|
@ -29,6 +29,8 @@
|
|||
#include "conf.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "acc/acc_lib.ch"
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// qsort() util
|
||||
|
@ -516,25 +518,6 @@ bool makebakname(char *ofilename, size_t size,
|
|||
}
|
||||
|
||||
|
||||
/* test if fd is connected to a file or a pipe */
|
||||
bool isafile(int fd)
|
||||
{
|
||||
if (isatty(fd))
|
||||
return 0;
|
||||
#if defined(HAVE_FSTAT)
|
||||
{
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) != 0)
|
||||
return 0;
|
||||
/* fprintf(stderr,"fstat(%d): %o\n", fd, st.st_mode); */
|
||||
if (S_ISDIR(st.st_mode))
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// return compression ratio, where 100% == 1000*1000 == 1e6
|
||||
**************************************************************************/
|
||||
|
|
|
@ -44,7 +44,6 @@ bool maketempname(char *ofilename, size_t size,
|
|||
const char *ifilename, const char *ext, bool force=true);
|
||||
bool makebakname(char *ofilename, size_t size,
|
||||
const char *ifilename, bool force=true);
|
||||
bool isafile(int fd);
|
||||
|
||||
unsigned get_ratio(unsigned u_len, unsigned c_len);
|
||||
bool set_method_name(char *buf, size_t size, int method, int level);
|
||||
|
|
|
@ -105,7 +105,7 @@ void do_one_file(const char *iname, char *oname)
|
|||
{
|
||||
if (opt->to_stdout)
|
||||
{
|
||||
if (!fo.openStdout(O_BINARY, opt->force ? true : false))
|
||||
if (!fo.openStdout(1, opt->force ? true : false))
|
||||
throwIOException("data not written to a terminal; Use `-f' to force.");
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue
Block a user