This commit is contained in:
John Reiser 2006-06-16 06:53:56 -07:00
commit 7068e90771
289 changed files with 487 additions and 22147 deletions

View File

@ -13,9 +13,13 @@ default:
all mostlyclean clean distclean maintainer-clean:
ifneq ($(wildcard $(HOME)/local/bin/bin-upx),)
# these need special build tools
$(MAKE) -C src/stub/util/sstrip $@
# this needs special build tools
$(MAKE) -C src/stub $@
else
ifneq ($(wildcard $(HOME)/bin/bin-upx),)
# this needs special build tools
$(MAKE) -C src/stub $@
endif
endif
$(MAKE) -C src $@
$(MAKE) -C doc $@

View File

@ -1,5 +1,5 @@
Decompressing ELF Directly to Memory on Linux/x86
Copyright 2000 John F. Reiser jreiser@BitWagon.com
Copyright (C) 2000-2006 John F. Reiser jreiser@BitWagon.com
References:
<elf.h> definitions for the ELF file format

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2005 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2005 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@ -29,6 +29,7 @@
#include "conf.h"
#include "compress.h"
#include "mem.h"
#include <zlib.h>
/*************************************************************************
@ -40,25 +41,31 @@ unsigned upx_adler32(const void *buf, unsigned len, unsigned adler)
if (len == 0)
return adler;
assert(buf != NULL);
#if defined(WITH_UCL)
return ucl_adler32(adler, (const ucl_bytep)buf, len);
#if 0
return adler32(adler, (const Bytef *) buf, len); // zlib
#elif defined(WITH_UCL)
return ucl_adler32(adler, (const ucl_bytep) buf, len);
#else
# error
#endif
}
#if 0 /* UNUSED */
unsigned upx_crc32(const void *buf, unsigned len, unsigned crc)
{
if (len == 0)
return crc;
assert(buf != NULL);
#if defined(WITH_UCL)
return ucl_crc32(crc, (const ucl_bytep)buf, len);
#if 0
return crc32(crc, (const Bytef *) buf, len); // zlib
#elif defined(WITH_UCL)
return ucl_crc32(crc, (const ucl_bytep) buf, len);
#else
# error
#endif
}
#endif /* UNUSED */
/*************************************************************************

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@ -200,7 +200,7 @@ int upx_lzma_compress ( const upx_bytep src, upx_uint src_len,
if (pr[3].uintVal > src_len)
pr[3].uintVal = src_len;
if (enc.SetCoderProperties(propIDs, pr, 3) != S_OK)
if (enc.SetCoderProperties(propIDs, pr, 7) != S_OK)
goto error;
if (enc.WriteCoderProperties(&os) != S_OK)
goto error;
@ -227,7 +227,7 @@ int upx_lzma_compress ( const upx_bytep src, upx_uint src_len,
res->dict_size = pr[3].uintVal;
//res->num_probs = LzmaGetNumProbs(&s.Properties));
//res->num_probs = (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
res->num_probs = 1846 + (768 << (pr[2].uintVal + pr[1].uintVal));
res->num_probs = 1846 + (768 << (res->lit_context_bits + res->lit_pos_bits));
error:
*dst_len = os.Pos;
@ -260,6 +260,7 @@ error:
#undef _LZMA_OUT_READ
#undef _LZMA_PROB32
#undef _LZMA_LOC_OPT
#include "C/7zip/Compress/LZMA_C/LzmaDecode.h"
#include "C/7zip/Compress/LZMA_C/LzmaDecode.c"
int upx_lzma_decompress ( const upx_bytep src, upx_uint src_len,
@ -267,6 +268,9 @@ int upx_lzma_decompress ( const upx_bytep src, upx_uint src_len,
int method )
{
assert(method == M_LZMA);
// see res->num_probs above
COMPILE_TIME_ASSERT(LZMA_BASE_SIZE == 1846);
COMPILE_TIME_ASSERT(LZMA_LIT_SIZE == 768);
CLzmaDecoderState s;
SizeT src_out = 0, dst_out = 0;
@ -306,7 +310,9 @@ int upx_lzma_test_overlap ( const upx_bytep buf, upx_uint src_off,
{
assert(method == M_LZMA);
/* FIXME */
// FIXME - implement this
// Note that Packer::verifyOverlappingDecompression() will
// verify the final result in any case.
UNUSED(buf);
unsigned overlap_overhead = src_off + src_len - *dst_len;

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2004 John F. Reiser
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2004 John F. Reiser
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2004 John F. Reiser
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2004-2005 John F. Reiser
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2004-2006 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2005 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2005 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2004 John F. Reiser
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2004 John F. Reiser
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2004 John F. Reiser
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,7 +2,7 @@
This file is part of the UPX executable compressor.
Copyright (C) 2004 John Reiser
Copyright (C) 2004-2006 John Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2002-2004 Jens Medoch
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2002-2006 Jens Medoch
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 2004 John Reiser
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2004-2006 John Reiser
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them

View File

