Compare commits
206 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fed3ed9f9a | |||
| 260138ba11 | |||
| 67f7e0089c | |||
| d4a22c7851 | |||
| 06cf986490 | |||
| adf9aa04ce | |||
| 69f66fbe52 | |||
| d061005c89 | |||
| f6ee8b9f04 | |||
| 31af22c2ff | |||
| c421e3f243 | |||
| 6e92902407 | |||
| 6256381dc3 | |||
| b247b051ea | |||
| afbd553622 | |||
| 36bc14e884 | |||
| 9c5d0ff2ff | |||
| cfa6c8ddf6 | |||
| 21924bf022 | |||
| eea33f6019 | |||
| 66d48ae808 | |||
| de9b9fd0b1 | |||
| ece7384be4 | |||
| 0c052e4506 | |||
| 1996a0a3d6 | |||
| 679ad9b8c6 | |||
| d4983731e7 | |||
| 4fec3c8f34 | |||
| 836fd2565f | |||
| 54618064a1 | |||
| 519e3e01ae | |||
| aec8f81358 | |||
| c1d6bf4366 | |||
| 9bf2b79d9e | |||
| 4d98408995 | |||
| 7b466388f9 | |||
| b926fb3c66 | |||
| 6c8d5c0d0e | |||
| 5a1d234260 | |||
| fd6d42c297 | |||
| 7310ad6e92 | |||
| 7e47b1348d | |||
| 1e3555a6b7 | |||
| 9a67ce5968 | |||
| 279d7955f8 | |||
| db977c0bf5 | |||
| ba6bc59818 | |||
| 6e8be0578c | |||
| 92f7d16b5e | |||
| 40bb3c2f5e | |||
| 56a6096221 | |||
| ee37b42a91 | |||
| 0806e61df4 | |||
| 279ffeeefa | |||
| 80c5ee2479 | |||
| 16208544e5 | |||
| 6afeb24fdb | |||
| e6357b81eb | |||
| dfc2efe8a6 | |||
| f28b96f431 | |||
| a10293f8f7 | |||
| b1f02f91d7 | |||
| e76fa45d86 | |||
| 06f43892a5 | |||
| a094332b0d | |||
| 7b8779f534 | |||
| 371bf20d19 | |||
| 0f633ddd15 | |||
| 7886ca7f5f | |||
| 9b4c11954d | |||
| a1b724f30a | |||
| 7c3b2fb9cc | |||
| acef68d67e | |||
| 7e393d5f1e | |||
| 955c31b165 | |||
| e307cd48ad | |||
| 25f8b9e451 | |||
| e8ba14a2c1 | |||
| 9670d3341c | |||
| cec9778fd5 | |||
| 7451db4a68 | |||
| e31777ec53 | |||
| 7aa0b3dc7a | |||
| e7b2d5dc01 | |||
| 47d728667d | |||
| e1f8989d54 | |||
| 1d8cb47830 | |||
| faaa7c37a9 | |||
| 0aff9d8df4 | |||
| 30c3f8c1ac | |||
| bcd2469e01 | |||
| 983c6ae73d | |||
| 6d8e1fe776 | |||
| 99b4921309 | |||
| 3c231c3c9e | |||
| 175c0a6236 | |||
| 0031ceb06c | |||
| e3cc5a63df | |||
| 3cb61402c2 | |||
| 5336c51199 | |||
| 52aa658aaa | |||
| d08a51d7e4 | |||
| d97a557ac3 | |||
| 8a68d9cded | |||
| b031f7e902 | |||
| 963ffecb96 | |||
| 8f8aaca818 | |||
| 801f92b7e7 | |||
| 44db45700e | |||
| 25902005f6 | |||
| ffec71e0d8 | |||
| 99a208110b | |||
| e56799c993 | |||
| 957eb300f8 | |||
| 626025d539 | |||
| 9e8a0a020f | |||
| 40f592eade | |||
| 5e899f0be4 | |||
| f2748284b1 | |||
| a15ce00934 | |||
| 9e3e80261b | |||
| c72c685434 | |||
| 0177a8d277 | |||
| b6a9b0a4c9 | |||
| f4f8bd8d42 | |||
| 6e4aeffc0c | |||
| dba256d384 | |||
| 910008e9e7 | |||
| 8cb9545c41 | |||
| 59c16da6fb | |||
| 630df5bbd2 | |||
| f550111400 | |||
| 77377195aa | |||
| 7e2e72bd40 | |||
| aa7a13bd02 | |||
| 5895058a17 | |||
| ffb60d5149 | |||
| 1e2cb279b0 | |||
| e7f766f5ba | |||
| 8de5aa9409 | |||
| bf28a4df49 | |||
| fe1a0ab371 | |||
| 01daccfaf7 | |||
| 94e861e298 | |||
| d36af2ed5c | |||
| 7104b33214 | |||
| 32998e5377 | |||
| af0c9ef092 | |||
| 3bc3b3d10e | |||
| f03f42ca4d | |||
| 79783abeb1 | |||
| 895b0bd602 | |||
| 2ee5ee92f8 | |||
| 3e619423b1 | |||
| b524e18bdf | |||
| 6aa4579db8 | |||
| 17fb86c0f1 | |||
| 62ecfe4873 | |||
| 04e55e6b9a | |||
| f432aa1090 | |||
| 7add104313 | |||
| 36de249066 | |||
| b7a54dcffd | |||
| 6bb28deab2 | |||
| 7f88d15c86 | |||
| 94c5014e23 | |||
| c5a8256500 | |||
| 5f39884bf7 | |||
| d96825a242 | |||
| 443a938091 | |||
| 6bc3197721 | |||
| 269cc91fd5 | |||
| c1ddea479d | |||
| 5f3a95962c | |||
| ee1a8e6a32 | |||
| eeae73296e | |||
| 4ca8357af4 | |||
| 8a5b8c87fb | |||
| 6ab04d7bbc | |||
| a5a1380636 | |||
| eeab1aef64 | |||
| 4e1c342e55 | |||
| d8ed259bce | |||
| 9f6cb5de4c | |||
| ba634118d7 | |||
| 63da091d36 | |||
| ad0dc88a33 | |||
| 147acf4b57 | |||
| 5085f3a15e | |||
| 22a95ad8ea | |||
| df4bd6a60c | |||
| 813e7b05e4 | |||
| ab8b486b4a | |||
| 590f666ec9 | |||
| 9adaee915b | |||
| bce0f06fe9 | |||
| 856ecb84a0 | |||
| 90ddc06c98 | |||
| 405abc4e95 | |||
| 549c59ecf5 | |||
| 0a485eafcb | |||
| e0c11956a6 | |||
| da6a9bf3eb | |||
| dacd11e1cc | |||
| fc854b4c77 | |||
| 4dcc1f0374 |
@@ -42,7 +42,9 @@ src/*.ttp
|
|||||||
|
|
||||||
stub/**MMakefile
|
stub/**MMakefile
|
||||||
stub/**.*-stamp
|
stub/**.*-stamp
|
||||||
stub/tmp*/*
|
##stub/tmp*/*
|
||||||
|
stub/tmp*/*.{bin,bin.bindump,bin.disasm,d,map,o,o.disasm}
|
||||||
|
stub/tmp*/mips{,el}.r3000-*.{i,s}
|
||||||
stub/**/tmp*/*
|
stub/**/tmp*/*
|
||||||
|
|
||||||
stub/tools/armpe/armpe_tester{,.exe,.out}
|
stub/tools/armpe/armpe_tester{,.exe,.out}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
140415ffbcef86a42b4d672249927364430d3d38 RELEASE_111
|
140415ffbcef86a42b4d672249927364430d3d38 RELEASE_111
|
||||||
|
155618b5b7930f97bd84b82befa7a4fd6672efb3 RELEASE_304
|
||||||
1931f4f28074970ec53b4cd21c7fc181b4da8e5e RELEASE_301
|
1931f4f28074970ec53b4cd21c7fc181b4da8e5e RELEASE_301
|
||||||
223ac5b23f9731ceac9ff8d65167df4900776e36 RELEASE_190
|
223ac5b23f9731ceac9ff8d65167df4900776e36 RELEASE_190
|
||||||
2c753c5bf38e7322715e2a5c6c5381111bd7a61a RELEASE_194
|
2c753c5bf38e7322715e2a5c6c5381111bd7a61a RELEASE_194
|
||||||
@@ -6,6 +7,7 @@
|
|||||||
396983c065fc743cb5b9703e266ca87eeff8a6ee RELEASE_291
|
396983c065fc743cb5b9703e266ca87eeff8a6ee RELEASE_291
|
||||||
46f3a6cca02603000fadc16637b02e30caddd909 RELEASE_302
|
46f3a6cca02603000fadc16637b02e30caddd909 RELEASE_302
|
||||||
70402aeee6e0e4fc2889658ed8cee44461c0b0a8 RELEASE_200
|
70402aeee6e0e4fc2889658ed8cee44461c0b0a8 RELEASE_200
|
||||||
|
7c6747c82b167368344a238b1a3a87c2a4fa6a18 RELEASE_306
|
||||||
95c558f81a0b8d5bb2bede4c8208bb84ae7d1e58 RELEASE_303
|
95c558f81a0b8d5bb2bede4c8208bb84ae7d1e58 RELEASE_303
|
||||||
a1c61174f54aac714f59ac20fcba839d71e64c5c RELEASE_292
|
a1c61174f54aac714f59ac20fcba839d71e64c5c RELEASE_292
|
||||||
a916a2fe22de45167d25abcb40008315f415221c RELEASE_201
|
a916a2fe22de45167d25abcb40008315f415221c RELEASE_201
|
||||||
@@ -13,8 +15,10 @@ a935d577fc7dd9c2c87761c9c702805da6ce1e51 RELEASE_193
|
|||||||
b0353253b0b3d062eb5adb50d4b665a96620da45 RELEASE_195
|
b0353253b0b3d062eb5adb50d4b665a96620da45 RELEASE_195
|
||||||
b82ef51896199484afe5b0553af7d1e59b7ce428 BRANCHPOINT_FOR_upx2.hg
|
b82ef51896199484afe5b0553af7d1e59b7ce428 BRANCHPOINT_FOR_upx2.hg
|
||||||
c2e0cd4d621b047f254f2def42132a03683ff52c RELEASE_192
|
c2e0cd4d621b047f254f2def42132a03683ff52c RELEASE_192
|
||||||
|
c9a983b7da9d4a2311f74366478348412cac2986 RELEASE_305
|
||||||
d276aa09033c24d0981bc3f4fee5628aecc988ad RELEASE_290
|
d276aa09033c24d0981bc3f4fee5628aecc988ad RELEASE_290
|
||||||
eb1ce56dce7dd1835964362470610925963b9043 RELEASE_110
|
eb1ce56dce7dd1835964362470610925963b9043 RELEASE_110
|
||||||
ed96891ef795bceec6b7ff3ca1ca7764431bfb39 RELEASE_191
|
ed96891ef795bceec6b7ff3ca1ca7764431bfb39 RELEASE_191
|
||||||
ef9c7f2c9658d73a9b5ab2ed291483d2bbcd8bc7 RELEASE_300
|
ef9c7f2c9658d73a9b5ab2ed291483d2bbcd8bc7 RELEASE_300
|
||||||
efa52753e366300c0e0ebe20631adcb24ed3c15b RELEASE_293
|
efa52753e366300c0e0ebe20631adcb24ed3c15b RELEASE_293
|
||||||
|
fe7acf61147e7031fcc304aae47ca2352056815d RELEASE_307
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2009 Markus Oberhumer, Laszlo Molnar & John Reiser
|
Copyright (c) 1996-2011 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
http://upx.sourceforge.net
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# UPX toplevel Makefile - needs GNU make 3.81 or better
|
# UPX toplevel Makefile - needs GNU make 3.81 or better
|
||||||
#
|
#
|
||||||
# Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
# Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
#
|
#
|
||||||
|
|
||||||
MAKEFLAGS += -rR
|
MAKEFLAGS += -rR
|
||||||
@@ -38,13 +38,5 @@ endif
|
|||||||
$(MAKE) -C doc $@
|
$(MAKE) -C doc $@
|
||||||
|
|
||||||
|
|
||||||
ifneq ($(wildcard .hg/.),)
|
|
||||||
# automatically generate ChangeLog from local Mercurial repo
|
|
||||||
ChangeLog:
|
|
||||||
hg log --style=changelog > $@
|
|
||||||
.PHONY: ChangeLog
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: default all mostlyclean clean distclean maintainer-clean
|
.PHONY: default all mostlyclean clean distclean maintainer-clean
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,34 @@
|
|||||||
User visible changes for UPX
|
User visible changes for UPX
|
||||||
==================================================================
|
==================================================================
|
||||||
|
|
||||||
|
Changes in 3.08 (12 Dec 2011):
|
||||||
|
* Fix allocation in runtime stub for darwin.macho-entry (i386 and amd64).
|
||||||
|
* Compress shared library on ELF i386 only [ld.so threatens even this case].
|
||||||
|
* Attempt to suport ELF on QNX 6.3.0 for armel (experimental).
|
||||||
|
* Better diangostic when ELF -fPIC is needed.
|
||||||
|
* PT_NOTE improvements for *BSD.
|
||||||
|
* Preserve more ELF .e_flags on ARM.
|
||||||
|
* Minor code improvements for ELF stubs
|
||||||
|
* Defend against another flavor of corrupt PE header.
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
|
Changes in 3.07 (08 Sep 2010):
|
||||||
|
* win32/pe: fixed relocation handling for files with *no* TLS callbacks
|
||||||
|
[severe bug introduced in 3.06]
|
||||||
|
|
||||||
|
Changes in 3.06 (04 Sep 2010):
|
||||||
|
* win32/pe: TLS callback support contributed by Stefan Widmann. Thanks!
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
|
Changes in 3.05 (27 Apr 2010):
|
||||||
|
* i386-linux and amd64-linux support shared libraries (DT_INIT must
|
||||||
|
exist, all info needed by runtime loader must be first in .text, etc.)
|
||||||
|
* Linux /proc/self/exe now is preserved by default, by leaving behind
|
||||||
|
one page. New compress-time option --unmap-all-pages is available.
|
||||||
|
* Withdraw support for shared libraries on Darwin (Apple Mac OS X)
|
||||||
|
because upx does not understand enough about .dylib.
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
Changes in 3.04 (27 Sep 2009):
|
Changes in 3.04 (27 Sep 2009):
|
||||||
* new format Mach/AMD64 supports 64-bit programs on Apple Macintosh.
|
* new format Mach/AMD64 supports 64-bit programs on Apple Macintosh.
|
||||||
* new formats Dylib/i386 and Dylib/ppc32 support shared libraries
|
* new formats Dylib/i386 and Dylib/ppc32 support shared libraries
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2009 Markus Oberhumer, Laszlo Molnar & John Reiser
|
Copyright (c) 1996-2011 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
http://upx.sourceforge.net
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2009 Markus Oberhumer, Laszlo Molnar & John Reiser
|
Copyright (c) 1996-2011 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
http://upx.sourceforge.net
|
||||||
|
|
||||||
|
|
||||||
@@ -108,9 +108,9 @@ THE FUTURE
|
|||||||
COPYRIGHT
|
COPYRIGHT
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
Copyright (C) 2000-2009 John F. Reiser
|
Copyright (C) 2000-2011 John F. Reiser
|
||||||
|
|
||||||
This program may be used freely, and you are welcome to
|
This program may be used freely, and you are welcome to
|
||||||
redistribute it under certain conditions.
|
redistribute it under certain conditions.
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2009 Markus Oberhumer, Laszlo Molnar & John Reiser
|
Copyright (c) 1996-2011 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
http://upx.sourceforge.net
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -98,7 +98,7 @@ If you want to modify the stub sources you'll also need
|
|||||||
|
|
||||||
- A number of cross-assemblers and cross-compilers - precompiled
|
- A number of cross-assemblers and cross-compilers - precompiled
|
||||||
binaries for i386-linux hosts are available from
|
binaries for i386-linux hosts are available from
|
||||||
http://sourceforge.net/project/showfiles.php?group_id=2331
|
http://sourceforge.net/projects/upx/files/upx-tools/20060823/
|
||||||
|
|
||||||
|
|
||||||
Misc. notes
|
Misc. notes
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2009 Markus Oberhumer, Laszlo Molnar & John Reiser
|
Copyright (c) 1996-2011 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
http://upx.sourceforge.net
|
||||||
|
|
||||||
|
|
||||||
@@ -53,6 +53,8 @@ Ralph Roth <RalphRoth@gmx.net>
|
|||||||
for reporting several bugs
|
for reporting several bugs
|
||||||
Salvador Eduardo Tropea
|
Salvador Eduardo Tropea
|
||||||
for beta testing
|
for beta testing
|
||||||
|
Stefan Widmann
|
||||||
|
for the win32/pe TLS callback support
|
||||||
The WINE project (http://www.winehq.com/)
|
The WINE project (http://www.winehq.com/)
|
||||||
for lots of useful information found in their PE loader sources
|
for lots of useful information found in their PE loader sources
|
||||||
Natascha
|
Natascha
|
||||||
|
|||||||
+22
-11
@@ -1,5 +1,5 @@
|
|||||||
Decompressing ELF Directly to Memory on Linux/x86
|
Decompressing ELF Directly to Memory on Linux/x86
|
||||||
Copyright (C) 2000-2009 John F. Reiser jreiser@BitWagon.com
|
Copyright (C) 2000-2011 John F. Reiser jreiser@BitWagon.com
|
||||||
|
|
||||||
References:
|
References:
|
||||||
<elf.h> definitions for the ELF file format
|
<elf.h> definitions for the ELF file format
|
||||||
@@ -64,16 +64,27 @@ assuming that its automatic stack variables are initialized to zero),
|
|||||||
and remove (all but 4 bytes of) the decompression program (and
|
and remove (all but 4 bytes of) the decompression program (and
|
||||||
compressed executable) from the address space.
|
compressed executable) from the address space.
|
||||||
|
|
||||||
Because the UPX runtime stub removes all traces of the compressed file
|
As of upx-3.05, by default on Linux, upon decompression then one page
|
||||||
from the address space, then the Linux kernel erases the symlink
|
of the compressed executable remains mapped into the address space
|
||||||
/proc/self/exe. Linux stores the pathname argument that was specified
|
of the process. If all of the pages of the compressed executable are
|
||||||
to execve() immediately after the '\0' which terminates the character
|
unmapped, then the Linux kernel erases the symlink /proc/self/exe,
|
||||||
string of the last environment variable [as of execve()]. This is true
|
and this can cause trouble for the runtime shared library loader
|
||||||
for at least all Linux 2.6, 2.4, and 2.2 kernels. The pathname is not
|
expanding $ORIGIN in -rpath, or for application code that relies on
|
||||||
"bound" to the file as strongly as /proc/self/exe (the file may be changed
|
/proc/self/exe. Use the compress-time command-line option
|
||||||
without affecting the pathname), but the pathname does provide some
|
--unmap-all-pages to achieve that effect at run time. Upx-3.04
|
||||||
information. The pathname may be relative to the working directory,
|
and previous versions did this by default with no option. However,
|
||||||
so look before any chdir().
|
too much other software erroneously assumes that /proc/self/exe
|
||||||
|
always exists.
|
||||||
|
|
||||||
|
Linux stores the pathname argument that was specified to execve()
|
||||||
|
immediately after the '\0' which terminates the character string of the
|
||||||
|
last environment variable [as of execve()]. This is true for at least
|
||||||
|
all Linux 2.6, 2.4, and 2.2 kernels. Linux kernel 2.6.29 and later
|
||||||
|
records a pointer to that character string in Elf32_auxv[AT_EXECFN].
|
||||||
|
The pathname is not "bound" to the file as strongly as /proc/self/exe
|
||||||
|
(the file may be changed without affecting the pathname), but the
|
||||||
|
pathname does provide some information. The pathname may be relative
|
||||||
|
to the working directory, so look before any chdir().
|
||||||
|
|
||||||
The Elf formats for Linux add an environment variable named " " [three
|
The Elf formats for Linux add an environment variable named " " [three
|
||||||
spaces] which saves the results of readlink("/proc/self/exe",,) before
|
spaces] which saves the results of readlink("/proc/self/exe",,) before
|
||||||
|
|||||||
+5
-5
@@ -13,7 +13,7 @@ B<upx> S<[ I<command> ]> S<[ I<options> ]> I<filename>...
|
|||||||
=head1 ABSTRACT
|
=head1 ABSTRACT
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2009 Markus Oberhumer, Laszlo Molnar & John Reiser
|
Copyright (c) 1996-2011 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
http://upx.sourceforge.net
|
||||||
|
|
||||||
|
|
||||||
@@ -933,13 +933,13 @@ Please report all bugs immediately to the authors.
|
|||||||
|
|
||||||
=head1 COPYRIGHT
|
=head1 COPYRIGHT
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
|
|
||||||
Copyright (C) 2000-2009 John F. Reiser
|
Copyright (C) 2000-2011 John F. Reiser
|
||||||
|
|
||||||
Copyright (C) 2002-2009 Jens Medoch
|
Copyright (C) 2002-2011 Jens Medoch
|
||||||
|
|
||||||
This program may be used freely, and you are welcome to
|
This program may be used freely, and you are welcome to
|
||||||
redistribute it under certain conditions.
|
redistribute it under certain conditions.
|
||||||
|
|||||||
+6
-5
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# UPX Makefile - needs GNU make 3.81 or better
|
# UPX Makefile - needs GNU make 3.81 or better
|
||||||
#
|
#
|
||||||
# Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
# Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
#
|
#
|
||||||
|
|
||||||
MAKEFLAGS += -rR
|
MAKEFLAGS += -rR
|
||||||
@@ -38,8 +38,9 @@ CXXFLAGS += -O0 -g
|
|||||||
else
|
else
|
||||||
CXXFLAGS += -O2
|
CXXFLAGS += -O2
|
||||||
endif
|
endif
|
||||||
CXXFLAGS += -Wall -W -Wcast-align -Wcast-qual -Wpointer-arith -Wwrite-strings -Werror
|
CXXFLAGS_WERROR = -Werror
|
||||||
##CXXFLAGS += -Wshadow
|
CXXFLAGS += -Wall -W -Wcast-align -Wcast-qual -Wpointer-arith -Wshadow -Wwrite-strings
|
||||||
|
CXXFLAGS += $(CXXFLAGS_WERROR)
|
||||||
endif
|
endif
|
||||||
CPPFLAGS += $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
|
CPPFLAGS += $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
|
||||||
CXXLD ?= $(CXX)
|
CXXLD ?= $(CXX)
|
||||||
@@ -48,7 +49,7 @@ exeext ?= .out
|
|||||||
libext ?= .a
|
libext ?= .a
|
||||||
objext ?= .o
|
objext ?= .o
|
||||||
|
|
||||||
upx_SOURCES := $(wildcard $(srcdir)/*.cpp)
|
upx_SOURCES := $(sort $(wildcard $(srcdir)/*.cpp))
|
||||||
upx_OBJECTS := $(notdir $(upx_SOURCES:.cpp=$(objext)))
|
upx_OBJECTS := $(notdir $(upx_SOURCES:.cpp=$(objext)))
|
||||||
|
|
||||||
# we need UCL and zlib - you can set envvar UPX_UCLDIR
|
# we need UCL and zlib - you can set envvar UPX_UCLDIR
|
||||||
@@ -76,7 +77,7 @@ upx$(exeext): $(upx_OBJECTS) $(upx_DEPENDENCIES)
|
|||||||
%.o : %.cpp | .depend
|
%.o : %.cpp | .depend
|
||||||
$(strip $(CXX) $(call e,CPPFLAGS) $(call e,CXXFLAGS) -o $@ -c $<)
|
$(strip $(CXX) $(call e,CPPFLAGS) $(call e,CXXFLAGS) -o $@ -c $<)
|
||||||
|
|
||||||
.depend: $(wildcard $(srcdir)/*.cpp $(srcdir)/*.h) $(MAKEFILE_LIST)
|
.depend: $(sort $(wildcard $(srcdir)/*.cpp $(srcdir)/*.h)) $(MAKEFILE_LIST)
|
||||||
@rm -f $@
|
@rm -f $@
|
||||||
ifeq ($(USE_GNUC),1)
|
ifeq ($(USE_GNUC),1)
|
||||||
@echo "Updating $@"
|
@echo "Updating $@"
|
||||||
|
|||||||
+7
-7
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_BELE_H
|
#ifndef __UPX_BELE_H
|
||||||
#define __UPX_BELE_H
|
#define __UPX_BELE_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -543,7 +543,7 @@ int __acc_cdecl_qsort le64_compare_signed(const void *, const void *);
|
|||||||
|
|
||||||
|
|
||||||
// just for testing...
|
// just for testing...
|
||||||
#if !defined(ACC_CFG_NO_UNALIGNED)
|
#if !(ACC_CFG_NO_UNALIGNED)
|
||||||
#if 0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_CC_GNUC >= 0x030200)
|
#if 0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_CC_GNUC >= 0x030200)
|
||||||
typedef acc_uint16e_t LE16_unaligned __attribute__((__aligned__(1)));
|
typedef acc_uint16e_t LE16_unaligned __attribute__((__aligned__(1)));
|
||||||
typedef acc_uint32e_t LE32_unaligned __attribute__((__aligned__(1)));
|
typedef acc_uint32e_t LE32_unaligned __attribute__((__aligned__(1)));
|
||||||
@@ -587,13 +587,13 @@ int __acc_cdecl_qsort le64_compare_signed(const void *, const void *);
|
|||||||
|
|
||||||
// forward declarations
|
// forward declarations
|
||||||
namespace N_BELE_CTP {
|
namespace N_BELE_CTP {
|
||||||
class BEPolicy; class LEPolicy;
|
struct BEPolicy; struct LEPolicy;
|
||||||
extern const BEPolicy be_policy;
|
extern const BEPolicy be_policy;
|
||||||
extern const LEPolicy le_policy;
|
extern const LEPolicy le_policy;
|
||||||
}
|
}
|
||||||
namespace N_BELE_RTP {
|
namespace N_BELE_RTP {
|
||||||
class AbstractPolicy;
|
struct AbstractPolicy;
|
||||||
class BEPolicy; class LEPolicy;
|
struct BEPolicy; struct LEPolicy;
|
||||||
extern const BEPolicy be_policy;
|
extern const BEPolicy be_policy;
|
||||||
extern const LEPolicy le_policy;
|
extern const LEPolicy le_policy;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
// CTP - Compile-Time Polymorphism (templates)
|
// CTP - Compile-Time Polymorphism (templates)
|
||||||
# define V static inline
|
# define V static inline
|
||||||
# define S static int __acc_cdecl_qsort
|
# define S static int __acc_cdecl_qsort
|
||||||
# define C
|
# define C /*empty*/
|
||||||
#elif defined(BELE_RTP)
|
#elif defined(BELE_RTP)
|
||||||
// RTP - Run-Time Polymorphism (virtual functions)
|
// RTP - Run-Time Polymorphism (virtual functions)
|
||||||
# define V virtual
|
# define V virtual
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_BPTR_H
|
#ifndef __UPX_BPTR_H
|
||||||
#define __UPX_BPTR_H
|
#define __UPX_BPTR_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
|
||||||
#if defined(USE_CONSOLE)
|
#if (USE_CONSOLE)
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
//
|
//
|
||||||
|
|||||||
+6
-6
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
FILE *con_term = NULL;
|
FILE *con_term = NULL;
|
||||||
|
|
||||||
#if defined(USE_CONSOLE)
|
#if (USE_CONSOLE)
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
//
|
//
|
||||||
@@ -84,14 +84,14 @@ static int do_init(FILE *f)
|
|||||||
if (!acc_isatty(STDIN_FILENO) || !acc_isatty(STDOUT_FILENO) || !acc_isatty(STDERR_FILENO))
|
if (!acc_isatty(STDIN_FILENO) || !acc_isatty(STDOUT_FILENO) || !acc_isatty(STDERR_FILENO))
|
||||||
return con_mode;
|
return con_mode;
|
||||||
|
|
||||||
#if defined(USE_ANSI)
|
#if (USE_ANSI)
|
||||||
try_init(&console_ansi_mono,f);
|
try_init(&console_ansi_mono,f);
|
||||||
try_init(&console_ansi_color,f);
|
try_init(&console_ansi_color,f);
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_SCREEN)
|
#if (USE_SCREEN)
|
||||||
try_init(&console_screen,f);
|
try_init(&console_screen,f);
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_AALIB)
|
#if (USE_AALIB)
|
||||||
try_init(&console_aalib,f);
|
try_init(&console_aalib,f);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
|
||||||
#if defined(USE_CONSOLE)
|
#if (USE_CONSOLE)
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
//
|
//
|
||||||
|
|||||||
+7
-7
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
|
||||||
#if defined(USE_SCREEN)
|
#if (USE_SCREEN)
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
@@ -130,15 +130,15 @@ static int init(FILE *f, int o, int now)
|
|||||||
if (!screen)
|
if (!screen)
|
||||||
screen = do_construct(screen_djgpp2_construct(),fd);
|
screen = do_construct(screen_djgpp2_construct(),fd);
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_SCREEN_WIN32)
|
#if (USE_SCREEN_WIN32)
|
||||||
if (!screen)
|
if (!screen)
|
||||||
screen = do_construct(screen_win32_construct(),fd);
|
screen = do_construct(screen_win32_construct(),fd);
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_SCREEN_VCSA)
|
#if (USE_SCREEN_VCSA)
|
||||||
if (!screen)
|
if (!screen)
|
||||||
screen = do_construct(screen_vcsa_construct(),fd);
|
screen = do_construct(screen_vcsa_construct(),fd);
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_SCREEN_CURSES)
|
#if (USE_SCREEN_CURSES)
|
||||||
if (!screen && o == CON_SCREEN)
|
if (!screen && o == CON_SCREEN)
|
||||||
screen = do_construct(screen_curses_construct(),fd);
|
screen = do_construct(screen_curses_construct(),fd);
|
||||||
#endif
|
#endif
|
||||||
@@ -298,7 +298,7 @@ static void print0(FILE *f, const char *ss)
|
|||||||
static bool intro(FILE *f)
|
static bool intro(FILE *f)
|
||||||
{
|
{
|
||||||
UNUSED(f);
|
UNUSED(f);
|
||||||
#if defined(USE_FRAMES)
|
#if (USE_FRAMES)
|
||||||
if (screen->intro)
|
if (screen->intro)
|
||||||
return screen->intro(screen,screen_show_frames);
|
return screen->intro(screen,screen_show_frames);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+14
-14
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -43,7 +43,7 @@ unsigned upx_adler32(const void *buf, unsigned len, unsigned adler)
|
|||||||
assert(buf != NULL);
|
assert(buf != NULL);
|
||||||
#if 0
|
#if 0
|
||||||
return adler32(adler, (const Bytef *) buf, len); // zlib
|
return adler32(adler, (const Bytef *) buf, len); // zlib
|
||||||
#elif defined(WITH_UCL)
|
#elif (WITH_UCL)
|
||||||
return ucl_adler32(adler, (const ucl_bytep) buf, len);
|
return ucl_adler32(adler, (const ucl_bytep) buf, len);
|
||||||
#else
|
#else
|
||||||
# error
|
# error
|
||||||
@@ -59,7 +59,7 @@ unsigned upx_crc32(const void *buf, unsigned len, unsigned crc)
|
|||||||
assert(buf != NULL);
|
assert(buf != NULL);
|
||||||
#if 0
|
#if 0
|
||||||
return crc32(crc, (const Bytef *) buf, len); // zlib
|
return crc32(crc, (const Bytef *) buf, len); // zlib
|
||||||
#elif defined(WITH_UCL)
|
#elif (WITH_UCL)
|
||||||
return ucl_crc32(crc, (const ucl_bytep) buf, len);
|
return ucl_crc32(crc, (const ucl_bytep) buf, len);
|
||||||
#else
|
#else
|
||||||
# error
|
# error
|
||||||
@@ -108,17 +108,17 @@ int upx_compress ( const upx_bytep src, unsigned src_len,
|
|||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
}
|
}
|
||||||
#if defined(WITH_LZMA)
|
#if (WITH_LZMA)
|
||||||
else if (M_IS_LZMA(method))
|
else if (M_IS_LZMA(method))
|
||||||
r = upx_lzma_compress(src, src_len, dst, dst_len,
|
r = upx_lzma_compress(src, src_len, dst, dst_len,
|
||||||
cb, method, level, cconf, cresult);
|
cb, method, level, cconf, cresult);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_NRV)
|
#if (WITH_NRV)
|
||||||
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
||||||
r = upx_nrv_compress(src, src_len, dst, dst_len,
|
r = upx_nrv_compress(src, src_len, dst, dst_len,
|
||||||
cb, method, level, cconf, cresult);
|
cb, method, level, cconf, cresult);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_UCL)
|
#if (WITH_UCL)
|
||||||
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
||||||
r = upx_ucl_compress(src, src_len, dst, dst_len,
|
r = upx_ucl_compress(src, src_len, dst, dst_len,
|
||||||
cb, method, level, cconf, cresult);
|
cb, method, level, cconf, cresult);
|
||||||
@@ -154,19 +154,19 @@ int upx_decompress ( const upx_bytep src, unsigned src_len,
|
|||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
}
|
}
|
||||||
#if defined(WITH_LZMA)
|
#if (WITH_LZMA)
|
||||||
else if (M_IS_LZMA(method))
|
else if (M_IS_LZMA(method))
|
||||||
r = upx_lzma_decompress(src, src_len, dst, dst_len, method, cresult);
|
r = upx_lzma_decompress(src, src_len, dst, dst_len, method, cresult);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_NRV)
|
#if (WITH_NRV)
|
||||||
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
||||||
r = upx_nrv_decompress(src, src_len, dst, dst_len, method, cresult);
|
r = upx_nrv_decompress(src, src_len, dst, dst_len, method, cresult);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_UCL)
|
#if (WITH_UCL)
|
||||||
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
||||||
r = upx_ucl_decompress(src, src_len, dst, dst_len, method, cresult);
|
r = upx_ucl_decompress(src, src_len, dst, dst_len, method, cresult);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_ZLIB)
|
#if (WITH_ZLIB)
|
||||||
else if (M_IS_DEFLATE(method))
|
else if (M_IS_DEFLATE(method))
|
||||||
r = upx_zlib_decompress(src, src_len, dst, dst_len, method, cresult);
|
r = upx_zlib_decompress(src, src_len, dst, dst_len, method, cresult);
|
||||||
#endif
|
#endif
|
||||||
@@ -201,15 +201,15 @@ int upx_test_overlap ( const upx_bytep buf,
|
|||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
}
|
}
|
||||||
#if defined(WITH_LZMA)
|
#if (WITH_LZMA)
|
||||||
else if (M_IS_LZMA(method))
|
else if (M_IS_LZMA(method))
|
||||||
r = upx_lzma_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
|
r = upx_lzma_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_NRV)
|
#if (WITH_NRV)
|
||||||
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
||||||
r = upx_nrv_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
|
r = upx_nrv_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_UCL)
|
#if (WITH_UCL)
|
||||||
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
||||||
r = upx_ucl_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
|
r = upx_ucl_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+8
-7
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,14 +27,14 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_COMPRESS_H
|
#ifndef __UPX_COMPRESS_H
|
||||||
#define __UPX_COMPRESS_H
|
#define __UPX_COMPRESS_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#if defined(WITH_LZMA)
|
#if (WITH_LZMA)
|
||||||
const char *upx_lzma_version_string(void);
|
const char *upx_lzma_version_string(void);
|
||||||
int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
||||||
upx_bytep dst, unsigned* dst_len,
|
upx_bytep dst, unsigned* dst_len,
|
||||||
@@ -55,7 +55,7 @@ int upx_lzma_test_overlap ( const upx_bytep buf,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(WITH_NRV)
|
#if (WITH_NRV)
|
||||||
const char *upx_nrv_version_string(void);
|
const char *upx_nrv_version_string(void);
|
||||||
int upx_nrv_compress ( const upx_bytep src, unsigned src_len,
|
int upx_nrv_compress ( const upx_bytep src, unsigned src_len,
|
||||||
upx_bytep dst, unsigned* dst_len,
|
upx_bytep dst, unsigned* dst_len,
|
||||||
@@ -76,7 +76,7 @@ int upx_nrv_test_overlap ( const upx_bytep buf,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(WITH_UCL)
|
#if (WITH_UCL)
|
||||||
const char *upx_ucl_version_string(void);
|
const char *upx_ucl_version_string(void);
|
||||||
int upx_ucl_compress ( const upx_bytep src, unsigned src_len,
|
int upx_ucl_compress ( const upx_bytep src, unsigned src_len,
|
||||||
upx_bytep dst, unsigned* dst_len,
|
upx_bytep dst, unsigned* dst_len,
|
||||||
@@ -96,7 +96,8 @@ int upx_ucl_test_overlap ( const upx_bytep buf,
|
|||||||
const upx_compress_result_t *cresult );
|
const upx_compress_result_t *cresult );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WITH_ZLIB)
|
|
||||||
|
#if (WITH_ZLIB)
|
||||||
const char *upx_zlib_version_string(void);
|
const char *upx_zlib_version_string(void);
|
||||||
int upx_zlib_compress ( const upx_bytep src, unsigned src_len,
|
int upx_zlib_compress ( const upx_bytep src, unsigned src_len,
|
||||||
upx_bytep dst, unsigned* dst_len,
|
upx_bytep dst, unsigned* dst_len,
|
||||||
|
|||||||
+12
-11
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -47,10 +47,11 @@ void lzma_compress_config_t::reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if !defined(WITH_LZMA)
|
#if !(WITH_LZMA)
|
||||||
extern int compress_lzma_dummy;
|
extern int compress_lzma_dummy;
|
||||||
int compress_lzma_dummy = 0;
|
int compress_lzma_dummy = 0;
|
||||||
#else
|
#else
|
||||||
|
#define opt compress_lzma_opt
|
||||||
|
|
||||||
#undef USE_LZMA_PROPERTIES
|
#undef USE_LZMA_PROPERTIES
|
||||||
|
|
||||||
@@ -290,7 +291,7 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
|||||||
unsigned char props_buf[LZMA_PROPS_SIZE];
|
unsigned char props_buf[LZMA_PROPS_SIZE];
|
||||||
SizeT props_buf_size; props_buf_size = LZMA_PROPS_SIZE;
|
SizeT props_buf_size; props_buf_size = LZMA_PROPS_SIZE;
|
||||||
|
|
||||||
#if defined(USE_LZMA_PROPERTIES)
|
#if (USE_LZMA_PROPERTIES)
|
||||||
if (dst_avail < 1)
|
if (dst_avail < 1)
|
||||||
goto error;
|
goto error;
|
||||||
dst[0] = 0; // filled below
|
dst[0] = 0; // filled below
|
||||||
@@ -311,8 +312,8 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
|||||||
assert(x_len <= dst_avail);
|
assert(x_len <= dst_avail);
|
||||||
*dst_len += x_len;
|
*dst_len += x_len;
|
||||||
if (rh == SZ_OK) {
|
if (rh == SZ_OK) {
|
||||||
#if defined(USE_LZMA_PROPERTIES)
|
#if (USE_LZMA_PROPERTIES)
|
||||||
dst[-1] = probs_buf[0];
|
dst[-1] = props_buf[0];
|
||||||
#endif
|
#endif
|
||||||
r = UPX_E_OK;
|
r = UPX_E_OK;
|
||||||
}
|
}
|
||||||
@@ -512,7 +513,7 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
assert(os.b_pos == 5);
|
assert(os.b_pos == 5);
|
||||||
#if defined(USE_LZMA_PROPERTIES)
|
#if (USE_LZMA_PROPERTIES)
|
||||||
os.b_pos = 1;
|
os.b_pos = 1;
|
||||||
#else
|
#else
|
||||||
os.b_pos = 0;
|
os.b_pos = 0;
|
||||||
@@ -545,7 +546,7 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
|||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
*dst_len = os.b_pos;
|
*dst_len = (unsigned) os.b_pos;
|
||||||
//printf("\nlzma_compress: %d: %u %u %u %u %u, %u - > %u\n", r, res->pos_bits, res->lit_pos_bits, res->lit_context_bits, res->dict_size, res->num_probs, src_len, *dst_len);
|
//printf("\nlzma_compress: %d: %u %u %u %u %u, %u - > %u\n", r, res->pos_bits, res->lit_pos_bits, res->lit_context_bits, res->dict_size, res->num_probs, src_len, *dst_len);
|
||||||
//printf("%u %u %u\n", is.__m_RefCount, os.__m_RefCount, progress.__m_RefCount);
|
//printf("%u %u %u\n", is.__m_RefCount, os.__m_RefCount, progress.__m_RefCount);
|
||||||
return r;
|
return r;
|
||||||
@@ -585,7 +586,7 @@ int upx_lzma_decompress ( const upx_bytep src, unsigned src_len,
|
|||||||
SRes rh;
|
SRes rh;
|
||||||
ELzmaStatus status;
|
ELzmaStatus status;
|
||||||
|
|
||||||
#if defined(USE_LZMA_PROPERTIES)
|
#if (USE_LZMA_PROPERTIES)
|
||||||
rh = LzmaProps_Decode(&s.Properties, src, src_len);
|
rh = LzmaProps_Decode(&s.Properties, src, src_len);
|
||||||
if (rh != 0)
|
if (rh != 0)
|
||||||
goto error;
|
goto error;
|
||||||
@@ -640,7 +641,7 @@ int upx_lzma_decompress ( const upx_bytep src, unsigned src_len,
|
|||||||
}
|
}
|
||||||
error:
|
error:
|
||||||
*dst_len = s.dicPos;
|
*dst_len = s.dicPos;
|
||||||
// LzmaDec_Free(&s, &cba); // FIXME - why does this crash ???
|
LzmaDec_FreeProbs(&s, &cba);
|
||||||
return r;
|
return r;
|
||||||
#undef Properties
|
#undef Properties
|
||||||
}
|
}
|
||||||
@@ -683,7 +684,7 @@ int upx_lzma_decompress ( const upx_bytep src, unsigned src_len,
|
|||||||
int r = UPX_E_ERROR;
|
int r = UPX_E_ERROR;
|
||||||
int rh;
|
int rh;
|
||||||
|
|
||||||
#if defined(USE_LZMA_PROPERTIES)
|
#if (USE_LZMA_PROPERTIES)
|
||||||
if (src_len < 2)
|
if (src_len < 2)
|
||||||
goto error;
|
goto error;
|
||||||
rh = LzmaDecodeProperties(&s.Properties, src, src_len);
|
rh = LzmaDecodeProperties(&s.Properties, src, src_len);
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -28,23 +28,23 @@
|
|||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "compress.h"
|
#include "compress.h"
|
||||||
#if !defined(WITH_UCL)
|
#if !(WITH_UCL)
|
||||||
extern int compress_ucl_dummy;
|
extern int compress_ucl_dummy;
|
||||||
int compress_ucl_dummy = 0;
|
int compress_ucl_dummy = 0;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#if 1 && !defined(UCL_USE_ASM) && (ACC_ARCH_I386)
|
#if 1 && !(UCL_USE_ASM) && (ACC_ARCH_I386)
|
||||||
# if (ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_WATCOMC)
|
# if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_WATCOMC)
|
||||||
# define UCL_USE_ASM
|
# define UCL_USE_ASM 1
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(UCL_NO_ASM)
|
#if (UCL_NO_ASM)
|
||||||
# undef UCL_USE_ASM
|
# undef UCL_USE_ASM
|
||||||
#endif
|
#endif
|
||||||
#if defined(ACC_CFG_NO_UNALIGNED)
|
#if (ACC_CFG_NO_UNALIGNED)
|
||||||
# undef UCL_USE_ASM
|
# undef UCL_USE_ASM
|
||||||
#endif
|
#endif
|
||||||
#if 1 && defined(UCL_USE_ASM)
|
#if 1 && (UCL_USE_ASM)
|
||||||
# include <ucl/ucl_asm.h>
|
# include <ucl/ucl_asm.h>
|
||||||
# define ucl_nrv2b_decompress_safe_8 ucl_nrv2b_decompress_asm_safe_8
|
# define ucl_nrv2b_decompress_safe_8 ucl_nrv2b_decompress_asm_safe_8
|
||||||
# define ucl_nrv2b_decompress_safe_le16 ucl_nrv2b_decompress_asm_safe_le16
|
# define ucl_nrv2b_decompress_safe_le16 ucl_nrv2b_decompress_asm_safe_le16
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -41,7 +41,7 @@ void zlib_compress_config_t::reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if !defined(WITH_ZLIB)
|
#if !(WITH_ZLIB)
|
||||||
extern int compress_zlib_dummy;
|
extern int compress_zlib_dummy;
|
||||||
int compress_zlib_dummy = 0;
|
int compress_zlib_dummy = 0;
|
||||||
#else
|
#else
|
||||||
|
|||||||
+34
-20
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_CONF_H
|
#ifndef __UPX_CONF_H
|
||||||
#define __UPX_CONF_H
|
#define __UPX_CONF_H 1
|
||||||
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
@@ -36,6 +36,21 @@
|
|||||||
// ACC
|
// ACC
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
#if (defined(_WIN32) || defined(_WIN64)) && defined(_MSC_VER)
|
||||||
|
#ifndef _CRT_NONSTDC_NO_DEPRECATE
|
||||||
|
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
||||||
|
#endif
|
||||||
|
#ifndef _CRT_NONSTDC_NO_WARNINGS
|
||||||
|
#define _CRT_NONSTDC_NO_WARNINGS 1
|
||||||
|
#endif
|
||||||
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||||
|
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||||
|
#endif
|
||||||
|
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "miniacc.h"
|
#include "miniacc.h"
|
||||||
#if ((ACC_OS_WIN32 || ACC_OS_WIN64) && ACC_CC_MWERKS) && defined(__MSL__)
|
#if ((ACC_OS_WIN32 || ACC_OS_WIN64) && ACC_CC_MWERKS) && defined(__MSL__)
|
||||||
# undef HAVE_UTIME_H /* this pulls in <windows.h> */
|
# undef HAVE_UTIME_H /* this pulls in <windows.h> */
|
||||||
@@ -93,6 +108,7 @@
|
|||||||
# error "need Visual C++ 5.0 or newer"
|
# error "need Visual C++ 5.0 or newer"
|
||||||
# endif
|
# endif
|
||||||
# pragma warning(error: 4096) // W2: '__cdecl' must be used with '...'
|
# pragma warning(error: 4096) // W2: '__cdecl' must be used with '...'
|
||||||
|
# pragma warning(error: 4138) // Wx: '*/' found outside of comment
|
||||||
# pragma warning(disable: 4097) // W3: typedef-name 'A' used as synonym for class-name 'B'
|
# pragma warning(disable: 4097) // W3: typedef-name 'A' used as synonym for class-name 'B'
|
||||||
# pragma warning(disable: 4511) // W3: 'class': copy constructor could not be generated
|
# pragma warning(disable: 4511) // W3: 'class': copy constructor could not be generated
|
||||||
# pragma warning(disable: 4512) // W4: 'class': assignment operator could not be generated
|
# pragma warning(disable: 4512) // W4: 'class': assignment operator could not be generated
|
||||||
@@ -143,15 +159,18 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// just in case
|
// just in case
|
||||||
|
#undef _
|
||||||
|
#undef __
|
||||||
|
#undef ___
|
||||||
#undef NDEBUG
|
#undef NDEBUG
|
||||||
#undef dos
|
#undef dos
|
||||||
#undef linux
|
#undef linux
|
||||||
#undef small
|
#undef small
|
||||||
#undef tos
|
#undef tos
|
||||||
#if defined(ACC_CC_DMC)
|
#if (ACC_CC_DMC)
|
||||||
# undef tell
|
# undef tell
|
||||||
#endif
|
#endif
|
||||||
#if !defined(ACC_CC_PGI)
|
#if !(ACC_CC_PGI)
|
||||||
# undef unix
|
# undef unix
|
||||||
#endif
|
#endif
|
||||||
#if defined(__DJGPP__)
|
#if defined(__DJGPP__)
|
||||||
@@ -170,14 +189,14 @@
|
|||||||
# undef WITH_LZMA
|
# undef WITH_LZMA
|
||||||
#endif
|
#endif
|
||||||
#if defined(UPX_OFFICIAL_BUILD)
|
#if defined(UPX_OFFICIAL_BUILD)
|
||||||
# if !defined(WITH_LZMA) || !defined(WITH_NRV) || !defined(WITH_UCL)
|
# if !(WITH_LZMA) || !(WITH_NRV) || !(WITH_UCL)
|
||||||
# error
|
# error
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_NRV)
|
#if (WITH_NRV)
|
||||||
# include <nrv/nrvconf.h>
|
# include <nrv/nrvconf.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_UCL)
|
#if (WITH_UCL)
|
||||||
# define ucl_compress_config_t REAL_ucl_compress_config_t
|
# define ucl_compress_config_t REAL_ucl_compress_config_t
|
||||||
# include <ucl/uclconf.h>
|
# include <ucl/uclconf.h>
|
||||||
# include <ucl/ucl.h>
|
# include <ucl/ucl.h>
|
||||||
@@ -187,11 +206,6 @@
|
|||||||
# undef ucl_compress_config_t
|
# undef ucl_compress_config_t
|
||||||
# undef ucl_compress_config_p
|
# undef ucl_compress_config_p
|
||||||
#endif
|
#endif
|
||||||
#if !defined(__UPX_CHECKER)
|
|
||||||
# if defined(__UCL_CHECKER) || defined(__NRV_CHECKER)
|
|
||||||
# define __UPX_CHECKER
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if !defined(UINT_MAX) || (UINT_MAX < 0xffffffffL)
|
#if !defined(UINT_MAX) || (UINT_MAX < 0xffffffffL)
|
||||||
# error "UINT_MAX"
|
# error "UINT_MAX"
|
||||||
#endif
|
#endif
|
||||||
@@ -205,7 +219,7 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
// malloc debuggers
|
// malloc debuggers
|
||||||
#if defined(WITH_VALGRIND)
|
#if (WITH_VALGRIND)
|
||||||
# include <valgrind/memcheck.h>
|
# include <valgrind/memcheck.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -244,10 +258,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if !defined(HAVE_STRCASECMP) && defined(HAVE_STRICMP)
|
#if !(HAVE_STRCASECMP) && (HAVE_STRICMP)
|
||||||
# define strcasecmp stricmp
|
# define strcasecmp stricmp
|
||||||
#endif
|
#endif
|
||||||
#if !defined(HAVE_STRNCASECMP) && defined(HAVE_STRNICMP)
|
#if !(HAVE_STRNCASECMP) && (HAVE_STRNICMP)
|
||||||
# define strncasecmp strnicmp
|
# define strncasecmp strnicmp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -312,7 +326,7 @@
|
|||||||
|
|
||||||
#if (ACC_CC_INTELC && (__INTEL_COMPILER < 800))
|
#if (ACC_CC_INTELC && (__INTEL_COMPILER < 800))
|
||||||
#elif (0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386))
|
#elif (0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386))
|
||||||
#elif (ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE)
|
#elif (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE)
|
||||||
# define __packed_struct(s) struct s {
|
# define __packed_struct(s) struct s {
|
||||||
# define __packed_struct_end() } __attribute__((__packed__,__aligned__(1)));
|
# define __packed_struct_end() } __attribute__((__packed__,__aligned__(1)));
|
||||||
#elif (ACC_CC_WATCOMC)
|
#elif (ACC_CC_WATCOMC)
|
||||||
@@ -738,7 +752,7 @@ typedef ElfLinker Linker;
|
|||||||
// main.cpp
|
// main.cpp
|
||||||
extern const char *progname;
|
extern const char *progname;
|
||||||
bool set_ec(int ec);
|
bool set_ec(int ec);
|
||||||
#if (ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
#if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
void e_exit(int ec) __attribute__((__noreturn__));
|
void e_exit(int ec) __attribute__((__noreturn__));
|
||||||
#else
|
#else
|
||||||
void e_exit(int ec);
|
void e_exit(int ec);
|
||||||
@@ -750,7 +764,7 @@ void printSetNl(int need_nl);
|
|||||||
void printClearLine(FILE *f = NULL);
|
void printClearLine(FILE *f = NULL);
|
||||||
void printErr(const char *iname, const Throwable *e);
|
void printErr(const char *iname, const Throwable *e);
|
||||||
void printUnhandledException(const char *iname, const std::exception *e);
|
void printUnhandledException(const char *iname, const std::exception *e);
|
||||||
#if (ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
#if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
void __acc_cdecl_va printErr(const char *iname, const char *format, ...)
|
void __acc_cdecl_va printErr(const char *iname, const char *format, ...)
|
||||||
__attribute__((__format__(__printf__,2,3)));
|
__attribute__((__format__(__printf__,2,3)));
|
||||||
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...)
|
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...)
|
||||||
@@ -760,7 +774,7 @@ void __acc_cdecl_va printErr(const char *iname, const char *format, ...);
|
|||||||
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...);
|
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
#if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
void __acc_cdecl_va infoWarning(const char *format, ...)
|
void __acc_cdecl_va infoWarning(const char *format, ...)
|
||||||
__attribute__((__format__(__printf__,1,2)));
|
__attribute__((__format__(__printf__,1,2)));
|
||||||
void __acc_cdecl_va infoHeader(const char *format, ...)
|
void __acc_cdecl_va infoHeader(const char *format, ...)
|
||||||
|
|||||||
+21
-21
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -39,41 +39,41 @@
|
|||||||
#undef USE_SCREEN_WIN32
|
#undef USE_SCREEN_WIN32
|
||||||
#undef USE_FRAMES
|
#undef USE_FRAMES
|
||||||
|
|
||||||
#if defined(WITH_GUI) && !defined(NO_CONSOLE)
|
#if 1 && (WITH_GUI) && !defined(NO_CONSOLE)
|
||||||
# define NO_CONSOLE
|
# define NO_CONSOLE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1 && defined(__linux__)
|
#if 1 && defined(__linux__)
|
||||||
# define USE_SCREEN
|
# define USE_SCREEN 1
|
||||||
# define USE_SCREEN_VCSA
|
# define USE_SCREEN_VCSA 1
|
||||||
# if !defined(HAVE_LINUX_KD_H)
|
# if !(HAVE_LINUX_KD_H)
|
||||||
# undef USE_SCREEN
|
# undef USE_SCREEN
|
||||||
# undef USE_SCREEN_VCSA
|
# undef USE_SCREEN_VCSA
|
||||||
# endif
|
# endif
|
||||||
# if !defined(HAVE_LINUX_KDEV_T_H) || !defined(HAVE_LINUX_MAJOR_H)
|
# if !(HAVE_LINUX_KDEV_T_H) || !(HAVE_LINUX_MAJOR_H)
|
||||||
# undef USE_SCREEN
|
# undef USE_SCREEN
|
||||||
# undef USE_SCREEN_VCSA
|
# undef USE_SCREEN_VCSA
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1 && defined(__DJGPP__)
|
#if 1 && defined(__DJGPP__)
|
||||||
# define USE_SCREEN
|
# define USE_SCREEN 1
|
||||||
#elif 1 && (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64)
|
#elif 1 && (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||||
# define USE_SCREEN
|
# define USE_SCREEN 1
|
||||||
# define USE_SCREEN_WIN32
|
# define USE_SCREEN_WIN32 1
|
||||||
#elif 1 && (ACC_OS_EMX && defined(__RSXNT__))
|
#elif 1 && (ACC_OS_EMX && defined(__RSXNT__))
|
||||||
# define USE_SCREEN
|
# define USE_SCREEN 1
|
||||||
# define USE_SCREEN_WIN32
|
# define USE_SCREEN_WIN32 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if 0 || defined(NO_ANSI)
|
#if 0 || (NO_ANSI)
|
||||||
# undef USE_ANSI
|
# undef USE_ANSI
|
||||||
#endif
|
#endif
|
||||||
#if 0 || defined(NO_SCREEN)
|
#if 0 || (NO_SCREEN)
|
||||||
# undef USE_SCREEN
|
# undef USE_SCREEN
|
||||||
#endif
|
#endif
|
||||||
#if 0 || defined(NO_FRAMES) || !defined(USE_SCREEN)
|
#if 0 || (NO_FRAMES) || !(USE_SCREEN)
|
||||||
# undef USE_FRAMES
|
# undef USE_FRAMES
|
||||||
#endif
|
#endif
|
||||||
#if 1
|
#if 1
|
||||||
@@ -81,11 +81,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if 0 || defined(USE_ANSI) || defined(USE_SCREEN)
|
#if 0 || (USE_ANSI) || (USE_SCREEN)
|
||||||
# define USE_CONSOLE
|
# define USE_CONSOLE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0 || defined(NO_CONSOLE) || !defined(USE_CONSOLE)
|
#if 0 || (NO_CONSOLE) || !(USE_CONSOLE)
|
||||||
# undef USE_CONSOLE
|
# undef USE_CONSOLE
|
||||||
# undef USE_ANSI
|
# undef USE_ANSI
|
||||||
# undef USE_SCREEN
|
# undef USE_SCREEN
|
||||||
@@ -110,7 +110,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#if defined(USE_CONSOLE)
|
#if (USE_CONSOLE)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -165,7 +165,7 @@ void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...);
|
|||||||
|
|
||||||
extern FILE *con_term;
|
extern FILE *con_term;
|
||||||
|
|
||||||
#if defined(USE_CONSOLE)
|
#if (USE_CONSOLE)
|
||||||
|
|
||||||
extern int con_mode;
|
extern int con_mode;
|
||||||
extern console_t *con;
|
extern console_t *con;
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+4
-4
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_EXCEPT_H
|
#ifndef __UPX_EXCEPT_H
|
||||||
#define __UPX_EXCEPT_H
|
#define __UPX_EXCEPT_H 1
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ public:
|
|||||||
// (noreturn) is probably not the correct semantics for throwing exceptions
|
// (noreturn) is probably not the correct semantics for throwing exceptions
|
||||||
#define NORET __attribute__((__noreturn__))
|
#define NORET __attribute__((__noreturn__))
|
||||||
#else
|
#else
|
||||||
#define NORET
|
#define NORET /*empty*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void throwCantPack(const char *msg) NORET;
|
void throwCantPack(const char *msg) NORET;
|
||||||
|
|||||||
+30
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
void File::chmod(const char *name, int mode)
|
void File::chmod(const char *name, int mode)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_CHMOD)
|
#if (HAVE_CHMOD)
|
||||||
if (::chmod(name,mode) != 0)
|
if (::chmod(name,mode) != 0)
|
||||||
throwIOException(name,errno);
|
throwIOException(name,errno);
|
||||||
#else
|
#else
|
||||||
@@ -396,9 +396,36 @@ void OutputFile::rewrite(const void *buf, int len)
|
|||||||
void OutputFile::seek(off_t off, int whence)
|
void OutputFile::seek(off_t off, int whence)
|
||||||
{
|
{
|
||||||
assert(!opt->to_stdout);
|
assert(!opt->to_stdout);
|
||||||
|
switch (whence) {
|
||||||
|
case SEEK_SET: {
|
||||||
|
if (bytes_written < off) {
|
||||||
|
bytes_written = off;
|
||||||
|
}
|
||||||
|
_length = bytes_written; // cheap, lazy update; needed?
|
||||||
|
} break;
|
||||||
|
case SEEK_END: {
|
||||||
|
_length = bytes_written; // necessary
|
||||||
|
} break;
|
||||||
|
}
|
||||||
super::seek(off,whence);
|
super::seek(off,whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int OutputFile::read(void *buf, int len)
|
||||||
|
{
|
||||||
|
InputFile infile;
|
||||||
|
infile.open(this->getName(), O_RDONLY);
|
||||||
|
infile.seek(this->tell(), SEEK_SET);
|
||||||
|
return infile.read(buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int OutputFile::readx(void *buf, int len)
|
||||||
|
{
|
||||||
|
InputFile infile;
|
||||||
|
infile.open(this->getName(), O_RDONLY);
|
||||||
|
infile.seek(this->tell(), SEEK_SET);
|
||||||
|
return infile.readx(buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
void OutputFile::set_extent(off_t offset, off_t length)
|
void OutputFile::set_extent(off_t offset, off_t length)
|
||||||
{
|
{
|
||||||
super::set_extent(offset, length);
|
super::set_extent(offset, length);
|
||||||
|
|||||||
+5
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_FILE_H
|
#ifndef __UPX_FILE_H
|
||||||
#define __UPX_FILE_H
|
#define __UPX_FILE_H 1
|
||||||
|
|
||||||
class MemBuffer;
|
class MemBuffer;
|
||||||
|
|
||||||
@@ -141,6 +141,8 @@ public:
|
|||||||
// FIXME - these won't work when using the '--stdout' option
|
// FIXME - these won't work when using the '--stdout' option
|
||||||
virtual void seek(off_t off, int whence);
|
virtual void seek(off_t off, int whence);
|
||||||
virtual void rewrite(const void *buf, int len);
|
virtual void rewrite(const void *buf, int len);
|
||||||
|
virtual int read(void *buf, int len);
|
||||||
|
virtual int readx(void *buf, int len);
|
||||||
|
|
||||||
// util
|
// util
|
||||||
static void dump(const char *name, const void *buf, int len, int flags=-1);
|
static void dump(const char *name, const void *buf, int len, int flags=-1);
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_FILTER_H
|
#ifndef __UPX_FILTER_H
|
||||||
#define __UPX_FILTER_H
|
#define __UPX_FILTER_H 1
|
||||||
|
|
||||||
class Filter;
|
class Filter;
|
||||||
class FilterImp;
|
class FilterImp;
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+3
-3
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
Copyright (C) 2000-2009 John F. Reiser
|
Copyright (C) 2000-2011 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+3
-3
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
Copyright (C) 2000-2009 John F. Reiser
|
Copyright (C) 2000-2011 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+3
-3
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
Copyright (C) 2000-2009 John F. Reiser
|
Copyright (C) 2000-2011 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+4
-3
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
Copyright (C) 2004-2009 John F. Reiser
|
Copyright (C) 2004-2011 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -108,6 +108,7 @@ static int F(Filter *f)
|
|||||||
f->calls = calls;
|
f->calls = calls;
|
||||||
f->noncalls = noncalls;
|
f->noncalls = noncalls;
|
||||||
f->lastcall = lastcall;
|
f->lastcall = lastcall;
|
||||||
|
ACC_UNUSED(lastnoncall);
|
||||||
|
|
||||||
#if 0 || defined(TESTING)
|
#if 0 || defined(TESTING)
|
||||||
printf("\ncalls=%d noncalls=%d text_size=%x calltrickoffset=%x\n",
|
printf("\ncalls=%d noncalls=%d text_size=%x calltrickoffset=%x\n",
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+18
-16
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -51,8 +51,9 @@ void show_head(void)
|
|||||||
fg = con_fg(f,FG_GREEN);
|
fg = con_fg(f,FG_GREEN);
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" Ultimate Packer for eXecutables\n"
|
" Ultimate Packer for eXecutables\n"
|
||||||
" Copyright (C) 1996 - 2009\n"
|
" Copyright (C) 1996 - %s\n"
|
||||||
"UPX %-10s Markus Oberhumer, Laszlo Molnar & John Reiser %14s\n\n",
|
"UPX %-10s Markus Oberhumer, Laszlo Molnar & John Reiser %14s\n\n",
|
||||||
|
UPX_VERSION_YEAR,
|
||||||
#if (ACC_OS_DOS16 || ACC_OS_DOS32)
|
#if (ACC_OS_DOS16 || ACC_OS_DOS32)
|
||||||
V("d"),
|
V("d"),
|
||||||
#elif (ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
|
#elif (ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||||
@@ -113,6 +114,7 @@ struct PackerNames
|
|||||||
{
|
{
|
||||||
PackerNames *self = (PackerNames *) user;
|
PackerNames *self = (PackerNames *) user;
|
||||||
self->add(p);
|
self->add(p);
|
||||||
|
delete p; p = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static int __acc_cdecl_qsort cmp_fname(const void *a, const void *b) {
|
static int __acc_cdecl_qsort cmp_fname(const void *a, const void *b) {
|
||||||
@@ -308,13 +310,13 @@ void show_help(int verbose)
|
|||||||
// "\nUPX comes with ABSOLUTELY NO WARRANTY; for details type 'upx -L'.\n"
|
// "\nUPX comes with ABSOLUTELY NO WARRANTY; for details type 'upx -L'.\n"
|
||||||
"");
|
"");
|
||||||
|
|
||||||
#if defined(DEBUG) || defined(TESTING)
|
#if (DEBUG) || (TESTING)
|
||||||
fg = con_fg(f,FG_RED);
|
fg = con_fg(f,FG_RED);
|
||||||
con_fprintf(f,"\nWARNING: this version is compiled with"
|
con_fprintf(f,"\nWARNING: this version is compiled with"
|
||||||
#if defined(DEBUG)
|
#if (DEBUG)
|
||||||
" -DDEBUG"
|
" -DDEBUG"
|
||||||
#endif
|
#endif
|
||||||
#if defined(TESTING)
|
#if (TESTING)
|
||||||
" -DTESTING"
|
" -DTESTING"
|
||||||
#endif
|
#endif
|
||||||
"\n");
|
"\n");
|
||||||
@@ -378,34 +380,34 @@ void show_version(int x)
|
|||||||
UNUSED(v);
|
UNUSED(v);
|
||||||
|
|
||||||
fprintf(fp, "upx %s\n", UPX_VERSION_STRING);
|
fprintf(fp, "upx %s\n", UPX_VERSION_STRING);
|
||||||
#if defined(WITH_NRV)
|
#if (WITH_NRV)
|
||||||
v = upx_nrv_version_string();
|
v = upx_nrv_version_string();
|
||||||
if (v != NULL && v[0])
|
if (v != NULL && v[0])
|
||||||
fprintf(fp, "NRV data compression library %s\n", v);
|
fprintf(fp, "NRV data compression library %s\n", v);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_UCL)
|
#if (WITH_UCL)
|
||||||
v = upx_ucl_version_string();
|
v = upx_ucl_version_string();
|
||||||
if (v != NULL && v[0])
|
if (v != NULL && v[0])
|
||||||
fprintf(fp, "UCL data compression library %s\n", v);
|
fprintf(fp, "UCL data compression library %s\n", v);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_ZLIB)
|
#if (WITH_ZLIB)
|
||||||
v = upx_zlib_version_string();
|
v = upx_zlib_version_string();
|
||||||
if (v != NULL && v[0])
|
if (v != NULL && v[0])
|
||||||
fprintf(fp, "zlib data compression library %s\n", v);
|
fprintf(fp, "zlib data compression library %s\n", v);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_LZMA)
|
#if (WITH_LZMA)
|
||||||
v = upx_lzma_version_string();
|
v = upx_lzma_version_string();
|
||||||
if (v != NULL && v[0])
|
if (v != NULL && v[0])
|
||||||
fprintf(fp, "LZMA SDK version %s\n", v);
|
fprintf(fp, "LZMA SDK version %s\n", v);
|
||||||
#endif
|
#endif
|
||||||
fprintf(fp, "Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer\n");
|
fprintf(fp, "Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\n");
|
||||||
fprintf(fp, "Copyright (C) 1996-2009 Laszlo Molnar\n");
|
fprintf(fp, "Copyright (C) 1996-2011 Laszlo Molnar\n");
|
||||||
fprintf(fp, "Copyright (C) 2000-2009 John F. Reiser\n");
|
fprintf(fp, "Copyright (C) 2000-2011 John F. Reiser\n");
|
||||||
fprintf(fp, "Copyright (C) 2002-2009 Jens Medoch\n");
|
fprintf(fp, "Copyright (C) 2002-2011 Jens Medoch\n");
|
||||||
#if defined(WITH_ZLIB)
|
#if (WITH_ZLIB)
|
||||||
fprintf(fp, "Copyright (C) 1995" "-2005 Jean-loup Gailly and Mark Adler\n");
|
fprintf(fp, "Copyright (C) 1995" "-2005 Jean-loup Gailly and Mark Adler\n");
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_LZMA)
|
#if (WITH_LZMA)
|
||||||
fprintf(fp, "Copyright (C) 1999" "-2006 Igor Pavlov\n");
|
fprintf(fp, "Copyright (C) 1999" "-2006 Igor Pavlov\n");
|
||||||
#endif
|
#endif
|
||||||
fprintf(fp, "UPX comes with ABSOLUTELY NO WARRANTY; for details type '%s -L'.\n", progname);
|
fprintf(fp, "UPX comes with ABSOLUTELY NO WARRANTY; for details type '%s -L'.\n", progname);
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_LEFILE_H
|
#ifndef __UPX_LEFILE_H
|
||||||
#define __UPX_LEFILE_H
|
#define __UPX_LEFILE_H 1
|
||||||
|
|
||||||
class InputFile;
|
class InputFile;
|
||||||
class OutputFile;
|
class OutputFile;
|
||||||
|
|||||||
+42
-56
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -45,6 +45,18 @@ static bool update_capacity(unsigned size, unsigned *capacity)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __acc_cdecl_va internal_error(const char *format, ...)
|
||||||
|
{
|
||||||
|
char buf[1024];
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, format);
|
||||||
|
vsnprintf(buf, sizeof(buf), format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
throwInternalError(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// Section
|
// Section
|
||||||
@@ -317,10 +329,7 @@ ElfLinker::Section *ElfLinker::findSection(const char *name, bool fatal) const
|
|||||||
if (strcmp(sections[ic]->name, name) == 0)
|
if (strcmp(sections[ic]->name, name) == 0)
|
||||||
return sections[ic];
|
return sections[ic];
|
||||||
if (fatal)
|
if (fatal)
|
||||||
{
|
internal_error("unknown section %s\n", name);
|
||||||
printf("unknown section %s\n", name);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,10 +339,7 @@ ElfLinker::Symbol *ElfLinker::findSymbol(const char *name, bool fatal) const
|
|||||||
if (strcmp(symbols[ic]->name, name) == 0)
|
if (strcmp(symbols[ic]->name, name) == 0)
|
||||||
return symbols[ic];
|
return symbols[ic];
|
||||||
if (fatal)
|
if (fatal)
|
||||||
{
|
internal_error("unknown symbol %s\n", name);
|
||||||
printf("unknown symbol %s\n", name);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,7 +475,7 @@ int ElfLinker::getSection(const char *sname, int *slen) const
|
|||||||
const Section *section = findSection(sname);
|
const Section *section = findSection(sname);
|
||||||
if (slen)
|
if (slen)
|
||||||
*slen = section->size;
|
*slen = section->size;
|
||||||
return section->output - output;
|
return (int) (section->output - output);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ElfLinker::getSectionSize(const char *sname) const
|
int ElfLinker::getSectionSize(const char *sname) const
|
||||||
@@ -492,7 +498,7 @@ void ElfLinker::relocate()
|
|||||||
for (unsigned ic = 0; ic < nrelocations; ic++)
|
for (unsigned ic = 0; ic < nrelocations; ic++)
|
||||||
{
|
{
|
||||||
const Relocation *rel = relocations[ic];
|
const Relocation *rel = relocations[ic];
|
||||||
unsigned value;
|
unsigned value = 0;
|
||||||
|
|
||||||
if (rel->section->output == NULL)
|
if (rel->section->output == NULL)
|
||||||
continue;
|
continue;
|
||||||
@@ -502,17 +508,11 @@ void ElfLinker::relocate()
|
|||||||
}
|
}
|
||||||
else if (strcmp(rel->value->section->name, "*UND*") == 0 &&
|
else if (strcmp(rel->value->section->name, "*UND*") == 0 &&
|
||||||
rel->value->offset == 0xdeaddead)
|
rel->value->offset == 0xdeaddead)
|
||||||
{
|
internal_error("undefined symbol '%s' referenced\n", rel->value->name);
|
||||||
printf("undefined symbol '%s' referenced\n", rel->value->name);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
else if (rel->value->section->output == NULL)
|
else if (rel->value->section->output == NULL)
|
||||||
{
|
internal_error("can not apply reloc '%s:%x' without section '%s'\n",
|
||||||
printf("can not apply reloc '%s:%x' without section '%s'\n",
|
|
||||||
rel->section->name, rel->offset,
|
rel->section->name, rel->offset,
|
||||||
rel->value->section->name);
|
rel->value->section->name);
|
||||||
abort();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
value = rel->value->section->offset +
|
value = rel->value->section->offset +
|
||||||
@@ -529,10 +529,7 @@ void ElfLinker::defineSymbol(const char *name, unsigned value)
|
|||||||
{
|
{
|
||||||
Symbol *symbol = findSymbol(name);
|
Symbol *symbol = findSymbol(name);
|
||||||
if (strcmp(symbol->section->name, "*ABS*") == 0)
|
if (strcmp(symbol->section->name, "*ABS*") == 0)
|
||||||
{
|
internal_error("defineSymbol: symbol '%s' is *ABS*\n", name);
|
||||||
printf("defineSymbol: symbol '%s' is *ABS*\n", name);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
else if (strcmp(symbol->section->name, "*UND*") == 0) // for undefined symbols
|
else if (strcmp(symbol->section->name, "*UND*") == 0) // for undefined symbols
|
||||||
symbol->offset = value;
|
symbol->offset = value;
|
||||||
else if (strcmp(symbol->section->name, name) == 0) // for sections
|
else if (strcmp(symbol->section->name, name) == 0) // for sections
|
||||||
@@ -545,10 +542,7 @@ void ElfLinker::defineSymbol(const char *name, unsigned value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
internal_error("defineSymbol: symbol '%s' already defined\n", name);
|
||||||
printf("defineSymbol: symbol '%s' already defined\n", name);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// debugging support
|
// debugging support
|
||||||
@@ -602,8 +596,7 @@ void ElfLinker::alignWithByte(unsigned len, unsigned char b)
|
|||||||
void ElfLinker::relocate1(const Relocation *rel, upx_byte *,
|
void ElfLinker::relocate1(const Relocation *rel, upx_byte *,
|
||||||
unsigned, const char *)
|
unsigned, const char *)
|
||||||
{
|
{
|
||||||
printf("unknown relocation type '%s\n", rel->type);
|
internal_error("unknown relocation type '%s\n", rel->type);
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -616,16 +609,12 @@ void ElfLinker::relocate1(const Relocation *rel, upx_byte *,
|
|||||||
#if 0 // FIXME
|
#if 0 // FIXME
|
||||||
static void check8(const Relocation *rel, const upx_byte *location, int v, int d)
|
static void check8(const Relocation *rel, const upx_byte *location, int v, int d)
|
||||||
{
|
{
|
||||||
if (v < -128 || v > 127) {
|
if (v < -128 || v > 127)
|
||||||
printf("value out of range (%d) in reloc %s:%x\n",
|
internal_error("value out of range (%d) in reloc %s:%x\n",
|
||||||
v, rel->section->name, rel->offset);
|
v, rel->section->name, rel->offset);
|
||||||
abort();
|
if (d < -128 || d > 127)
|
||||||
}
|
internal_error("displacement target out of range (%d) in reloc %s:%x\n",
|
||||||
if (d < -128 || d > 127) {
|
|
||||||
printf("displacement target out of range (%d) in reloc %s:%x\n",
|
|
||||||
v, rel->section->name, rel->offset);
|
v, rel->section->name, rel->offset);
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -651,11 +640,8 @@ void ElfLinkerAMD64::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
int displ = (signed char) *location + (int) value;
|
int displ = (signed char) *location + (int) value;
|
||||||
#endif
|
#endif
|
||||||
if (displ < -128 || displ > 127)
|
if (displ < -128 || displ > 127)
|
||||||
{
|
internal_error("target out of range (%d) in reloc %s:%x\n",
|
||||||
printf("target out of range (%d) in reloc %s:%x\n",
|
|
||||||
displ, rel->section->name, rel->offset);
|
displ, rel->section->name, rel->offset);
|
||||||
abort();
|
|
||||||
}
|
|
||||||
*location += value;
|
*location += value;
|
||||||
}
|
}
|
||||||
else if (strcmp(type, "16") == 0)
|
else if (strcmp(type, "16") == 0)
|
||||||
@@ -679,7 +665,10 @@ void ElfLinkerArmBE::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
{
|
{
|
||||||
set_be32(location, get_be32(location) + value);
|
set_be32(location, get_be32(location) + value);
|
||||||
}
|
}
|
||||||
else if (strcmp(type, "R_ARM_THM_CALL") == 0)
|
else if (strcmp(type, "R_ARM_THM_CALL") == 0
|
||||||
|
|| strcmp(type, "R_ARM_THM_XPC22") == 0
|
||||||
|
|| strcmp(type, "R_ARM_THM_PC22") == 0
|
||||||
|
)
|
||||||
{
|
{
|
||||||
value -= rel->section->offset + rel->offset;
|
value -= rel->section->offset + rel->offset;
|
||||||
value += ((get_be16(location) & 0x7ff) << 12);
|
value += ((get_be16(location) & 0x7ff) << 12);
|
||||||
@@ -711,7 +700,10 @@ void ElfLinkerArmLE::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
{
|
{
|
||||||
set_le32(location, get_le32(location) + value);
|
set_le32(location, get_le32(location) + value);
|
||||||
}
|
}
|
||||||
else if (strcmp(type, "R_ARM_THM_CALL") == 0)
|
else if (strcmp(type, "R_ARM_THM_CALL") == 0
|
||||||
|
|| strcmp(type, "R_ARM_THM_XPC22") == 0
|
||||||
|
|| strcmp(type, "R_ARM_THM_PC22") == 0
|
||||||
|
)
|
||||||
{
|
{
|
||||||
value -= rel->section->offset + rel->offset;
|
value -= rel->section->offset + rel->offset;
|
||||||
value += ((get_le16(location) & 0x7ff) << 12);
|
value += ((get_le16(location) & 0x7ff) << 12);
|
||||||
@@ -851,19 +843,15 @@ void ElfLinkerPpc32::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
|
|
||||||
// Note that original (*location).displ is ignored.
|
// Note that original (*location).displ is ignored.
|
||||||
if (strcmp(type, "24") == 0) {
|
if (strcmp(type, "24") == 0) {
|
||||||
if (3& value) {
|
if (3& value)
|
||||||
printf("unaligned word diplacement");
|
internal_error("unaligned word diplacement");
|
||||||
abort();
|
|
||||||
}
|
|
||||||
// FIXME: displacment overflow?
|
// FIXME: displacment overflow?
|
||||||
set_be32(location, (0xfc000003 & get_be32(location)) +
|
set_be32(location, (0xfc000003 & get_be32(location)) +
|
||||||
(0x03fffffc & value));
|
(0x03fffffc & value));
|
||||||
}
|
}
|
||||||
else if (strcmp(type, "14") == 0) {
|
else if (strcmp(type, "14") == 0) {
|
||||||
if (3& value) {
|
if (3& value)
|
||||||
printf("unaligned word diplacement");
|
internal_error("unaligned word diplacement");
|
||||||
abort();
|
|
||||||
}
|
|
||||||
// FIXME: displacment overflow?
|
// FIXME: displacment overflow?
|
||||||
set_be32(location, (0xffff0003 & get_be32(location)) +
|
set_be32(location, (0xffff0003 & get_be32(location)) +
|
||||||
(0x0000fffc & value));
|
(0x0000fffc & value));
|
||||||
@@ -895,11 +883,9 @@ void ElfLinkerX86::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
#else
|
#else
|
||||||
int displ = (signed char) *location + (int) value;
|
int displ = (signed char) *location + (int) value;
|
||||||
#endif
|
#endif
|
||||||
if (range_check && (displ < -128 || displ > 127)) {
|
if (range_check && (displ < -128 || displ > 127))
|
||||||
printf("target out of range (%d,%d,%d) in reloc %s:%x\n",
|
internal_error("target out of range (%d,%d,%d) in reloc %s:%x\n",
|
||||||
displ, *location, value, rel->section->name, rel->offset);
|
displ, *location, value, rel->section->name, rel->offset);
|
||||||
abort();
|
|
||||||
}
|
|
||||||
*location += value;
|
*location += value;
|
||||||
}
|
}
|
||||||
else if (strcmp(type, "16") == 0)
|
else if (strcmp(type, "16") == 0)
|
||||||
|
|||||||
+4
-4
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_LINKER_H
|
#ifndef __UPX_LINKER_H
|
||||||
#define __UPX_LINKER_H
|
#define __UPX_LINKER_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
//virtual void setLoaderAlignOffset(int phase);
|
//virtual void setLoaderAlignOffset(int phase);
|
||||||
virtual int addLoader(const char *sname);
|
virtual int addLoader(const char *sname);
|
||||||
void addLoader(const char *s, va_list ap);
|
void addLoader(const char *s, va_list ap);
|
||||||
#if 1 && (ACC_CC_GNUC >= 0x040100)
|
#if 1 && (ACC_CC_CLANG || (ACC_CC_GNUC >= 0x040100))
|
||||||
void __acc_cdecl_va addLoaderVA(const char *s, ...) __attribute__((__sentinel__));
|
void __acc_cdecl_va addLoaderVA(const char *s, ...) __attribute__((__sentinel__));
|
||||||
#else
|
#else
|
||||||
void __acc_cdecl_va addLoaderVA(const char *s, ...);
|
void __acc_cdecl_va addLoaderVA(const char *s, ...);
|
||||||
|
|||||||
+57
-19
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "mygetopt.h"
|
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "packer.h"
|
#include "packer.h"
|
||||||
#include "p_elf.h"
|
#include "p_elf.h"
|
||||||
@@ -63,7 +62,7 @@ void options_t::reset()
|
|||||||
o->console = CON_FILE;
|
o->console = CON_FILE;
|
||||||
#if defined(__DJGPP__)
|
#if defined(__DJGPP__)
|
||||||
o->console = CON_INIT;
|
o->console = CON_INIT;
|
||||||
#elif defined(USE_SCREEN_WIN32)
|
#elif (USE_SCREEN_WIN32)
|
||||||
o->console = CON_INIT;
|
o->console = CON_INIT;
|
||||||
#elif 1 && defined(__linux__)
|
#elif 1 && defined(__linux__)
|
||||||
o->console = CON_INIT;
|
o->console = CON_INIT;
|
||||||
@@ -90,6 +89,19 @@ static int done_script_name = 0;
|
|||||||
const char *argv0 = "";
|
const char *argv0 = "";
|
||||||
const char *progname = "";
|
const char *progname = "";
|
||||||
|
|
||||||
|
static acc_getopt_t mfx_getopt;
|
||||||
|
#define mfx_optarg mfx_getopt.optarg
|
||||||
|
#define mfx_optind mfx_getopt.optind
|
||||||
|
#define mfx_option acc_getopt_longopt_t
|
||||||
|
static void handle_opterr(acc_getopt_p g, const char *f, void *v)
|
||||||
|
{
|
||||||
|
struct A { va_list ap; };
|
||||||
|
struct A *a = (struct A *) v;
|
||||||
|
fprintf( stderr, "%s: ", g->progname);
|
||||||
|
vfprintf(stderr, f, a->ap);
|
||||||
|
fprintf( stderr, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int num_files = -1;
|
static int num_files = -1;
|
||||||
static int exit_code = EXIT_OK;
|
static int exit_code = EXIT_OK;
|
||||||
@@ -883,6 +895,9 @@ static int do_option(int optc, const char *arg)
|
|||||||
case 673:
|
case 673:
|
||||||
opt->ps1_exe.do_8mib = false;
|
opt->ps1_exe.do_8mib = false;
|
||||||
break;
|
break;
|
||||||
|
case 674:
|
||||||
|
opt->o_unix.unmap_all_pages = true; // val ?
|
||||||
|
break;
|
||||||
|
|
||||||
case '\0':
|
case '\0':
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1032,6 +1047,7 @@ static const struct mfx_option longopts[] =
|
|||||||
{"netbsd", 0x10, 0, 668},
|
{"netbsd", 0x10, 0, 668},
|
||||||
{"OpenBSD", 0x10, 0, 669},
|
{"OpenBSD", 0x10, 0, 669},
|
||||||
{"openbsd", 0x10, 0, 669},
|
{"openbsd", 0x10, 0, 669},
|
||||||
|
{"unmap-all-pages", 0x10, 0, 674}, // linux /proc/self/exe vanishes
|
||||||
// watcom/le
|
// watcom/le
|
||||||
{"le", 0x10, 0, 620}, // produce LE output
|
{"le", 0x10, 0, 620}, // produce LE output
|
||||||
// win32/pe
|
// win32/pe
|
||||||
@@ -1057,13 +1073,14 @@ static const struct mfx_option longopts[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
int optc, longind;
|
int optc, longind;
|
||||||
char buf[256];
|
char shortopts[256];
|
||||||
|
|
||||||
prepare_shortopts(buf,"123456789hH?V",longopts),
|
prepare_shortopts(shortopts, "123456789hH?V", longopts),
|
||||||
mfx_optind = 0;
|
acc_getopt_init(&mfx_getopt, 1, argc, argv);
|
||||||
mfx_opterr = 1;
|
mfx_getopt.progname = progname;
|
||||||
|
mfx_getopt.opterr = handle_opterr;
|
||||||
opt->o_unix.osabi0 = Elf32_Ehdr::ELFOSABI_LINUX;
|
opt->o_unix.osabi0 = Elf32_Ehdr::ELFOSABI_LINUX;
|
||||||
while ((optc = mfx_getopt_long(argc, argv, buf, longopts, &longind)) >= 0)
|
while ((optc = acc_getopt(&mfx_getopt, shortopts, longopts, &longind)) >= 0)
|
||||||
{
|
{
|
||||||
if (do_option(optc, argv[mfx_optind-1]) != 0)
|
if (do_option(optc, argv[mfx_optind-1]) != 0)
|
||||||
e_usage();
|
e_usage();
|
||||||
@@ -1149,7 +1166,7 @@ static const struct mfx_option longopts[] =
|
|||||||
int targc;
|
int targc;
|
||||||
char **targv = NULL;
|
char **targv = NULL;
|
||||||
static const char sep[] = " \t";
|
static const char sep[] = " \t";
|
||||||
char buf[256];
|
char shortopts[256];
|
||||||
|
|
||||||
var = getenv(OPTIONS_VAR);
|
var = getenv(OPTIONS_VAR);
|
||||||
if (var == NULL || !var[0])
|
if (var == NULL || !var[0])
|
||||||
@@ -1205,10 +1222,11 @@ static const struct mfx_option longopts[] =
|
|||||||
e_envopt(targv[i]);
|
e_envopt(targv[i]);
|
||||||
|
|
||||||
/* handle options */
|
/* handle options */
|
||||||
prepare_shortopts(buf,"123456789",longopts);
|
prepare_shortopts(shortopts, "123456789", longopts);
|
||||||
mfx_optind = 0;
|
acc_getopt_init(&mfx_getopt, 1, targc, targv);
|
||||||
mfx_opterr = 1;
|
mfx_getopt.progname = progname;
|
||||||
while ((optc = mfx_getopt_long(targc, targv, buf, longopts, &longind)) >= 0)
|
mfx_getopt.opterr = handle_opterr;
|
||||||
|
while ((optc = acc_getopt(&mfx_getopt, shortopts, longopts, &longind)) >= 0)
|
||||||
{
|
{
|
||||||
if (do_option(optc, targv[mfx_optind-1]) != 0)
|
if (do_option(optc, targv[mfx_optind-1]) != 0)
|
||||||
e_envopt(NULL);
|
e_envopt(NULL);
|
||||||
@@ -1267,9 +1285,13 @@ static bool test(void)
|
|||||||
COMPILE_TIME_ASSERT_ALIGNED1(test2_t)
|
COMPILE_TIME_ASSERT_ALIGNED1(test2_t)
|
||||||
COMPILE_TIME_ASSERT(sizeof(t2) == 7 + 21*sizeof(T))
|
COMPILE_TIME_ASSERT(sizeof(t2) == 7 + 21*sizeof(T))
|
||||||
#if defined(__acc_alignof)
|
#if defined(__acc_alignof)
|
||||||
|
#if (ACC_CC_CLANG && ACC_ARCH_AMD64)
|
||||||
|
// CBUG: clang-2.8 bug in 64-bit mode
|
||||||
|
#else
|
||||||
COMPILE_TIME_ASSERT(__acc_alignof(t1) == 1)
|
COMPILE_TIME_ASSERT(__acc_alignof(t1) == 1)
|
||||||
COMPILE_TIME_ASSERT(__acc_alignof(t2) == 1)
|
COMPILE_TIME_ASSERT(__acc_alignof(t2) == 1)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if 1 && (ACC_CC_WATCOMC)
|
#if 1 && (ACC_CC_WATCOMC)
|
||||||
test1_t t11; COMPILE_TIME_ASSERT(sizeof(t11.a) <= sizeof(t11.b))
|
test1_t t11; COMPILE_TIME_ASSERT(sizeof(t11.a) <= sizeof(t11.b))
|
||||||
test2_t t22; COMPILE_TIME_ASSERT(sizeof(t22.a) <= sizeof(t22.b))
|
test2_t t22; COMPILE_TIME_ASSERT(sizeof(t22.a) <= sizeof(t22.b))
|
||||||
@@ -1347,27 +1369,40 @@ void upx_sanity_check(void)
|
|||||||
assert(TestBELE<BE32>::test());
|
assert(TestBELE<BE32>::test());
|
||||||
assert(TestBELE<BE64>::test());
|
assert(TestBELE<BE64>::test());
|
||||||
{
|
{
|
||||||
static const unsigned char dd[32] = { 0, 0, 0, 0, 0, 0, 0,
|
static const unsigned char dd[32]
|
||||||
|
#if 1 && (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE) && defined(__ELF__)
|
||||||
|
__attribute__((__aligned__(16)))
|
||||||
|
#endif
|
||||||
|
= { 0, 0, 0, 0, 0, 0, 0,
|
||||||
0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
|
0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78,
|
0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78,
|
||||||
0, 0, 0, 0, 0 };
|
0, 0, 0, 0, 0 };
|
||||||
const unsigned char *d;
|
const unsigned char *d;
|
||||||
|
const N_BELE_RTP::AbstractPolicy *bele;
|
||||||
d = dd + 7;
|
d = dd + 7;
|
||||||
assert(upx_adler32(d, 4) == 0x09f003f7);
|
assert(upx_adler32(d, 4) == 0x09f003f7);
|
||||||
assert(upx_adler32(d, 4, 0) == 0x09ec03f6);
|
assert(upx_adler32(d, 4, 0) == 0x09ec03f6);
|
||||||
assert(upx_adler32(d, 4, 1) == 0x09f003f7);
|
assert(upx_adler32(d, 4, 1) == 0x09f003f7);
|
||||||
|
bele = &N_BELE_RTP::be_policy;
|
||||||
assert(get_be16(d) == 0xfffe);
|
assert(get_be16(d) == 0xfffe);
|
||||||
|
assert(bele->get16(d) == 0xfffe);
|
||||||
assert(get_be16_signed(d) == -2);
|
assert(get_be16_signed(d) == -2);
|
||||||
assert(get_be24(d) == 0xfffefd);
|
assert(get_be24(d) == 0xfffefd);
|
||||||
|
assert(bele->get24(d) == 0xfffefd);
|
||||||
assert(get_be24_signed(d) == -259);
|
assert(get_be24_signed(d) == -259);
|
||||||
assert(get_be32(d) == 0xfffefdfc);
|
assert(get_be32(d) == 0xfffefdfc);
|
||||||
|
assert(bele->get32(d) == 0xfffefdfc);
|
||||||
assert(get_be32_signed(d) == -66052);
|
assert(get_be32_signed(d) == -66052);
|
||||||
|
bele = &N_BELE_RTP::le_policy;
|
||||||
assert(get_le16(d) == 0xfeff);
|
assert(get_le16(d) == 0xfeff);
|
||||||
|
assert(bele->get16(d) == 0xfeff);
|
||||||
assert(get_le16_signed(d) == -257);
|
assert(get_le16_signed(d) == -257);
|
||||||
assert(get_le24(d) == 0xfdfeff);
|
assert(get_le24(d) == 0xfdfeff);
|
||||||
|
assert(bele->get24(d) == 0xfdfeff);
|
||||||
assert(get_le24_signed(d) == -131329);
|
assert(get_le24_signed(d) == -131329);
|
||||||
assert(get_le32(d) == 0xfcfdfeff);
|
assert(get_le32(d) == 0xfcfdfeff);
|
||||||
|
assert(bele->get32(d) == 0xfcfdfeff);
|
||||||
assert(get_le32_signed(d) == -50462977);
|
assert(get_le32_signed(d) == -50462977);
|
||||||
assert(get_le64_signed(d) == ACC_INT64_C(-506097522914230529));
|
assert(get_le64_signed(d) == ACC_INT64_C(-506097522914230529));
|
||||||
assert(find_be16(d, 2, 0xfffe) == 0);
|
assert(find_be16(d, 2, 0xfffe) == 0);
|
||||||
@@ -1388,7 +1423,7 @@ void upx_sanity_check(void)
|
|||||||
// main entry point
|
// main entry point
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#if !defined(WITH_GUI)
|
#if !(WITH_GUI)
|
||||||
|
|
||||||
#if (ACC_ARCH_M68K && ACC_OS_TOS && ACC_CC_GNUC) && defined(__MINT__)
|
#if (ACC_ARCH_M68K && ACC_OS_TOS && ACC_CC_GNUC) && defined(__MINT__)
|
||||||
extern "C" { extern long _stksize; long _stksize = 256 * 1024L; }
|
extern "C" { extern long _stksize; long _stksize = 256 * 1024L; }
|
||||||
@@ -1403,6 +1438,9 @@ int __acc_cdecl_main main(int argc, char *argv[])
|
|||||||
#if 0 && defined(__DJGPP__)
|
#if 0 && defined(__DJGPP__)
|
||||||
// LFN=n may cause problems with 2.03's _rename and mkdir under WinME
|
// LFN=n may cause problems with 2.03's _rename and mkdir under WinME
|
||||||
putenv("LFN=y");
|
putenv("LFN=y");
|
||||||
|
#endif
|
||||||
|
#if (ACC_OS_WIN32 || ACC_OS_WIN64) && (ACC_CC_MSC) && defined(_WRITE_ABORT_MSG) && defined(_CALL_REPORTFAULT)
|
||||||
|
_set_abort_behavior(_WRITE_ABORT_MSG, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
||||||
#endif
|
#endif
|
||||||
acc_wildargv(&argc, &argv);
|
acc_wildargv(&argc, &argv);
|
||||||
|
|
||||||
@@ -1438,7 +1476,7 @@ int __acc_cdecl_main main(int argc, char *argv[])
|
|||||||
|
|
||||||
set_term(stderr);
|
set_term(stderr);
|
||||||
|
|
||||||
#if defined(WITH_UCL)
|
#if (WITH_UCL)
|
||||||
if (ucl_init() != UCL_E_OK)
|
if (ucl_init() != UCL_E_OK)
|
||||||
{
|
{
|
||||||
show_head();
|
show_head();
|
||||||
@@ -1449,7 +1487,7 @@ int __acc_cdecl_main main(int argc, char *argv[])
|
|||||||
e_exit(EXIT_INIT);
|
e_exit(EXIT_INIT);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_NRV)
|
#if (WITH_NRV)
|
||||||
if (nrv_init() != NRV_E_OK || NRV_VERSION != nrv_version())
|
if (nrv_init() != NRV_E_OK || NRV_VERSION != nrv_version())
|
||||||
{
|
{
|
||||||
show_head();
|
show_head();
|
||||||
@@ -1542,7 +1580,7 @@ int __acc_cdecl_main main(int argc, char *argv[])
|
|||||||
return exit_code;
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !defined(WITH_GUI) */
|
#endif /* !(WITH_GUI) */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -41,7 +41,7 @@ static int mcheck_init()
|
|||||||
if (use_mcheck < 0)
|
if (use_mcheck < 0)
|
||||||
{
|
{
|
||||||
use_mcheck = 1;
|
use_mcheck = 1;
|
||||||
#if defined(WITH_VALGRIND) && defined(RUNNING_ON_VALGRIND)
|
#if (WITH_VALGRIND) && defined(RUNNING_ON_VALGRIND)
|
||||||
if (RUNNING_ON_VALGRIND)
|
if (RUNNING_ON_VALGRIND)
|
||||||
{
|
{
|
||||||
//fprintf(stderr, "upx: detected RUNNING_ON_VALGRIND\n");
|
//fprintf(stderr, "upx: detected RUNNING_ON_VALGRIND\n");
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_MEM_H
|
#ifndef __UPX_MEM_H
|
||||||
#define __UPX_MEM_H
|
#define __UPX_MEM_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+599
-244
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -57,7 +57,7 @@ void printClearLine(FILE *f)
|
|||||||
fflush(stdout); fflush(stderr);
|
fflush(stdout); fflush(stderr);
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
f = stdout;
|
f = stdout;
|
||||||
con_fprintf(f,clear_line_msg);
|
con_fprintf(f, "%s", clear_line_msg);
|
||||||
fflush(f);
|
fflush(f);
|
||||||
printSetNl(0);
|
printSetNl(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,706 +0,0 @@
|
|||||||
/* Getopt for GNU.
|
|
||||||
NOTE: getopt is now part of the C library, so if you don't know what
|
|
||||||
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
|
|
||||||
before changing it!
|
|
||||||
|
|
||||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
|
|
||||||
Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This program 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, 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; if not, write to the Free Software
|
|
||||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef PROGNAME
|
|
||||||
#if 0
|
|
||||||
#ifndef EOF
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
#define PROGNAME(x) (x)
|
|
||||||
#else
|
|
||||||
#include "conf.h"
|
|
||||||
static const char *my_progname(const char *argv0)
|
|
||||||
{
|
|
||||||
return progname ? progname : argv0;
|
|
||||||
}
|
|
||||||
#define PROGNAME(x) my_progname(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
|
|
||||||
long-named option. Because this is not POSIX.2 compliant, it is
|
|
||||||
being phased out. */
|
|
||||||
/* #define GETOPT_COMPAT */
|
|
||||||
#undef GETOPT_COMPAT
|
|
||||||
|
|
||||||
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
|
||||||
but it behaves differently for the user, since it allows the user
|
|
||||||
to intersperse the options with the other arguments.
|
|
||||||
|
|
||||||
As `getopt' works, it permutes the elements of ARGV so that,
|
|
||||||
when it is done, all the options precede everything else. Thus
|
|
||||||
all application programs are extended to handle flexible argument order.
|
|
||||||
|
|
||||||
Setting the environment variable POSIXLY_CORRECT disables permutation.
|
|
||||||
Then the behavior is completely standard.
|
|
||||||
|
|
||||||
GNU application programs can use a third alternative mode in which
|
|
||||||
they can distinguish the relative order of options and other arguments. */
|
|
||||||
|
|
||||||
#include "mygetopt.h"
|
|
||||||
#define option mfx_option
|
|
||||||
#define optarg mfx_optarg
|
|
||||||
#define optind mfx_optind
|
|
||||||
#define opterr mfx_opterr
|
|
||||||
#define optopt mfx_optopt
|
|
||||||
#undef BAD_OPTION
|
|
||||||
|
|
||||||
/* For communication from `getopt' to the caller.
|
|
||||||
When `getopt' finds an option that takes an argument,
|
|
||||||
the argument value is returned here.
|
|
||||||
Also, when `ordering' is RETURN_IN_ORDER,
|
|
||||||
each non-option ARGV-element is returned here. */
|
|
||||||
|
|
||||||
char *optarg = NULL;
|
|
||||||
|
|
||||||
/* Index in ARGV of the next element to be scanned.
|
|
||||||
This is used for communication to and from the caller
|
|
||||||
and for communication between successive calls to `getopt'.
|
|
||||||
|
|
||||||
On entry to `getopt', zero means this is the first call; initialize.
|
|
||||||
|
|
||||||
When `getopt' returns EOF, this is the index of the first of the
|
|
||||||
non-option elements that the caller should itself scan.
|
|
||||||
|
|
||||||
Otherwise, `optind' communicates from one call to the next
|
|
||||||
how much of ARGV has been scanned so far. */
|
|
||||||
|
|
||||||
/* XXX 1003.2 says this must be 1 before any call. */
|
|
||||||
int optind = 0;
|
|
||||||
|
|
||||||
/* The next char to be scanned in the option-element
|
|
||||||
in which the last option character we returned was found.
|
|
||||||
This allows us to pick up the scan where we left off.
|
|
||||||
|
|
||||||
If this is zero, or a null string, it means resume the scan
|
|
||||||
by advancing to the next ARGV-element. */
|
|
||||||
|
|
||||||
static char *nextchar;
|
|
||||||
|
|
||||||
/* Callers store zero here to inhibit the error message
|
|
||||||
for unrecognized options. */
|
|
||||||
|
|
||||||
int opterr = 1;
|
|
||||||
|
|
||||||
/* Set to an option character which was unrecognized.
|
|
||||||
This must be initialized on some systems to avoid linking in the
|
|
||||||
system's own getopt implementation. */
|
|
||||||
|
|
||||||
#define BAD_OPTION '\0'
|
|
||||||
int optopt = BAD_OPTION;
|
|
||||||
|
|
||||||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
|
||||||
|
|
||||||
If the caller did not specify anything,
|
|
||||||
the default is REQUIRE_ORDER if the environment variable
|
|
||||||
POSIXLY_CORRECT is defined, PERMUTE otherwise.
|
|
||||||
|
|
||||||
REQUIRE_ORDER means don't recognize them as options;
|
|
||||||
stop option processing when the first non-option is seen.
|
|
||||||
This is what Unix does.
|
|
||||||
This mode of operation is selected by either setting the environment
|
|
||||||
variable POSIXLY_CORRECT, or using `+' as the first character
|
|
||||||
of the list of option characters.
|
|
||||||
|
|
||||||
PERMUTE is the default. We permute the contents of ARGV as we scan,
|
|
||||||
so that eventually all the non-options are at the end. This allows options
|
|
||||||
to be given in any order, even with programs that were not written to
|
|
||||||
expect this.
|
|
||||||
|
|
||||||
RETURN_IN_ORDER is an option available to programs that were written
|
|
||||||
to expect options and other ARGV-elements in any order and that care about
|
|
||||||
the ordering of the two. We describe each non-option ARGV-element
|
|
||||||
as if it were the argument of an option with character code 1.
|
|
||||||
Using `-' as the first character of the list of option characters
|
|
||||||
selects this mode of operation.
|
|
||||||
|
|
||||||
The special argument `--' forces an end of option-scanning regardless
|
|
||||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
|
||||||
`--' can cause `getopt' to return EOF with `optind' != ARGC. */
|
|
||||||
|
|
||||||
static enum
|
|
||||||
{
|
|
||||||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
|
||||||
} ordering;
|
|
||||||
|
|
||||||
/* Handle permutation of arguments. */
|
|
||||||
|
|
||||||
/* Describe the part of ARGV that contains non-options that have
|
|
||||||
been skipped. `first_nonopt' is the index in ARGV of the first of them;
|
|
||||||
`last_nonopt' is the index after the last of them. */
|
|
||||||
|
|
||||||
static int first_nonopt;
|
|
||||||
static int last_nonopt;
|
|
||||||
|
|
||||||
/* Exchange two adjacent subsequences of ARGV.
|
|
||||||
One subsequence is elements [first_nonopt,last_nonopt)
|
|
||||||
which contains all the non-options that have been skipped so far.
|
|
||||||
The other is elements [last_nonopt,optind), which contains all
|
|
||||||
the options processed since those non-options were skipped.
|
|
||||||
|
|
||||||
`first_nonopt' and `last_nonopt' are relocated so that they describe
|
|
||||||
the new indices of the non-options in ARGV after they are moved.
|
|
||||||
|
|
||||||
To perform the swap, we first reverse the order of all elements. So
|
|
||||||
all options now come before all non options, but they are in the
|
|
||||||
wrong order. So we put back the options and non options in original
|
|
||||||
order by reversing them again. For example:
|
|
||||||
original input: a b c -x -y
|
|
||||||
reverse all: -y -x c b a
|
|
||||||
reverse options: -x -y c b a
|
|
||||||
reverse non options: -x -y a b c
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
static void exchange (char **argv)
|
|
||||||
{
|
|
||||||
char *temp; char **first, **last;
|
|
||||||
|
|
||||||
/* Reverse all the elements [first_nonopt, optind) */
|
|
||||||
first = &argv[first_nonopt];
|
|
||||||
last = &argv[optind-1];
|
|
||||||
while (first < last) {
|
|
||||||
temp = *first; *first = *last; *last = temp; first++; last--;
|
|
||||||
}
|
|
||||||
/* Put back the options in order */
|
|
||||||
first = &argv[first_nonopt];
|
|
||||||
first_nonopt += (optind - last_nonopt);
|
|
||||||
last = &argv[first_nonopt - 1];
|
|
||||||
while (first < last) {
|
|
||||||
temp = *first; *first = *last; *last = temp; first++; last--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Put back the non options in order */
|
|
||||||
first = &argv[first_nonopt];
|
|
||||||
last_nonopt = optind;
|
|
||||||
last = &argv[last_nonopt-1];
|
|
||||||
while (first < last) {
|
|
||||||
temp = *first; *first = *last; *last = temp; first++; last--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Scan elements of ARGV (whose length is ARGC) for option characters
|
|
||||||
given in OPTSTRING.
|
|
||||||
|
|
||||||
If an element of ARGV starts with '-', and is not exactly "-" or "--",
|
|
||||||
then it is an option element. The characters of this element
|
|
||||||
(aside from the initial '-') are option characters. If `getopt'
|
|
||||||
is called repeatedly, it returns successively each of the option characters
|
|
||||||
from each of the option elements.
|
|
||||||
|
|
||||||
If `getopt' finds another option character, it returns that character,
|
|
||||||
updating `optind' and `nextchar' so that the next call to `getopt' can
|
|
||||||
resume the scan with the following option character or ARGV-element.
|
|
||||||
|
|
||||||
If there are no more option characters, `getopt' returns `EOF'.
|
|
||||||
Then `optind' is the index in ARGV of the first ARGV-element
|
|
||||||
that is not an option. (The ARGV-elements have been permuted
|
|
||||||
so that those that are not options now come last.)
|
|
||||||
|
|
||||||
OPTSTRING is a string containing the legitimate option characters.
|
|
||||||
If an option character is seen that is not listed in OPTSTRING,
|
|
||||||
return BAD_OPTION after printing an error message. If you set `opterr' to
|
|
||||||
zero, the error message is suppressed but we still return BAD_OPTION.
|
|
||||||
|
|
||||||
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
|
|
||||||
so the following text in the same ARGV-element, or the text of the following
|
|
||||||
ARGV-element, is returned in `optarg'. Two colons mean an option that
|
|
||||||
wants an optional arg; if there is text in the current ARGV-element,
|
|
||||||
it is returned in `optarg', otherwise `optarg' is set to zero.
|
|
||||||
|
|
||||||
If OPTSTRING starts with `-' or `+', it requests different methods of
|
|
||||||
handling the non-option ARGV-elements.
|
|
||||||
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
|
|
||||||
|
|
||||||
Long-named options begin with `--' instead of `-'.
|
|
||||||
Their names may be abbreviated as long as the abbreviation is unique
|
|
||||||
or is an exact match for some defined option. If they have an
|
|
||||||
argument, it follows the option name in the same ARGV-element, separated
|
|
||||||
from the option name by a `=', or else the in next ARGV-element.
|
|
||||||
When `getopt' finds a long-named option, it returns 0 if that option's
|
|
||||||
`flag' field is nonzero, the value of the option's `val' field
|
|
||||||
if the `flag' field is zero.
|
|
||||||
|
|
||||||
LONGOPTS is a vector of `struct option' terminated by an
|
|
||||||
element containing a name which is zero.
|
|
||||||
|
|
||||||
LONGIND returns the index in LONGOPT of the long-named option found.
|
|
||||||
It is only valid when a long-named option has been found by the most
|
|
||||||
recent call.
|
|
||||||
|
|
||||||
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
|
|
||||||
long-named options. */
|
|
||||||
|
|
||||||
static int _getopt_internal (int argc, char **argv, const char *optstring,
|
|
||||||
const struct option *longopts, int *longind,
|
|
||||||
int long_only)
|
|
||||||
{
|
|
||||||
static char empty_string[1];
|
|
||||||
int option_index;
|
|
||||||
|
|
||||||
if (longind != NULL)
|
|
||||||
*longind = -1;
|
|
||||||
|
|
||||||
optarg = 0;
|
|
||||||
|
|
||||||
/* Initialize the internal data when the first call is made.
|
|
||||||
Start processing options with ARGV-element 1 (since ARGV-element 0
|
|
||||||
is the program name); the sequence of previously skipped
|
|
||||||
non-option ARGV-elements is empty. */
|
|
||||||
|
|
||||||
if (optind == 0)
|
|
||||||
{
|
|
||||||
first_nonopt = last_nonopt = optind = 1;
|
|
||||||
|
|
||||||
nextchar = NULL;
|
|
||||||
|
|
||||||
/* Determine how to handle the ordering of options and nonoptions. */
|
|
||||||
|
|
||||||
if (optstring[0] == '-')
|
|
||||||
{
|
|
||||||
ordering = RETURN_IN_ORDER;
|
|
||||||
++optstring;
|
|
||||||
}
|
|
||||||
else if (optstring[0] == '+')
|
|
||||||
{
|
|
||||||
ordering = REQUIRE_ORDER;
|
|
||||||
++optstring;
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
else if (getenv ("POSIXLY_CORRECT") != NULL)
|
|
||||||
ordering = REQUIRE_ORDER;
|
|
||||||
#endif
|
|
||||||
else
|
|
||||||
ordering = PERMUTE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextchar == NULL || *nextchar == '\0')
|
|
||||||
{
|
|
||||||
if (ordering == PERMUTE)
|
|
||||||
{
|
|
||||||
/* If we have just processed some options following some non-options,
|
|
||||||
exchange them so that the options come first. */
|
|
||||||
|
|
||||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
|
||||||
exchange (argv);
|
|
||||||
else if (last_nonopt != optind)
|
|
||||||
first_nonopt = optind;
|
|
||||||
|
|
||||||
/* Now skip any additional non-options
|
|
||||||
and extend the range of non-options previously skipped. */
|
|
||||||
|
|
||||||
while (optind < argc
|
|
||||||
&& (argv[optind][0] != '-' || argv[optind][1] == '\0')
|
|
||||||
#ifdef GETOPT_COMPAT
|
|
||||||
&& (longopts == NULL
|
|
||||||
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
|
|
||||||
#endif /* GETOPT_COMPAT */
|
|
||||||
)
|
|
||||||
optind++;
|
|
||||||
last_nonopt = optind;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Special ARGV-element `--' means premature end of options.
|
|
||||||
Skip it like a null option,
|
|
||||||
then exchange with previous non-options as if it were an option,
|
|
||||||
then skip everything else like a non-option. */
|
|
||||||
|
|
||||||
if (optind != argc && !strcmp (argv[optind], "--"))
|
|
||||||
{
|
|
||||||
optind++;
|
|
||||||
|
|
||||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
|
||||||
exchange (argv);
|
|
||||||
else if (first_nonopt == last_nonopt)
|
|
||||||
first_nonopt = optind;
|
|
||||||
last_nonopt = argc;
|
|
||||||
|
|
||||||
optind = argc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we have done all the ARGV-elements, stop the scan
|
|
||||||
and back over any non-options that we skipped and permuted. */
|
|
||||||
|
|
||||||
if (optind == argc)
|
|
||||||
{
|
|
||||||
/* Set the next-arg-index to point at the non-options
|
|
||||||
that we previously skipped, so the caller will digest them. */
|
|
||||||
if (first_nonopt != last_nonopt)
|
|
||||||
optind = first_nonopt;
|
|
||||||
return EOF;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we have come to a non-option and did not permute it,
|
|
||||||
either stop the scan or describe it to the caller and pass it by. */
|
|
||||||
|
|
||||||
if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
|
|
||||||
#ifdef GETOPT_COMPAT
|
|
||||||
&& (longopts == NULL
|
|
||||||
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
|
|
||||||
#endif /* GETOPT_COMPAT */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (ordering == REQUIRE_ORDER)
|
|
||||||
return EOF;
|
|
||||||
optarg = argv[optind++];
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We have found another option-ARGV-element.
|
|
||||||
Start decoding its characters. */
|
|
||||||
|
|
||||||
nextchar = (argv[optind] + 1
|
|
||||||
+ (longopts != NULL && argv[optind][1] == '-'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (longopts != NULL
|
|
||||||
&& ((argv[optind][0] == '-'
|
|
||||||
&& (argv[optind][1] == '-' || long_only))
|
|
||||||
#ifdef GETOPT_COMPAT
|
|
||||||
|| argv[optind][0] == '+'
|
|
||||||
#endif /* GETOPT_COMPAT */
|
|
||||||
))
|
|
||||||
{
|
|
||||||
const struct option *p;
|
|
||||||
char *s = nextchar;
|
|
||||||
int exact = 0;
|
|
||||||
int ambig = 0;
|
|
||||||
const struct option *pfound = NULL;
|
|
||||||
int indfound = 0;
|
|
||||||
int needexact = 0;
|
|
||||||
|
|
||||||
/* allow `--option#value' because you cannout assign a '='
|
|
||||||
to an environment variable under DOS command.com */
|
|
||||||
while (*s && *s != '=' && * s != '#')
|
|
||||||
s++;
|
|
||||||
|
|
||||||
/* Test all options for either exact match or abbreviated matches. */
|
|
||||||
for (p = longopts, option_index = 0; p->name;
|
|
||||||
p++, option_index++)
|
|
||||||
if (!strncmp (p->name, nextchar, (unsigned) (s - nextchar)))
|
|
||||||
{
|
|
||||||
if (p->has_arg & 0x10)
|
|
||||||
needexact = 1;
|
|
||||||
if ((unsigned) (s - nextchar) == strlen (p->name))
|
|
||||||
{
|
|
||||||
/* Exact match found. */
|
|
||||||
pfound = p;
|
|
||||||
indfound = option_index;
|
|
||||||
exact = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (pfound == NULL)
|
|
||||||
{
|
|
||||||
/* First nonexact match found. */
|
|
||||||
pfound = p;
|
|
||||||
indfound = option_index;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* Second nonexact match found. */
|
|
||||||
ambig = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* don't allow nonexact longoptions */
|
|
||||||
if (needexact && !exact)
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
fprintf (stderr, "%s: unrecognized option `%s'\n",
|
|
||||||
PROGNAME(argv[0]), argv[optind]);
|
|
||||||
nextchar += strlen (nextchar);
|
|
||||||
optind++;
|
|
||||||
return BAD_OPTION;
|
|
||||||
}
|
|
||||||
if (ambig && !exact)
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
fprintf (stderr, "%s: option `%s' is ambiguous\n",
|
|
||||||
PROGNAME(argv[0]), argv[optind]);
|
|
||||||
nextchar += strlen (nextchar);
|
|
||||||
optind++;
|
|
||||||
return BAD_OPTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pfound != NULL)
|
|
||||||
{
|
|
||||||
int have_arg = (s[0] != '\0');
|
|
||||||
if (have_arg && (pfound->has_arg & 0xf))
|
|
||||||
have_arg = (s[1] != '\0');
|
|
||||||
option_index = indfound;
|
|
||||||
optind++;
|
|
||||||
if (have_arg)
|
|
||||||
{
|
|
||||||
/* Don't test has_arg with >, because some C compilers don't
|
|
||||||
allow it to be used on enums. */
|
|
||||||
if (pfound->has_arg & 0xf)
|
|
||||||
optarg = s + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
{
|
|
||||||
if (argv[optind - 1][1] == '-')
|
|
||||||
/* --option */
|
|
||||||
fprintf (stderr,
|
|
||||||
"%s: option `--%s' doesn't allow an argument\n",
|
|
||||||
PROGNAME(argv[0]), pfound->name);
|
|
||||||
else
|
|
||||||
/* +option or -option */
|
|
||||||
fprintf (stderr,
|
|
||||||
"%s: option `%c%s' doesn't allow an argument\n",
|
|
||||||
PROGNAME(argv[0]), argv[optind - 1][0], pfound->name);
|
|
||||||
}
|
|
||||||
nextchar += strlen (nextchar);
|
|
||||||
return BAD_OPTION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((pfound->has_arg & 0xf) == 1)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
if (optind < argc)
|
|
||||||
#else
|
|
||||||
if (optind < argc && (pfound->has_arg & 0x20) == 0)
|
|
||||||
#endif
|
|
||||||
optarg = argv[optind++];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
fprintf (stderr, "%s: option `--%s%s' requires an argument\n",
|
|
||||||
PROGNAME(argv[0]), pfound->name,
|
|
||||||
(pfound->has_arg & 0x20) ? "=" : "");
|
|
||||||
nextchar += strlen (nextchar);
|
|
||||||
return optstring[0] == ':' ? ':' : BAD_OPTION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nextchar += strlen (nextchar);
|
|
||||||
if (longind != NULL)
|
|
||||||
*longind = option_index;
|
|
||||||
if (pfound->flag)
|
|
||||||
{
|
|
||||||
*(pfound->flag) = pfound->val;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return pfound->val;
|
|
||||||
}
|
|
||||||
/* Can't find it as a long option. If this is not getopt_long_only,
|
|
||||||
or the option starts with '--' or is not a valid short
|
|
||||||
option, then it's an error.
|
|
||||||
Otherwise interpret it as a short option. */
|
|
||||||
if (!long_only || argv[optind][1] == '-'
|
|
||||||
#ifdef GETOPT_COMPAT
|
|
||||||
|| argv[optind][0] == '+'
|
|
||||||
#endif /* GETOPT_COMPAT */
|
|
||||||
|| strchr (optstring, *nextchar) == NULL)
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
{
|
|
||||||
if (argv[optind][1] == '-')
|
|
||||||
/* --option */
|
|
||||||
fprintf (stderr, "%s: unrecognized option `--%s'\n",
|
|
||||||
PROGNAME(argv[0]), nextchar);
|
|
||||||
else
|
|
||||||
/* +option or -option */
|
|
||||||
fprintf (stderr, "%s: unrecognized option `%c%s'\n",
|
|
||||||
PROGNAME(argv[0]), argv[optind][0], nextchar);
|
|
||||||
}
|
|
||||||
nextchar = empty_string;
|
|
||||||
optind++;
|
|
||||||
return BAD_OPTION;
|
|
||||||
}
|
|
||||||
(void) &ambig; /* UNUSED */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Look at and handle the next option-character. */
|
|
||||||
|
|
||||||
{
|
|
||||||
char c = *nextchar++;
|
|
||||||
const char *temp = strchr (optstring, c);
|
|
||||||
|
|
||||||
/* Increment `optind' when we start to process its last character. */
|
|
||||||
if (*nextchar == '\0')
|
|
||||||
++optind;
|
|
||||||
|
|
||||||
if (temp == NULL || c == ':')
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
if (c < 040 || c >= 0177)
|
|
||||||
fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
|
|
||||||
PROGNAME(argv[0]), c);
|
|
||||||
else
|
|
||||||
fprintf (stderr, "%s: unrecognized option `-%c'\n", PROGNAME(argv[0]), c);
|
|
||||||
#else
|
|
||||||
/* 1003.2 specifies the format of this message. */
|
|
||||||
fprintf (stderr, "%s: illegal option -- %c\n", PROGNAME(argv[0]), c);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
optopt = c;
|
|
||||||
return BAD_OPTION;
|
|
||||||
}
|
|
||||||
if (temp[1] == ':')
|
|
||||||
{
|
|
||||||
if (temp[2] == ':')
|
|
||||||
{
|
|
||||||
/* This is an option that accepts an argument optionally. */
|
|
||||||
if (*nextchar != '\0')
|
|
||||||
{
|
|
||||||
optarg = nextchar;
|
|
||||||
optind++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
optarg = 0;
|
|
||||||
nextchar = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* This is an option that requires an argument. */
|
|
||||||
if (*nextchar != '\0')
|
|
||||||
{
|
|
||||||
optarg = nextchar;
|
|
||||||
/* If we end this ARGV-element by taking the rest as an arg,
|
|
||||||
we must advance to the next element now. */
|
|
||||||
optind++;
|
|
||||||
}
|
|
||||||
else if (optind == argc)
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
fprintf (stderr, "%s: option `-%c' requires an argument\n",
|
|
||||||
PROGNAME(argv[0]), c);
|
|
||||||
#else
|
|
||||||
/* 1003.2 specifies the format of this message. */
|
|
||||||
fprintf (stderr, "%s: option requires an argument -- %c\n",
|
|
||||||
PROGNAME(argv[0]), c);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
optopt = c;
|
|
||||||
if (optstring[0] == ':')
|
|
||||||
c = ':';
|
|
||||||
else
|
|
||||||
c = BAD_OPTION;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* We already incremented `optind' once;
|
|
||||||
increment it again when taking next ARGV-elt as argument. */
|
|
||||||
optarg = argv[optind++];
|
|
||||||
nextchar = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int mfx_getopt(int argc, char **argv, const char *optstring)
|
|
||||||
{
|
|
||||||
return _getopt_internal (argc, argv, optstring,
|
|
||||||
(const struct option *) 0,
|
|
||||||
(int *) 0,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int mfx_getopt_long(int argc, char **argv, const char *options,
|
|
||||||
const struct option *long_options, int *opt_index)
|
|
||||||
{
|
|
||||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef TEST
|
|
||||||
|
|
||||||
/* Compile with -DTEST to make an executable for use in testing
|
|
||||||
the above definition of `getopt'. */
|
|
||||||
|
|
||||||
int
|
|
||||||
main (argc, argv)
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
int digit_optind = 0;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
int this_option_optind = optind ? optind : 1;
|
|
||||||
|
|
||||||
c = getopt (argc, argv, "abc:d:0123456789");
|
|
||||||
if (c == EOF)
|
|
||||||
break;
|
|
||||||
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case '0':
|
|
||||||
case '1':
|
|
||||||
case '2':
|
|
||||||
case '3':
|
|
||||||
case '4':
|
|
||||||
case '5':
|
|
||||||
case '6':
|
|
||||||
case '7':
|
|
||||||
case '8':
|
|
||||||
case '9':
|
|
||||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
|
||||||
printf ("digits occur in two different argv-elements.\n");
|
|
||||||
digit_optind = this_option_optind;
|
|
||||||
printf ("option %c\n", c);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'a':
|
|
||||||
printf ("option a\n");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'b':
|
|
||||||
printf ("option b\n");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'c':
|
|
||||||
printf ("option c with value `%s'\n", optarg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BAD_OPTION:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optind < argc)
|
|
||||||
{
|
|
||||||
printf ("non-option ARGV-elements: ");
|
|
||||||
while (optind < argc)
|
|
||||||
printf ("%s ", argv[optind++]);
|
|
||||||
printf ("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TEST */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
-102
@@ -1,102 +0,0 @@
|
|||||||
/* Declarations for getopt.
|
|
||||||
Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This program 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, 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; if not, write to the Free Software
|
|
||||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
||||||
|
|
||||||
#ifndef __MFX_GETOPT_H
|
|
||||||
#define __MFX_GETOPT_H 1
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
/* extern "C" { */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* For communication from `getopt' to the caller.
|
|
||||||
When `getopt' finds an option that takes an argument,
|
|
||||||
the argument value is returned here.
|
|
||||||
Also, when `ordering' is RETURN_IN_ORDER,
|
|
||||||
each non-option ARGV-element is returned here. */
|
|
||||||
|
|
||||||
extern char *mfx_optarg;
|
|
||||||
|
|
||||||
/* Index in ARGV of the next element to be scanned.
|
|
||||||
This is used for communication to and from the caller
|
|
||||||
and for communication between successive calls to `getopt'.
|
|
||||||
|
|
||||||
On entry to `getopt', zero means this is the first call; initialize.
|
|
||||||
|
|
||||||
When `getopt' returns EOF, this is the index of the first of the
|
|
||||||
non-option elements that the caller should itself scan.
|
|
||||||
|
|
||||||
Otherwise, `optind' communicates from one call to the next
|
|
||||||
how much of ARGV has been scanned so far. */
|
|
||||||
|
|
||||||
extern int mfx_optind;
|
|
||||||
|
|
||||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
|
||||||
for unrecognized options. */
|
|
||||||
|
|
||||||
extern int mfx_opterr;
|
|
||||||
|
|
||||||
/* Set to an option character which was unrecognized. */
|
|
||||||
|
|
||||||
extern int mfx_optopt;
|
|
||||||
|
|
||||||
/* Describe the long-named options requested by the application.
|
|
||||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
|
||||||
of `struct option' terminated by an element containing a name which is
|
|
||||||
zero.
|
|
||||||
|
|
||||||
The field `has_arg' is:
|
|
||||||
no_argument (or 0) if the option does not take an argument,
|
|
||||||
required_argument (or 1) if the option requires an argument,
|
|
||||||
optional_argument (or 2) if the option takes an optional argument.
|
|
||||||
|
|
||||||
If the field `flag' is not NULL, it points to a variable that is set
|
|
||||||
to the value given in the field `val' when the option is found, but
|
|
||||||
left unchanged if the option is not found.
|
|
||||||
|
|
||||||
To have a long-named option do something other than set an `int' to
|
|
||||||
a compiled-in constant, such as set a value from `optarg', set the
|
|
||||||
option's `flag' field to zero and its `val' field to a nonzero
|
|
||||||
value (the equivalent single-letter option character, if there is
|
|
||||||
one). For long options that have a zero `flag' field, `getopt'
|
|
||||||
returns the contents of the `val' field. */
|
|
||||||
|
|
||||||
struct mfx_option
|
|
||||||
{
|
|
||||||
const char *name;
|
|
||||||
/* has_arg can't be an enum because some compilers complain about
|
|
||||||
type mismatches in all the code that assumes it is an int. */
|
|
||||||
int has_arg;
|
|
||||||
int *flag;
|
|
||||||
int val;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
|
||||||
|
|
||||||
#define mfx_no_argument 0
|
|
||||||
#define mfx_required_argument 1
|
|
||||||
#define mfx_optional_argument 2
|
|
||||||
#define mfx_exact_argument 0x10 /* no abbrev. */
|
|
||||||
|
|
||||||
int mfx_getopt(int argc, char **argv, const char *shortopts);
|
|
||||||
int mfx_getopt_long(int argc, char **argv, const char *shortopts,
|
|
||||||
const struct mfx_option *longopts, int *longind);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
/* } */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __MFX_GETOPT_H */
|
|
||||||
+4
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_OPTIONS_H
|
#ifndef __UPX_OPTIONS_H
|
||||||
#define __UPX_OPTIONS_H
|
#define __UPX_OPTIONS_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -142,6 +142,7 @@ struct options_t {
|
|||||||
bool is_ptinterp; // is PT_INTERP, so don't adjust auxv_t
|
bool is_ptinterp; // is PT_INTERP, so don't adjust auxv_t
|
||||||
bool use_ptinterp; // use PT_INTERP /opt/upx/run
|
bool use_ptinterp; // use PT_INTERP /opt/upx/run
|
||||||
bool make_ptinterp; // make PT_INTERP [ignore current file!]
|
bool make_ptinterp; // make PT_INTERP [ignore current file!]
|
||||||
|
bool unmap_all_pages; // thus /proc/self/exe vanishes
|
||||||
unsigned char osabi0; // replacement if 0==.e_ident[EI_OSABI]
|
unsigned char osabi0; // replacement if 0==.e_ident[EI_OSABI]
|
||||||
enum { SCRIPT_MAX = 32 };
|
enum { SCRIPT_MAX = 32 };
|
||||||
const char *script_name;
|
const char *script_name;
|
||||||
|
|||||||
+13
-6
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -202,6 +202,7 @@ unsigned PackArmPe::processImports() // pass 1
|
|||||||
unsigned iat;
|
unsigned iat;
|
||||||
LE32 *lookupt;
|
LE32 *lookupt;
|
||||||
unsigned npos;
|
unsigned npos;
|
||||||
|
unsigned original_position;
|
||||||
bool isk32;
|
bool isk32;
|
||||||
|
|
||||||
static int __acc_cdecl_qsort compare(const void *p1, const void *p2)
|
static int __acc_cdecl_qsort compare(const void *p1, const void *p2)
|
||||||
@@ -210,6 +211,8 @@ unsigned PackArmPe::processImports() // pass 1
|
|||||||
const udll *u2 = * (const udll * const *) p2;
|
const udll *u2 = * (const udll * const *) p2;
|
||||||
if (u1->isk32) return -1;
|
if (u1->isk32) return -1;
|
||||||
if (u2->isk32) return 1;
|
if (u2->isk32) return 1;
|
||||||
|
if (!*u1->lookupt) return 1;
|
||||||
|
if (!*u2->lookupt) return -1;
|
||||||
int rc = strcasecmp(u1->name,u2->name);
|
int rc = strcasecmp(u1->name,u2->name);
|
||||||
if (rc) return rc;
|
if (rc) return rc;
|
||||||
if (u1->ordinal) return -1;
|
if (u1->ordinal) return -1;
|
||||||
@@ -236,11 +239,12 @@ unsigned PackArmPe::processImports() // pass 1
|
|||||||
dlls[ic].iat = im->iat;
|
dlls[ic].iat = im->iat;
|
||||||
dlls[ic].lookupt = (LE32*) (ibuf + (im->oft ? im->oft : im->iat));
|
dlls[ic].lookupt = (LE32*) (ibuf + (im->oft ? im->oft : im->iat));
|
||||||
dlls[ic].npos = 0;
|
dlls[ic].npos = 0;
|
||||||
|
dlls[ic].original_position = ic;
|
||||||
dlls[ic].isk32 = strcasecmp(kernel32dll,dlls[ic].name) == 0;
|
dlls[ic].isk32 = strcasecmp(kernel32dll,dlls[ic].name) == 0;
|
||||||
|
|
||||||
soimport += strlen(dlls[ic].name) + 1 + 4;
|
soimport += strlen(dlls[ic].name) + 1 + 4;
|
||||||
|
|
||||||
for (LE32 *tarr = dlls[ic].lookupt; *tarr; tarr++)
|
for (IPTR_I(LE32, tarr, dlls[ic].lookupt); *tarr; tarr += 1)
|
||||||
{
|
{
|
||||||
if (*tarr & 0x80000000)
|
if (*tarr & 0x80000000)
|
||||||
{
|
{
|
||||||
@@ -252,10 +256,11 @@ unsigned PackArmPe::processImports() // pass 1
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned len = strlen(ibuf + *tarr + 2);
|
IPTR_I(const upx_byte, n, ibuf + *tarr + 2);
|
||||||
|
unsigned len = strlen(n);
|
||||||
soimport += len + 1;
|
soimport += len + 1;
|
||||||
if (dlls[ic].shname == NULL || len < strlen (dlls[ic].shname))
|
if (dlls[ic].shname == NULL || len < strlen (dlls[ic].shname))
|
||||||
dlls[ic].shname = ibuf + *tarr + 2;
|
dlls[ic].shname = n;
|
||||||
}
|
}
|
||||||
soimport++; // separator
|
soimport++; // separator
|
||||||
}
|
}
|
||||||
@@ -343,8 +348,10 @@ unsigned PackArmPe::processImports() // pass 1
|
|||||||
for (ic = 0; ic < dllnum; ic++)
|
for (ic = 0; ic < dllnum; ic++)
|
||||||
{
|
{
|
||||||
LE32 *tarr = idlls[ic]->lookupt;
|
LE32 *tarr = idlls[ic]->lookupt;
|
||||||
|
#if 0 && ENABLE_THIS_AND_UNCOMPRESSION_WILL_BREAK
|
||||||
if (!*tarr) // no imports from this dll
|
if (!*tarr) // no imports from this dll
|
||||||
continue;
|
continue;
|
||||||
|
#endif
|
||||||
set_le32(ppi,idlls[ic]->npos);
|
set_le32(ppi,idlls[ic]->npos);
|
||||||
set_le32(ppi+4,idlls[ic]->iat - rvamin);
|
set_le32(ppi+4,idlls[ic]->iat - rvamin);
|
||||||
ppi += 8;
|
ppi += 8;
|
||||||
@@ -412,7 +419,7 @@ unsigned PackArmPe::processImports() // pass 1
|
|||||||
for (ic = 0; ic < dllnum; ic++, im++)
|
for (ic = 0; ic < dllnum; ic++, im++)
|
||||||
{
|
{
|
||||||
memset(im,FILLVAL,sizeof(*im));
|
memset(im,FILLVAL,sizeof(*im));
|
||||||
im->dllname = ptr_diff(idlls[ic]->name,ibuf); // I only need this info
|
im->dllname = ptr_diff(dlls[idlls[ic]->original_position].name,ibuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
+4
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_ARMPE_H
|
#ifndef __UPX_P_ARMPE_H
|
||||||
#define __UPX_P_ARMPE_H
|
#define __UPX_P_ARMPE_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// arm/pe
|
// arm/pe
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
static const
|
static const
|
||||||
#include "stub/i086-dos16.com.h"
|
#include "stub/i086-dos16.com.h"
|
||||||
|
|
||||||
//#define TESTING
|
//#define TESTING 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_COM_H
|
#ifndef __UPX_P_COM_H
|
||||||
#define __UPX_P_COM_H
|
#define __UPX_P_COM_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_DJGPP2_H
|
#ifndef __UPX_P_DJGPP2_H
|
||||||
#define __UPX_P_DJGPP2_H
|
#define __UPX_P_DJGPP2_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+52
-5
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_ELF_H
|
#ifndef __UPX_P_ELF_H
|
||||||
#define __UPX_P_ELF_H
|
#define __UPX_P_ELF_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -91,6 +91,27 @@ __packed_struct(Dyn)
|
|||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
|
|
||||||
|
template <class TElfITypes>
|
||||||
|
__packed_struct(Rel)
|
||||||
|
typedef typename TElfITypes::Xword Xword;
|
||||||
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
|
||||||
|
Addr r_offset;
|
||||||
|
Xword r_info;
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
|
||||||
|
template <class TElfITypes>
|
||||||
|
__packed_struct(Rela)
|
||||||
|
typedef typename TElfITypes::Xword Xword;
|
||||||
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
|
||||||
|
Addr r_offset;
|
||||||
|
Xword r_info;
|
||||||
|
Xword r_addend;
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
__packed_struct(External_Note)
|
__packed_struct(External_Note)
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
@@ -172,7 +193,8 @@ __packed_struct(Sym)
|
|||||||
|
|
||||||
static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); }
|
static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); }
|
||||||
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
||||||
static unsigned char make_st_info(unsigned bind, unsigned type) { return (bind<<4) + (0xf & type); }
|
static unsigned char make_st_info(unsigned bind, unsigned type)
|
||||||
|
{ return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); }
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
|
|
||||||
@@ -248,7 +270,8 @@ __packed_struct(Sym)
|
|||||||
|
|
||||||
static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); }
|
static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); }
|
||||||
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
||||||
static unsigned char make_st_info(unsigned bind, unsigned type) { return (bind<<4) + (0xf & type); }
|
static unsigned char make_st_info(unsigned bind, unsigned type)
|
||||||
|
{ return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); }
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
|
|
||||||
@@ -277,6 +300,8 @@ struct ElfClass_32
|
|||||||
typedef N_Elf32::Phdr<ElfITypes> Phdr;
|
typedef N_Elf32::Phdr<ElfITypes> Phdr;
|
||||||
typedef N_Elf32::Shdr<ElfITypes> Shdr;
|
typedef N_Elf32::Shdr<ElfITypes> Shdr;
|
||||||
typedef N_Elf ::Dyn <ElfITypes> Dyn;
|
typedef N_Elf ::Dyn <ElfITypes> Dyn;
|
||||||
|
typedef N_Elf ::Rel <ElfITypes> Rel;
|
||||||
|
typedef N_Elf ::Rela<ElfITypes> Rela;
|
||||||
typedef N_Elf32::Sym <ElfITypes> Sym;
|
typedef N_Elf32::Sym <ElfITypes> Sym;
|
||||||
typedef N_Elf ::External_Note<ElfITypes> External_Note;
|
typedef N_Elf ::External_Note<ElfITypes> External_Note;
|
||||||
|
|
||||||
@@ -286,11 +311,15 @@ struct ElfClass_32
|
|||||||
COMPILE_TIME_ASSERT(sizeof(Phdr) == 32)
|
COMPILE_TIME_ASSERT(sizeof(Phdr) == 32)
|
||||||
COMPILE_TIME_ASSERT(sizeof(Shdr) == 40)
|
COMPILE_TIME_ASSERT(sizeof(Shdr) == 40)
|
||||||
COMPILE_TIME_ASSERT(sizeof(Dyn) == 8)
|
COMPILE_TIME_ASSERT(sizeof(Dyn) == 8)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Rel) == 8)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Rela) == 12)
|
||||||
COMPILE_TIME_ASSERT(sizeof(Sym) == 16)
|
COMPILE_TIME_ASSERT(sizeof(Sym) == 16)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(Ehdr)
|
COMPILE_TIME_ASSERT_ALIGNED1(Ehdr)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(Phdr)
|
COMPILE_TIME_ASSERT_ALIGNED1(Phdr)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(Shdr)
|
COMPILE_TIME_ASSERT_ALIGNED1(Shdr)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(Dyn)
|
COMPILE_TIME_ASSERT_ALIGNED1(Dyn)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Rel)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Rela)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(Sym)
|
COMPILE_TIME_ASSERT_ALIGNED1(Sym)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -312,6 +341,8 @@ struct ElfClass_64
|
|||||||
typedef N_Elf64::Phdr<ElfITypes> Phdr;
|
typedef N_Elf64::Phdr<ElfITypes> Phdr;
|
||||||
typedef N_Elf64::Shdr<ElfITypes> Shdr;
|
typedef N_Elf64::Shdr<ElfITypes> Shdr;
|
||||||
typedef N_Elf ::Dyn <ElfITypes> Dyn;
|
typedef N_Elf ::Dyn <ElfITypes> Dyn;
|
||||||
|
typedef N_Elf ::Rel <ElfITypes> Rel;
|
||||||
|
typedef N_Elf ::Rela<ElfITypes> Rela;
|
||||||
typedef N_Elf64::Sym <ElfITypes> Sym;
|
typedef N_Elf64::Sym <ElfITypes> Sym;
|
||||||
typedef N_Elf ::External_Note<ElfITypes> External_Note;
|
typedef N_Elf ::External_Note<ElfITypes> External_Note;
|
||||||
|
|
||||||
@@ -321,11 +352,15 @@ struct ElfClass_64
|
|||||||
COMPILE_TIME_ASSERT(sizeof(Phdr) == 56)
|
COMPILE_TIME_ASSERT(sizeof(Phdr) == 56)
|
||||||
COMPILE_TIME_ASSERT(sizeof(Shdr) == 64)
|
COMPILE_TIME_ASSERT(sizeof(Shdr) == 64)
|
||||||
COMPILE_TIME_ASSERT(sizeof(Dyn) == 16)
|
COMPILE_TIME_ASSERT(sizeof(Dyn) == 16)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Rel) == 16)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Rela) == 24)
|
||||||
COMPILE_TIME_ASSERT(sizeof(Sym) == 24)
|
COMPILE_TIME_ASSERT(sizeof(Sym) == 24)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(Ehdr)
|
COMPILE_TIME_ASSERT_ALIGNED1(Ehdr)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(Phdr)
|
COMPILE_TIME_ASSERT_ALIGNED1(Phdr)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(Shdr)
|
COMPILE_TIME_ASSERT_ALIGNED1(Shdr)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(Dyn)
|
COMPILE_TIME_ASSERT_ALIGNED1(Dyn)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Rel)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Rela)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(Sym)
|
COMPILE_TIME_ASSERT_ALIGNED1(Sym)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -350,6 +385,8 @@ typedef ElfClass_Host32::Ehdr Elf32_Ehdr;
|
|||||||
typedef ElfClass_Host32::Phdr Elf32_Phdr;
|
typedef ElfClass_Host32::Phdr Elf32_Phdr;
|
||||||
typedef ElfClass_Host32::Shdr Elf32_Shdr;
|
typedef ElfClass_Host32::Shdr Elf32_Shdr;
|
||||||
typedef ElfClass_Host32::Dyn Elf32_Dyn;
|
typedef ElfClass_Host32::Dyn Elf32_Dyn;
|
||||||
|
typedef ElfClass_Host32::Rel Elf32_Rel;
|
||||||
|
typedef ElfClass_Host32::Rela Elf32_Rela;
|
||||||
typedef ElfClass_Host32::Sym Elf32_Sym;
|
typedef ElfClass_Host32::Sym Elf32_Sym;
|
||||||
typedef ElfClass_Host32::External_Note Elf32_External_Note;
|
typedef ElfClass_Host32::External_Note Elf32_External_Note;
|
||||||
|
|
||||||
@@ -357,6 +394,8 @@ typedef ElfClass_Host64::Ehdr Elf64_Ehdr;
|
|||||||
typedef ElfClass_Host64::Phdr Elf64_Phdr;
|
typedef ElfClass_Host64::Phdr Elf64_Phdr;
|
||||||
typedef ElfClass_Host64::Shdr Elf64_Shdr;
|
typedef ElfClass_Host64::Shdr Elf64_Shdr;
|
||||||
typedef ElfClass_Host64::Dyn Elf64_Dyn;
|
typedef ElfClass_Host64::Dyn Elf64_Dyn;
|
||||||
|
typedef ElfClass_Host64::Rel Elf64_Rel;
|
||||||
|
typedef ElfClass_Host64::Rela Elf64_Rela;
|
||||||
typedef ElfClass_Host64::Sym Elf64_Sym;
|
typedef ElfClass_Host64::Sym Elf64_Sym;
|
||||||
typedef ElfClass_Host64::External_Note Elf64_External_Note;
|
typedef ElfClass_Host64::External_Note Elf64_External_Note;
|
||||||
|
|
||||||
@@ -364,6 +403,8 @@ typedef ElfClass_BE32::Ehdr Elf_BE32_Ehdr;
|
|||||||
typedef ElfClass_BE32::Phdr Elf_BE32_Phdr;
|
typedef ElfClass_BE32::Phdr Elf_BE32_Phdr;
|
||||||
typedef ElfClass_BE32::Shdr Elf_BE32_Shdr;
|
typedef ElfClass_BE32::Shdr Elf_BE32_Shdr;
|
||||||
typedef ElfClass_BE32::Dyn Elf_BE32_Dyn;
|
typedef ElfClass_BE32::Dyn Elf_BE32_Dyn;
|
||||||
|
typedef ElfClass_BE32::Rel Elf_BE32_Rel;
|
||||||
|
typedef ElfClass_BE32::Rela Elf_BE32_Rela;
|
||||||
typedef ElfClass_BE32::Sym Elf_BE32_Sym;
|
typedef ElfClass_BE32::Sym Elf_BE32_Sym;
|
||||||
typedef ElfClass_BE32::External_Note Elf_BE32_External_Note;
|
typedef ElfClass_BE32::External_Note Elf_BE32_External_Note;
|
||||||
|
|
||||||
@@ -371,6 +412,8 @@ typedef ElfClass_BE64::Ehdr Elf_BE64_Ehdr;
|
|||||||
typedef ElfClass_BE64::Phdr Elf_BE64_Phdr;
|
typedef ElfClass_BE64::Phdr Elf_BE64_Phdr;
|
||||||
typedef ElfClass_BE64::Shdr Elf_BE64_Shdr;
|
typedef ElfClass_BE64::Shdr Elf_BE64_Shdr;
|
||||||
typedef ElfClass_BE64::Dyn Elf_BE64_Dyn;
|
typedef ElfClass_BE64::Dyn Elf_BE64_Dyn;
|
||||||
|
typedef ElfClass_BE64::Rel Elf_BE64_Rel;
|
||||||
|
typedef ElfClass_BE64::Rela Elf_BE64_Rela;
|
||||||
typedef ElfClass_BE64::Sym Elf_BE64_Sym;
|
typedef ElfClass_BE64::Sym Elf_BE64_Sym;
|
||||||
typedef ElfClass_BE64::External_Note Elf_BE64_External_Note;
|
typedef ElfClass_BE64::External_Note Elf_BE64_External_Note;
|
||||||
|
|
||||||
@@ -378,6 +421,8 @@ typedef ElfClass_LE32::Ehdr Elf_LE32_Ehdr;
|
|||||||
typedef ElfClass_LE32::Phdr Elf_LE32_Phdr;
|
typedef ElfClass_LE32::Phdr Elf_LE32_Phdr;
|
||||||
typedef ElfClass_LE32::Shdr Elf_LE32_Shdr;
|
typedef ElfClass_LE32::Shdr Elf_LE32_Shdr;
|
||||||
typedef ElfClass_LE32::Dyn Elf_LE32_Dyn;
|
typedef ElfClass_LE32::Dyn Elf_LE32_Dyn;
|
||||||
|
typedef ElfClass_LE32::Rel Elf_LE32_Rel;
|
||||||
|
typedef ElfClass_LE32::Rela Elf_LE32_Rela;
|
||||||
typedef ElfClass_LE32::Sym Elf_LE32_Sym;
|
typedef ElfClass_LE32::Sym Elf_LE32_Sym;
|
||||||
typedef ElfClass_LE32::External_Note Elf_LE32_External_Note;
|
typedef ElfClass_LE32::External_Note Elf_LE32_External_Note;
|
||||||
|
|
||||||
@@ -385,6 +430,8 @@ typedef ElfClass_LE64::Ehdr Elf_LE64_Ehdr;
|
|||||||
typedef ElfClass_LE64::Phdr Elf_LE64_Phdr;
|
typedef ElfClass_LE64::Phdr Elf_LE64_Phdr;
|
||||||
typedef ElfClass_LE64::Shdr Elf_LE64_Shdr;
|
typedef ElfClass_LE64::Shdr Elf_LE64_Shdr;
|
||||||
typedef ElfClass_LE64::Dyn Elf_LE64_Dyn;
|
typedef ElfClass_LE64::Dyn Elf_LE64_Dyn;
|
||||||
|
typedef ElfClass_LE64::Rel Elf_LE64_Rel;
|
||||||
|
typedef ElfClass_LE64::Rela Elf_LE64_Rela;
|
||||||
typedef ElfClass_LE64::Sym Elf_LE64_Sym;
|
typedef ElfClass_LE64::Sym Elf_LE64_Sym;
|
||||||
typedef ElfClass_LE64::External_Note Elf_LE64_External_Note;
|
typedef ElfClass_LE64::External_Note Elf_LE64_External_Note;
|
||||||
|
|
||||||
|
|||||||
+62
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -145,10 +145,20 @@
|
|||||||
DT_HASH = 4, /* Hash table of symbol names */
|
DT_HASH = 4, /* Hash table of symbol names */
|
||||||
DT_STRTAB = 5, /* String table */
|
DT_STRTAB = 5, /* String table */
|
||||||
DT_SYMTAB = 6, /* Symbol table */
|
DT_SYMTAB = 6, /* Symbol table */
|
||||||
|
DT_RELA = 7, /* Relocations which do contain an addend */
|
||||||
|
DT_RELAENT = 9, /* Size of one RELA relocation */
|
||||||
|
DT_INIT = 12, /* Address of init function */
|
||||||
|
DT_REL = 17, /* Relocations which contain no addend */
|
||||||
|
DT_RELENT = 19, /* Size of one Rel relocation */
|
||||||
DT_STRSZ = 10, /* Sizeof string table */
|
DT_STRSZ = 10, /* Sizeof string table */
|
||||||
DT_PLTREL = 20, /* Type of reloc in PLT */
|
DT_PLTREL = 20, /* Type of reloc in PLT */
|
||||||
|
DT_TEXTREL = 22, /* Reloc might modify .text */
|
||||||
DT_JMPREL = 23, /* Address of PLT relocs */
|
DT_JMPREL = 23, /* Address of PLT relocs */
|
||||||
DT_GNU_HASH = 0x6ffffef5 /* GNU-style hash table */
|
DT_CHECKSUM = 0x6ffffdf8, /* Only for prelink? */
|
||||||
|
DT_GNU_HASH = 0x6ffffef5, /* GNU-style hash table */
|
||||||
|
DT_VERSYM = 0x6ffffff0, /* version[] for each symbol */
|
||||||
|
DT_VERDEF = 0x6ffffffc, /* version definitions[] */
|
||||||
|
DT_VERNEEDED= 0x6ffffffe /* version[] needed */
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -186,6 +196,55 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WANT_NHDR_ENUM
|
||||||
|
#undef WANT_NHDR_ENUM
|
||||||
|
enum { // ELF PT_NOTE types
|
||||||
|
#define ELF_NOTE_GNU_NAME "GNU\0"
|
||||||
|
NT_GNU_ABI_TAG = 1,
|
||||||
|
NT_GNU_HWCAP = 2,
|
||||||
|
NT_GNU_BUILD_ID = 3,
|
||||||
|
|
||||||
|
#define ELF_NOTE_OPENBSD_NAME "OpenBSD\0"
|
||||||
|
NHDR_OPENBSD_TAG = 1,
|
||||||
|
|
||||||
|
#define ELF_NOTE_NETBSD_NAME "NetBSD\0"
|
||||||
|
NHDR_NETBSD_TAG = 1,
|
||||||
|
NHDR_CHECKSUM_TAG = 2,
|
||||||
|
NHDR_PAX_TAG = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
enum { // descsz descriptor sizes
|
||||||
|
GNU_ABI_DESCSZ = 16, // int GNU_OS, major, minor, subminor;
|
||||||
|
NETBSD_DESCSZ = 4, // major_ver * (10**8) + minor
|
||||||
|
OPENBSD_DESCSZ = 4, // 32-bit zero
|
||||||
|
// CHECKSUM_DESCSZ is 2*sizeof(short) + sizeof(checksum)
|
||||||
|
PAX_DESCSZ = 4 // 32-bit mask
|
||||||
|
};
|
||||||
|
|
||||||
|
enum { // GNU OS/version
|
||||||
|
GNU_OS_LINUX = 0,
|
||||||
|
GNU_OS_HURD = 1,
|
||||||
|
GNU_OS_SOLARIS = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
enum { // NetBSD checksum methods
|
||||||
|
CHECKSUM_CRC32 = 1,
|
||||||
|
CHECKSUM_MD5 = 2,
|
||||||
|
CHECKSUM_SHA1 = 3,
|
||||||
|
CHECKSUM_SHA256 = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ELF_NOTE_PAX_NAME "PaX\0"
|
||||||
|
enum { // NetBSD PaX bit values
|
||||||
|
PAX_MPROTECT = (1<<0), /* force enable Mprotect */
|
||||||
|
PAX_NOMPROTECT = (1<<1), /* force disable Mprotect */
|
||||||
|
PAX_GUARD = (1<<2), /* force enable SEGVguard */
|
||||||
|
PAX_NOGUARD = (1<<3), /* force disable SEGVguard */
|
||||||
|
PAX_ASLR = (1<<4), /* force enable ASLR */
|
||||||
|
PAX_NOASLR = (1<<5) /* force disable ASLR */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
vi:ts=4:et
|
vi:ts=4:et
|
||||||
*/
|
*/
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+8
-8
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -56,16 +56,16 @@ PackExe::PackExe(InputFile *f) :
|
|||||||
ih_exesize = ih_imagesize = ih_overlay = 0;
|
ih_exesize = ih_imagesize = ih_overlay = 0;
|
||||||
stack_for_lzma = 0;
|
stack_for_lzma = 0;
|
||||||
use_clear_dirty_stack = false;
|
use_clear_dirty_stack = false;
|
||||||
|
|
||||||
// disable lzma for "--brute" unless explicitly given "--lzma"
|
|
||||||
if (opt->all_methods_use_lzma && !opt->method_lzma_seen)
|
|
||||||
opt->all_methods_use_lzma = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const int *PackExe::getCompressionMethods(int method, int level) const
|
const int *PackExe::getCompressionMethods(int method, int level) const
|
||||||
{
|
{
|
||||||
bool small = ih_imagesize <= 256*1024;
|
bool small = ih_imagesize <= 256*1024;
|
||||||
|
// disable lzma for "--brute" unless explicitly given "--lzma"
|
||||||
|
// WARNING: this side effect persists for later files!
|
||||||
|
if (opt->all_methods_use_lzma && !opt->method_lzma_seen)
|
||||||
|
opt->all_methods_use_lzma = false;
|
||||||
return Packer::getDefaultCompressionMethods_8(method, level, small);
|
return Packer::getDefaultCompressionMethods_8(method, level, small);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,7 +514,7 @@ void PackExe::pack(OutputFile *fo)
|
|||||||
if (ph.max_run_found + ph.max_match_found > 0x8000)
|
if (ph.max_run_found + ph.max_match_found > 0x8000)
|
||||||
throwCantPack("decompressor limit exceeded, send a bugreport");
|
throwCantPack("decompressor limit exceeded, send a bugreport");
|
||||||
|
|
||||||
#ifdef TESTING
|
#if TESTING
|
||||||
if (opt->debug.debug_level)
|
if (opt->debug.debug_level)
|
||||||
{
|
{
|
||||||
printf("image+relocs %d -> %d\n",ih_imagesize+relocsize,ph.c_len);
|
printf("image+relocs %d -> %d\n",ih_imagesize+relocsize,ph.c_len);
|
||||||
@@ -631,7 +631,7 @@ void PackExe::pack(OutputFile *fo)
|
|||||||
//fprintf(stderr,"\ne_len=%x d_len=%x c_len=%x oo=%x ulen=%x destp=%x copys=%x images=%x",e_len,d_len,packedsize,ph.overlap_overhead,ph.u_len,destpara,copysize,ih_imagesize);
|
//fprintf(stderr,"\ne_len=%x d_len=%x c_len=%x oo=%x ulen=%x destp=%x copys=%x images=%x",e_len,d_len,packedsize,ph.overlap_overhead,ph.u_len,destpara,copysize,ih_imagesize);
|
||||||
|
|
||||||
// write header + write loader + compressed file
|
// write header + write loader + compressed file
|
||||||
#ifdef TESTING
|
#if TESTING
|
||||||
if (opt->debug.debug_level)
|
if (opt->debug.debug_level)
|
||||||
printf("\n%d %d %d %d\n",(int)sizeof(oh),e_len,packedsize,d_len);
|
printf("\n%d %d %d %d\n",(int)sizeof(oh),e_len,packedsize,d_len);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_EXE_H
|
#ifndef __UPX_P_EXE_H
|
||||||
#define __UPX_P_EXE_H
|
#define __UPX_P_EXE_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+1246
-355
File diff suppressed because it is too large
Load Diff
+89
-22
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
Copyright (C) 2000-2009 John F. Reiser
|
Copyright (C) 2000-2011 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_LX_ELF_H //{
|
#ifndef __UPX_P_LX_ELF_H //{
|
||||||
#define __UPX_P_LX_ELF_H
|
#define __UPX_P_LX_ELF_H 1
|
||||||
|
|
||||||
|
|
||||||
class PackLinuxElf : public PackUnix
|
class PackLinuxElf : public PackUnix
|
||||||
@@ -61,17 +61,27 @@ protected:
|
|||||||
) = 0;
|
) = 0;
|
||||||
virtual void defineSymbols(Filter const *);
|
virtual void defineSymbols(Filter const *);
|
||||||
virtual void addStubEntrySections(Filter const *);
|
virtual void addStubEntrySections(Filter const *);
|
||||||
virtual void unpack(OutputFile *fo) = 0;
|
virtual void unpack(OutputFile *fo);
|
||||||
|
|
||||||
|
//virtual void const *elf_find_dynamic(unsigned) const = 0;
|
||||||
|
virtual acc_uint64l_t elf_unsigned_dynamic(unsigned) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
unsigned e_phnum; /* Program header table entry count */
|
||||||
char *file_image; // if ET_DYN investigation
|
char *file_image; // if ET_DYN investigation
|
||||||
char const *dynstr; // from DT_STRTAB
|
char const *dynstr; // from DT_STRTAB
|
||||||
|
|
||||||
unsigned sz_phdrs; // sizeof Phdr[]
|
unsigned sz_phdrs; // sizeof Phdr[]
|
||||||
unsigned sz_elf_hdrs; // all Elf headers
|
unsigned sz_elf_hdrs; // all Elf headers
|
||||||
unsigned sz_pack2; // after pack2(), before loader
|
unsigned sz_pack2; // after pack2(), before loader
|
||||||
|
unsigned sz_pack2a; // after pack2() of all PT_LOAD
|
||||||
|
unsigned sz_pack2b; // after pack2() of all PT_LOAD and gaps
|
||||||
unsigned lg2_page; // log2(PAGE_SIZE)
|
unsigned lg2_page; // log2(PAGE_SIZE)
|
||||||
unsigned page_size; // 1u<<lg2_page
|
unsigned page_size; // 1u<<lg2_page
|
||||||
|
unsigned xct_off; // shared library: file offset of SHT_EXECINSTR
|
||||||
|
unsigned hatch_off; // file offset of escape hatch
|
||||||
|
acc_uint64l_t load_va; // PT_LOAD[0].p_vaddr
|
||||||
|
acc_uint64l_t xct_va; // minimum SHT_EXECINSTR virtual address
|
||||||
|
|
||||||
unsigned short e_machine;
|
unsigned short e_machine;
|
||||||
unsigned char ei_class;
|
unsigned char ei_class;
|
||||||
@@ -94,6 +104,7 @@ protected:
|
|||||||
// but the class hierarchy splits after this class.
|
// but the class hierarchy splits after this class.
|
||||||
virtual void ARM_defineSymbols(Filter const *ft);
|
virtual void ARM_defineSymbols(Filter const *ft);
|
||||||
virtual void ARM_updateLoader(OutputFile *);
|
virtual void ARM_updateLoader(OutputFile *);
|
||||||
|
virtual int ARM_is_QNX(void);
|
||||||
|
|
||||||
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
virtual void pack2(OutputFile *, Filter &); // append compressed data
|
virtual void pack2(OutputFile *, Filter &); // append compressed data
|
||||||
@@ -122,15 +133,19 @@ protected:
|
|||||||
|
|
||||||
static unsigned elf_hash(char const *) /*const*/;
|
static unsigned elf_hash(char const *) /*const*/;
|
||||||
static unsigned gnu_hash(char const *) /*const*/;
|
static unsigned gnu_hash(char const *) /*const*/;
|
||||||
virtual void const *elf_find_dynamic(unsigned) const;
|
|
||||||
virtual Elf32_Sym const *elf_lookup(char const *) const;
|
virtual Elf32_Sym const *elf_lookup(char const *) const;
|
||||||
virtual unsigned elf_get_offset_from_address(unsigned) const;
|
virtual unsigned elf_get_offset_from_address(unsigned) const;
|
||||||
Elf32_Shdr const *elf_find_section_name(char const *) const;
|
Elf32_Shdr const *elf_find_section_name(char const *) const;
|
||||||
Elf32_Shdr const *elf_find_section_type(unsigned) const;
|
Elf32_Shdr const *elf_find_section_type(unsigned) const;
|
||||||
|
void const *elf_find_dynamic(unsigned) const;
|
||||||
|
Elf32_Dyn const *elf_has_dynamic(unsigned) const;
|
||||||
|
acc_uint64l_t elf_unsigned_dynamic(unsigned) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Elf32_Ehdr ehdri; // from input file
|
Elf32_Ehdr ehdri; // from input file
|
||||||
Elf32_Phdr *phdri; // for input file
|
Elf32_Phdr *phdri; // for input file
|
||||||
|
unsigned char *note_body; // concatenated contents of PT_NOTEs, if any
|
||||||
|
unsigned note_size; // total size of PT_NOTEs
|
||||||
Elf32_Shdr const *shdri; // from input file
|
Elf32_Shdr const *shdri; // from input file
|
||||||
unsigned page_mask; // AND clears the offset-within-page
|
unsigned page_mask; // AND clears the offset-within-page
|
||||||
|
|
||||||
@@ -163,23 +178,30 @@ protected:
|
|||||||
l_info linfo;
|
l_info linfo;
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
cprElfHdr3 elfout;
|
__packed_struct(cprElfHdrNetBSD)
|
||||||
|
Elf32_Ehdr ehdr;
|
||||||
|
Elf32_Phdr phdr[4];
|
||||||
|
unsigned char notes[512];
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
struct Elf32_Note {
|
cprElfHdrNetBSD elfout;
|
||||||
unsigned namesz; // 8
|
|
||||||
unsigned descsz; // 4
|
struct Elf32_Nhdr {
|
||||||
unsigned type; // 1
|
unsigned namesz;
|
||||||
char text[0x18 - 4*4]; // "OpenBSD"
|
unsigned descsz;
|
||||||
unsigned end; // 0
|
unsigned type;
|
||||||
} elfnote;
|
//unsigned char body[0];
|
||||||
|
};
|
||||||
|
|
||||||
static void compileTimeAssertions() {
|
static void compileTimeAssertions() {
|
||||||
COMPILE_TIME_ASSERT(sizeof(cprElfHdr1) == 52 + 1*32 + 12)
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr1) == 52 + 1*32 + 12)
|
||||||
COMPILE_TIME_ASSERT(sizeof(cprElfHdr2) == 52 + 2*32 + 12)
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr2) == 52 + 2*32 + 12)
|
||||||
COMPILE_TIME_ASSERT(sizeof(cprElfHdr3) == 52 + 3*32 + 12)
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr3) == 52 + 3*32 + 12)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdrNetBSD) == 52 + 4*32 + 512)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr1)
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr1)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr2)
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr2)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr3)
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr3)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdrNetBSD)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -219,11 +241,32 @@ protected:
|
|||||||
virtual unsigned find_LOAD_gap(Elf64_Phdr const *const phdri, unsigned const k,
|
virtual unsigned find_LOAD_gap(Elf64_Phdr const *const phdri, unsigned const k,
|
||||||
unsigned const e_phnum);
|
unsigned const e_phnum);
|
||||||
|
|
||||||
|
virtual acc_uint64l_t elf_get_offset_from_address(acc_uint64l_t) const;
|
||||||
|
Elf64_Shdr const *elf_find_section_name(char const *) const;
|
||||||
|
Elf64_Shdr const *elf_find_section_type(unsigned) const;
|
||||||
|
void const *elf_find_dynamic(unsigned) const;
|
||||||
|
Elf64_Dyn const *elf_has_dynamic(unsigned) const;
|
||||||
|
acc_uint64l_t elf_unsigned_dynamic(unsigned) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Elf64_Ehdr ehdri; // from input file
|
Elf64_Ehdr ehdri; // from input file
|
||||||
Elf64_Phdr *phdri; // for input file
|
Elf64_Phdr *phdri; // for input file
|
||||||
|
unsigned char *note_body; // concatenated contents of PT_NOTEs, if any
|
||||||
|
unsigned note_size; // total size of PT_NOTEs
|
||||||
|
Elf64_Shdr const *shdri; // from input file
|
||||||
acc_uint64l_t page_mask; // AND clears the offset-within-page
|
acc_uint64l_t page_mask; // AND clears the offset-within-page
|
||||||
|
|
||||||
|
Elf64_Dyn const *dynseg; // from PT_DYNAMIC
|
||||||
|
unsigned int const *hashtab; // from DT_HASH
|
||||||
|
unsigned int const *gashtab; // from DT_GNU_HASH
|
||||||
|
Elf64_Sym const *dynsym; // from DT_SYMTAB
|
||||||
|
char const *shstrtab; // via Elf64_Shdr
|
||||||
|
int n_elf_shnum; // via e_shnum
|
||||||
|
|
||||||
|
Elf64_Shdr const *sec_strndx;
|
||||||
|
Elf64_Shdr const *sec_dynsym;
|
||||||
|
Elf64_Shdr const *sec_dynstr;
|
||||||
|
|
||||||
__packed_struct(cprElfHdr1)
|
__packed_struct(cprElfHdr1)
|
||||||
Elf64_Ehdr ehdr;
|
Elf64_Ehdr ehdr;
|
||||||
Elf64_Phdr phdr[1];
|
Elf64_Phdr phdr[1];
|
||||||
@@ -242,15 +285,23 @@ protected:
|
|||||||
l_info linfo;
|
l_info linfo;
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
cprElfHdr3 elfout;
|
__packed_struct(cprElfHdr4)
|
||||||
|
Elf64_Ehdr ehdr;
|
||||||
|
Elf64_Phdr phdr[4];
|
||||||
|
l_info linfo;
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
cprElfHdr4 elfout;
|
||||||
|
|
||||||
static void compileTimeAssertions() {
|
static void compileTimeAssertions() {
|
||||||
COMPILE_TIME_ASSERT(sizeof(cprElfHdr1) == 64 + 1*56 + 12)
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr1) == 64 + 1*56 + 12)
|
||||||
COMPILE_TIME_ASSERT(sizeof(cprElfHdr2) == 64 + 2*56 + 12)
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr2) == 64 + 2*56 + 12)
|
||||||
COMPILE_TIME_ASSERT(sizeof(cprElfHdr3) == 64 + 3*56 + 12)
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr3) == 64 + 3*56 + 12)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr4) == 64 + 4*56 + 12)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr1)
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr1)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr2)
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr2)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr3)
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr3)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr4)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -258,21 +309,30 @@ class PackLinuxElf32Be : public PackLinuxElf32
|
|||||||
{
|
{
|
||||||
typedef PackLinuxElf32 super;
|
typedef PackLinuxElf32 super;
|
||||||
protected:
|
protected:
|
||||||
PackLinuxElf32Be(InputFile *f) : super(f) { bele = &N_BELE_RTP::be_policy; }
|
PackLinuxElf32Be(InputFile *f) : super(f) {
|
||||||
|
bele = &N_BELE_RTP::be_policy;
|
||||||
|
e_phnum = get_te16(&ehdri.e_phnum);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PackLinuxElf32Le : public PackLinuxElf32
|
class PackLinuxElf32Le : public PackLinuxElf32
|
||||||
{
|
{
|
||||||
typedef PackLinuxElf32 super;
|
typedef PackLinuxElf32 super;
|
||||||
protected:
|
protected:
|
||||||
PackLinuxElf32Le(InputFile *f) : super(f) { bele = &N_BELE_RTP::le_policy; }
|
PackLinuxElf32Le(InputFile *f) : super(f) {
|
||||||
|
bele = &N_BELE_RTP::le_policy;
|
||||||
|
e_phnum = get_te16(&ehdri.e_phnum);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PackLinuxElf64Le : public PackLinuxElf64
|
class PackLinuxElf64Le : public PackLinuxElf64
|
||||||
{
|
{
|
||||||
typedef PackLinuxElf64 super;
|
typedef PackLinuxElf64 super;
|
||||||
protected:
|
protected:
|
||||||
PackLinuxElf64Le(InputFile *f) : super(f) { bele = &N_BELE_RTP::le_policy; }
|
PackLinuxElf64Le(InputFile *f) : super(f) {
|
||||||
|
bele = &N_BELE_RTP::le_policy;
|
||||||
|
e_phnum = get_te16(&ehdri.e_phnum);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -336,8 +396,6 @@ public:
|
|||||||
virtual const char *getFullName(const options_t *) const { return "i386-linux.elf"; }
|
virtual const char *getFullName(const options_t *) const { return "i386-linux.elf"; }
|
||||||
virtual const int *getFilters() const;
|
virtual const int *getFilters() const;
|
||||||
|
|
||||||
virtual void unpack(OutputFile *fo);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
|
|
||||||
@@ -371,13 +429,21 @@ public:
|
|||||||
virtual const char *getFullName(const options_t *) const { return "i386-freebsd.elf"; }
|
virtual const char *getFullName(const options_t *) const { return "i386-freebsd.elf"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class PackNetBSDElf32x86 : public PackBSDElf32x86
|
class PackNetBSDElf32x86 : public PackLinuxElf32x86
|
||||||
{
|
{
|
||||||
typedef PackBSDElf32x86 super;
|
typedef PackLinuxElf32x86 super;
|
||||||
public:
|
public:
|
||||||
PackNetBSDElf32x86(InputFile *f);
|
PackNetBSDElf32x86(InputFile *f);
|
||||||
virtual ~PackNetBSDElf32x86();
|
virtual ~PackNetBSDElf32x86();
|
||||||
|
virtual const char *getName() const { return "netbsd/elf386"; }
|
||||||
virtual const char *getFullName(const options_t *) const { return "i386-netbsd.elf"; }
|
virtual const char *getFullName(const options_t *) const { return "i386-netbsd.elf"; }
|
||||||
|
protected:
|
||||||
|
virtual void buildLoader(const Filter *ft);
|
||||||
|
virtual void generateElfHdr(
|
||||||
|
OutputFile *,
|
||||||
|
void const *proto,
|
||||||
|
unsigned const brka
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
class PackOpenBSDElf32x86 : public PackBSDElf32x86
|
class PackOpenBSDElf32x86 : public PackBSDElf32x86
|
||||||
@@ -386,6 +452,7 @@ class PackOpenBSDElf32x86 : public PackBSDElf32x86
|
|||||||
public:
|
public:
|
||||||
PackOpenBSDElf32x86(InputFile *f);
|
PackOpenBSDElf32x86(InputFile *f);
|
||||||
virtual ~PackOpenBSDElf32x86();
|
virtual ~PackOpenBSDElf32x86();
|
||||||
|
virtual const char *getName() const { return "opnbsd/elf386"; }
|
||||||
virtual const char *getFullName(const options_t *) const { return "i386-openbsd.elf"; }
|
virtual const char *getFullName(const options_t *) const { return "i386-openbsd.elf"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
+5
-5
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
Copyright (C) 2001-2009 John F. Reiser
|
Copyright (C) 2001-2011 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -601,11 +601,11 @@ void PackLinuxI386::patchLoaderChecksum()
|
|||||||
// checksum for loader + p_info
|
// checksum for loader + p_info
|
||||||
lp->l_checksum = 0;
|
lp->l_checksum = 0;
|
||||||
lp->l_magic = UPX_ELF_MAGIC;
|
lp->l_magic = UPX_ELF_MAGIC;
|
||||||
lp->l_lsize = (unsigned short) lsize;
|
set_te16(&lp->l_lsize, (unsigned short) lsize);
|
||||||
lp->l_version = (unsigned char) ph.version;
|
lp->l_version = (unsigned char) ph.version;
|
||||||
lp->l_format = (unsigned char) ph.format;
|
lp->l_format = (unsigned char) ph.format;
|
||||||
// INFO: lp->l_checksum is currently unused
|
// INFO: lp->l_checksum is currently unused
|
||||||
lp->l_checksum = upx_adler32(ptr, lsize);
|
set_te32(&lp->l_checksum, upx_adler32(ptr, lsize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_LX_EXC_H
|
#ifndef __UPX_P_LX_EXC_H
|
||||||
#define __UPX_P_LX_EXC_H
|
#define __UPX_P_LX_EXC_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+4
-4
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
Copyright (C) 2000-2009 John F. Reiser
|
Copyright (C) 2000-2011 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -114,7 +114,7 @@ void PackLinuxElf32x86interp::pack1(OutputFile *fo, Filter &)
|
|||||||
h3.phdr[2].p_align = 1;
|
h3.phdr[2].p_align = 1;
|
||||||
|
|
||||||
if (opt->o_unix.make_ptinterp) { // unusual "once per release"
|
if (opt->o_unix.make_ptinterp) { // unusual "once per release"
|
||||||
elfout = h3;
|
*(cprElfHdr3 *)(void *)&elfout = h3;
|
||||||
elfout.ehdr.e_phnum = 1;
|
elfout.ehdr.e_phnum = 1;
|
||||||
fo->write(&elfout, elfout.ehdr.e_ehsize + elfout.ehdr.e_phentsize);
|
fo->write(&elfout, elfout.ehdr.e_ehsize + elfout.ehdr.e_phentsize);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
Copyright (C) 2000-2009 John F. Reiser
|
Copyright (C) 2000-2011 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_LX_INTERP_H //{
|
#ifndef __UPX_P_LX_INTERP_H //{
|
||||||
#define __UPX_P_LX_INTERP_H
|
#define __UPX_P_LX_INTERP_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+3
-3
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
Copyright (C) 2000-2009 John F. Reiser
|
Copyright (C) 2000-2011 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+4
-4
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
Copyright (C) 2000-2009 John F. Reiser
|
Copyright (C) 2000-2011 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_LX_SH_H //{
|
#ifndef __UPX_P_LX_SH_H //{
|
||||||
#define __UPX_P_LX_SH_H
|
#define __UPX_P_LX_SH_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+193
-18
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 2004-2009 John Reiser
|
Copyright (C) 2004-2011 John Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -70,6 +70,8 @@ static const
|
|||||||
|
|
||||||
static const
|
static const
|
||||||
#include "stub/powerpc-darwin.dylib-entry.h"
|
#include "stub/powerpc-darwin.dylib-entry.h"
|
||||||
|
static const
|
||||||
|
#include "stub/amd64-darwin.dylib-entry.h"
|
||||||
|
|
||||||
static const unsigned lc_segment[2] = {
|
static const unsigned lc_segment[2] = {
|
||||||
0x1, 0x19
|
0x1, 0x19
|
||||||
@@ -77,6 +79,12 @@ static const unsigned lc_segment[2] = {
|
|||||||
//Mach_segment_command::LC_SEGMENT_64
|
//Mach_segment_command::LC_SEGMENT_64
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const unsigned lc_routines[2] = {
|
||||||
|
0x11, 0x1a
|
||||||
|
//Mach_segment_command::LC_ROUTINES,
|
||||||
|
//Mach_segment_command::LC_ROUTINES_64
|
||||||
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
PackMachBase<T>::PackMachBase(InputFile *f, unsigned cputype, unsigned filetype,
|
PackMachBase<T>::PackMachBase(InputFile *f, unsigned cputype, unsigned filetype,
|
||||||
unsigned flavor, unsigned count, unsigned size) :
|
unsigned flavor, unsigned count, unsigned size) :
|
||||||
@@ -101,6 +109,11 @@ PackDylibI386::PackDylibI386(InputFile *f) : super(f)
|
|||||||
my_filetype = Mach_header::MH_DYLIB;
|
my_filetype = Mach_header::MH_DYLIB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PackDylibAMD64::PackDylibAMD64(InputFile *f) : super(f)
|
||||||
|
{
|
||||||
|
my_filetype = Mach_header::MH_DYLIB;
|
||||||
|
}
|
||||||
|
|
||||||
PackDylibPPC32::PackDylibPPC32(InputFile *f) : super(f)
|
PackDylibPPC32::PackDylibPPC32(InputFile *f) : super(f)
|
||||||
{
|
{
|
||||||
my_filetype = Mach_header::MH_DYLIB;
|
my_filetype = Mach_header::MH_DYLIB;
|
||||||
@@ -262,7 +275,7 @@ void PackMachI386::addStubEntrySections(Filter const *ft)
|
|||||||
addLoader("FOLDEXEC", NULL);
|
addLoader("FOLDEXEC", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackMachAMD64::addStubEntrySections(Filter const */*ft*/)
|
void PackMachAMD64::addStubEntrySections(Filter const * /*ft*/)
|
||||||
{
|
{
|
||||||
addLoader("MACHMAINX", NULL);
|
addLoader("MACHMAINX", NULL);
|
||||||
//addLoader(getDecompressorSections(), NULL);
|
//addLoader(getDecompressorSections(), NULL);
|
||||||
@@ -277,7 +290,7 @@ void PackMachAMD64::addStubEntrySections(Filter const */*ft*/)
|
|||||||
addLoader("MACHMAINY,IDENTSTR,+40,MACHMAINZ,FOLDEXEC", NULL);
|
addLoader("MACHMAINY,IDENTSTR,+40,MACHMAINZ,FOLDEXEC", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackMachARMEL::addStubEntrySections(Filter const */*ft*/)
|
void PackMachARMEL::addStubEntrySections(Filter const * /*ft*/)
|
||||||
{
|
{
|
||||||
addLoader("MACHMAINX", NULL);
|
addLoader("MACHMAINX", NULL);
|
||||||
//addLoader(getDecompressorSections(), NULL);
|
//addLoader(getDecompressorSections(), NULL);
|
||||||
@@ -386,6 +399,14 @@ PackDylibI386::buildLoader(const Filter *ft)
|
|||||||
0, 0, ft );
|
0, 0, ft );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PackDylibAMD64::buildLoader(const Filter *ft)
|
||||||
|
{
|
||||||
|
buildMachLoader(
|
||||||
|
stub_amd64_darwin_dylib_entry, sizeof(stub_amd64_darwin_dylib_entry),
|
||||||
|
0, 0, ft );
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PackDylibPPC32::buildLoader(const Filter *ft)
|
PackDylibPPC32::buildLoader(const Filter *ft)
|
||||||
{
|
{
|
||||||
@@ -408,11 +429,11 @@ void PackMachBase<T>::patchLoaderChecksum()
|
|||||||
// checksum for loader; also some PackHeader info
|
// checksum for loader; also some PackHeader info
|
||||||
lp->l_checksum = 0;
|
lp->l_checksum = 0;
|
||||||
lp->l_magic = UPX_MAGIC_LE32; // LE32 always
|
lp->l_magic = UPX_MAGIC_LE32; // LE32 always
|
||||||
lp->l_lsize = (unsigned short) lsize;
|
set_te16(&lp->l_lsize, (unsigned short) lsize);
|
||||||
lp->l_version = (unsigned char) ph.version;
|
lp->l_version = (unsigned char) ph.version;
|
||||||
lp->l_format = (unsigned char) ph.format;
|
lp->l_format = (unsigned char) ph.format;
|
||||||
// INFO: lp->l_checksum is currently unused
|
// INFO: lp->l_checksum is currently unused
|
||||||
lp->l_checksum = upx_adler32(ptr, lsize);
|
set_te32(&lp->l_checksum, upx_adler32(ptr, lsize));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -576,10 +597,60 @@ void PackMachBase<T>::pack4dylib( // append PackHeader
|
|||||||
Mach_section_command seccmdtmp;
|
Mach_section_command seccmdtmp;
|
||||||
for (unsigned j = 0; j < nsects; ++secp, ++j) {
|
for (unsigned j = 0; j < nsects; ++secp, ++j) {
|
||||||
seccmdtmp = *secp;
|
seccmdtmp = *secp;
|
||||||
seccmdtmp.offset += slide;
|
if (o_end_txt <= seccmdtmp.offset) { seccmdtmp.offset += slide; }
|
||||||
if (seccmdtmp.nreloc) {
|
if (o_end_txt <= seccmdtmp.reloff) { seccmdtmp.reloff += slide; }
|
||||||
seccmdtmp.reloff += slide;
|
if (0==strncmp(&seccmdtmp.sectname[0], "__mod_init_func", 1+ 15)) {
|
||||||
|
if (seccmdtmp.flags==9 // FIXME: S_MOD_INIT_FUNC_POINTERS
|
||||||
|
&& seccmdtmp.nreloc==0 && seccmdtmp.size==sizeof(Addr) ) {
|
||||||
|
seccmdtmp.addr = seccmdtmp.offset = init_address -4*4 - 8;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
infoWarning("unknown __mod_init_func section");
|
||||||
|
}
|
||||||
|
#if 0 /*{*/
|
||||||
|
// 2010-03-12 Stop work because I don't understand what is going on,
|
||||||
|
// and I cannot find good documentation on the meaning of various parts
|
||||||
|
// of .dylib. amd64(x86_64) is almost certain to fail in the dynamic
|
||||||
|
// loader, before the upx stub gets control. For instance:
|
||||||
|
//
|
||||||
|
// Program received signal EXC_BAD_ACCESS, Could not access memory.
|
||||||
|
// Reason: KERN_INVALID_ADDRESS at address: 0x000000015f00329a
|
||||||
|
// 0x00007fff5fc10ce3 in __dyld__ZN16ImageLoaderMachO23setupLazyPointerHandlerERKN11ImageLoader11LinkContextE ()
|
||||||
|
// (gdb) bt
|
||||||
|
// #0 0x00007fff5fc10ce3 in __dyld__ZN16ImageLoaderMachO23setupLazyPointerHandlerERKN11ImageLoader11LinkContextE ()
|
||||||
|
// #1 0x00007fff5fc138c2 in __dyld__ZN16ImageLoaderMachO6doBindERKN11ImageLoader11LinkContextEb ()
|
||||||
|
// #2 0x00007fff5fc0c0ab in __dyld__ZN11ImageLoader13recursiveBindERKNS_11LinkContextEb ()
|
||||||
|
// #3 0x00007fff5fc0c08f in __dyld__ZN11ImageLoader13recursiveBindERKNS_11LinkContextEb ()
|
||||||
|
// #4 0x00007fff5fc0f49e in __dyld__ZN11ImageLoader4linkERKNS_11LinkContextEbbRKNS_10RPathChainE ()
|
||||||
|
// #5 0x00007fff5fc04c56 in __dyld__ZN4dyld4linkEP11ImageLoaderbRKNS0_10RPathChainE ()
|
||||||
|
// #6 0x00007fff5fc06e04 in __dyld__ZN4dyld5_mainEPK11mach_headermiPPKcS5_S5_ ()
|
||||||
|
// #7 0x00007fff5fc01695 in __dyld__ZN13dyldbootstrap5startEPK11mach_headeriPPKcl ()
|
||||||
|
// #8 0x00007fff5fc0103a in __dyld__dyld_start ()
|
||||||
|
// #9 0x0000000100000000 in ?? ()
|
||||||
|
// #10 0x0000000000000001 in ?? ()
|
||||||
|
// #11 0x00007fff5fbffbd0 in ?? ()
|
||||||
|
//
|
||||||
|
// The various paragraphs below are experiments in "commenting out" pieces of
|
||||||
|
// the compressed .dylib, trying to isolate the bug(s).
|
||||||
|
// FIXME
|
||||||
|
unsigned const t = seccmdtmp.flags & 0xff;
|
||||||
|
if (t==6 // FIXME: S_NON_LAZY_SYMBOL_POINTERS
|
||||||
|
|| t==7 // FIXME: S_LAZY_SYMBOL_POINTERS
|
||||||
|
|| t==8 // FIXME: S_SYMBOL_STUBS
|
||||||
|
|| t==11 // FIXME: S_COALESCED
|
||||||
|
) {
|
||||||
|
seccmdtmp.flags = 0; // FIXME: S_REGULAR
|
||||||
|
strcpy(seccmdtmp.sectname, "__data");
|
||||||
|
}
|
||||||
|
// FIXME
|
||||||
|
if (0==strncmp("__stub_helper", &seccmdtmp.sectname[0], 1+ 13)) {
|
||||||
|
strcpy(seccmdtmp.sectname, "__text");
|
||||||
|
}
|
||||||
|
// FIXME
|
||||||
|
if (0==strncmp("__dyld", &seccmdtmp.sectname[0], 1+ 6)) {
|
||||||
|
strcpy(seccmdtmp.sectname, "__text");
|
||||||
|
}
|
||||||
|
#endif /*}*/
|
||||||
fo->rewrite(&seccmdtmp, sizeof(seccmdtmp));
|
fo->rewrite(&seccmdtmp, sizeof(seccmdtmp));
|
||||||
hdrpos += sizeof(seccmdtmp);
|
hdrpos += sizeof(seccmdtmp);
|
||||||
}
|
}
|
||||||
@@ -635,6 +706,11 @@ void PackDylibI386::pack4(OutputFile *fo, Filter &ft) // append PackHeader
|
|||||||
pack4dylib(fo, ft, threado.state.eip);
|
pack4dylib(fo, ft, threado.state.eip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PackDylibAMD64::pack4(OutputFile *fo, Filter &ft) // append PackHeader
|
||||||
|
{
|
||||||
|
pack4dylib(fo, ft, threado.state.rip);
|
||||||
|
}
|
||||||
|
|
||||||
void PackDylibPPC32::pack4(OutputFile *fo, Filter &ft) // append PackHeader
|
void PackDylibPPC32::pack4(OutputFile *fo, Filter &ft) // append PackHeader
|
||||||
{
|
{
|
||||||
pack4dylib(fo, ft, threado.state.srr0);
|
pack4dylib(fo, ft, threado.state.srr0);
|
||||||
@@ -719,6 +795,33 @@ void PackDylibI386::pack3(OutputFile *fo, Filter &ft) // append loader
|
|||||||
sz_mach_headers = save_sz_mach_headers;
|
sz_mach_headers = save_sz_mach_headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PackDylibAMD64::pack3(OutputFile *fo, Filter &ft) // append loader
|
||||||
|
{
|
||||||
|
TE32 disp;
|
||||||
|
TE64 disp64;
|
||||||
|
unsigned const zero = 0;
|
||||||
|
unsigned len = fo->getBytesWritten();
|
||||||
|
fo->write(&zero, 7& (0u-len));
|
||||||
|
len += (7& (0u-len)) + sizeof(disp64) + 4*sizeof(disp);
|
||||||
|
|
||||||
|
disp64= len;
|
||||||
|
fo->write(&disp64, sizeof(disp64)); // __mod_init_func
|
||||||
|
|
||||||
|
disp = prev_init_address;
|
||||||
|
fo->write(&disp, sizeof(disp)); // user .init_address
|
||||||
|
|
||||||
|
disp = sizeof(mhdro) + mhdro.sizeofcmds + sizeof(l_info) + sizeof(p_info);
|
||||||
|
fo->write(&disp, sizeof(disp)); // src offset(compressed __TEXT)
|
||||||
|
|
||||||
|
disp = len - disp - 3*sizeof(disp);
|
||||||
|
fo->write(&disp, sizeof(disp)); // length(compressed __TEXT)
|
||||||
|
|
||||||
|
unsigned const save_sz_mach_headers(sz_mach_headers);
|
||||||
|
sz_mach_headers = 0;
|
||||||
|
super::pack3(fo, ft);
|
||||||
|
sz_mach_headers = save_sz_mach_headers;
|
||||||
|
}
|
||||||
|
|
||||||
void PackDylibPPC32::pack3(OutputFile *fo, Filter &ft) // append loader
|
void PackDylibPPC32::pack3(OutputFile *fo, Filter &ft) // append loader
|
||||||
{
|
{
|
||||||
TE32 disp;
|
TE32 disp;
|
||||||
@@ -758,6 +861,8 @@ unsigned PackMachBase<T>::find_SEGMENT_gap(
|
|||||||
}
|
}
|
||||||
unsigned const hi = msegcmd[k].fileoff + msegcmd[k].filesize;
|
unsigned const hi = msegcmd[k].fileoff + msegcmd[k].filesize;
|
||||||
unsigned lo = ph.u_file_size;
|
unsigned lo = ph.u_file_size;
|
||||||
|
if (lo < hi)
|
||||||
|
throwCantPack("bad input: LC_SEGMENT beyond end-of-file");
|
||||||
unsigned j = k;
|
unsigned j = k;
|
||||||
for (;;) { // circular search, optimize for adjacent ascending
|
for (;;) { // circular search, optimize for adjacent ascending
|
||||||
++j;
|
++j;
|
||||||
@@ -769,7 +874,7 @@ unsigned PackMachBase<T>::find_SEGMENT_gap(
|
|||||||
}
|
}
|
||||||
if (lc_seg==msegcmd[j].cmd
|
if (lc_seg==msegcmd[j].cmd
|
||||||
&& 0!=msegcmd[j].filesize ) {
|
&& 0!=msegcmd[j].filesize ) {
|
||||||
unsigned const t = msegcmd[j].fileoff;
|
unsigned const t = (unsigned) msegcmd[j].fileoff;
|
||||||
if ((t - hi) < (lo - hi)) {
|
if ((t - hi) < (lo - hi)) {
|
||||||
lo = t;
|
lo = t;
|
||||||
if (hi==lo) {
|
if (hi==lo) {
|
||||||
@@ -832,7 +937,7 @@ void PackMachBase<T>::pack2(OutputFile *fo, Filter &ft) // append compressed bo
|
|||||||
if (lc_seg==msegcmd[k].cmd
|
if (lc_seg==msegcmd[k].cmd
|
||||||
&& 0!=(Mach_segment_command::VM_PROT_EXECUTE & msegcmd[k].initprot)
|
&& 0!=(Mach_segment_command::VM_PROT_EXECUTE & msegcmd[k].initprot)
|
||||||
&& exe_filesize_max < msegcmd[k].filesize) {
|
&& exe_filesize_max < msegcmd[k].filesize) {
|
||||||
exe_filesize_max = msegcmd[k].filesize;
|
exe_filesize_max = (unsigned) msegcmd[k].filesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nx = 0;
|
int nx = 0;
|
||||||
@@ -1069,10 +1174,11 @@ template <class T>
|
|||||||
bool PackMachBase<T>::canPack()
|
bool PackMachBase<T>::canPack()
|
||||||
{
|
{
|
||||||
unsigned const lc_seg = lc_segment[sizeof(Addr)>>3];
|
unsigned const lc_seg = lc_segment[sizeof(Addr)>>3];
|
||||||
|
unsigned const lc_rout = lc_routines[sizeof(Addr)>>3];
|
||||||
fi->seek(0, SEEK_SET);
|
fi->seek(0, SEEK_SET);
|
||||||
fi->readx(&mhdri, sizeof(mhdri));
|
fi->readx(&mhdri, sizeof(mhdri));
|
||||||
|
|
||||||
if ((Mach_header::MH_MAGIC + (sizeof(Addr)>>3)) !=mhdri.magic
|
if (((unsigned) Mach_header::MH_MAGIC + (sizeof(Addr)>>3)) !=mhdri.magic
|
||||||
|| my_cputype !=mhdri.cputype
|
|| my_cputype !=mhdri.cputype
|
||||||
|| my_filetype !=mhdri.filetype
|
|| my_filetype !=mhdri.filetype
|
||||||
)
|
)
|
||||||
@@ -1086,10 +1192,10 @@ bool PackMachBase<T>::canPack()
|
|||||||
unsigned char const *ptr = (unsigned char const *)rawmseg;
|
unsigned char const *ptr = (unsigned char const *)rawmseg;
|
||||||
for (unsigned j= 0; j < ncmds; ++j) {
|
for (unsigned j= 0; j < ncmds; ++j) {
|
||||||
msegcmd[j] = *(Mach_segment_command const *)ptr;
|
msegcmd[j] = *(Mach_segment_command const *)ptr;
|
||||||
if (((Mach_segment_command const *)ptr)->cmd ==
|
if (((Mach_segment_command const *)ptr)->cmd == lc_rout) {
|
||||||
Mach_segment_command::LC_ROUTINES) {
|
|
||||||
o_routines_cmd = (const char *)ptr - (const char *)rawmseg;
|
o_routines_cmd = (const char *)ptr - (const char *)rawmseg;
|
||||||
prev_init_address = ((Mach_routines_command const *)ptr)->init_address;
|
prev_init_address =
|
||||||
|
((Mach_routines_command const *)ptr)->init_address;
|
||||||
}
|
}
|
||||||
ptr += (unsigned) ((const Mach_segment_command *)ptr)->cmdsize;
|
ptr += (unsigned) ((const Mach_segment_command *)ptr)->cmdsize;
|
||||||
}
|
}
|
||||||
@@ -1170,6 +1276,7 @@ void PackMachFat::pack(OutputFile *fo)
|
|||||||
|
|
||||||
ph.u_file_size = fat_head.arch[j].size;
|
ph.u_file_size = fat_head.arch[j].size;
|
||||||
fi->set_extent(fat_head.arch[j].offset, fat_head.arch[j].size);
|
fi->set_extent(fat_head.arch[j].offset, fat_head.arch[j].size);
|
||||||
|
fi->seek(0, SEEK_SET);
|
||||||
switch (fat_head.arch[j].cputype) {
|
switch (fat_head.arch[j].cputype) {
|
||||||
case PackMachFat::CPU_TYPE_I386: {
|
case PackMachFat::CPU_TYPE_I386: {
|
||||||
typedef N_Mach::Mach_header<MachClass_LE32::MachITypes> Mach_header;
|
typedef N_Mach::Mach_header<MachClass_LE32::MachITypes> Mach_header;
|
||||||
@@ -1190,6 +1297,25 @@ void PackMachFat::pack(OutputFile *fo)
|
|||||||
packer.pack(fo);
|
packer.pack(fo);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case PackMachFat::CPU_TYPE_X86_64: {
|
||||||
|
typedef N_Mach::Mach_header<MachClass_LE64::MachITypes> Mach_header;
|
||||||
|
Mach_header hdr;
|
||||||
|
fi->readx(&hdr, sizeof(hdr));
|
||||||
|
if (hdr.filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
PackMachAMD64 packer(fi);
|
||||||
|
packer.initPackHeader();
|
||||||
|
packer.canPack();
|
||||||
|
packer.updatePackHeader();
|
||||||
|
packer.pack(fo);
|
||||||
|
}
|
||||||
|
else if (hdr.filetype==Mach_header::MH_DYLIB) {
|
||||||
|
PackDylibAMD64 packer(fi);
|
||||||
|
packer.initPackHeader();
|
||||||
|
packer.canPack();
|
||||||
|
packer.updatePackHeader();
|
||||||
|
packer.pack(fo);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
case PackMachFat::CPU_TYPE_POWERPC: {
|
case PackMachFat::CPU_TYPE_POWERPC: {
|
||||||
typedef N_Mach::Mach_header<MachClass_BE32::MachITypes> Mach_header;
|
typedef N_Mach::Mach_header<MachClass_BE32::MachITypes> Mach_header;
|
||||||
Mach_header hdr;
|
Mach_header hdr;
|
||||||
@@ -1225,18 +1351,23 @@ void PackMachFat::pack(OutputFile *fo)
|
|||||||
|
|
||||||
void PackMachFat::unpack(OutputFile *fo)
|
void PackMachFat::unpack(OutputFile *fo)
|
||||||
{
|
{
|
||||||
|
if (fo) { // test mode ("-t") sets fo = NULL
|
||||||
fo->seek(0, SEEK_SET);
|
fo->seek(0, SEEK_SET);
|
||||||
fo->write(&fat_head, sizeof(fat_head.fat) +
|
fo->write(&fat_head, sizeof(fat_head.fat) +
|
||||||
fat_head.fat.nfat_arch * sizeof(fat_head.arch[0]));
|
fat_head.fat.nfat_arch * sizeof(fat_head.arch[0]));
|
||||||
|
}
|
||||||
unsigned length;
|
unsigned length;
|
||||||
for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) {
|
for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) {
|
||||||
unsigned base = fo->unset_extent(); // actual length
|
unsigned base = (fo ? fo->unset_extent() : 0); // actual length
|
||||||
base += ~(~0u<<fat_head.arch[j].align) & (0-base); // align up
|
base += ~(~0u<<fat_head.arch[j].align) & (0-base); // align up
|
||||||
|
if (fo) {
|
||||||
fo->seek(base, SEEK_SET);
|
fo->seek(base, SEEK_SET);
|
||||||
fo->set_extent(base, ~0u);
|
fo->set_extent(base, ~0u);
|
||||||
|
}
|
||||||
|
|
||||||
ph.u_file_size = fat_head.arch[j].size;
|
ph.u_file_size = fat_head.arch[j].size;
|
||||||
fi->set_extent(fat_head.arch[j].offset, fat_head.arch[j].size);
|
fi->set_extent(fat_head.arch[j].offset, fat_head.arch[j].size);
|
||||||
|
fi->seek(0, SEEK_SET);
|
||||||
switch (fat_head.arch[j].cputype) {
|
switch (fat_head.arch[j].cputype) {
|
||||||
case PackMachFat::CPU_TYPE_I386: {
|
case PackMachFat::CPU_TYPE_I386: {
|
||||||
N_Mach::Mach_header<MachClass_LE32::MachITypes> hdr;
|
N_Mach::Mach_header<MachClass_LE32::MachITypes> hdr;
|
||||||
@@ -1255,6 +1386,23 @@ void PackMachFat::unpack(OutputFile *fo)
|
|||||||
packer.unpack(fo);
|
packer.unpack(fo);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case PackMachFat::CPU_TYPE_X86_64: {
|
||||||
|
N_Mach::Mach_header<MachClass_LE64::MachITypes> hdr;
|
||||||
|
typedef N_Mach::Mach_header<MachClass_LE64::MachITypes> Mach_header;
|
||||||
|
fi->readx(&hdr, sizeof(hdr));
|
||||||
|
if (hdr.filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
PackMachAMD64 packer(fi);
|
||||||
|
packer.initPackHeader();
|
||||||
|
packer.canUnpack();
|
||||||
|
packer.unpack(fo);
|
||||||
|
}
|
||||||
|
else if (hdr.filetype==Mach_header::MH_DYLIB) {
|
||||||
|
PackDylibAMD64 packer(fi);
|
||||||
|
packer.initPackHeader();
|
||||||
|
packer.canUnpack();
|
||||||
|
packer.unpack(fo);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
case PackMachFat::CPU_TYPE_POWERPC: {
|
case PackMachFat::CPU_TYPE_POWERPC: {
|
||||||
N_Mach::Mach_header<MachClass_BE32::MachITypes> hdr;
|
N_Mach::Mach_header<MachClass_BE32::MachITypes> hdr;
|
||||||
typedef N_Mach::Mach_header<MachClass_BE32::MachITypes> Mach_header;
|
typedef N_Mach::Mach_header<MachClass_BE32::MachITypes> Mach_header;
|
||||||
@@ -1274,13 +1422,15 @@ void PackMachFat::unpack(OutputFile *fo)
|
|||||||
} break;
|
} break;
|
||||||
} // switch cputype
|
} // switch cputype
|
||||||
fat_head.arch[j].offset = base;
|
fat_head.arch[j].offset = base;
|
||||||
length = fo->unset_extent();
|
length = (fo ? fo->unset_extent() : 0);
|
||||||
fat_head.arch[j].size = length - base;
|
fat_head.arch[j].size = length - base;
|
||||||
}
|
}
|
||||||
|
if (fo) {
|
||||||
fo->unset_extent();
|
fo->unset_extent();
|
||||||
fo->seek(0, SEEK_SET);
|
fo->seek(0, SEEK_SET);
|
||||||
fo->rewrite(&fat_head, sizeof(fat_head.fat) +
|
fo->rewrite(&fat_head, sizeof(fat_head.fat) +
|
||||||
fat_head.fat.nfat_arch * sizeof(fat_head.arch[0]));
|
fat_head.fat.nfat_arch * sizeof(fat_head.arch[0]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PackMachFat::canPack()
|
bool PackMachFat::canPack()
|
||||||
@@ -1294,8 +1444,12 @@ bool PackMachFat::canPack()
|
|||||||
}
|
}
|
||||||
for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) {
|
for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) {
|
||||||
fi->set_extent(fat_head.arch[j].offset, fat_head.arch[j].size);
|
fi->set_extent(fat_head.arch[j].offset, fat_head.arch[j].size);
|
||||||
|
fi->seek(0, SEEK_SET);
|
||||||
switch (arch[j].cputype) {
|
switch (arch[j].cputype) {
|
||||||
default: return false;
|
default:
|
||||||
|
infoWarning("unknown cputype 0x%x: %s",
|
||||||
|
(unsigned)arch[j].cputype, fi->getName());
|
||||||
|
return false;
|
||||||
case PackMachFat::CPU_TYPE_I386: {
|
case PackMachFat::CPU_TYPE_I386: {
|
||||||
PackMachI386 packer(fi);
|
PackMachI386 packer(fi);
|
||||||
if (!packer.canPack()) {
|
if (!packer.canPack()) {
|
||||||
@@ -1304,6 +1458,14 @@ bool PackMachFat::canPack()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case PackMachFat::CPU_TYPE_X86_64: {
|
||||||
|
PackMachAMD64 packer(fi);
|
||||||
|
if (!packer.canPack()) {
|
||||||
|
PackDylibI386 pack2r(fi);
|
||||||
|
if (!pack2r.canPack())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
case PackMachFat::CPU_TYPE_POWERPC: {
|
case PackMachFat::CPU_TYPE_POWERPC: {
|
||||||
PackMachPPC32 packer(fi);
|
PackMachPPC32 packer(fi);
|
||||||
if (!packer.canPack()) {
|
if (!packer.canPack()) {
|
||||||
@@ -1335,6 +1497,7 @@ int PackMachFat::canUnpack()
|
|||||||
}
|
}
|
||||||
for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) {
|
for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) {
|
||||||
fi->set_extent(fat_head.arch[j].offset, fat_head.arch[j].size);
|
fi->set_extent(fat_head.arch[j].offset, fat_head.arch[j].size);
|
||||||
|
fi->seek(0, SEEK_SET);
|
||||||
switch (arch[j].cputype) {
|
switch (arch[j].cputype) {
|
||||||
default: return false;
|
default: return false;
|
||||||
case PackMachFat::CPU_TYPE_I386: {
|
case PackMachFat::CPU_TYPE_I386: {
|
||||||
@@ -1349,6 +1512,18 @@ int PackMachFat::canUnpack()
|
|||||||
else
|
else
|
||||||
ph.format = packer.getFormat(); // FIXME: copy entire PackHeader
|
ph.format = packer.getFormat(); // FIXME: copy entire PackHeader
|
||||||
} break;
|
} break;
|
||||||
|
case PackMachFat::CPU_TYPE_X86_64: {
|
||||||
|
PackMachAMD64 packer(fi);
|
||||||
|
if (!packer.canUnpack()) {
|
||||||
|
PackDylibAMD64 pack2r(fi);
|
||||||
|
if (!pack2r.canUnpack())
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
ph.format = pack2r.getFormat(); // FIXME: copy entire PackHeader
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ph.format = packer.getFormat(); // FIXME: copy entire PackHeader
|
||||||
|
} break;
|
||||||
case PackMachFat::CPU_TYPE_POWERPC: {
|
case PackMachFat::CPU_TYPE_POWERPC: {
|
||||||
PackMachPPC32 packer(fi);
|
PackMachPPC32 packer(fi);
|
||||||
if (!packer.canUnpack()) {
|
if (!packer.canUnpack()) {
|
||||||
@@ -1366,7 +1541,7 @@ int PackMachFat::canUnpack()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackMachFat::buildLoader(const Filter */*ft*/)
|
void PackMachFat::buildLoader(const Filter * /*ft*/)
|
||||||
{
|
{
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|||||||
+84
-43
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_MACHO_H
|
#ifndef __UPX_P_MACHO_H
|
||||||
#define __UPX_P_MACHO_H
|
#define __UPX_P_MACHO_H 1
|
||||||
|
|
||||||
|
|
||||||
__packed_struct(Mach_fat_header)
|
__packed_struct(Mach_fat_header)
|
||||||
@@ -128,13 +128,37 @@ __packed_struct(Mach_section_command)
|
|||||||
char segname[16];
|
char segname[16];
|
||||||
Addr addr; /* memory address */
|
Addr addr; /* memory address */
|
||||||
Addr size; /* size in bytes */
|
Addr size; /* size in bytes */
|
||||||
Word offset; /* file offset */ // FIXME: 64 bit?
|
Word offset; /* file offset */
|
||||||
Word align; /* power of 2 */
|
Word align; /* power of 2 */
|
||||||
Word reloff; /* file offset of relocation entries */
|
Word reloff; /* file offset of relocation entries */
|
||||||
Word nreloc; /* number of relocation entries */
|
Word nreloc; /* number of relocation entries */
|
||||||
Word flags; /* section type and attributes */
|
Word flags; /* section type and attributes */
|
||||||
Word reserved1;
|
Word reserved1; /* for offset or index */
|
||||||
Word reserved2;
|
Word reserved2; /* for count or sizeof */
|
||||||
|
#define WANT_MACH_SECTION_ENUM 1
|
||||||
|
#include "p_mach_enum.h"
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
template <class TMachITypes>
|
||||||
|
__packed_struct(Mach_section_command_64)
|
||||||
|
typedef typename TMachITypes::Word Word;
|
||||||
|
typedef typename TMachITypes::Addr Addr;
|
||||||
|
typedef typename TMachITypes::Off Off;
|
||||||
|
typedef typename TMachITypes::Word Off32;
|
||||||
|
typedef typename TMachITypes::Xword Xword;
|
||||||
|
|
||||||
|
char sectname[16];
|
||||||
|
char segname[16];
|
||||||
|
Addr addr; /* memory address */
|
||||||
|
Addr size; /* size in bytes */
|
||||||
|
Off32 offset; /* file offset */
|
||||||
|
Word align; /* power of 2 */
|
||||||
|
Word reloff; /* file offset of relocation entries */
|
||||||
|
Word nreloc; /* number of relocation entries */
|
||||||
|
Word flags; /* section type and attributes */
|
||||||
|
Word reserved1; /* for offset or index */
|
||||||
|
Word reserved2; /* for count or sizeof */
|
||||||
|
Word reserved3; /* NOT IN 32-bit VERSION!! */
|
||||||
#define WANT_MACH_SECTION_ENUM 1
|
#define WANT_MACH_SECTION_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
@@ -143,12 +167,13 @@ template <class TMachITypes>
|
|||||||
__packed_struct(Mach_symtab_command)
|
__packed_struct(Mach_symtab_command)
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Off Off;
|
typedef typename TMachITypes::Off Off;
|
||||||
|
typedef typename TMachITypes::Word Off32;
|
||||||
|
|
||||||
Word cmd; /* LC_SYMTAB */
|
Word cmd; /* LC_SYMTAB */
|
||||||
Word cmdsize; /* sizeof(struct Mach_symtab_command) */
|
Word cmdsize; /* sizeof(struct Mach_symtab_command) */
|
||||||
Off symoff; /* symbol table offset */
|
Off32 symoff; /* symbol table offset */
|
||||||
Word nsyms; /* number of symbol table entries */
|
Word nsyms; /* number of symbol table entries */
|
||||||
Off stroff; /* string table offset */
|
Off32 stroff; /* string table offset */
|
||||||
Word strsize; /* string table size in bytes */
|
Word strsize; /* string table size in bytes */
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
@@ -156,6 +181,7 @@ template <class TMachITypes>
|
|||||||
__packed_struct(Mach_dysymtab_command)
|
__packed_struct(Mach_dysymtab_command)
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Off Off;
|
typedef typename TMachITypes::Off Off;
|
||||||
|
typedef typename TMachITypes::Word Off32;
|
||||||
|
|
||||||
Word cmd; /* LC_DYSYMTAB */
|
Word cmd; /* LC_DYSYMTAB */
|
||||||
Word cmdsize; /* sizeof(struct Mach_dysymtab_command) */
|
Word cmdsize; /* sizeof(struct Mach_dysymtab_command) */
|
||||||
@@ -165,17 +191,17 @@ __packed_struct(Mach_dysymtab_command)
|
|||||||
Word nextdefsym; /* number of externally defined symbols */
|
Word nextdefsym; /* number of externally defined symbols */
|
||||||
Word iundefsym; /* index to undefined symbols */
|
Word iundefsym; /* index to undefined symbols */
|
||||||
Word nundefsym; /* number of undefined symbols */
|
Word nundefsym; /* number of undefined symbols */
|
||||||
Off tocoff; /* file offset to table of contents */
|
Off32 tocoff; /* file offset to table of contents */
|
||||||
Word ntoc; /* number of entries in table of contents */
|
Word ntoc; /* number of entries in table of contents */
|
||||||
Off modtaboff; /* file offset to module table */
|
Off32 modtaboff; /* file offset to module table */
|
||||||
Word nmodtab; /* number of module table entries */
|
Word nmodtab; /* number of module table entries */
|
||||||
Off extrefsymoff; /* offset to referenced symbol table */
|
Off32 extrefsymoff; /* offset to referenced symbol table */
|
||||||
Word nextrefsymoff; /* number of referenced symbol table entries */
|
Word nextrefsymoff; /* number of referenced symbol table entries */
|
||||||
Off indirectsymoff; /* file offset to the indirect symbol table */
|
Off32 indirectsymoff; /* file offset to the indirect symbol table */
|
||||||
Word nindirectsyms; /* number of indirect symbol table entries */
|
Word nindirectsyms; /* number of indirect symbol table entries */
|
||||||
Off extreloff; /* offset to external relocation entries */
|
Off32 extreloff; /* offset to external relocation entries */
|
||||||
Word nextrel; /* number of external relocation entries */
|
Word nextrel; /* number of external relocation entries */
|
||||||
Off locreloff; /* offset to local relocation entries */
|
Off32 locreloff; /* offset to local relocation entries */
|
||||||
Word nlocrel; /* number of local relocation entries */
|
Word nlocrel; /* number of local relocation entries */
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
@@ -194,7 +220,6 @@ template <class TMachITypes>
|
|||||||
__packed_struct(Mach_routines_command)
|
__packed_struct(Mach_routines_command)
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Addr Addr;
|
typedef typename TMachITypes::Addr Addr;
|
||||||
typedef typename TMachITypes::Off Off;
|
|
||||||
|
|
||||||
Word cmd;
|
Word cmd;
|
||||||
Word cmdsize;
|
Word cmdsize;
|
||||||
@@ -210,6 +235,26 @@ __packed_struct(Mach_routines_command)
|
|||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
|
template <class TMachITypes>
|
||||||
|
__packed_struct(Mach_routines_command_64)
|
||||||
|
typedef typename TMachITypes::Word Word;
|
||||||
|
typedef typename TMachITypes::Addr Addr;
|
||||||
|
typedef typename TMachITypes::Xword Xword;
|
||||||
|
|
||||||
|
Word cmd;
|
||||||
|
Word cmdsize;
|
||||||
|
Addr init_address;
|
||||||
|
Xword init_module;
|
||||||
|
Xword reserved1;
|
||||||
|
Xword reserved2;
|
||||||
|
Xword reserved3;
|
||||||
|
Xword reserved4;
|
||||||
|
Xword reserved5;
|
||||||
|
Xword reserved6;
|
||||||
|
#define WANT_MACH_SEGMENT_ENUM 1
|
||||||
|
#include "p_mach_enum.h"
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_twolevel_hints_command)
|
__packed_struct(Mach_twolevel_hints_command)
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
@@ -318,26 +363,6 @@ __packed_struct(Mach_ppc_thread_state64)
|
|||||||
Word vrsave; /* Vector Save Register */
|
Word vrsave; /* Vector Save Register */
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
template <class TMachITypes>
|
|
||||||
__packed_struct(Mach_routines_command_64)
|
|
||||||
typedef typename TMachITypes::Word Word;
|
|
||||||
typedef typename TMachITypes::Addr Addr;
|
|
||||||
typedef typename TMachITypes::Xword Xword;
|
|
||||||
|
|
||||||
Word cmd;
|
|
||||||
Word cmdsize;
|
|
||||||
Addr init_address;
|
|
||||||
Xword init_module;
|
|
||||||
Xword reserved1;
|
|
||||||
Xword reserved2;
|
|
||||||
Xword reserved3;
|
|
||||||
Xword reserved4;
|
|
||||||
Xword reserved5;
|
|
||||||
Xword reserved6;
|
|
||||||
#define WANT_MACH_SEGMENT_ENUM 1
|
|
||||||
#include "p_mach_enum.h"
|
|
||||||
__packed_struct_end()
|
|
||||||
|
|
||||||
} // namespace N_Mach64
|
} // namespace N_Mach64
|
||||||
|
|
||||||
namespace N_Mach {
|
namespace N_Mach {
|
||||||
@@ -397,11 +422,11 @@ struct MachClass_64
|
|||||||
// Mach types
|
// Mach types
|
||||||
typedef N_Mach::Mach_header64<MachITypes> Mach_header;
|
typedef N_Mach::Mach_header64<MachITypes> Mach_header;
|
||||||
typedef N_Mach::Mach_segment_command<MachITypes> Mach_segment_command;
|
typedef N_Mach::Mach_segment_command<MachITypes> Mach_segment_command;
|
||||||
typedef N_Mach::Mach_section_command<MachITypes> Mach_section_command;
|
typedef N_Mach::Mach_section_command_64<MachITypes> Mach_section_command;
|
||||||
typedef N_Mach::Mach_symtab_command<MachITypes> Mach_symtab_command;
|
typedef N_Mach::Mach_symtab_command<MachITypes> Mach_symtab_command;
|
||||||
typedef N_Mach::Mach_dysymtab_command<MachITypes> Mach_dysymtab_command;
|
typedef N_Mach::Mach_dysymtab_command<MachITypes> Mach_dysymtab_command;
|
||||||
typedef N_Mach::Mach_segsplit_info_command<MachITypes> Mach_segsplit_info_command;
|
typedef N_Mach::Mach_segsplit_info_command<MachITypes> Mach_segsplit_info_command;
|
||||||
typedef N_Mach::Mach_routines_command<MachITypes> Mach_routines_command;
|
typedef N_Mach::Mach_routines_command_64<MachITypes> Mach_routines_command;
|
||||||
typedef N_Mach::Mach_twolevel_hints_command<MachITypes> Mach_twolevel_hints_command;
|
typedef N_Mach::Mach_twolevel_hints_command<MachITypes> Mach_twolevel_hints_command;
|
||||||
|
|
||||||
static void compileTimeAssertions() {
|
static void compileTimeAssertions() {
|
||||||
@@ -546,7 +571,7 @@ protected:
|
|||||||
Mach_segment_command *rawmseg; // as input, with sections
|
Mach_segment_command *rawmseg; // as input, with sections
|
||||||
Mach_segment_command *msegcmd; // LC_SEGMENT first, without sections
|
Mach_segment_command *msegcmd; // LC_SEGMENT first, without sections
|
||||||
unsigned o_routines_cmd; // file offset to LC_ROUINTES
|
unsigned o_routines_cmd; // file offset to LC_ROUINTES
|
||||||
unsigned prev_init_address;
|
acc_uint64l_t prev_init_address;
|
||||||
Mach_header mhdri;
|
Mach_header mhdri;
|
||||||
|
|
||||||
Mach_header mhdro;
|
Mach_header mhdro;
|
||||||
@@ -615,7 +640,7 @@ protected:
|
|||||||
BE32 flavor;
|
BE32 flavor;
|
||||||
BE32 count; /* sizeof(following_thread_state)/4 */
|
BE32 count; /* sizeof(following_thread_state)/4 */
|
||||||
Mach_ppc_thread_state state;
|
Mach_ppc_thread_state state;
|
||||||
#define WANT_MACH_THREAD_ENUM
|
#define WANT_MACH_THREAD_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
@@ -664,7 +689,7 @@ protected:
|
|||||||
LE32 flavor;
|
LE32 flavor;
|
||||||
LE32 count; /* sizeof(following_thread_state)/4 */
|
LE32 count; /* sizeof(following_thread_state)/4 */
|
||||||
Mach_i386_thread_state state;
|
Mach_i386_thread_state state;
|
||||||
#define WANT_MACH_THREAD_ENUM
|
#define WANT_MACH_THREAD_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
@@ -713,13 +738,29 @@ protected:
|
|||||||
LE32 flavor;
|
LE32 flavor;
|
||||||
LE32 count; /* sizeof(following_thread_state)/4 */
|
LE32 count; /* sizeof(following_thread_state)/4 */
|
||||||
Mach_AMD64_thread_state state;
|
Mach_AMD64_thread_state state;
|
||||||
#define WANT_MACH_THREAD_ENUM
|
#define WANT_MACH_THREAD_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
Mach_thread_command threado;
|
Mach_thread_command threado;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PackDylibAMD64 : public PackMachAMD64
|
||||||
|
{
|
||||||
|
typedef PackMachAMD64 super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PackDylibAMD64(InputFile *f);
|
||||||
|
|
||||||
|
virtual int getFormat() const { return UPX_F_DYLIB_AMD64; }
|
||||||
|
virtual const char *getName() const { return "Dylib/AMD64"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "AMD64-darwin.dylib"; }
|
||||||
|
protected:
|
||||||
|
virtual void pack3(OutputFile *, Filter &); // append loader
|
||||||
|
virtual void pack4(OutputFile *, Filter &); // append PackHeader
|
||||||
|
virtual void buildLoader(const Filter *ft);
|
||||||
|
};
|
||||||
|
|
||||||
class PackMachARMEL : public PackMachBase<MachClass_LE32>
|
class PackMachARMEL : public PackMachBase<MachClass_LE32>
|
||||||
{
|
{
|
||||||
typedef PackMachBase<MachClass_LE32> super;
|
typedef PackMachBase<MachClass_LE32> super;
|
||||||
@@ -747,7 +788,7 @@ protected:
|
|||||||
LE32 flavor;
|
LE32 flavor;
|
||||||
LE32 count; /* sizeof(following_thread_state)/4 */
|
LE32 count; /* sizeof(following_thread_state)/4 */
|
||||||
Mach_ARM_thread_state state;
|
Mach_ARM_thread_state state;
|
||||||
#define WANT_MACH_THREAD_ENUM
|
#define WANT_MACH_THREAD_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
@@ -800,7 +841,7 @@ protected:
|
|||||||
|
|
||||||
// linker
|
// linker
|
||||||
Linker *linker;
|
Linker *linker;
|
||||||
#define WANT_MACH_HEADER_ENUM
|
#define WANT_MACH_HEADER_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+21
-9
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 2007-2009 John F. Reiser
|
Copyright (C) 2007-2011 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -52,7 +52,8 @@
|
|||||||
};
|
};
|
||||||
enum { // filetype
|
enum { // filetype
|
||||||
MH_EXECUTE = 2,
|
MH_EXECUTE = 2,
|
||||||
MH_DYLIB = 6
|
MH_DYLIB = 6,
|
||||||
|
MH_BUNDLE = 8 /* dynamically bound bundle file */
|
||||||
};
|
};
|
||||||
enum { // flags
|
enum { // flags
|
||||||
MH_NOUNDEFS = 1
|
MH_NOUNDEFS = 1
|
||||||
@@ -79,6 +80,9 @@
|
|||||||
LC_CODE_SIGNATURE = 0x1d,
|
LC_CODE_SIGNATURE = 0x1d,
|
||||||
LC_SEGMENT_SPLIT_INFO = 0x1e,
|
LC_SEGMENT_SPLIT_INFO = 0x1e,
|
||||||
LC_REEXPORT_DYLIB = 0x1f,
|
LC_REEXPORT_DYLIB = 0x1f,
|
||||||
|
LC_LAZY_LOAD_DYLIB= 0X20,
|
||||||
|
LC_ENCRYPTION_INFO= 0X21,
|
||||||
|
LC_DYLD_INFO = 0X22, // compressed dyld information (10.6.x)
|
||||||
LC_REQ_DYLD = 0x80000000 // OR'ed ==> must not ignore
|
LC_REQ_DYLD = 0x80000000 // OR'ed ==> must not ignore
|
||||||
};
|
};
|
||||||
enum { // maxprot
|
enum { // maxprot
|
||||||
@@ -90,24 +94,32 @@
|
|||||||
|
|
||||||
#ifdef WANT_MACH_SECTION_ENUM /*{*/
|
#ifdef WANT_MACH_SECTION_ENUM /*{*/
|
||||||
#undef WANT_MACH_SECTION_ENUM
|
#undef WANT_MACH_SECTION_ENUM
|
||||||
enum { // section flags
|
enum { // section type (low byte only)
|
||||||
S_REGULAR = 0,
|
S_REGULAR = 0,
|
||||||
S_ZEROFILL,
|
S_ZEROFILL,
|
||||||
S_CSTRING_LITERALS,
|
S_CSTRING_LITERALS,
|
||||||
S_4BYTE_LITERALS,
|
S_4BYTE_LITERALS,
|
||||||
S_8BYTE_LITERALS,
|
S_8BYTE_LITERALS,
|
||||||
S_LITERAL_POINTERS,
|
S_LITERAL_POINTERS,
|
||||||
S_NON_LAZY_SYMBOL_POINTERS,
|
S_NON_LAZY_SYMBOL_POINTERS, // sectname __nl_symbol_ptr
|
||||||
S_LAZY_SYMBOL_POINTERS,
|
S_LAZY_SYMBOL_POINTERS, // sectname __la_symbol_ptr
|
||||||
S_SYMBOL_STUBS,
|
S_SYMBOL_STUBS,
|
||||||
S_MOD_INIT_FUNC_POINTERS,
|
S_MOD_INIT_FUNC_POINTERS, // sectname __mod_init_func
|
||||||
S_MOD_TERM_FNC_POINTERS,
|
S_MOD_TERM_FUNC_POINTERS,
|
||||||
S_COALESCED
|
S_COALESCED,
|
||||||
|
S_GB_ZEROFILL,
|
||||||
|
S_INTERPOSING,
|
||||||
|
S_16BYTE_LITERALS,
|
||||||
|
S_DTRACE_DOF
|
||||||
};
|
};
|
||||||
enum {
|
enum { // section flags (high 24 bits)
|
||||||
S_ATTR_PURE_INSTRUCTIONS = 0x80000000,
|
S_ATTR_PURE_INSTRUCTIONS = 0x80000000,
|
||||||
S_ATTR_NO_TOC = 0x40000000,
|
S_ATTR_NO_TOC = 0x40000000,
|
||||||
S_ATTR_STRIP_STATIC_SYMS = 0x20000000,
|
S_ATTR_STRIP_STATIC_SYMS = 0x20000000,
|
||||||
|
S_ATTR_NO_DEAD_STRIP = 0x10000000,
|
||||||
|
S_ATTR_LIVE_SUPPORT = 0x08000000,
|
||||||
|
S_ATTR_SELF_MODIFYING_CODE = 0x04000000,
|
||||||
|
S_ATTR_DEBUG = 0x02000000,
|
||||||
S_ATTR_SOME_INSTRUCTIONS = 0x00000400,
|
S_ATTR_SOME_INSTRUCTIONS = 0x00000400,
|
||||||
S_ATTR_EXT_RELOC = 0x00000200,
|
S_ATTR_EXT_RELOC = 0x00000200,
|
||||||
S_ATTR_LOC_RELOC = 0x00000100
|
S_ATTR_LOC_RELOC = 0x00000100
|
||||||
|
|||||||
+3
-3
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
Copyright (C) 2002-2009 Jens Medoch
|
Copyright (C) 2002-2011 Jens Medoch
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+4
-4
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
Copyright (C) 2002-2009 Jens Medoch
|
Copyright (C) 2002-2011 Jens Medoch
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_PS1_H
|
#ifndef __UPX_P_PS1_H
|
||||||
#define __UPX_P_PS1_H
|
#define __UPX_P_PS1_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_SYS_H
|
#ifndef __UPX_P_SYS_H
|
||||||
#define __UPX_P_SYS_H
|
#define __UPX_P_SYS_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+5
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -327,7 +327,9 @@ void PackTmt::unpack(OutputFile *fo)
|
|||||||
{
|
{
|
||||||
Filter ft(ph.level);
|
Filter ft(ph.level);
|
||||||
ft.init(ph.filter, 0);
|
ft.init(ph.filter, 0);
|
||||||
ft.cto = (unsigned char) (ph.version < 11 ? (get_le32(obuf+ph.u_len-12) >> 24) : ph.filter_cto);
|
ft.cto = (unsigned char) ph.filter_cto;
|
||||||
|
if (ph.version < 11)
|
||||||
|
ft.cto = (unsigned char) (get_le32(obuf+ph.u_len-12) >> 24);
|
||||||
ft.unfilter(obuf, ptr_diff(relocs, obuf));
|
ft.unfilter(obuf, ptr_diff(relocs, obuf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_TMT_H
|
#ifndef __UPX_P_TMT_H
|
||||||
#define __UPX_P_TMT_H
|
#define __UPX_P_TMT_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+6
-6
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -446,7 +446,7 @@ void PackTos::pack(OutputFile *fo)
|
|||||||
overlay = file_size - (FH_SIZE + i_text + i_data + i_sym);
|
overlay = file_size - (FH_SIZE + i_text + i_data + i_sym);
|
||||||
fi->readx(ibuf+t,overlay);
|
fi->readx(ibuf+t,overlay);
|
||||||
|
|
||||||
#if 0 || defined(TESTING)
|
#if 0 || (TESTING)
|
||||||
printf("text: %d, data: %d, sym: %d, bss: %d, flags=0x%x\n",
|
printf("text: %d, data: %d, sym: %d, bss: %d, flags=0x%x\n",
|
||||||
i_text, i_data, i_sym, i_bss, (int)ih.fh_flag);
|
i_text, i_data, i_sym, i_bss, (int)ih.fh_flag);
|
||||||
printf("xx1 reloc: %d, overlay: %d, fixup: %d\n", relocsize, overlay, overlay >= 4 ? (int)get_be32(ibuf+t) : -1);
|
printf("xx1 reloc: %d, overlay: %d, fixup: %d\n", relocsize, overlay, overlay >= 4 ? (int)get_be32(ibuf+t) : -1);
|
||||||
@@ -476,7 +476,7 @@ void PackTos::pack(OutputFile *fo)
|
|||||||
symbols.need_reloc = true;
|
symbols.need_reloc = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 || defined(TESTING)
|
#if 0 || (TESTING)
|
||||||
printf("xx2: %d relocs: %d, overlay: %d, t: %d\n", nrelocs, relocsize, overlay, t);
|
printf("xx2: %d relocs: %d, overlay: %d, t: %d\n", nrelocs, relocsize, overlay, t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -487,7 +487,7 @@ void PackTos::pack(OutputFile *fo)
|
|||||||
ih.fh_sym = 0; // we stripped all symbols
|
ih.fh_sym = 0; // we stripped all symbols
|
||||||
memcpy(ibuf+t, &ih, FH_SIZE);
|
memcpy(ibuf+t, &ih, FH_SIZE);
|
||||||
t += FH_SIZE;
|
t += FH_SIZE;
|
||||||
#if 0 || defined(TESTING)
|
#if 0 || (TESTING)
|
||||||
printf("xx3 reloc: %d, overlay: %d, t: %d\n", relocsize, overlay, t);
|
printf("xx3 reloc: %d, overlay: %d, t: %d\n", relocsize, overlay, t);
|
||||||
#endif
|
#endif
|
||||||
assert(t <= isize);
|
assert(t <= isize);
|
||||||
@@ -686,7 +686,7 @@ void PackTos::pack(OutputFile *fo)
|
|||||||
// add an empty relocation fixup to workaround a bug in some TOS versions
|
// add an empty relocation fixup to workaround a bug in some TOS versions
|
||||||
oh.fh_reloc = 0;
|
oh.fh_reloc = 0;
|
||||||
|
|
||||||
#if 0 || defined(TESTING)
|
#if 0 || (TESTING)
|
||||||
printf("old text: %6d, data: %6d, bss: %6d, reloc: %d, overlay: %d\n",
|
printf("old text: %6d, data: %6d, bss: %6d, reloc: %d, overlay: %d\n",
|
||||||
i_text, i_data, i_bss, relocsize, overlay);
|
i_text, i_data, i_bss, relocsize, overlay);
|
||||||
printf("new text: %6d, data: %6d, bss: %6d, flag=0x%x\n",
|
printf("new text: %6d, data: %6d, bss: %6d, flag=0x%x\n",
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_TOS_H
|
#ifndef __UPX_P_TOS_H
|
||||||
#define __UPX_P_TOS_H
|
#define __UPX_P_TOS_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+8
-8
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -231,11 +231,11 @@ PackUnix::patchLoaderChecksum()
|
|||||||
l_info *const lp = &linfo;
|
l_info *const lp = &linfo;
|
||||||
// checksum for loader; also some PackHeader info
|
// checksum for loader; also some PackHeader info
|
||||||
lp->l_magic = UPX_MAGIC_LE32; // LE32 always
|
lp->l_magic = UPX_MAGIC_LE32; // LE32 always
|
||||||
lp->l_lsize = (unsigned short) lsize;
|
set_te16(&lp->l_lsize, (unsigned short) lsize);
|
||||||
lp->l_version = (unsigned char) ph.version;
|
lp->l_version = (unsigned char) ph.version;
|
||||||
lp->l_format = (unsigned char) ph.format;
|
lp->l_format = (unsigned char) ph.format;
|
||||||
// INFO: lp->l_checksum is currently unused
|
// INFO: lp->l_checksum is currently unused
|
||||||
lp->l_checksum = upx_adler32(ptr, lsize);
|
set_te32(&lp->l_checksum, upx_adler32(ptr, lsize));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackUnix::pack3(OutputFile *fo, Filter &/*ft*/)
|
void PackUnix::pack3(OutputFile *fo, Filter &/*ft*/)
|
||||||
@@ -412,6 +412,9 @@ void PackUnix::packExtent(
|
|||||||
fo->write(&tmp, sizeof(tmp));
|
fo->write(&tmp, sizeof(tmp));
|
||||||
b_len += sizeof(b_info);
|
b_len += sizeof(b_info);
|
||||||
|
|
||||||
|
if (ft) {
|
||||||
|
ph.u_adler = end_u_adler;
|
||||||
|
}
|
||||||
// write compressed data
|
// write compressed data
|
||||||
if (ph.c_len < ph.u_len) {
|
if (ph.c_len < ph.u_len) {
|
||||||
fo->write(obuf, ph.c_len);
|
fo->write(obuf, ph.c_len);
|
||||||
@@ -422,9 +425,6 @@ void PackUnix::packExtent(
|
|||||||
fo->write(ibuf, ph.u_len);
|
fo->write(ibuf, ph.u_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ft) {
|
|
||||||
ph.u_adler = end_u_adler;
|
|
||||||
}
|
|
||||||
total_in += ph.u_len;
|
total_in += ph.u_len;
|
||||||
total_out += ph.c_len;
|
total_out += ph.c_len;
|
||||||
}
|
}
|
||||||
@@ -498,7 +498,7 @@ void PackUnix::unpackExtent(unsigned wanted, OutputFile *fo,
|
|||||||
|
|
||||||
int PackUnix::canUnpack()
|
int PackUnix::canUnpack()
|
||||||
{
|
{
|
||||||
upx_byte buf[128];
|
upx_byte buf[sizeof(overlay_offset) + 32];
|
||||||
const int bufsize = sizeof(buf);
|
const int bufsize = sizeof(buf);
|
||||||
|
|
||||||
fi->seek(-bufsize, SEEK_END);
|
fi->seek(-bufsize, SEEK_END);
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_UNIX_H
|
#ifndef __UPX_P_UNIX_H
|
||||||
#define __UPX_P_UNIX_H
|
#define __UPX_P_UNIX_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+12
-8
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 2004-2009 John Reiser
|
Copyright (C) 2004-2011 John Reiser
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -322,6 +322,7 @@ void PackVmlinuxBase<T>::pack(OutputFile *fo)
|
|||||||
unsigned const frag = (3& (0u-len_cpr));
|
unsigned const frag = (3& (0u-len_cpr));
|
||||||
ppc32_extra += sizeof(hdr_info) + len_cpr + frag;
|
ppc32_extra += sizeof(hdr_info) + len_cpr + frag;
|
||||||
fo_off += len_cpr + frag;
|
fo_off += len_cpr + frag;
|
||||||
|
memset(&cpr_hdr[len_cpr], 0, frag); // valgrind only
|
||||||
fo->write(cpr_hdr, len_cpr + frag);
|
fo->write(cpr_hdr, len_cpr + frag);
|
||||||
|
|
||||||
// Partial filter: .text and following contiguous SHF_EXECINSTR
|
// Partial filter: .text and following contiguous SHF_EXECINSTR
|
||||||
@@ -986,11 +987,14 @@ void PackVmlinuxPPC32::buildLoader(const Filter *ft)
|
|||||||
addFilter32(ft->id);
|
addFilter32(ft->id);
|
||||||
}
|
}
|
||||||
addLoader("LINUX030", NULL);
|
addLoader("LINUX030", NULL);
|
||||||
if (ph.method == M_NRV2E_LE32) addLoader("NRV2E", NULL);
|
if (ph.method == M_NRV2E_LE32) addLoader("NRV2E,NRV_TAIL", NULL);
|
||||||
else if (ph.method == M_NRV2B_LE32) addLoader("NRV2B", NULL);
|
else if (ph.method == M_NRV2B_LE32) addLoader("NRV2B,NRV_TAIL", NULL);
|
||||||
else if (ph.method == M_NRV2D_LE32) addLoader("NRV2D", NULL);
|
else if (ph.method == M_NRV2D_LE32) addLoader("NRV2D,NRV_TAIL", NULL);
|
||||||
else if (M_IS_LZMA(ph.method)) addLoader("LZMA_ELF00,LZMA_DEC10,LZMA_DEC30", NULL);
|
else if (M_IS_LZMA(ph.method)) addLoader("LZMA_ELF00,LZMA_DEC10,LZMA_DEC30", NULL);
|
||||||
else throwBadLoader();
|
else throwBadLoader();
|
||||||
|
if (hasLoaderSection("CFLUSH"))
|
||||||
|
addLoader("CFLUSH");
|
||||||
|
|
||||||
addLoader("IDENTSTR,UPX1HEAD", NULL);
|
addLoader("IDENTSTR,UPX1HEAD", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1075,8 +1079,8 @@ void PackVmlinuxAMD64::defineDecompressorSymbols()
|
|||||||
// We assume a 32-bit boot loader, so we use the 32-bit convention
|
// We assume a 32-bit boot loader, so we use the 32-bit convention
|
||||||
// of "enter at the beginning" (startup_32). The 64-bit convention
|
// of "enter at the beginning" (startup_32). The 64-bit convention
|
||||||
// would be to use ehdri.e_entry (startup_64).
|
// would be to use ehdri.e_entry (startup_64).
|
||||||
linker->defineSymbol("ENTRY_POINT", phdri[0].p_paddr);
|
linker->defineSymbol("ENTRY_POINT", (unsigned) phdri[0].p_paddr);
|
||||||
linker->defineSymbol("PHYSICAL_START", phdri[0].p_paddr);
|
linker->defineSymbol("PHYSICAL_START", (unsigned) phdri[0].p_paddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned PackVmlinuxARMEL::write_vmlinux_head(
|
unsigned PackVmlinuxARMEL::write_vmlinux_head(
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_VMLINX_H
|
#ifndef __UPX_P_VMLINX_H
|
||||||
#define __UPX_P_VMLINX_H
|
#define __UPX_P_VMLINX_H 1
|
||||||
|
|
||||||
#include "p_elf.h"
|
#include "p_elf.h"
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_VMLINZ_H
|
#ifndef __UPX_P_VMLINZ_H
|
||||||
#define __UPX_P_VMLINZ_H
|
#define __UPX_P_VMLINZ_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_VXD_H
|
#ifndef __UPX_P_VXD_H
|
||||||
#define __UPX_P_VXD_H
|
#define __UPX_P_VXD_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_W16NE_H
|
#ifndef __UPX_P_W16NE_H
|
||||||
#define __UPX_P_W16NE_H
|
#define __UPX_P_W16NE_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|||||||
+270
-14
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2009 Laszlo Molnar
|
Copyright (C) 1996-2011 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -123,6 +123,7 @@ PackW32Pe::PackW32Pe(InputFile *f) : super(f)
|
|||||||
isrtm = false;
|
isrtm = false;
|
||||||
use_dep_hack = true;
|
use_dep_hack = true;
|
||||||
use_clear_dirty_stack = true;
|
use_clear_dirty_stack = true;
|
||||||
|
use_tls_callbacks = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -168,6 +169,142 @@ int PackW32Pe::readFileHeader()
|
|||||||
return super::readFileHeader();
|
return super::readFileHeader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//new: processTLS moved to p_w32pe.cpp for TLS callback support
|
||||||
|
/*************************************************************************
|
||||||
|
// TLS handling
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
// thanks for theowl for providing me some docs, so that now I understand
|
||||||
|
// what I'm doing here :)
|
||||||
|
|
||||||
|
// 1999-10-17: this was tricky to find:
|
||||||
|
// when the fixup records and the tls area are on the same page, then
|
||||||
|
// the tls area is not relocated, because the relocation is done by
|
||||||
|
// the virtual memory manager only for pages which are not yet loaded.
|
||||||
|
// of course it was impossible to debug this ;-)
|
||||||
|
|
||||||
|
#define TLS_CB_ALIGNMENT 4u // alignment of tls callbacks
|
||||||
|
|
||||||
|
__packed_struct(tls)
|
||||||
|
LE32 datastart; // VA tls init data start
|
||||||
|
LE32 dataend; // VA tls init data end
|
||||||
|
LE32 tlsindex; // VA tls index
|
||||||
|
LE32 callbacks; // VA tls callbacks
|
||||||
|
char _[8]; // zero init, characteristics
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
void PackW32Pe::processTls(Interval *iv) // pass 1
|
||||||
|
{
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(tls) == 24)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(tls)
|
||||||
|
|
||||||
|
if ((sotls = ALIGN_UP(IDSIZE(PEDIR_TLS),4)) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const tls * const tlsp = (const tls*) (ibuf + IDADDR(PEDIR_TLS));
|
||||||
|
|
||||||
|
// note: TLS callbacks are not implemented in Windows 95/98/ME
|
||||||
|
if (tlsp->callbacks)
|
||||||
|
{
|
||||||
|
if (tlsp->callbacks < ih.imagebase)
|
||||||
|
throwCantPack("invalid TLS callback");
|
||||||
|
else if (tlsp->callbacks - ih.imagebase + 4 >= ih.imagesize)
|
||||||
|
throwCantPack("invalid TLS callback");
|
||||||
|
unsigned v = get_le32(ibuf + tlsp->callbacks - ih.imagebase);
|
||||||
|
|
||||||
|
//NEW: TLS callback support - Stefan Widmann
|
||||||
|
if(v != 0)
|
||||||
|
{
|
||||||
|
//count number of callbacks, just for information string - Stefan Widmann
|
||||||
|
unsigned num_callbacks = 0;
|
||||||
|
unsigned callback_offset = 0;
|
||||||
|
while(get_le32(ibuf + tlsp->callbacks - ih.imagebase + callback_offset))
|
||||||
|
{
|
||||||
|
//increment number of callbacks
|
||||||
|
num_callbacks++;
|
||||||
|
//increment pointer by 4
|
||||||
|
callback_offset += 4;
|
||||||
|
}
|
||||||
|
info("TLS: %u callback(s) found, adding TLS callback handler", num_callbacks);
|
||||||
|
//set flag to include necessary sections in loader
|
||||||
|
use_tls_callbacks = true;
|
||||||
|
//define linker symbols
|
||||||
|
tlscb_ptr = tlsp->callbacks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const unsigned tlsdatastart = tlsp->datastart - ih.imagebase;
|
||||||
|
const unsigned tlsdataend = tlsp->dataend - ih.imagebase;
|
||||||
|
|
||||||
|
// now some ugly stuff: find the relocation entries in the tls data area
|
||||||
|
unsigned pos,type;
|
||||||
|
Reloc rel(ibuf + IDADDR(PEDIR_RELOC),IDSIZE(PEDIR_RELOC));
|
||||||
|
while (rel.next(pos,type))
|
||||||
|
if (pos >= tlsdatastart && pos < tlsdataend)
|
||||||
|
iv->add(pos,type);
|
||||||
|
|
||||||
|
sotls = sizeof(tls) + tlsdataend - tlsdatastart;
|
||||||
|
// if TLS callbacks are used, we need two more DWORDS at the end of the TLS
|
||||||
|
// ... and those dwords should be correctly aligned
|
||||||
|
if (use_tls_callbacks)
|
||||||
|
sotls = ALIGN_UP(sotls, TLS_CB_ALIGNMENT) + 8;
|
||||||
|
|
||||||
|
// the PE loader wants this stuff uncompressed
|
||||||
|
otls = new upx_byte[sotls];
|
||||||
|
memset(otls,0,sotls);
|
||||||
|
memcpy(otls,ibuf + IDADDR(PEDIR_TLS),sizeof(tls));
|
||||||
|
// WARNING: this can acces data in BSS
|
||||||
|
memcpy(otls + sizeof(tls),ibuf + tlsdatastart,sotls - sizeof(tls));
|
||||||
|
tlsindex = tlsp->tlsindex - ih.imagebase;
|
||||||
|
//NEW: subtract two dwords if TLS callbacks are used - Stefan Widmann
|
||||||
|
info("TLS: %u bytes tls data and %u relocations added",sotls - (unsigned) sizeof(tls) - (use_tls_callbacks ? 8 : 0),iv->ivnum);
|
||||||
|
|
||||||
|
// makes sure tls index is zero after decompression
|
||||||
|
if (tlsindex && tlsindex < ih.imagesize)
|
||||||
|
set_le32(ibuf + tlsindex, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PackW32Pe::processTls(Reloc *rel,const Interval *iv,unsigned newaddr) // pass 2
|
||||||
|
{
|
||||||
|
if (sotls == 0)
|
||||||
|
return;
|
||||||
|
// add new relocation entries
|
||||||
|
unsigned ic;
|
||||||
|
//NEW: if TLS callbacks are used, relocate the VA of the callback chain, too - Stefan Widmann
|
||||||
|
for (ic = 0; ic < (use_tls_callbacks ? 16u : 12u); ic += 4)
|
||||||
|
rel->add(newaddr + ic,3);
|
||||||
|
|
||||||
|
tls * const tlsp = (tls*) otls;
|
||||||
|
// now the relocation entries in the tls data area
|
||||||
|
for (ic = 0; ic < iv->ivnum; ic += 4)
|
||||||
|
{
|
||||||
|
void *p = otls + iv->ivarr[ic].start - (tlsp->datastart - ih.imagebase) + sizeof(tls);
|
||||||
|
unsigned kc = get_le32(p);
|
||||||
|
if (kc < tlsp->dataend && kc >= tlsp->datastart)
|
||||||
|
{
|
||||||
|
kc += newaddr + sizeof(tls) - tlsp->datastart;
|
||||||
|
set_le32(p,kc + ih.imagebase);
|
||||||
|
rel->add(kc,iv->ivarr[ic].len);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
rel->add(kc - ih.imagebase,iv->ivarr[ic].len);
|
||||||
|
}
|
||||||
|
|
||||||
|
const unsigned tls_data_size = tlsp->dataend - tlsp->datastart;
|
||||||
|
tlsp->datastart = newaddr + sizeof(tls) + ih.imagebase;
|
||||||
|
tlsp->dataend = tlsp->datastart + tls_data_size;
|
||||||
|
|
||||||
|
//NEW: if we have TLS callbacks to handle, we create a pointer to the new callback chain - Stefan Widmann
|
||||||
|
tlsp->callbacks = (use_tls_callbacks ? newaddr + sotls + ih.imagebase - 8 : 0);
|
||||||
|
|
||||||
|
if(use_tls_callbacks)
|
||||||
|
{
|
||||||
|
//set handler offset
|
||||||
|
set_le32(otls + sotls - 8, tls_handler_offset + ih.imagebase);
|
||||||
|
//add relocation for TLS handler offset
|
||||||
|
rel->add(newaddr + sotls - 8, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// import handling
|
// import handling
|
||||||
@@ -226,6 +363,7 @@ unsigned PackW32Pe::processImports() // pass 1
|
|||||||
unsigned iat;
|
unsigned iat;
|
||||||
LE32 *lookupt;
|
LE32 *lookupt;
|
||||||
unsigned npos;
|
unsigned npos;
|
||||||
|
unsigned original_position;
|
||||||
bool isk32;
|
bool isk32;
|
||||||
|
|
||||||
static int __acc_cdecl_qsort compare(const void *p1, const void *p2)
|
static int __acc_cdecl_qsort compare(const void *p1, const void *p2)
|
||||||
@@ -234,6 +372,8 @@ unsigned PackW32Pe::processImports() // pass 1
|
|||||||
const udll *u2 = * (const udll * const *) p2;
|
const udll *u2 = * (const udll * const *) p2;
|
||||||
if (u1->isk32) return -1;
|
if (u1->isk32) return -1;
|
||||||
if (u2->isk32) return 1;
|
if (u2->isk32) return 1;
|
||||||
|
if (!*u1->lookupt) return 1;
|
||||||
|
if (!*u2->lookupt) return -1;
|
||||||
int rc = strcasecmp(u1->name,u2->name);
|
int rc = strcasecmp(u1->name,u2->name);
|
||||||
if (rc) return rc;
|
if (rc) return rc;
|
||||||
if (u1->ordinal) return -1;
|
if (u1->ordinal) return -1;
|
||||||
@@ -260,11 +400,12 @@ unsigned PackW32Pe::processImports() // pass 1
|
|||||||
dlls[ic].iat = im->iat;
|
dlls[ic].iat = im->iat;
|
||||||
dlls[ic].lookupt = (LE32*) (ibuf + (im->oft ? im->oft : im->iat));
|
dlls[ic].lookupt = (LE32*) (ibuf + (im->oft ? im->oft : im->iat));
|
||||||
dlls[ic].npos = 0;
|
dlls[ic].npos = 0;
|
||||||
|
dlls[ic].original_position = ic;
|
||||||
dlls[ic].isk32 = strcasecmp(kernel32dll,dlls[ic].name) == 0;
|
dlls[ic].isk32 = strcasecmp(kernel32dll,dlls[ic].name) == 0;
|
||||||
|
|
||||||
soimport += strlen(dlls[ic].name) + 1 + 4;
|
soimport += strlen(dlls[ic].name) + 1 + 4;
|
||||||
|
|
||||||
for (LE32 *tarr = dlls[ic].lookupt; *tarr; tarr++)
|
for (IPTR_I(LE32, tarr, dlls[ic].lookupt); *tarr; tarr += 1)
|
||||||
{
|
{
|
||||||
if (*tarr & 0x80000000)
|
if (*tarr & 0x80000000)
|
||||||
{
|
{
|
||||||
@@ -276,10 +417,11 @@ unsigned PackW32Pe::processImports() // pass 1
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned len = strlen(ibuf + *tarr + 2);
|
IPTR_I(const upx_byte, n, ibuf + *tarr + 2);
|
||||||
|
unsigned len = strlen(n);
|
||||||
soimport += len + 1;
|
soimport += len + 1;
|
||||||
if (dlls[ic].shname == NULL || len < strlen (dlls[ic].shname))
|
if (dlls[ic].shname == NULL || len < strlen (dlls[ic].shname))
|
||||||
dlls[ic].shname = ibuf + *tarr + 2;
|
dlls[ic].shname = n;
|
||||||
}
|
}
|
||||||
soimport++; // separator
|
soimport++; // separator
|
||||||
}
|
}
|
||||||
@@ -371,8 +513,10 @@ unsigned PackW32Pe::processImports() // pass 1
|
|||||||
for (ic = 0; ic < dllnum; ic++)
|
for (ic = 0; ic < dllnum; ic++)
|
||||||
{
|
{
|
||||||
LE32 *tarr = idlls[ic]->lookupt;
|
LE32 *tarr = idlls[ic]->lookupt;
|
||||||
|
#if 0 && ENABLE_THIS_AND_UNCOMPRESSION_WILL_BREAK
|
||||||
if (!*tarr) // no imports from this dll
|
if (!*tarr) // no imports from this dll
|
||||||
continue;
|
continue;
|
||||||
|
#endif
|
||||||
set_le32(ppi,idlls[ic]->npos);
|
set_le32(ppi,idlls[ic]->npos);
|
||||||
set_le32(ppi+4,idlls[ic]->iat - rvamin);
|
set_le32(ppi+4,idlls[ic]->iat - rvamin);
|
||||||
ppi += 8;
|
ppi += 8;
|
||||||
@@ -440,7 +584,7 @@ unsigned PackW32Pe::processImports() // pass 1
|
|||||||
for (ic = 0; ic < dllnum; ic++, im++)
|
for (ic = 0; ic < dllnum; ic++, im++)
|
||||||
{
|
{
|
||||||
memset(im,FILLVAL,sizeof(*im));
|
memset(im,FILLVAL,sizeof(*im));
|
||||||
im->dllname = ptr_diff(idlls[ic]->name,ibuf); // I only need this info
|
im->dllname = ptr_diff(dlls[idlls[ic]->original_position].name,ibuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -577,14 +721,30 @@ void PackW32Pe::buildLoader(const Filter *ft)
|
|||||||
}
|
}
|
||||||
if (use_dep_hack)
|
if (use_dep_hack)
|
||||||
addLoader("PEDEPHAK", NULL);
|
addLoader("PEDEPHAK", NULL);
|
||||||
|
|
||||||
|
//NEW: TLS callback support PART 1, the callback handler installation - Stefan Widmann
|
||||||
|
if(use_tls_callbacks)
|
||||||
|
addLoader("PETLSC", NULL);
|
||||||
|
|
||||||
addLoader("PEMAIN20", NULL);
|
addLoader("PEMAIN20", NULL);
|
||||||
if (use_clear_dirty_stack)
|
if (use_clear_dirty_stack)
|
||||||
addLoader("CLEARSTACK", NULL);
|
addLoader("CLEARSTACK", NULL);
|
||||||
addLoader("PEMAIN21", NULL);
|
addLoader("PEMAIN21", NULL);
|
||||||
|
#if 0
|
||||||
addLoader(ih.entry ? "PEDOJUMP" : "PERETURN",
|
addLoader(ih.entry ? "PEDOJUMP" : "PERETURN",
|
||||||
"IDENTSTR,UPX1HEAD",
|
"IDENTSTR,UPX1HEAD",
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
|
//NEW: last loader sections split up to insert TLS callback handler - Stefan Widmann
|
||||||
|
addLoader(ih.entry ? "PEDOJUMP" : "PERETURN", NULL);
|
||||||
|
|
||||||
|
//NEW: TLS callback support PART 2, the callback handler - Stefan Widmann
|
||||||
|
if(use_tls_callbacks)
|
||||||
|
addLoader("PETLSC2", NULL);
|
||||||
|
|
||||||
|
addLoader("IDENTSTR,UPX1HEAD", NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -605,12 +765,13 @@ void PackW32Pe::pack(OutputFile *fo)
|
|||||||
|
|
||||||
// check the PE header
|
// check the PE header
|
||||||
// FIXME: add more checks
|
// FIXME: add more checks
|
||||||
|
//NEW: subsystem check moved to switch ... case below, check of COFF magic, 32 bit machine flag check - Stefan Widmann
|
||||||
if (!opt->force && (
|
if (!opt->force && (
|
||||||
(ih.cpu < 0x14c || ih.cpu > 0x150)
|
(ih.cpu < 0x14c || ih.cpu > 0x150)
|
||||||
|| (ih.opthdrsize != 0xe0)
|
|| (ih.opthdrsize != 0xe0)
|
||||||
|| ((ih.flags & EXECUTABLE) == 0)
|
|| ((ih.flags & EXECUTABLE) == 0)
|
||||||
|| (ih.subsystem != 2 && ih.subsystem != 3
|
|| ((ih.flags & BITS_32_MACHINE) == 0) //NEW: 32 bit machine flag must be set - Stefan Widmann
|
||||||
&& ih.subsystem != 1 && ih.subsystem != 9)
|
|| (ih.coffmagic != 0x10B) //COFF magic is 0x10B in PE files, 0x20B in PE32+ files - Stefan Widmann
|
||||||
|| (ih.entry == 0 && !isdll)
|
|| (ih.entry == 0 && !isdll)
|
||||||
|| (ih.ddirsentries != 16)
|
|| (ih.ddirsentries != 16)
|
||||||
|| IDSIZE(PEDIR_EXCEPTION) // is this used on i386?
|
|| IDSIZE(PEDIR_EXCEPTION) // is this used on i386?
|
||||||
@@ -618,15 +779,90 @@ void PackW32Pe::pack(OutputFile *fo)
|
|||||||
))
|
))
|
||||||
throwCantPack("unexpected value in PE header (try --force)");
|
throwCantPack("unexpected value in PE header (try --force)");
|
||||||
|
|
||||||
if (ih.subsystem == 9)
|
switch(ih.subsystem) //let's take a closer look at the subsystem
|
||||||
throwCantPack("x86/wince files are not yet supported");
|
{
|
||||||
|
case 1: //NATIVE
|
||||||
|
{
|
||||||
|
if(!opt->force)
|
||||||
|
{
|
||||||
|
throwCantPack("win32/native applications are not yet supported");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: //GUI
|
||||||
|
{
|
||||||
|
//fine, continue
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: //CONSOLE
|
||||||
|
{
|
||||||
|
//fine, continue
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5: //OS2
|
||||||
|
{
|
||||||
|
throwCantPack("win32/os2 files are not yet supported");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 7: //POSIX - do x32/posix files exist?
|
||||||
|
{
|
||||||
|
throwCantPack("win32/posix files are not yet supported");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 9: //WINCE x86 files
|
||||||
|
{
|
||||||
|
throwCantPack("PE32/wince files are not yet supported");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 10: //EFI APPLICATION
|
||||||
|
{
|
||||||
|
throwCantPack("PE32/EFIapplication files are not yet supported");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 11: //EFI BOOT SERVICE DRIVER
|
||||||
|
{
|
||||||
|
throwCantPack("PE32/EFIbootservicedriver files are not yet supported");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 12: //EFI RUNTIME DRIVER
|
||||||
|
{
|
||||||
|
throwCantPack("PE32/EFIruntimedriver files are not yet supported");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 13: //EFI ROM
|
||||||
|
{
|
||||||
|
throwCantPack("PE32/EFIROM files are not yet supported");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 14: //XBOX - will we ever see an XBOX file?
|
||||||
|
{
|
||||||
|
throwCantPack("PE32/xbox files are not yet supported");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 16: //WINDOWS BOOT APPLICATION
|
||||||
|
{
|
||||||
|
throwCantPack("PE32/windowsbootapplication files are not yet supported");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: //UNKNOWN SUBSYSTEM
|
||||||
|
{
|
||||||
|
throwCantPack("PE32/? unknown subsystem");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//remove certificate directory entry
|
||||||
if (IDSIZE(PEDIR_SEC))
|
if (IDSIZE(PEDIR_SEC))
|
||||||
IDSIZE(PEDIR_SEC) = IDADDR(PEDIR_SEC) = 0;
|
IDSIZE(PEDIR_SEC) = IDADDR(PEDIR_SEC) = 0;
|
||||||
if (IDSIZE(PEDIR_COMRT))
|
|
||||||
throwCantPack(".NET files (win32/net) are not yet supported");
|
|
||||||
|
|
||||||
if (isdll)
|
//check CLR Runtime Header directory entry
|
||||||
|
if (IDSIZE(PEDIR_COMRT))
|
||||||
|
throwCantPack(".NET files (win32/.net) are not yet supported");
|
||||||
|
|
||||||
|
//NEW: disable reloc stripping if ASLR is enabled
|
||||||
|
if(ih.dllflags & IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE)
|
||||||
|
opt->win32_pe.strip_relocs = false;
|
||||||
|
else if (isdll) //do never strip relocations from DLLs
|
||||||
opt->win32_pe.strip_relocs = false;
|
opt->win32_pe.strip_relocs = false;
|
||||||
else if (opt->win32_pe.strip_relocs < 0)
|
else if (opt->win32_pe.strip_relocs < 0)
|
||||||
opt->win32_pe.strip_relocs = (ih.imagebase >= 0x400000);
|
opt->win32_pe.strip_relocs = (ih.imagebase >= 0x400000);
|
||||||
@@ -644,8 +880,10 @@ void PackW32Pe::pack(OutputFile *fo)
|
|||||||
throwCantPack("file is possibly packed/protected (try --force)");
|
throwCantPack("file is possibly packed/protected (try --force)");
|
||||||
if (ih.entry && ih.entry < rvamin)
|
if (ih.entry && ih.entry < rvamin)
|
||||||
throwCantPack("run a virus scanner on this file!");
|
throwCantPack("run a virus scanner on this file!");
|
||||||
|
#if 0 //subsystem check moved to switch ... case above - Stefan Widmann
|
||||||
if (!opt->force && ih.subsystem == 1)
|
if (!opt->force && ih.subsystem == 1)
|
||||||
throwCantPack("subsystem 'native' is not supported (try --force)");
|
throwCantPack("subsystem 'native' is not supported (try --force)");
|
||||||
|
#endif
|
||||||
if (ih.filealign < 0x200)
|
if (ih.filealign < 0x200)
|
||||||
throwCantPack("filealign < 0x200 is not yet supported");
|
throwCantPack("filealign < 0x200 is not yet supported");
|
||||||
|
|
||||||
@@ -904,6 +1142,16 @@ void PackW32Pe::pack(OutputFile *fo)
|
|||||||
linker->defineSymbol("start_of_uncompressed", 0u - esi0 + rvamin);
|
linker->defineSymbol("start_of_uncompressed", 0u - esi0 + rvamin);
|
||||||
linker->defineSymbol("start_of_compressed", esi0 + ih.imagebase);
|
linker->defineSymbol("start_of_compressed", esi0 + ih.imagebase);
|
||||||
|
|
||||||
|
//NEW: TLS callback support - Stefan Widmann
|
||||||
|
ic = s1addr + s1size - sotls - soloadconf; //moved here, we need the address of the new TLS!
|
||||||
|
if(use_tls_callbacks)
|
||||||
|
{
|
||||||
|
//esi is ih.imagebase + rvamin
|
||||||
|
linker->defineSymbol("tls_callbacks_ptr", tlscb_ptr);
|
||||||
|
//linker->defineSymbol("tls_callbacks_off", ic + sotls - 8 - rvamin);
|
||||||
|
linker->defineSymbol("tls_module_base", 0u - rvamin);
|
||||||
|
}
|
||||||
|
|
||||||
linker->defineSymbol(isdll ? "PEISDLL1" : "PEMAIN01", upxsection);
|
linker->defineSymbol(isdll ? "PEISDLL1" : "PEMAIN01", upxsection);
|
||||||
//linker->dumpSymbols();
|
//linker->dumpSymbols();
|
||||||
relocateLoader();
|
relocateLoader();
|
||||||
@@ -935,7 +1183,15 @@ void PackW32Pe::pack(OutputFile *fo)
|
|||||||
|
|
||||||
// tls & loadconf are put into section 1
|
// tls & loadconf are put into section 1
|
||||||
|
|
||||||
ic = s1addr + s1size - sotls - soloadconf;
|
//ic = s1addr + s1size - sotls - soloadconf; //ATTENTION: moved upwards to TLS callback handling - Stefan Widmann
|
||||||
|
//get address of TLS callback handler
|
||||||
|
if (use_tls_callbacks)
|
||||||
|
{
|
||||||
|
tls_handler_offset = linker->getSymbolOffset("PETLSC2");
|
||||||
|
//add relocation entry for TLS callback handler
|
||||||
|
rel.add(tls_handler_offset + 4, 3);
|
||||||
|
}
|
||||||
|
|
||||||
processTls(&rel,&tlsiv,ic);
|
processTls(&rel,&tlsiv,ic);
|
||||||
ODADDR(PEDIR_TLS) = sotls ? ic : 0;
|
ODADDR(PEDIR_TLS) = sotls ? ic : 0;
|
||||||
ODSIZE(PEDIR_TLS) = sotls ? 0x18 : 0;
|
ODSIZE(PEDIR_TLS) = sotls ? 0x18 : 0;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user