Compare commits

...

54 Commits

Author SHA1 Message Date
Markus F.X.J. Oberhumer 7082594bbc Prepare release. 2013-02-18 11:03:33 +01:00
Markus F.X.J. Oberhumer 36dd35f238 Silence some compilation warnings. 2013-02-18 11:01:30 +01:00
John Reiser 9c9fb6a485 DEBUG-only bug in decimal() 2013-02-15 16:35:45 -08:00
John Reiser 5438a4837b more AT_PHDR trouble 2013-02-15 16:32:51 -08:00
Markus F.X.J. Oberhumer 84996e8cb6 Bump tentative release date. 2013-02-12 10:32:11 +01:00
Markus F.X.J. Oberhumer 87a368a857 Welcome 2013. 2013-02-12 10:14:03 +01:00
Markus F.X.J. Oberhumer 21412d93dd New ACC version. 2013-02-12 08:16:44 +00:00
John Reiser 0b11ff22b4 internal documentation: pointer to source for Apple codesign 2013-02-03 11:27:02 -08:00
John Reiser 8fafa78796 sync stubs 2013-01-31 12:33:16 -08:00
John Reiser c43158f8a2 find PT_LOAD in case ARM PT_EXIDX is first 2013-01-31 12:21:51 -08:00
John Reiser 92ad524947 clear registers at user entry (paranoia) 2013-01-31 12:20:42 -08:00
John Reiser b362a61863 fix for user brk() on ARM with static linking 2013-01-31 12:19:35 -08:00
John Reiser 468fec38d7 Fix .e_ident[EI_OSABI] for Debian armhf. 2013-01-30 13:31:35 -08:00
John Reiser 89830a5ae0 Mac OS X codesign disallows overhang of vmsize. 2013-01-25 15:58:25 -08:00
John Reiser 5977c296bd Fix codesign for Mac OS X. 2013-01-24 15:28:21 -08:00
John Reiser 47d5792d97 Updates to prepare for next release. 2012-11-14 09:07:10 -08:00
Markus F.X.J. Oberhumer 25d706a913 Whitespace cleanup. 2012-10-31 15:50:52 +01:00
John Reiser 048236aaaa Isolate change to p_mach.cpp of previous revision
(p_lx_elf.cpp and p_lx_elf.h were included by mistake.)
2012-10-10 08:58:15 -07:00
John Reiser d442c58fd1 MachO no longer needs contiguous LC_SEGMENT (SourceForge bug 3308161) 2012-10-10 08:51:52 -07:00
John Reiser f890f6bb09 ignore another .vmsize==0; fix unfold which needs another page 2012-08-23 14:26:42 -07:00
John Reiser 036d466790 allow 3-byte decompressor overrun; fix DEBUG decimal(); unify with i386 2012-08-23 14:25:32 -07:00
John Reiser dee47ba2d8 implement DEBUG 2012-08-23 14:22:55 -07:00
John Reiser be96c28b77 fix DEBUG decimal() of negative number 2012-08-23 12:37:44 -07:00
John Reiser ad1c0f578e fix DEBUG decimal() of negative number 2012-08-23 07:31:30 -07:00
John Reiser c8f7b1b72c MacOSX launcher gets SIGBUS when it cannot find mapped Mach_header.
Add segZERO, segMHDR, secMHDR.
2012-08-22 20:46:35 -07:00
John Reiser c89702ae84 skip 0==.vmsize; also DEBUG, DPRINTF 2012-08-22 20:43:00 -07:00
John Reiser 2d29a82250 PackMachBase<T>::pack1() segTEXT.vmaddr must ignore zero-length segments 2012-08-20 20:02:26 -07:00
John Reiser b36c65e654 fix Mac OS X code signing; also leave room for LC_UUID 2012-08-04 16:44:21 -07:00
John Reiser 09b072b908 Leave space for code signing on Mac OS X. 2012-08-03 13:28:33 -07:00
John Reiser 0ae9fee350 Mach_linkedit_data_command 2012-08-03 13:20:00 -07:00
John Reiser 1579182ed9 PackUnix::canUnpack() allows zero-filled last page 2012-08-03 13:19:28 -07:00
John Reiser 074671aa71 ::unpack "if (fo)"; also "delete []" (SourceForge bug 3545609) 2012-07-19 20:11:44 -07:00
John Reiser 36b7c47247 __DWARF LC_SEGMENT_64 with .vmsize==0 (SourceForge bug 3308161) 2012-07-18 15:37:41 -07:00
John Reiser 424d5b3025 UPX_LZMA_VERSION, zlib, zlib-devel, URL for lzma SDK 2012-07-16 15:22:22 -07:00
John Reiser 8a5d352733 Portability: fix "EOFException: premature end of file" doing ELF on Windows.
OutputFile::read() was bad news; fsync() should work, but was missing.
2012-07-12 14:25:28 -07:00
John Reiser f383629282 compressWithFilters(..., inhibit_compression_check=0) // SourceForge bug 3541020
Not good to check compression ratio on every block when blocksize < file_size,
as when --force_execve of Elf > 0x80000 bytes.
2012-07-12 07:04:56 -07:00
John Reiser a6d717cb04 big endian, too: ARM Linux EABI version 4 and 5 is a mess 2012-07-07 07:45:51 -07:00
Markus F.X.J. Oberhumer 84a5753301 New ACC version. 2012-05-31 16:08:14 +00:00
Markus F.X.J. Oberhumer 5d2d9c7e81 Update .hgignore. Update valgrind macros. 2012-04-26 09:05:35 +02:00
Markus F.X.J. Oberhumer 82801d1411 Fix some typos in documentation and comments. 2012-03-27 02:14:03 +02:00
John Reiser 340c3963d8 MIPS mmap_privanon in .S in case gcc learns how to 'bal'. 2012-03-14 08:24:04 -07:00
John Reiser ef15cf9847 merge 2012-03-13 19:56:30 -07:00
John Reiser 4d613ccfa7 MIPS mmap_privanon() forgot to set syscall number; also gcc __asm__() problems.
[Sourceforge upx-Bugs-3503753]
2012-03-13 19:54:47 -07:00
Markus F.X.J. Oberhumer 43ce34d547 Welcome 2012. 2012-01-01 22:35:11 +01:00
Markus F.X.J. Oberhumer eda074cd80 New ACC version. 2012-01-01 21:18:43 +00:00
Markus F.X.J. Oberhumer a2396d82f6 NEWS: spelling fixes. 2011-12-14 18:06:39 +01:00
Markus F.X.J. Oberhumer a38721db93 Remove meaningless "const" from casts. 2011-12-14 06:05:41 +01:00
Markus F.X.J. Oberhumer a06e811717 Remove extra semicolons. 2011-12-14 06:05:08 +01:00
Markus F.X.J. Oberhumer 86e534ff75 Remove trailing whitespace. Remove hard tabs. 2011-12-14 06:03:08 +01:00
John Reiser 640d5b2dec Option --preserve-build-id for Gnu ELF; contributed by Nicholas Twerdochlib
(SourceForge [ upx-Patches-3413335 ])
2011-12-13 17:26:03 -08:00
John Reiser 57e9b27085 merge 2011-12-13 10:54:55 -08:00
John Reiser c56eefc739 Document /proc/self/exe problems on arm*-linux-elf. 2011-12-13 10:53:26 -08:00
Markus F.X.J. Oberhumer cf28306997 Post-release version bump. 2011-12-13 01:30:00 +01:00
Markus F.X.J. Oberhumer 10acf3ddd1 Add tag for RELEASE_308. 2011-12-12 16:08:00 +00:00
350 changed files with 2889 additions and 1928 deletions
+1
View File
@@ -9,6 +9,7 @@ syntax: regexp
syntax: glob
.depend
*.qtcreator.{config,creator,creator.user,files,includes}
Makevars.local
*.a
+1
View File
@@ -1,3 +1,4 @@
087cafe682c014863b4aa8a6ea21431251a6ad3c RELEASE_308
140415ffbcef86a42b4d672249927364430d3d38 RELEASE_111
155618b5b7930f97bd84b82befa7a4fd6672efb3 RELEASE_304
1931f4f28074970ec53b4cd21c7fc181b4da8e5e RELEASE_301
+2 -2
View File
@@ -8,7 +8,7 @@
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
@@ -44,7 +44,7 @@ test file.
win32/pe
--------
* writeable shared sections (`--force' *may* work)
* writable shared sections (`--force' *may* work)
* certificates in the image
* compressing files which contain a big BSS requires lots of memory
during compression
+1 -1
View File
@@ -1,7 +1,7 @@
#
# 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
+10 -3
View File
@@ -2,14 +2,21 @@
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):
* Fix allocation in runtime stub for darwin.macho-entry (i386 and amd64).
* Compress shared library on ELF i386 only [ld.so threatens even this case].
* Attempt to suport ELF on QNX 6.3.0 for armel (experimental).
* Better diangostic when ELF -fPIC is needed.
* Attempt to support ELF on QNX 6.3.0 for armel (experimental).
* Better diagnostic when ELF -fPIC is needed.
* PT_NOTE improvements for *BSD.
* 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.
* bug fixes
+1 -1
View File
@@ -8,7 +8,7 @@
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
+4 -4
View File
@@ -8,7 +8,7 @@
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
@@ -108,9 +108,9 @@ THE FUTURE
COPYRIGHT
=========
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2000-2011 John F. Reiser
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2000-2013 John F. Reiser
This program may be used freely, and you are welcome to
redistribute it under certain conditions.
+1 -1
View File
@@ -8,7 +8,7 @@
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
+7
View File
@@ -71,6 +71,12 @@ Tools needed to build/modify the UPX sources
- 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
-----------------------------
@@ -85,6 +91,7 @@ To compile the packer sources
to your unpacked lzma443.tar.bz2 source directory, e.g.
export UPX_LZMADIR=$HOME/local/src/lzma-4.43 (Unix)
export UPX_LZMA_VERSION=0x443 # perhaps 0x459,0x458,0x457,0x449,0x442
Finally type
+1 -1
View File
@@ -8,7 +8,7 @@
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
+16 -1
View File
@@ -1,5 +1,5 @@
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:
<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
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()
immediately after the '\0' which terminates the character string of the
last environment variable [as of execve()]. This is true for at least
+1 -1
View File
@@ -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
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
eradicate runtime generation of instructions because of the possibility
for exploitation by malware (virus, trojan, key logger, privilege
+5 -5
View File
@@ -13,7 +13,7 @@ B<upx> S<[ I<command> ]> S<[ I<options> ]> I<filename>...
=head1 ABSTRACT
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
@@ -933,13 +933,13 @@ Please report all bugs immediately to the authors.
=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
redistribute it under certain conditions.
+1 -1
View File
@@ -1,7 +1,7 @@
#
# 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
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+5 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -352,6 +352,7 @@ namespace MyLzma {
struct InStream: public ISequentialInStream, public CMyUnknownImp
{
virtual ~InStream() { }
MY_UNKNOWN_IMP
const Byte *b_buf; size_t b_size; size_t b_pos;
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
{
virtual ~OutStream() { }
MY_UNKNOWN_IMP
Byte *b_buf; size_t b_size; size_t b_pos; bool overflow;
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
{
virtual ~ProgressInfo() { }
MY_UNKNOWN_IMP
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
upx_callback_p cb;
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+8 -13
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -222,19 +222,14 @@
#if (WITH_VALGRIND)
# include <valgrind/memcheck.h>
#endif
#if !defined(VALGRIND_MAKE_WRITABLE)
# define VALGRIND_MAKE_WRITABLE(addr,len) 0
#if !defined(VALGRIND_MAKE_MEM_DEFINED)
# define VALGRIND_MAKE_MEM_DEFINED(addr,len) 0
#endif
#if !defined(VALGRIND_MAKE_READABLE)
# if 0
# define VALGRIND_MAKE_READABLE(addr,len) (memset(addr,0,len), 0)
# else
# define VALGRIND_MAKE_READABLE(addr,len) 0
# endif
#if !defined(VALGRIND_MAKE_MEM_NOACCESS)
# define VALGRIND_MAKE_MEM_NOACCESS(addr,len) 0
#endif
#if !defined(VALGRIND_DISCARD)
# define VALGRIND_DISCARD(handle) ((void)(&handle))
#if !defined(VALGRIND_MAKE_MEM_UNDEFINED)
# define VALGRIND_MAKE_MEM_UNDEFINED(addr,len) 0
#endif
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+12 -17
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
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);
}
int OutputFile::read(void *buf, int len)
{
InputFile infile;
infile.open(this->getName(), O_RDONLY);
infile.seek(this->tell(), SEEK_SET);
return infile.read(buf, len);
}
int OutputFile::readx(void *buf, int len)
{
InputFile infile;
infile.open(this->getName(), O_RDONLY);
infile.seek(this->tell(), SEEK_SET);
return infile.readx(buf, len);
}
// WARNING: fsync() does not exist in some Windows environments.
// This trick works only on UNIX-like systems.
//int OutputFile::read(void *buf, int len)
//{
// fsync(_fd);
// InputFile infile;
// infile.open(this->getName(), O_RDONLY);
// infile.seek(this->tell(), SEEK_SET);
// return infile.read(buf, len);
//}
void OutputFile::set_extent(off_t offset, off_t length)
{
+2 -4
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
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
virtual void seek(off_t off, int whence);
virtual void rewrite(const void *buf, int len);
virtual int read(void *buf, int len);
virtual int readx(void *buf, int len);
// util
static void dump(const char *name, const void *buf, int len, int flags=-1);
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2000-2011 John F. Reiser
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2000-2013 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2000-2011 John F. Reiser
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2000-2013 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2000-2011 John F. Reiser
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2000-2013 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+5 -5
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2004-2011 John F. Reiser
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2004-2013 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -98,7 +98,7 @@ static int F(Filter *f)
}
else {
#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
lastnoncall = ic;
noncalls++;
@@ -133,7 +133,7 @@ static int U(Filter *f)
for (ic = 0; ic<=size4; ic+=4) if (COND(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));
set_be32(b+ic, (0xfc000003&word)|(0x03fffffc&(jc-ic-addvalue)));
f->calls++;
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+11 -6
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
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=1 strip relocations [default]\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");
@@ -400,10 +405,10 @@ void show_version(int x)
if (v != NULL && v[0])
fprintf(fp, "LZMA SDK version %s\n", v);
#endif
fprintf(fp, "Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\n");
fprintf(fp, "Copyright (C) 1996-2011 Laszlo Molnar\n");
fprintf(fp, "Copyright (C) 2000-2011 John F. Reiser\n");
fprintf(fp, "Copyright (C) 2002-2011 Jens Medoch\n");
fprintf(fp, "Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer\n");
fprintf(fp, "Copyright (C) 1996-2013 Laszlo Molnar\n");
fprintf(fp, "Copyright (C) 2000-2013 John F. Reiser\n");
fprintf(fp, "Copyright (C) 2002-2013 Jens Medoch\n");
#if (WITH_ZLIB)
fprintf(fp, "Copyright (C) 1995" "-2005 Jean-loup Gailly and Mark Adler\n");
#endif
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+6 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
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:
opt->o_unix.unmap_all_pages = true; // val ?
break;
case 675:
opt->o_unix.preserve_build_id = true;
break;
case '\0':
return -1;
@@ -1048,6 +1051,7 @@ static const struct mfx_option longopts[] =
{"OpenBSD", 0x10, 0, 669},
{"openbsd", 0x10, 0, 669},
{"unmap-all-pages", 0x10, 0, 674}, // linux /proc/self/exe vanishes
{"preserve-build-id", 0, 0, 675},
// watcom/le
{"le", 0x10, 0, 620}, // produce LE output
// win32/pe
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+99 -56
View File
@@ -2,6 +2,8 @@
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) 2009 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
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
@@ -41,7 +43,7 @@
#ifndef __ACC_H_INCLUDED
#define __ACC_H_INCLUDED 1
#define ACC_VERSION 20101017L
#define ACC_VERSION 20130212L
#if defined(__CYGWIN32__) && !defined(__CYGWIN__)
# define __CYGWIN__ __CYGWIN32__
#endif
@@ -537,7 +539,7 @@
# define ACC_INFO_CC "sdcc"
# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(SDCC)
#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_CCVER __PATHSCALE__
#elif defined(__INTEL_COMPILER)
@@ -553,34 +555,43 @@
# define ACC_CC_PELLESC 1
# define ACC_INFO_CC "Pelles C"
# 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__)
# 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
# define ACC_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
# define ACC_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__+0) * 0x100)
# endif
# 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
# define ACC_CC_CLANG_CLANG 0x020700L
# define ACC_CC_CLANG_CLANG 0x010000L
# endif
# define ACC_CC_CLANG ACC_CC_CLANG_GNUC
# define ACC_INFO_CC "clang"
# define ACC_INFO_CCVER __VERSION__
#elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
# 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
# define ACC_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
# define ACC_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__+0) * 0x100)
# endif
# define ACC_CC_LLVM ACC_CC_LLVM_GNUC
# define ACC_INFO_CC "llvm-gcc"
# define ACC_INFO_CCVER __VERSION__
#elif defined(__GNUC__) && defined(__VERSION__)
# 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__)
# define ACC_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
# define ACC_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__+0) * 0x100)
# else
# define ACC_CC_GNUC (__GNUC__ * 0x10000L)
# endif
@@ -590,6 +601,11 @@
# define ACC_CC_ACK 1
# define ACC_INFO_CC "Amsterdam Compiler Kit C"
# 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__)
# define ACC_CC_AZTECC 1
# define ACC_INFO_CC "Aztec C"
@@ -725,6 +741,20 @@
# define ACC_INFO_CC "unknown"
# define ACC_INFO_CCVER "unknown"
#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)
# error "ACC_CC_MSC: _MSC_FULL_VER is not defined"
#endif
@@ -1403,6 +1433,9 @@ extern "C" {
# define ACC_INFO_LIBC "isoc90"
#elif (ACC_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__)
# define ACC_LIBC_DIETLIBC 1
# define ACC_INFO_LIBC "dietlibc"
@@ -1411,13 +1444,13 @@ extern "C" {
# define ACC_INFO_LIBC "newlib"
#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__)
# 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
# define ACC_LIBC_UCLIBC 0x00090bL
# endif
# define ACC_INFO_LIBC "uclibc"
#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"
#elif (ACC_CC_MWERKS) && defined(__MSL__)
# define ACC_LIBC_MSL __MSL__
@@ -1433,7 +1466,7 @@ extern "C" {
#if !defined(__acc_gnuc_extension__)
#if (ACC_CC_GNUC >= 0x020800ul)
# 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__
#else
# define __acc_gnuc_extension__ /*empty*/
@@ -1443,7 +1476,7 @@ extern "C" {
# define __acc_ua_volatile volatile
#endif
#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)
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 700))
# define __acc_alignof(e) __alignof__(e)
@@ -1461,7 +1494,7 @@ extern "C" {
# define __acc_constructor __attribute__((__constructor__,__used__))
#elif (ACC_CC_GNUC >= 0x020700ul)
# 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__))
#endif
#endif
@@ -1473,7 +1506,7 @@ extern "C" {
# define __acc_destructor __attribute__((__destructor__,__used__))
#elif (ACC_CC_GNUC >= 0x020700ul)
# 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__))
#endif
#endif
@@ -1489,7 +1522,7 @@ extern "C" {
# define __acc_inline inline
#elif (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0550))
# 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__
#elif (ACC_CC_DMC)
# define __acc_inline __inline
@@ -1517,7 +1550,7 @@ extern "C" {
# define __acc_forceinline __forceinline
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 800) && ACC_CC_SYNTAX_GNUC)
# 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__))
#elif (ACC_CC_MSC && (_MSC_VER >= 1200))
# define __acc_forceinline __forceinline
@@ -1539,7 +1572,7 @@ extern "C" {
# define __acc_noinline __declspec(noinline)
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 800) && ACC_CC_SYNTAX_GNUC)
# 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__))
#elif (ACC_CC_MSC && (_MSC_VER >= 1300))
# define __acc_noinline __declspec(noinline)
@@ -1567,7 +1600,7 @@ extern "C" {
# define __acc_noreturn __declspec(noreturn)
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 600) && ACC_CC_SYNTAX_GNUC)
# 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__))
#elif (ACC_CC_MSC && (_MSC_VER >= 1200))
# define __acc_noreturn __declspec(noreturn)
@@ -1585,7 +1618,7 @@ extern "C" {
# define __acc_nothrow __declspec(nothrow)
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 900) && ACC_CC_SYNTAX_GNUC)
# 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__))
#elif (ACC_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus)
# define __acc_nothrow __declspec(nothrow)
@@ -1601,7 +1634,7 @@ extern "C" {
# define __acc_restrict __restrict__
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 600) && ACC_CC_SYNTAX_GNUC)
# 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__
#elif (ACC_CC_MSC && (_MSC_VER >= 1400))
# define __acc_restrict __restrict
@@ -1619,7 +1652,7 @@ extern "C" {
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 800))
# define __acc_likely(e) (__builtin_expect(!!(e),1))
# 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_unlikely(e) (__builtin_expect(!!(e),0))
#endif
@@ -1639,7 +1672,9 @@ extern "C" {
# define ACC_UNUSED(var) ((void) &var)
# elif (ACC_CC_BORLANDC || ACC_CC_HIGHC || ACC_CC_NDPC || ACC_CC_PELLESC || ACC_CC_TURBOC)
# 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)
# elif (ACC_CC_MSC && (_MSC_VER < 900))
# define ACC_UNUSED(var) if (&var) ; else
@@ -1658,7 +1693,7 @@ extern "C" {
# define ACC_UNUSED_FUNC(func) ((void) func)
# elif (ACC_CC_BORLANDC || ACC_CC_NDPC || ACC_CC_TURBOC)
# define ACC_UNUSED_FUNC(func) if (func) ; else
# elif (ACC_CC_CLANG || ACC_CC_LLVM)
# elif (ACC_CC_ARMCC_GNUC || ACC_CC_CLANG || ACC_CC_LLVM)
# define ACC_UNUSED_FUNC(func) ((void) &func)
# elif (ACC_CC_MSC && (_MSC_VER < 900))
# define ACC_UNUSED_FUNC(func) if (func) ; else
@@ -1673,7 +1708,7 @@ extern "C" {
#if !defined(ACC_UNUSED_LABEL)
# if (ACC_CC_WATCOMC) && defined(__cplusplus)
# 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
# else
# define ACC_UNUSED_LABEL(l) switch(0) case 1:goto l
@@ -1691,7 +1726,7 @@ extern "C" {
#if !defined(ACC_UNCONST_CAST)
# if 0 && defined(__cplusplus)
# 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))))))
# else
# 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)];}
# 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;
# 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))
# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
# 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))
# define ACC_ASM_SYNTAX_MSC 1
#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))
# define ACC_ASM_SYNTAX_GNUC 1
#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_CHMOD
# undef HAVE_CHOWN
# undef HAVE_FILENO
# undef HAVE_FSTAT
# undef HAVE_GETTIMEOFDAY
# 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)
#endif
#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)
#else
ACCCHK_ASSERT((1 << (8*SIZEOF_INT-1)) < 0)
#endif
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
ACCCHK_ASSERT((1l << (8*SIZEOF_LONG-1)) < 0)
#endif
@@ -4699,6 +4742,7 @@ ACCLIB_EXTERN(int, acc_spawnve) (int mode, const char* fn, const char* const * a
#if (ACC_CC_KEILC)
#elif (ACC_CC_NDPC)
#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 !(ACC_BROKEN_INTEGRAL_PROMOTION) && (SIZEOF_INT > 1)
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)
#endif
#if (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_ASM_SYNTAX_GNUC)
#if (ACC_ARCH_AMD64 && ACC_CC_PATHSCALE)
# define __ACCLIB_RDTSC_REGS : : "c" (t) : "cc", "memory", "rax", "rdx"
#elif (ACC_ARCH_AMD64 && ACC_CC_INTELC)
#if (ACC_ARCH_AMD64 && ACC_CC_INTELC)
# 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)
# define __ACCLIB_RDTSC_REGS : : "r" (t) : "cc", "memory", "rax", "rdx"
#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)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#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
#define acc_pclock_syscall_clock_gettime acc_pclock_syscall_clock_gettime
#endif
static __acc_noinline long acc_pclock_syscall_clock_gettime(long clockid, struct timespec *ts)
{
long r;
__asm__ __volatile__("syscall\n" : "=a" (r) : "0" (228), "D" (clockid), "S" (ts) : __ACC_ASM_CLOBBER);
return r;
unsigned long r = 228;
__asm__ __volatile__("syscall\n" : "=a" (r) : "0" (r), "D" (clockid), "S" (ts) : __ACC_ASM_CLOBBER);
return (long) r;
}
#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
#define acc_pclock_syscall_clock_gettime acc_pclock_syscall_clock_gettime
#endif
static __acc_noinline long acc_pclock_syscall_clock_gettime(long clockid, struct timespec *ts)
{
long r;
__asm__ __volatile__("int $0x80\n" : "=a" (r) : "0" (265), "b" (clockid), "c" (ts) : __ACC_ASM_CLOBBER);
return r;
unsigned long r = 265;
__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 (long) r;
}
#endif
#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)
return -1;
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;
}
#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)
return -1;
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;
}
#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;
}
#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
#define acc_pclock_read_clock_gettime_p_libc acc_pclock_read_clock_gettime_p_libc
#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)
return -1;
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;
}
#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)
return -1;
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;
}
#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;
}
#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
#define acc_pclock_read_clock_gettime_t_libc acc_pclock_read_clock_gettime_t_libc
#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)
return -1;
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;
}
#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)
return -1;
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;
}
#endif
@@ -6776,7 +6820,8 @@ ACCLIB_PUBLIC_NOINLINE(void, acc_debug_break) (void)
#elif (ACC_OS_WIN32) && (ACC_HAVE_WINDOWS_H)
DebugBreak();
#else
* (volatile int *) 0x1 = -1;
volatile size_t a = 0;
* (volatile unsigned long *) (volatile void *) a = ~0ul;
#endif
}
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)
{
#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);
return (int)(r >> 18) & 1;
#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)
{
int r;
#if (ACC_ARCH_AMD64) && (ACC_ASM_SYNTAX_GNUC)
if (v) {
__asm__ __volatile__("pushf\n orl $262144,(%%rsp)\n popf\n" : : : __ACC_ASM_CLOBBER);
} else {
__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)
if (v) {
__asm__ __volatile__("pushf\n orl $262144,(%%esp)\n popf\n" : : : __ACC_ASM_CLOBBER);
} else {
__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)
if (v) { __asm {
pushf
@@ -6827,11 +6871,10 @@ ACCLIB_PUBLIC_NOINLINE(int, acc_debug_align_check_enable) (int v)
and dword ptr [esp],-262145
popf
}}
r = 0;
return 0;
#else
r = -1;
ACC_UNUSED(v); return -1;
#endif
ACC_UNUSED(v); return r;
}
ACCLIB_PUBLIC_NOINLINE(unsigned, acc_debug_running_on_qemu) (void)
{
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+3 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
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]
enum { SCRIPT_MAX = 32 };
const char *script_name;
bool preserve_build_id; // copy the build-id to the compressed binary
} o_unix;
struct {
bool le;
+3 -3
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
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))
== (PEFL_WRITE|PEFL_SHARED)))
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)
throwCantPack("superfluous data between sections");
fi->seek(isection[ic].rawdataptr,SEEK_SET);
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+258 -48
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2000-2011 John F. Reiser
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2000-2013 John F. Reiser
All Rights Reserved.
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_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
umin(unsigned a, unsigned b)
{
@@ -96,7 +102,7 @@ PackLinuxElf32::checkEhdr(Elf32_Ehdr const *ehdr) const
int const type = get_te16(&ehdr->e_type);
if (type != Elf32_Ehdr::ET_EXEC && type != Elf32_Ehdr::ET_DYN)
return 2;
if (get_te16(&ehdr->e_machine) != e_machine)
if (get_te16(&ehdr->e_machine) != (unsigned) e_machine)
return 3;
if (get_te32(&ehdr->e_version) != Elf32_Ehdr::EV_CURRENT)
return 4;
@@ -129,7 +135,7 @@ int
PackLinuxElf64::checkEhdr(Elf64_Ehdr const *ehdr) const
{
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) {
osabi0 = opt->o_unix.osabi0;
}
@@ -147,7 +153,7 @@ PackLinuxElf64::checkEhdr(Elf64_Ehdr const *ehdr) const
int const type = get_te16(&ehdr->e_type);
if (type != Elf64_Ehdr::ET_EXEC && type != Elf64_Ehdr::ET_DYN)
return 2;
if (get_te16(&ehdr->e_machine) != e_machine)
if (get_te16(&ehdr->e_machine) != (unsigned) e_machine)
return 3;
if (get_te32(&ehdr->e_version) != Elf64_Ehdr::EV_CURRENT)
return 4;
@@ -180,7 +186,8 @@ PackLinuxElf::PackLinuxElf(InputFile *f)
: 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),
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;
}
// 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)
{
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));
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)
{
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_memsz, sz_pack2 + lsize);
if (0!=xct_off) { // shared library
@@ -324,7 +332,24 @@ void PackLinuxElf32::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_memsz, sz_pack2 + lsize);
if (0!=xct_off) { // shared library
@@ -411,7 +436,10 @@ PackLinuxElf::addStubEntrySections(Filter const *)
{
addLoader("ELFMAINX", NULL);
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(
@@ -1141,6 +1169,21 @@ Elf32_Shdr const *PackLinuxElf32::elf_find_section_name(
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(
unsigned const type
) const
@@ -1198,7 +1241,7 @@ bool PackLinuxElf32::canPack()
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).
Elf32_Phdr const *phdr = (Elf32_Phdr const *)(u.buf + e_phoff);
note_size = 0;
@@ -1249,10 +1292,9 @@ bool PackLinuxElf32::canPack()
if (Elf32_Ehdr::ELFOSABI_NONE==osabi0) { // No EI_OSBAI, no PT_NOTE.
unsigned const arm_eabi = 0xff000000u & get_te32(&ehdr->e_flags);
if (Elf32_Ehdr::EM_ARM==e_machine
&& Elf32_Ehdr::ELFDATA2LSB==ei_data
&& (EF_ARM_EABI_VER5==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;
}
else {
@@ -1652,8 +1694,14 @@ PackLinuxElf32::generateElfHdr(
assert(get_te16(&h2->ehdr.e_ehsize) == sizeof(Elf32_Ehdr));
assert(get_te16(&h2->ehdr.e_phentsize) == sizeof(Elf32_Phdr));
set_te16(&h2->ehdr.e_shentsize, sizeof(Elf32_Shdr));
h2->ehdr.e_shnum = 0;
h2->ehdr.e_shstrndx = 0;
if (o_elf_shnum) {
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
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_phentsize) == sizeof(Elf64_Phdr));
set_te16(&h2->ehdr.e_shentsize, sizeof(Elf64_Shdr));
h2->ehdr.e_shnum = 0;
h2->ehdr.e_shstrndx = 0;
if (o_elf_shnum) {
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
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));
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)
@@ -1998,6 +2111,9 @@ void PackLinuxElf32armLe::pack1(OutputFile *fo, Filter &ft)
else {
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);
generateElfHdr(fo, &h3, getbrk(phdri, e_phnum) );
}
@@ -2094,6 +2210,68 @@ void PackLinuxElf64::pack1(OutputFile *fo, Filter & /*ft*/)
memset(&linfo, 0, 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)
@@ -2144,7 +2322,7 @@ unsigned PackLinuxElf32::find_LOAD_gap(
return lo - hi;
}
void PackLinuxElf32::pack2(OutputFile *fo, Filter &ft)
int PackLinuxElf32::pack2(OutputFile *fo, Filter &ft)
{
Extent x;
unsigned k;
@@ -2202,17 +2380,15 @@ void PackLinuxElf32::pack2(OutputFile *fo, Filter &ft)
}
sz_pack2a = fpad4(fo);
// Accounting only; ::pack3 will do the compression and output
for (k = 0; k < e_phnum; ++k) {
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);
}
total_in += find_LOAD_gap(phdri, k, e_phnum);
}
if ((off_t)total_in != file_size)
throwEOFException();
return 0; // omit end-of-compression bhdr for now
}
// 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;
}
void PackLinuxElf64::pack2(OutputFile *fo, Filter &ft)
int PackLinuxElf64::pack2(OutputFile *fo, Filter &ft)
{
Extent x;
unsigned k;
@@ -2313,17 +2489,15 @@ void PackLinuxElf64::pack2(OutputFile *fo, Filter &ft)
}
sz_pack2a = fpad4(fo);
for (k = 0; k < e_phnum; ++k) {
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);
}
// Accounting only; ::pack3 will do the compression and output
for (k = 0; k < e_phnum; ++k) { //
total_in += find_LOAD_gap(phdri, k, e_phnum);
}
if ((off_t)total_in != file_size)
throwEOFException();
return 0; // omit end-of-compression bhdr for now
}
// Filter 0x50, 0x51 assume HostPolicy::isLE
@@ -2601,6 +2775,24 @@ void PackLinuxElf32::pack4(OutputFile *fo, Filter &ft)
{
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
// tries to make .bss, which requires PF_W.
// 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);
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
// tries to make .bss, which requires PF_W.
// But strict SELinux (or PaX, grSecurity) disallows PF_W with PF_X.
+22 -6
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2000-2011 John F. Reiser
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2000-2013 John F. Reiser
All Rights Reserved.
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.
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 pack4(OutputFile *, Filter &) = 0; // append pack header
@@ -88,6 +88,10 @@ protected:
unsigned char ei_data;
unsigned char ei_osabi;
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
@@ -107,7 +111,7 @@ protected:
virtual int ARM_is_QNX(void);
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 pack4(OutputFile *, Filter &); // append pack header
virtual void unpack(OutputFile *fo);
@@ -186,6 +190,12 @@ protected:
cprElfHdrNetBSD elfout;
__packed_struct(cprElfShdr3)
Elf32_Shdr shdr[3];
__packed_struct_end()
cprElfShdr3 shdrout;
struct Elf32_Nhdr {
unsigned namesz;
unsigned descsz;
@@ -218,7 +228,7 @@ protected:
virtual int checkEhdr(Elf64_Ehdr const *ehdr) const;
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 pack4(OutputFile *, Filter &); // append pack header
virtual void unpack(OutputFile *fo);
@@ -293,6 +303,12 @@ protected:
cprElfHdr4 elfout;
__packed_struct(cprElfShdr3)
Elf64_Shdr shdr[3];
__packed_struct_end()
cprElfShdr3 shdrout;
static void compileTimeAssertions() {
COMPILE_TIME_ASSERT(sizeof(cprElfHdr1) == 64 + 1*56 + 12)
COMPILE_TIME_ASSERT(sizeof(cprElfHdr2) == 64 + 2*56 + 12)
+4 -4
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2001-2011 John F. Reiser
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2001-2013 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -449,7 +449,7 @@ int PackLinuxI386::getLoaderPrefixSize() const
// 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
{
const unsigned char * const buf = ehdr->e_ident;
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+6 -6
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2000-2011 John F. Reiser
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2000-2013 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -124,12 +124,12 @@ void PackLinuxElf32x86interp::pack1(OutputFile *fo, Filter &)
#undef E
}
void PackLinuxElf32x86interp::pack2(OutputFile *fo, Filter &ft)
int PackLinuxElf32x86interp::pack2(OutputFile *fo, Filter &ft)
{
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
+4 -4
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2000-2011 John F. Reiser
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2000-2013 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -54,7 +54,7 @@ public:
protected:
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
};
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2000-2011 John F. Reiser
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2000-2013 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2000-2011 John F. Reiser
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2000-2013 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+257 -64
View File
@@ -2,7 +2,7 @@
This file is part of the UPX executable compressor.
Copyright (C) 2004-2011 John Reiser
Copyright (C) 2004-2013 John Reiser
All Rights Reserved.
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 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);
@@ -447,77 +447,211 @@ PackMachBase<T>::compare_segment_command(void const *const aa, void const *const
unsigned const xb = b->cmd - lc_seg;
if (xa < xb) return -1; // LC_SEGMENT first
if (xa > xb) return 1;
if (a->vmaddr < b->vmaddr) return -1; // ascending by .vmaddr
if (a->vmaddr > b->vmaddr) return 1;
// Beware 0==.vmsize (some MacOSX __DWARF debug info: a "comment")
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;
}
#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
{
// 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);
segcmdo.filesize = fo->getBytesWritten();
segcmdo.vmsize += segcmdo.filesize;
unsigned const t = fo->getBytesWritten();
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->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));
if (my_filetype==Mach_header::MH_EXECUTE) {
fo->rewrite(&uuid_cmd, sizeof(uuid_cmd));
fo->rewrite(&linkitem, sizeof(linkitem));
}
fo->rewrite(&linfo, sizeof(linfo));
}
void PackMachI386::pack4(OutputFile *fo, Filter &ft) // append PackHeader
{
// 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);
segcmdo.filesize = fo->getBytesWritten();
segcmdo.vmsize += segcmdo.filesize;
unsigned const t = fo->getBytesWritten();
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->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));
if (my_filetype==Mach_header::MH_EXECUTE) {
fo->rewrite(&uuid_cmd, sizeof(uuid_cmd));
fo->rewrite(&linkitem, sizeof(linkitem));
}
fo->rewrite(&linfo, sizeof(linfo));
}
void PackMachAMD64::pack4(OutputFile *fo, Filter &ft) // append PackHeader
{
// 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);
segcmdo.filesize = fo->getBytesWritten();
segcmdo.vmsize += segcmdo.filesize;
unsigned const t = fo->getBytesWritten();
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->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));
if (my_filetype==Mach_header::MH_EXECUTE) {
fo->rewrite(&uuid_cmd, sizeof(uuid_cmd));
fo->rewrite(&linkitem, sizeof(linkitem));
}
fo->rewrite(&linfo, sizeof(linfo));
}
void PackMachARMEL::pack4(OutputFile *fo, Filter &ft) // append PackHeader
{
// 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);
segcmdo.filesize = fo->getBytesWritten();
segcmdo.vmsize += segcmdo.filesize;
unsigned const t = fo->getBytesWritten();
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->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));
if (my_filetype==Mach_header::MH_EXECUTE) {
fo->rewrite(&uuid_cmd, sizeof(uuid_cmd));
fo->rewrite(&linkitem, sizeof(linkitem));
}
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>
void PackMachBase<T>::pack4dylib( // append PackHeader
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)
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);
}
@@ -740,7 +874,7 @@ void PackMachI386::pack3(OutputFile *fo, Filter &ft) // append loader
disp = len - sz_mach_headers;
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);
}
@@ -754,7 +888,7 @@ void PackMachAMD64::pack3(OutputFile *fo, Filter &ft) // append loader
disp = len - sz_mach_headers;
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);
}
@@ -768,7 +902,7 @@ void PackMachARMEL::pack3(OutputFile *fo, Filter &ft) // append loader
disp = len - sz_mach_headers;
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);
}
@@ -899,7 +1033,7 @@ void PackMachBase<T>::pack3(OutputFile *fo, Filter &ft)
}
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];
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 ((off_t)total_in != file_size)
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)
@@ -1025,34 +1162,82 @@ void PackMachBase<T>::pack1(OutputFile *const fo, Filter &/*ft*/) // generate e
unsigned const lc_seg = lc_segment[sizeof(Addr)>>3];
mhdro = mhdri;
if (my_filetype==Mach_header::MH_EXECUTE) {
mhdro.ncmds = 2;
mhdro.sizeofcmds = sizeof(segcmdo) + my_thread_command_size;
mhdro.ncmds = 5; // __ZERO, __XHDR, __TEXT, __LINKEDIT, THREAD_STATE
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;
}
fo->write(&mhdro, sizeof(mhdro));
segcmdo.cmd = lc_seg;
segcmdo.cmdsize = sizeof(segcmdo);
strncpy((char *)segcmdo.segname, "__TEXT", sizeof(segcmdo.segname));
memset(&segZERO, 0, sizeof(segZERO));
segZERO.cmd = lc_seg;
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) {
segcmdo.vmaddr = PAGE_MASK64 & (~PAGE_MASK64 +
msegcmd[n_segment -1].vmsize + msegcmd[n_segment -1].vmaddr );
int k; // must ignore zero-length segments, which sort last
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) {
segcmdo.vmaddr = 0;
segTEXT.vmaddr = 0;
}
segcmdo.vmsize = 0; // adjust later
segcmdo.fileoff = 0;
segcmdo.filesize = 0; // adjust later
segcmdo.initprot = segcmdo.maxprot =
segTEXT.vmsize = 0; // adjust later
segTEXT.fileoff = 0;
segTEXT.filesize = 0; // adjust later
segTEXT.initprot = segTEXT.maxprot =
Mach_segment_command::VM_PROT_READ |
Mach_segment_command::VM_PROT_WRITE |
Mach_segment_command::VM_PROT_EXECUTE;
segcmdo.nsects = 0;
segcmdo.flags = 0;
segTEXT.nsects = 1; // secTEXT
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) {
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);
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) {
fo->write(rawmseg, mhdri.sizeofcmds);
@@ -1073,7 +1258,11 @@ void PackMachBase<T>::unpack(OutputFile *fo)
fi->readx(&mhdri, sizeof(mhdri));
rawmseg = (Mach_segment_command *)new char[(unsigned) 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);
p_info hbuf;
fi->readx(&hbuf, sizeof(hbuf));
@@ -1126,6 +1315,8 @@ void PackMachBase<T>::unpack(OutputFile *fo)
) {
if (lc_seg==sc->cmd
&& 0!=sc->filesize ) {
if (fo)
fo->seek(sc->fileoff, SEEK_SET);
unsigned filesize = sc->filesize;
unpackExtent(filesize, fo, total_in, total_out,
c_adler, u_adler, false, sizeof(bhdr));
@@ -1147,11 +1338,13 @@ void PackMachBase<T>::unpack(OutputFile *fo)
if (lc_seg==rc->cmd
&& 0!=rc->filesize ) {
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;
MemBuffer 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) {
unsigned const size = find_SEGMENT_gap(j);
if (size) {
unsigned const where = msegcmd[k].fileoff +msegcmd[k].filesize;
unsigned const where = msegcmd[j].fileoff +msegcmd[j].filesize;
if (fo)
fo->seek(where, SEEK_SET);
unpackExtent(size, fo, total_in, total_out,
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.
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) {
if (lc_seg==msegcmd[j].cmd) {
if (~PAGE_MASK & (msegcmd[j].fileoff | msegcmd[j].vmaddr)) {
return false;
}
if (0 < j) {
unsigned const sz = PAGE_MASK
& (~PAGE_MASK + msegcmd[j-1].filesize);
if ((sz + msegcmd[j-1].fileoff)!=msegcmd[j].fileoff) {
return false;
}
}
if (msegcmd[j].vmsize==0)
break; // was sorted last
// We used to check that LC_SEGMENTS were contiguous,
// but apparently that is not needed anymore,
// and Google compilers generate strange layouts.
++n_segment;
sz_segment = msegcmd[j].filesize + msegcmd[j].fileoff - msegcmd[0].fileoff;
}
+48 -4
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
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"
__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>
__packed_struct(Mach_ppc_thread_state)
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_routines_command<MachITypes> Mach_routines_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_i386_thread_state<MachITypes> Mach_i386_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_routines_command_64<MachITypes> Mach_routines_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() {
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_routines_command Mach32_routines_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_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_routines_command Mach64_routines_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_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_routines_command MachBE32_routines_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_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_routines_command MachBE64_routines_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_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_routines_command MachLE32_routines_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_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_routines_command MachLE64_routines_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_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_routines_command Mach_routines_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:
PackMachBase(InputFile *, unsigned cpuid, unsigned filetype,
@@ -532,7 +569,7 @@ public:
// called by the generic pack()
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 pack4(OutputFile *, Filter &) = 0; // append PackHeader
@@ -575,7 +612,14 @@ protected:
Mach_header mhdri;
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
TE32 sz_unc; // uncompressed_size
+2 -2
View File
@@ -2,7 +2,7 @@
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.
UPX and the UCL library are free software; you can redistribute them
@@ -53,7 +53,7 @@
enum { // filetype
MH_EXECUTE = 2,
MH_DYLIB = 6,
MH_BUNDLE = 8 /* dynamically bound bundle file */
MH_BUNDLE = 8 /* dynamically bound bundle file */
};
enum { // flags
MH_NOUNDEFS = 1
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2002-2011 Jens Medoch
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2002-2013 Jens Medoch
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2002-2011 Jens Medoch
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
Copyright (C) 2002-2013 Jens Medoch
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+27 -14
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
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));
}
void PackUnix::pack2(OutputFile *fo, Filter &ft)
int PackUnix::pack2(OutputFile *fo, Filter &ft)
{
// compress blocks
unsigned total_in = 0;
@@ -142,6 +142,7 @@ void PackUnix::pack2(OutputFile *fo, Filter &ft)
// ui_total_passes = 0;
unsigned remaining = file_size;
unsigned n_block = 0;
while (remaining > 0)
{
// 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,
// so that decompression checks the end-to-end checksum.
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) {
const upx_bytep tbuf = NULL;
@@ -222,6 +224,8 @@ void PackUnix::pack2(OutputFile *fo, Filter &ft)
if ((off_t)total_in != file_size) {
throwEOFException();
}
return 1; // default: write end-of-compression bhdr next
}
void
@@ -283,12 +287,13 @@ void PackUnix::pack(OutputFile *fo)
set_te32(&hbuf.p_blocksize, blocksize);
fo->write(&hbuf, sizeof(hbuf));
pack2(fo, ft); // append the compressed body
// 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));
// append the compressed body
if (pack2(fo, ft)) {
// 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));
}
pack3(fo, ft); // append loader
@@ -498,18 +503,26 @@ void PackUnix::unpackExtent(unsigned wanted, OutputFile *fo,
int PackUnix::canUnpack()
{
upx_byte buf[sizeof(overlay_offset) + 32];
const int bufsize = sizeof(buf);
int const small = 32 + sizeof(overlay_offset);
// 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->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;
int l = ph.buf_offset + ph.getPackHeaderSize();
if (l < 0 || l + 4 > bufsize)
throwCantUnpack("file corrupted");
overlay_offset = get_te32(buf+l);
overlay_offset = get_te32(buf + i + l);
if ((off_t)overlay_offset >= file_size)
throwCantUnpack("file corrupted");
+3 -3
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -54,7 +54,7 @@ public:
protected:
// called by the generic pack()
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 pack4(OutputFile *, Filter &); // append PackHeader
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 2004-2011 John Reiser
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 2004-2013 John Reiser
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+5 -5
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
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");
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");
break;
@@ -917,7 +917,7 @@ void PackW32Pe::pack(OutputFile *fo)
if (!isrtm && ((isection[ic].flags & (PEFL_WRITE|PEFL_SHARED))
== (PEFL_WRITE|PEFL_SHARED)))
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)
throwCantPack("superfluous data between sections");
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
// file. If this check fails the runtime does "interesting" things
// 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
// 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
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2011 Laszlo Molnar
Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2013 Laszlo Molnar
All Rights Reserved.
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