@ -9,15 +9,20 @@
MAKEFLAGS += -rR
.SUFFIXES:
.SECONDEXPANSION:
export SHELL = /bin/sh
# GNU make 3.81
.SECONDEXPANSION:
ifneq ($(findstring $(firstword $(MAKE_VERSION)),3.79 3.79.1 3.80),)
$(error GNU make 3.81 or better is required)
endif
# update $PATH for our special stub build tools
ifneq ($(wildcard $(HOME)/local/bin/bin-upx),)
export PATH := $(HOME)/local/bin/bin-upx:$(PATH)
endif
ifneq ($(wildcard $(HOME)/bin/bin-upx),)
export PATH := $(HOME)/bin/bin-upx:$(PATH)
endif
# /***********************************************************************
@ -74,7 +79,7 @@ endif
all: tmp/.tmp-stamp .all-stamp
tmp/.tmp-stamp:
@mkdir -p tmp
@mkdir -p $(dir $@)
@echo "timestamp" > $@
.all-stamp: $(STUBS)
@echo "timestamp" > $@
@ -113,7 +118,7 @@ tc.default.nasm += -I$(srcdir)/ -I$(srcdir)/src/
tc.default.nasm += -O99 -w+macro-params -w+macro-selfref -w+number-overflow -w+orphan-labels
tc.default.pp-asm = i386-linux-gcc-2.95.3 -E -nostdinc -x assembler-with-cpp -Wall -Wp,-P,-C,-traditional
tc.default.pp-nasm = $(tc.default.gpp_inc) --mode=nasm -I$(srcdir)/ -I$(srcdir)/src/
tc.default.stripelf = sstrip
tc.default.sstrip = sstrip
# some common settings for $(tc_list)
tc.i086.app-nasm = perl -w $(srcdir)/src/arch/i086/app-nasm.pl
@ -122,14 +127,14 @@ tc.i386.app-nasm = perl -w $(srcdir)/src/arch/i386/app-nasm.pl
# slightly tricky make stuff follows
# enumerate the names of all variables that will get tested (from basename and $(tc_list))
__tc_varlist = tc.$(basename $(notdir $@)).$1 $(foreach __tc_varlist_tmp,$(tc_list),tc.$(__tc_varlist_tmp).$1)
# return the name of the first variable that is not empty
__tc_varsearch = $(firstword $(foreach __tc_varsearch_tmp,$1,$(if $($(__tc_varsearch_tmp)),$(__tc_varsearch_tmp),)))
# error sentinel for missing commands
__tc_FALSE = false tc_FALSE: '$@' '$<'
# enumerate all variables that will get tested (from basename and $tc_list)
__tc_varlist = tc.$(basename $(notdir $@)).$1 $(foreach __tc_tmp,$(tc_list),tc.$(__tc_tmp).$1)
# return the _name_ of the first variable that is not empty
__tc_varname = $(firstword $(foreach __tc_vn,$2,$(if $($(__tc_vn)),$(__tc_vn),)) __tc_FALSE)
__tc_FALSE = false tc_FALSE: '$1' '$@' '$<'
# expand the first variable that is not empty
tc = $($(call __tc_varname,$1,$(call __tc_varlist,$1)))
tc = $($(call __tc_varsearch,$(call __tc_varlist,$1) __tc_FALSE))
# clear some vars, just in case
@ -148,6 +153,7 @@ IDENT_SUFFIX =
amd64-linux.elf% : tc_list = amd64-linux.elf default
tc.amd64-linux.elf.gcc = x86_64-unknown-linux-gnu-gcc-3.4.4 -m64 -nostdinc -MMD
tc.amd64-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables
tc.amd64-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror
tc.amd64-linux.elf.ld = x86_64-unknown-linux-gnu-ld -m elf_x86_64
tc.amd64-linux.elf.objcopy = x86_64-unknown-linux-gnu-objcopy
@ -161,7 +167,7 @@ amd64-linux.elf-entry.h : $(srcdir)/src/$$T.S
amd64-linux.elf-fold.h : tmp/$$T.o tmp/amd64-linux.elf-main.o
$(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^)
$(call tc,stripelf) tmp/$T.bin
$(call tc,sstrip) tmp/$T.bin
$(call tc,bin2h) --ident=linux_elf64amd_fold tmp/$T.bin $@
tmp/amd64-linux.elf-fold.o : $(srcdir)/src/$$T.S
@ -169,7 +175,7 @@ tmp/amd64-linux.elf-fold.o : $(srcdir)/src/$$T.S
$(call tc,objstrip) $@
tmp/amd64-linux.elf-main.o : $(srcdir)/src/$$T.c
$(call tc,gcc) -c -Os -fno-exceptions -fno-asynchronous-unwind-tables $< -o $@
$(call tc,gcc) -c -Os $< -o $@
$(call tc,objstrip) $@
@ -180,6 +186,7 @@ tmp/amd64-linux.elf-main.o : $(srcdir)/src/$$T.c
arm-linux.elf% : tc_list = arm-linux.elf default
tc.arm-linux.elf.gcc = arm-9tdmi-linux-gnu-gcc-3.4.5 -march=armv4 -nostdinc -MMD
tc.arm-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables
tc.arm-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror
tc.arm-linux.elf.ld = arm-9tdmi-linux-gnu-ld
tc.arm-linux.elf.objcopy = arm-9tdmi-linux-gnu-objcopy
@ -192,7 +199,7 @@ arm-linux.elf-entry.h : $(srcdir)/src/$$T.S
arm-linux.elf-fold.h : tmp/$$T.o tmp/arm-linux.elf-main.o
$(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^)
$(call tc,stripelf) tmp/$T.bin
$(call tc,sstrip) tmp/$T.bin
$(call tc,bin2h) --ident=linux_elf32arm_fold tmp/$T.bin $@
tmp/arm-linux.elf-fold.o : $(srcdir)/src/$$T.S
@ -200,7 +207,7 @@ tmp/arm-linux.elf-fold.o : $(srcdir)/src/$$T.S
$(call tc,objstrip) $@
tmp/arm-linux.elf-main.o : $(srcdir)/src/$$T.c
$(call tc,gcc) -c -Os -fno-exceptions -fno-asynchronous-unwind-tables $< -o $@
$(call tc,gcc) -c -Os $< -o $@
$(call tc,objstrip) $@
@ -209,12 +216,9 @@ tmp/arm-linux.elf-main.o : $(srcdir)/src/$$T.c
# // arm.v4t-wince.pe
# ************************************************************************/
arm.v4a-wince.pe% : tc_list = arm.v4a-wince.pe arm-wince.pe default
arm.v4t-wince.pe% : tc_list = arm.v4t-wince.pe arm-wince.pe default
tc.arm-wince.pe.gcc = arm-9tdmi-linux-gnu-gcc-3.4.5 -nostdinc -MMD
tc.arm-wince.pe.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror
tc.arm-wince.pe.objcopy = arm-9tdmi-linux-gnu-objcopy
# info: we use the tc settings from arm-linux.elf
arm.v4a-wince.pe% : tc_list = arm-linux.elf default
arm.v4t-wince.pe% : tc_list = arm-linux.elf default
arm.v4a-wince.pe.h : $(srcdir)/src/$$T.S
$(call tc,gcc) -march=armv4 -nostdlib $< -o tmp/$T.out
@ -316,6 +320,7 @@ i386-dos32.watcom.le.h : $(srcdir)/src/$$T.asm
i386-linux.elf% : tc_list = i386-linux.elf i386 default
tc.i386-linux.elf.gcc = i386-linux-gcc-3.4.6 -m32 -nostdinc -MMD
tc.i386-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables
tc.i386-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror
tc.i386-linux.elf.gcc += -march=i386 -mtune=k6
tc.i386-linux.elf.gcc += -Os -fno-omit-frame-pointer
@ -336,7 +341,7 @@ i386-linux.elf-entry.h : $(srcdir)/src/$$T.asm
i386-linux.elf-fold.h : tmp/$$T.o tmp/i386-linux.elf-main.o
$(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^)
$(call tc,objstrip) tmp/$T.bin
$(call tc,stripelf) tmp/$T.bin
$(call tc,sstrip) tmp/$T.bin
$(call tc,brandelf) tmp/$T.bin
$(call tc,bin2h) --ident=linux_i386elf_fold tmp/$T.bin $@
@ -353,7 +358,7 @@ tmp/i386-linux.elf-main.o : $(srcdir)/src/$$T.c
# // i386-linux.elf.execve
# ************************************************************************/
# tc settings are shared with i386-linux.elf
# note: tc_list settings are inherited from i386-linux.elf
i386-linux.elf.execve-entry.h : $(srcdir)/src/$$T.asm
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
@ -364,7 +369,7 @@ i386-linux.elf.execve-entry.h : $(srcdir)/src/$$T.asm
i386-linux.elf.execve-fold.h : tmp/$$T.o tmp/i386-linux.elf.execve-main.o tmp/i386-linux.elf.execve-upx_itoa.o
$(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^)
$(call tc,objstrip) tmp/$T.bin
$(call tc,stripelf) tmp/$T.bin
$(call tc,sstrip) tmp/$T.bin
$(call tc,brandelf) tmp/$T.bin
$(call tc,bin2h) --ident=linux_i386exec_fold tmp/$T.bin $@
@ -385,7 +390,7 @@ tmp/i386-linux.elf.execve-upx_itoa.o: $(srcdir)/src/$$T.asm
# // i386-linux.elf.interp
# ************************************************************************/
# tc settings are shared with i386-linux.elf
# note: tc_list settings are inherited from i386-linux.elf
i386-linux.elf.interp-entry.h : $(srcdir)/src/$$T.asm
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
@ -396,7 +401,7 @@ i386-linux.elf.interp-entry.h : $(srcdir)/src/$$T.asm
i386-linux.elf.interp-fold.h : tmp/$$T.o tmp/i386-linux.elf.interp-main.o
$(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^)
$(call tc,objstrip) tmp/$T.bin
$(call tc,stripelf) tmp/$T.bin
$(call tc,sstrip) tmp/$T.bin
$(call tc,brandelf) tmp/$T.bin
$(call tc,bin2h) --ident=linux_i386pti_fold tmp/$T.bin $@
@ -413,7 +418,7 @@ tmp/i386-linux.elf.interp-main.o : $(srcdir)/src/$$T.c
# // i386-linux.elf.shell
# ************************************************************************/
# tc settings are shared with i386-linux.elf
# note: tc_list settings are inherited from i386-linux.elf
i386-linux.elf.shell-entry.h : $(srcdir)/src/$$T.asm
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
@ -424,7 +429,7 @@ i386-linux.elf.shell-entry.h : $(srcdir)/src/$$T.asm
i386-linux.elf.shell-fold.h : tmp/$$T.o tmp/i386-linux.elf.shell-main.o
$(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^)
$(call tc,objstrip) tmp/$T.bin
$(call tc,stripelf) tmp/$T.bin
$(call tc,sstrip) tmp/$T.bin
$(call tc,brandelf) tmp/$T.bin
$(call tc,bin2h) --ident=linux_i386sh_fold tmp/$T.bin $@
@ -520,7 +525,8 @@ mipsel.r3000-ps1-console.h: IDENT_NAME = nrv_con_loader
powerpc-linux.elf% : tc_list = powerpc-linux.elf default
tc.powerpc-linux.elf.gcc = powerpc-750-linux-gnu-gcc-3.4.4 -nostdinc -MMD
tc.powerpc-linux.elf.gcc = powerpc-750-linux-gnu-gcc-3.4.4 -mcpu=405 -nostdinc -MMD
tc.powerpc-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables
tc.powerpc-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror
tc.powerpc-linux.elf.ld = powerpc-750-linux-gnu-ld
tc.powerpc-linux.elf.objcopy = powerpc-750-linux-gnu-objcopy
@ -534,7 +540,7 @@ powerpc-linux.elf-entry.h : $(srcdir)/src/$$T.S
powerpc-linux.elf-fold.h : tmp/$$T.o tmp/powerpc-linux.elf-main.o
$(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^)
## $(call tc,stripelf) tmp/$T.bin ## FIXME / TODO
$(call tc,sstrip) tmp/$T.bin
$(call tc,bin2h) --ident=linux_elfppc32_fold tmp/$T.bin $@
tmp/powerpc-linux.elf-fold.o : $(srcdir)/src/$$T.S
@ -542,7 +548,7 @@ tmp/powerpc-linux.elf-fold.o : $(srcdir)/src/$$T.S
$(call tc,objstrip) $@
tmp/powerpc-linux.elf-main.o : $(srcdir)/src/$$T.c
$(call tc,gcc) -c -Os -fno-exceptions -fno-asynchronous-unwind-tables $< -o $@
$(call tc,gcc) -c -Os $< -o $@
$(call tc,objstrip) $@
@ -550,6 +556,7 @@ tmp/powerpc-linux.elf-main.o : $(srcdir)/src/$$T.c
# // powerpc-darwin.macho
# ************************************************************************/
# info: we use the tc settings from powerpc-linux.elf
powerpc-darwin.macho% : tc_list = powerpc-linux.elf default
powerpc-darwin.macho-entry.h : $(srcdir)/src/$$T.S
@ -560,7 +567,6 @@ powerpc-darwin.macho-entry.h : $(srcdir)/src/$$T.S
powerpc-darwin.macho-fold.h : tmp/$$T.o tmp/powerpc-darwin.macho-main.o
$(call tc,ld) --oformat binary -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^)
## $(call tc,stripelf) tmp/$T.bin ## FIXME / TODO
$(call tc,bin2h) --ident=fold_machppc32 tmp/$T.bin $@
tmp/powerpc-darwin.macho-fold.o : $(srcdir)/src/$$T.S
@ -568,7 +574,7 @@ tmp/powerpc-darwin.macho-fold.o : $(srcdir)/src/$$T.S
$(call tc,objstrip) $@
tmp/powerpc-darwin.macho-main.o : $(srcdir)/src/$$T.c
$(call tc,gcc) -c -Os -fno-exceptions -fno-asynchronous-unwind-tables $< -o $@
$(call tc,gcc) -c -Os $< -o $@
$(call tc,objstrip) $@
@ -582,51 +588,4 @@ tmp/powerpc-darwin.macho-main.o : $(srcdir)/src/$$T.c
-include tmp/*.d
# /***********************************************************************
# // debug
# ************************************************************************/
define debug-diff
-diff $(HOME)/p/compress/upx/680c27309177-upx.hg/src/stub/$2 $1
endef
debug-diff: $(STUBS)
$(call debug-diff,amd64-linux.elf-entry.h,l_lx_elf64amd.h)
$(call debug-diff,amd64-linux.elf-fold.h,fold_elf64amd.h)
$(call debug-diff,arm-linux.elf-entry.h,l_lx_elf32arm.h)
$(call debug-diff,arm-linux.elf-fold.h,fold_elf32arm.h)
$(call debug-diff,arm.v4a-wince.pe.h,l_armpea.h)
$(call debug-diff,arm.v4t-wince.pe.h,l_armpet.h)
$(call debug-diff,i086-dos16.com.h,l_com.h)
$(call debug-diff,i086-dos16.exe.h,l_exe.h)
$(call debug-diff,i086-dos16.sys.h,l_sys.h)
$(call debug-diff,i386-dos32.djgpp2.h,l_djgpp2.h)
$(call debug-diff,i386-dos32.djgpp2-stubify.h,stubify.h)
$(call debug-diff,i386-dos32.tmt.h,l_tmt.h)
$(call debug-diff,i386-dos32.watcom.le.h,l_wcle.h)
$(call debug-diff,i386-linux.elf-entry.h,l_lx_elf86.h)
$(call debug-diff,i386-linux.elf-fold.h,fold_elf86.h)
$(call debug-diff,i386-linux.elf.execve-entry.h,l_lx_exec86.h)
$(call debug-diff,i386-linux.elf.execve-fold.h,fold_exec86.h)
$(call debug-diff,i386-linux.elf.interp-entry.h,l_lx_pti86.h)
$(call debug-diff,i386-linux.elf.interp-fold.h,fold_pti86.h)
$(call debug-diff,i386-linux.elf.shell-entry.h,l_lx_sh86.h)
$(call debug-diff,i386-linux.elf.shell-fold.h,fold_sh86.h)
$(call debug-diff,i386-linux.kernel.vmlinux.h,l_vmlinx.h)
$(call debug-diff,i386-linux.kernel.vmlinuz.h,l_vmlinz.h)
$(call debug-diff,i386-win32.pe.h,l_w32pe.h)
$(call debug-diff,m68k-atari.tos-nrv2b.h,l_t_n2b.h)
$(call debug-diff,m68k-atari.tos-nrv2b.small.h,l_t_n2bs.h)
$(call debug-diff,m68k-atari.tos-nrv2d.h,l_t_n2d.h)
$(call debug-diff,m68k-atari.tos-nrv2d.small.h,l_t_n2ds.h)
$(call debug-diff,m68k-atari.tos-nrv2e.h,l_t_n2e.h)
$(call debug-diff,m68k-atari.tos-nrv2e.small.h,l_t_n2es.h)
$(call debug-diff,mipsel.r3000-ps1-boot.h,l_ps1b.h)
$(call debug-diff,mipsel.r3000-ps1-console.h,l_ps1c.h)
$(call debug-diff,powerpc-darwin.macho-entry.h,l_mac_ppc32.h)
$(call debug-diff,powerpc-darwin.macho-fold.h,fold_machppc32.h)
$(call debug-diff,powerpc-linux.elf-entry.h,l_lx_elfppc32.h)
$(call debug-diff,powerpc-linux.elf-fold.h,fold_elfppc32.h)
# vi:nowrap
# vi:ts=8:nowrap

