Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7082594bbc | |||
| 36dd35f238 | |||
| 9c9fb6a485 | |||
| 5438a4837b | |||
| 84996e8cb6 | |||
| 87a368a857 | |||
| 21412d93dd | |||
| 0b11ff22b4 | |||
| 8fafa78796 | |||
| c43158f8a2 | |||
| 92ad524947 | |||
| b362a61863 | |||
| 468fec38d7 | |||
| 89830a5ae0 | |||
| 5977c296bd | |||
| 47d5792d97 | |||
| 25d706a913 | |||
| 048236aaaa | |||
| d442c58fd1 | |||
| f890f6bb09 | |||
| 036d466790 | |||
| dee47ba2d8 | |||
| be96c28b77 | |||
| ad1c0f578e | |||
| c8f7b1b72c | |||
| c89702ae84 | |||
| 2d29a82250 | |||
| b36c65e654 | |||
| 09b072b908 | |||
| 0ae9fee350 | |||
| 1579182ed9 | |||
| 074671aa71 | |||
| 36b7c47247 | |||
| 424d5b3025 | |||
| 8a5d352733 | |||
| f383629282 | |||
| a6d717cb04 | |||
| 84a5753301 | |||
| 5d2d9c7e81 | |||
| 82801d1411 | |||
| 340c3963d8 | |||
| ef15cf9847 | |||
| 4d613ccfa7 | |||
| 43ce34d547 | |||
| eda074cd80 | |||
| a2396d82f6 | |||
| a38721db93 | |||
| a06e811717 | |||
| 86e534ff75 | |||
| 640d5b2dec | |||
| 57e9b27085 | |||
| c56eefc739 | |||
| cf28306997 | |||
| 10acf3ddd1 |
@@ -9,6 +9,7 @@ syntax: regexp
|
|||||||
syntax: glob
|
syntax: glob
|
||||||
|
|
||||||
.depend
|
.depend
|
||||||
|
*.qtcreator.{config,creator,creator.user,files,includes}
|
||||||
Makevars.local
|
Makevars.local
|
||||||
|
|
||||||
*.a
|
*.a
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
087cafe682c014863b4aa8a6ea21431251a6ad3c RELEASE_308
|
||||||
140415ffbcef86a42b4d672249927364430d3d38 RELEASE_111
|
140415ffbcef86a42b4d672249927364430d3d38 RELEASE_111
|
||||||
155618b5b7930f97bd84b82befa7a4fd6672efb3 RELEASE_304
|
155618b5b7930f97bd84b82befa7a4fd6672efb3 RELEASE_304
|
||||||
1931f4f28074970ec53b4cd21c7fc181b4da8e5e RELEASE_301
|
1931f4f28074970ec53b4cd21c7fc181b4da8e5e RELEASE_301
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2011 Markus Oberhumer, Laszlo Molnar & John Reiser
|
Copyright (c) 1996-2013 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
http://upx.sourceforge.net
|
||||||
|
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ test file.
|
|||||||
|
|
||||||
win32/pe
|
win32/pe
|
||||||
--------
|
--------
|
||||||
* writeable shared sections (`--force' *may* work)
|
* writable shared sections (`--force' *may* work)
|
||||||
* certificates in the image
|
* certificates in the image
|
||||||
* compressing files which contain a big BSS requires lots of memory
|
* compressing files which contain a big BSS requires lots of memory
|
||||||
during compression
|
during compression
|
||||||
|
|||||||
@@ -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-2011 Markus Franz Xaver Johannes Oberhumer
|
# Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
#
|
#
|
||||||
|
|
||||||
MAKEFLAGS += -rR
|
MAKEFLAGS += -rR
|
||||||
|
|||||||
@@ -2,14 +2,21 @@
|
|||||||
User visible changes for UPX
|
User visible changes for UPX
|
||||||
==================================================================
|
==================================================================
|
||||||
|
|
||||||
|
Changes in 3.09 (18 Feb 2013):
|
||||||
|
* New option --preserve-build-id for GNU ELF.
|
||||||
|
* Allow for code signing and LC_UUID on Mac OS X executables.
|
||||||
|
* Allow non-contiguous LC_SEGMENTs and 0==.vmsize for Mach-O.
|
||||||
|
* Allow zero-filled final page in PackUnix::canUnpack().
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
Changes in 3.08 (12 Dec 2011):
|
Changes in 3.08 (12 Dec 2011):
|
||||||
* Fix allocation in runtime stub for darwin.macho-entry (i386 and amd64).
|
* 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].
|
* 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).
|
* Attempt to support ELF on QNX 6.3.0 for armel (experimental).
|
||||||
* Better diangostic when ELF -fPIC is needed.
|
* Better diagnostic when ELF -fPIC is needed.
|
||||||
* PT_NOTE improvements for *BSD.
|
* PT_NOTE improvements for *BSD.
|
||||||
* Preserve more ELF .e_flags on ARM.
|
* Preserve more ELF .e_flags on ARM.
|
||||||
* Minor code improvements for ELF stubs
|
* Minor code improvements for ELF stubs.
|
||||||
* Defend against another flavor of corrupt PE header.
|
* Defend against another flavor of corrupt PE header.
|
||||||
* bug fixes
|
* bug fixes
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2011 Markus Oberhumer, Laszlo Molnar & John Reiser
|
Copyright (c) 1996-2013 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-2011 Markus Oberhumer, Laszlo Molnar & John Reiser
|
Copyright (c) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2000-2011 John F. Reiser
|
Copyright (C) 2000-2013 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-2011 Markus Oberhumer, Laszlo Molnar & John Reiser
|
Copyright (c) 1996-2013 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
http://upx.sourceforge.net
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,12 @@ Tools needed to build/modify the UPX sources
|
|||||||
|
|
||||||
- GNU make 3.81 or better
|
- GNU make 3.81 or better
|
||||||
|
|
||||||
|
- zlib and zlib-devel [or zlib-dev] software packages for your
|
||||||
|
host environment, or via http://www.cygwin.org/setup.exe
|
||||||
|
|
||||||
|
- lzma SDK, such as from https://sourceforge.net/projects/sevenzip/
|
||||||
|
files/LZMA%20SDK/4.43/
|
||||||
|
|
||||||
|
|
||||||
To compile the packer sources
|
To compile the packer sources
|
||||||
-----------------------------
|
-----------------------------
|
||||||
@@ -85,6 +91,7 @@ To compile the packer sources
|
|||||||
to your unpacked lzma443.tar.bz2 source directory, e.g.
|
to your unpacked lzma443.tar.bz2 source directory, e.g.
|
||||||
|
|
||||||
export UPX_LZMADIR=$HOME/local/src/lzma-4.43 (Unix)
|
export UPX_LZMADIR=$HOME/local/src/lzma-4.43 (Unix)
|
||||||
|
export UPX_LZMA_VERSION=0x443 # perhaps 0x459,0x458,0x457,0x449,0x442
|
||||||
|
|
||||||
Finally type
|
Finally type
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2011 Markus Oberhumer, Laszlo Molnar & John Reiser
|
Copyright (c) 1996-2013 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
http://upx.sourceforge.net
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+16
-1
@@ -1,5 +1,5 @@
|
|||||||
Decompressing ELF Directly to Memory on Linux/x86
|
Decompressing ELF Directly to Memory on Linux/x86
|
||||||
Copyright (C) 2000-2011 John F. Reiser jreiser@BitWagon.com
|
Copyright (C) 2000-2013 John F. Reiser jreiser@BitWagon.com
|
||||||
|
|
||||||
References:
|
References:
|
||||||
<elf.h> definitions for the ELF file format
|
<elf.h> definitions for the ELF file format
|
||||||
@@ -76,6 +76,21 @@ and previous versions did this by default with no option. However,
|
|||||||
too much other software erroneously assumes that /proc/self/exe
|
too much other software erroneously assumes that /proc/self/exe
|
||||||
always exists.
|
always exists.
|
||||||
|
|
||||||
|
On arm*-linux-elf there is no good address at which to retain one
|
||||||
|
page of the compressed executable. Pages below the usual .p_vaddr
|
||||||
|
0x8000 (32KiB) are rejected by the kernel. Using a page above the
|
||||||
|
original uncompressed brk(0) would require placing the entire initial
|
||||||
|
compressed program above uncompressed brk(0), which would significantly
|
||||||
|
increase the running brk(0); but too many programs break if brk(0)
|
||||||
|
moves. Thus on arm*-linux-elf the compressed executable begins
|
||||||
|
with 0x8000==.p_vaddr, all pages mapped by execve() that are also
|
||||||
|
occupied by decompressed bytes are removed before overwriting, and
|
||||||
|
/proc/self/exe becomes a "(deleted)" symlink. It might be possible
|
||||||
|
to preserve /proc/self/exe if the original uncompressed executable
|
||||||
|
were created with 0x9000==.p_vaddr (one page higher than the usual
|
||||||
|
0x8000) so that the compressed page mapped at 0x8000 would linger.
|
||||||
|
[This has not been tested.]
|
||||||
|
|
||||||
Linux stores the pathname argument that was specified to execve()
|
Linux stores the pathname argument that was specified to execve()
|
||||||
immediately after the '\0' which terminates the character string of the
|
immediately after the '\0' which terminates the character string of the
|
||||||
last environment variable [as of execve()]. This is true for at least
|
last environment variable [as of execve()]. This is true for at least
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ code 127, and a record will be added to the history file
|
|||||||
|
|
||||||
In "targeted enforcing" mode, SELinux pays close attention mostly to
|
In "targeted enforcing" mode, SELinux pays close attention mostly to
|
||||||
designated processes that run with elevated privileges: web server,
|
designated processes that run with elevated privileges: web server,
|
||||||
print server, login server, etc. Ordinary user excutables receive
|
print server, login server, etc. Ordinary user executables receive
|
||||||
much less scrutiny. However, one of the eventual goals of SELinux is to
|
much less scrutiny. However, one of the eventual goals of SELinux is to
|
||||||
eradicate runtime generation of instructions because of the possibility
|
eradicate runtime generation of instructions because of the possibility
|
||||||
for exploitation by malware (virus, trojan, key logger, privilege
|
for exploitation by malware (virus, trojan, key logger, privilege
|
||||||
|
|||||||
+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-2011 Markus Oberhumer, Laszlo Molnar & John Reiser
|
Copyright (c) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
|
|
||||||
Copyright (C) 2000-2011 John F. Reiser
|
Copyright (C) 2000-2013 John F. Reiser
|
||||||
|
|
||||||
Copyright (C) 2002-2011 Jens Medoch
|
Copyright (C) 2002-2013 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.
|
||||||
|
|||||||
+1
-1
@@ -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-2011 Markus Franz Xaver Johannes Oberhumer
|
# Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
#
|
#
|
||||||
|
|
||||||
MAKEFLAGS += -rR
|
MAKEFLAGS += -rR
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
@@ -352,6 +352,7 @@ namespace MyLzma {
|
|||||||
|
|
||||||
struct InStream: public ISequentialInStream, public CMyUnknownImp
|
struct InStream: public ISequentialInStream, public CMyUnknownImp
|
||||||
{
|
{
|
||||||
|
virtual ~InStream() { }
|
||||||
MY_UNKNOWN_IMP
|
MY_UNKNOWN_IMP
|
||||||
const Byte *b_buf; size_t b_size; size_t b_pos;
|
const Byte *b_buf; size_t b_size; size_t b_pos;
|
||||||
void Init(const Byte *data, size_t size) {
|
void Init(const Byte *data, size_t size) {
|
||||||
@@ -372,6 +373,7 @@ STDMETHODIMP InStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
|||||||
|
|
||||||
struct OutStream : public ISequentialOutStream, public CMyUnknownImp
|
struct OutStream : public ISequentialOutStream, public CMyUnknownImp
|
||||||
{
|
{
|
||||||
|
virtual ~OutStream() { }
|
||||||
MY_UNKNOWN_IMP
|
MY_UNKNOWN_IMP
|
||||||
Byte *b_buf; size_t b_size; size_t b_pos; bool overflow;
|
Byte *b_buf; size_t b_size; size_t b_pos; bool overflow;
|
||||||
void Init(Byte *data, size_t size) {
|
void Init(Byte *data, size_t size) {
|
||||||
@@ -397,6 +399,7 @@ STDMETHODIMP OutStream::Write(const void *data, UInt32 size, UInt32 *processedSi
|
|||||||
|
|
||||||
struct ProgressInfo : public ICompressProgressInfo, public CMyUnknownImp
|
struct ProgressInfo : public ICompressProgressInfo, public CMyUnknownImp
|
||||||
{
|
{
|
||||||
|
virtual ~ProgressInfo() { }
|
||||||
MY_UNKNOWN_IMP
|
MY_UNKNOWN_IMP
|
||||||
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
|
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
|
||||||
upx_callback_p cb;
|
upx_callback_p cb;
|
||||||
|
|||||||
@@ -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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
-13
@@ -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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
@@ -222,19 +222,14 @@
|
|||||||
#if (WITH_VALGRIND)
|
#if (WITH_VALGRIND)
|
||||||
# include <valgrind/memcheck.h>
|
# include <valgrind/memcheck.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(VALGRIND_MAKE_MEM_DEFINED)
|
||||||
#if !defined(VALGRIND_MAKE_WRITABLE)
|
# define VALGRIND_MAKE_MEM_DEFINED(addr,len) 0
|
||||||
# define VALGRIND_MAKE_WRITABLE(addr,len) 0
|
|
||||||
#endif
|
#endif
|
||||||
#if !defined(VALGRIND_MAKE_READABLE)
|
#if !defined(VALGRIND_MAKE_MEM_NOACCESS)
|
||||||
# if 0
|
# define VALGRIND_MAKE_MEM_NOACCESS(addr,len) 0
|
||||||
# define VALGRIND_MAKE_READABLE(addr,len) (memset(addr,0,len), 0)
|
|
||||||
# else
|
|
||||||
# define VALGRIND_MAKE_READABLE(addr,len) 0
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
#if !defined(VALGRIND_DISCARD)
|
#if !defined(VALGRIND_MAKE_MEM_UNDEFINED)
|
||||||
# define VALGRIND_DISCARD(handle) ((void)(&handle))
|
# define VALGRIND_MAKE_MEM_UNDEFINED(addr,len) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
|
|||||||
+12
-17
@@ -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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
@@ -410,21 +410,16 @@ void OutputFile::seek(off_t off, int whence)
|
|||||||
super::seek(off,whence);
|
super::seek(off,whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OutputFile::read(void *buf, int len)
|
// WARNING: fsync() does not exist in some Windows environments.
|
||||||
{
|
// This trick works only on UNIX-like systems.
|
||||||
InputFile infile;
|
//int OutputFile::read(void *buf, int len)
|
||||||
infile.open(this->getName(), O_RDONLY);
|
//{
|
||||||
infile.seek(this->tell(), SEEK_SET);
|
// fsync(_fd);
|
||||||
return infile.read(buf, len);
|
// InputFile infile;
|
||||||
}
|
// infile.open(this->getName(), O_RDONLY);
|
||||||
|
// infile.seek(this->tell(), SEEK_SET);
|
||||||
int OutputFile::readx(void *buf, int len)
|
// return infile.read(buf, 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)
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
@@ -141,8 +141,6 @@ 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2000-2011 John F. Reiser
|
Copyright (C) 2000-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2000-2011 John F. Reiser
|
Copyright (C) 2000-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2000-2011 John F. Reiser
|
Copyright (C) 2000-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2004-2011 John F. Reiser
|
Copyright (C) 2004-2013 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
|
||||||
@@ -98,7 +98,7 @@ static int F(Filter *f)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if (W_CTO != 0)
|
#if (W_CTO != 0)
|
||||||
assert((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) != cto8); // this should not happen
|
assert((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) != (unsigned) cto8); // this should not happen
|
||||||
#endif
|
#endif
|
||||||
lastnoncall = ic;
|
lastnoncall = ic;
|
||||||
noncalls++;
|
noncalls++;
|
||||||
@@ -133,7 +133,7 @@ static int U(Filter *f)
|
|||||||
|
|
||||||
for (ic = 0; ic<=size4; ic+=4) if (COND(b,ic)) {
|
for (ic = 0; ic<=size4; ic+=4) if (COND(b,ic)) {
|
||||||
unsigned const word = get_be32(b+ic);
|
unsigned const word = get_be32(b+ic);
|
||||||
if ((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) == f->cto) {
|
if ((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) == (unsigned) f->cto) {
|
||||||
unsigned const jc = word & (~(~0u<<(26 - W_CTO)) & (~0u<<2));
|
unsigned const jc = word & (~(~0u<<(26 - W_CTO)) & (~0u<<2));
|
||||||
set_be32(b+ic, (0xfc000003&word)|(0x03fffffc&(jc-ic-addvalue)));
|
set_be32(b+ic, (0xfc000003&word)|(0x03fffffc&(jc-ic-addvalue)));
|
||||||
f->calls++;
|
f->calls++;
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
|
|||||||
+11
-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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
@@ -290,6 +290,11 @@ void show_help(int verbose)
|
|||||||
" --strip-relocs=0 do not strip relocations\n"
|
" --strip-relocs=0 do not strip relocations\n"
|
||||||
" --strip-relocs=1 strip relocations [default]\n"
|
" --strip-relocs=1 strip relocations [default]\n"
|
||||||
"\n");
|
"\n");
|
||||||
|
con_fprintf(f,"Options for linux/elf:\n");
|
||||||
|
fg = con_fg(f,fg);
|
||||||
|
con_fprintf(f,
|
||||||
|
" --preserve-build-id copy .gnu.note.build-id to compressed output\n"
|
||||||
|
"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
con_fprintf(f, "file.. executables to (de)compress\n");
|
con_fprintf(f, "file.. executables to (de)compress\n");
|
||||||
@@ -400,10 +405,10 @@ void show_version(int x)
|
|||||||
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-2011 Markus Franz Xaver Johannes Oberhumer\n");
|
fprintf(fp, "Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer\n");
|
||||||
fprintf(fp, "Copyright (C) 1996-2011 Laszlo Molnar\n");
|
fprintf(fp, "Copyright (C) 1996-2013 Laszlo Molnar\n");
|
||||||
fprintf(fp, "Copyright (C) 2000-2011 John F. Reiser\n");
|
fprintf(fp, "Copyright (C) 2000-2013 John F. Reiser\n");
|
||||||
fprintf(fp, "Copyright (C) 2002-2011 Jens Medoch\n");
|
fprintf(fp, "Copyright (C) 2002-2013 Jens Medoch\n");
|
||||||
#if (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
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
|
|||||||
+6
-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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
@@ -898,6 +898,9 @@ static int do_option(int optc, const char *arg)
|
|||||||
case 674:
|
case 674:
|
||||||
opt->o_unix.unmap_all_pages = true; // val ?
|
opt->o_unix.unmap_all_pages = true; // val ?
|
||||||
break;
|
break;
|
||||||
|
case 675:
|
||||||
|
opt->o_unix.preserve_build_id = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case '\0':
|
case '\0':
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1048,6 +1051,7 @@ static const struct mfx_option longopts[] =
|
|||||||
{"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
|
{"unmap-all-pages", 0x10, 0, 674}, // linux /proc/self/exe vanishes
|
||||||
|
{"preserve-build-id", 0, 0, 675},
|
||||||
// watcom/le
|
// watcom/le
|
||||||
{"le", 0x10, 0, 620}, // produce LE output
|
{"le", 0x10, 0, 620}, // produce LE output
|
||||||
// win32/pe
|
// win32/pe
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
|
|||||||
+99
-56
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
|
Copyright (C) 2012 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
|
||||||
@@ -32,7 +34,7 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; see the file COPYING.
|
along with this program; see the file COPYING.
|
||||||
If not, write to the Free Software Foundation, Inc.,
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer
|
Markus F.X.J. Oberhumer
|
||||||
<markus@oberhumer.com>
|
<markus@oberhumer.com>
|
||||||
@@ -41,7 +43,7 @@
|
|||||||
|
|
||||||
#ifndef __ACC_H_INCLUDED
|
#ifndef __ACC_H_INCLUDED
|
||||||
#define __ACC_H_INCLUDED 1
|
#define __ACC_H_INCLUDED 1
|
||||||
#define ACC_VERSION 20101017L
|
#define ACC_VERSION 20130212L
|
||||||
#if defined(__CYGWIN32__) && !defined(__CYGWIN__)
|
#if defined(__CYGWIN32__) && !defined(__CYGWIN__)
|
||||||
# define __CYGWIN__ __CYGWIN32__
|
# define __CYGWIN__ __CYGWIN32__
|
||||||
#endif
|
#endif
|
||||||
@@ -537,7 +539,7 @@
|
|||||||
# define ACC_INFO_CC "sdcc"
|
# define ACC_INFO_CC "sdcc"
|
||||||
# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(SDCC)
|
# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(SDCC)
|
||||||
#elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__)
|
#elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__)
|
||||||
# define ACC_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__)
|
# define ACC_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__+0) * 0x100 + (__PATHCC_PATCHLEVEL__+0))
|
||||||
# define ACC_INFO_CC "Pathscale C"
|
# define ACC_INFO_CC "Pathscale C"
|
||||||
# define ACC_INFO_CCVER __PATHSCALE__
|
# define ACC_INFO_CCVER __PATHSCALE__
|
||||||
#elif defined(__INTEL_COMPILER)
|
#elif defined(__INTEL_COMPILER)
|
||||||
@@ -553,34 +555,43 @@
|
|||||||
# define ACC_CC_PELLESC 1
|
# define ACC_CC_PELLESC 1
|
||||||
# define ACC_INFO_CC "Pelles C"
|
# define ACC_INFO_CC "Pelles C"
|
||||||
# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__POCC__)
|
# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__POCC__)
|
||||||
|
#elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
|
||||||
|
# if defined(__GNUC_PATCHLEVEL__)
|
||||||
|
# define ACC_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__+0) * 0x100 + (__GNUC_PATCHLEVEL__+0))
|
||||||
|
# else
|
||||||
|
# define ACC_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__+0) * 0x100)
|
||||||
|
# endif
|
||||||
|
# define ACC_CC_ARMCC __ARMCC_VERSION
|
||||||
|
# define ACC_INFO_CC "ARM C Compiler"
|
||||||
|
# define ACC_INFO_CCVER __VERSION__
|
||||||
#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
|
#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
|
||||||
# if defined(__GNUC_PATCHLEVEL__)
|
# if defined(__GNUC_PATCHLEVEL__)
|
||||||
# define ACC_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
|
# define ACC_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__+0) * 0x100 + (__GNUC_PATCHLEVEL__+0))
|
||||||
# else
|
# else
|
||||||
# define ACC_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
|
# define ACC_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__+0) * 0x100)
|
||||||
# endif
|
# endif
|
||||||
# if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__)
|
# if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__)
|
||||||
# define ACC_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__)
|
# define ACC_CC_CLANG_CLANG (__clang_major__ * 0x10000L + (__clang_minor__+0) * 0x100 + (__clang_patchlevel__+0))
|
||||||
# else
|
# else
|
||||||
# define ACC_CC_CLANG_CLANG 0x020700L
|
# define ACC_CC_CLANG_CLANG 0x010000L
|
||||||
# endif
|
# endif
|
||||||
# define ACC_CC_CLANG ACC_CC_CLANG_GNUC
|
# define ACC_CC_CLANG ACC_CC_CLANG_GNUC
|
||||||
# define ACC_INFO_CC "clang"
|
# define ACC_INFO_CC "clang"
|
||||||
# define ACC_INFO_CCVER __VERSION__
|
# define ACC_INFO_CCVER __VERSION__
|
||||||
#elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
|
#elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
|
||||||
# if defined(__GNUC_PATCHLEVEL__)
|
# if defined(__GNUC_PATCHLEVEL__)
|
||||||
# define ACC_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
|
# define ACC_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__+0) * 0x100 + (__GNUC_PATCHLEVEL__+0))
|
||||||
# else
|
# else
|
||||||
# define ACC_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
|
# define ACC_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__+0) * 0x100)
|
||||||
# endif
|
# endif
|
||||||
# define ACC_CC_LLVM ACC_CC_LLVM_GNUC
|
# define ACC_CC_LLVM ACC_CC_LLVM_GNUC
|
||||||
# define ACC_INFO_CC "llvm-gcc"
|
# define ACC_INFO_CC "llvm-gcc"
|
||||||
# define ACC_INFO_CCVER __VERSION__
|
# define ACC_INFO_CCVER __VERSION__
|
||||||
#elif defined(__GNUC__) && defined(__VERSION__)
|
#elif defined(__GNUC__) && defined(__VERSION__)
|
||||||
# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
|
# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
|
||||||
# define ACC_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
|
# define ACC_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__+0) * 0x100 + (__GNUC_PATCHLEVEL__+0))
|
||||||
# elif defined(__GNUC_MINOR__)
|
# elif defined(__GNUC_MINOR__)
|
||||||
# define ACC_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
|
# define ACC_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__+0) * 0x100)
|
||||||
# else
|
# else
|
||||||
# define ACC_CC_GNUC (__GNUC__ * 0x10000L)
|
# define ACC_CC_GNUC (__GNUC__ * 0x10000L)
|
||||||
# endif
|
# endif
|
||||||
@@ -590,6 +601,11 @@
|
|||||||
# define ACC_CC_ACK 1
|
# define ACC_CC_ACK 1
|
||||||
# define ACC_INFO_CC "Amsterdam Compiler Kit C"
|
# define ACC_INFO_CC "Amsterdam Compiler Kit C"
|
||||||
# define ACC_INFO_CCVER "unknown"
|
# define ACC_INFO_CCVER "unknown"
|
||||||
|
#elif defined(__ARMCC_VERSION) && !defined(__GNUC__)
|
||||||
|
# define ACC_CC_ARMCC __ARMCC_VERSION
|
||||||
|
# define ACC_CC_ARMCC_ARMCC __ARMCC_VERSION
|
||||||
|
# define ACC_INFO_CC "ARM C Compiler"
|
||||||
|
# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__ARMCC_VERSION)
|
||||||
#elif defined(__AZTEC_C__)
|
#elif defined(__AZTEC_C__)
|
||||||
# define ACC_CC_AZTECC 1
|
# define ACC_CC_AZTECC 1
|
||||||
# define ACC_INFO_CC "Aztec C"
|
# define ACC_INFO_CC "Aztec C"
|
||||||
@@ -725,6 +741,20 @@
|
|||||||
# define ACC_INFO_CC "unknown"
|
# define ACC_INFO_CC "unknown"
|
||||||
# define ACC_INFO_CCVER "unknown"
|
# define ACC_INFO_CCVER "unknown"
|
||||||
#endif
|
#endif
|
||||||
|
#if (ACC_CC_GNUC) && defined(__OPEN64__)
|
||||||
|
# if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__)
|
||||||
|
# define ACC_CC_OPEN64_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__+0) * 0x100 + (__OPENCC_PATCHLEVEL__+0))
|
||||||
|
# define ACC_CC_OPEN64_GNUC ACC_CC_GNUC
|
||||||
|
# define ACC_CC_OPEN64 ACC_CC_OPEN64_OPEN64
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if (ACC_CC_GNUC) && defined(__PCC__)
|
||||||
|
# if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__)
|
||||||
|
# define ACC_CC_PCC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__+0) * 0x100 + (__PCC_MINORMINOR__+0))
|
||||||
|
# define ACC_CC_PCC_GNUC ACC_CC_GNUC
|
||||||
|
# define ACC_CC_PCC ACC_CC_PCC_PCC
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
#if 0 && (ACC_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER)
|
#if 0 && (ACC_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER)
|
||||||
# error "ACC_CC_MSC: _MSC_FULL_VER is not defined"
|
# error "ACC_CC_MSC: _MSC_FULL_VER is not defined"
|
||||||
#endif
|
#endif
|
||||||
@@ -1403,6 +1433,9 @@ extern "C" {
|
|||||||
# define ACC_INFO_LIBC "isoc90"
|
# define ACC_INFO_LIBC "isoc90"
|
||||||
#elif (ACC_LIBC_ISOC99)
|
#elif (ACC_LIBC_ISOC99)
|
||||||
# define ACC_INFO_LIBC "isoc99"
|
# define ACC_INFO_LIBC "isoc99"
|
||||||
|
#elif (ACC_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION)
|
||||||
|
# define ACC_LIBC_ISOC90 1
|
||||||
|
# define ACC_INFO_LIBC "isoc90"
|
||||||
#elif defined(__dietlibc__)
|
#elif defined(__dietlibc__)
|
||||||
# define ACC_LIBC_DIETLIBC 1
|
# define ACC_LIBC_DIETLIBC 1
|
||||||
# define ACC_INFO_LIBC "dietlibc"
|
# define ACC_INFO_LIBC "dietlibc"
|
||||||
@@ -1411,13 +1444,13 @@ extern "C" {
|
|||||||
# define ACC_INFO_LIBC "newlib"
|
# define ACC_INFO_LIBC "newlib"
|
||||||
#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__)
|
#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__)
|
||||||
# if defined(__UCLIBC_SUBLEVEL__)
|
# if defined(__UCLIBC_SUBLEVEL__)
|
||||||
# define ACC_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__)
|
# define ACC_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__+0) * 0x100 + (__UCLIBC_SUBLEVEL__+0))
|
||||||
# else
|
# else
|
||||||
# define ACC_LIBC_UCLIBC 0x00090bL
|
# define ACC_LIBC_UCLIBC 0x00090bL
|
||||||
# endif
|
# endif
|
||||||
# define ACC_INFO_LIBC "uclibc"
|
# define ACC_INFO_LIBC "uclibc"
|
||||||
#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__)
|
#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__)
|
||||||
# define ACC_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100)
|
# define ACC_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__+0) * 0x100)
|
||||||
# define ACC_INFO_LIBC "glibc"
|
# define ACC_INFO_LIBC "glibc"
|
||||||
#elif (ACC_CC_MWERKS) && defined(__MSL__)
|
#elif (ACC_CC_MWERKS) && defined(__MSL__)
|
||||||
# define ACC_LIBC_MSL __MSL__
|
# define ACC_LIBC_MSL __MSL__
|
||||||
@@ -1433,7 +1466,7 @@ extern "C" {
|
|||||||
#if !defined(__acc_gnuc_extension__)
|
#if !defined(__acc_gnuc_extension__)
|
||||||
#if (ACC_CC_GNUC >= 0x020800ul)
|
#if (ACC_CC_GNUC >= 0x020800ul)
|
||||||
# define __acc_gnuc_extension__ __extension__
|
# define __acc_gnuc_extension__ __extension__
|
||||||
#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
#elif (ACC_CC_ARMCC_GNUC || ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
# define __acc_gnuc_extension__ __extension__
|
# define __acc_gnuc_extension__ __extension__
|
||||||
#else
|
#else
|
||||||
# define __acc_gnuc_extension__ /*empty*/
|
# define __acc_gnuc_extension__ /*empty*/
|
||||||
@@ -1443,7 +1476,7 @@ extern "C" {
|
|||||||
# define __acc_ua_volatile volatile
|
# define __acc_ua_volatile volatile
|
||||||
#endif
|
#endif
|
||||||
#if !defined(__acc_alignof)
|
#if !defined(__acc_alignof)
|
||||||
#if (ACC_CC_CILLY || ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE || ACC_CC_PGI)
|
#if (ACC_CC_ARMCC_GNUC || ACC_CC_CILLY || ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE || ACC_CC_PGI)
|
||||||
# define __acc_alignof(e) __alignof__(e)
|
# define __acc_alignof(e) __alignof__(e)
|
||||||
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 700))
|
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 700))
|
||||||
# define __acc_alignof(e) __alignof__(e)
|
# define __acc_alignof(e) __alignof__(e)
|
||||||
@@ -1461,7 +1494,7 @@ extern "C" {
|
|||||||
# define __acc_constructor __attribute__((__constructor__,__used__))
|
# define __acc_constructor __attribute__((__constructor__,__used__))
|
||||||
#elif (ACC_CC_GNUC >= 0x020700ul)
|
#elif (ACC_CC_GNUC >= 0x020700ul)
|
||||||
# define __acc_constructor __attribute__((__constructor__))
|
# define __acc_constructor __attribute__((__constructor__))
|
||||||
#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
#elif (ACC_CC_ARMCC_GNUC || ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
# define __acc_constructor __attribute__((__constructor__))
|
# define __acc_constructor __attribute__((__constructor__))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -1473,7 +1506,7 @@ extern "C" {
|
|||||||
# define __acc_destructor __attribute__((__destructor__,__used__))
|
# define __acc_destructor __attribute__((__destructor__,__used__))
|
||||||
#elif (ACC_CC_GNUC >= 0x020700ul)
|
#elif (ACC_CC_GNUC >= 0x020700ul)
|
||||||
# define __acc_destructor __attribute__((__destructor__))
|
# define __acc_destructor __attribute__((__destructor__))
|
||||||
#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
#elif (ACC_CC_ARMCC_GNUC || ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
# define __acc_destructor __attribute__((__destructor__))
|
# define __acc_destructor __attribute__((__destructor__))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -1489,7 +1522,7 @@ extern "C" {
|
|||||||
# define __acc_inline inline
|
# define __acc_inline inline
|
||||||
#elif (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0550))
|
#elif (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0550))
|
||||||
# define __acc_inline __inline
|
# define __acc_inline __inline
|
||||||
#elif (ACC_CC_CILLY || ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE || ACC_CC_PGI)
|
#elif (ACC_CC_ARMCC_GNUC || ACC_CC_CILLY || ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE || ACC_CC_PGI)
|
||||||
# define __acc_inline __inline__
|
# define __acc_inline __inline__
|
||||||
#elif (ACC_CC_DMC)
|
#elif (ACC_CC_DMC)
|
||||||
# define __acc_inline __inline
|
# define __acc_inline __inline
|
||||||
@@ -1517,7 +1550,7 @@ extern "C" {
|
|||||||
# define __acc_forceinline __forceinline
|
# define __acc_forceinline __forceinline
|
||||||
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 800) && ACC_CC_SYNTAX_GNUC)
|
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 800) && ACC_CC_SYNTAX_GNUC)
|
||||||
# define __acc_forceinline __inline__ __attribute__((__always_inline__))
|
# define __acc_forceinline __inline__ __attribute__((__always_inline__))
|
||||||
#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
#elif (ACC_CC_ARMCC_GNUC || ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
# define __acc_forceinline __inline__ __attribute__((__always_inline__))
|
# define __acc_forceinline __inline__ __attribute__((__always_inline__))
|
||||||
#elif (ACC_CC_MSC && (_MSC_VER >= 1200))
|
#elif (ACC_CC_MSC && (_MSC_VER >= 1200))
|
||||||
# define __acc_forceinline __forceinline
|
# define __acc_forceinline __forceinline
|
||||||
@@ -1539,7 +1572,7 @@ extern "C" {
|
|||||||
# define __acc_noinline __declspec(noinline)
|
# define __acc_noinline __declspec(noinline)
|
||||||
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 800) && ACC_CC_SYNTAX_GNUC)
|
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 800) && ACC_CC_SYNTAX_GNUC)
|
||||||
# define __acc_noinline __attribute__((__noinline__))
|
# define __acc_noinline __attribute__((__noinline__))
|
||||||
#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
#elif (ACC_CC_ARMCC_GNUC || ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
# define __acc_noinline __attribute__((__noinline__))
|
# define __acc_noinline __attribute__((__noinline__))
|
||||||
#elif (ACC_CC_MSC && (_MSC_VER >= 1300))
|
#elif (ACC_CC_MSC && (_MSC_VER >= 1300))
|
||||||
# define __acc_noinline __declspec(noinline)
|
# define __acc_noinline __declspec(noinline)
|
||||||
@@ -1567,7 +1600,7 @@ extern "C" {
|
|||||||
# define __acc_noreturn __declspec(noreturn)
|
# define __acc_noreturn __declspec(noreturn)
|
||||||
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 600) && ACC_CC_SYNTAX_GNUC)
|
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 600) && ACC_CC_SYNTAX_GNUC)
|
||||||
# define __acc_noreturn __attribute__((__noreturn__))
|
# define __acc_noreturn __attribute__((__noreturn__))
|
||||||
#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
#elif (ACC_CC_ARMCC_GNUC || ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
# define __acc_noreturn __attribute__((__noreturn__))
|
# define __acc_noreturn __attribute__((__noreturn__))
|
||||||
#elif (ACC_CC_MSC && (_MSC_VER >= 1200))
|
#elif (ACC_CC_MSC && (_MSC_VER >= 1200))
|
||||||
# define __acc_noreturn __declspec(noreturn)
|
# define __acc_noreturn __declspec(noreturn)
|
||||||
@@ -1585,7 +1618,7 @@ extern "C" {
|
|||||||
# define __acc_nothrow __declspec(nothrow)
|
# define __acc_nothrow __declspec(nothrow)
|
||||||
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 900) && ACC_CC_SYNTAX_GNUC)
|
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 900) && ACC_CC_SYNTAX_GNUC)
|
||||||
# define __acc_nothrow __attribute__((__nothrow__))
|
# define __acc_nothrow __attribute__((__nothrow__))
|
||||||
#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
#elif (ACC_CC_ARMCC_GNUC || ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
# define __acc_nothrow __attribute__((__nothrow__))
|
# define __acc_nothrow __attribute__((__nothrow__))
|
||||||
#elif (ACC_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus)
|
#elif (ACC_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus)
|
||||||
# define __acc_nothrow __declspec(nothrow)
|
# define __acc_nothrow __declspec(nothrow)
|
||||||
@@ -1601,7 +1634,7 @@ extern "C" {
|
|||||||
# define __acc_restrict __restrict__
|
# define __acc_restrict __restrict__
|
||||||
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 600) && ACC_CC_SYNTAX_GNUC)
|
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 600) && ACC_CC_SYNTAX_GNUC)
|
||||||
# define __acc_restrict __restrict__
|
# define __acc_restrict __restrict__
|
||||||
#elif (ACC_CC_CLANG || ACC_CC_LLVM)
|
#elif (ACC_CC_ARMCC_GNUC || ACC_CC_CLANG || ACC_CC_LLVM)
|
||||||
# define __acc_restrict __restrict__
|
# define __acc_restrict __restrict__
|
||||||
#elif (ACC_CC_MSC && (_MSC_VER >= 1400))
|
#elif (ACC_CC_MSC && (_MSC_VER >= 1400))
|
||||||
# define __acc_restrict __restrict
|
# define __acc_restrict __restrict
|
||||||
@@ -1619,7 +1652,7 @@ extern "C" {
|
|||||||
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 800))
|
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 800))
|
||||||
# define __acc_likely(e) (__builtin_expect(!!(e),1))
|
# define __acc_likely(e) (__builtin_expect(!!(e),1))
|
||||||
# define __acc_unlikely(e) (__builtin_expect(!!(e),0))
|
# define __acc_unlikely(e) (__builtin_expect(!!(e),0))
|
||||||
#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
#elif (ACC_CC_ARMCC_GNUC || ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
# define __acc_likely(e) (__builtin_expect(!!(e),1))
|
# define __acc_likely(e) (__builtin_expect(!!(e),1))
|
||||||
# define __acc_unlikely(e) (__builtin_expect(!!(e),0))
|
# define __acc_unlikely(e) (__builtin_expect(!!(e),0))
|
||||||
#endif
|
#endif
|
||||||
@@ -1639,7 +1672,9 @@ extern "C" {
|
|||||||
# define ACC_UNUSED(var) ((void) &var)
|
# define ACC_UNUSED(var) ((void) &var)
|
||||||
# elif (ACC_CC_BORLANDC || ACC_CC_HIGHC || ACC_CC_NDPC || ACC_CC_PELLESC || ACC_CC_TURBOC)
|
# elif (ACC_CC_BORLANDC || ACC_CC_HIGHC || ACC_CC_NDPC || ACC_CC_PELLESC || ACC_CC_TURBOC)
|
||||||
# define ACC_UNUSED(var) if (&var) ; else
|
# define ACC_UNUSED(var) if (&var) ; else
|
||||||
# elif (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
# elif (ACC_CC_CLANG && (ACC_CC_CLANG_CLANG >= 0x030200ul))
|
||||||
|
# define ACC_UNUSED(var) ((void) &var)
|
||||||
|
# elif (ACC_CC_ARMCC_GNUC || ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
# define ACC_UNUSED(var) ((void) var)
|
# define ACC_UNUSED(var) ((void) var)
|
||||||
# elif (ACC_CC_MSC && (_MSC_VER < 900))
|
# elif (ACC_CC_MSC && (_MSC_VER < 900))
|
||||||
# define ACC_UNUSED(var) if (&var) ; else
|
# define ACC_UNUSED(var) if (&var) ; else
|
||||||
@@ -1658,7 +1693,7 @@ extern "C" {
|
|||||||
# define ACC_UNUSED_FUNC(func) ((void) func)
|
# define ACC_UNUSED_FUNC(func) ((void) func)
|
||||||
# elif (ACC_CC_BORLANDC || ACC_CC_NDPC || ACC_CC_TURBOC)
|
# elif (ACC_CC_BORLANDC || ACC_CC_NDPC || ACC_CC_TURBOC)
|
||||||
# define ACC_UNUSED_FUNC(func) if (func) ; else
|
# define ACC_UNUSED_FUNC(func) if (func) ; else
|
||||||
# elif (ACC_CC_CLANG || ACC_CC_LLVM)
|
# elif (ACC_CC_ARMCC_GNUC || ACC_CC_CLANG || ACC_CC_LLVM)
|
||||||
# define ACC_UNUSED_FUNC(func) ((void) &func)
|
# define ACC_UNUSED_FUNC(func) ((void) &func)
|
||||||
# elif (ACC_CC_MSC && (_MSC_VER < 900))
|
# elif (ACC_CC_MSC && (_MSC_VER < 900))
|
||||||
# define ACC_UNUSED_FUNC(func) if (func) ; else
|
# define ACC_UNUSED_FUNC(func) if (func) ; else
|
||||||
@@ -1673,7 +1708,7 @@ extern "C" {
|
|||||||
#if !defined(ACC_UNUSED_LABEL)
|
#if !defined(ACC_UNUSED_LABEL)
|
||||||
# if (ACC_CC_WATCOMC) && defined(__cplusplus)
|
# if (ACC_CC_WATCOMC) && defined(__cplusplus)
|
||||||
# define ACC_UNUSED_LABEL(l) switch(0) case 1:goto l
|
# define ACC_UNUSED_LABEL(l) switch(0) case 1:goto l
|
||||||
# elif (ACC_CC_CLANG || ACC_CC_INTELC || ACC_CC_WATCOMC)
|
# elif (ACC_CC_ARMCC || ACC_CC_CLANG || ACC_CC_INTELC || ACC_CC_WATCOMC)
|
||||||
# define ACC_UNUSED_LABEL(l) if (0) goto l
|
# define ACC_UNUSED_LABEL(l) if (0) goto l
|
||||||
# else
|
# else
|
||||||
# define ACC_UNUSED_LABEL(l) switch(0) case 1:goto l
|
# define ACC_UNUSED_LABEL(l) switch(0) case 1:goto l
|
||||||
@@ -1691,7 +1726,7 @@ extern "C" {
|
|||||||
#if !defined(ACC_UNCONST_CAST)
|
#if !defined(ACC_UNCONST_CAST)
|
||||||
# if 0 && defined(__cplusplus)
|
# if 0 && defined(__cplusplus)
|
||||||
# define ACC_UNCONST_CAST(t,e) (const_cast<t> (e))
|
# define ACC_UNCONST_CAST(t,e) (const_cast<t> (e))
|
||||||
# elif (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
# elif (ACC_CC_ARMCC_GNUC || ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
# define ACC_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((acc_uintptr_t) ((const void *) (e))))))
|
# define ACC_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((acc_uintptr_t) ((const void *) (e))))))
|
||||||
# else
|
# else
|
||||||
# define ACC_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e)))))
|
# define ACC_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e)))))
|
||||||
@@ -1713,6 +1748,10 @@ extern "C" {
|
|||||||
# define ACC_COMPILE_TIME_ASSERT(e) {typedef int __acc_cta_t[1-!(e)];}
|
# define ACC_COMPILE_TIME_ASSERT(e) {typedef int __acc_cta_t[1-!(e)];}
|
||||||
# elif (ACC_CC_DMC || ACC_CC_PACIFICC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
|
# elif (ACC_CC_DMC || ACC_CC_PACIFICC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
|
||||||
# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
|
# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
|
||||||
|
# elif (ACC_CC_GNUC >= 0x040700ul) && defined(__cplusplus)
|
||||||
|
# define ACC_COMPILE_TIME_ASSERT(e) {enum {__acc_cta_e=1/!!(e)} __attribute__((__unused__));}
|
||||||
|
# elif (ACC_CC_GNUC >= 0x040700ul)
|
||||||
|
# define ACC_COMPILE_TIME_ASSERT(e) {typedef int __acc_cta_t[1-2*!(e)] __attribute__((__unused__));}
|
||||||
# elif (ACC_CC_MSC && (_MSC_VER < 900))
|
# elif (ACC_CC_MSC && (_MSC_VER < 900))
|
||||||
# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
|
# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
|
||||||
# elif (ACC_CC_TURBOC && (__TURBOC__ == 0x0295))
|
# elif (ACC_CC_TURBOC && (__TURBOC__ == 0x0295))
|
||||||
@@ -1862,6 +1901,7 @@ extern "C" {
|
|||||||
#elif (ACC_ARCH_I386 && (ACC_OS_DOS32 || ACC_OS_WIN32) && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC))
|
#elif (ACC_ARCH_I386 && (ACC_OS_DOS32 || ACC_OS_WIN32) && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC))
|
||||||
# define ACC_ASM_SYNTAX_MSC 1
|
# define ACC_ASM_SYNTAX_MSC 1
|
||||||
#elif (ACC_OS_WIN64 && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC))
|
#elif (ACC_OS_WIN64 && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC))
|
||||||
|
#elif (ACC_ARCH_I386 && ACC_CC_GNUC && (ACC_CC_GNUC == 0x011f00ul))
|
||||||
#elif (ACC_ARCH_I386 && (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE))
|
#elif (ACC_ARCH_I386 && (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE))
|
||||||
# define ACC_ASM_SYNTAX_GNUC 1
|
# define ACC_ASM_SYNTAX_GNUC 1
|
||||||
#elif (ACC_ARCH_AMD64 && (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE))
|
#elif (ACC_ARCH_AMD64 && (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE))
|
||||||
@@ -2475,6 +2515,7 @@ extern "C" {
|
|||||||
# undef HAVE_ACCESS
|
# undef HAVE_ACCESS
|
||||||
# undef HAVE_CHMOD
|
# undef HAVE_CHMOD
|
||||||
# undef HAVE_CHOWN
|
# undef HAVE_CHOWN
|
||||||
|
# undef HAVE_FILENO
|
||||||
# undef HAVE_FSTAT
|
# undef HAVE_FSTAT
|
||||||
# undef HAVE_GETTIMEOFDAY
|
# undef HAVE_GETTIMEOFDAY
|
||||||
# undef HAVE_LSTAT
|
# undef HAVE_LSTAT
|
||||||
@@ -4465,12 +4506,14 @@ ACCLIB_EXTERN(int, acc_spawnve) (int mode, const char* fn, const char* const * a
|
|||||||
ACCCHK_ASSERT((((1ul << 31) + 1) >> 31) == 1)
|
ACCCHK_ASSERT((((1ul << 31) + 1) >> 31) == 1)
|
||||||
#endif
|
#endif
|
||||||
#if defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0150)
|
#if defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0150)
|
||||||
|
#elif 1 && (ACC_CC_ARMCC) && !defined(ACCCHK_CFG_PEDANTIC)
|
||||||
#elif 1 && (ACC_CC_SUNPROC) && !defined(ACCCHK_CFG_PEDANTIC)
|
#elif 1 && (ACC_CC_SUNPROC) && !defined(ACCCHK_CFG_PEDANTIC)
|
||||||
#else
|
#else
|
||||||
ACCCHK_ASSERT((1 << (8*SIZEOF_INT-1)) < 0)
|
ACCCHK_ASSERT((1 << (8*SIZEOF_INT-1)) < 0)
|
||||||
#endif
|
#endif
|
||||||
ACCCHK_ASSERT((1u << (8*SIZEOF_INT-1)) > 0)
|
ACCCHK_ASSERT((1u << (8*SIZEOF_INT-1)) > 0)
|
||||||
#if 1 && (ACC_CC_SUNPROC) && !defined(ACCCHK_CFG_PEDANTIC)
|
#if 1 && (ACC_CC_ARMCC) && !defined(ACCCHK_CFG_PEDANTIC)
|
||||||
|
#elif 1 && (ACC_CC_SUNPROC) && !defined(ACCCHK_CFG_PEDANTIC)
|
||||||
#else
|
#else
|
||||||
ACCCHK_ASSERT((1l << (8*SIZEOF_LONG-1)) < 0)
|
ACCCHK_ASSERT((1l << (8*SIZEOF_LONG-1)) < 0)
|
||||||
#endif
|
#endif
|
||||||
@@ -4699,6 +4742,7 @@ ACCLIB_EXTERN(int, acc_spawnve) (int mode, const char* fn, const char* const * a
|
|||||||
#if (ACC_CC_KEILC)
|
#if (ACC_CC_KEILC)
|
||||||
#elif (ACC_CC_NDPC)
|
#elif (ACC_CC_NDPC)
|
||||||
#elif 1 && (ACC_CC_LCC || ACC_CC_LCCWIN32) && !defined(ACCCHK_CFG_PEDANTIC)
|
#elif 1 && (ACC_CC_LCC || ACC_CC_LCCWIN32) && !defined(ACCCHK_CFG_PEDANTIC)
|
||||||
|
#elif 1 && (ACC_CC_ARMCC) && !defined(ACCCHK_CFG_PEDANTIC)
|
||||||
#elif 1 && (ACC_CC_SUNPROC) && !defined(ACCCHK_CFG_PEDANTIC)
|
#elif 1 && (ACC_CC_SUNPROC) && !defined(ACCCHK_CFG_PEDANTIC)
|
||||||
#elif !(ACC_BROKEN_INTEGRAL_PROMOTION) && (SIZEOF_INT > 1)
|
#elif !(ACC_BROKEN_INTEGRAL_PROMOTION) && (SIZEOF_INT > 1)
|
||||||
ACCCHK_ASSERT( (((unsigned char)128) << (int)(8*sizeof(int)-8)) < 0)
|
ACCCHK_ASSERT( (((unsigned char)128) << (int)(8*sizeof(int)-8)) < 0)
|
||||||
@@ -5234,10 +5278,10 @@ ACCLIB_PUBLIC(acc_uint64l_t, acc_randmt64_r64) (acc_randmt64_p r)
|
|||||||
# pragma warn(disable:2007)
|
# pragma warn(disable:2007)
|
||||||
#endif
|
#endif
|
||||||
#if (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_ASM_SYNTAX_GNUC)
|
#if (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_ASM_SYNTAX_GNUC)
|
||||||
#if (ACC_ARCH_AMD64 && ACC_CC_PATHSCALE)
|
#if (ACC_ARCH_AMD64 && ACC_CC_INTELC)
|
||||||
# define __ACCLIB_RDTSC_REGS : : "c" (t) : "cc", "memory", "rax", "rdx"
|
|
||||||
#elif (ACC_ARCH_AMD64 && ACC_CC_INTELC)
|
|
||||||
# define __ACCLIB_RDTSC_REGS : : "r" (t) : "memory", "rax", "rdx"
|
# define __ACCLIB_RDTSC_REGS : : "r" (t) : "memory", "rax", "rdx"
|
||||||
|
#elif (ACC_ARCH_AMD64 && ACC_CC_PATHSCALE)
|
||||||
|
# define __ACCLIB_RDTSC_REGS : : "c" (t) : "cc", "memory", "rax", "rdx"
|
||||||
#elif (ACC_ARCH_AMD64)
|
#elif (ACC_ARCH_AMD64)
|
||||||
# define __ACCLIB_RDTSC_REGS : : "r" (t) : "cc", "memory", "rax", "rdx"
|
# define __ACCLIB_RDTSC_REGS : : "r" (t) : "cc", "memory", "rax", "rdx"
|
||||||
#elif (ACC_ARCH_I386 && ACC_CC_GNUC && (ACC_CC_GNUC < 0x020000ul))
|
#elif (ACC_ARCH_I386 && ACC_CC_GNUC && (ACC_CC_GNUC < 0x020000ul))
|
||||||
@@ -5842,26 +5886,26 @@ ACCLIB_PUBLIC(long, acc_safe_hwrite) (int fd, const acc_hvoid_p buf, long size)
|
|||||||
#if !defined(ACCLIB_PUBLIC)
|
#if !defined(ACCLIB_PUBLIC)
|
||||||
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
|
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
|
||||||
#endif
|
#endif
|
||||||
#if 0 && (ACC_OS_POSIX_LINUX && ACC_ARCH_AMD64 && ACC_ASM_SYNTAX_GNUC)
|
#if 1 && (ACC_OS_POSIX_LINUX && ACC_ARCH_AMD64 && ACC_ASM_SYNTAX_GNUC)
|
||||||
#ifndef acc_pclock_syscall_clock_gettime
|
#ifndef acc_pclock_syscall_clock_gettime
|
||||||
#define acc_pclock_syscall_clock_gettime acc_pclock_syscall_clock_gettime
|
#define acc_pclock_syscall_clock_gettime acc_pclock_syscall_clock_gettime
|
||||||
#endif
|
#endif
|
||||||
static __acc_noinline long acc_pclock_syscall_clock_gettime(long clockid, struct timespec *ts)
|
static __acc_noinline long acc_pclock_syscall_clock_gettime(long clockid, struct timespec *ts)
|
||||||
{
|
{
|
||||||
long r;
|
unsigned long r = 228;
|
||||||
__asm__ __volatile__("syscall\n" : "=a" (r) : "0" (228), "D" (clockid), "S" (ts) : __ACC_ASM_CLOBBER);
|
__asm__ __volatile__("syscall\n" : "=a" (r) : "0" (r), "D" (clockid), "S" (ts) : __ACC_ASM_CLOBBER);
|
||||||
return r;
|
return (long) r;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if 0 && (ACC_OS_POSIX_LINUX && ACC_ARCH_I386 && ACC_ASM_SYNTAX_GNUC)
|
#if 1 && (ACC_OS_POSIX_LINUX && ACC_ARCH_I386 && ACC_ASM_SYNTAX_GNUC) && defined(acc_int64l_t)
|
||||||
#ifndef acc_pclock_syscall_clock_gettime
|
#ifndef acc_pclock_syscall_clock_gettime
|
||||||
#define acc_pclock_syscall_clock_gettime acc_pclock_syscall_clock_gettime
|
#define acc_pclock_syscall_clock_gettime acc_pclock_syscall_clock_gettime
|
||||||
#endif
|
#endif
|
||||||
static __acc_noinline long acc_pclock_syscall_clock_gettime(long clockid, struct timespec *ts)
|
static __acc_noinline long acc_pclock_syscall_clock_gettime(long clockid, struct timespec *ts)
|
||||||
{
|
{
|
||||||
long r;
|
unsigned long r = 265;
|
||||||
__asm__ __volatile__("int $0x80\n" : "=a" (r) : "0" (265), "b" (clockid), "c" (ts) : __ACC_ASM_CLOBBER);
|
__asm__ __volatile__("pushl %%ebx\n pushl %%edx\n popl %%ebx\n int $0x80\n popl %%ebx\n" : "=a" (r) : "0" (r), "d" (clockid), "c" (ts) : __ACC_ASM_CLOBBER);
|
||||||
return r;
|
return (long) r;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if 0 && defined(acc_pclock_syscall_clock_gettime)
|
#if 0 && defined(acc_pclock_syscall_clock_gettime)
|
||||||
@@ -5874,7 +5918,7 @@ static int acc_pclock_read_clock_gettime_r_syscall(acc_pclock_handle_p h, acc_pc
|
|||||||
if (acc_pclock_syscall_clock_gettime(0, &ts) != 0)
|
if (acc_pclock_syscall_clock_gettime(0, &ts) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
c->tv_sec = ts.tv_sec;
|
c->tv_sec = ts.tv_sec;
|
||||||
c->tv_nsec = ts.tv_nsec;
|
c->tv_nsec = (acc_uint32l_t) ts.tv_nsec;
|
||||||
ACC_UNUSED(h); return 0;
|
ACC_UNUSED(h); return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -5932,7 +5976,7 @@ static int acc_pclock_read_clock_gettime_m_syscall(acc_pclock_handle_p h, acc_pc
|
|||||||
if (acc_pclock_syscall_clock_gettime(1, &ts) != 0)
|
if (acc_pclock_syscall_clock_gettime(1, &ts) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
c->tv_sec = ts.tv_sec;
|
c->tv_sec = ts.tv_sec;
|
||||||
c->tv_nsec = ts.tv_nsec;
|
c->tv_nsec = (acc_uint32l_t) ts.tv_nsec;
|
||||||
ACC_UNUSED(h); return 0;
|
ACC_UNUSED(h); return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -5953,7 +5997,7 @@ static int acc_pclock_read_uclock(acc_pclock_handle_p h, acc_pclock_p c)
|
|||||||
ACC_UNUSED(h); return 0;
|
ACC_UNUSED(h); return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if 0 && (HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID) && defined(acc_int64l_t)
|
#if 1 && (HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID) && defined(acc_int64l_t)
|
||||||
#ifndef acc_pclock_read_clock_gettime_p_libc
|
#ifndef acc_pclock_read_clock_gettime_p_libc
|
||||||
#define acc_pclock_read_clock_gettime_p_libc acc_pclock_read_clock_gettime_p_libc
|
#define acc_pclock_read_clock_gettime_p_libc acc_pclock_read_clock_gettime_p_libc
|
||||||
#endif
|
#endif
|
||||||
@@ -5963,7 +6007,7 @@ static int acc_pclock_read_clock_gettime_p_libc(acc_pclock_handle_p h, acc_pcloc
|
|||||||
if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) != 0)
|
if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
c->tv_sec = ts.tv_sec;
|
c->tv_sec = ts.tv_sec;
|
||||||
c->tv_nsec = ts.tv_nsec;
|
c->tv_nsec = (acc_uint32l_t) ts.tv_nsec;
|
||||||
ACC_UNUSED(h); return 0;
|
ACC_UNUSED(h); return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -5977,7 +6021,7 @@ static int acc_pclock_read_clock_gettime_p_syscall(acc_pclock_handle_p h, acc_pc
|
|||||||
if (acc_pclock_syscall_clock_gettime(2, &ts) != 0)
|
if (acc_pclock_syscall_clock_gettime(2, &ts) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
c->tv_sec = ts.tv_sec;
|
c->tv_sec = ts.tv_sec;
|
||||||
c->tv_nsec = ts.tv_nsec;
|
c->tv_nsec = (acc_uint32l_t) ts.tv_nsec;
|
||||||
ACC_UNUSED(h); return 0;
|
ACC_UNUSED(h); return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -6041,7 +6085,7 @@ static int acc_pclock_read_perfctr(acc_pclock_handle_p h, acc_pclock_p c)
|
|||||||
ACC_UNUSED(h); return 0;
|
ACC_UNUSED(h); return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if 0 && (HAVE_CLOCK_GETTIME) && defined(CLOCK_THREAD_CPUTIME_ID) && defined(acc_int64l_t)
|
#if 1 && (HAVE_CLOCK_GETTIME) && defined(CLOCK_THREAD_CPUTIME_ID) && defined(acc_int64l_t)
|
||||||
#ifndef acc_pclock_read_clock_gettime_t_libc
|
#ifndef acc_pclock_read_clock_gettime_t_libc
|
||||||
#define acc_pclock_read_clock_gettime_t_libc acc_pclock_read_clock_gettime_t_libc
|
#define acc_pclock_read_clock_gettime_t_libc acc_pclock_read_clock_gettime_t_libc
|
||||||
#endif
|
#endif
|
||||||
@@ -6051,7 +6095,7 @@ static int acc_pclock_read_clock_gettime_t_libc(acc_pclock_handle_p h, acc_pcloc
|
|||||||
if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) != 0)
|
if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
c->tv_sec = ts.tv_sec;
|
c->tv_sec = ts.tv_sec;
|
||||||
c->tv_nsec = ts.tv_nsec;
|
c->tv_nsec = (acc_uint32l_t) ts.tv_nsec;
|
||||||
ACC_UNUSED(h); return 0;
|
ACC_UNUSED(h); return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -6065,7 +6109,7 @@ static int acc_pclock_read_clock_gettime_t_syscall(acc_pclock_handle_p h, acc_pc
|
|||||||
if (acc_pclock_syscall_clock_gettime(3, &ts) != 0)
|
if (acc_pclock_syscall_clock_gettime(3, &ts) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
c->tv_sec = ts.tv_sec;
|
c->tv_sec = ts.tv_sec;
|
||||||
c->tv_nsec = ts.tv_nsec;
|
c->tv_nsec = (acc_uint32l_t) ts.tv_nsec;
|
||||||
ACC_UNUSED(h); return 0;
|
ACC_UNUSED(h); return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -6776,7 +6820,8 @@ ACCLIB_PUBLIC_NOINLINE(void, acc_debug_break) (void)
|
|||||||
#elif (ACC_OS_WIN32) && (ACC_HAVE_WINDOWS_H)
|
#elif (ACC_OS_WIN32) && (ACC_HAVE_WINDOWS_H)
|
||||||
DebugBreak();
|
DebugBreak();
|
||||||
#else
|
#else
|
||||||
* (volatile int *) 0x1 = -1;
|
volatile size_t a = 0;
|
||||||
|
* (volatile unsigned long *) (volatile void *) a = ~0ul;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
ACCLIB_PUBLIC_NOINLINE(void, acc_debug_nop) (void)
|
ACCLIB_PUBLIC_NOINLINE(void, acc_debug_nop) (void)
|
||||||
@@ -6785,7 +6830,7 @@ ACCLIB_PUBLIC_NOINLINE(void, acc_debug_nop) (void)
|
|||||||
ACCLIB_PUBLIC_NOINLINE(int, acc_debug_align_check_query) (void)
|
ACCLIB_PUBLIC_NOINLINE(int, acc_debug_align_check_query) (void)
|
||||||
{
|
{
|
||||||
#if (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_ASM_SYNTAX_GNUC)
|
#if (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_ASM_SYNTAX_GNUC)
|
||||||
size_t r;
|
size_t r = 0;
|
||||||
__asm__ __volatile__("pushf\n pop %0\n" : "=a" (r) : : __ACC_ASM_CLOBBER);
|
__asm__ __volatile__("pushf\n pop %0\n" : "=a" (r) : : __ACC_ASM_CLOBBER);
|
||||||
return (int)(r >> 18) & 1;
|
return (int)(r >> 18) & 1;
|
||||||
#elif (ACC_ARCH_I386) && (ACC_ASM_SYNTAX_MSC)
|
#elif (ACC_ARCH_I386) && (ACC_ASM_SYNTAX_MSC)
|
||||||
@@ -6802,21 +6847,20 @@ ACCLIB_PUBLIC_NOINLINE(int, acc_debug_align_check_query) (void)
|
|||||||
}
|
}
|
||||||
ACCLIB_PUBLIC_NOINLINE(int, acc_debug_align_check_enable) (int v)
|
ACCLIB_PUBLIC_NOINLINE(int, acc_debug_align_check_enable) (int v)
|
||||||
{
|
{
|
||||||
int r;
|
|
||||||
#if (ACC_ARCH_AMD64) && (ACC_ASM_SYNTAX_GNUC)
|
#if (ACC_ARCH_AMD64) && (ACC_ASM_SYNTAX_GNUC)
|
||||||
if (v) {
|
if (v) {
|
||||||
__asm__ __volatile__("pushf\n orl $262144,(%%rsp)\n popf\n" : : : __ACC_ASM_CLOBBER);
|
__asm__ __volatile__("pushf\n orl $262144,(%%rsp)\n popf\n" : : : __ACC_ASM_CLOBBER);
|
||||||
} else {
|
} else {
|
||||||
__asm__ __volatile__("pushf\n andl $-262145,(%%rsp)\n popf\n" : : : __ACC_ASM_CLOBBER);
|
__asm__ __volatile__("pushf\n andl $-262145,(%%rsp)\n popf\n" : : : __ACC_ASM_CLOBBER);
|
||||||
}
|
}
|
||||||
r = 0;
|
return 0;
|
||||||
#elif (ACC_ARCH_I386) && (ACC_ASM_SYNTAX_GNUC)
|
#elif (ACC_ARCH_I386) && (ACC_ASM_SYNTAX_GNUC)
|
||||||
if (v) {
|
if (v) {
|
||||||
__asm__ __volatile__("pushf\n orl $262144,(%%esp)\n popf\n" : : : __ACC_ASM_CLOBBER);
|
__asm__ __volatile__("pushf\n orl $262144,(%%esp)\n popf\n" : : : __ACC_ASM_CLOBBER);
|
||||||
} else {
|
} else {
|
||||||
__asm__ __volatile__("pushf\n andl $-262145,(%%esp)\n popf\n" : : : __ACC_ASM_CLOBBER);
|
__asm__ __volatile__("pushf\n andl $-262145,(%%esp)\n popf\n" : : : __ACC_ASM_CLOBBER);
|
||||||
}
|
}
|
||||||
r = 0;
|
return 0;
|
||||||
#elif (ACC_ARCH_I386) && (ACC_ASM_SYNTAX_MSC)
|
#elif (ACC_ARCH_I386) && (ACC_ASM_SYNTAX_MSC)
|
||||||
if (v) { __asm {
|
if (v) { __asm {
|
||||||
pushf
|
pushf
|
||||||
@@ -6827,11 +6871,10 @@ ACCLIB_PUBLIC_NOINLINE(int, acc_debug_align_check_enable) (int v)
|
|||||||
and dword ptr [esp],-262145
|
and dword ptr [esp],-262145
|
||||||
popf
|
popf
|
||||||
}}
|
}}
|
||||||
r = 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
r = -1;
|
ACC_UNUSED(v); return -1;
|
||||||
#endif
|
#endif
|
||||||
ACC_UNUSED(v); return r;
|
|
||||||
}
|
}
|
||||||
ACCLIB_PUBLIC_NOINLINE(unsigned, acc_debug_running_on_qemu) (void)
|
ACCLIB_PUBLIC_NOINLINE(unsigned, acc_debug_running_on_qemu) (void)
|
||||||
{
|
{
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
-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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
@@ -146,6 +146,7 @@ struct options_t {
|
|||||||
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;
|
||||||
|
bool preserve_build_id; // copy the build-id to the compressed binary
|
||||||
} o_unix;
|
} o_unix;
|
||||||
struct {
|
struct {
|
||||||
bool le;
|
bool le;
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
@@ -599,7 +599,7 @@ void PackArmPe::pack(OutputFile *fo)
|
|||||||
if (((isection[ic].flags & (PEFL_WRITE|PEFL_SHARED))
|
if (((isection[ic].flags & (PEFL_WRITE|PEFL_SHARED))
|
||||||
== (PEFL_WRITE|PEFL_SHARED)))
|
== (PEFL_WRITE|PEFL_SHARED)))
|
||||||
if (!opt->force)
|
if (!opt->force)
|
||||||
throwCantPack("writeable shared sections not supported (try --force)");
|
throwCantPack("writable shared sections not supported (try --force)");
|
||||||
if (jc && isection[ic].rawdataptr - jc > ih.filealign)
|
if (jc && isection[ic].rawdataptr - jc > ih.filealign)
|
||||||
throwCantPack("superfluous data between sections");
|
throwCantPack("superfluous data between sections");
|
||||||
fi->seek(isection[ic].rawdataptr,SEEK_SET);
|
fi->seek(isection[ic].rawdataptr,SEEK_SET);
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
|
|||||||
+258
-48
@@ -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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2000-2011 John F. Reiser
|
Copyright (C) 2000-2013 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
|
||||||
@@ -51,6 +51,12 @@
|
|||||||
static unsigned const EF_ARM_EABI_VER4 = 0x04000000;
|
static unsigned const EF_ARM_EABI_VER4 = 0x04000000;
|
||||||
static unsigned const EF_ARM_EABI_VER5 = 0x05000000;
|
static unsigned const EF_ARM_EABI_VER5 = 0x05000000;
|
||||||
|
|
||||||
|
unsigned char PackLinuxElf::o_shstrtab[] = { \
|
||||||
|
/*start*/ '\0',
|
||||||
|
/*offset 1*/ '.','n','o','t','e','.','g','n','u','.','b','u','i','l','d','-','i','d','\0',
|
||||||
|
/*offset 20*/ '.','s','h','s','t','r','t','a','b','\0'
|
||||||
|
};
|
||||||
|
|
||||||
static unsigned
|
static unsigned
|
||||||
umin(unsigned a, unsigned b)
|
umin(unsigned a, unsigned b)
|
||||||
{
|
{
|
||||||
@@ -96,7 +102,7 @@ PackLinuxElf32::checkEhdr(Elf32_Ehdr const *ehdr) const
|
|||||||
int const type = get_te16(&ehdr->e_type);
|
int const type = get_te16(&ehdr->e_type);
|
||||||
if (type != Elf32_Ehdr::ET_EXEC && type != Elf32_Ehdr::ET_DYN)
|
if (type != Elf32_Ehdr::ET_EXEC && type != Elf32_Ehdr::ET_DYN)
|
||||||
return 2;
|
return 2;
|
||||||
if (get_te16(&ehdr->e_machine) != e_machine)
|
if (get_te16(&ehdr->e_machine) != (unsigned) e_machine)
|
||||||
return 3;
|
return 3;
|
||||||
if (get_te32(&ehdr->e_version) != Elf32_Ehdr::EV_CURRENT)
|
if (get_te32(&ehdr->e_version) != Elf32_Ehdr::EV_CURRENT)
|
||||||
return 4;
|
return 4;
|
||||||
@@ -129,7 +135,7 @@ int
|
|||||||
PackLinuxElf64::checkEhdr(Elf64_Ehdr const *ehdr) const
|
PackLinuxElf64::checkEhdr(Elf64_Ehdr const *ehdr) const
|
||||||
{
|
{
|
||||||
const unsigned char * const buf = ehdr->e_ident;
|
const unsigned char * const buf = ehdr->e_ident;
|
||||||
unsigned osabi0 = buf[Elf32_Ehdr::EI_OSABI];
|
unsigned char osabi0 = buf[Elf32_Ehdr::EI_OSABI];
|
||||||
if (0==osabi0) {
|
if (0==osabi0) {
|
||||||
osabi0 = opt->o_unix.osabi0;
|
osabi0 = opt->o_unix.osabi0;
|
||||||
}
|
}
|
||||||
@@ -147,7 +153,7 @@ PackLinuxElf64::checkEhdr(Elf64_Ehdr const *ehdr) const
|
|||||||
int const type = get_te16(&ehdr->e_type);
|
int const type = get_te16(&ehdr->e_type);
|
||||||
if (type != Elf64_Ehdr::ET_EXEC && type != Elf64_Ehdr::ET_DYN)
|
if (type != Elf64_Ehdr::ET_EXEC && type != Elf64_Ehdr::ET_DYN)
|
||||||
return 2;
|
return 2;
|
||||||
if (get_te16(&ehdr->e_machine) != e_machine)
|
if (get_te16(&ehdr->e_machine) != (unsigned) e_machine)
|
||||||
return 3;
|
return 3;
|
||||||
if (get_te32(&ehdr->e_version) != Elf64_Ehdr::EV_CURRENT)
|
if (get_te32(&ehdr->e_version) != Elf64_Ehdr::EV_CURRENT)
|
||||||
return 4;
|
return 4;
|
||||||
@@ -180,7 +186,8 @@ PackLinuxElf::PackLinuxElf(InputFile *f)
|
|||||||
: super(f), e_phnum(0), file_image(NULL), dynstr(NULL),
|
: super(f), e_phnum(0), file_image(NULL), dynstr(NULL),
|
||||||
sz_phdrs(0), sz_elf_hdrs(0), sz_pack2(0), sz_pack2a(0), sz_pack2b(0),
|
sz_phdrs(0), sz_elf_hdrs(0), sz_pack2(0), sz_pack2a(0), sz_pack2b(0),
|
||||||
lg2_page(12), page_size(1u<<lg2_page), xct_off(0), xct_va(0),
|
lg2_page(12), page_size(1u<<lg2_page), xct_off(0), xct_va(0),
|
||||||
e_machine(0), ei_class(0), ei_data(0), ei_osabi(0), osabi_note(NULL)
|
e_machine(0), ei_class(0), ei_data(0), ei_osabi(0), osabi_note(NULL),
|
||||||
|
o_elf_shnum(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,17 +196,6 @@ PackLinuxElf::~PackLinuxElf()
|
|||||||
delete[] file_image; file_image = NULL;
|
delete[] file_image; file_image = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Swap the byte ranges fo[a to b] and fo[b to c].
|
|
||||||
static void swap_byte_ranges(OutputFile *fo, unsigned a, unsigned b, unsigned c)
|
|
||||||
{
|
|
||||||
MemBuffer buf(c - a);
|
|
||||||
fo->seek(a, SEEK_SET);
|
|
||||||
fo->readx(buf, c - a);
|
|
||||||
fo->seek(a, SEEK_SET);
|
|
||||||
fo->rewrite(&buf[b - a], c - b);
|
|
||||||
fo->rewrite(&buf[0], b - a);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PackLinuxElf::pack3(OutputFile *fo, Filter &ft)
|
void PackLinuxElf::pack3(OutputFile *fo, Filter &ft)
|
||||||
{
|
{
|
||||||
sz_pack2b = fpad4(fo); // after headers, all PT_LOAD, gaps
|
sz_pack2b = fpad4(fo); // after headers, all PT_LOAD, gaps
|
||||||
@@ -238,16 +234,28 @@ void PackLinuxElf::pack3(OutputFile *fo, Filter &ft)
|
|||||||
get_te16(&linfo.l_lsize) + len - sz_pack2a));
|
get_te16(&linfo.l_lsize) + len - sz_pack2a));
|
||||||
|
|
||||||
len = fpad4(fo);
|
len = fpad4(fo);
|
||||||
// Put the loader in the middle, after the compressed PT_LOADs
|
|
||||||
// and before the compressed gaps (and debuginfo!)
|
|
||||||
// As first written, loader is fo[sz_pack2b to len],
|
|
||||||
// and gaps and debuginfo are fo[sz_pack2a to sz_pack2b].
|
|
||||||
swap_byte_ranges(fo, sz_pack2a, sz_pack2b, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackLinuxElf32::pack3(OutputFile *fo, Filter &ft)
|
void PackLinuxElf32::pack3(OutputFile *fo, Filter &ft)
|
||||||
{
|
{
|
||||||
super::pack3(fo, ft);
|
super::pack3(fo, ft); // loader follows compressed PT_LOADs
|
||||||
|
// Then compressed gaps (including debuginfo.)
|
||||||
|
unsigned total_in = 0, total_out = 0;
|
||||||
|
for (unsigned k = 0; k < e_phnum; ++k) {
|
||||||
|
Extent x;
|
||||||
|
x.size = find_LOAD_gap(phdri, k, e_phnum);
|
||||||
|
if (x.size) {
|
||||||
|
x.offset = get_te32(&phdri[k].p_offset) +
|
||||||
|
get_te32(&phdri[k].p_filesz);
|
||||||
|
packExtent(x, total_in, total_out, 0, fo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// write block end marker (uncompressed size 0)
|
||||||
|
b_info hdr; memset(&hdr, 0, sizeof(hdr));
|
||||||
|
set_le32(&hdr.sz_cpr, UPX_MAGIC_LE32);
|
||||||
|
fo->write(&hdr, sizeof(hdr));
|
||||||
|
fpad4(fo);
|
||||||
|
|
||||||
set_te32(&elfout.phdr[0].p_filesz, sz_pack2 + lsize);
|
set_te32(&elfout.phdr[0].p_filesz, sz_pack2 + lsize);
|
||||||
set_te32(&elfout.phdr[0].p_memsz, sz_pack2 + lsize);
|
set_te32(&elfout.phdr[0].p_memsz, sz_pack2 + lsize);
|
||||||
if (0!=xct_off) { // shared library
|
if (0!=xct_off) { // shared library
|
||||||
@@ -324,7 +332,24 @@ void PackLinuxElf32::pack3(OutputFile *fo, Filter &ft)
|
|||||||
|
|
||||||
void PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
|
void PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
|
||||||
{
|
{
|
||||||
super::pack3(fo, ft);
|
super::pack3(fo, ft); // loader follows compressed PT_LOADs
|
||||||
|
// Then compressed gaps (including debuginfo.)
|
||||||
|
unsigned total_in = 0, total_out = 0;
|
||||||
|
for (unsigned k = 0; k < e_phnum; ++k) {
|
||||||
|
Extent x;
|
||||||
|
x.size = find_LOAD_gap(phdri, k, e_phnum);
|
||||||
|
if (x.size) {
|
||||||
|
x.offset = get_te64(&phdri[k].p_offset) +
|
||||||
|
get_te64(&phdri[k].p_filesz);
|
||||||
|
packExtent(x, total_in, total_out, 0, fo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// write block end marker (uncompressed size 0)
|
||||||
|
b_info hdr; memset(&hdr, 0, sizeof(hdr));
|
||||||
|
set_le32(&hdr.sz_cpr, UPX_MAGIC_LE32);
|
||||||
|
fo->write(&hdr, sizeof(hdr));
|
||||||
|
fpad4(fo);
|
||||||
|
|
||||||
set_te64(&elfout.phdr[0].p_filesz, sz_pack2 + lsize);
|
set_te64(&elfout.phdr[0].p_filesz, sz_pack2 + lsize);
|
||||||
set_te64(&elfout.phdr[0].p_memsz, sz_pack2 + lsize);
|
set_te64(&elfout.phdr[0].p_memsz, sz_pack2 + lsize);
|
||||||
if (0!=xct_off) { // shared library
|
if (0!=xct_off) { // shared library
|
||||||
@@ -411,7 +436,10 @@ PackLinuxElf::addStubEntrySections(Filter const *)
|
|||||||
{
|
{
|
||||||
addLoader("ELFMAINX", NULL);
|
addLoader("ELFMAINX", NULL);
|
||||||
if (hasLoaderSection("ELFMAINXu")) {
|
if (hasLoaderSection("ELFMAINXu")) {
|
||||||
addLoader((opt->o_unix.unmap_all_pages ? "LUNMP000" : "LUNMP001"), "ELFMAINXu", NULL);
|
int const all_pages = opt->o_unix.unmap_all_pages ||
|
||||||
|
// brk() trouble if static
|
||||||
|
(Elf32_Ehdr::EM_ARM==e_machine && 0x8000==load_va);
|
||||||
|
addLoader((all_pages ? "LUNMP000" : "LUNMP001"), "ELFMAINXu", NULL);
|
||||||
}
|
}
|
||||||
//addLoader(getDecompressorSections(), NULL);
|
//addLoader(getDecompressorSections(), NULL);
|
||||||
addLoader(
|
addLoader(
|
||||||
@@ -1141,6 +1169,21 @@ Elf32_Shdr const *PackLinuxElf32::elf_find_section_name(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Elf64_Shdr const *PackLinuxElf64::elf_find_section_name(
|
||||||
|
char const *const name
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
Elf64_Shdr const *shdr = shdri;
|
||||||
|
int j = n_elf_shnum;
|
||||||
|
for (; 0 <=--j; ++shdr) {
|
||||||
|
unsigned ndx = get_te64(&shdr->sh_name);
|
||||||
|
if (0==strcmp(name, &shstrtab[ndx])) {
|
||||||
|
return shdr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Elf32_Shdr const *PackLinuxElf32::elf_find_section_type(
|
Elf32_Shdr const *PackLinuxElf32::elf_find_section_type(
|
||||||
unsigned const type
|
unsigned const type
|
||||||
) const
|
) const
|
||||||
@@ -1198,7 +1241,7 @@ bool PackLinuxElf32::canPack()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned osabi0 = u.buf[Elf32_Ehdr::EI_OSABI];
|
unsigned char osabi0 = u.buf[Elf32_Ehdr::EI_OSABI];
|
||||||
// The first PT_LOAD32 must cover the beginning of the file (0==p_offset).
|
// The first PT_LOAD32 must cover the beginning of the file (0==p_offset).
|
||||||
Elf32_Phdr const *phdr = (Elf32_Phdr const *)(u.buf + e_phoff);
|
Elf32_Phdr const *phdr = (Elf32_Phdr const *)(u.buf + e_phoff);
|
||||||
note_size = 0;
|
note_size = 0;
|
||||||
@@ -1249,10 +1292,9 @@ bool PackLinuxElf32::canPack()
|
|||||||
if (Elf32_Ehdr::ELFOSABI_NONE==osabi0) { // No EI_OSBAI, no PT_NOTE.
|
if (Elf32_Ehdr::ELFOSABI_NONE==osabi0) { // No EI_OSBAI, no PT_NOTE.
|
||||||
unsigned const arm_eabi = 0xff000000u & get_te32(&ehdr->e_flags);
|
unsigned const arm_eabi = 0xff000000u & get_te32(&ehdr->e_flags);
|
||||||
if (Elf32_Ehdr::EM_ARM==e_machine
|
if (Elf32_Ehdr::EM_ARM==e_machine
|
||||||
&& Elf32_Ehdr::ELFDATA2LSB==ei_data
|
|
||||||
&& (EF_ARM_EABI_VER5==arm_eabi
|
&& (EF_ARM_EABI_VER5==arm_eabi
|
||||||
|| EF_ARM_EABI_VER4==arm_eabi ) ) {
|
|| EF_ARM_EABI_VER4==arm_eabi ) ) {
|
||||||
// armel-eabi ARM little-endian Linux EABI version 4 is a mess.
|
// armel-eabi armeb-eabi ARM Linux EABI version 4 is a mess.
|
||||||
ei_osabi = osabi0 = Elf32_Ehdr::ELFOSABI_LINUX;
|
ei_osabi = osabi0 = Elf32_Ehdr::ELFOSABI_LINUX;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1652,8 +1694,14 @@ PackLinuxElf32::generateElfHdr(
|
|||||||
assert(get_te16(&h2->ehdr.e_ehsize) == sizeof(Elf32_Ehdr));
|
assert(get_te16(&h2->ehdr.e_ehsize) == sizeof(Elf32_Ehdr));
|
||||||
assert(get_te16(&h2->ehdr.e_phentsize) == sizeof(Elf32_Phdr));
|
assert(get_te16(&h2->ehdr.e_phentsize) == sizeof(Elf32_Phdr));
|
||||||
set_te16(&h2->ehdr.e_shentsize, sizeof(Elf32_Shdr));
|
set_te16(&h2->ehdr.e_shentsize, sizeof(Elf32_Shdr));
|
||||||
h2->ehdr.e_shnum = 0;
|
if (o_elf_shnum) {
|
||||||
h2->ehdr.e_shstrndx = 0;
|
h2->ehdr.e_shnum = o_elf_shnum;
|
||||||
|
h2->ehdr.e_shstrndx = o_elf_shnum - 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
h2->ehdr.e_shnum = 0;
|
||||||
|
h2->ehdr.e_shstrndx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
sz_elf_hdrs = sizeof(*h2) - sizeof(linfo); // default
|
sz_elf_hdrs = sizeof(*h2) - sizeof(linfo); // default
|
||||||
set_te32(&h2->phdr[0].p_filesz, sizeof(*h2)); // + identsize;
|
set_te32(&h2->phdr[0].p_filesz, sizeof(*h2)); // + identsize;
|
||||||
@@ -1878,8 +1926,14 @@ PackLinuxElf64::generateElfHdr(
|
|||||||
assert(get_te16(&h2->ehdr.e_ehsize) == sizeof(Elf64_Ehdr));
|
assert(get_te16(&h2->ehdr.e_ehsize) == sizeof(Elf64_Ehdr));
|
||||||
assert(get_te16(&h2->ehdr.e_phentsize) == sizeof(Elf64_Phdr));
|
assert(get_te16(&h2->ehdr.e_phentsize) == sizeof(Elf64_Phdr));
|
||||||
set_te16(&h2->ehdr.e_shentsize, sizeof(Elf64_Shdr));
|
set_te16(&h2->ehdr.e_shentsize, sizeof(Elf64_Shdr));
|
||||||
h2->ehdr.e_shnum = 0;
|
if (o_elf_shnum) {
|
||||||
h2->ehdr.e_shstrndx = 0;
|
h2->ehdr.e_shnum = o_elf_shnum;
|
||||||
|
h2->ehdr.e_shstrndx = o_elf_shnum - 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
h2->ehdr.e_shnum = 0;
|
||||||
|
h2->ehdr.e_shstrndx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
sz_elf_hdrs = sizeof(*h2) - sizeof(linfo); // default
|
sz_elf_hdrs = sizeof(*h2) - sizeof(linfo); // default
|
||||||
set_te64(&h2->phdr[0].p_filesz, sizeof(*h2)); // + identsize;
|
set_te64(&h2->phdr[0].p_filesz, sizeof(*h2)); // + identsize;
|
||||||
@@ -1965,6 +2019,65 @@ void PackLinuxElf32::pack1(OutputFile *fo, Filter & /*ft*/)
|
|||||||
memset(&linfo, 0, sizeof(linfo));
|
memset(&linfo, 0, sizeof(linfo));
|
||||||
fo->write(&linfo, sizeof(linfo));
|
fo->write(&linfo, sizeof(linfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the preserve build-id option was specified
|
||||||
|
if (opt->o_unix.preserve_build_id) {
|
||||||
|
n_elf_shnum = ehdri.e_shnum;
|
||||||
|
Elf32_Shdr *shdr = NULL;
|
||||||
|
|
||||||
|
Elf32_Shdr const *tmp = shdri;
|
||||||
|
|
||||||
|
if (! shdri) {
|
||||||
|
shdr = new Elf32_Shdr[n_elf_shnum];
|
||||||
|
|
||||||
|
fi->seek(0,SEEK_SET);
|
||||||
|
fi->seek(ehdri.e_shoff,SEEK_SET);
|
||||||
|
fi->readx((void*)shdr,ehdri.e_shentsize*ehdri.e_shnum);
|
||||||
|
|
||||||
|
// set this so we can use elf_find_section_name
|
||||||
|
shdri = (Elf32_Shdr *)shdr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//set the shstrtab
|
||||||
|
sec_strndx = &shdr[ehdri.e_shstrndx];
|
||||||
|
|
||||||
|
char *strtab = new char[(unsigned) sec_strndx->sh_size];
|
||||||
|
fi->seek(0,SEEK_SET);
|
||||||
|
fi->seek(sec_strndx->sh_offset,SEEK_SET);
|
||||||
|
fi->readx(strtab,sec_strndx->sh_size);
|
||||||
|
|
||||||
|
shstrtab = (const char*)strtab;
|
||||||
|
|
||||||
|
Elf32_Shdr const *buildid = elf_find_section_name(".note.gnu.build-id");
|
||||||
|
if (buildid) {
|
||||||
|
unsigned char *data = new unsigned char[(unsigned) buildid->sh_size];
|
||||||
|
memset(data,0,buildid->sh_size);
|
||||||
|
fi->seek(0,SEEK_SET);
|
||||||
|
fi->seek(buildid->sh_offset,SEEK_SET);
|
||||||
|
fi->readx(data,buildid->sh_size);
|
||||||
|
|
||||||
|
buildid_data = data;
|
||||||
|
|
||||||
|
o_elf_shnum = 3;
|
||||||
|
memset(&shdrout,0,sizeof(shdrout));
|
||||||
|
|
||||||
|
//setup the build-id
|
||||||
|
memcpy(&shdrout.shdr[1],buildid, sizeof(shdrout.shdr[1]));
|
||||||
|
shdrout.shdr[1].sh_name = 1;
|
||||||
|
|
||||||
|
//setup the shstrtab
|
||||||
|
memcpy(&shdrout.shdr[2],sec_strndx, sizeof(shdrout.shdr[2]));
|
||||||
|
shdrout.shdr[2].sh_name = 20;
|
||||||
|
shdrout.shdr[2].sh_size = 29; //size of our static shstrtab
|
||||||
|
}
|
||||||
|
|
||||||
|
// repoint shdr in case it is used by code some where else
|
||||||
|
if (shdr) {
|
||||||
|
shdri = tmp;
|
||||||
|
delete [] shdr;
|
||||||
|
shdr = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackLinuxElf32x86::pack1(OutputFile *fo, Filter &ft)
|
void PackLinuxElf32x86::pack1(OutputFile *fo, Filter &ft)
|
||||||
@@ -1998,6 +2111,9 @@ void PackLinuxElf32armLe::pack1(OutputFile *fo, Filter &ft)
|
|||||||
else {
|
else {
|
||||||
memcpy(&h3, stub_arm_linux_elf_fold, sizeof(Elf32_Ehdr) + 2*sizeof(Elf32_Phdr));
|
memcpy(&h3, stub_arm_linux_elf_fold, sizeof(Elf32_Ehdr) + 2*sizeof(Elf32_Phdr));
|
||||||
}
|
}
|
||||||
|
// Fighting over .e_ident[EI_ABIVERSION]: Debian armhf is latest culprit.
|
||||||
|
// So copy from input to output; but see PackLinuxElf32::generateElfHdr
|
||||||
|
memcpy(&h3.ehdr.e_ident[0], &ehdri.e_ident[0], sizeof(ehdri.e_ident));
|
||||||
set_te32(&h3.ehdr.e_flags, e_flags);
|
set_te32(&h3.ehdr.e_flags, e_flags);
|
||||||
generateElfHdr(fo, &h3, getbrk(phdri, e_phnum) );
|
generateElfHdr(fo, &h3, getbrk(phdri, e_phnum) );
|
||||||
}
|
}
|
||||||
@@ -2094,6 +2210,68 @@ void PackLinuxElf64::pack1(OutputFile *fo, Filter & /*ft*/)
|
|||||||
memset(&linfo, 0, sizeof(linfo));
|
memset(&linfo, 0, sizeof(linfo));
|
||||||
fo->write(&linfo, sizeof(linfo));
|
fo->write(&linfo, sizeof(linfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only execute if option present
|
||||||
|
if (opt->o_unix.preserve_build_id) {
|
||||||
|
// set this so we can use elf_find_section_name
|
||||||
|
n_elf_shnum = ehdri.e_shnum;
|
||||||
|
|
||||||
|
// there is a class member similar to this, but I did not
|
||||||
|
// want to assume it would be available
|
||||||
|
Elf64_Shdr const *tmp = shdri;
|
||||||
|
|
||||||
|
Elf64_Shdr *shdr = NULL;
|
||||||
|
|
||||||
|
if (! shdri) {
|
||||||
|
shdr = new Elf64_Shdr[n_elf_shnum];
|
||||||
|
|
||||||
|
fi->seek(0,SEEK_SET);
|
||||||
|
fi->seek(ehdri.e_shoff,SEEK_SET);
|
||||||
|
fi->readx((void*)shdr,ehdri.e_shentsize*ehdri.e_shnum);
|
||||||
|
|
||||||
|
// set this so we can use elf_find_section_name
|
||||||
|
shdri = (Elf64_Shdr *)shdr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//set the shstrtab
|
||||||
|
sec_strndx = &shdri[ehdri.e_shstrndx];
|
||||||
|
|
||||||
|
char *strtab = new char[(unsigned) sec_strndx->sh_size];
|
||||||
|
fi->seek(0,SEEK_SET);
|
||||||
|
fi->seek(sec_strndx->sh_offset,SEEK_SET);
|
||||||
|
fi->readx(strtab,sec_strndx->sh_size);
|
||||||
|
|
||||||
|
shstrtab = (const char*)strtab;
|
||||||
|
|
||||||
|
Elf64_Shdr const *buildid = elf_find_section_name(".note.gnu.build-id");
|
||||||
|
if (buildid) {
|
||||||
|
unsigned char *data = new unsigned char[(unsigned) buildid->sh_size];
|
||||||
|
memset(data,0,buildid->sh_size);
|
||||||
|
fi->seek(0,SEEK_SET);
|
||||||
|
fi->seek(buildid->sh_offset,SEEK_SET);
|
||||||
|
fi->readx(data,buildid->sh_size);
|
||||||
|
|
||||||
|
buildid_data = data;
|
||||||
|
|
||||||
|
o_elf_shnum = 3;
|
||||||
|
memset(&shdrout,0,sizeof(shdrout));
|
||||||
|
|
||||||
|
//setup the build-id
|
||||||
|
memcpy(&shdrout.shdr[1],buildid, sizeof(shdrout.shdr[1]));
|
||||||
|
shdrout.shdr[1].sh_name = 1;
|
||||||
|
|
||||||
|
//setup the shstrtab
|
||||||
|
memcpy(&shdrout.shdr[2],sec_strndx, sizeof(shdrout.shdr[2]));
|
||||||
|
shdrout.shdr[2].sh_name = 20;
|
||||||
|
shdrout.shdr[2].sh_size = 29; //size of our static shstrtab
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shdr) {
|
||||||
|
shdri = tmp;
|
||||||
|
delete [] shdr;
|
||||||
|
shdr = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackLinuxElf64amd::pack1(OutputFile *fo, Filter &ft)
|
void PackLinuxElf64amd::pack1(OutputFile *fo, Filter &ft)
|
||||||
@@ -2144,7 +2322,7 @@ unsigned PackLinuxElf32::find_LOAD_gap(
|
|||||||
return lo - hi;
|
return lo - hi;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackLinuxElf32::pack2(OutputFile *fo, Filter &ft)
|
int PackLinuxElf32::pack2(OutputFile *fo, Filter &ft)
|
||||||
{
|
{
|
||||||
Extent x;
|
Extent x;
|
||||||
unsigned k;
|
unsigned k;
|
||||||
@@ -2202,17 +2380,15 @@ void PackLinuxElf32::pack2(OutputFile *fo, Filter &ft)
|
|||||||
}
|
}
|
||||||
sz_pack2a = fpad4(fo);
|
sz_pack2a = fpad4(fo);
|
||||||
|
|
||||||
|
// Accounting only; ::pack3 will do the compression and output
|
||||||
for (k = 0; k < e_phnum; ++k) {
|
for (k = 0; k < e_phnum; ++k) {
|
||||||
x.size = find_LOAD_gap(phdri, k, e_phnum);
|
total_in += find_LOAD_gap(phdri, k, e_phnum);
|
||||||
if (x.size) {
|
|
||||||
x.offset = get_te32(&phdri[k].p_offset) +
|
|
||||||
get_te32(&phdri[k].p_filesz);
|
|
||||||
packExtent(x, total_in, total_out, 0, fo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((off_t)total_in != file_size)
|
if ((off_t)total_in != file_size)
|
||||||
throwEOFException();
|
throwEOFException();
|
||||||
|
|
||||||
|
return 0; // omit end-of-compression bhdr for now
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine length of gap between PT_LOAD phdr[k] and closest PT_LOAD
|
// Determine length of gap between PT_LOAD phdr[k] and closest PT_LOAD
|
||||||
@@ -2255,7 +2431,7 @@ unsigned PackLinuxElf64::find_LOAD_gap(
|
|||||||
return lo - hi;
|
return lo - hi;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackLinuxElf64::pack2(OutputFile *fo, Filter &ft)
|
int PackLinuxElf64::pack2(OutputFile *fo, Filter &ft)
|
||||||
{
|
{
|
||||||
Extent x;
|
Extent x;
|
||||||
unsigned k;
|
unsigned k;
|
||||||
@@ -2313,17 +2489,15 @@ void PackLinuxElf64::pack2(OutputFile *fo, Filter &ft)
|
|||||||
}
|
}
|
||||||
sz_pack2a = fpad4(fo);
|
sz_pack2a = fpad4(fo);
|
||||||
|
|
||||||
for (k = 0; k < e_phnum; ++k) {
|
// Accounting only; ::pack3 will do the compression and output
|
||||||
x.size = find_LOAD_gap(phdri, k, e_phnum);
|
for (k = 0; k < e_phnum; ++k) { //
|
||||||
if (x.size) {
|
total_in += find_LOAD_gap(phdri, k, e_phnum);
|
||||||
x.offset = get_te64(&phdri[k].p_offset) +
|
|
||||||
get_te64(&phdri[k].p_filesz);
|
|
||||||
packExtent(x, total_in, total_out, 0, fo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((off_t)total_in != file_size)
|
if ((off_t)total_in != file_size)
|
||||||
throwEOFException();
|
throwEOFException();
|
||||||
|
|
||||||
|
return 0; // omit end-of-compression bhdr for now
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter 0x50, 0x51 assume HostPolicy::isLE
|
// Filter 0x50, 0x51 assume HostPolicy::isLE
|
||||||
@@ -2601,6 +2775,24 @@ void PackLinuxElf32::pack4(OutputFile *fo, Filter &ft)
|
|||||||
{
|
{
|
||||||
overlay_offset = sz_elf_hdrs + sizeof(linfo);
|
overlay_offset = sz_elf_hdrs + sizeof(linfo);
|
||||||
|
|
||||||
|
if (opt->o_unix.preserve_build_id) {
|
||||||
|
// calc e_shoff here and write shdrout, then o_shstrtab
|
||||||
|
//NOTE: these are pushed last to ensure nothing is stepped on
|
||||||
|
//for the UPX structure.
|
||||||
|
unsigned const len = fpad4(fo);
|
||||||
|
set_te32(&elfout.ehdr.e_shoff,len);
|
||||||
|
|
||||||
|
int const ssize = sizeof(shdrout);
|
||||||
|
|
||||||
|
shdrout.shdr[2].sh_offset = len+ssize;
|
||||||
|
shdrout.shdr[1].sh_offset = shdrout.shdr[2].sh_offset+shdrout.shdr[2].sh_size;
|
||||||
|
|
||||||
|
fo->write(&shdrout, ssize);
|
||||||
|
|
||||||
|
fo->write(o_shstrtab,shdrout.shdr[2].sh_size);
|
||||||
|
fo->write(buildid_data,shdrout.shdr[1].sh_size);
|
||||||
|
}
|
||||||
|
|
||||||
// Cannot pre-round .p_memsz. If .p_filesz < .p_memsz, then kernel
|
// Cannot pre-round .p_memsz. If .p_filesz < .p_memsz, then kernel
|
||||||
// tries to make .bss, which requires PF_W.
|
// tries to make .bss, which requires PF_W.
|
||||||
// But strict SELinux (or PaX, grSecurity) disallows PF_W with PF_X.
|
// But strict SELinux (or PaX, grSecurity) disallows PF_W with PF_X.
|
||||||
@@ -2650,6 +2842,24 @@ void PackLinuxElf64::pack4(OutputFile *fo, Filter &ft)
|
|||||||
{
|
{
|
||||||
overlay_offset = sz_elf_hdrs + sizeof(linfo);
|
overlay_offset = sz_elf_hdrs + sizeof(linfo);
|
||||||
|
|
||||||
|
if (opt->o_unix.preserve_build_id) {
|
||||||
|
// calc e_shoff here and write shdrout, then o_shstrtab
|
||||||
|
//NOTE: these are pushed last to ensure nothing is stepped on
|
||||||
|
//for the UPX structure.
|
||||||
|
unsigned const len = fpad4(fo);
|
||||||
|
set_te64(&elfout.ehdr.e_shoff,len);
|
||||||
|
|
||||||
|
int const ssize = sizeof(shdrout);
|
||||||
|
|
||||||
|
shdrout.shdr[2].sh_offset = len+ssize;
|
||||||
|
shdrout.shdr[1].sh_offset = shdrout.shdr[2].sh_offset+shdrout.shdr[2].sh_size;
|
||||||
|
|
||||||
|
fo->write(&shdrout, ssize);
|
||||||
|
|
||||||
|
fo->write(o_shstrtab,shdrout.shdr[2].sh_size);
|
||||||
|
fo->write(buildid_data,shdrout.shdr[1].sh_size);
|
||||||
|
}
|
||||||
|
|
||||||
// Cannot pre-round .p_memsz. If .p_filesz < .p_memsz, then kernel
|
// Cannot pre-round .p_memsz. If .p_filesz < .p_memsz, then kernel
|
||||||
// tries to make .bss, which requires PF_W.
|
// tries to make .bss, which requires PF_W.
|
||||||
// But strict SELinux (or PaX, grSecurity) disallows PF_W with PF_X.
|
// But strict SELinux (or PaX, grSecurity) disallows PF_W with PF_X.
|
||||||
|
|||||||
+22
-6
@@ -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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2000-2011 John F. Reiser
|
Copyright (C) 2000-2013 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
|
||||||
@@ -50,7 +50,7 @@ protected:
|
|||||||
// because they depend on Elf32 or Elf64 data structures, which differ.
|
// because they depend on Elf32 or Elf64 data structures, which differ.
|
||||||
|
|
||||||
virtual void pack1(OutputFile *, Filter &) = 0; // generate executable header
|
virtual void pack1(OutputFile *, Filter &) = 0; // generate executable header
|
||||||
virtual void pack2(OutputFile *, Filter &) = 0; // append compressed data
|
virtual int pack2(OutputFile *, Filter &) = 0; // append compressed data
|
||||||
virtual void pack3(OutputFile *, Filter &) = 0; // append loader
|
virtual void pack3(OutputFile *, Filter &) = 0; // append loader
|
||||||
//virtual void pack4(OutputFile *, Filter &) = 0; // append pack header
|
//virtual void pack4(OutputFile *, Filter &) = 0; // append pack header
|
||||||
|
|
||||||
@@ -88,6 +88,10 @@ protected:
|
|||||||
unsigned char ei_data;
|
unsigned char ei_data;
|
||||||
unsigned char ei_osabi;
|
unsigned char ei_osabi;
|
||||||
char const *osabi_note;
|
char const *osabi_note;
|
||||||
|
|
||||||
|
unsigned char const *buildid_data;
|
||||||
|
int o_elf_shnum; // num output Shdrs
|
||||||
|
static unsigned char o_shstrtab[];
|
||||||
};
|
};
|
||||||
|
|
||||||
class PackLinuxElf32 : public PackLinuxElf
|
class PackLinuxElf32 : public PackLinuxElf
|
||||||
@@ -107,7 +111,7 @@ protected:
|
|||||||
virtual int ARM_is_QNX(void);
|
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 int pack2(OutputFile *, Filter &); // append compressed data
|
||||||
virtual void pack3(OutputFile *, Filter &); // append loader
|
virtual void pack3(OutputFile *, Filter &); // append loader
|
||||||
virtual void pack4(OutputFile *, Filter &); // append pack header
|
virtual void pack4(OutputFile *, Filter &); // append pack header
|
||||||
virtual void unpack(OutputFile *fo);
|
virtual void unpack(OutputFile *fo);
|
||||||
@@ -186,6 +190,12 @@ protected:
|
|||||||
|
|
||||||
cprElfHdrNetBSD elfout;
|
cprElfHdrNetBSD elfout;
|
||||||
|
|
||||||
|
__packed_struct(cprElfShdr3)
|
||||||
|
Elf32_Shdr shdr[3];
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
cprElfShdr3 shdrout;
|
||||||
|
|
||||||
struct Elf32_Nhdr {
|
struct Elf32_Nhdr {
|
||||||
unsigned namesz;
|
unsigned namesz;
|
||||||
unsigned descsz;
|
unsigned descsz;
|
||||||
@@ -218,7 +228,7 @@ protected:
|
|||||||
virtual int checkEhdr(Elf64_Ehdr const *ehdr) const;
|
virtual int checkEhdr(Elf64_Ehdr const *ehdr) const;
|
||||||
|
|
||||||
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 int pack2(OutputFile *, Filter &); // append compressed data
|
||||||
virtual void pack3(OutputFile *, Filter &); // append loader
|
virtual void pack3(OutputFile *, Filter &); // append loader
|
||||||
virtual void pack4(OutputFile *, Filter &); // append pack header
|
virtual void pack4(OutputFile *, Filter &); // append pack header
|
||||||
virtual void unpack(OutputFile *fo);
|
virtual void unpack(OutputFile *fo);
|
||||||
@@ -293,6 +303,12 @@ protected:
|
|||||||
|
|
||||||
cprElfHdr4 elfout;
|
cprElfHdr4 elfout;
|
||||||
|
|
||||||
|
__packed_struct(cprElfShdr3)
|
||||||
|
Elf64_Shdr shdr[3];
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
cprElfShdr3 shdrout;
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2001-2011 John F. Reiser
|
Copyright (C) 2001-2013 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
|
||||||
@@ -449,7 +449,7 @@ int PackLinuxI386::getLoaderPrefixSize() const
|
|||||||
// some ELF utitlity functions
|
// some ELF utitlity functions
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
// basic check of an Linux ELF Ehdr
|
// basic check of a Linux ELF Ehdr
|
||||||
int PackLinuxI386::checkEhdr(const Elf_LE32_Ehdr *ehdr) const
|
int PackLinuxI386::checkEhdr(const Elf_LE32_Ehdr *ehdr) const
|
||||||
{
|
{
|
||||||
const unsigned char * const buf = ehdr->e_ident;
|
const unsigned char * const buf = ehdr->e_ident;
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
|
|||||||
+6
-6
@@ -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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2000-2011 John F. Reiser
|
Copyright (C) 2000-2013 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
|
||||||
@@ -124,12 +124,12 @@ void PackLinuxElf32x86interp::pack1(OutputFile *fo, Filter &)
|
|||||||
#undef E
|
#undef E
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackLinuxElf32x86interp::pack2(OutputFile *fo, Filter &ft)
|
int PackLinuxElf32x86interp::pack2(OutputFile *fo, Filter &ft)
|
||||||
{
|
{
|
||||||
if (opt->o_unix.make_ptinterp) {
|
if (opt->o_unix.make_ptinterp) {
|
||||||
return; // ignore current input file!
|
return 1; // ignore current input file!
|
||||||
}
|
}
|
||||||
super::pack2(fo, ft);
|
return super::pack2(fo, ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef PAGE_MASK
|
#undef PAGE_MASK
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2000-2011 John F. Reiser
|
Copyright (C) 2000-2013 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
|
||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
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 int pack2(OutputFile *, Filter &); // append compressed data
|
||||||
virtual void pack3(OutputFile *, Filter &); // build loader
|
virtual void pack3(OutputFile *, Filter &); // build loader
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2000-2011 John F. Reiser
|
Copyright (C) 2000-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2000-2011 John F. Reiser
|
Copyright (C) 2000-2013 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
|
||||||
|
|||||||
+257
-64
@@ -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-2011 John Reiser
|
Copyright (C) 2004-2013 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
|
||||||
@@ -351,7 +351,7 @@ PackMachBase<T>::buildMachLoader(
|
|||||||
|
|
||||||
int const GAP = 128; // must match stub/l_mac_ppc.S
|
int const GAP = 128; // must match stub/l_mac_ppc.S
|
||||||
int const NO_LAP = 64; // must match stub/src/*darwin*.S
|
int const NO_LAP = 64; // must match stub/src/*darwin*.S
|
||||||
segcmdo.vmsize += h.sz_unc - h.sz_cpr + GAP + NO_LAP;
|
segTEXT.vmsize = h.sz_unc - h.sz_cpr + GAP + NO_LAP;
|
||||||
|
|
||||||
addStubEntrySections(ft);
|
addStubEntrySections(ft);
|
||||||
|
|
||||||
@@ -447,77 +447,211 @@ PackMachBase<T>::compare_segment_command(void const *const aa, void const *const
|
|||||||
unsigned const xb = b->cmd - lc_seg;
|
unsigned const xb = b->cmd - lc_seg;
|
||||||
if (xa < xb) return -1; // LC_SEGMENT first
|
if (xa < xb) return -1; // LC_SEGMENT first
|
||||||
if (xa > xb) return 1;
|
if (xa > xb) return 1;
|
||||||
if (a->vmaddr < b->vmaddr) return -1; // ascending by .vmaddr
|
// Beware 0==.vmsize (some MacOSX __DWARF debug info: a "comment")
|
||||||
if (a->vmaddr > b->vmaddr) return 1;
|
if (a->vmsize!=0 && b->vmsize!=0) {
|
||||||
|
if (a->vmaddr < b->vmaddr) return -1; // ascending by .vmaddr
|
||||||
|
if (a->vmaddr > b->vmaddr) return 1;
|
||||||
|
}
|
||||||
|
else { // 0==.vmsize goes last, except ordered by fileoff
|
||||||
|
if (a->vmsize) return -1; // 'a' is first
|
||||||
|
if (b->vmsize) return 1; // 'a' is last
|
||||||
|
if (a->fileoff < b->fileoff)
|
||||||
|
return -1;
|
||||||
|
if (a->fileoff > b->fileoff)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef PAGE_MASK
|
||||||
|
#undef PAGE_SIZE
|
||||||
|
#define PAGE_MASK (~0u<<12)
|
||||||
|
#define PAGE_SIZE (0u-PAGE_MASK)
|
||||||
|
|
||||||
|
#undef PAGE_MASK64
|
||||||
|
#undef PAGE_SIZE64
|
||||||
|
#define PAGE_MASK64 (~(acc_uint64l_t)0<<12)
|
||||||
|
#define PAGE_SIZE64 ((acc_uint64l_t)0-PAGE_MASK64)
|
||||||
|
|
||||||
|
// At 2013-02-03 part of the source for codesign was
|
||||||
|
// http://opensource.apple.com/source/cctools/cctools-836/libstuff/ofile.c
|
||||||
|
|
||||||
void PackMachPPC32::pack4(OutputFile *fo, Filter &ft) // append PackHeader
|
void PackMachPPC32::pack4(OutputFile *fo, Filter &ft) // append PackHeader
|
||||||
{
|
{
|
||||||
// offset of p_info in compressed file
|
// offset of p_info in compressed file
|
||||||
overlay_offset = sizeof(mhdro) + sizeof(segcmdo) + sizeof(threado) + sizeof(linfo);
|
overlay_offset = sizeof(mhdro) + sizeof(segZERO)
|
||||||
|
+ sizeof(segXHDR) + sizeof(secXHDR)
|
||||||
|
+ sizeof(segTEXT) + sizeof(secTEXT)
|
||||||
|
+ sizeof(segLINK) + sizeof(threado) + sizeof(linfo);
|
||||||
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
overlay_offset += sizeof(uuid_cmd) + sizeof(linkitem);
|
||||||
|
}
|
||||||
|
|
||||||
super::pack4(fo, ft);
|
super::pack4(fo, ft);
|
||||||
segcmdo.filesize = fo->getBytesWritten();
|
unsigned const t = fo->getBytesWritten();
|
||||||
segcmdo.vmsize += segcmdo.filesize;
|
segTEXT.filesize = t;
|
||||||
|
segTEXT.vmsize += t; // utilize GAP + NO_LAP + sz_unc - sz_cpr
|
||||||
|
secTEXT.offset = overlay_offset - sizeof(linfo);
|
||||||
|
secTEXT.addr = segTEXT.vmaddr + secTEXT.offset;
|
||||||
|
secTEXT.size = segTEXT.vmsize - secTEXT.offset;
|
||||||
|
secXHDR.offset = overlay_offset - sizeof(linfo);
|
||||||
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
secXHDR.offset -= sizeof(uuid_cmd) + sizeof(linkitem);
|
||||||
|
}
|
||||||
|
secXHDR.addr += secXHDR.offset;
|
||||||
|
unsigned foff1 = (PAGE_MASK & (~PAGE_MASK + segTEXT.filesize));
|
||||||
|
if (foff1 < segTEXT.vmsize)
|
||||||
|
foff1 += PAGE_SIZE; // codesign disallows overhang
|
||||||
|
segLINK.fileoff = foff1;
|
||||||
|
segLINK.vmaddr = segTEXT.vmaddr + foff1;
|
||||||
|
fo->seek(foff1 - 1, SEEK_SET); fo->write("", 1);
|
||||||
fo->seek(sizeof(mhdro), SEEK_SET);
|
fo->seek(sizeof(mhdro), SEEK_SET);
|
||||||
fo->rewrite(&segcmdo, sizeof(segcmdo));
|
fo->rewrite(&segZERO, sizeof(segZERO));
|
||||||
|
fo->rewrite(&segXHDR, sizeof(segXHDR));
|
||||||
|
fo->rewrite(&secXHDR, sizeof(secXHDR));
|
||||||
|
fo->rewrite(&segTEXT, sizeof(segTEXT));
|
||||||
|
fo->rewrite(&secTEXT, sizeof(secTEXT));
|
||||||
|
fo->rewrite(&segLINK, sizeof(segLINK));
|
||||||
fo->rewrite(&threado, sizeof(threado));
|
fo->rewrite(&threado, sizeof(threado));
|
||||||
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
fo->rewrite(&uuid_cmd, sizeof(uuid_cmd));
|
||||||
|
fo->rewrite(&linkitem, sizeof(linkitem));
|
||||||
|
}
|
||||||
fo->rewrite(&linfo, sizeof(linfo));
|
fo->rewrite(&linfo, sizeof(linfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackMachI386::pack4(OutputFile *fo, Filter &ft) // append PackHeader
|
void PackMachI386::pack4(OutputFile *fo, Filter &ft) // append PackHeader
|
||||||
{
|
{
|
||||||
// offset of p_info in compressed file
|
// offset of p_info in compressed file
|
||||||
overlay_offset = sizeof(mhdro) + sizeof(segcmdo) + sizeof(threado) + sizeof(linfo);
|
overlay_offset = sizeof(mhdro) + sizeof(segZERO)
|
||||||
|
+ sizeof(segXHDR) + sizeof(secXHDR)
|
||||||
|
+ sizeof(segTEXT) + sizeof(secTEXT)
|
||||||
|
+ sizeof(segLINK) + sizeof(threado) + sizeof(linfo);
|
||||||
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
overlay_offset += sizeof(uuid_cmd) + sizeof(linkitem);
|
||||||
|
}
|
||||||
|
|
||||||
super::pack4(fo, ft);
|
super::pack4(fo, ft);
|
||||||
segcmdo.filesize = fo->getBytesWritten();
|
unsigned const t = fo->getBytesWritten();
|
||||||
segcmdo.vmsize += segcmdo.filesize;
|
segTEXT.filesize = t;
|
||||||
|
segTEXT.vmsize += t; // utilize GAP + NO_LAP + sz_unc - sz_cpr
|
||||||
|
secTEXT.offset = overlay_offset - sizeof(linfo);
|
||||||
|
secTEXT.addr = segTEXT.vmaddr + secTEXT.offset;
|
||||||
|
secTEXT.size = segTEXT.vmsize - secTEXT.offset;
|
||||||
|
secXHDR.offset = overlay_offset - sizeof(linfo);
|
||||||
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
secXHDR.offset -= sizeof(uuid_cmd) + sizeof(linkitem);
|
||||||
|
}
|
||||||
|
secXHDR.addr += secXHDR.offset;
|
||||||
|
unsigned foff1 = (PAGE_MASK & (~PAGE_MASK + segTEXT.filesize));
|
||||||
|
if (foff1 < segTEXT.vmsize)
|
||||||
|
foff1 += PAGE_SIZE; // codesign disallows overhang
|
||||||
|
segLINK.fileoff = foff1;
|
||||||
|
segLINK.vmaddr = segTEXT.vmaddr + foff1;
|
||||||
|
fo->seek(foff1 - 1, SEEK_SET); fo->write("", 1);
|
||||||
fo->seek(sizeof(mhdro), SEEK_SET);
|
fo->seek(sizeof(mhdro), SEEK_SET);
|
||||||
fo->rewrite(&segcmdo, sizeof(segcmdo));
|
fo->rewrite(&segZERO, sizeof(segZERO));
|
||||||
|
fo->rewrite(&segXHDR, sizeof(segXHDR));
|
||||||
|
fo->rewrite(&secXHDR, sizeof(secXHDR));
|
||||||
|
fo->rewrite(&segTEXT, sizeof(segTEXT));
|
||||||
|
fo->rewrite(&secTEXT, sizeof(secTEXT));
|
||||||
|
fo->rewrite(&segLINK, sizeof(segLINK));
|
||||||
fo->rewrite(&threado, sizeof(threado));
|
fo->rewrite(&threado, sizeof(threado));
|
||||||
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
fo->rewrite(&uuid_cmd, sizeof(uuid_cmd));
|
||||||
|
fo->rewrite(&linkitem, sizeof(linkitem));
|
||||||
|
}
|
||||||
fo->rewrite(&linfo, sizeof(linfo));
|
fo->rewrite(&linfo, sizeof(linfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackMachAMD64::pack4(OutputFile *fo, Filter &ft) // append PackHeader
|
void PackMachAMD64::pack4(OutputFile *fo, Filter &ft) // append PackHeader
|
||||||
{
|
{
|
||||||
// offset of p_info in compressed file
|
// offset of p_info in compressed file
|
||||||
overlay_offset = sizeof(mhdro) + sizeof(segcmdo) + sizeof(threado) + sizeof(linfo);
|
overlay_offset = sizeof(mhdro) + sizeof(segZERO)
|
||||||
|
+ sizeof(segXHDR) + sizeof(secXHDR)
|
||||||
|
+ sizeof(segTEXT) + sizeof(secTEXT)
|
||||||
|
+ sizeof(segLINK) + sizeof(threado) + sizeof(linfo);
|
||||||
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
overlay_offset += sizeof(uuid_cmd) + sizeof(linkitem);
|
||||||
|
}
|
||||||
|
|
||||||
super::pack4(fo, ft);
|
super::pack4(fo, ft);
|
||||||
segcmdo.filesize = fo->getBytesWritten();
|
unsigned const t = fo->getBytesWritten();
|
||||||
segcmdo.vmsize += segcmdo.filesize;
|
segTEXT.filesize = t;
|
||||||
|
segTEXT.vmsize += t; // utilize GAP + NO_LAP + sz_unc - sz_cpr
|
||||||
|
secTEXT.offset = overlay_offset - sizeof(linfo);
|
||||||
|
secTEXT.addr = segTEXT.vmaddr + secTEXT.offset;
|
||||||
|
secTEXT.size = segTEXT.vmsize - secTEXT.offset;
|
||||||
|
secXHDR.offset = overlay_offset - sizeof(linfo);
|
||||||
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
secXHDR.offset -= sizeof(uuid_cmd) + sizeof(linkitem);
|
||||||
|
}
|
||||||
|
secXHDR.addr += secXHDR.offset;
|
||||||
|
unsigned foff1 = (PAGE_MASK & (~PAGE_MASK + segTEXT.filesize));
|
||||||
|
if (foff1 < segTEXT.vmsize)
|
||||||
|
foff1 += PAGE_SIZE; // codesign disallows overhang
|
||||||
|
segLINK.fileoff = foff1;
|
||||||
|
segLINK.vmaddr = segTEXT.vmaddr + foff1;
|
||||||
|
fo->seek(foff1 - 1, SEEK_SET); fo->write("", 1);
|
||||||
fo->seek(sizeof(mhdro), SEEK_SET);
|
fo->seek(sizeof(mhdro), SEEK_SET);
|
||||||
fo->rewrite(&segcmdo, sizeof(segcmdo));
|
fo->rewrite(&segZERO, sizeof(segZERO));
|
||||||
|
fo->rewrite(&segXHDR, sizeof(segXHDR));
|
||||||
|
fo->rewrite(&secXHDR, sizeof(secXHDR));
|
||||||
|
fo->rewrite(&segTEXT, sizeof(segTEXT));
|
||||||
|
fo->rewrite(&secTEXT, sizeof(secTEXT));
|
||||||
|
fo->rewrite(&segLINK, sizeof(segLINK));
|
||||||
fo->rewrite(&threado, sizeof(threado));
|
fo->rewrite(&threado, sizeof(threado));
|
||||||
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
fo->rewrite(&uuid_cmd, sizeof(uuid_cmd));
|
||||||
|
fo->rewrite(&linkitem, sizeof(linkitem));
|
||||||
|
}
|
||||||
fo->rewrite(&linfo, sizeof(linfo));
|
fo->rewrite(&linfo, sizeof(linfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackMachARMEL::pack4(OutputFile *fo, Filter &ft) // append PackHeader
|
void PackMachARMEL::pack4(OutputFile *fo, Filter &ft) // append PackHeader
|
||||||
{
|
{
|
||||||
// offset of p_info in compressed file
|
// offset of p_info in compressed file
|
||||||
overlay_offset = sizeof(mhdro) + sizeof(segcmdo) + sizeof(threado) + sizeof(linfo);
|
overlay_offset = sizeof(mhdro) + sizeof(segZERO)
|
||||||
|
+ sizeof(segXHDR) + sizeof(secXHDR)
|
||||||
|
+ sizeof(segTEXT) + sizeof(secTEXT)
|
||||||
|
+ sizeof(segLINK) + sizeof(threado) + sizeof(linfo);
|
||||||
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
overlay_offset += sizeof(uuid_cmd) + sizeof(linkitem);
|
||||||
|
}
|
||||||
|
|
||||||
super::pack4(fo, ft);
|
super::pack4(fo, ft);
|
||||||
segcmdo.filesize = fo->getBytesWritten();
|
unsigned const t = fo->getBytesWritten();
|
||||||
segcmdo.vmsize += segcmdo.filesize;
|
segTEXT.filesize = t;
|
||||||
|
segTEXT.vmsize += t; // utilize GAP + NO_LAP + sz_unc - sz_cpr
|
||||||
|
secTEXT.offset = overlay_offset - sizeof(linfo);
|
||||||
|
secTEXT.addr = segTEXT.vmaddr + secTEXT.offset;
|
||||||
|
secTEXT.size = segTEXT.vmsize - secTEXT.offset;
|
||||||
|
secXHDR.offset = overlay_offset - sizeof(linfo);
|
||||||
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
secXHDR.offset -= sizeof(uuid_cmd) + sizeof(linkitem);
|
||||||
|
}
|
||||||
|
secXHDR.addr += secXHDR.offset;
|
||||||
|
unsigned foff1 = (PAGE_MASK & (~PAGE_MASK + segTEXT.filesize));
|
||||||
|
if (foff1 < segTEXT.vmsize)
|
||||||
|
foff1 += PAGE_SIZE; // codesign disallows overhang
|
||||||
|
segLINK.fileoff = foff1;
|
||||||
|
segLINK.vmaddr = segTEXT.vmaddr + foff1;
|
||||||
|
fo->seek(foff1 - 1, SEEK_SET); fo->write("", 1);
|
||||||
fo->seek(sizeof(mhdro), SEEK_SET);
|
fo->seek(sizeof(mhdro), SEEK_SET);
|
||||||
fo->rewrite(&segcmdo, sizeof(segcmdo));
|
fo->rewrite(&segZERO, sizeof(segZERO));
|
||||||
|
fo->rewrite(&segXHDR, sizeof(segXHDR));
|
||||||
|
fo->rewrite(&secXHDR, sizeof(secXHDR));
|
||||||
|
fo->rewrite(&segTEXT, sizeof(segTEXT));
|
||||||
|
fo->rewrite(&secTEXT, sizeof(secTEXT));
|
||||||
|
fo->rewrite(&segLINK, sizeof(segLINK));
|
||||||
fo->rewrite(&threado, sizeof(threado));
|
fo->rewrite(&threado, sizeof(threado));
|
||||||
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
|
fo->rewrite(&uuid_cmd, sizeof(uuid_cmd));
|
||||||
|
fo->rewrite(&linkitem, sizeof(linkitem));
|
||||||
|
}
|
||||||
fo->rewrite(&linfo, sizeof(linfo));
|
fo->rewrite(&linfo, sizeof(linfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef PAGE_MASK
|
|
||||||
#undef PAGE_SIZE
|
|
||||||
#define PAGE_MASK (~0u<<12)
|
|
||||||
#define PAGE_SIZE -PAGE_MASK
|
|
||||||
|
|
||||||
#undef PAGE_MASK64
|
|
||||||
#undef PAGE_SIZE64
|
|
||||||
#define PAGE_MASK64 (~(acc_uint64l_t)0<<12)
|
|
||||||
#define PAGE_SIZE64 -PAGE_MASK64
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void PackMachBase<T>::pack4dylib( // append PackHeader
|
void PackMachBase<T>::pack4dylib( // append PackHeader
|
||||||
OutputFile *const fo,
|
OutputFile *const fo,
|
||||||
@@ -726,7 +860,7 @@ void PackMachPPC32::pack3(OutputFile *fo, Filter &ft) // append loader
|
|||||||
disp = 4+ len - sz_mach_headers; // 4: sizeof(instruction)
|
disp = 4+ len - sz_mach_headers; // 4: sizeof(instruction)
|
||||||
fo->write(&disp, sizeof(disp));
|
fo->write(&disp, sizeof(disp));
|
||||||
|
|
||||||
threado.state.srr0 = len + segcmdo.vmaddr; /* entry address */
|
threado.state.srr0 = len + segTEXT.vmaddr; /* entry address */
|
||||||
super::pack3(fo, ft);
|
super::pack3(fo, ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -740,7 +874,7 @@ void PackMachI386::pack3(OutputFile *fo, Filter &ft) // append loader
|
|||||||
disp = len - sz_mach_headers;
|
disp = len - sz_mach_headers;
|
||||||
fo->write(&disp, sizeof(disp));
|
fo->write(&disp, sizeof(disp));
|
||||||
|
|
||||||
threado.state.eip = len + sizeof(disp) + segcmdo.vmaddr; /* entry address */
|
threado.state.eip = len + sizeof(disp) + segTEXT.vmaddr; /* entry address */
|
||||||
super::pack3(fo, ft);
|
super::pack3(fo, ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -754,7 +888,7 @@ void PackMachAMD64::pack3(OutputFile *fo, Filter &ft) // append loader
|
|||||||
disp = len - sz_mach_headers;
|
disp = len - sz_mach_headers;
|
||||||
fo->write(&disp, sizeof(disp));
|
fo->write(&disp, sizeof(disp));
|
||||||
|
|
||||||
threado.state.rip = len + sizeof(disp) + segcmdo.vmaddr; /* entry address */
|
threado.state.rip = len + sizeof(disp) + segTEXT.vmaddr; /* entry address */
|
||||||
super::pack3(fo, ft);
|
super::pack3(fo, ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -768,7 +902,7 @@ void PackMachARMEL::pack3(OutputFile *fo, Filter &ft) // append loader
|
|||||||
disp = len - sz_mach_headers;
|
disp = len - sz_mach_headers;
|
||||||
fo->write(&disp, sizeof(disp));
|
fo->write(&disp, sizeof(disp));
|
||||||
|
|
||||||
threado.state.pc = len + sizeof(disp) + segcmdo.vmaddr; /* entry address */
|
threado.state.pc = len + sizeof(disp) + segTEXT.vmaddr; /* entry address */
|
||||||
super::pack3(fo, ft);
|
super::pack3(fo, ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -899,7 +1033,7 @@ void PackMachBase<T>::pack3(OutputFile *fo, Filter &ft)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void PackMachBase<T>::pack2(OutputFile *fo, Filter &ft) // append compressed body
|
int PackMachBase<T>::pack2(OutputFile *fo, Filter &ft) // append compressed body
|
||||||
{
|
{
|
||||||
unsigned const lc_seg = lc_segment[sizeof(Addr)>>3];
|
unsigned const lc_seg = lc_segment[sizeof(Addr)>>3];
|
||||||
Extent x;
|
Extent x;
|
||||||
@@ -976,7 +1110,10 @@ void PackMachBase<T>::pack2(OutputFile *fo, Filter &ft) // append compressed bo
|
|||||||
if (my_filetype!=Mach_header::MH_DYLIB)
|
if (my_filetype!=Mach_header::MH_DYLIB)
|
||||||
if ((off_t)total_in != file_size)
|
if ((off_t)total_in != file_size)
|
||||||
throwEOFException();
|
throwEOFException();
|
||||||
segcmdo.filesize = fo->getBytesWritten();
|
segTEXT.filesize = fo->getBytesWritten();
|
||||||
|
secTEXT.size = segTEXT.filesize - overlay_offset + sizeof(linfo);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackMachPPC32::pack1_setup_threado(OutputFile *const fo)
|
void PackMachPPC32::pack1_setup_threado(OutputFile *const fo)
|
||||||
@@ -1025,34 +1162,82 @@ void PackMachBase<T>::pack1(OutputFile *const fo, Filter &/*ft*/) // generate e
|
|||||||
unsigned const lc_seg = lc_segment[sizeof(Addr)>>3];
|
unsigned const lc_seg = lc_segment[sizeof(Addr)>>3];
|
||||||
mhdro = mhdri;
|
mhdro = mhdri;
|
||||||
if (my_filetype==Mach_header::MH_EXECUTE) {
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
mhdro.ncmds = 2;
|
mhdro.ncmds = 5; // __ZERO, __XHDR, __TEXT, __LINKEDIT, THREAD_STATE
|
||||||
mhdro.sizeofcmds = sizeof(segcmdo) + my_thread_command_size;
|
mhdro.sizeofcmds = sizeof(segZERO)
|
||||||
|
+ sizeof(segXHDR) + sizeof(secXHDR)
|
||||||
|
+ sizeof(segTEXT) + sizeof(secTEXT) + sizeof(segLINK) +
|
||||||
|
my_thread_command_size /* + sizeof(uuid_cmd) + sizeof(linkitem) */ ;
|
||||||
mhdro.flags = Mach_header::MH_NOUNDEFS;
|
mhdro.flags = Mach_header::MH_NOUNDEFS;
|
||||||
}
|
}
|
||||||
fo->write(&mhdro, sizeof(mhdro));
|
fo->write(&mhdro, sizeof(mhdro));
|
||||||
|
|
||||||
segcmdo.cmd = lc_seg;
|
memset(&segZERO, 0, sizeof(segZERO));
|
||||||
segcmdo.cmdsize = sizeof(segcmdo);
|
segZERO.cmd = lc_seg;
|
||||||
strncpy((char *)segcmdo.segname, "__TEXT", sizeof(segcmdo.segname));
|
segZERO.cmdsize = sizeof(segZERO);
|
||||||
|
strncpy((char *)segZERO.segname, "__PAGEZERO", sizeof(segZERO.segname));
|
||||||
|
segZERO.vmsize = PAGE_SIZE;
|
||||||
|
|
||||||
|
segTEXT.cmd = lc_seg;
|
||||||
|
segTEXT.cmdsize = sizeof(segTEXT) + sizeof(secTEXT);
|
||||||
|
strncpy((char *)segTEXT.segname, "__TEXT", sizeof(segTEXT.segname));
|
||||||
if (my_filetype==Mach_header::MH_EXECUTE) {
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
segcmdo.vmaddr = PAGE_MASK64 & (~PAGE_MASK64 +
|
int k; // must ignore zero-length segments, which sort last
|
||||||
msegcmd[n_segment -1].vmsize + msegcmd[n_segment -1].vmaddr );
|
for (k=n_segment; --k>=0; )
|
||||||
|
if (msegcmd[k].vmsize!=0)
|
||||||
|
break;
|
||||||
|
segTEXT.vmaddr = PAGE_MASK64 & (~PAGE_MASK64 +
|
||||||
|
msegcmd[k].vmsize + msegcmd[k].vmaddr );
|
||||||
}
|
}
|
||||||
if (my_filetype==Mach_header::MH_DYLIB) {
|
if (my_filetype==Mach_header::MH_DYLIB) {
|
||||||
segcmdo.vmaddr = 0;
|
segTEXT.vmaddr = 0;
|
||||||
}
|
}
|
||||||
segcmdo.vmsize = 0; // adjust later
|
segTEXT.vmsize = 0; // adjust later
|
||||||
segcmdo.fileoff = 0;
|
segTEXT.fileoff = 0;
|
||||||
segcmdo.filesize = 0; // adjust later
|
segTEXT.filesize = 0; // adjust later
|
||||||
segcmdo.initprot = segcmdo.maxprot =
|
segTEXT.initprot = segTEXT.maxprot =
|
||||||
Mach_segment_command::VM_PROT_READ |
|
Mach_segment_command::VM_PROT_READ |
|
||||||
Mach_segment_command::VM_PROT_WRITE |
|
Mach_segment_command::VM_PROT_WRITE |
|
||||||
Mach_segment_command::VM_PROT_EXECUTE;
|
Mach_segment_command::VM_PROT_EXECUTE;
|
||||||
segcmdo.nsects = 0;
|
segTEXT.nsects = 1; // secTEXT
|
||||||
segcmdo.flags = 0;
|
segTEXT.flags = 0;
|
||||||
|
|
||||||
|
memset(&secTEXT, 0, sizeof(secTEXT));
|
||||||
|
strncpy((char *)secTEXT.sectname, "__text", sizeof(secTEXT.sectname));
|
||||||
|
memcpy(secTEXT.segname, segTEXT.segname, sizeof(secTEXT.segname));
|
||||||
|
secTEXT.align = 2; // (1<<2) ==> 4
|
||||||
|
|
||||||
|
segXHDR = segTEXT;
|
||||||
|
segXHDR.vmaddr = PAGE_SIZE;
|
||||||
|
segXHDR.vmsize = PAGE_SIZE;
|
||||||
|
segXHDR.filesize = PAGE_SIZE;
|
||||||
|
strncpy((char *)segXHDR.segname, "__XHDR", sizeof(segXHDR.segname));
|
||||||
|
|
||||||
|
memset(&secXHDR, 0, sizeof(secXHDR));
|
||||||
|
strncpy((char *)secXHDR.sectname, "__xhdr", sizeof(secXHDR.sectname));
|
||||||
|
memcpy(secXHDR.segname, segXHDR.segname, sizeof(secXHDR.segname));
|
||||||
|
secXHDR.addr = PAGE_SIZE;
|
||||||
|
secXHDR.size = 0; // empty so far
|
||||||
|
secXHDR.align = 2; // (1<<2) ==> 4
|
||||||
|
|
||||||
|
segLINK = segTEXT;
|
||||||
|
segLINK.cmdsize = sizeof(segLINK);
|
||||||
|
strncpy((char *)segLINK.segname, "__LINKEDIT", sizeof(segLINK.segname));
|
||||||
|
segLINK.nsects = 0;
|
||||||
|
segLINK.initprot = Mach_segment_command::VM_PROT_READ;
|
||||||
|
// Adjust later: .vmaddr .vmsize .fileoff .filesize
|
||||||
|
|
||||||
if (my_filetype==Mach_header::MH_EXECUTE) {
|
if (my_filetype==Mach_header::MH_EXECUTE) {
|
||||||
fo->write(&segcmdo, sizeof(segcmdo));
|
fo->write(&segZERO, sizeof(segZERO));
|
||||||
|
fo->write(&segXHDR, sizeof(segXHDR));
|
||||||
|
fo->write(&secXHDR, sizeof(secXHDR));
|
||||||
|
fo->write(&segTEXT, sizeof(segTEXT));
|
||||||
|
fo->write(&secTEXT, sizeof(secTEXT));
|
||||||
|
fo->write(&segLINK, sizeof(segLINK));
|
||||||
pack1_setup_threado(fo);
|
pack1_setup_threado(fo);
|
||||||
|
memset(&uuid_cmd, 0, sizeof(uuid_cmd));
|
||||||
|
fo->write(&uuid_cmd, sizeof(uuid_cmd));
|
||||||
|
memset(&linkitem, 0, sizeof(linkitem));
|
||||||
|
fo->write(&linkitem, sizeof(linkitem));
|
||||||
}
|
}
|
||||||
if (my_filetype==Mach_header::MH_DYLIB) {
|
if (my_filetype==Mach_header::MH_DYLIB) {
|
||||||
fo->write(rawmseg, mhdri.sizeofcmds);
|
fo->write(rawmseg, mhdri.sizeofcmds);
|
||||||
@@ -1073,7 +1258,11 @@ void PackMachBase<T>::unpack(OutputFile *fo)
|
|||||||
fi->readx(&mhdri, sizeof(mhdri));
|
fi->readx(&mhdri, sizeof(mhdri));
|
||||||
rawmseg = (Mach_segment_command *)new char[(unsigned) mhdri.sizeofcmds];
|
rawmseg = (Mach_segment_command *)new char[(unsigned) mhdri.sizeofcmds];
|
||||||
fi->readx(rawmseg, mhdri.sizeofcmds);
|
fi->readx(rawmseg, mhdri.sizeofcmds);
|
||||||
overlay_offset = sizeof(mhdri) + mhdri.sizeofcmds + sizeof(linfo);
|
|
||||||
|
// FIXME forgot space left for LC_CODE_SIGNATURE;
|
||||||
|
// but PackUnix::canUnpack() sets overlay_offset anyway.
|
||||||
|
//overlay_offset = sizeof(mhdri) + mhdri.sizeofcmds + sizeof(linfo);
|
||||||
|
|
||||||
fi->seek(overlay_offset, SEEK_SET);
|
fi->seek(overlay_offset, SEEK_SET);
|
||||||
p_info hbuf;
|
p_info hbuf;
|
||||||
fi->readx(&hbuf, sizeof(hbuf));
|
fi->readx(&hbuf, sizeof(hbuf));
|
||||||
@@ -1126,6 +1315,8 @@ void PackMachBase<T>::unpack(OutputFile *fo)
|
|||||||
) {
|
) {
|
||||||
if (lc_seg==sc->cmd
|
if (lc_seg==sc->cmd
|
||||||
&& 0!=sc->filesize ) {
|
&& 0!=sc->filesize ) {
|
||||||
|
if (fo)
|
||||||
|
fo->seek(sc->fileoff, SEEK_SET);
|
||||||
unsigned filesize = sc->filesize;
|
unsigned filesize = sc->filesize;
|
||||||
unpackExtent(filesize, fo, total_in, total_out,
|
unpackExtent(filesize, fo, total_in, total_out,
|
||||||
c_adler, u_adler, false, sizeof(bhdr));
|
c_adler, u_adler, false, sizeof(bhdr));
|
||||||
@@ -1147,11 +1338,13 @@ void PackMachBase<T>::unpack(OutputFile *fo)
|
|||||||
if (lc_seg==rc->cmd
|
if (lc_seg==rc->cmd
|
||||||
&& 0!=rc->filesize ) {
|
&& 0!=rc->filesize ) {
|
||||||
fi->seek(rc->fileoff, SEEK_SET);
|
fi->seek(rc->fileoff, SEEK_SET);
|
||||||
fo->seek(sc->fileoff, SEEK_SET);
|
if (fo)
|
||||||
|
fo->seek(sc->fileoff, SEEK_SET);
|
||||||
unsigned const len = rc->filesize;
|
unsigned const len = rc->filesize;
|
||||||
MemBuffer data(len);
|
MemBuffer data(len);
|
||||||
fi->readx(data, len);
|
fi->readx(data, len);
|
||||||
fo->write(data, len);
|
if (fo)
|
||||||
|
fo->write(data, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1159,14 +1352,14 @@ void PackMachBase<T>::unpack(OutputFile *fo)
|
|||||||
for (unsigned j = 0; j < ncmds; ++j) {
|
for (unsigned j = 0; j < ncmds; ++j) {
|
||||||
unsigned const size = find_SEGMENT_gap(j);
|
unsigned const size = find_SEGMENT_gap(j);
|
||||||
if (size) {
|
if (size) {
|
||||||
unsigned const where = msegcmd[k].fileoff +msegcmd[k].filesize;
|
unsigned const where = msegcmd[j].fileoff +msegcmd[j].filesize;
|
||||||
if (fo)
|
if (fo)
|
||||||
fo->seek(where, SEEK_SET);
|
fo->seek(where, SEEK_SET);
|
||||||
unpackExtent(size, fo, total_in, total_out,
|
unpackExtent(size, fo, total_in, total_out,
|
||||||
c_adler, u_adler, false, sizeof(bhdr));
|
c_adler, u_adler, false, sizeof(bhdr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete mhdr;
|
delete [] mhdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1207,19 +1400,19 @@ bool PackMachBase<T>::canPack()
|
|||||||
// Put LC_SEGMENT together at the beginning, ascending by .vmaddr.
|
// Put LC_SEGMENT together at the beginning, ascending by .vmaddr.
|
||||||
qsort(msegcmd, ncmds, sizeof(*msegcmd), compare_segment_command);
|
qsort(msegcmd, ncmds, sizeof(*msegcmd), compare_segment_command);
|
||||||
|
|
||||||
// Check that LC_SEGMENTs form one contiguous chunk of the file.
|
// Check alignment of non-null LC_SEGMENT.
|
||||||
for (unsigned j= 0; j < ncmds; ++j) {
|
for (unsigned j= 0; j < ncmds; ++j) {
|
||||||
if (lc_seg==msegcmd[j].cmd) {
|
if (lc_seg==msegcmd[j].cmd) {
|
||||||
if (~PAGE_MASK & (msegcmd[j].fileoff | msegcmd[j].vmaddr)) {
|
if (~PAGE_MASK & (msegcmd[j].fileoff | msegcmd[j].vmaddr)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (0 < j) {
|
if (msegcmd[j].vmsize==0)
|
||||||
unsigned const sz = PAGE_MASK
|
break; // was sorted last
|
||||||
& (~PAGE_MASK + msegcmd[j-1].filesize);
|
|
||||||
if ((sz + msegcmd[j-1].fileoff)!=msegcmd[j].fileoff) {
|
// We used to check that LC_SEGMENTS were contiguous,
|
||||||
return false;
|
// but apparently that is not needed anymore,
|
||||||
}
|
// and Google compilers generate strange layouts.
|
||||||
}
|
|
||||||
++n_segment;
|
++n_segment;
|
||||||
sz_segment = msegcmd[j].filesize + msegcmd[j].fileoff - msegcmd[0].fileoff;
|
sz_segment = msegcmd[j].filesize + msegcmd[j].fileoff - msegcmd[0].fileoff;
|
||||||
}
|
}
|
||||||
|
|||||||
+48
-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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
@@ -269,6 +269,25 @@ __packed_struct(Mach_twolevel_hints_command)
|
|||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
__packed_struct_end()
|
||||||
|
|
||||||
|
template <class TMachITypes>
|
||||||
|
__packed_struct(Mach_linkedit_data_command)
|
||||||
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
|
Word cmd;
|
||||||
|
Word cmdsize;
|
||||||
|
Word dataoff; // file offset of data in __LINKEDIT segment
|
||||||
|
Word datasize; // file size of data in __LINKEDIT segment
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
template <class TMachITypes>
|
||||||
|
__packed_struct(Mach_uuid_command)
|
||||||
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
|
Word cmd;
|
||||||
|
Word cmdsize;
|
||||||
|
unsigned char uuid[16];
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_ppc_thread_state)
|
__packed_struct(Mach_ppc_thread_state)
|
||||||
typedef typename TMachITypes::Addr Addr;
|
typedef typename TMachITypes::Addr Addr;
|
||||||
@@ -392,6 +411,8 @@ struct MachClass_32
|
|||||||
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<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;
|
||||||
|
typedef N_Mach::Mach_linkedit_data_command<MachITypes> Mach_linkedit_data_command;
|
||||||
|
typedef N_Mach::Mach_uuid_command<MachITypes> Mach_uuid_command;
|
||||||
typedef N_Mach::Mach_ppc_thread_state<MachITypes> Mach_ppc_thread_state;
|
typedef N_Mach::Mach_ppc_thread_state<MachITypes> Mach_ppc_thread_state;
|
||||||
typedef N_Mach::Mach_i386_thread_state<MachITypes> Mach_i386_thread_state;
|
typedef N_Mach::Mach_i386_thread_state<MachITypes> Mach_i386_thread_state;
|
||||||
typedef N_Mach::Mach_AMD64_thread_state<MachITypes> Mach_AMD64_thread_state;
|
typedef N_Mach::Mach_AMD64_thread_state<MachITypes> Mach_AMD64_thread_state;
|
||||||
@@ -428,6 +449,8 @@ struct MachClass_64
|
|||||||
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_64<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;
|
||||||
|
typedef N_Mach::Mach_linkedit_data_command<MachITypes> Mach_linkedit_data_command;
|
||||||
|
typedef N_Mach::Mach_uuid_command<MachITypes> Mach_uuid_command;
|
||||||
|
|
||||||
static void compileTimeAssertions() {
|
static void compileTimeAssertions() {
|
||||||
BeLePolicy::compileTimeAssertions();
|
BeLePolicy::compileTimeAssertions();
|
||||||
@@ -452,6 +475,8 @@ typedef MachClass_Host32::Mach_dysymtab_command Mach32_dysymtab_command;
|
|||||||
typedef MachClass_Host32::Mach_segsplit_info_command Mach32_segsplit_info_command;
|
typedef MachClass_Host32::Mach_segsplit_info_command Mach32_segsplit_info_command;
|
||||||
typedef MachClass_Host32::Mach_routines_command Mach32_routines_command;
|
typedef MachClass_Host32::Mach_routines_command Mach32_routines_command;
|
||||||
typedef MachClass_Host32::Mach_twolevel_hints_command Mach32_twolevel_hints_command;
|
typedef MachClass_Host32::Mach_twolevel_hints_command Mach32_twolevel_hints_command;
|
||||||
|
typedef MachClass_Host32::Mach_linkedit_data_command Mach32_linkedit_data_command;
|
||||||
|
typedef MachClass_Host32::Mach_uuid_command Mach32_uuid_command;
|
||||||
|
|
||||||
typedef MachClass_Host64::Mach_segment_command Mach64_segment_command;
|
typedef MachClass_Host64::Mach_segment_command Mach64_segment_command;
|
||||||
typedef MachClass_Host64::Mach_section_command Mach64_section_command;
|
typedef MachClass_Host64::Mach_section_command Mach64_section_command;
|
||||||
@@ -460,6 +485,8 @@ typedef MachClass_Host64::Mach_dysymtab_command Mach64_dysymtab_command;
|
|||||||
typedef MachClass_Host64::Mach_segsplit_info_command Mach64_segsplit_info_command;
|
typedef MachClass_Host64::Mach_segsplit_info_command Mach64_segsplit_info_command;
|
||||||
typedef MachClass_Host64::Mach_routines_command Mach64_routines_command;
|
typedef MachClass_Host64::Mach_routines_command Mach64_routines_command;
|
||||||
typedef MachClass_Host64::Mach_twolevel_hints_command Mach64_twolevel_hints_command;
|
typedef MachClass_Host64::Mach_twolevel_hints_command Mach64_twolevel_hints_command;
|
||||||
|
typedef MachClass_Host64::Mach_linkedit_data_command Mach64_linkedit_data_command;
|
||||||
|
typedef MachClass_Host64::Mach_uuid_command Mach64_uuid_command;
|
||||||
|
|
||||||
typedef MachClass_BE32::Mach_segment_command MachBE32_segment_command;
|
typedef MachClass_BE32::Mach_segment_command MachBE32_segment_command;
|
||||||
typedef MachClass_BE32::Mach_section_command MachBE32_section_command;
|
typedef MachClass_BE32::Mach_section_command MachBE32_section_command;
|
||||||
@@ -468,6 +495,8 @@ typedef MachClass_BE32::Mach_dysymtab_command MachBE32_dysymtab_command;
|
|||||||
typedef MachClass_BE32::Mach_segsplit_info_command MachBE32_segsplit_info_command;
|
typedef MachClass_BE32::Mach_segsplit_info_command MachBE32_segsplit_info_command;
|
||||||
typedef MachClass_BE32::Mach_routines_command MachBE32_routines_command;
|
typedef MachClass_BE32::Mach_routines_command MachBE32_routines_command;
|
||||||
typedef MachClass_BE32::Mach_twolevel_hints_command MachBE32_twolevel_hints_command;
|
typedef MachClass_BE32::Mach_twolevel_hints_command MachBE32_twolevel_hints_command;
|
||||||
|
typedef MachClass_BE32::Mach_linkedit_data_command MachBE32_linkedit_data_command;
|
||||||
|
typedef MachClass_BE32::Mach_uuid_command MachBE32_uuid_command;
|
||||||
|
|
||||||
typedef MachClass_BE64::Mach_segment_command MachBE64_segment_command;
|
typedef MachClass_BE64::Mach_segment_command MachBE64_segment_command;
|
||||||
typedef MachClass_BE64::Mach_section_command MachBE64_section_command;
|
typedef MachClass_BE64::Mach_section_command MachBE64_section_command;
|
||||||
@@ -476,6 +505,8 @@ typedef MachClass_BE64::Mach_dysymtab_command MachBE64_dysymtab_command;
|
|||||||
typedef MachClass_BE64::Mach_segsplit_info_command MachBE64_segsplit_info_command;
|
typedef MachClass_BE64::Mach_segsplit_info_command MachBE64_segsplit_info_command;
|
||||||
typedef MachClass_BE64::Mach_routines_command MachBE64_routines_command;
|
typedef MachClass_BE64::Mach_routines_command MachBE64_routines_command;
|
||||||
typedef MachClass_BE64::Mach_twolevel_hints_command MachBE64_twolevel_hints_command;
|
typedef MachClass_BE64::Mach_twolevel_hints_command MachBE64_twolevel_hints_command;
|
||||||
|
typedef MachClass_BE64::Mach_linkedit_data_command MachBE64_linkedit_data_command;
|
||||||
|
typedef MachClass_BE64::Mach_uuid_command MachBE64_uuid_command;
|
||||||
|
|
||||||
typedef MachClass_LE32::Mach_segment_command MachLE32_segment_command;
|
typedef MachClass_LE32::Mach_segment_command MachLE32_segment_command;
|
||||||
typedef MachClass_LE32::Mach_section_command MachLE32_section_command;
|
typedef MachClass_LE32::Mach_section_command MachLE32_section_command;
|
||||||
@@ -484,6 +515,8 @@ typedef MachClass_LE32::Mach_dysymtab_command MachLE32_dysymtab_command;
|
|||||||
typedef MachClass_LE32::Mach_segsplit_info_command MachLE32_segsplit_info_command;
|
typedef MachClass_LE32::Mach_segsplit_info_command MachLE32_segsplit_info_command;
|
||||||
typedef MachClass_LE32::Mach_routines_command MachLE32_routines_command;
|
typedef MachClass_LE32::Mach_routines_command MachLE32_routines_command;
|
||||||
typedef MachClass_LE32::Mach_twolevel_hints_command MachLE32_twolevel_hints_command;
|
typedef MachClass_LE32::Mach_twolevel_hints_command MachLE32_twolevel_hints_command;
|
||||||
|
typedef MachClass_LE32::Mach_linkedit_data_command MachLE32_linkedit_data_command;
|
||||||
|
typedef MachClass_LE32::Mach_uuid_command MachLE32_uuid_command;
|
||||||
|
|
||||||
typedef MachClass_LE64::Mach_segment_command MachLE64_segment_command;
|
typedef MachClass_LE64::Mach_segment_command MachLE64_segment_command;
|
||||||
typedef MachClass_LE64::Mach_section_command MachLE64_section_command;
|
typedef MachClass_LE64::Mach_section_command MachLE64_section_command;
|
||||||
@@ -492,6 +525,8 @@ typedef MachClass_LE64::Mach_dysymtab_command MachLE64_dysymtab_command;
|
|||||||
typedef MachClass_LE64::Mach_segsplit_info_command MachLE64_segsplit_info_command;
|
typedef MachClass_LE64::Mach_segsplit_info_command MachLE64_segsplit_info_command;
|
||||||
typedef MachClass_LE64::Mach_routines_command MachLE64_routines_command;
|
typedef MachClass_LE64::Mach_routines_command MachLE64_routines_command;
|
||||||
typedef MachClass_LE64::Mach_twolevel_hints_command MachLE64_twolevel_hints_command;
|
typedef MachClass_LE64::Mach_twolevel_hints_command MachLE64_twolevel_hints_command;
|
||||||
|
typedef MachClass_LE64::Mach_linkedit_data_command MachLE64_linkedit_data_command;
|
||||||
|
typedef MachClass_LE64::Mach_uuid_command MachLE64_uuid_command;
|
||||||
|
|
||||||
typedef MachClass_BE32::Mach_ppc_thread_state Mach_ppc_thread_state;
|
typedef MachClass_BE32::Mach_ppc_thread_state Mach_ppc_thread_state;
|
||||||
typedef MachClass_LE32::Mach_i386_thread_state Mach_i386_thread_state;
|
typedef MachClass_LE32::Mach_i386_thread_state Mach_i386_thread_state;
|
||||||
@@ -522,6 +557,8 @@ protected:
|
|||||||
typedef typename MachClass::Mach_segsplit_info_command Mach_segsplit_info_command;
|
typedef typename MachClass::Mach_segsplit_info_command Mach_segsplit_info_command;
|
||||||
typedef typename MachClass::Mach_routines_command Mach_routines_command;
|
typedef typename MachClass::Mach_routines_command Mach_routines_command;
|
||||||
typedef typename MachClass::Mach_twolevel_hints_command Mach_twolevel_hints_command;
|
typedef typename MachClass::Mach_twolevel_hints_command Mach_twolevel_hints_command;
|
||||||
|
typedef typename MachClass::Mach_linkedit_data_command Mach_linkedit_data_command;
|
||||||
|
typedef typename MachClass::Mach_uuid_command Mach_uuid_command;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PackMachBase(InputFile *, unsigned cpuid, unsigned filetype,
|
PackMachBase(InputFile *, unsigned cpuid, unsigned filetype,
|
||||||
@@ -532,7 +569,7 @@ public:
|
|||||||
|
|
||||||
// called by the generic pack()
|
// called by the generic pack()
|
||||||
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 int pack2(OutputFile *, Filter &); // append compressed data
|
||||||
virtual void pack3(OutputFile *, Filter &) = 0; // append loader
|
virtual void pack3(OutputFile *, Filter &) = 0; // append loader
|
||||||
virtual void pack4(OutputFile *, Filter &) = 0; // append PackHeader
|
virtual void pack4(OutputFile *, Filter &) = 0; // append PackHeader
|
||||||
|
|
||||||
@@ -575,7 +612,14 @@ protected:
|
|||||||
Mach_header mhdri;
|
Mach_header mhdri;
|
||||||
|
|
||||||
Mach_header mhdro;
|
Mach_header mhdro;
|
||||||
Mach_segment_command segcmdo;
|
Mach_segment_command segZERO;
|
||||||
|
Mach_segment_command segXHDR; // location to put eXtra headers
|
||||||
|
Mach_section_command secXHDR;
|
||||||
|
Mach_segment_command segTEXT;
|
||||||
|
Mach_section_command secTEXT;
|
||||||
|
Mach_segment_command segLINK;
|
||||||
|
Mach_linkedit_data_command linkitem;
|
||||||
|
Mach_uuid_command uuid_cmd;
|
||||||
|
|
||||||
__packed_struct(b_info) // 12-byte header before each compressed block
|
__packed_struct(b_info) // 12-byte header before each compressed block
|
||||||
TE32 sz_unc; // uncompressed_size
|
TE32 sz_unc; // uncompressed_size
|
||||||
|
|||||||
+2
-2
@@ -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-2011 John F. Reiser
|
Copyright (C) 2007-2013 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
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
enum { // filetype
|
enum { // filetype
|
||||||
MH_EXECUTE = 2,
|
MH_EXECUTE = 2,
|
||||||
MH_DYLIB = 6,
|
MH_DYLIB = 6,
|
||||||
MH_BUNDLE = 8 /* dynamically bound bundle file */
|
MH_BUNDLE = 8 /* dynamically bound bundle file */
|
||||||
};
|
};
|
||||||
enum { // flags
|
enum { // flags
|
||||||
MH_NOUNDEFS = 1
|
MH_NOUNDEFS = 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2002-2011 Jens Medoch
|
Copyright (C) 2002-2013 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
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 Laszlo Molnar
|
||||||
Copyright (C) 2002-2011 Jens Medoch
|
Copyright (C) 2002-2013 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
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
@@ -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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
@@ -130,7 +130,7 @@ int PackUnix::getStrategy(Filter &/*ft*/)
|
|||||||
return (opt->no_filter ? -3 : ((opt->filter > 0) ? -2 : 2));
|
return (opt->no_filter ? -3 : ((opt->filter > 0) ? -2 : 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackUnix::pack2(OutputFile *fo, Filter &ft)
|
int PackUnix::pack2(OutputFile *fo, Filter &ft)
|
||||||
{
|
{
|
||||||
// compress blocks
|
// compress blocks
|
||||||
unsigned total_in = 0;
|
unsigned total_in = 0;
|
||||||
@@ -142,6 +142,7 @@ void PackUnix::pack2(OutputFile *fo, Filter &ft)
|
|||||||
// ui_total_passes = 0;
|
// ui_total_passes = 0;
|
||||||
|
|
||||||
unsigned remaining = file_size;
|
unsigned remaining = file_size;
|
||||||
|
unsigned n_block = 0;
|
||||||
while (remaining > 0)
|
while (remaining > 0)
|
||||||
{
|
{
|
||||||
// FIXME: disable filters if we have more than one block.
|
// FIXME: disable filters if we have more than one block.
|
||||||
@@ -170,7 +171,8 @@ void PackUnix::pack2(OutputFile *fo, Filter &ft)
|
|||||||
// that is, AFTER filtering. We want BEFORE filtering,
|
// that is, AFTER filtering. We want BEFORE filtering,
|
||||||
// so that decompression checks the end-to-end checksum.
|
// so that decompression checks the end-to-end checksum.
|
||||||
unsigned const end_u_adler = upx_adler32(ibuf, ph.u_len, ph.u_adler);
|
unsigned const end_u_adler = upx_adler32(ibuf, ph.u_len, ph.u_adler);
|
||||||
compressWithFilters(&ft, OVERHEAD, NULL_cconf, filter_strategy);
|
compressWithFilters(&ft, OVERHEAD, NULL_cconf, filter_strategy,
|
||||||
|
!!n_block++); // check compression ratio only on first block
|
||||||
|
|
||||||
if (ph.c_len < ph.u_len) {
|
if (ph.c_len < ph.u_len) {
|
||||||
const upx_bytep tbuf = NULL;
|
const upx_bytep tbuf = NULL;
|
||||||
@@ -222,6 +224,8 @@ void PackUnix::pack2(OutputFile *fo, Filter &ft)
|
|||||||
if ((off_t)total_in != file_size) {
|
if ((off_t)total_in != file_size) {
|
||||||
throwEOFException();
|
throwEOFException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 1; // default: write end-of-compression bhdr next
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -283,12 +287,13 @@ void PackUnix::pack(OutputFile *fo)
|
|||||||
set_te32(&hbuf.p_blocksize, blocksize);
|
set_te32(&hbuf.p_blocksize, blocksize);
|
||||||
fo->write(&hbuf, sizeof(hbuf));
|
fo->write(&hbuf, sizeof(hbuf));
|
||||||
|
|
||||||
pack2(fo, ft); // append the compressed body
|
// append the compressed body
|
||||||
|
if (pack2(fo, ft)) {
|
||||||
// write block end marker (uncompressed size 0)
|
// write block end marker (uncompressed size 0)
|
||||||
b_info hdr; memset(&hdr, 0, sizeof(hdr));
|
b_info hdr; memset(&hdr, 0, sizeof(hdr));
|
||||||
set_le32(&hdr.sz_cpr, UPX_MAGIC_LE32);
|
set_le32(&hdr.sz_cpr, UPX_MAGIC_LE32);
|
||||||
fo->write(&hdr, sizeof(hdr));
|
fo->write(&hdr, sizeof(hdr));
|
||||||
|
}
|
||||||
|
|
||||||
pack3(fo, ft); // append loader
|
pack3(fo, ft); // append loader
|
||||||
|
|
||||||
@@ -498,18 +503,26 @@ void PackUnix::unpackExtent(unsigned wanted, OutputFile *fo,
|
|||||||
|
|
||||||
int PackUnix::canUnpack()
|
int PackUnix::canUnpack()
|
||||||
{
|
{
|
||||||
upx_byte buf[sizeof(overlay_offset) + 32];
|
int const small = 32 + sizeof(overlay_offset);
|
||||||
const int bufsize = sizeof(buf);
|
// Allow zero-filled last page, for Mac OS X code signing.
|
||||||
|
int bufsize = 2*4096 + 2*small +1;
|
||||||
|
if (bufsize > fi->st_size())
|
||||||
|
bufsize = fi->st_size();
|
||||||
|
MemBuffer buf(bufsize);
|
||||||
|
|
||||||
fi->seek(-bufsize, SEEK_END);
|
fi->seek(-bufsize, SEEK_END);
|
||||||
fi->readx(buf, bufsize);
|
fi->readx(buf, bufsize);
|
||||||
if (!getPackHeader(buf, bufsize, true)) // allow incompressible extents
|
int i = bufsize;
|
||||||
|
while (i > small && 0 == buf[--i]) { }
|
||||||
|
i -= small;
|
||||||
|
// allow incompressible extents
|
||||||
|
if (i < 0 || !getPackHeader(buf + i, bufsize - i, true))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int l = ph.buf_offset + ph.getPackHeaderSize();
|
int l = ph.buf_offset + ph.getPackHeaderSize();
|
||||||
if (l < 0 || l + 4 > bufsize)
|
if (l < 0 || l + 4 > bufsize)
|
||||||
throwCantUnpack("file corrupted");
|
throwCantUnpack("file corrupted");
|
||||||
overlay_offset = get_te32(buf+l);
|
overlay_offset = get_te32(buf + i + l);
|
||||||
if ((off_t)overlay_offset >= file_size)
|
if ((off_t)overlay_offset >= file_size)
|
||||||
throwCantUnpack("file corrupted");
|
throwCantUnpack("file corrupted");
|
||||||
|
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
// called by the generic pack()
|
// called by the generic pack()
|
||||||
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 int pack2(OutputFile *, Filter &); // append compressed data
|
||||||
virtual void pack3(OutputFile *, Filter &); // append loader
|
virtual void pack3(OutputFile *, Filter &); // append loader
|
||||||
virtual void pack4(OutputFile *, Filter &); // append PackHeader
|
virtual void pack4(OutputFile *, Filter &); // append PackHeader
|
||||||
|
|
||||||
|
|||||||
+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) 2004-2011 John Reiser
|
Copyright (C) 2004-2013 John Reiser
|
||||||
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
|
|||||||
+5
-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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
@@ -834,7 +834,7 @@ void PackW32Pe::pack(OutputFile *fo)
|
|||||||
throwCantPack("PE32/EFIROM files are not yet supported");
|
throwCantPack("PE32/EFIROM files are not yet supported");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 14: //XBOX - will we ever see an XBOX file?
|
case 14: //XBOX - will we ever see a XBOX file?
|
||||||
{
|
{
|
||||||
throwCantPack("PE32/xbox files are not yet supported");
|
throwCantPack("PE32/xbox files are not yet supported");
|
||||||
break;
|
break;
|
||||||
@@ -917,7 +917,7 @@ void PackW32Pe::pack(OutputFile *fo)
|
|||||||
if (!isrtm && ((isection[ic].flags & (PEFL_WRITE|PEFL_SHARED))
|
if (!isrtm && ((isection[ic].flags & (PEFL_WRITE|PEFL_SHARED))
|
||||||
== (PEFL_WRITE|PEFL_SHARED)))
|
== (PEFL_WRITE|PEFL_SHARED)))
|
||||||
if (!opt->force)
|
if (!opt->force)
|
||||||
throwCantPack("writeable shared sections not supported (try --force)");
|
throwCantPack("writable shared sections not supported (try --force)");
|
||||||
if (jc && isection[ic].rawdataptr - jc > ih.filealign)
|
if (jc && isection[ic].rawdataptr - jc > ih.filealign)
|
||||||
throwCantPack("superfluous data between sections");
|
throwCantPack("superfluous data between sections");
|
||||||
fi->seek(isection[ic].rawdataptr,SEEK_SET);
|
fi->seek(isection[ic].rawdataptr,SEEK_SET);
|
||||||
@@ -1092,7 +1092,7 @@ void PackW32Pe::pack(OutputFile *fo)
|
|||||||
// still in a read only section by looking at the pe header of the
|
// still in a read only section by looking at the pe header of the
|
||||||
// file. If this check fails the runtime does "interesting" things
|
// file. If this check fails the runtime does "interesting" things
|
||||||
// like not running the floating point initialization code - the result
|
// like not running the floating point initialization code - the result
|
||||||
// is an R6002 runtime error.
|
// is a R6002 runtime error.
|
||||||
// These supposed to be read only addresses are covered by the sections
|
// These supposed to be read only addresses are covered by the sections
|
||||||
// UPX0 & UPX1 in the compressed files, so we have to patch the PE header
|
// UPX0 & UPX1 in the compressed files, so we have to patch the PE header
|
||||||
// in the memory. And the page on which the PE header is stored is read
|
// in the memory. And the page on which the PE header is stored is read
|
||||||
|
|||||||
+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-2011 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2011 Laszlo Molnar
|
Copyright (C) 1996-2013 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
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user