Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 814eabb88e | |||
| 95021e4977 | |||
| d17fb7ebf0 | |||
| df9aa9ac32 | |||
| 9110517893 | |||
| 8204c7deb6 | |||
| 6662f8985e | |||
| a2b305ed3b | |||
| ce3d3a850c | |||
| 212b674bc2 | |||
| 2980a6b4bb | |||
| 435c0a9e82 | |||
| 4102cd7c91 | |||
| b4b603819d | |||
| 20e3707e69 | |||
| fc6eeaaea8 | |||
| 41799955ce | |||
| efb4ec9cb8 | |||
| 4dbda29f82 | |||
| befaa3c501 | |||
| f41edf9e21 | |||
| 754f10f0b0 | |||
| 5d331fdf69 | |||
| cbf1dbe2cb | |||
| 3177de92fb | |||
| 3878890783 | |||
| 61594f7873 | |||
| f412b5e0cd | |||
| f14d594a1a | |||
| f0279d23d3 |
@@ -1,6 +1,7 @@
|
||||
_darcs
|
||||
B
|
||||
ChangeLog.cvs*
|
||||
TODO.*
|
||||
build
|
||||
doxygen
|
||||
maint
|
||||
|
||||
@@ -4,8 +4,14 @@ User visible changes for UPX
|
||||
|
||||
[ UNSTABLE BETA VERSION - please see README.1ST for some more info ]
|
||||
|
||||
Changes in 1.91 beta (30 Jun 2004):
|
||||
Changes in 1.92 beta (20 Jul 2004):
|
||||
* UNSTABLE BETA VERSION - DO NOT USE EXCEPT FOR TESTING
|
||||
* win32/pe: added option `--strip-loadconf' to strip the SEH load config section
|
||||
* win32/pe: try to detect .NET (win32/net) files [not yet supported by UPX]
|
||||
* vmlinux/386: new format that directly supports building Linux kernels
|
||||
* source code: now compiles cleanly under Win64
|
||||
|
||||
Changes in 1.91 beta (30 Jun 2004):
|
||||
* djgpp2/coff: added support for recent binutils versions
|
||||
* linux/elf386, linux/sh386: lots of improvements
|
||||
* vmlinuz/386: added support for recent kernels
|
||||
|
||||
@@ -20,13 +20,14 @@ All versions 1.9x are unstable beta releases - use them only for testing,
|
||||
and never distribute a program that is packed with them !
|
||||
There will be hidden bugs. Really.
|
||||
|
||||
The current stable release is 1.24, and the next stable release
|
||||
The current stable release is 1.25, and the next stable release
|
||||
will be called version 2.00.
|
||||
|
||||
The main news since 1.24 are:
|
||||
The main news since 1.25 are:
|
||||
- slightly better compression using the new NRV2E algorithm
|
||||
- new options for compression tuining (e.g. `--brute')
|
||||
- support for bootable Linux kernels ("vmlinuz/386")
|
||||
- support for Linux kernel building ("vmlinux/386")
|
||||
- direct Linux ELF-to-memory decompression ("linux/elf386") and
|
||||
shell-to-memory decompression ("linux/sh386")
|
||||
- support for playstation exes ("ps1/exe")
|
||||
|
||||
@@ -25,6 +25,7 @@ The main news since 1.25 are:
|
||||
- slightly better compression using the new NRV2E algorithm
|
||||
- new options for compression tuining (e.g. `--brute')
|
||||
- support for bootable Linux kernels ("vmlinuz/386")
|
||||
- support for Linux kernel building ("vmlinux/386")
|
||||
- direct Linux ELF-to-memory decompression ("linux/elf386") and
|
||||
shell-to-memory decompression ("linux/sh386")
|
||||
- support for playstation exes ("ps1/exe")
|
||||
|
||||
+6
-6
@@ -69,11 +69,11 @@ Tools needed to build/modify the UPX sources
|
||||
- A C++ compiler supporting inner classes, templates, exceptions
|
||||
and RTTI.
|
||||
|
||||
- GNU make for Win32
|
||||
http://upx.sourceforge.net/download/tools/
|
||||
- GNU make 3.80 for Win32
|
||||
http://www.cygwin.com/
|
||||
|
||||
- GNU make for DOS
|
||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/
|
||||
- GNU make 3.80 for DOS
|
||||
http://www.delorie.com/djgpp/
|
||||
|
||||
|
||||
To compile the packer sources
|
||||
@@ -81,8 +81,8 @@ To compile the packer sources
|
||||
|
||||
set the environment variable UCLDIR to point to your UCL installation, e.g.
|
||||
|
||||
set UCLDIR=c:\src\ucl-1.01 (DOS / Windows)
|
||||
export UCLDIR=$HOME/local/src/ucl-1.01 (Unix)
|
||||
set UCLDIR=c:\src\ucl-1.02 (DOS / Windows)
|
||||
export UCLDIR=$HOME/local/src/ucl-1.02 (Unix)
|
||||
|
||||
then type
|
||||
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
UPX TODO list. Last updated 2004-06-30.
|
||||
UPX TODO list. Last updated 2004-07-19.
|
||||
|
||||
|
||||
IMPORTANT PROBLEMS THAT SHOULD BE FIXED SOON:
|
||||
|
||||
- win32/pe should add support for PEDIR_LOADCONF (Visual C++ 7.1 generated
|
||||
exes, IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG)
|
||||
|
||||
- win32/pe should reliably detect .NET exes and somehow deal with them
|
||||
|
||||
- stub ctojr32 needs CPU 486 because of bswap
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ SHELL = /bin/sh
|
||||
top_srcdir = ..
|
||||
|
||||
PACKAGE = upx
|
||||
VERSION_DATE = 30 Jun 2004
|
||||
VERSION_DATE = 20 Jul 2004
|
||||
VERSION := $(shell sed -n 's/^.*UPX_VERSION_STRING .*"\(.*\)".*/\1/p' $(top_srcdir)/src/version.h)
|
||||
|
||||
TRIMSPACE = cat
|
||||
|
||||
@@ -869,6 +869,9 @@ Extra options available for this executable format:
|
||||
unexpected value in a header field.
|
||||
Use with care.
|
||||
|
||||
--strip-loadconf=0 Don't strip Structured Exception Handling load config [DEFAULT].
|
||||
--strip-loadconf=1 Strip Structured Exception Handling load config.
|
||||
|
||||
--strip-relocs=0 Don't strip relocation records.
|
||||
--strip-relocs=1 Strip relocation records. [DEFAULT]
|
||||
This option only works on executables with base
|
||||
|
||||
+17
-9
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/perl -w
|
||||
#! /usr/bin/perl -w
|
||||
|
||||
|
||||
##############################################################
|
||||
@@ -7,8 +7,8 @@
|
||||
### ###
|
||||
##############################################################
|
||||
|
||||
## $Revision: 2.55 $
|
||||
## $Date: 2004/05/15 20:09:14 $
|
||||
## $Revision: 2.57 $
|
||||
## $Date: 2004/07/10 19:38:37 $
|
||||
## $Author: fluffy $
|
||||
##
|
||||
|
||||
@@ -141,7 +141,7 @@ use Time::Local qw( timegm );
|
||||
# Globals --------------------------------------------------------------------
|
||||
|
||||
# In case we have to print it out:
|
||||
my $VERSION = '$Revision: 2.55 $';
|
||||
my $VERSION = '$Revision: 2.57 $';
|
||||
$VERSION =~ s/\S+\s+(\S+)\s+\S+/$1/;
|
||||
|
||||
## Vars set by options:
|
||||
@@ -1754,6 +1754,8 @@ sub files { wantarray ? @{$_[0]->{files}} : $_[0]->{files} }
|
||||
|
||||
package CVS::Utils::ChangeLog::FileEntry;
|
||||
|
||||
use File::Basename qw( fileparse );
|
||||
|
||||
# Each revision of a file has a little data structure (a `qunk')
|
||||
# associated with it. That data structure holds not only the
|
||||
# file's name, but any additional information about the file
|
||||
@@ -1939,6 +1941,7 @@ sub read_changelog {
|
||||
XX_Log_Source:
|
||||
while (<LOG_SOURCE>) {
|
||||
chomp;
|
||||
s!\r$!!;
|
||||
|
||||
# If on a new file and don't see filename, skip until we find it, and
|
||||
# when we find it, grab it.
|
||||
@@ -2208,10 +2211,11 @@ sub read_date_author_and_state {
|
||||
if defined $Domain && $Domain ne '';
|
||||
|
||||
my $pw = getpwnam($author);
|
||||
my ($fullname, $office, $workphone, $homephone);
|
||||
my ($fullname, $office, $workphone, $homephone, $gcos);
|
||||
if ( defined $pw ) {
|
||||
$gcos = (getpwnam($author))[6];
|
||||
($fullname, $office, $workphone, $homephone) =
|
||||
split /\s*,\s*/, $pw->gecos;
|
||||
split /\s*,\s*/, $gcos;
|
||||
} else {
|
||||
warn "Couldn't find gecos info for author '$author'\n"
|
||||
unless $gecos_warned{$author}++;
|
||||
@@ -2282,18 +2286,22 @@ sub parse_date_author_and_state {
|
||||
# Parses the date/time and author out of a line like:
|
||||
#
|
||||
# date: 1999/02/19 23:29:05; author: apharris; state: Exp;
|
||||
#
|
||||
# or, in CVS 1.12.9:
|
||||
#
|
||||
# date: 2004-06-05 16:10:32 +0000; author: somebody; state: Exp;
|
||||
|
||||
my ($year, $mon, $mday, $hours, $min, $secs, $utcOffset, $author, $state, $rest) =
|
||||
$line =~
|
||||
m!(\d+)[-/](\d+)[-/](\d+) \s+ (\d+):(\d+):(\d+)(\s+[+-]\d{4})?;\s+
|
||||
m!(\d+)[-/](\d+)[-/](\d+)\s+(\d+):(\d+):(\d+)(\s+[+-]\d{4})?;\s+
|
||||
author:\s+([^;]+);\s+state:\s+([^;]+);(.*)!x
|
||||
or die "Couldn't parse date ``$line''";
|
||||
die "Bad date or Y2K issues"
|
||||
unless $year > 1969 and $year < 2258;
|
||||
# Kinda arbitrary, but useful as a sanity check
|
||||
my $time = timegm($secs, $min, $hours, $mday, $mon-1, $year-1900);
|
||||
if (defined $utcOffset) {
|
||||
my ($plusminus, $hour, $minute) = $utcOffset =~ m/([+-])(\d\d)(\d\d)/;
|
||||
if ( defined $utcOffset ) {
|
||||
my ($plusminus, $hour, $minute) = ($utcOffset =~ m/([+-])(\d\d)(\d\d)/);
|
||||
my $offset = (($hour * 60) + $minute) * 60 * ($plusminus eq '+' ? -1 : 1);
|
||||
$time += $offset;
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@ CXXFLAGS_W =
|
||||
CXXFLAGS_M =
|
||||
CXXFLAGS_O =
|
||||
|
||||
CFLAGS = $(CFLAGS_W) $(EXTRA_CFLAGS_W) $(CFLAGS_M) $(CFLAGS_O) $(EXTRA_CFLAGS_O)
|
||||
CXXFLAGS = $(CXXFLAGS_W) $(EXTRA_CXXFLAGS_W) $(CXXFLAGS_M) $(CXXFLAGS_O) $(EXTRA_CXXFLAGS_O)
|
||||
CFLAGS = $(call __mkflags,CFLAGS_W) $(call __mkflags,CFLAGS_M) $(call __mkflags,CFLAGS_O)
|
||||
CXXFLAGS = $(call __mkflags,CXXFLAGS_W) $(call __mkflags,CXXFLAGS_M) $(call __mkflags,CXXFLAGS_O)
|
||||
|
||||
|
||||
#
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ OBJECTS1 = \
|
||||
p_com$o p_djgpp2$o p_elks$o p_exe$o \
|
||||
p_lx_elf$o p_lx_exc$o p_lx_sep$o p_lx_sh$o \
|
||||
p_ps1$o p_sys$o p_tmt$o p_tos$o \
|
||||
p_unix$o p_vmlinz$o p_w16ne$o p_w32pe$o p_wcle$o
|
||||
p_unix$o p_vmlinz$o p_vmlinx$o p_w16ne$o p_w32pe$o p_wcle$o
|
||||
|
||||
# no exceptions or RTTI
|
||||
OBJECTS2 = \
|
||||
|
||||
+19
-16
@@ -38,6 +38,9 @@ endif
|
||||
# util var for use in the rules - basename of the current target
|
||||
override T = $(basename $@)
|
||||
|
||||
# expand "VAR" into "$(VAR) $(EXTRA_VAR) $(UPX_EXTRA_VAR)"
|
||||
override __mkflags = $(strip $($(1)) $(EXTRA_$(1)) $(UPX_EXTRA_$(1)))
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# // compiler defaults
|
||||
@@ -45,9 +48,9 @@ override T = $(basename $@)
|
||||
|
||||
CC_SRC = $<
|
||||
CXX_SRC = $<
|
||||
CC_COMPILE = $(CC) $(CCARCH) $(DEFS) $(EXTRA_DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_OUTPUT) -c $(CC_SRC)
|
||||
CXX_COMPILE = $(CXX) $(CXXARCH) $(DEFS) $(EXTRA_DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(CXXFLAGS_OUTPUT) -c $(CXX_SRC)
|
||||
CXX_LINK_EXE = $(CXXLD) $(CXXLDARCH) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LINK_EXE_OUTPUT) $^ $(LDLIBS) $(EXTRA_LDLIBS) $(LINK_EXE_LDFLAGS)
|
||||
CC_COMPILE = $(CC) $(CCARCH) $(call __mkflags,DEFS) $(call __mkflags,INCLUDES) $(call __mkflags,CFLAGS) $(CFLAGS_OUTPUT) -c $(CC_SRC)
|
||||
CXX_COMPILE = $(CXX) $(CXXARCH) $(call __mkflags,DEFS) $(call __mkflags,INCLUDES) $(call __mkflags,CXXFLAGS) $(CXXFLAGS_OUTPUT) -c $(CXX_SRC)
|
||||
CXX_LINK_EXE = $(CXXLD) $(CXXLDARCH) $(call __mkflags,LDFLAGS) $(LINK_EXE_OUTPUT) $^ $(call __mkflags,LDLIBS)
|
||||
STUBEDIT_EXE =
|
||||
STUBIFY_EXE =
|
||||
CHMOD_EXE =
|
||||
@@ -440,14 +443,14 @@ LINK_EXE_OUTPUT = -Fe$@
|
||||
LINK_EXE_LDFLAGS = /link /map:$T.map
|
||||
##LINK_EXE_LDFLAGS += /verbose
|
||||
ifeq (1,2)
|
||||
# statically link libc.lib
|
||||
CC += -ML
|
||||
# statically link libcmt.lib
|
||||
CC += -MT
|
||||
## DOS_LDLIBS := $(DOS_LDLIBS:.lib=_ml.lib)
|
||||
else
|
||||
# link against msvcrt.dll
|
||||
CC += -MD
|
||||
endif
|
||||
LDLIBS = $(DOS_LDLIBS) setargv.obj
|
||||
LDLIBS = $(DOS_LDLIBS)
|
||||
ifeq ($(DEBUG),1)
|
||||
CFLAGS += -Od -ZI
|
||||
LINK_EXE_LDFLAGS += /debug
|
||||
@@ -521,14 +524,14 @@ LINK_EXE_OUTPUT = -Fe$@
|
||||
LINK_EXE_LDFLAGS = /link /map:$T.map
|
||||
##LINK_EXE_LDFLAGS += /verbose
|
||||
ifeq (1,1)
|
||||
# statically link libc.lib
|
||||
CC += -ML
|
||||
# statically link libcmt.lib
|
||||
CC += -MT
|
||||
## DOS_LDLIBS := $(DOS_LDLIBS:.lib=_ml.lib)
|
||||
else
|
||||
# link against msvcrt.dll
|
||||
CC += -MD
|
||||
endif
|
||||
LDLIBS = $(DOS_LDLIBS) setargv.obj
|
||||
LDLIBS = $(DOS_LDLIBS)
|
||||
ifeq ($(DEBUG),1)
|
||||
CFLAGS += -Od -ZI
|
||||
LINK_EXE_LDFLAGS += /debug
|
||||
@@ -590,14 +593,14 @@ LINK_EXE_OUTPUT = -Fe$@
|
||||
LINK_EXE_LDFLAGS = /link /map:$T.map
|
||||
##LINK_EXE_LDFLAGS += /verbose
|
||||
ifeq (1,2)
|
||||
# statically link libc.lib
|
||||
CC += -ML
|
||||
# statically link libcmt.lib
|
||||
CC += -MT
|
||||
## DOS_LDLIBS := $(DOS_LDLIBS:.lib=_ml.lib)
|
||||
else
|
||||
# link against msvcrt.dll
|
||||
CC += -MD
|
||||
endif
|
||||
LDLIBS = $(DOS_LDLIBS) setargv.obj
|
||||
LDLIBS = $(DOS_LDLIBS)
|
||||
ifeq ($(DEBUG),1)
|
||||
CFLAGS += -Od -ZI
|
||||
LINK_EXE_LDFLAGS += /debug
|
||||
@@ -618,21 +621,21 @@ o = .obj
|
||||
a = .lib
|
||||
e = .exe
|
||||
CC = cl -nologo
|
||||
CFLAGS = -W4
|
||||
CFLAGS = -W4 -Wall
|
||||
CXXFLAGS = $(CFLAGS) -EHac -GR
|
||||
LDFLAGS =
|
||||
LINK_EXE_OUTPUT = -Fe$@
|
||||
LINK_EXE_LDFLAGS = /link /map:$T.map
|
||||
##LINK_EXE_LDFLAGS += /verbose
|
||||
ifeq (1,1)
|
||||
# statically link libc.lib
|
||||
CC += -ML
|
||||
# statically link libcmt.lib
|
||||
CC += -MT
|
||||
## DOS_LDLIBS := $(DOS_LDLIBS:.lib=_ml.lib)
|
||||
else
|
||||
# link against msvcrt.dll
|
||||
CC += -MD
|
||||
endif
|
||||
LDLIBS = $(DOS_LDLIBS) setargv.obj
|
||||
LDLIBS = $(DOS_LDLIBS)
|
||||
ifeq ($(DEBUG),1)
|
||||
CFLAGS += -Od -ZI
|
||||
LINK_EXE_LDFLAGS += /debug
|
||||
|
||||
+5
-2
@@ -27,7 +27,7 @@
|
||||
#ifndef __ACC_H_INCLUDED
|
||||
#define __ACC_H_INCLUDED 1
|
||||
|
||||
#define ACC_VERSION 20040623L
|
||||
#define ACC_VERSION 20040715L
|
||||
|
||||
#if !defined(ACC_CONFIG_INCLUDE)
|
||||
# define ACC_CONFIG_INCLUDE(file) file
|
||||
@@ -44,6 +44,9 @@
|
||||
# define __INTEL_COMPILER __ICL
|
||||
#endif
|
||||
|
||||
#if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE)
|
||||
# define _ALL_SOURCE 1
|
||||
#endif
|
||||
|
||||
/* disable pedantic warnings for undefined preprocessing symbols */
|
||||
#if defined(__INTEL_COMPILER) && defined(__linux__)
|
||||
@@ -54,7 +57,7 @@
|
||||
#elif 0 && defined(__C251__)
|
||||
# pragma warning disable = 322
|
||||
#endif
|
||||
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
|
||||
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__)
|
||||
# if (_MSC_VER >= 1300)
|
||||
# pragma warning(disable: 4668)
|
||||
# endif
|
||||
|
||||
+15
-7
@@ -92,7 +92,7 @@
|
||||
# define HAVE_STRINGS_H 1
|
||||
# if (ACC_OS_POSIX_FREEBSD || ACC_OS_POSIX_MACOSX || ACC_OS_POSIX_OPENBSD)
|
||||
# undef HAVE_MALLOC_H /* deprecated */
|
||||
# elif (ACC_OS_POSIX_HPUX)
|
||||
# elif (ACC_OS_POSIX_HPUX || ACC_OS_POSIX_INTERIX)
|
||||
# define HAVE_ALLOCA_H 1
|
||||
# endif
|
||||
# if (ACC_OS_POSIX_MACOSX && ACC_CC_MWERKS) && defined(__MSL__)
|
||||
@@ -438,7 +438,8 @@
|
||||
# if ((_MSC_VER < 800) && ACC_OS_WIN16)
|
||||
# undef HAVE_ALLOCA
|
||||
# endif
|
||||
# if (_MSC_VER < 1000) && defined(__cplusplus)
|
||||
# if (ACC_ARCH_IA16) && defined(__cplusplus)
|
||||
# undef HAVE_LONGJMP
|
||||
# undef HAVE_SETJMP
|
||||
# endif
|
||||
#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__MINGW32__)
|
||||
@@ -522,7 +523,7 @@
|
||||
# if (__WATCOMC__ < 1100)
|
||||
# undef HAVE_SNPRINTF
|
||||
# undef HAVE_VSNPRINTF
|
||||
# else
|
||||
# elif (__WATCOMC__ < 1200)
|
||||
# define snprintf _snprintf
|
||||
# define vsnprintf _vsnprintf
|
||||
# endif
|
||||
@@ -594,7 +595,11 @@
|
||||
|
||||
|
||||
#if ((SIZEOF_LONG) > 0 && (SIZEOF_LONG) < 8)
|
||||
#if (ACC_CC_GNUC)
|
||||
#if (ACC_ARCH_IA16 && ACC_CC_DMC)
|
||||
#elif (ACC_CC_GNUC)
|
||||
# define SIZEOF_LONG_LONG 8
|
||||
# define SIZEOF_UNSIGNED_LONG_LONG 8
|
||||
#elif ((ACC_OS_WIN32 || ACC_OS_WIN64) && ACC_CC_MSC && (_MSC_VER >= 1400))
|
||||
# define SIZEOF_LONG_LONG 8
|
||||
# define SIZEOF_UNSIGNED_LONG_LONG 8
|
||||
#elif (ACC_OS_WIN64)
|
||||
@@ -603,7 +608,7 @@
|
||||
#elif (ACC_ARCH_IA32 && (ACC_CC_DMC))
|
||||
# define SIZEOF_LONG_LONG 8
|
||||
# define SIZEOF_UNSIGNED_LONG_LONG 8
|
||||
#elif (ACC_ARCH_IA32 && (ACC_CC_SYMANTECC && __SC__ >= 0x700))
|
||||
#elif (ACC_ARCH_IA32 && (ACC_CC_SYMANTECC && (__SC__ >= 0x700)))
|
||||
# define SIZEOF_LONG_LONG 8
|
||||
# define SIZEOF_UNSIGNED_LONG_LONG 8
|
||||
#elif (ACC_ARCH_IA32 && (ACC_CC_INTELC && defined(__linux__)))
|
||||
@@ -615,16 +620,19 @@
|
||||
#elif (ACC_ARCH_IA32 && (ACC_CC_INTELC || ACC_CC_MSC))
|
||||
# define SIZEOF___INT64 8
|
||||
# define SIZEOF_UNSIGNED___INT64 8
|
||||
#elif (ACC_ARCH_IA32 && (ACC_CC_BORLANDC && __BORLANDC__ >= 0x0520))
|
||||
#elif (ACC_ARCH_IA32 && (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0520)))
|
||||
/* INFO: unsigned __int64 is somewhat broken in 0x0520; fixed in 0x0530 */
|
||||
# define SIZEOF___INT64 8
|
||||
# define SIZEOF_UNSIGNED___INT64 8
|
||||
#elif (ACC_ARCH_IA32 && (ACC_CC_WATCOMC && __WATCOMC__ >= 1100))
|
||||
#elif (ACC_ARCH_IA32 && (ACC_CC_WATCOMC && (__WATCOMC__ >= 1100)))
|
||||
# define SIZEOF___INT64 8
|
||||
# define SIZEOF_UNSIGNED___INT64 8
|
||||
#elif (ACC_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64))
|
||||
# define SIZEOF___INT64 8
|
||||
# define SIZEOF_UNSIGNED___INT64 8
|
||||
#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
||||
# define SIZEOF_LONG_LONG 8
|
||||
# define SIZEOF_UNSIGNED_LONG_LONG 8
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
+5
-1
@@ -21,7 +21,11 @@
|
||||
* ...
|
||||
*/
|
||||
|
||||
#if defined(__INTEL_COMPILER)
|
||||
#if defined(CIL) && defined(_GNUCC) && defined(__GNUC__)
|
||||
# define ACC_CC_CILLY 1
|
||||
# define ACC_INFO_CC "Cilly"
|
||||
# define ACC_INFO_CCVER "unknown"
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
# define ACC_CC_INTELC 1
|
||||
# define ACC_INFO_CC "Intel C"
|
||||
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__INTEL_COMPILER)
|
||||
|
||||
+16
-1
@@ -81,6 +81,8 @@
|
||||
// check basic arithmetics
|
||||
**************************************************************************/
|
||||
|
||||
ACCCHK_ASSERT(1 == 1)
|
||||
|
||||
ACCCHK_ASSERT(__ACC_INT_MAX(2) == 1)
|
||||
ACCCHK_ASSERT(__ACC_INT_MAX(8) == 127)
|
||||
ACCCHK_ASSERT(__ACC_INT_MAX(16) == 32767)
|
||||
@@ -103,7 +105,11 @@
|
||||
ACCCHK_ASSERT(sizeof(signed char) == sizeof(char))
|
||||
ACCCHK_ASSERT(sizeof(unsigned char) == sizeof(char))
|
||||
ACCCHK_ASSERT(sizeof(char) == 1)
|
||||
#if (ACC_CC_CILLY)
|
||||
/* CIL is broken */
|
||||
#else
|
||||
ACCCHK_ASSERT(sizeof(char) == sizeof((char)0))
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
ACCCHK_ASSERT(sizeof('\0') == sizeof(char))
|
||||
#else
|
||||
@@ -124,7 +130,11 @@
|
||||
ACCCHK_ASSERT(sizeof(short) == sizeof(unsigned short))
|
||||
ACCCHK_ASSERT(sizeof(short) >= 2)
|
||||
ACCCHK_ASSERT(sizeof(short) >= sizeof(char))
|
||||
#if (ACC_CC_CILLY)
|
||||
/* CIL is broken */
|
||||
#else
|
||||
ACCCHK_ASSERT(sizeof(short) == sizeof((short)0))
|
||||
#endif
|
||||
#if (SIZEOF_SHORT > 0)
|
||||
ACCCHK_ASSERT(sizeof(short) == SIZEOF_SHORT)
|
||||
#endif
|
||||
@@ -344,14 +354,19 @@
|
||||
#endif /* ACCCHK_CONFIG_PEDANTIC */
|
||||
ACCCHK_ASSERT((ACC_INT64L_C(1) << (8*SIZEOF_ACC_INT64L_T-1)) < 0)
|
||||
ACCCHK_ASSERT((ACC_UINT64L_C(1) << (8*SIZEOF_ACC_INT64L_T-1)) > 0)
|
||||
#if (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020600ul))
|
||||
/* avoid pedantic warning */
|
||||
ACCCHK_ASSERT(ACC_INT64L_C(9223372036854775807) > ACC_INT64L_C(0))
|
||||
#else
|
||||
ACCCHK_ASSERT(ACC_INT64L_C(9223372036854775807) > 0)
|
||||
#endif
|
||||
ACCCHK_ASSERT(ACC_INT64L_C(-9223372036854775807) - 1 < 0)
|
||||
|
||||
ACCCHK_ASSERT( ACC_INT64L_C(9223372036854775807) % 2147483629l == 721)
|
||||
ACCCHK_ASSERT( ACC_INT64L_C(9223372036854775807) % 2147483647l == 1)
|
||||
ACCCHK_ASSERT(ACC_UINT64L_C(9223372036854775807) % 2147483629ul == 721)
|
||||
ACCCHK_ASSERT(ACC_UINT64L_C(9223372036854775807) % 2147483647ul == 1)
|
||||
#endif
|
||||
#endif /* acc_int64l_t */
|
||||
|
||||
|
||||
ACCCHK_ASSERT_IS_SIGNED_T(acc_intptr_t)
|
||||
|
||||
+9
-9
@@ -17,14 +17,12 @@
|
||||
// acc_alignof() / acc_inline
|
||||
************************************************************************/
|
||||
|
||||
#if (ACC_CC_GNUC)
|
||||
#if (ACC_CC_CILLY || ACC_CC_GNUC || ACC_CC_PGI)
|
||||
# define acc_alignof(e) __alignof__(e)
|
||||
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 700))
|
||||
# define acc_alignof(e) __alignof__(e)
|
||||
#elif (ACC_CC_MSC && (_MSC_VER >= 1300))
|
||||
# define acc_alignof(e) __alignof(e)
|
||||
#elif (ACC_CC_PGI)
|
||||
# define acc_alignof(e) __alignof__(e)
|
||||
#endif
|
||||
|
||||
#if (ACC_CC_TURBOC && (__TURBOC__ <= 0x0295))
|
||||
@@ -32,17 +30,15 @@
|
||||
# define acc_inline inline
|
||||
#elif (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0550))
|
||||
# define acc_inline __inline
|
||||
#elif (ACC_CC_CILLY || ACC_CC_GNUC || ACC_CC_PGI)
|
||||
# define acc_inline __inline__
|
||||
#elif (ACC_CC_DMC)
|
||||
# define acc_inline __inline
|
||||
#elif (ACC_CC_GNUC)
|
||||
# define acc_inline __inline__
|
||||
#elif (ACC_CC_INTELC)
|
||||
# define acc_inline __inline
|
||||
#elif (ACC_CC_MSC && (_MSC_VER >= 1000))
|
||||
#elif (ACC_CC_MSC && (_MSC_VER >= 900))
|
||||
# define acc_inline __inline
|
||||
#elif (ACC_CC_PGI)
|
||||
# define acc_inline __inline__
|
||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
|
||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
||||
# define acc_inline inline
|
||||
#endif
|
||||
|
||||
@@ -71,8 +67,12 @@
|
||||
# define ACC_UNUSED_FUNC(func) ((void) func)
|
||||
# elif (ACC_CC_BORLANDC || ACC_CC_NDPC || ACC_CC_TURBOC)
|
||||
# define ACC_UNUSED_FUNC(func) if (func) ; else
|
||||
# elif (ACC_CC_GNUC == 0x030400ul) && defined(__llvm__)
|
||||
# define ACC_UNUSED_FUNC(func) ((void) &func)
|
||||
# elif (ACC_CC_MSC && (_MSC_VER < 900))
|
||||
# define ACC_UNUSED_FUNC(func) if (func) ; else
|
||||
# elif (ACC_CC_MSC)
|
||||
# define ACC_UNUSED_FUNC(func) ((void) &func)
|
||||
# elif (ACC_CC_KEILC)
|
||||
# define ACC_UNUSED_FUNC(func)
|
||||
# else
|
||||
|
||||
+2
-4
@@ -313,6 +313,8 @@ ACCLIB_EXTERN(int, acc_set_binmode) (int, int);
|
||||
ACCLIB_EXTERN(acc_int32l_t, acc_muldiv32) (acc_int32l_t, acc_int32l_t, acc_int32l_t);
|
||||
ACCLIB_EXTERN(acc_uint32l_t, acc_umuldiv32) (acc_uint32l_t, acc_uint32l_t, acc_uint32l_t);
|
||||
|
||||
ACCLIB_EXTERN(void, acc_wildargv) (int*, char***);
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// uclock (real, i.e. "wall" clock)
|
||||
@@ -367,13 +369,9 @@ ACCLIB_EXTERN(double, acc_uclock_get_elapsed) (acc_uclock_handle_p, const acc_uc
|
||||
#if defined(acc_int64l_t)
|
||||
|
||||
typedef struct { /* all private */
|
||||
#if (ACC_OS_POSIX_LINUX)
|
||||
void* h;
|
||||
unsigned cpu_type, cpu_features, cpu_khz, cpu_nrctrs;
|
||||
const char* cpu_name;
|
||||
#else
|
||||
void* h;
|
||||
#endif
|
||||
} acc_perfctr_handle_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -141,6 +141,9 @@
|
||||
# elif defined(__hpux__) || defined(__hpux)
|
||||
# define ACC_OS_POSIX_HPUX 1
|
||||
# define ACC_INFO_OS_POSIX "hpux"
|
||||
# elif defined(__INTERIX)
|
||||
# define ACC_OS_POSIX_INTERIX 1
|
||||
# define ACC_INFO_OS_POSIX "interix"
|
||||
# elif defined(__IRIX__) || defined(__irix__)
|
||||
# define ACC_OS_POSIX_IRIX 1
|
||||
# define ACC_INFO_OS_POSIX "irix"
|
||||
|
||||
@@ -271,6 +271,8 @@ __acc_gnuc_extension__ typedef unsigned long long acc_ullong_t;
|
||||
# define __acc_cdecl_sighandler __pascal
|
||||
# elif (ACC_OS_OS2 && (ACC_CC_ZORTECHC))
|
||||
# define __acc_cdecl_sighandler _stdcall
|
||||
# elif (ACC_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE)
|
||||
# define __acc_cdecl_sighandler __clrcall
|
||||
# elif (ACC_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700))
|
||||
# if defined(_DLL)
|
||||
# define __acc_cdecl_sighandler _far _cdecl _loadds
|
||||
|
||||
@@ -154,10 +154,10 @@ ACCLIB_PUBLIC(acc_hvoid_p, acc_ascii_hmemimem) (const acc_hvoid_p p, acc_hsize_t
|
||||
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrcpy) (acc_hchar_p d, const acc_hchar_p s)
|
||||
{
|
||||
acc_hchar_p dest = d;
|
||||
for (;;) {
|
||||
if ((*d = *s) == 0) return dest;
|
||||
while ((*d = *s) != 0) {
|
||||
++d; ++s;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,10 +165,10 @@ ACCLIB_PUBLIC(acc_hchar_p, acc_hstrcat) (acc_hchar_p d, const acc_hchar_p s)
|
||||
{
|
||||
acc_hchar_p dest = d;
|
||||
while (*d) ++d;
|
||||
for (;;) {
|
||||
if ((*d = *s) == 0) return dest;
|
||||
while ((*d = *s) != 0) {
|
||||
++d; ++s;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+17
-28
@@ -21,31 +21,31 @@
|
||||
#if defined(acc_int32e_t)
|
||||
|
||||
|
||||
#if ((ACC_ARCH_AMD64 || ACC_ARCH_IA32) && ACC_CC_GNUC)
|
||||
# if (ACC_CC_GNUC >= 0x020000ul)
|
||||
# define __ACCLIB_RDTSC_REGS : : "r" (t) : "cc", "memory", "eax", "edx"
|
||||
# else
|
||||
# define __ACCLIB_RDTSC_REGS : : "r" (t) : "ax", "dx"
|
||||
# endif
|
||||
#elif (ACC_ARCH_IA32 && ACC_CC_INTELC) && defined(__linux__)
|
||||
# define __ACCLIB_RDTSC_REGS : : "r" (t) : "memory", "eax", "edx"
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// read TSC
|
||||
**************************************************************************/
|
||||
|
||||
ACCLIB_PUBLIC(int, acc_tsc_read) (acc_uint32e_t* t)
|
||||
{
|
||||
#if ((ACC_ARCH_AMD64 || ACC_ARCH_IA32) && ACC_CC_GNUC)
|
||||
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32) && defined(__ACCLIB_RDTSC_REGS)
|
||||
__asm__ __volatile__(
|
||||
"clc \n" ".byte 0x0f, 0x31\n"
|
||||
"movl %%eax,(%0)\n" "movl %%edx,4(%0)\n"
|
||||
# if (ACC_CC_GNUC >= 0x020000ul)
|
||||
: : "r" (t) : "cc", "memory", "eax", "edx"
|
||||
# else
|
||||
: : "r" (t) : "ax", "dx"
|
||||
# endif
|
||||
__ACCLIB_RDTSC_REGS
|
||||
);
|
||||
return 0;
|
||||
#elif (ACC_ARCH_IA32 && ACC_CC_INTELC) && defined(__linux__)
|
||||
__asm__ __volatile__(
|
||||
"clc \n" ".byte 0x0f, 0x31\n"
|
||||
"movl %%eax,(%0)\n" "movl %%edx,4(%0)\n"
|
||||
: : "r" (t) : "memory", "eax", "edx"
|
||||
);
|
||||
return 0;
|
||||
#elif (ACC_ARCH_IA32 && (ACC_OS_DOS32 || ACC_OS_WIN32) && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC))
|
||||
#elif (ACC_ARCH_IA32 && (ACC_OS_DOS32 || ACC_OS_WIN32) && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC))
|
||||
ACC_UNUSED(t);
|
||||
__asm {
|
||||
mov ecx, t
|
||||
@@ -73,25 +73,14 @@ ACCLIB_PUBLIC(int, acc_tsc_read) (acc_uint32e_t* t)
|
||||
|
||||
ACCLIB_PUBLIC(int, acc_tsc_read_add) (acc_uint32e_t* t)
|
||||
{
|
||||
#if ((ACC_ARCH_AMD64 || ACC_ARCH_IA32) && ACC_CC_GNUC)
|
||||
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32) && defined(__ACCLIB_RDTSC_REGS)
|
||||
__asm__ __volatile__(
|
||||
"clc \n" ".byte 0x0f, 0x31\n"
|
||||
"addl %%eax,(%0)\n" "adcl $0,%%edx\n" "addl %%edx,4(%0)\n"
|
||||
# if (ACC_CC_GNUC >= 0x020000ul)
|
||||
: : "r" (t) : "cc", "memory", "eax", "edx"
|
||||
# else
|
||||
: : "r" (t) : "ax", "dx"
|
||||
# endif
|
||||
__ACCLIB_RDTSC_REGS
|
||||
);
|
||||
return 0;
|
||||
#elif (ACC_ARCH_IA32 && ACC_CC_INTELC) && defined(__linux__)
|
||||
__asm__ __volatile__(
|
||||
"clc \n" ".byte 0x0f, 0x31\n"
|
||||
"addl %%eax,(%0)\n" "adcl $0,%%edx\n" "addl %%edx,4(%0)\n"
|
||||
: : "r" (t) : "memory", "eax", "edx"
|
||||
);
|
||||
return 0;
|
||||
#elif (ACC_ARCH_IA32 && (ACC_OS_DOS32 || ACC_OS_WIN32) && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC))
|
||||
#elif (ACC_ARCH_IA32 && (ACC_OS_DOS32 || ACC_OS_WIN32) && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC))
|
||||
ACC_UNUSED(t);
|
||||
__asm {
|
||||
mov ecx, t
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
# define __ACCLIB_UCLOCK_USE_CLOCK 1
|
||||
# else
|
||||
# define __ACCLIB_UCLOCK_USE_WINMM 1
|
||||
# if (ACC_CC_MSC && (_MSC_VER >= 1000))
|
||||
# if (ACC_CC_MSC && (_MSC_VER >= 900))
|
||||
/* avoid `-W4' warnings in <mmsystem.h> */
|
||||
# pragma warning(disable: 4201)
|
||||
# elif (ACC_CC_MWERKS)
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/* ACC -- Automatic Compiler Configuration
|
||||
|
||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
This software is a copyrighted work licensed under the terms of
|
||||
the GNU General Public License. Please consult the file "ACC_LICENSE"
|
||||
for details.
|
||||
|
||||
Markus F.X.J. Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
http://www.oberhumer.com/
|
||||
*/
|
||||
|
||||
|
||||
#define __ACCLIB_WILDARGV_CH_INCLUDED 1
|
||||
#if !defined(ACCLIB_PUBLIC)
|
||||
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
#if (ACC_OS_DOS16 || ACC_OS216 || ACC_OS_WIN16)
|
||||
#if 0 && (ACC_CC_MSC)
|
||||
|
||||
/* FIXME */
|
||||
ACC_EXTERN_C int __acc_cdecl __setargv(void);
|
||||
ACC_EXTERN_C int __acc_cdecl _setargv(void);
|
||||
ACC_EXTERN_C int __acc_cdecl _setargv(void) { return __setargv(); }
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if (ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||
#if (ACC_CC_INTELC || ACC_CC_MSC)
|
||||
|
||||
ACC_EXTERN_C int __acc_cdecl __setargv(void);
|
||||
ACC_EXTERN_C int __acc_cdecl _setargv(void);
|
||||
ACC_EXTERN_C int __acc_cdecl _setargv(void) { return __setargv(); }
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if (ACC_OS_EMX)
|
||||
|
||||
#define __ACCLIB_HAVE_ACC_WILDARGV 1
|
||||
ACCLIB_PUBLIC(void, acc_wildargv) (int* argc, char*** argv)
|
||||
{
|
||||
_response(argc, argv);
|
||||
_wildcard(argc, argv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(__ACCLIB_HAVE_ACC_WILDARGV)
|
||||
#define __ACCLIB_HAVE_ACC_WILDARGV 1
|
||||
ACCLIB_PUBLIC(void, acc_wildargv) (int* argc, char*** argv)
|
||||
{
|
||||
ACC_UNUSED(argc); ACC_UNUSED(argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
vi:ts=4:et
|
||||
*/
|
||||
+21
-9
@@ -38,15 +38,7 @@
|
||||
|
||||
#include "acc/acc.h"
|
||||
#if ((ACC_OS_WIN32 || ACC_OS_WIN64) && ACC_CC_MWERKS) && defined(__MSL__)
|
||||
# undef HAVE_UTIME_H /* this pulls in <windows.h> */
|
||||
#endif
|
||||
#include "acc/acc_incd.h"
|
||||
#include "acc/acc_ince.h"
|
||||
#include "acc/acc_lib.h"
|
||||
#if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||
# if defined(INVALID_HANDLE_VALUE) || defined(MAKEWORD) || defined(RT_CURSOR)
|
||||
# error "something pulled in <windows.h>"
|
||||
# endif
|
||||
# undef HAVE_UTIME_H /* this pulls in <windows.h> */
|
||||
#endif
|
||||
|
||||
|
||||
@@ -95,6 +87,15 @@
|
||||
# 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
|
||||
# if (_MSC_VER >= 1300)
|
||||
# pragma warning(disable: 4625) // W4: 'class' : copy constructor could not be generated because a base class copy constructor is inaccessible
|
||||
# pragma warning(disable: 4626) // W4: 'class' : assignment operator could not be generated because a base class assignment operator is inaccessible
|
||||
# pragma warning(disable: 4711) // W4: 'function' selected for automatic inline expansion
|
||||
# pragma warning(disable: 4820) // W4: 'struct' : 'x' bytes padding added after member 'member'
|
||||
# endif
|
||||
# if (_MSC_VER >= 1400)
|
||||
# pragma warning(disable: 4996) // W1: 'function': was declared deprecated
|
||||
# endif
|
||||
#elif (ACC_CC_WATCOMC)
|
||||
# if (__WATCOMC__ < 1100)
|
||||
# error "need Watcom C++ 11.0c or newer"
|
||||
@@ -105,6 +106,16 @@
|
||||
#endif
|
||||
|
||||
|
||||
#include "acc/acc_incd.h"
|
||||
#include "acc/acc_ince.h"
|
||||
#include "acc/acc_lib.h"
|
||||
#if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||
# if defined(INVALID_HANDLE_VALUE) || defined(MAKEWORD) || defined(RT_CURSOR)
|
||||
# error "something pulled in <windows.h>"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
@@ -434,6 +445,7 @@ inline void operator delete[](void *p)
|
||||
#define UPX_F_BVMLINUZ_i386 16
|
||||
#define UPX_F_ELKS_8086 17
|
||||
#define UPX_F_PS1_EXE 18
|
||||
#define UPX_F_VMLINUX_i386 19
|
||||
#define UPX_F_ATARI_TOS 129
|
||||
#define UPX_F_SOLARIS_SPARC 130
|
||||
|
||||
|
||||
+7
-4
@@ -48,7 +48,7 @@ void show_head(void)
|
||||
fg = con_fg(f,FG_GREEN);
|
||||
con_fprintf(f,
|
||||
" Ultimate Packer for eXecutables\n"
|
||||
" Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004\n"
|
||||
" Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004\n"
|
||||
"UPX %-12s Markus F.X.J. Oberhumer & Laszlo Molnar %20s\n\n",
|
||||
#if (ACC_OS_DOS16 || ACC_OS_DOS32)
|
||||
V("d"),
|
||||
@@ -105,7 +105,7 @@ void show_help(int x)
|
||||
" -d decompress -l list compressed file\n"
|
||||
" -t test compressed file -V display version number\n"
|
||||
" -h give %s help -L display software license\n%s",
|
||||
x == 0 ? "" : " --best compress best (can be very slow for big files)\n",
|
||||
x == 0 ? "" : " --best compress best (can be slow for big files)\n",
|
||||
x == 0 ? "more" : "this", x == 0 ? "" : "\n");
|
||||
|
||||
fg = con_fg(f,FG_YELLOW);
|
||||
@@ -140,7 +140,7 @@ void show_help(int x)
|
||||
fg = con_fg(f,fg);
|
||||
con_fprintf(f,
|
||||
" --overlay=copy copy any extra data attached to the file [default]\n"
|
||||
" --overlay=strip strip any extra data attached to the file [dangerous]\n"
|
||||
" --overlay=strip strip any extra data attached to the file [DANGEROUS]\n"
|
||||
" --overlay=skip don't compress a file with an overlay\n"
|
||||
"\n");
|
||||
fg = con_fg(f,FG_YELLOW);
|
||||
@@ -207,7 +207,7 @@ void show_help(int x)
|
||||
" --all-filters try all available preprocessing filters\n"
|
||||
"\n");
|
||||
fg = con_fg(f,FG_YELLOW);
|
||||
con_fprintf(f,"Options for [b]vmlinuz/386\n");
|
||||
con_fprintf(f,"Options for vmlinuz/386\n");
|
||||
fg = con_fg(f,fg);
|
||||
con_fprintf(f,
|
||||
" --all-methods try all available compression methods\n"
|
||||
@@ -229,6 +229,8 @@ void show_help(int x)
|
||||
" --compress-icons=1 compress all but the first icon\n"
|
||||
" --compress-icons=2 compress all but the first icon directory [default]\n"
|
||||
" --compress-resources=0 do not compress any resources at all\n"
|
||||
" --strip-loadconf=0 do not strip SEH load config [default]\n"
|
||||
" --strip-loadconf=1 strip SEH load config [DANGEROUS]\n"
|
||||
" --strip-relocs=0 do not strip relocations\n"
|
||||
" --strip-relocs=1 strip relocations [default]\n"
|
||||
" --all-methods try all available compression methods\n"
|
||||
@@ -258,6 +260,7 @@ void show_help(int x)
|
||||
" rtm32/pe,"
|
||||
" tmt/adam,"
|
||||
"\n "
|
||||
" vmlinux/386,"
|
||||
" vmlinuz/386,"
|
||||
" watcom/le,"
|
||||
//" win16/ne,"
|
||||
|
||||
+4
-3
@@ -57,7 +57,8 @@ Linker::Linker(const void *pdata, int plen, int pinfo)
|
||||
info = pinfo;
|
||||
njumps = nsections = frozen = 0;
|
||||
jumps = new jump[200];
|
||||
sections = new section[200];
|
||||
#define NSECTIONS 350
|
||||
sections = new section[NSECTIONS];
|
||||
|
||||
char *p = iloader + info;
|
||||
while (get32(p) != (unsigned)(-1))
|
||||
@@ -68,7 +69,7 @@ Linker::Linker(const void *pdata, int plen, int pinfo)
|
||||
sections[nsections].istart = get32(p+8);
|
||||
sections[nsections++].ostart = -1;
|
||||
p += 12;
|
||||
assert(nsections < 200);
|
||||
assert(nsections < NSECTIONS);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -154,7 +155,7 @@ void Linker::addSection(const char *sname, const void *sdata, unsigned len)
|
||||
sections[nsections].istart = ilen;
|
||||
sections[nsections].len = len;
|
||||
sections[nsections++].ostart = olen;
|
||||
assert(nsections < 200);
|
||||
assert(nsections < NSECTIONS);
|
||||
memcpy(iloader+ilen,sdata,len);
|
||||
ilen += len;
|
||||
}
|
||||
|
||||
+13
-7
@@ -71,6 +71,7 @@ void init_options(struct options_t *o)
|
||||
for (unsigned i = 0; i < TABLESIZE(o->win32_pe.compress_rt); i++)
|
||||
o->win32_pe.compress_rt[i] = -1;
|
||||
o->win32_pe.compress_rt[24] = false; // 24 == RT_MANIFEST
|
||||
o->win32_pe.strip_loadconf = -1;
|
||||
o->win32_pe.strip_relocs = -1;
|
||||
}
|
||||
|
||||
@@ -676,6 +677,12 @@ static int do_option(int optc, const char *arg)
|
||||
//printf("compress_resources: %d\n", opt->win32_pe.compress_resources);
|
||||
break;
|
||||
case 633:
|
||||
opt->win32_pe.strip_loadconf = 1;
|
||||
if (mfx_optarg && strcmp(mfx_optarg,"0") == 0)
|
||||
opt->win32_pe.strip_loadconf = 0;
|
||||
//printf("strip_loadconf: %d\n", opt->win32_pe.strip_loadconf);
|
||||
break;
|
||||
case 634:
|
||||
opt->win32_pe.strip_relocs = 1;
|
||||
if (mfx_optarg && strcmp(mfx_optarg,"0") == 0)
|
||||
opt->win32_pe.strip_relocs = 0;
|
||||
@@ -823,7 +830,8 @@ static const struct mfx_option longopts[] =
|
||||
{"compress-exports", 2, 0, 630},
|
||||
{"compress-icons", 2, 0, 631},
|
||||
{"compress-resources", 2, 0, 632},
|
||||
{"strip-relocs", 2, 0, 633},
|
||||
{"strip-loadconf", 0x12, 0, 633},
|
||||
{"strip-relocs", 0x12, 0, 634},
|
||||
// ps1/exe
|
||||
{"console-run", 0x10, 0, 670},
|
||||
{"no-align", 0x10, 0, 671},
|
||||
@@ -904,7 +912,8 @@ static const struct mfx_option longopts[] =
|
||||
{"compress-exports", 2, 0, 630},
|
||||
{"compress-icons", 2, 0, 631},
|
||||
{"compress-resources", 2, 0, 632},
|
||||
{"strip-relocs", 2, 0, 633},
|
||||
{"strip-loadconf", 0x12, 0, 633},
|
||||
{"strip-relocs", 0x12, 0, 634},
|
||||
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
@@ -1088,15 +1097,12 @@ int __acc_cdecl_main main(int argc, char *argv[])
|
||||
// LFN=n may cause problems with 2.03's _rename and mkdir under WinME
|
||||
putenv("LFN=y");
|
||||
#endif
|
||||
#if defined(__EMX__)
|
||||
_response(&argc,&argv);
|
||||
_wildcard(&argc,&argv);
|
||||
#endif
|
||||
#if defined(__MINT__)
|
||||
__binmode(1);
|
||||
__set_binmode(stdout, 0);
|
||||
__set_binmode(stderr, 0);
|
||||
#endif
|
||||
acc_wildargv(&argc, &argv);
|
||||
|
||||
upx_sanity_check();
|
||||
init_options(opt);
|
||||
@@ -1226,7 +1232,7 @@ int __acc_cdecl_main main(int argc, char *argv[])
|
||||
set_term(stdout);
|
||||
do_files(i,argc,argv);
|
||||
|
||||
#if 1 && (UPX_VERSION_HEX < 0x020000)
|
||||
#if 0 && (UPX_VERSION_HEX < 0x020000)
|
||||
{
|
||||
FILE *f = stdout;
|
||||
int fg = con_fg(f,FG_RED);
|
||||
|
||||
+3
-4
@@ -21,14 +21,13 @@
|
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
|
||||
|
||||
#undef PROGNAME
|
||||
#if 0
|
||||
#ifndef EOF
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
#undef PROGNAME
|
||||
#if 1
|
||||
#define PROGNAME(x) (x)
|
||||
#else
|
||||
#include "conf.h"
|
||||
|
||||
@@ -128,6 +128,7 @@ struct options_t {
|
||||
int compress_icons;
|
||||
int compress_resources;
|
||||
signed char compress_rt[25]; // 25 == RT_LAST
|
||||
int strip_loadconf;
|
||||
int strip_relocs;
|
||||
} win32_pe;
|
||||
};
|
||||
|
||||
@@ -51,6 +51,15 @@ struct Elf_LE32_Ehdr
|
||||
LE16 e_shentsize; /* Section header table entry size */
|
||||
LE16 e_shnum; /* Section header table entry count */
|
||||
LE16 e_shstrndx; /* Section header string table index */
|
||||
|
||||
// Values for e_type
|
||||
enum {
|
||||
ET_NONE = 0, /* No file type */
|
||||
ET_REL = 1, /* Relocatable file */
|
||||
ET_EXEC = 2, /* Executable file */
|
||||
ET_DYN = 3, /* Shared object file */
|
||||
ET_CORE = 4 /* Core file */
|
||||
};
|
||||
}
|
||||
__attribute_packed;
|
||||
|
||||
|
||||
+6
-7
@@ -338,7 +338,7 @@ unsigned optimize_relocs(upx_byte *b, const unsigned size,
|
||||
set_le16 (crel_save+2,seg_high);
|
||||
|
||||
//OutputFile::dump("x.rel", crel_save, crel - crel_save);
|
||||
return crel - crel_save;
|
||||
return (unsigned) (crel - crel_save);
|
||||
}
|
||||
|
||||
|
||||
@@ -605,12 +605,11 @@ void PackExe::unpack(OutputFile *fo)
|
||||
{
|
||||
relocs -= get_le16(obuf+ph.u_len-2);
|
||||
ph.u_len -= 2;
|
||||
upx_byte *p;
|
||||
|
||||
wrkmem.alloc(4*MAXRELOCS);
|
||||
unsigned es = 0,ones = get_le16(relocs);
|
||||
unsigned seghi = get_le16(relocs+2);
|
||||
p = relocs + 4;
|
||||
unsigned es = 0, ones = get_le16(relocs);
|
||||
const unsigned seghi = get_le16(relocs+2);
|
||||
const upx_byte *p = relocs + 4;
|
||||
|
||||
while (ones)
|
||||
{
|
||||
@@ -628,10 +627,10 @@ void PackExe::unpack(OutputFile *fo)
|
||||
dorel = true;
|
||||
if (*p == 0)
|
||||
{
|
||||
upx_byte *q;
|
||||
const upx_byte *q;
|
||||
for (q = obuf+es*16+di; !(*q == 0x9a && get_le16(q+3) <= seghi); q++)
|
||||
;
|
||||
di = q - (obuf+es*16) + 3;
|
||||
di = ptr_diff(q, obuf+es*16) + 3;
|
||||
}
|
||||
else if (*p == 1)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,551 @@
|
||||
/* p_vmlinx.cpp -- pack vmlinux ET_EXEC file (before bootsect or setup)
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 2004 John Reiser
|
||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2004 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
|
||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
||||
|
||||
John Reiser
|
||||
jreiser@users.sourceforge.net
|
||||
*/
|
||||
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#include "file.h"
|
||||
#include "filter.h"
|
||||
#include "packer.h"
|
||||
#include "p_vmlinx.h"
|
||||
|
||||
static const
|
||||
#include "stub/l_vmlinx.h"
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
PackVmlinuxI386::PackVmlinuxI386(InputFile *f) :
|
||||
super(f), n_ptload(0), phdri(NULL), shdri(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
PackVmlinuxI386::~PackVmlinuxI386()
|
||||
{
|
||||
delete [] phdri;
|
||||
delete [] shdri;
|
||||
}
|
||||
|
||||
const int *PackVmlinuxI386::getCompressionMethods(int method, int level) const
|
||||
{
|
||||
return Packer::getDefaultCompressionMethods_le32(method, level);
|
||||
}
|
||||
|
||||
|
||||
const int *PackVmlinuxI386::getFilters() const
|
||||
{
|
||||
static const int filters[] = {
|
||||
0x49,
|
||||
-1 };
|
||||
return filters;
|
||||
}
|
||||
|
||||
static int __acc_cdecl_qsort
|
||||
compare_Phdr(void const *aa, void const *bb)
|
||||
{
|
||||
Elf_LE32_Phdr const *const a = (Elf_LE32_Phdr const *)aa;
|
||||
Elf_LE32_Phdr const *const b = (Elf_LE32_Phdr const *)bb;
|
||||
unsigned const xa = a->p_type - Elf_LE32_Phdr::PT_LOAD;
|
||||
unsigned const xb = b->p_type - Elf_LE32_Phdr::PT_LOAD;
|
||||
if (xa < xb) return -1; // PT_LOAD first
|
||||
if (xa > xb) return 1;
|
||||
if (a->p_paddr < b->p_paddr) return -1; // ascending by .p_paddr
|
||||
if (a->p_paddr > b->p_paddr) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Examples as of 2004-07-16 [readelf --segments vmlinux # before fiddling]:
|
||||
//
|
||||
//----- kernel-2.6.7 plain [defconfig?]
|
||||
//Program Headers(2):
|
||||
// Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
|
||||
// LOAD 0x001000 0x00100000 0x00100000 0x1c7e61 0x1c7e61 R E 0x1000
|
||||
// LOAD 0x1c8e64 0x002c8e64 0x002c8e64 0x00000 0x00000 RW 0x1000
|
||||
//
|
||||
//----- kernel-2.6.7-1.488 Fedora Core 3 test 1
|
||||
//Program Headers(5):
|
||||
// Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
|
||||
// LOAD 0x001000 0x02100000 0x02100000 0x202246 0x202246 R E 0x1000
|
||||
// LOAD 0x204000 0xffff3000 0x02303000 0x00664 0x00664 R E 0x1000
|
||||
// LOAD 0x205000 0x02304000 0x02304000 0x43562 0x43562 R 0x1000
|
||||
// LOAD 0x249000 0x02348000 0x02348000 0x81800 0xcb0fc RWE 0x1000
|
||||
// STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
|
||||
//
|
||||
|
||||
bool PackVmlinuxI386::canPack()
|
||||
{
|
||||
fi->seek(0, SEEK_SET);
|
||||
fi->readx(&ehdri, sizeof(ehdri));
|
||||
|
||||
// now check the ELF header
|
||||
if (memcmp(&ehdri, "\x7f\x45\x4c\x46\x01\x01\x01", 7) // ELF 32-bit LSB
|
||||
|| !memcmp(&ehdri.e_ident[8], "FreeBSD", 7) // branded
|
||||
|| ehdri.e_machine != 3 // Intel 80386
|
||||
|| ehdri.e_version != 1 // version
|
||||
)
|
||||
return false;
|
||||
|
||||
// additional requirements for vmlinux
|
||||
if (ehdri.e_ehsize != sizeof(ehdri) // different <elf.h> ?
|
||||
|| ehdri.e_phoff != sizeof(ehdri) // Phdrs not contiguous with Ehdr
|
||||
|| ehdri.e_phentsize!=sizeof(Elf_LE32_Phdr)
|
||||
|| ehdri.e_type!=Elf_LE32_Ehdr::ET_EXEC
|
||||
|| 0x00100000!=(0x001fffff & ehdri.e_entry) // entry not an odd 1MB
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
phdri = new Elf_LE32_Phdr[(unsigned) ehdri.e_phnum];
|
||||
fi->seek(ehdri.e_phoff, SEEK_SET);
|
||||
fi->readx(phdri, ehdri.e_phnum * sizeof(*phdri));
|
||||
|
||||
// Put PT_LOAD together at the beginning, ascending by .p_paddr.
|
||||
qsort(phdri, ehdri.e_phnum, sizeof(*phdri), compare_Phdr);
|
||||
|
||||
// Check that PT_LOADs form one contiguous chunk of the file.
|
||||
for (unsigned j = 0; j < ehdri.e_phnum; ++j) {
|
||||
if (Elf_LE32_Phdr::PT_LOAD==phdri[j].p_type) {
|
||||
if (0xfff & (phdri[j].p_offset | phdri[j].p_paddr
|
||||
| phdri[j].p_align | phdri[j].p_vaddr) ) {
|
||||
return false;
|
||||
}
|
||||
if (0 < j) {
|
||||
unsigned const sz = (0u - phdri[j-1].p_align)
|
||||
& (phdri[j-1].p_align -1 + phdri[j-1].p_filesz);
|
||||
if ((sz + phdri[j-1].p_offset)!=phdri[j].p_offset) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
++n_ptload;
|
||||
sz_ptload = phdri[j].p_filesz + phdri[j].p_offset - phdri[0].p_offset;
|
||||
}
|
||||
}
|
||||
return 0 < n_ptload;
|
||||
}
|
||||
|
||||
int PackVmlinuxI386::buildLoader(const Filter *ft)
|
||||
{
|
||||
// prepare loader
|
||||
initLoader(nrv_loader, sizeof(nrv_loader));
|
||||
addLoader("LINUX000",
|
||||
(0x40==(0xf0 & ft->id)) ? "LXCKLLT1" : (ft->id ? "LXCALLT1" : ""),
|
||||
"LXMOVEUP",
|
||||
getDecompressor(),
|
||||
NULL
|
||||
);
|
||||
if (ft->id)
|
||||
{
|
||||
assert(ft->calls > 0);
|
||||
if (0x40==(0xf0 & ft->id)) {
|
||||
addLoader("LXCKLLT9", NULL);
|
||||
}
|
||||
else {
|
||||
addLoader("LXCALLT9", NULL);
|
||||
}
|
||||
addFilter32(ft->id);
|
||||
}
|
||||
addLoader("LINUX990""IDENTSTR""UPX1HEAD", NULL);
|
||||
return getLoaderSize();
|
||||
}
|
||||
|
||||
|
||||
void PackVmlinuxI386::pack(OutputFile *fo)
|
||||
{
|
||||
unsigned fo_off = 0;
|
||||
Elf_LE32_Ehdr ehdro;
|
||||
LE32 tmp_le32;
|
||||
|
||||
// NULL
|
||||
// .text(PT_LOADs) .note(1st page) .note(rest)
|
||||
// .shstrtab /* .symtab .strtab */
|
||||
Elf_LE32_Shdr shdro[1+3+1/*+2*/];
|
||||
memset(shdro, 0, sizeof(shdro));
|
||||
char const shstrtab[]= "\0.text\0.note\0.shstrtab\0.symtab\0.strtab";
|
||||
char const *p = shstrtab;
|
||||
|
||||
ibuf.alloc(file_size);
|
||||
obuf.allocForCompression(file_size);
|
||||
|
||||
// .e_ident, .e_machine, .e_version, .e_flags
|
||||
memcpy(&ehdro, &ehdri, sizeof(ehdro));
|
||||
ehdro.e_type = Elf_LE32_Ehdr::ET_REL;
|
||||
ehdro.e_entry = 0;
|
||||
ehdro.e_phoff = 0;
|
||||
ehdro.e_shoff = 0; // later
|
||||
ehdro.e_phentsize = 0;
|
||||
ehdro.e_phnum = 0;
|
||||
ehdro.e_shnum = 1+3+1/*+2*/;
|
||||
ehdro.e_shstrndx = 4;
|
||||
fo->write(&ehdro, sizeof(ehdro)); fo_off+= sizeof(ehdro);
|
||||
|
||||
ph.u_len = sz_ptload;
|
||||
fi->seek(phdri[0].p_offset, SEEK_SET);
|
||||
fi->readx(ibuf, ph.u_len);
|
||||
checkAlreadyPacked(ibuf + ph.u_len - 1024, 1024);
|
||||
|
||||
// prepare filter
|
||||
ph.filter = 0;
|
||||
Filter ft(ph.level);
|
||||
ft.buf_len = ph.u_len;
|
||||
ft.addvalue = 0;
|
||||
|
||||
compressWithFilters(&ft, 1 << 20);
|
||||
|
||||
const unsigned lsize = getLoaderSize();
|
||||
MemBuffer loader(lsize);
|
||||
memcpy(loader, getLoader(), lsize);
|
||||
|
||||
patchPackHeader(loader, lsize);
|
||||
patch_le32(loader, lsize, "ULEN", ph.u_len);
|
||||
patchFilter32(loader, lsize, &ft);
|
||||
|
||||
while (0!=*p++) ;
|
||||
shdro[1].sh_name = ptr_diff(p, shstrtab);
|
||||
shdro[1].sh_type = Elf_LE32_Shdr::SHT_PROGBITS;
|
||||
shdro[1].sh_flags = Elf_LE32_Shdr::SHF_ALLOC | Elf_LE32_Shdr::SHF_EXECINSTR;
|
||||
shdro[1].sh_offset = fo_off;
|
||||
shdro[1].sh_size = 1+ 4+ ph.c_len + lsize;
|
||||
shdro[1].sh_addralign = 1;
|
||||
|
||||
unsigned char const call = 0xE8; // opcode for CALL d32
|
||||
fo->write(&call, 1); fo_off+=1;
|
||||
tmp_le32 = ph.c_len; fo->write(&tmp_le32, 4); fo_off += 4;
|
||||
fo->write(obuf, ph.c_len); fo_off += ph.c_len;
|
||||
fo->write(loader, lsize); fo_off += lsize;
|
||||
|
||||
verifyOverlappingDecompression();
|
||||
|
||||
// .note with 1st page --------------------------------
|
||||
ph.u_len = phdri[0].p_offset;
|
||||
fi->seek(0, SEEK_SET);
|
||||
fi->readx(ibuf, ph.u_len);
|
||||
compress(ibuf, obuf);
|
||||
|
||||
while (0!=*p++) ;
|
||||
shdro[2].sh_name = ptr_diff(p, shstrtab);
|
||||
shdro[2].sh_type = Elf_LE32_Shdr::SHT_NOTE;
|
||||
shdro[2].sh_offset = fo_off;
|
||||
shdro[2].sh_size = sizeof(ph.u_len) + ph.c_len;
|
||||
shdro[2].sh_addralign = 1;
|
||||
tmp_le32 = ph.u_len; fo->write(&tmp_le32, 4);
|
||||
fo->write(obuf, ph.c_len); fo_off += shdro[2].sh_size;
|
||||
|
||||
// .note with rest --------------------------------
|
||||
ph.u_len = file_size - (sz_ptload + phdri[0].p_offset);
|
||||
fi->seek(sz_ptload + phdri[0].p_offset, SEEK_SET);
|
||||
fi->readx(ibuf, ph.u_len);
|
||||
|
||||
// Temporarily decrease ph.level by about (1+ log2(sz_rest / sz_ptload))
|
||||
// to avoid spending unreasonable effort compressing large symbol tables
|
||||
// that are discarded 99.9% of the time anyway.
|
||||
int const old_level = ph.level;
|
||||
for (unsigned v = ((ph.u_len>>3) + ph.u_len) / sz_ptload; 0 < v; v>>=1) {
|
||||
if (0== --ph.level) {
|
||||
ph.level = 1;
|
||||
}
|
||||
}
|
||||
compress(ibuf, obuf);
|
||||
ph.level = old_level;
|
||||
|
||||
// while (0!=*p++) ; // name is the same
|
||||
shdro[3].sh_name = ptr_diff(p, shstrtab);
|
||||
shdro[3].sh_type = Elf_LE32_Shdr::SHT_NOTE;
|
||||
shdro[3].sh_offset = fo_off;
|
||||
shdro[3].sh_size = sizeof(ph.u_len) + ph.c_len;
|
||||
shdro[3].sh_addralign = 1;
|
||||
tmp_le32 = ph.u_len; fo->write(&tmp_le32, 4);
|
||||
fo->write(obuf, ph.c_len); fo_off += shdro[3].sh_size;
|
||||
|
||||
while (0!=*p++) ;
|
||||
shdro[4].sh_name = ptr_diff(p, shstrtab);
|
||||
shdro[4].sh_type = Elf_LE32_Shdr::SHT_STRTAB;
|
||||
shdro[4].sh_offset = fo_off;
|
||||
shdro[4].sh_size = 1+ sizeof(shstrtab); // 1+: terminating '\0'
|
||||
shdro[4].sh_addralign = 1;
|
||||
fo->write(shstrtab, shdro[4].sh_size); fo_off += shdro[4].sh_size;
|
||||
|
||||
#if 0 /*{ no symbols! */
|
||||
while (0!=*p++) ;
|
||||
fo_off = ~3 & (3+ fo_off);
|
||||
shdro[5].sh_name = ptr_diff(p, shstrtab);
|
||||
shdro[5].sh_type = Elf_LE32_Shdr::SHT_SYMTAB;
|
||||
shdro[5].sh_offset = fo_off;
|
||||
shdro[5].sh_size = 16; // XXX ?
|
||||
shdro[5].sh_link = 6; // to .strtab for symbols
|
||||
shdro[5].sh_addralign = 4;
|
||||
shdro[5].sh_entsize = 16; // XXX Elf32_Sym
|
||||
fo->seek(fo_off, SEEK_SET);
|
||||
fo->write("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16); fo_off += 16;
|
||||
|
||||
while (0!=*p++) ;
|
||||
shdro[6].sh_name = ptr_diff(p, shstrtab);
|
||||
shdro[6].sh_type = Elf_LE32_Shdr::SHT_STRTAB;
|
||||
shdro[6].sh_offset = fo_off;
|
||||
shdro[6].sh_size = 1; // XXX ?
|
||||
shdro[6].sh_addralign = 1;
|
||||
fo->write("", 1); fo_off += 1;
|
||||
#endif /*}*/
|
||||
|
||||
fo_off = ~3 & (3+ fo_off);
|
||||
fo->seek(fo_off, SEEK_SET);
|
||||
ehdro.e_shoff = fo_off;
|
||||
fo->write(shdro, sizeof(shdro));
|
||||
|
||||
fo->seek(0, SEEK_SET);
|
||||
fo->write(&ehdro, sizeof(ehdro));
|
||||
|
||||
if (!checkFinalCompressionRatio(fo))
|
||||
throwNotCompressible();
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// unpack
|
||||
**************************************************************************/
|
||||
|
||||
int PackVmlinuxI386::canUnpack()
|
||||
{
|
||||
fi->seek(0, SEEK_SET);
|
||||
fi->readx(&ehdri, sizeof(ehdri));
|
||||
|
||||
// now check the ELF header
|
||||
if (memcmp(&ehdri, "\x7f\x45\x4c\x46\x01\x01\x01", 7) // ELF 32-bit LSB
|
||||
|| !memcmp(&ehdri.e_ident[8], "FreeBSD", 7) // branded
|
||||
|| ehdri.e_machine != 3 // Intel 80386
|
||||
|| ehdri.e_version != 1 // version
|
||||
|| ehdri.e_type != Elf_LE32_Ehdr::ET_REL
|
||||
|| ehdri.e_shnum < 4
|
||||
|| (unsigned)file_size < (ehdri.e_shnum * sizeof(Elf_LE32_Shdr) + ehdri.e_shoff)
|
||||
)
|
||||
return false;
|
||||
|
||||
// find the .shstrtab section
|
||||
char shstrtab[40];
|
||||
Elf_LE32_Shdr *p, *p_shstrtab=0;
|
||||
shdri = new Elf_LE32_Shdr[(unsigned) ehdri.e_shnum];
|
||||
fi->seek(ehdri.e_shoff, SEEK_SET);
|
||||
fi->readx(shdri, ehdri.e_shnum * sizeof(*shdri));
|
||||
int j;
|
||||
for (p = shdri, j= ehdri.e_shnum; --j>=0; ++p) {
|
||||
if (Elf_LE32_Shdr::SHT_STRTAB==p->sh_type
|
||||
&& p->sh_size <= sizeof(shstrtab)
|
||||
&& (p->sh_size + p->sh_offset) <= (unsigned) file_size
|
||||
&& (10+ p->sh_name) <= p->sh_size // 1+ strlen(".shstrtab")
|
||||
) {
|
||||
fi->seek(p->sh_offset, SEEK_SET);
|
||||
fi->readx(shstrtab, p->sh_size);
|
||||
if (0==strcmp(".shstrtab", shstrtab + p->sh_name)) {
|
||||
p_shstrtab = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (0==p_shstrtab) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check for .text .note .note and sane (.sh_size + .sh_offset)
|
||||
p_note0 = p_note1 = p_text = 0;
|
||||
for (p= shdri, j= ehdri.e_shnum; --j>=0; ++p) {
|
||||
if ((unsigned)file_size < (p->sh_size + p->sh_offset)
|
||||
|| p_shstrtab->sh_size < (5+ p->sh_name) ) {
|
||||
continue;
|
||||
}
|
||||
if (0==strcmp(".text", shstrtab + p->sh_name)) {
|
||||
p_text = p;
|
||||
}
|
||||
if (0==strcmp(".note", shstrtab + p->sh_name)) {
|
||||
if (0==p_note0) {
|
||||
p_note0 = p;
|
||||
} else
|
||||
if (0==p_note1) {
|
||||
p_note1 = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (0==p_text || 0==p_note0 || 0==p_note1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char buf[1024];
|
||||
fi->seek(p_text->sh_offset + p_text->sh_size - sizeof(buf), SEEK_SET);
|
||||
fi->readx(buf, sizeof(buf));
|
||||
if (!getPackHeader(buf, sizeof(buf)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void PackVmlinuxI386::unpack(OutputFile *fo)
|
||||
{
|
||||
unsigned char buf[5];
|
||||
PackHeader const ph_tmp(ph);
|
||||
|
||||
fi->seek(p_note0->sh_offset, SEEK_SET);
|
||||
fi->readx(&buf[0], 4);
|
||||
ph.u_len = get_le32(buf);
|
||||
ph.c_len = p_note0->sh_size - 4;
|
||||
ibuf.alloc(ph.c_len);
|
||||
fi->readx(ibuf, ph.c_len);
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
decompress(ibuf, obuf, false);
|
||||
fo->write(obuf, ph.u_len);
|
||||
obuf.dealloc();
|
||||
ibuf.dealloc();
|
||||
|
||||
ph = ph_tmp;
|
||||
fi->seek(p_text->sh_offset, SEEK_SET);
|
||||
fi->readx(&buf[0], 5);
|
||||
if (0xE8!=buf[0] || get_le32(&buf[1]) != ph.c_len)
|
||||
{
|
||||
throwCantUnpack(".text corrupted");
|
||||
}
|
||||
ibuf.alloc(ph.c_len);
|
||||
fi->readx(ibuf, ph.c_len);
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
decompress(ibuf, obuf);
|
||||
|
||||
Filter ft(ph.level);
|
||||
ft.init(ph.filter, 0);
|
||||
ft.cto = (unsigned char) ph.filter_cto;
|
||||
ft.unfilter(obuf, ph.u_len);
|
||||
fo->write(obuf, ph.u_len);
|
||||
obuf.dealloc();
|
||||
ibuf.dealloc();
|
||||
|
||||
fi->seek(p_note1->sh_offset, SEEK_SET);
|
||||
fi->readx(&buf[0], 4);
|
||||
ph.u_len = get_le32(buf);
|
||||
ph.c_len = p_note1->sh_size - 4;
|
||||
ibuf.alloc(ph.c_len);
|
||||
fi->readx(ibuf, p_note1->sh_size - sizeof(ph.u_len));
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
decompress(ibuf, obuf, false);
|
||||
fo->write(obuf, ph.u_len);
|
||||
obuf.dealloc();
|
||||
ibuf.dealloc();
|
||||
|
||||
ph = ph_tmp;
|
||||
}
|
||||
|
||||
//
|
||||
// Example usage within build system of Linux kernel-2.6.7:
|
||||
//
|
||||
//----- arch/i386/boot/compressed/Makefile
|
||||
//#
|
||||
//# linux/arch/i386/boot/compressed/Makefile
|
||||
//#
|
||||
//# create a compressed vmlinux image from the original vmlinux
|
||||
//#
|
||||
//
|
||||
//targets := vmlinux upx-head.o upx-piggy.o
|
||||
//
|
||||
//LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup_32
|
||||
//
|
||||
//$(obj)/vmlinux: $(obj)/upx-head.o $(obj)/upx-piggy.o FORCE
|
||||
// $(call if_changed,ld)
|
||||
// @:
|
||||
//
|
||||
//$(obj)/upx-piggy.o: vmlinux FORCE
|
||||
// rm -f $(obj)/upx-piggy.o
|
||||
// upx -o $(obj)/upx-piggy.o $<
|
||||
//-----
|
||||
//
|
||||
//----- arch/i386/boot/compressed/upx-head.S
|
||||
//#include <asm/segment.h>
|
||||
//
|
||||
// .text
|
||||
//startup_32: .globl startup_32 # In: %esi=0x90000 setup data "real_mode pointer"
|
||||
// cli # but if it matters, then there is a race!
|
||||
//
|
||||
// movl $ __BOOT_DS,%eax
|
||||
// movl %eax,%ss; movl $0x99000,%esp # 2.6.7 setup had ss:sp of 9000:8ffe
|
||||
// /* Avoid EBDA (Extended BIOS Data Area) below 0xA0000. */
|
||||
//
|
||||
// pushl $0; popf # subsumes "cli; cld"; also clears NT for buggy BIOS
|
||||
//
|
||||
// movl %eax,%ds # all non-code segments identical
|
||||
// movl %eax,%es
|
||||
// movl %eax,%fs
|
||||
// movl %eax,%gs
|
||||
//
|
||||
// movl $ 0x100000,%eax # destination of uncompression (and entry point)
|
||||
// pushl $ __BOOT_CS
|
||||
///* Fall into .text of upx-compressed vmlinux. */
|
||||
//-----
|
||||
|
||||
//
|
||||
// Example test jig:
|
||||
// gcc -o test-piggy -nostartfiles -nostdlib test-piggy.o piggy.o
|
||||
// gdb test-piggy
|
||||
// (gdb) run >dumped
|
||||
//----- test-piggy.S
|
||||
//#include <asm/mman.h>
|
||||
//#include <asm/unistd.h>
|
||||
//
|
||||
//dump:
|
||||
// movl $0x456789,%edx # length MODIFY THIS VALUE TO SUIT YOUR CASE
|
||||
// movl $0x100000,%ecx # base
|
||||
// movl $1,%ebx # stdout
|
||||
// movl $ __NR_write,%eax
|
||||
// int $0x80
|
||||
// nop
|
||||
// hlt
|
||||
//mmap:
|
||||
// pushl %ebx
|
||||
// leal 2*4(%esp),%ebx
|
||||
// pushl $ __NR_mmap; popl %eax
|
||||
// int $0x80
|
||||
// popl %ebx
|
||||
// ret $6*4
|
||||
//
|
||||
//_start: .globl _start
|
||||
// nop
|
||||
// int3 # enter debugger!
|
||||
// pushl $0
|
||||
// pushl $0
|
||||
// pushl $ MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED
|
||||
// pushl $ PROT_EXEC | PROT_WRITE | PROT_READ
|
||||
// pushl $0x600000 # 6MB
|
||||
// pushl $0x100000 # 1MB
|
||||
// call mmap
|
||||
// push %cs
|
||||
///* Fall into .text of upx-compressed vmlinux. */
|
||||
//-----
|
||||
|
||||
/*
|
||||
vi:ts=4:et
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/* p_vmlinx.h --
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2004 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
|
||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __UPX_P_VMLINX_H
|
||||
#define __UPX_P_VMLINX_H
|
||||
|
||||
#include "p_elf.h"
|
||||
|
||||
/*************************************************************************
|
||||
// vmlinx/i386 (bare binary Linux kernel image)
|
||||
**************************************************************************/
|
||||
|
||||
class PackVmlinuxI386 : public Packer
|
||||
{
|
||||
typedef Packer super;
|
||||
public:
|
||||
PackVmlinuxI386(InputFile *f);
|
||||
virtual ~PackVmlinuxI386();
|
||||
virtual int getVersion() const { return 13; }
|
||||
virtual int getFormat() const { return UPX_F_VMLINUX_i386; }
|
||||
virtual const char *getName() const { return "vmlinux/386"; }
|
||||
virtual const int *getCompressionMethods(int method, int level) const;
|
||||
virtual const int *getFilters() const;
|
||||
|
||||
virtual void pack(OutputFile *fo);
|
||||
virtual void unpack(OutputFile *fo);
|
||||
|
||||
virtual bool canPack();
|
||||
virtual int canUnpack();
|
||||
|
||||
protected:
|
||||
virtual int buildLoader(const Filter *ft);
|
||||
// virtual const upx_byte *getLoader() const;
|
||||
// virtual int getLoaderSize() const;
|
||||
|
||||
int n_ptload;
|
||||
unsigned sz_ptload;
|
||||
Elf_LE32_Phdr *phdri; // from input file
|
||||
Elf_LE32_Shdr *shdri; // from input file
|
||||
Elf_LE32_Shdr *p_text;
|
||||
Elf_LE32_Shdr *p_note0;
|
||||
Elf_LE32_Shdr *p_note1;
|
||||
Elf_LE32_Ehdr ehdri; // from input file
|
||||
};
|
||||
|
||||
|
||||
#endif /* already included */
|
||||
|
||||
|
||||
/*
|
||||
vi:ts=4:et
|
||||
*/
|
||||
|
||||
+46
-21
@@ -66,6 +66,19 @@ static const
|
||||
# define strcpy(a,b) strcpy((char *)(a),(const char *)(b))
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
static unsigned my_strlen(const char *s)
|
||||
{
|
||||
size_t l = strlen((const char*)s); assert((unsigned) l == l); return (unsigned) l;
|
||||
}
|
||||
static unsigned my_strlen(const unsigned char *s)
|
||||
{
|
||||
size_t l = strlen((const char*)s); assert((unsigned) l == l); return (unsigned) l;
|
||||
}
|
||||
#undef strlen
|
||||
#define strlen my_strlen
|
||||
#endif
|
||||
|
||||
|
||||
// Unicode string compare
|
||||
static bool ustrsame(const void *s1, const void *s2)
|
||||
@@ -728,11 +741,11 @@ unsigned PackW32Pe::processImports() // pass 1
|
||||
}
|
||||
ppi++;
|
||||
|
||||
unsigned esize = ptr_diff(tarr,idlls[ic]->lookupt);
|
||||
unsigned esize = ptr_diff((char *)tarr, (char *)idlls[ic]->lookupt);
|
||||
lookups.add(idlls[ic]->lookupt,esize);
|
||||
if (ptr_diff(ibuf + idlls[ic]->iat,idlls[ic]->lookupt))
|
||||
if (ptr_diff(ibuf + idlls[ic]->iat, (char *)idlls[ic]->lookupt))
|
||||
{
|
||||
memcpy(ibuf + idlls[ic]->iat,idlls[ic]->lookupt,esize);
|
||||
memcpy(ibuf + idlls[ic]->iat, idlls[ic]->lookupt, esize);
|
||||
iats.add(idlls[ic]->iat,esize);
|
||||
}
|
||||
names.add(idlls[ic]->name,strlen(idlls[ic]->name) + 1 + 1);
|
||||
@@ -908,26 +921,26 @@ void Export::convert(unsigned eoffs,unsigned esize)
|
||||
#endif
|
||||
}
|
||||
|
||||
void Export::build(char *newbase,unsigned newoffs)
|
||||
void Export::build(char *newbase, unsigned newoffs)
|
||||
{
|
||||
char *functionp = newbase + sizeof(edir);
|
||||
char *namep = functionp + 4 * edir.functions;
|
||||
char *ordinalp = namep + 4 * edir.names;
|
||||
char *enamep = ordinalp + 2 * edir.names;
|
||||
char *exports = enamep + strlen(ename) + 1;
|
||||
char * const functionp = newbase + sizeof(edir);
|
||||
char * const namep = functionp + 4 * edir.functions;
|
||||
char * const ordinalp = namep + 4 * edir.names;
|
||||
char * const enamep = ordinalp + 2 * edir.names;
|
||||
char * exports = enamep + strlen(ename) + 1;
|
||||
|
||||
edir.addrtable = newoffs + functionp - newbase;
|
||||
edir.ordinaltable = newoffs + ordinalp - newbase;
|
||||
edir.addrtable = newoffs + ptr_diff(functionp, newbase);
|
||||
edir.ordinaltable = newoffs + ptr_diff(ordinalp, newbase);
|
||||
memcpy(ordinalp,ordinals,2 * edir.names);
|
||||
|
||||
edir.name = newoffs + enamep - newbase;
|
||||
edir.name = newoffs + ptr_diff(enamep, newbase);
|
||||
strcpy(enamep,ename);
|
||||
edir.nameptrtable = newoffs + namep - newbase;
|
||||
edir.nameptrtable = newoffs + ptr_diff(namep, newbase);
|
||||
unsigned ic;
|
||||
for (ic = 0; ic < edir.names; ic++)
|
||||
{
|
||||
strcpy(exports,names[ic]);
|
||||
set_le32(namep + 4 * ic,newoffs + exports - newbase);
|
||||
set_le32(namep + 4 * ic,newoffs + ptr_diff(exports, newbase));
|
||||
exports += strlen(exports) + 1;
|
||||
}
|
||||
|
||||
@@ -936,7 +949,7 @@ void Export::build(char *newbase,unsigned newoffs)
|
||||
if (names[edir.names + ic])
|
||||
{
|
||||
strcpy(exports,names[edir.names + ic]);
|
||||
set_le32(functionp + 4 * ic,newoffs + exports - newbase);
|
||||
set_le32(functionp + 4 * ic,newoffs + ptr_diff(exports, newbase));
|
||||
exports += strlen(exports) + 1;
|
||||
}
|
||||
|
||||
@@ -1589,6 +1602,9 @@ int PackW32Pe::buildLoader(const Filter *ft)
|
||||
|
||||
void PackW32Pe::pack(OutputFile *fo)
|
||||
{
|
||||
if (opt->win32_pe.strip_loadconf < 0)
|
||||
opt->win32_pe.strip_loadconf = false;
|
||||
|
||||
const unsigned objs = ih.objects;
|
||||
isection = new pe_section_t[objs];
|
||||
fi->seek(pe_offset+sizeof(ih),SEEK_SET);
|
||||
@@ -1600,8 +1616,8 @@ void PackW32Pe::pack(OutputFile *fo)
|
||||
|
||||
// check the PE header
|
||||
// FIXME: add more checks
|
||||
if (!opt->force
|
||||
&& (ih.cpu < 0x14c || ih.cpu > 0x150
|
||||
if (!opt->force && (
|
||||
ih.cpu < 0x14c || ih.cpu > 0x150
|
||||
|| ih.opthdrsize != 0xE0
|
||||
|| (ih.flags & EXECUTABLE) == 0
|
||||
|| (ih.subsystem != 2 && ih.subsystem != 3 && ih.subsystem != 1)
|
||||
@@ -1609,15 +1625,18 @@ void PackW32Pe::pack(OutputFile *fo)
|
||||
|| ih.ddirsentries != 16
|
||||
|| IDSIZE(PEDIR_EXCEPTION) // is this used on i386?
|
||||
// || IDSIZE(PEDIR_COPYRIGHT)
|
||||
|| IDSIZE(PEDIR_LOADCONF)
|
||||
|| IDSIZE(PEDIR_COMRT)
|
||||
))
|
||||
throwCantPack("unexpected value in PE header (try --force)");
|
||||
|
||||
if (IDSIZE(PEDIR_SEC))
|
||||
throwCantPack("compressing certificate info is not supported");
|
||||
//if (IDSIZE(PEDIR_DELAYIMP))
|
||||
// throwCantPack("delay load imports are not supported");
|
||||
if (IDSIZE(PEDIR_COMRT))
|
||||
throwCantPack(".NET files (win32/net) are not yet supported");
|
||||
|
||||
// Structured Exception Handling
|
||||
if (!opt->win32_pe.strip_loadconf && IDSIZE(PEDIR_LOADCONF))
|
||||
throwCantPack("Structured Exception Handling present (try --strip-loadconf)");
|
||||
|
||||
if (isdll)
|
||||
opt->win32_pe.strip_relocs = false;
|
||||
else if (opt->win32_pe.strip_relocs < 0)
|
||||
@@ -1892,6 +1911,12 @@ void PackW32Pe::pack(OutputFile *fo)
|
||||
ODADDR(PEDIR_BOUNDIM) = 0;
|
||||
ODSIZE(PEDIR_BOUNDIM) = 0;
|
||||
|
||||
if (opt->win32_pe.strip_loadconf)
|
||||
{
|
||||
ODADDR(PEDIR_LOADCONF) = 0;
|
||||
ODSIZE(PEDIR_LOADCONF) = 0;
|
||||
}
|
||||
|
||||
// tls is put into section 1
|
||||
|
||||
ic = s1addr + s1size - sotls;
|
||||
|
||||
+6
-6
@@ -166,7 +166,7 @@ void PackWcle::encodeEntryTable()
|
||||
//if (Opt_debug) printf("%d entries encoded.\n",n);
|
||||
UNUSED(n);
|
||||
|
||||
soentries = p - ientries + 1;
|
||||
soentries = ptr_diff(p, ientries) + 1;
|
||||
oentries = ientries;
|
||||
ientries = NULL;
|
||||
}
|
||||
@@ -402,7 +402,7 @@ void PackWcle::preprocessFixups()
|
||||
set_le32(fix,0xFFFFFFFFUL);
|
||||
fix += 4;
|
||||
|
||||
sofixups = fix - ifixups;
|
||||
sofixups = ptr_diff(fix, ifixups);
|
||||
}
|
||||
|
||||
|
||||
@@ -590,7 +590,7 @@ void PackWcle::decodeFixups()
|
||||
while (*selfrel_fixups != 0xC3)
|
||||
selfrel_fixups += 9;
|
||||
selfrel_fixups++;
|
||||
unsigned selectlen = (selfrel_fixups - selector_fixups)/9;
|
||||
unsigned selectlen = ptr_diff(selfrel_fixups, selector_fixups)/9;
|
||||
|
||||
ofixups = new upx_byte[fixupn*9+1000+selectlen*5];
|
||||
upx_bytep fp = ofixups;
|
||||
@@ -656,11 +656,11 @@ void PackWcle::decodeFixups()
|
||||
fp += fp[1] ? 9 : 7;
|
||||
jc += 2;
|
||||
}
|
||||
set_le32(ofpage_table+ic,fp-ofixups);
|
||||
set_le32(ofpage_table+ic,ptr_diff(fp,ofixups));
|
||||
}
|
||||
for (ic=0; ic < FIXUP_EXTRA; ic++)
|
||||
*fp++ = 0;
|
||||
sofixups = fp-ofixups;
|
||||
sofixups = ptr_diff(fp, ofixups);
|
||||
}
|
||||
|
||||
|
||||
@@ -748,7 +748,7 @@ void PackWcle::decodeEntryTable()
|
||||
|
||||
//if (Opt_debug) printf("\n%d entries decoded.\n",n);
|
||||
|
||||
soentries = p - ientries + 1;
|
||||
soentries = ptr_diff(p, ientries) + 1;
|
||||
oentries = ientries;
|
||||
ientries = NULL;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1030,8 +1030,8 @@ void __acc_cdecl_va Packer::addLoader(const char *s, ...)
|
||||
const char *p;
|
||||
va_list ap;
|
||||
|
||||
linker->addSection(s);
|
||||
va_start(ap, s);
|
||||
linker->addSection(s);
|
||||
while((p = va_arg(ap, const char *)) != NULL)
|
||||
linker->addSection(p);
|
||||
va_end(ap);
|
||||
|
||||
@@ -373,6 +373,7 @@ bool Packer::patchFilter32(void *loader, int lsize, const Filter *ft)
|
||||
if (ft->id < 0x80) {
|
||||
if (0x40 <= ft->id && ft->id < 0x50
|
||||
&& ( UPX_F_LINUX_i386 ==ph.format
|
||||
|| UPX_F_VMLINUX_i386 ==ph.format
|
||||
|| UPX_F_VMLINUZ_i386 ==ph.format
|
||||
|| UPX_F_BVMLINUZ_i386==ph.format ) ) {
|
||||
// "push byte '?'"
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "p_w16ne.h"
|
||||
#include "p_w32pe.h"
|
||||
#include "p_vmlinz.h"
|
||||
#include "p_vmlinx.h"
|
||||
#include "p_ps1.h"
|
||||
|
||||
|
||||
@@ -182,6 +183,8 @@ static Packer* try_packers(InputFile *f, try_function func)
|
||||
//
|
||||
// linux kernel
|
||||
//
|
||||
if ((p = func(new PackVmlinuxI386(f),f)) != NULL)
|
||||
return p;
|
||||
if ((p = func(new PackVmlinuzI386(f),f)) != NULL)
|
||||
return p;
|
||||
if ((p = func(new PackBvmlinuzI386(f),f)) != NULL)
|
||||
@@ -224,6 +227,7 @@ static Packer* try_packers(InputFile *f, try_function func)
|
||||
return p;
|
||||
if ((p = func(new PackCom(f),f)) != NULL)
|
||||
return p;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ l_t_n2ds.h
|
||||
l_t_n2e.h
|
||||
l_t_n2es.h
|
||||
l_tmt.h
|
||||
l_vmlinx.h
|
||||
l_vmlinz.h
|
||||
l_w32pe.h
|
||||
l_wcle.h
|
||||
|
||||
+16
-11
@@ -35,7 +35,7 @@ STUBS = \
|
||||
l_lx_exec86.h fold_exec86.h \
|
||||
l_lx_elf86.h fold_elf86.h \
|
||||
l_lx_sh86.h fold_sh86.h \
|
||||
l_vmlinz.h
|
||||
l_vmlinz.h l_vmlinx.h
|
||||
|
||||
# experimental:
|
||||
ifneq ($(strip $(wildcard $(srcdir)/l_ext2.asm)),)
|
||||
@@ -87,27 +87,27 @@ LD_LINUX_I386 = ld-2.13.2
|
||||
LD_LINUX_I386 = ld
|
||||
OBJCOPY_LINUX_I386 = objcopy
|
||||
|
||||
# gcc 2.7.2.3 (fold_*.bin: 1718 / 1011 / 1340)
|
||||
# gcc 2.7.2.3 (fold_*.bin: 1839 / 1011 / 1390)
|
||||
CC_LINUX_I386_GCC272 = gcc-2.72 -m386 -O2 -MMD
|
||||
CC_LINUX_I386_GCC272 += -malign-functions=0 -malign-jumps=0 -malign-loops=0
|
||||
|
||||
# gcc 2.95.3 (fold_*.bin: 1618 / 995 / 1305)
|
||||
# gcc 2.95.3 (fold_*.bin: 1729 / 995 / 1332)
|
||||
CC_LINUX_I386_GCC295 = gcc-2.95 -march=i386 -mcpu=k6 -fno-exceptions -MMD
|
||||
CC_LINUX_I386_GCC295 += -Os -fno-omit-frame-pointer
|
||||
CC_LINUX_I386_GCC295 += -malign-functions=0 -malign-jumps=0 -malign-loops=0
|
||||
CC_LINUX_I386_GCC295 += -Werror
|
||||
|
||||
# gcc 3.4.0 (fold_*.bin: 1482 / 931 / 1173)
|
||||
CC_LINUX_I386_GCC340 = gcc-3.4 -march=i386 -mtune=k6 -fno-exceptions -MMD
|
||||
CC_LINUX_I386_GCC340 += -Os -fno-omit-frame-pointer
|
||||
CC_LINUX_I386_GCC340 += -momit-leaf-frame-pointer
|
||||
CC_LINUX_I386_GCC340 += -fno-align-functions -fno-align-jumps -fno-align-labels -fno-align-loops
|
||||
##CC_LINUX_I386_GCC340 += -fweb
|
||||
CC_LINUX_I386_GCC340 += -Werror
|
||||
# gcc 3.4.0 (fold_*.bin: 1628 / 931 / 1210)
|
||||
CC_LINUX_I386_GCC34 = gcc-3.4.0 -march=i386 -mtune=k6 -fno-exceptions -MMD
|
||||
CC_LINUX_I386_GCC34 += -Os -fno-omit-frame-pointer
|
||||
CC_LINUX_I386_GCC34 += -momit-leaf-frame-pointer
|
||||
CC_LINUX_I386_GCC34 += -fno-align-functions -fno-align-jumps -fno-align-labels -fno-align-loops
|
||||
##CC_LINUX_I386_GCC34 += -fweb
|
||||
CC_LINUX_I386_GCC34 += -Werror
|
||||
|
||||
CC_LINUX_I386 = $(CC_LINUX_I386_GCC272)
|
||||
CC_LINUX_I386 = $(CC_LINUX_I386_GCC295)
|
||||
CC_LINUX_I386 = $(CC_LINUX_I386_GCC340)
|
||||
CC_LINUX_I386 = $(CC_LINUX_I386_GCC34)
|
||||
CC_LINUX_I386 += -nostdinc
|
||||
CC_LINUX_I386 += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings
|
||||
CC_LINUX_I386 += -funsigned-char
|
||||
@@ -221,6 +221,10 @@ l_vmlinz.h: l_vmlinz.asx
|
||||
$(NASM) -f bin -o $T.bin $<
|
||||
$(BIN2H) $T.bin nrv_loader $@
|
||||
|
||||
l_vmlinx.h: l_vmlinx.asx
|
||||
$(NASM) -f bin -o $T.bin $<
|
||||
$(BIN2H) $T.bin nrv_loader $@
|
||||
|
||||
l_vxd.h: l_vxd.asx
|
||||
$(NASM) -f bin -o $T.bin $<
|
||||
$(BIN2H) $T.bin nrv_loader $@
|
||||
@@ -398,6 +402,7 @@ l_t_n2e.h: n2e_d.ash bits.ash $(DEPS1) ../version.h
|
||||
l_t_n2es.h: n2e_d.ash bits.ash $(DEPS1) ../version.h
|
||||
l_tmt.h: $(DEPS2) $(DEPS3)
|
||||
l_vmlinz.h: $(DEPS2) $(DEPS3)
|
||||
l_vmlinx.h: $(DEPS2) $(DEPS3)
|
||||
l_vxd.h: $(DEPS2) $(DEPS3)
|
||||
l_wcle.h: $(DEPS2) $(DEPS3)
|
||||
l_w32pe.h: $(DEPS2) $(DEPS3)
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
; cl1_d32.ash -- cl1_decompress_le32 in 32-bit assembly
|
||||
; schema from ucl/nrv2b_d32.ash
|
||||
;
|
||||
; Copyright (C) 2004 John Reiser
|
||||
; Copyright (C) 1996-2003 Markus Franz Xaver Johannes Oberhumer
|
||||
; All Rights Reserved.
|
||||
;
|
||||
; This file is free software; you can redistribute it and/or
|
||||
; modify it 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 file 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 the UCL library; 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 John Reiser
|
||||
; <markus@oberhumer.com> <jreiser@BitWagon.com>
|
||||
;
|
||||
|
||||
|
||||
; ------------- DECOMPRESSION -------------
|
||||
|
||||
; Input:
|
||||
; esi - source
|
||||
; edi - dest
|
||||
; ebp - -1
|
||||
; cld
|
||||
|
||||
; Output:
|
||||
; eax - 0
|
||||
; ecx - 0
|
||||
|
||||
|
||||
%ifndef jmps
|
||||
%define jmps jmp short
|
||||
%endif
|
||||
%ifndef jmpn
|
||||
%define jmpn jmp near
|
||||
%endif
|
||||
|
||||
|
||||
;; One of these two is instantiated many times by buildLoader
|
||||
%ifdef __CL1SMA1B__
|
||||
call edx
|
||||
%else; __CL1FAS1B__
|
||||
add ebx, ebx
|
||||
db 0x75,2 ;jnz cl1_no_reload
|
||||
call edx
|
||||
;cl1_no_reload:
|
||||
%endif; __CL1GET1B__
|
||||
|
||||
; __CL1ENTER__
|
||||
nop ; 'int3' for debugging
|
||||
call start_cl1 ; pic push address of next instr
|
||||
; __CL1SMA10__
|
||||
getbit_cl1: ; appears only in small version
|
||||
add ebx, ebx
|
||||
jz reload_cl1
|
||||
ret
|
||||
; __CL1RLOAD__
|
||||
reload_cl1: ; for both small and fast version
|
||||
mov ebx, [esi]
|
||||
sub esi, byte -4
|
||||
adc ebx, ebx
|
||||
ret
|
||||
; __CL1WID01__
|
||||
widelit_cl1:
|
||||
sub ecx,ecx ; back to 0
|
||||
; getbit
|
||||
; __CL1WID02__
|
||||
adc ecx,ecx
|
||||
; getbit
|
||||
; __CL1WID03__
|
||||
jc lit89_cl1
|
||||
; getbit
|
||||
; __CL1WID04__
|
||||
adc ecx,ecx
|
||||
; getbit
|
||||
; __CL1WID05__
|
||||
jc lit10_12_cl1
|
||||
; getbit
|
||||
; __CL1WID06__
|
||||
adc ecx,ecx ; 0..7; -1+ (width/2) of length
|
||||
litwidth_cl1: ; ss22 algorithm, counted width<=8 pairs; returns eax= 2..0x15555
|
||||
; getbit
|
||||
; __CL1WID07__
|
||||
adc eax,eax
|
||||
dec eax
|
||||
; getbit
|
||||
; __CL1WID08__
|
||||
adc eax,eax
|
||||
sub ecx, byte 1
|
||||
jnc litwidth_cl1
|
||||
lea ecx,[17 -2 + eax] ; 17: predecessors; ss22 returns 2..
|
||||
cmp eax,0xffff-(17 -2)
|
||||
jb litgo_cl1 ; not maximal range of search
|
||||
lea eax,[esi + ecx] ; esi after copy
|
||||
push eax ; "parameter" to maxlit_cl1
|
||||
jmpn maxlit_cl1 ; can have another literal afterwards
|
||||
lit13_16_cl1:
|
||||
; getbit
|
||||
; __CL1WID09__
|
||||
adc ecx,ecx
|
||||
; getbit
|
||||
; __CL1WID10__
|
||||
adc ecx,ecx
|
||||
add ecx, byte 13
|
||||
jmps litmov_cl1
|
||||
lit10_12_cl1:
|
||||
test ecx,ecx
|
||||
jz lit13_16_cl1
|
||||
inc ecx ; 2,3,4
|
||||
lit89_cl1:
|
||||
add ecx, byte 8
|
||||
litgo_cl1:
|
||||
jmps litmov_cl1
|
||||
; __CL1START__
|
||||
start_cl1:
|
||||
sub ecx,ecx ; 0
|
||||
pop edx ; edx= getbit_cl1 or reload_cl1
|
||||
sub ebx, ebx ; cause reload on first bit
|
||||
|
||||
; __CL1TOP00__
|
||||
top_cl1: ; In: 0==ecx
|
||||
lea eax,[1+ ecx] ; 1: the msb of offset or large width
|
||||
; getbit
|
||||
; __CL1TOP01__
|
||||
jnc match_cl1
|
||||
; getbit
|
||||
; __CL1TOP02__
|
||||
jc lit1_cl1
|
||||
; getbit
|
||||
; __CL1TOP03__
|
||||
jc lit2_cl1
|
||||
; getbit
|
||||
; __CL1TOP04__
|
||||
jc lit3_cl1
|
||||
add ecx, byte 2
|
||||
; getbit
|
||||
; __CL1TOP05__
|
||||
jc lit45_cl1
|
||||
inc ecx
|
||||
; getbit
|
||||
; __CL1TOP06__
|
||||
jc lit67_cl1
|
||||
jmpn widelit_cl1
|
||||
lit67_cl1:
|
||||
lit45_cl1:
|
||||
; getbit
|
||||
; __CL1TOP07__
|
||||
adc ecx,ecx
|
||||
litmov_cl1:
|
||||
db 0xD1,((3<<6)|(5<<3)|1) ;shr ecx,1
|
||||
jnc litmovb_cl1
|
||||
movsb
|
||||
litmovb_cl1:
|
||||
db 0xD1,((3<<6)|(5<<3)|1) ;shr ecx,1
|
||||
jnc litmovw_cl1
|
||||
movsw
|
||||
litmovw_cl1:
|
||||
rep
|
||||
movsd
|
||||
lea eax,[1+ ecx] ; 1: the msb
|
||||
jmps litdone_cl1
|
||||
lit3_cl1:
|
||||
movsb
|
||||
lit2_cl1:
|
||||
movsb
|
||||
lit1_cl1:
|
||||
movsb
|
||||
litdone_cl1:
|
||||
|
||||
match_cl1: ; In: 0==ecx; 1==eax
|
||||
|
||||
offset_cl1: ; ss11 algorithm
|
||||
; getbit
|
||||
; __CL1OFF01__
|
||||
adc eax,eax
|
||||
; getbit
|
||||
; __CL1OFF02__
|
||||
jnc offset_cl1
|
||||
sub eax, byte 3 ; 2.. ==> -1[prev], (0,,<<8)|byte
|
||||
jc prev_off_cl1
|
||||
shl eax,8
|
||||
lodsb
|
||||
xor eax, byte ~0
|
||||
jz done_cl1 ; EOF
|
||||
mov ebp,eax ; -offset
|
||||
prev_off_cl1: ; 1st 2 bits encode (5<=len),2,3,4
|
||||
; getbit
|
||||
; __CL1OFF03__
|
||||
adc ecx,ecx
|
||||
; getbit
|
||||
; __CL1OFF04__
|
||||
adc ecx,ecx
|
||||
jnz wrinkle_cl1
|
||||
; __CL1LEN00__
|
||||
inc ecx ; 1: the msb
|
||||
mlen_cl1:
|
||||
; getbit
|
||||
; __CL1LEN01__
|
||||
adc ecx,ecx
|
||||
; getbit
|
||||
; __CL1LEN02__
|
||||
jnc mlen_cl1
|
||||
add ecx, byte 2 ; 2.. ==> 4..
|
||||
; __CL1COPY0__
|
||||
wrinkle_cl1:
|
||||
cmp ebp,-0xd00
|
||||
adc ecx, byte 1
|
||||
copy_cl1:
|
||||
push esi
|
||||
lea esi,[edi + ebp]
|
||||
cmp ebp, byte -4
|
||||
ja ripple_cl1
|
||||
maxlit_cl1: ; literal copy cannot overlap; omit test for ripple
|
||||
db 0xD1,((3<<6)|(5<<3)|1) ;shr ecx,1
|
||||
jnc maxlitb_cl1
|
||||
movsb
|
||||
maxlitb_cl1:
|
||||
db 0xD1,((3<<6)|(5<<3)|1) ;shr ecx,1
|
||||
jnc maxlitw_cl1
|
||||
movsw
|
||||
maxlitw_cl1:
|
||||
rep
|
||||
movsd
|
||||
popbot_cl1:
|
||||
pop esi
|
||||
bottom_cl1:
|
||||
jmpn top_cl1
|
||||
ripple_cl1:
|
||||
cmp ebp, byte -1
|
||||
jne ripmov_cl1
|
||||
lodsb
|
||||
rep
|
||||
stosb
|
||||
jmps popbot_cl1
|
||||
ripmov_cl1:
|
||||
rep
|
||||
movsb
|
||||
jmps popbot_cl1
|
||||
done_cl1:
|
||||
; __CL1END__
|
||||
|
||||
; vi:ts=8:et
|
||||
|
||||
+16
-21
@@ -241,17 +241,12 @@ auxv_up(Elf32_auxv_t *av, int const type, unsigned const value)
|
||||
((x)|((x)<<4)|((x)<<8)|((x)<<12)|((x)<<16)|((x)<<20)|((x)<<24)|((x)<<28))
|
||||
#define EXP8(y) \
|
||||
((1&(y)) ? 0xf0f0f0f0 : (2&(y)) ? 0xff00ff00 : (4&(y)) ? 0xffff0000 : 0)
|
||||
|
||||
static inline unsigned
|
||||
__attribute__((regparm(1), stdcall))
|
||||
pf_to_prot(unsigned const pf)
|
||||
{
|
||||
return (PROT_READ|PROT_WRITE|PROT_EXEC) & (
|
||||
( (REP8(PROT_EXEC ) & EXP8(PF_X))
|
||||
|(REP8(PROT_READ ) & EXP8(PF_R))
|
||||
|(REP8(PROT_WRITE) & EXP8(PF_W))
|
||||
) >> ((pf & (PF_R|PF_W|PF_X))<<2) );
|
||||
}
|
||||
#define PF_TO_PROT(pf) \
|
||||
((PROT_READ|PROT_WRITE|PROT_EXEC) & ( \
|
||||
( (REP8(PROT_EXEC ) & EXP8(PF_X)) \
|
||||
|(REP8(PROT_READ ) & EXP8(PF_R)) \
|
||||
|(REP8(PROT_WRITE) & EXP8(PF_W)) \
|
||||
) >> ((pf & (PF_R|PF_W|PF_X))<<2) ))
|
||||
|
||||
|
||||
// Find convex hull of PT_LOAD (the minimal interval which covers all PT_LOAD),
|
||||
@@ -263,18 +258,18 @@ xfind_pages(unsigned mflags, Elf32_Phdr const *phdr, int phnum,
|
||||
char **const p_brk
|
||||
)
|
||||
{
|
||||
size_t lo= ~0, hi= 0, szlo= 0;
|
||||
size_t lo= ~0, hi= 0, szlo= 0;
|
||||
char *addr;
|
||||
mflags += MAP_PRIVATE | MAP_ANONYMOUS; // '+' can optimize better than '|'
|
||||
for (; --phnum>=0; ++phdr) if (PT_LOAD==phdr->p_type) {
|
||||
if (phdr->p_vaddr < lo) {
|
||||
lo = phdr->p_vaddr;
|
||||
for (; --phnum>=0; ++phdr) if (PT_LOAD==phdr->p_type) {
|
||||
if (phdr->p_vaddr < lo) {
|
||||
lo = phdr->p_vaddr;
|
||||
szlo = phdr->p_filesz;
|
||||
}
|
||||
if (hi < (phdr->p_memsz + phdr->p_vaddr)) {
|
||||
hi = phdr->p_memsz + phdr->p_vaddr;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hi < (phdr->p_memsz + phdr->p_vaddr)) {
|
||||
hi = phdr->p_memsz + phdr->p_vaddr;
|
||||
}
|
||||
}
|
||||
szlo += ~PAGE_MASK & lo; // page fragment on lo edge
|
||||
lo -= ~PAGE_MASK & lo; // round down to page boundary
|
||||
hi = PAGE_MASK & (hi - lo - PAGE_MASK -1); // page length
|
||||
@@ -300,7 +295,7 @@ do_xmap(int const fdi, Elf32_Ehdr const *const ehdr, struct Extent *const xi,
|
||||
auxv_up(av, AT_PHDR, phdr->p_vaddr + reloc);
|
||||
}
|
||||
else if (PT_LOAD==phdr->p_type) {
|
||||
unsigned const prot = pf_to_prot(phdr->p_flags);
|
||||
unsigned const prot = PF_TO_PROT(phdr->p_flags);
|
||||
struct Extent xo;
|
||||
size_t mlen = xo.size = phdr->p_filesz;
|
||||
char *addr = xo.buf = (char *)phdr->p_vaddr;
|
||||
|
||||
+15
-20
@@ -172,16 +172,11 @@ bzero(char *p, size_t len)
|
||||
((x)|((x)<<4)|((x)<<8)|((x)<<12)|((x)<<16)|((x)<<20)|((x)<<24)|((x)<<28))
|
||||
#define EXP8(y) \
|
||||
((1&(y)) ? 0xf0f0f0f0 : (2&(y)) ? 0xff00ff00 : (4&(y)) ? 0xffff0000 : 0)
|
||||
|
||||
static inline unsigned
|
||||
__attribute__((regparm(1), stdcall))
|
||||
pf_to_prot(unsigned const pf)
|
||||
{
|
||||
return 7 & (( (REP8(PROT_EXEC ) & EXP8(PF_X))
|
||||
|(REP8(PROT_READ ) & EXP8(PF_R))
|
||||
|(REP8(PROT_WRITE) & EXP8(PF_W)) )
|
||||
>> ((pf & (PF_R|PF_W|PF_X))<<2) );
|
||||
}
|
||||
#define PF_TO_PROT(pf) \
|
||||
(7 & (( (REP8(PROT_EXEC ) & EXP8(PF_X)) \
|
||||
|(REP8(PROT_READ ) & EXP8(PF_R)) \
|
||||
|(REP8(PROT_WRITE) & EXP8(PF_W)) ) \
|
||||
>> ((pf & (PF_R|PF_W|PF_X))<<2) ))
|
||||
|
||||
|
||||
// Find convex hull of PT_LOAD (the minimal interval which covers all PT_LOAD),
|
||||
@@ -191,18 +186,18 @@ static unsigned long // returns relocation constant
|
||||
__attribute__((regparm(3), stdcall))
|
||||
xfind_pages(unsigned mflags, Elf32_Phdr const *phdr, int phnum)
|
||||
{
|
||||
size_t lo= ~0, hi= 0, szlo= 0;
|
||||
size_t lo= ~0, hi= 0, szlo= 0;
|
||||
char *addr;
|
||||
mflags += MAP_PRIVATE | MAP_ANONYMOUS; // '+' can optimize better than '|'
|
||||
for (; --phnum>=0; ++phdr) if (PT_LOAD==phdr->p_type) {
|
||||
if (phdr->p_vaddr < lo) {
|
||||
lo = phdr->p_vaddr;
|
||||
for (; --phnum>=0; ++phdr) if (PT_LOAD==phdr->p_type) {
|
||||
if (phdr->p_vaddr < lo) {
|
||||
lo = phdr->p_vaddr;
|
||||
szlo = phdr->p_filesz;
|
||||
}
|
||||
if (hi < (phdr->p_memsz + phdr->p_vaddr)) {
|
||||
hi = phdr->p_memsz + phdr->p_vaddr;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hi < (phdr->p_memsz + phdr->p_vaddr)) {
|
||||
hi = phdr->p_memsz + phdr->p_vaddr;
|
||||
}
|
||||
}
|
||||
if (MAP_FIXED & mflags) { // the "shell", and not the PT_INTERP
|
||||
// This is a dirty hack to set the proper value for brk(0) as seen by
|
||||
// the "shell" which we will mmap() soon, upon return to do_xmap().
|
||||
@@ -249,7 +244,7 @@ do_xmap(int const fdi, Elf32_Ehdr const *const ehdr, Elf32_auxv_t *const av)
|
||||
av[AT_PHDR -1].a_un.a_val = phdr->p_vaddr;
|
||||
}
|
||||
else if (PT_LOAD==phdr->p_type) {
|
||||
unsigned const prot = pf_to_prot(phdr->p_flags);
|
||||
unsigned const prot = PF_TO_PROT(phdr->p_flags);
|
||||
struct Extent xo;
|
||||
size_t mlen = xo.size = phdr->p_filesz;
|
||||
char *addr = xo.buf = (char *)phdr->p_vaddr;
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
; l_vmlinx.asm -- loader & decompressor for the vmlinux/i386 format
|
||||
;
|
||||
; This file is part of the UPX executable compressor.
|
||||
;
|
||||
; Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
||||
; Copyright (C) 1996-2004 Laszlo Molnar
|
||||
; Copyright (C) 2004 John Reiser
|
||||
; 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>
|
||||
;
|
||||
; John Reiser
|
||||
; <jreiser@users.sourceforge.net>
|
||||
|
||||
|
||||
%define jmps jmp short
|
||||
%define jmpn jmp near
|
||||
%include "macros.ash"
|
||||
|
||||
BITS 32
|
||||
SECTION .text
|
||||
ORG 0
|
||||
|
||||
; =============
|
||||
; ============= ENTRY POINT
|
||||
; =============
|
||||
|
||||
start:
|
||||
; In:
|
||||
; %eax= &uncompressed [and final entry]; %ds= %es= __BOOT_DS
|
||||
; %esp: &compressed; __BOOT_CS
|
||||
; __LINUX000__
|
||||
pop edx ; &compressed; length at -4(%edx)
|
||||
|
||||
push eax ; MATCH00(1/2) entry address; __BOOT_CS
|
||||
push edi ; MATCH01 save
|
||||
push esi ; MATCH02 save
|
||||
|
||||
%ifdef __LXCALLT1__
|
||||
push eax ; MATCH03 src unfilter
|
||||
%endif; __LXDUMMY0__
|
||||
%ifdef __LXCKLLT1__
|
||||
push eax ; MATCH03 src unfilter
|
||||
push byte '?' ; MATCH04 cto unfilter
|
||||
%endif; __LXMOVEUP__
|
||||
push 'ULEN' ; MATCH05 uncompressed length
|
||||
call move_up ; MATCH06
|
||||
|
||||
; =============
|
||||
; ============= DECOMPRESSION
|
||||
; =============
|
||||
|
||||
%include "n2b_d32.ash"
|
||||
%include "n2d_d32.ash"
|
||||
%include "n2e_d32.ash"
|
||||
;;%include "cl1_d32.ash"
|
||||
|
||||
; =============
|
||||
; ============= UNFILTER
|
||||
; =============
|
||||
|
||||
pop ecx ; MATCH05 len
|
||||
%ifdef __LXCKLLT9__
|
||||
pop edx ; MATCH04 cto
|
||||
pop edi ; MATCH03 src
|
||||
ckt32 edi, dl
|
||||
%endif; __LXDUMMY2__
|
||||
%ifdef __LXCALLT9__
|
||||
pop edi ; MATCH03 src
|
||||
cjt32 0
|
||||
%endif; __LINUX990__
|
||||
pop esi ; MATCH02 restore
|
||||
pop edi ; MATCH01 restore
|
||||
xor ebx, ebx ; booting the 1st cpu
|
||||
retf ; MATCH00 set cs
|
||||
|
||||
%define UNLAP 0x10
|
||||
%define ALIGN (~0<<4)
|
||||
; must have 0==(UNLAP &~ ALIGN)
|
||||
|
||||
move_up:
|
||||
pop esi ; MATCH06 &decompressor
|
||||
mov ecx,[-4+ esi] ; length of decompressor+unfilter
|
||||
mov ebp,eax ; &uncompressed
|
||||
add eax,[esp] ; MATCH05 ULEN + base; entry to decompressor
|
||||
add eax, byte ~ALIGN + UNLAP
|
||||
and eax, byte ALIGN
|
||||
|
||||
std
|
||||
; copy decompressor
|
||||
lea esi,[-1+ ecx + esi] ; unmoved top -1 of decompressor
|
||||
lea edi,[-1+ ecx + eax] ; moved top -1 of decompressor
|
||||
rep
|
||||
movsb
|
||||
|
||||
mov ecx,[-4+ edx] ; length of compressed data
|
||||
add ecx, byte 3
|
||||
shr ecx,2 ; count of .long
|
||||
; copy compressed data
|
||||
lea esi,[-4+ 4*ecx + edx] ; unmoved top -4 of compressed data
|
||||
lea edi,[-4+ eax] ; moved top -4 of compressed data
|
||||
rep
|
||||
movsd
|
||||
|
||||
cld
|
||||
lea esi,[4+ edi] ; &compressed [after move]
|
||||
mov edi,ebp ; &uncompressed
|
||||
or ebp, byte -1 ; decompressor assumption
|
||||
jmp eax ; enter moved decompressor
|
||||
|
||||
; =============
|
||||
; ============= CUT HERE
|
||||
; =============
|
||||
|
||||
%include "header.ash"
|
||||
|
||||
eof:
|
||||
; __LITHEEND__
|
||||
section .data
|
||||
dd -1
|
||||
dw eof
|
||||
|
||||
|
||||
; vi:ts=8:et:nowrap
|
||||
@@ -120,7 +120,7 @@ checka20:
|
||||
pop ecx ; MATCH05 len
|
||||
pop edx ; MATCH04 cto
|
||||
pop edi ; MATCH03 src
|
||||
ckt32 0, dl
|
||||
ckt32 edi, dl
|
||||
%endif; __LZDUMMY2__
|
||||
%ifdef __LZCALLT9__
|
||||
pop edi ; MATCH03 src
|
||||
|
||||
+12
-7
@@ -219,13 +219,14 @@ UiPacker::~UiPacker()
|
||||
|
||||
void UiPacker::printInfo(int nl)
|
||||
{
|
||||
#if 1
|
||||
char method_name[32+1];
|
||||
set_method_name(method_name, sizeof(method_name), p->ph.method, p->ph.level);
|
||||
con_fprintf(stdout, "Compressing %s [%s, %s]%s", p->fi->getName(), p->getName(), method_name, nl ? "\n" : "");
|
||||
#else
|
||||
con_fprintf(stdout, "Compressing %s [%s]%s", p->fi->getName(), p->getName(), nl ? "\n" : "");
|
||||
#endif
|
||||
if (opt->all_methods && s->total_passes > 1)
|
||||
con_fprintf(stdout, "Compressing %s [%s]%s", p->fi->getName(), p->getName(), nl ? "\n" : "");
|
||||
else
|
||||
{
|
||||
char method_name[32+1];
|
||||
set_method_name(method_name, sizeof(method_name), p->ph.method, p->ph.level);
|
||||
con_fprintf(stdout, "Compressing %s [%s, %s]%s", p->fi->getName(), p->getName(), method_name, nl ? "\n" : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -263,7 +264,11 @@ void UiPacker::startCallback(unsigned u_len, unsigned step,
|
||||
return;
|
||||
}
|
||||
|
||||
#if (ACC_CC_MSC && (_MSC_VER == 1300))
|
||||
cb.callback = &UiPacker::callback;
|
||||
#else
|
||||
cb.callback = callback;
|
||||
#endif
|
||||
cb.user = this;
|
||||
|
||||
if (s->mode == M_CB_TERM)
|
||||
|
||||
+4
-7
@@ -35,13 +35,10 @@
|
||||
/* avoid -W4 warnings in <windows.h> */
|
||||
# pragma warning(disable: 4201 4214 4514)
|
||||
#endif
|
||||
#if 0
|
||||
# include "acc/acc_lib.ch"
|
||||
#else
|
||||
# include "acc/acc_inci.h"
|
||||
# include "acc/acclib/misc.ch"
|
||||
# include "acc/acclib/hsread.ch"
|
||||
#endif
|
||||
#include "acc/acc_inci.h"
|
||||
#include "acc/acclib/misc.ch"
|
||||
#include "acc/acclib/hsread.ch"
|
||||
#include "acc/acclib/wildargv.ch"
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
+17
-2
@@ -65,9 +65,24 @@ upx_bytep pfind_le32(const void *b, int blen, unsigned what);
|
||||
#endif
|
||||
|
||||
|
||||
inline ptrdiff_t ptr_diff(const void *p1, const void *p2)
|
||||
#if (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0530))
|
||||
#elif (ACC_CC_DMC && (__DMC__ < 0x830))
|
||||
#elif (ACC_CC_MSC && (_MSC_VER < 1310))
|
||||
#else
|
||||
template <class T>
|
||||
inline int ptr_diff(const T *p1, const T *p2)
|
||||
{
|
||||
return (const char*) p1 - (const char*) p2;
|
||||
COMPILE_TIME_ASSERT(sizeof(T) == 1)
|
||||
ptrdiff_t d = (const char*) p1 - (const char*) p2;
|
||||
assert((int)d == d);
|
||||
return (int) d;
|
||||
}
|
||||
#endif
|
||||
inline int ptr_diff(const void *p1, const void *p2)
|
||||
{
|
||||
ptrdiff_t d = (const char*) p1 - (const char*) p2;
|
||||
assert((int)d == d);
|
||||
return (int) d;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
#define UPX_VERSION_HEX 0x019100 /* 01.91.00 */
|
||||
#define UPX_VERSION_STRING "1.91 beta"
|
||||
#define UPX_VERSION_STRING4 "1.91"
|
||||
#define UPX_VERSION_DATE "Jun 30th 2004"
|
||||
#define UPX_VERSION_HEX 0x019200 /* 01.92.00 */
|
||||
#define UPX_VERSION_STRING "1.92 beta"
|
||||
#define UPX_VERSION_STRING4 "1.92"
|
||||
#define UPX_VERSION_DATE "Jul 20th 2004"
|
||||
|
||||
Reference in New Issue
Block a user