View File

@ -1,368 +0,0 @@
/* a_lx_elf64.c -- stub loader for Linux 64-bit ELF executable
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2005 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/
#include "linux.hh"
extern void exit(int);
/*************************************************************************
// configuration section
**************************************************************************/
// In order to make it much easier to move this code at runtime and execute
// it at an address different from it load address: there must be no
// static data, and no string constants.
#define MAX_ELF_HDR 1024 // Elf64_Ehdr + n*Elf64_Phdr must fit in this
/*************************************************************************
// "file" util
**************************************************************************/
typedef struct {
size_t size; // must be first to match size[0] uncompressed size
char *buf;
} Extent;
static void
xread(Extent *x, char *buf, size_t count)
{
char *p=x->buf, *q=buf;
size_t j;
if (x->size < count) {
exit(127);
}
for (j = count; 0!=j--; ++p, ++q) {
*q = *p;
}
x->buf += count;
x->size -= count;
}
/*************************************************************************
// util
**************************************************************************/
#if 1 //{ save space
#define ERR_LAB error: exit(127);
#define err_exit(a) goto error
#else //}{ save debugging time
#define ERR_LAB
static void
err_exit(int a)
{
(void)a; // debugging convenience
exit(127);
}
#endif //}
/*************************************************************************
// UPX & NRV stuff
**************************************************************************/
typedef void f_unfilter(
nrv_byte *, // also addvalue
nrv_uint,
unsigned cto8, // junk in high 24 bits
unsigned ftid
);
typedef int f_expand(
const nrv_byte *, nrv_uint,
nrv_byte *, nrv_uint *, unsigned );
static void
unpackExtent(
Extent *const xi, // input
Extent *const xo, // output
f_expand *const f_decompress,
f_unfilter *f_unf
)
{
while (xo->size) {
struct b_info h;
// Note: if h.sz_unc == h.sz_cpr then the block was not
// compressible and is stored in its uncompressed form.
// Read and check block sizes.
xread(xi, (char *)&h, sizeof(h));
if (h.sz_unc == 0) { // uncompressed size 0 -> EOF
if (h.sz_cpr != UPX_MAGIC_LE32) // h.sz_cpr must be h->magic
err_exit(2);
if (xi->size != 0) // all bytes must be written
err_exit(3);
break;
}
if (h.sz_cpr <= 0) {
err_exit(4);
ERR_LAB
}
if (h.sz_cpr > h.sz_unc
|| h.sz_unc > xo->size ) {
err_exit(5);
}
// Now we have:
// assert(h.sz_cpr <= h.sz_unc);
// assert(h.sz_unc > 0 && h.sz_unc <= blocksize);
// assert(h.sz_cpr > 0 && h.sz_cpr <= blocksize);
if (h.sz_cpr < h.sz_unc) { // Decompress block
nrv_uint out_len;
int const j = (*f_decompress)((unsigned char *)xi->buf, h.sz_cpr,
(unsigned char *)xo->buf, &out_len, h.b_method );
if (j != 0 || out_len != (nrv_uint)h.sz_unc)
err_exit(7);
// Skip Ehdr+Phdrs: separate 1st block, not filtered
if (h.b_ftid!=0 && f_unf // have filter
&& ((512 < out_len) // this block is longer than Ehdr+Phdrs
|| (xo->size==(unsigned)h.sz_unc) ) // block is last in Extent
) {
(*f_unf)((unsigned char *)xo->buf, out_len, h.b_cto8, h.b_ftid);
}
xi->buf += h.sz_cpr;
xi->size -= h.sz_cpr;
}
else { // copy literal block
xread(xi, xo->buf, h.sz_cpr);
}
xo->buf += h.sz_unc;
xo->size -= h.sz_unc;
}
}
#if 0 /*{*/
static void
upx_bzero(char *p, size_t len)
{
if (len) do {
*p++= 0;
} while (--len);
}
#define bzero upx_bzero
#else
#define bzero(a,b) __builtin_memset(a,0,b)
#endif /*}*/
static void
auxv_up(Elf64_auxv_t *av, unsigned const type, uint64_t const value)
{
if (av)
for (;; ++av) {
if (av->a_type==type || (av->a_type==AT_IGNORE && type!=AT_NULL)) {
av->a_type = type;
av->a_un.a_val = value;
return;
}
}
}
// The PF_* and PROT_* bits are {1,2,4}; the conversion table fits in 32 bits.
#define REP8(x) \
((x)|((x)<<4)|((x)<<8)|((x)<<12)|((x)<<16)|((x)<<20)|((x)<<24)|((x)<<28))
#define EXP8(y) \
((1&(y)) ? 0xf0f0f0f0 : (2&(y)) ? 0xff00ff00 : (4&(y)) ? 0xffff0000 : 0)
#define PF_TO_PROT(pf) \
((PROT_READ|PROT_WRITE|PROT_EXEC) & ( \
( (REP8(PROT_EXEC ) & EXP8(PF_X)) \
|(REP8(PROT_READ ) & EXP8(PF_R)) \
|(REP8(PROT_WRITE) & EXP8(PF_W)) \
) >> ((pf & (PF_R|PF_W|PF_X))<<2) ))
// Find convex hull of PT_LOAD (the minimal interval which covers all PT_LOAD),
// and mmap that much, to be sure that a kernel using exec-shield-randomize
// won't place the first piece in a way that leaves no room for the rest.
static unsigned long // returns relocation constant
xfind_pages(unsigned mflags, Elf64_Phdr const *phdr, int phnum,
char **const p_brk
)
{
size_t lo= ~0, hi= 0, szlo= 0;
char *addr;
mflags += MAP_PRIVATE | MAP_ANONYMOUS; // '+' can optimize better than '|'
for (; --phnum>=0; ++phdr) if (PT_LOAD==phdr->p_type) {
if (phdr->p_vaddr < lo) {
lo = phdr->p_vaddr;
szlo = phdr->p_filesz;
}
if (hi < (phdr->p_memsz + phdr->p_vaddr)) {
hi = phdr->p_memsz + phdr->p_vaddr;
}
}
szlo += ~PAGE_MASK & lo; // page fragment on lo edge
lo -= ~PAGE_MASK & lo; // round down to page boundary
hi = PAGE_MASK & (hi - lo - PAGE_MASK -1); // page length
szlo = PAGE_MASK & (szlo - PAGE_MASK -1); // page length
addr = mmap((void *)lo, hi, PROT_NONE, mflags, -1, 0);
*p_brk = hi + addr; // the logical value of brk(0)
//mprotect(szlo + addr, hi - szlo, PROT_NONE); // no access, but keep the frames!
return (unsigned long)addr - lo;
}
static Elf64_Addr // entry address
do_xmap(
Elf64_Ehdr const *const ehdr,
Extent *const xi,
int const fdi,
Elf64_auxv_t *const av,
f_expand *const f_decompress,
f_unfilter *const f_unf
)
{
Elf64_Phdr const *phdr = (Elf64_Phdr const *) (ehdr->e_phoff +
(char const *)ehdr);
char *v_brk;
unsigned long const reloc = xfind_pages(
((ET_DYN!=ehdr->e_type) ? MAP_FIXED : 0), phdr, ehdr->e_phnum, &v_brk);
int j;
for (j=0; j < ehdr->e_phnum; ++phdr, ++j)
if (xi && PT_PHDR==phdr->p_type) {
auxv_up(av, AT_PHDR, phdr->p_vaddr + reloc);
} else
if (PT_LOAD==phdr->p_type) {
unsigned const prot = PF_TO_PROT(phdr->p_flags);
Extent xo;
size_t mlen = xo.size = phdr->p_filesz;
char *addr = xo.buf = reloc + (char *)phdr->p_vaddr;
char *haddr = phdr->p_memsz + addr;
size_t frag = (long)addr &~ PAGE_MASK;
mlen += frag;
addr -= frag;
if (addr != mmap(addr, mlen, prot | (xi ? PROT_WRITE : 0),
MAP_FIXED | MAP_PRIVATE | (xi ? MAP_ANONYMOUS : 0),
(xi ? -1 : fdi), phdr->p_offset - frag) ) {
err_exit(8);
}
if (xi) {
unpackExtent(xi, &xo, f_decompress, f_unf);
}
// Linux does not fixup the low end, so neither do we.
//if (PROT_WRITE & prot) {
// bzero(addr, frag); // fragment at lo end
//}
frag = (-mlen) &~ PAGE_MASK; // distance to next page boundary
if (PROT_WRITE & prot) { // note: read-only .bss not supported here
bzero(mlen+addr, frag); // fragment at hi end
}
if (xi) {
if (0==phdr->p_offset) {
Elf64_Ehdr *const ehdr = (Elf64_Ehdr *)addr;
*(int *)&ehdr->e_ident[12] = 0x90c3050f; // syscall; ret; nop
}
if (0!=mprotect(addr, mlen, prot)) {
err_exit(10);
ERR_LAB
}
}
addr += mlen + frag; /* page boundary on hi end */
if (addr < haddr) { // need pages for .bss
if (addr != mmap(addr, haddr - addr, prot,
MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0 ) ) {
err_exit(9);
}
}
}
if (xi) { // 1st call (main); also have (0!=av) here
if (ET_DYN!=ehdr->e_type) {
// Needed only if compressed shell script invokes compressed shell.
brk(v_brk);
}
}
return ehdr->e_entry + reloc;
}
/*************************************************************************
// upx_main - called by our entry code
//
// This function is optimized for size.
**************************************************************************/
void *
upx_main( // returns entry address
struct b_info const *const bi, // 1st block header
size_t const sz_compressed, // total length
Elf64_Ehdr *const ehdr, // temp char[sz_ehdr] for decompressing
Elf64_auxv_t *const av,
f_expand *const f_decompress,
f_unfilter *const f_unf
)
{
Elf64_Phdr const *phdr = (Elf64_Phdr const *)(1+ ehdr);
Elf64_Addr entry;
Extent xo, xi1, xi2;
xo.buf = (char *)ehdr;
xo.size = bi->sz_unc;
xi2.buf = CONST_CAST(char *, bi); xi2.size = sz_compressed;
xi1.buf = CONST_CAST(char *, bi); xi1.size = sz_compressed;
// ehdr = Uncompress Ehdr and Phdrs
unpackExtent(&xi2, &xo, f_decompress, 0); // never filtered?
// AT_PHDR.a_un.a_val is set again by do_xmap if PT_PHDR is present.
auxv_up(av, AT_PHDR , (unsigned long)(1+(Elf64_Ehdr *)phdr->p_vaddr));
auxv_up(av, AT_PHNUM , ehdr->e_phnum);
auxv_up(av, AT_ENTRY , (unsigned long)ehdr->e_entry);
//auxv_up(av, AT_PHENT , ehdr->e_phentsize); /* this can never change */
//auxv_up(av, AT_PAGESZ, PAGE_SIZE); /* ld-linux.so.2 does not need this */
entry = do_xmap(ehdr, &xi1, 0, av, f_decompress, f_unf); // "rewind"
{ // Map PT_INTERP program interpreter
int j;
for (j=0; j < ehdr->e_phnum; ++phdr, ++j) if (PT_INTERP==phdr->p_type) {
char const *const iname = (char const *)phdr->p_vaddr;
int const fdi = open(iname, O_RDONLY, 0);
if (0 > fdi) {
err_exit(18);
}
if (MAX_ELF_HDR!=read(fdi, (void *)ehdr, MAX_ELF_HDR)) {
ERR_LAB
err_exit(19);
}
entry = do_xmap(ehdr, 0, fdi, 0, 0, 0);
close(fdi);
}
}
return (void *)entry;
}
/*
vi:ts=4:et:nowrap
*/

