1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

allow better handling for no_filter option;

new options is_ptinterp, use_ptintep, make_ptinterp;
reserve codes for M_CL1B.
	compress.ch conf.h main.cpp options.h

committer: jreiser <jreiser> 1108939577 +0000
This commit is contained in:
John Reiser 2005-02-20 22:46:17 +00:00
parent 67a77f1880
commit 8d60343940
4 changed files with 53 additions and 11 deletions

View File

@ -89,15 +89,10 @@ int upx_compress ( const upx_bytep src, upx_uint src_len,
// prepare bit-buffer settings
conf.bb_endian = 0;
conf.bb_size = 0;
if (method >= M_NRV2B_LE32 && method <= M_NRV2E_LE16)
if (method >= M_NRV2B_LE32 && method <= M_CL1B_LE16)
{
int n = (method - M_NRV2B_LE32) % 3;
if (n == 0)
conf.bb_size = 32;
else if (n == 1)
conf.bb_size = 8;
else
conf.bb_size = 16;
static unsigned char sizes[3]={32,8,16};
conf.bb_size = sizes[(method - M_NRV2B_LE32) % 3];
}
else
throwInternalError("unknown compression method");
@ -119,6 +114,11 @@ int upx_compress ( const upx_bytep src, upx_uint src_len,
r = ucl_nrv2e_99_compress(src, src_len, dst, dst_len,
cb, level, &conf, result);
#endif
#if 0 /*{*/
else if M_IS_CL1B(method)
r = cl1b_compress(src, src_len, dst, dst_len,
cb, level, &conf, result);
#endif /*}*/
else
throwInternalError("unknown compression method");
@ -171,6 +171,17 @@ int upx_decompress ( const upx_bytep src, upx_uint src_len,
r = ucl_nrv2e_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
break;
#endif
#if 0 /*{*/
case M_CL1B_8:
r = cl1b_decompress_safe_8(src,src_len,dst,dst_len,NULL);
break;
case M_CL1B_LE16:
r = cl1b_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
break;
case M_CL1B_LE32:
r = cl1b_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
break;
#endif /*}*/
default:
throwInternalError("unknown decompression method");
break;
@ -225,6 +236,17 @@ int upx_test_overlap ( const upx_bytep buf, upx_uint src_off,
r = ucl_nrv2e_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
break;
#endif
#if 0 /*{*/
case M_CL1B_8:
r = cl1b_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
break;
case M_CL1B_LE16:
r = cl1b_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
break;
case M_CL1B_LE32:
r = cl1b_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
break;
#endif /*}*/
default:
throwInternalError("unknown decompression method");
break;

View File

@ -423,10 +423,14 @@ inline void operator delete[](void *p)
#define M_NRV2E_LE32 8
#define M_NRV2E_8 9
#define M_NRV2E_LE16 10
#define M_CL1B_LE32 11
#define M_CL1B_8 12
#define M_CL1B_LE16 13
#define M_IS_NRV2B(x) ((x) >= M_NRV2B_LE32 && (x) <= M_NRV2B_LE16)
#define M_IS_NRV2D(x) ((x) >= M_NRV2D_LE32 && (x) <= M_NRV2D_LE16)
#define M_IS_NRV2E(x) ((x) >= M_NRV2E_LE32 && (x) <= M_NRV2E_LE16)
#define M_IS_CL1B(x) ((x) >= M_CL1B_LE32 && (x) <= M_CL1B_LE16)
// Executable formats. Note: big endian types are >= 128.
@ -449,8 +453,12 @@ inline void operator delete[](void *p)
#define UPX_F_ELKS_8086 17
#define UPX_F_PS1_EXE 18
#define UPX_F_VMLINUX_i386 19
#define UPX_F_LINUX_ELFI_i386 20
#define UPX_F_ATARI_TOS 129
#define UPX_F_SOLARIS_SPARC 130
#define UPX_F_MACH_PPC32 131
#define UPX_F_LINUX_ELFPPC32 132
#define UPX_MAGIC_LE32 0x21585055 /* "UPX!" */

View File

@ -567,6 +567,7 @@ static int do_option(int optc, const char *arg)
case 522: // --no-filter
opt->filter = 0;
opt->all_filters = false;
opt->no_filter = true;
break;
case 523: // --all-filters
opt->all_filters = true;
@ -703,7 +704,13 @@ static int do_option(int optc, const char *arg)
set_script_name(mfx_optarg,1);
break;
case 663:
opt->o_unix.ptinterp = true;
opt->o_unix.is_ptinterp = true;
break;
case 664:
opt->o_unix.use_ptinterp = true;
break;
case 665:
opt->o_unix.make_ptinterp = true;
break;
case 670:
opt->ps1_exe.boot_only = true;
@ -823,7 +830,9 @@ static const struct mfx_option longopts[] =
#if 0
{"script", 0x31, 0, 662}, // --script=
#endif
{"ptinterp", 0, 0, 663}, // linux/elf386 PT_INTERP program
{"is_ptinterp", 0, 0, 663}, // linux/elf386 PT_INTERP program
{"use_ptinterp", 0, 0, 664}, // linux/elf386 PT_INTERP program
{"make_ptinterp", 0, 0, 665}, // linux/elf386 PT_INTERP program
// watcom/le
{"le", 0, 0, 620}, // produce LE output
// win32/pe

View File

@ -51,6 +51,7 @@ struct options_t {
int filter; // preferred filter from Packer::getFilters()
bool all_methods; // try all available compression methods ?
bool all_filters; // try all available filters ?
bool no_filter; // force no filter
// other options
int backup;
@ -116,7 +117,9 @@ struct options_t {
struct {
unsigned blocksize;
bool force_execve; // force the linux/386 execve format
bool ptinterp; // is PT_INTERP, so don't adjust auxv_t
bool is_ptinterp; // is PT_INTERP, so don't adjust auxv_t
bool use_ptinterp; // use PT_INTERP /opt/upx/run
bool make_ptinterp; // make PT_INTERP [ignore current file!]
enum { SCRIPT_MAX = 32 };
const char *script_name;
} o_unix;