View File

@ -1,64 +0,0 @@
/* amd_bxx.S -- AMD x86_64 Call/Branch Trick unfilter
This file is part of the UPX executable compressor.
Copyright (C) 2005 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
John F. Reiser
<jreiser@users.sourceforge.net>
*/
#include "amd_regs.h"
amdbxx: # (*f_unf)(xo->buf, out_len, h.b_cto8, h.b_ftid);
#define ptr %arg1 /* known to be %rdi */
#define len %arg2
#define cto8 %arg3l /* known to be "%dl" */
#define ftid %arg4l
cmpl $0x49,ftid; jne ckend # filter: JMP, CALL, 6-byte Jxx
movq len,%rcx # byte count
movq ptr,%rsi # remember start of buffer
jmp ckstart
ckloop3:
movb (%rdi),%al; addq $1,%rdi
cmpb $0x80,%al; jb ckloop2 # lo of 6-byte Jcc
cmpb $0x8F,%al; ja ckloop2 # hi of 6-byte Jcc
cmpb $0x0F,-2(%rdi); je ckmark # prefix of 6-byte Jcc
ckloop2:
subb $ 0xE8,%al
cmpb $0xE9-0xE8,%al; ja ckcount # not JMP, not CALL
ckmark:
cmpb %dl,(%rdi); jne ckcount # not marked with cto8
movl (%rdi),%eax # the marked, bswapped 32-bit displacement
andl $~0<<8,%eax # clear the mark
bswap %eax
subl %edi,%eax
addl %esi,%eax
stosl # *%rdi++ = %eax;
ckstart:
subq $4,%rcx
movb (%rdi),%al; addq $1,%rdi
decq %rcx; jnz ckloop2 # prefix cannot overlap previous displacement
jmp ckend
ckcount:
decq %rcx; jnz ckloop3
ckend:
ret

View File

@ -1,68 +0,0 @@
/* amd_d_nrv2b.S -- AMD64 decompressor for NRV2B
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2005 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/
.p2align 3
lit_n2b:
incq %rsi; movb %dl,(%rdi)
incq %rdi
top_n2b:
movb (%rsi),%dl # speculate: literal, or bottom 8 bits of offset
jnextb1yp lit_n2b
lea 1(lenq),off # [len= 0] off= 1
offmore_n2b:
getnextbp(off)
jnextb0np offmore_n2b
subl $ 3,off; jc len_n2b # use previous offset
shll $ 8,off; movzbl %dl,%edx
orl %edx,off; incq %rsi
xorl $~0,off; jz eof
movslq off,disp # XXX: 2GB
len_n2b:
lea 1(lenq),off # [len= 0] off= 1
getnextb(len); getnextb(len) # two bits; cc set on result
jnz gotlen_n2b # raw 1,2,3 ==> 2,3,4
movl off,len # len= 1, the msb
addl $3-1,off # raw 2.. ==> 5..
lenmore_n2b:
getnextb(len)
jnextb0n lenmore_n2b
gotlen_n2b:
cmpq $-0xd00,disp
adcl off,len # len += off + (disp < -0xd00)
call copy
bot_n2b: # In: 0==len
jmp top_n2b
/*
vi:ts=8:et:nowrap
*/

View File

@ -1,81 +0,0 @@
/* amd_d_nrv2e.S -- AMD64 decompressor for NRV2E
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2005 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/
.p2align 3
lit_n2e:
incq %rsi; movb %dl,(%rdi)
incq %rdi
top_n2e:
movb (%rsi),%dl # speculate: literal, or bottom 8 bits of offset
jnextb1yp lit_n2e
lea 1(lenq),off # [len= 0] off= 1
jmp getoff_n2e
off_n2e:
dec off
getnextbp(off)
getoff_n2e:
getnextbp(off)
jnextb0np off_n2e
subl $ 3,off; jc offprev_n2e
shll $ 8,off; movzbl %dl,%edx
orl %edx,off; incq %rsi
xorl $~0,off; jz eof
sarl off # Carry= original low bit
movslq off,disp # XXX: 2GB
jc lenlast_n2e
jmp lenmore_n2e
offprev_n2e:
jnextb1y lenlast_n2e
lenmore_n2e:
incl len # len= 1
jnextb1y lenlast_n2e
len_n2e:
getnextb(len)
jnextb0n len_n2e
addl $6-2-2,len
jmp gotlen_n2e
lenlast_n2e:
getnextb(len) # 0,1,2,3
gotlen_n2e:
cmpq $-0x500,disp
adcl $2,len # len += 2+ (disp < -0x500);
call copy
bot_n2e: # In: 0==len
jmp top_n2e
/*
vi:ts=8:et:nowrap
*/

View File

@ -1,15 +0,0 @@
/* NOTE: THE FIRST ARGUMENT IS arg1, NOT arg0. */
#define arg1 rdi
#define arg1l edi
#define arg2 rsi
#define arg2l esi
#define arg3 rdx
#define arg3l edx
#define arg4 rcx
#define arg4l ecx
#define sys4 r10 # 4th arg to syscall is not in %rcx
#define sys4l r10d
#define arg5 r8
#define arg5l r8d
#define arg6 r9
#define arg6l r9d

View File

@ -1,129 +0,0 @@
/* arm_nrv2b_d32.S -- ARM decompressor for NRV2B
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/
#define src r0
#define len r1
#define dst r2
#define tmp r3
#define bits r4
#define off r5
#define g1b r6
#define wrnk r7 /* 0xd00 M2_MAX_OFFSET before "wrinkle" */
/* r12 ("ip") is assumed to be a scratch register. */
#define GETBIT blx g1b
#define getnextb(reg) GETBIT; adc reg,reg
#define jnextb0 GETBIT; bcc
#define jnextb1 GETBIT; bcs
ucl_nrv2b_decompress_32: .globl ucl_nrv2b_decompress_32 @ ARM mode
.type ucl_nrv2b_decompress_32, %function
/* error = (*)(char const *src, int len_src, char *dst, int *plen_dst) */
adr r12,1+go_thumb_n2b @ load pc-relative address
bx r12 @ enter THUMB mode
.code 16 @ THUMB mode
go_thumb_n2b:
add r1,len,src @ r1= eof_src;
push {r1,r2,r3, r4,r5,r6,r7, lr}
mov bits,#1; neg off,bits @ off= -1 initial condition
lsl bits,#31 @ 1<<31: refill next time
mov wrnk,#0xd
lsl wrnk,#8 @ 0xd00
adr g1b,get1b @ load pc-relative address
b top_n2b
eof_n2b:
pop {r1,r3,r4} @ r1= eof_src; r3= orig_dst; r4= plen_dst
sub src,r1 @ 0 if actual src length equals expected length
sub dst,r3 @ actual dst length
str dst,[r4]
pop {r4,r5,r6,r7, pc} @ return
lit_n2b:
ldrb tmp,[src]; add src,#1
strb tmp,[dst]; add dst,#1
top_n2b:
jnextb1 lit_n2b
mov len,#1 @ the msb
getoff_n2b: @ ss11 len= [2..)
getnextb(len)
jnextb0 getoff_n2b
sub tmp,len,#3 @ set Carry
mov len,#0 @ Carry unaffected
blo offprev_n2b @ ss11 returned 2
lsl tmp,#8
ldrb off,[src]; add src,#1 @ low 8 bits
orr off,tmp
mvn off,off; beq eof_n2b @ off= ~off
offprev_n2b: @ In: 0==len
getnextb(len); getnextb(len); bne plus1_n2b @ two bits; 1,2,3 ==> 2,3,4
mov len,#1 @ the msb
getlen_n2b: @ ss11 len= [2..)
getnextb(len)
jnextb0 getlen_n2b
add len,#2 @ [2..) ==> [4..);
plus1_n2b:
add len,#1 @ 1,2,3 ==> 2,3,4; [4..) ==> [5..)
/* 'cmn': add the inputs, set condition codes, discard the sum */
cmn off,wrnk; bcs near_n2b @ within M2_MAX_OFFSET
add len,#1 @ too far away, so minimum match length is 3
near_n2b:
ldrb tmp,[dst] @ force cacheline allocate
copy_n2b:
ldrb tmp,[dst,off]
strb tmp,[dst]; add dst,#1
sub len,#1; bne copy_n2b
b top_n2b
.code 32 @ ARM mode
get1b: @ Out: Carry= next_bit
adds bits,bits,bits @ shift up, set Carry
bxne lr @ return if reload is not needed
/* In: Carry set (unchanged until final adcs) */
ldrb bits,[src],#1
ldrb tmp, [src],#1; orr bits,bits,tmp,lsl #1*8
ldrb tmp, [src],#1; orr bits,bits,tmp,lsl #2*8
ldrb tmp, [src],#1; orr bits,bits,tmp,lsl #3*8
adcs bits,bits,bits @ Carry= next_bit; set bit0 flag from CarryIn
bx lr
.size ucl_nrv2b_decompress_32, .-ucl_nrv2b_decompress_32
/*
vi:ts=8:et:nowrap
*/

View File

@ -1,124 +0,0 @@
/* arm_nrv2b_d8.S -- ARM decompressor for NRV2B
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/
#define src r0
#define len r1
#define dst r2
#define tmp r3
#define bits r4
#define off r5
/* r6 UNUSED */
#define wrnk r7 /* 0xd00 M2_MAX_OFFSET before "wrinkle" */
/* r12 ("ip") is assumed to be a scratch register. */
#define GETBIT add bits,bits; mov lr,pc; beq get1_n2b
#define getnextb(reg) GETBIT; adc reg,reg
#define jnextb0 GETBIT; bcc
#define jnextb1 GETBIT; bcs
ucl_nrv2b_decompress_8: .globl ucl_nrv2b_decompress_8 @ ARM mode
.type ucl_nrv2b_decompress_8, %function
/* error = (*)(char const *src, int len_src, char *dst, int *plen_dst) */
adr r12,1+go_thumb_n2b @ load pc-relative address
bx r12 @ enter THUMB mode
.code 16 @ THUMB mode
.thumb_func
go_thumb_n2b: .globl go_thumb_n2b
add r1,len,src @ r1= eof_src;
push {r1,r2,r3, r4,r5,r6,r7, lr}
mov bits,#1; neg off,bits @ off= -1 initial condition
lsl bits,#31 @ 1<<31: refill next time
mov wrnk,#0xd
lsl wrnk,#8 @ 0xd00
b top_n2b
eof_n2b:
pop {r1,r3,r4} @ r1= eof_src; r3= orig_dst; r4= plen_dst
sub src,r1 @ 0 if actual src length equals expected length
sub dst,r3 @ actual dst length
str dst,[r4]
pop {r4,r5,r6,r7 /*,pc*/}
pop {r1}; bx r1 @ "pop {,pc}" fails return to ARM mode on ARMv4T
get1_n2b:
ldrb bits,[src] @ zero-extend next byte
adc bits,bits @ double and insert CarryIn as low bit
add src,#1
lsl bits,#24 @ move to top byte, and set CarryOut from old bit 8
mov pc,lr
lit_n2b:
ldrb tmp,[src]; add src,#1
strb tmp,[dst]; add dst,#1
top_n2b:
jnextb1 lit_n2b
mov len,#1 @ the msb
getoff_n2b: @ ss11 len= [2..)
getnextb(len)
jnextb0 getoff_n2b
sub tmp,len,#3 @ set Carry
mov len,#0 @ Carry unaffected
blo offprev_n2b @ ss11 returned 2
lsl tmp,#8
ldrb off,[src]; add src,#1 @ low 8 bits
orr off,tmp
mvn off,off; beq eof_n2b @ off= ~off
offprev_n2b: @ In: 0==len
getnextb(len); getnextb(len); bne plus1_n2b @ two bits; 1,2,3 ==> 2,3,4
mov len,#1 @ the msb
getlen_n2b: @ ss11 len= [2..)
getnextb(len)
jnextb0 getlen_n2b
add len,#2 @ [2..) ==> [4..);
plus1_n2b:
add len,#1 @ 1,2,3 ==> 2,3,4; [4..) ==> [5..)
/* 'cmn': add the inputs, set condition codes, discard the sum */
cmn off,wrnk; bcs near_n2b @ within M2_MAX_OFFSET
add len,#1 @ too far away, so minimum match length is 3
near_n2b:
ldrb tmp,[dst] @ force cacheline allocate
copy_n2b:
ldrb tmp,[dst,off]
strb tmp,[dst]; add dst,#1
sub len,#1; bne copy_n2b
b top_n2b
.size ucl_nrv2b_decompress_8, .-ucl_nrv2b_decompress_8
/*
vi:ts=8:et:nowrap
*/

View File

@ -1,138 +0,0 @@
/* arm_nrv2e_d32.S -- ARM decompressor for NRV2E
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/
#define src r0
#define len r1 /* overlaps 'cnt' */
#define dst r2
#define tmp r3
#define bits r4
#define off r5
#define g32 r6
#define wrnk r7 /* 0x500 M2_MAX_OFFSET before "wrinkle" */
#define cnt r1 /* overlaps 'len' while reading an offset */
#define GETBIT \
add bits,bits; beq 1f; 0: \
.subsection 1; \
1: blx g32; b 0b; \
.subsection 0
#define getnextb(reg) GETBIT; adc reg,reg
#define jnextb0 GETBIT; bcc
#define jnextb1 GETBIT; bcs
ucl_nrv2e_decompress_32: .globl ucl_nrv2e_decompress_32 @ ARM mode
.type ucl_nrv2e_decompress_32, %function
/* error = (*)(char const *src, int len_src, char *dst, int *plen_dst) */
adr r12,1+thumb_nrv2e_d32; bx r12 @ enter THUMB mode
.code 16 @ THUMB mode
thumb_nrv2e_d32:
add r1,len,src @ r1= eof_src;
push {r1,r2,r3, r4,r5,r6,r7, lr}
mov bits,#1; neg off,bits @ off= -1 initial condition
lsl bits,#31 @ 1<<31; refill next time
mov wrnk,#5
lsl wrnk,#8 @ 0x500
adr g32,get32 @ load pc-relative address
b top_n2e
eof_n2e:
pop {r1,r3,r4} @ r1= eof_src; r3= orig_dst; r4= plen_dst
sub src,r1 @ 0 if actual src length equals expected length
sub dst,r3 @ actual dst length
str dst,[r4]
pop {r4,r5,r6,r7, pc} @ return
lit_n2e:
ldrb tmp,[src]; add src,#1
strb tmp,[dst]; add dst,#1
top_n2e:
jnextb1 lit_n2e
mov cnt,#1; b getoff_n2e
off_n2e:
sub cnt,#1
getnextb(cnt)
getoff_n2e:
getnextb(cnt)
jnextb0 off_n2e
sub tmp,cnt,#3 @ set Carry
mov len,#0 @ Carry unaffected
blo offprev_n2e @ cnt was 2; tests Carry only
lsl tmp,#8
ldrb off,[src]; add src,#1 @ low 7+1 bits
orr off,tmp
mvn off,off; beq eof_n2e @ off= ~off
asr off,#1; bcs lenlast_n2e
b lenmore_n2e
offprev_n2e:
jnextb1 lenlast_n2e
lenmore_n2e:
mov len,#1
jnextb1 lenlast_n2e
len_n2e:
getnextb(len)
jnextb0 len_n2e
add len,#6-2
b gotlen_n2e
lenlast_n2e:
getnextb(len) @ 0,1,2,3
add len,#2
gotlen_n2e: @ 'cmn': add the inputs, set condition codes, discard the sum
cmn off,wrnk; bcs near_n2e @ within M2_MAX_OFFSET
add len,#1 @ too far away, so minimum match length is 3
near_n2e:
ldrb tmp,[dst] @ force cacheline allocate
copy_n2e:
ldrb tmp,[dst,off]
strb tmp,[dst]; add dst,#1
sub len,#1; bne copy_n2e
b top_n2e
.code 32 @ ARM mode for ease of Carry manipulation
get32: @ In: Carry set (unchanged until final adcs)
ldrb bits,[src],#1
ldrb tmp, [src],#1; orr bits,bits,tmp,lsl #1*8
ldrb tmp, [src],#1; orr bits,bits,tmp,lsl #2*8
ldrb tmp, [src],#1; orr bits,bits,tmp,lsl #3*8
adcs bits,bits,bits @ Set Carry out
bx lr
.size ucl_nrv2e_decompress_32, .-ucl_nrv2e_decompress_32
/*
vi:ts=8:et:nowrap
*/

View File

@ -1,182 +0,0 @@
/* arm_nrv2e_d8.S -- ARM decompressor for NRV2E
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/
#define SAFE 0 /* 1 for src+dst bounds checking: cost 40 bytes */
#define src r0
#define len r1 /* overlaps 'cnt' */
#define dst r2
#define tmp r3
#define bits r4
#define off r5
#define wrnk r6 /* 0x500 M2_MAX_OFFSET before "wrinkle" */
#define srclim r7
#if 1==SAFE /*{*/
#define dstlim r12
#endif /*}*/
#define cnt r1 /* overlaps 'len' while reading an offset */
#if 1==SAFE /*{*/
#define CHECK_SRC cmp src,srclim; bhs bad_src_n2e
#define CHECK_DST cmp dst,dstlim; bhs bad_dst_n2e
#else /*}{*/
#define CHECK_SRC /*empty*/
#define CHECK_DST /*empty*/
#endif /*}*/
#if 0 /*{ DEBUG only: check newly-decompressed against original dst */
#define CHECK_BYTE \
push {wrnk}; \
ldrb wrnk,[dst]; \
cmp wrnk,tmp; beq 0f; bkpt; \
0: pop {wrnk}
#else /*}{*/
#define CHECK_BYTE /*empty*/
#endif /*}*/
/* "mov lr,pc; bxx ..." implements conditional subroutine call */
#define GETBIT add bits,bits; mov lr,pc; beq get1_n2e
#define getnextb(reg) GETBIT; adc reg,reg
#define jnextb0 GETBIT; bcc
#define jnextb1 GETBIT; bcs
ucl_nrv2e_decompress_8: .globl ucl_nrv2e_decompress_8 @ ARM mode
.type ucl_nrv2e_decompress_8, %function
/* error = (*)(char const *src, int len_src, char *dst, int *plen_dst)
Actual decompressed length is stored through plen_dst.
For SAFE mode: at call, *plen_dst must be allowed length of output buffer.
*/
adr r12,1+thumb_nrv2e_d8; bx r12 @ enter THUMB mode
.code 16 @ THUMB mode
.globl thumb_nrv2e_d8
.thumb_func
thumb_nrv2e_d8:
push {r2,r3, r4,r5,r6,r7, lr}
#define sp_DST0 0 /* stack offset of original dst */
add srclim,len,src @ srclim= eof_src;
#if 1==SAFE /*{*/
ldr tmp,[r3] @ len_dst
add tmp,dst
mov dstlim,tmp
#endif /*}*/
mov bits,#1; neg off,bits @ off= -1 initial condition
lsl bits,#31 @ 1<<31; refill next time
mov wrnk,#5
lsl wrnk,#8 @ 0x500 @ nrv2e M2_MAX_OFFSET
b top_n2e
#if 1==SAFE /*{*/
bad_dst_n2e: # return value will be 2
add src,srclim,#1
bad_src_n2e: # return value will be 1
add src,#1
#endif /*}*/
eof_n2e:
pop {r3,r4} @ r3= orig_dst; r4= plen_dst
sub src,srclim @ 0 if actual src length equals expected length
sub dst,r3 @ actual dst length
str dst,[r4]
pop {r4,r5,r6,r7 /*,pc*/}
pop {r1}; bx r1 @ "pop {,pc}" fails return to ARM mode on ARMv4T
get1_n2e: @ In: Carry set [from adding 0x80000000 (1<<31) to itself]
ldrb bits,[src] @ zero-extend next byte
adc bits,bits @ double and insert CarryIn as low bit
CHECK_SRC
add src,#1
lsl bits,#24 @ move to top byte, and set CarryOut from old bit 8
mov pc,lr @ return, stay in current (THUMB) mode
lit_n2e:
CHECK_SRC; ldrb tmp,[src]; add src,#1
CHECK_BYTE
CHECK_DST; strb tmp,[dst]; add dst,#1
top_n2e:
jnextb1 lit_n2e
mov cnt,#1; b getoff_n2e
off_n2e:
sub cnt,#1
getnextb(cnt)
getoff_n2e:
getnextb(cnt)
jnextb0 off_n2e
sub tmp,cnt,#3 @ set Carry
mov len,#0 @ Carry unaffected
blo offprev_n2e @ cnt was 2; tests Carry only
lsl tmp,#8
CHECK_SRC; ldrb off,[src]; add src,#1 @ low 7+1 bits
orr off,tmp
mvn off,off; beq eof_n2e @ off= ~off
asr off,#1; bcs lenlast_n2e
b lenmore_n2e
offprev_n2e:
jnextb1 lenlast_n2e
lenmore_n2e:
mov len,#1
jnextb1 lenlast_n2e
len_n2e:
getnextb(len)
jnextb0 len_n2e
add len,#6-2
b gotlen_n2e
lenlast_n2e:
getnextb(len) @ 0,1,2,3
add len,#2
gotlen_n2e: @ 'cmn': add the inputs, set condition codes, discard the sum
cmn wrnk,off; bcs near_n2e @ within M2_MAX_OFFSET
add len,#1 @ too far away, so minimum match length is 3
near_n2e:
#if 1==SAFE /*{*/
ldr tmp,[sp,#sp_DST0]
sub tmp,dst
sub tmp,off; bhi bad_dst_n2e @ reaching back too far
add tmp,dst,cnt
cmp tmp,dstlim; bhi bad_dst_n2e @ too much output
#endif /*}*/
ldrb tmp,[dst] @ force cacheline allocate
copy_n2e:
ldrb tmp,[dst,off]
CHECK_BYTE
strb tmp,[dst]; add dst,#1
sub len,#1; bne copy_n2e
b top_n2e
.size ucl_nrv2e_decompress_8, .-ucl_nrv2e_decompress_8
/*
vi:ts=8:et:nowrap
*/

View File

@ -1,195 +0,0 @@
/* armv4_n2e_d8.S -- ARM decompressor for NRV2E
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/
#define SAFE 0 /* 1 for src+dst bounds checking: cost 76 bytes */
#define src r0
#define len r1 /* overlaps 'cnt' */
#define dst r2
#define tmp r3
#define bits r4
#define off r5
/* r6 UNUSED in ARM code unless DEBUG mode */
#define srclim r7
#if 1==SAFE /*{*/
#define dstlim r12
#endif /*}*/
#define cnt r1 /* overlaps 'len' while reading an offset */
/* macros reduce "noise" when comparing this ARM code to corresponding THUMB code */
#define PUSH stmdb sp!,
#define POP ldmia sp!,
#define ADD2( dst,src) add dst,dst,src
#define ADD2S(dst,src) adds dst,dst,src
#define ADC2( dst,src) adc dst,dst,src
#define ADC2S(dst,src) adcs dst,dst,src
#define SUB2( dst,src) sub dst,dst,src
#define SUB2S(dst,src) subs dst,dst,src
#define LDRB3(reg,psrc,incr) ldrb reg,psrc,incr
#define STRB3(reg,pdst,incr) strb reg,pdst,incr
#if 1==SAFE /*{*/
#define CHECK_SRC cmp srclim,src; bls bad_src_n2e /* Out: 1==Carry for get8_n2e */
#define CHECK_DST cmp dst,dstlim; bhs bad_dst_n2e
#else /*}{*/
#define CHECK_SRC /*empty*/
#define CHECK_DST /*empty*/
#endif /*}*/
#if 0 /*{ DEBUG only: check newly-decompressed against original dst */
#define CHECK_BYTE \
ldrb r6,[dst]; \
cmp r6,tmp; beq 0f; bkpt; 0:
#else /*}{*/
#define CHECK_BYTE /*empty*/
#endif /*}*/
#define GETBIT ADD2S(bits,bits); bleq get8_n2e
#define getnextb(reg) GETBIT; ADC2(reg,reg) /* Out: condition code not changed */
#define jnextb0 GETBIT; bcc
#define jnextb1 GETBIT; bcs
ucl_nrv2e_decompress_8: .globl ucl_nrv2e_decompress_8 @ ARM mode
.type ucl_nrv2e_decompress_8, %function
/* error = (*)(char const *src, int len_src, char *dst, int *plen_dst)
Actual decompressed length is stored through plen_dst.
For SAFE mode: at call, *plen_dst must be allowed length of output buffer.
*/
PUSH {r2,r3, r4,r5,r6,r7, lr}
#define sp_DST0 0 /* stack offset of original dst */
add srclim,len,src @ srclim= eof_src;
#if 1==SAFE /*{*/
ldr tmp,[r3] @ len_dst
add dstlim,tmp,dst
#endif /*}*/
mvn off,#~-1 @ off= -1 initial condition
mov bits,#1<<31 @ refill next time
b top_n2e
#if 1==SAFE /*{*/
bad_dst_n2e: # return value will be 2
bkpt
add src,srclim,#1
bad_src_n2e: # return value will be 1
ADD2(src,#1)
#endif /*}*/
eof_n2e:
POP {r3,r4} @ r3= orig_dst; r4= plen_dst
SUB2(src,srclim) @ 0 if actual src length equals expected length
SUB2(dst,r3) @ actual dst length
str dst,[r4]
#if defined(LINUX_ARM_CACHEFLUSH) /*{*/
/* linux/include/asm-arm/unistd.h */
#define __NR_SYSCALL_BASE 0x900000
#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
mov r4,r0 @ save result value
mov r0,r3 @ orig_dst
add r1,r3,dst @ orig_dst + dst_len
mov r2,#0
swi __ARM_NR_cacheflush @ decompressed region
mov r0,r4 @ result value
#endif /*}*/
POP {r4,r5,r6,r7 ,pc}
get8_n2e: @ In: Carry set [from adding 0x80000000 (1<<31) to itself]
CHECK_SRC; LDRB3(bits,[src],#1) @ zero-extend next byte
adc bits,bits,bits @ double and insert CarryIn as low bit
movs bits,bits,lsl #24 @ move to top byte, and set CarryOut from old bit 8
mov pc,lr
lit_n2e:
CHECK_SRC; LDRB3(tmp,[src],#1)
CHECK_BYTE
CHECK_DST; STRB3(tmp,[dst],#1)
top_n2e:
jnextb1 lit_n2e
mov cnt,#1; b getoff_n2e
off_n2e:
SUB2(cnt,#1)
getnextb(cnt)
getoff_n2e:
getnextb(cnt)
jnextb0 off_n2e
subs tmp,cnt,#3 @ set Carry
mov len,#0 @ Carry unaffected
blo offprev_n2e @ cnt was 2; tests Carry only
CHECK_SRC; LDRB3(off,[src],#1) @ low 7+1 bits
orr off,off,tmp,lsl #8
mvns off,off; beq eof_n2e @ off= ~off
movs off,off,asr #1; bcs lenlast_n2e
b lenmore_n2e
offprev_n2e:
jnextb1 lenlast_n2e
lenmore_n2e:
mov len,#1
jnextb1 lenlast_n2e
len_n2e:
getnextb(len)
jnextb0 len_n2e
ADD2(len,#6-2)
b gotlen_n2e
lenlast_n2e:
getnextb(len) @ 0,1,2,3
ADD2(len,#2)
gotlen_n2e: @ 'cmn': add the inputs, set condition codes, discard the sum
cmn off,#5<<8; bcs near_n2e @ within M2_MAX_OFFSET
ADD2(len,#1) @ too far away, so minimum match length is 3
near_n2e:
#if 1==SAFE /*{*/
ldr tmp,[sp,#sp_DST0]
SUB2( tmp,dst)
SUB2S(tmp,off); bhi bad_dst_n2e @ reaching back too far
add tmp,dst,cnt
cmp tmp,dstlim; bhi bad_dst_n2e @ too much output
#endif /*}*/
ldrb tmp,[dst] @ force cacheline allocate
copy_n2e:
ldrb tmp,[dst,off]
CHECK_BYTE
STRB3(tmp,[dst],#1)
SUB2S(len,#1); bne copy_n2e
b top_n2e
.size ucl_nrv2e_decompress_8, .-ucl_nrv2e_decompress_8
/*
vi:ts=8:et:nowrap
*/

View File

@ -1,253 +0,0 @@
; cl1_d32.ash -- cl1_decompress_le32 in 32-bit assembly
; schema from ucl/nrv2b_d32.ash
;
; Copyright (C) 2004 John Reiser
; Copyright (C) 1996-2003 Markus Franz Xaver Johannes Oberhumer
; All Rights Reserved.
;
; This file is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of
; the License, or (at your option) any later version.
;
; This file is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with the UCL library; see the file COPYING.
; If not, write to the Free Software Foundation, Inc.,
; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;
; Markus F.X.J. Oberhumer John Reiser
; <markus@oberhumer.com> <jreiser@BitWagon.com>
;
; ------------- DECOMPRESSION -------------
; Input:
; esi - source
; edi - dest
; ebp - -1
; cld
; Output:
; eax - 0
; ecx - 0
%ifndef jmps
%define jmps jmp short
%endif
%ifndef jmpn
%define jmpn jmp near
%endif
;; One of these two is instantiated many times by buildLoader
%ifdef __CL1SMA1B__
call edx
%else; __CL1FAS1B__
add ebx, ebx
db 0x75,2 ;jnz cl1_no_reload
call edx
;cl1_no_reload:
%endif; __CL1GET1B__
; __CL1ENTER__
nop ; 'int3' for debugging
call start_cl1 ; pic push address of next instr
; __CL1SMA10__
getbit_cl1: ; appears only in small version
add ebx, ebx
jz reload_cl1
ret
; __CL1RLOAD__
reload_cl1: ; for both small and fast version
mov ebx, [esi]
sub esi, byte -4
adc ebx, ebx
ret
; __CL1WID01__
widelit_cl1:
sub ecx,ecx ; back to 0
; getbit
; __CL1WID02__
adc ecx,ecx
; getbit
; __CL1WID03__
jc lit89_cl1
; getbit
; __CL1WID04__
adc ecx,ecx
; getbit
; __CL1WID05__
jc lit10_12_cl1
; getbit
; __CL1WID06__
adc ecx,ecx ; 0..7; -1+ (width/2) of length
litwidth_cl1: ; ss22 algorithm, counted width<=8 pairs; returns eax= 2..0x15555
; getbit
; __CL1WID07__
adc eax,eax
dec eax
; getbit
; __CL1WID08__
adc eax,eax
sub ecx, byte 1
jnc litwidth_cl1
lea ecx,[17 -2 + eax] ; 17: predecessors; ss22 returns 2..
cmp eax,0xffff-(17 -2)
jb litgo_cl1 ; not maximal range of search
lea eax,[esi + ecx] ; esi after copy
push eax ; "parameter" to maxlit_cl1
jmpn maxlit_cl1 ; can have another literal afterwards
lit13_16_cl1:
; getbit
; __CL1WID09__
adc ecx,ecx
; getbit
; __CL1WID10__
adc ecx,ecx
add ecx, byte 13
jmps litmov_cl1
lit10_12_cl1:
test ecx,ecx
jz lit13_16_cl1
inc ecx ; 2,3,4
lit89_cl1:
add ecx, byte 8
litgo_cl1:
jmps litmov_cl1
; __CL1START__
start_cl1:
sub ecx,ecx ; 0
pop edx ; edx= getbit_cl1 or reload_cl1
sub ebx, ebx ; cause reload on first bit
; __CL1TOP00__
top_cl1: ; In: 0==ecx
lea eax,[1+ ecx] ; 1: the msb of offset or large width
; getbit
; __CL1TOP01__
jnc match_cl1
; getbit
; __CL1TOP02__
jc lit1_cl1
; getbit
; __CL1TOP03__
jc lit2_cl1
; getbit
; __CL1TOP04__
jc lit3_cl1
add ecx, byte 2
; getbit
; __CL1TOP05__
jc lit45_cl1
inc ecx
; getbit
; __CL1TOP06__
jc lit67_cl1
jmpn widelit_cl1
lit67_cl1:
lit45_cl1:
; getbit
; __CL1TOP07__
adc ecx,ecx
litmov_cl1:
db 0xD1,((3<<6)|(5<<3)|1) ;shr ecx,1
jnc litmovb_cl1
movsb
litmovb_cl1:
db 0xD1,((3<<6)|(5<<3)|1) ;shr ecx,1
jnc litmovw_cl1
movsw
litmovw_cl1:
rep
movsd
lea eax,[1+ ecx] ; 1: the msb
jmps litdone_cl1
lit3_cl1:
movsb
lit2_cl1:
movsb
lit1_cl1:
movsb
litdone_cl1:
match_cl1: ; In: 0==ecx; 1==eax
offset_cl1: ; ss11 algorithm
; getbit
; __CL1OFF01__
adc eax,eax
; getbit
; __CL1OFF02__
jnc offset_cl1
sub eax, byte 3 ; 2.. ==> -1[prev], (0,,<<8)|byte
jc prev_off_cl1
shl eax,8
lodsb
xor eax, byte ~0
jz done_cl1 ; EOF
mov ebp,eax ; -offset
prev_off_cl1: ; 1st 2 bits encode (5<=len),2,3,4
; getbit
; __CL1OFF03__
adc ecx,ecx
; getbit
; __CL1OFF04__
adc ecx,ecx
jnz wrinkle_cl1
; __CL1LEN00__
inc ecx ; 1: the msb
mlen_cl1:
; getbit
; __CL1LEN01__
adc ecx,ecx
; getbit
; __CL1LEN02__
jnc mlen_cl1
add ecx, byte 2 ; 2.. ==> 4..
; __CL1COPY0__
wrinkle_cl1:
cmp ebp,-0xd00
adc ecx, byte 1
copy_cl1:
push esi
lea esi,[edi + ebp]
cmp ebp, byte -4
ja ripple_cl1
maxlit_cl1: ; literal copy cannot overlap; omit test for ripple
db 0xD1,((3<<6)|(5<<3)|1) ;shr ecx,1
jnc maxlitb_cl1
movsb
maxlitb_cl1:
db 0xD1,((3<<6)|(5<<3)|1) ;shr ecx,1
jnc maxlitw_cl1
movsw
maxlitw_cl1:
rep
movsd
popbot_cl1:
pop esi
bottom_cl1:
jmpn top_cl1
ripple_cl1:
cmp ebp, byte -1
jne ripmov_cl1
lodsb
rep
stosb
jmps popbot_cl1
ripmov_cl1:
rep
movsb
jmps popbot_cl1
done_cl1:
; __CL1END__
; vi:ts=8:et

Some files were not shown because too many files have changed in this diff Show More