mirror of
https://github.com/upx/upx
synced 2025-10-05 19:20:23 +08:00
merge
This commit is contained in:
commit
1e38bbfbc1
2
BUGS
2
BUGS
|
@ -28,7 +28,7 @@ dos/exe
|
||||||
watcom/le
|
watcom/le
|
||||||
---------
|
---------
|
||||||
* 16-bit selector alias fixups
|
* 16-bit selector alias fixups
|
||||||
* 16-bit offset relocation for objects larger than 4 kB
|
* 16-bit offset relocation for objects larger than 4 KiB
|
||||||
* 16:16 fixups
|
* 16:16 fixups
|
||||||
|
|
||||||
If you need any of the above (they're very rare), send us an URL of a
|
If you need any of the above (they're very rare), send us an URL of a
|
||||||
|
|
2
NEWS
2
NEWS
|
@ -4,7 +4,7 @@ User visible changes for UPX
|
||||||
|
|
||||||
Changes in 3.03 (27 Apr 2008):
|
Changes in 3.03 (27 Apr 2008):
|
||||||
* implement cache flushing for PowerPC (esp. model 440)
|
* implement cache flushing for PowerPC (esp. model 440)
|
||||||
* fix cache flushing on MIPS (>3MB compressed, or with holes)
|
* fix cache flushing on MIPS (>3 MiB compressed, or with holes)
|
||||||
* fix MIPS big-endian
|
* fix MIPS big-endian
|
||||||
* bug fixes
|
* bug fixes
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ may not be used to take the address of a function.
|
||||||
|
|
||||||
The address 0x00400000 was chosen to be out of the way of the usual
|
The address 0x00400000 was chosen to be out of the way of the usual
|
||||||
load address 0x08048000, and to minimize fragmentation in kernel
|
load address 0x08048000, and to minimize fragmentation in kernel
|
||||||
page tables; one page of page tables covers 4MB. The address
|
page tables; one page of page tables covers 4 MiB. The address
|
||||||
0x00401000 was chosen as 1 page up from a 64KB boundary, to
|
0x00401000 was chosen as 1 page up from a 64 KiB boundary, to
|
||||||
make the startup code and its constants smaller.
|
make the startup code and its constants smaller.
|
||||||
|
|
||||||
Decompression of the executable begins by decompressing the Elf32_Ehdr
|
Decompression of the executable begins by decompressing the Elf32_Ehdr
|
||||||
|
|
|
@ -108,14 +108,14 @@ then skip another one - the unfiltering process needs some information
|
||||||
to be able to reverse the filtering.
|
to be able to reverse the filtering.
|
||||||
|
|
||||||
UPX uses the following idea, which works nicely. First we assume that
|
UPX uses the following idea, which works nicely. First we assume that
|
||||||
the size of the area that should be filtered is less than 16MB. Then
|
the size of the area that should be filtered is less than 16 MiB. Then
|
||||||
UPX scans over this area and keeps a record of the bytes that are
|
UPX scans over this area and keeps a record of the bytes that are
|
||||||
following the 0xE8 bytes. If we are lucky, there will be bytes that
|
following the 0xE8 bytes. If we are lucky, there will be bytes that
|
||||||
were not found following 0xE8. These bytes are our candidates to be
|
were not found following 0xE8. These bytes are our candidates to be
|
||||||
used as markers.
|
used as markers.
|
||||||
|
|
||||||
Do you still remember that we assumed that the size of scanned area is
|
Do you still remember that we assumed that the size of scanned area is
|
||||||
less than 16MB? Well, this means that when we process a real call, the
|
less than 16 MiB? Well, this means that when we process a real call, the
|
||||||
resulting offset will be less than 0x00FFFFFF too. So the MSB is always
|
resulting offset will be less than 0x00FFFFFF too. So the MSB is always
|
||||||
0x00. Which is a nice place to store our marker. Of course we should
|
0x00. Which is a nice place to store our marker. Of course we should
|
||||||
reverse the byte order in the resulting offset - so this marker will
|
reverse the byte order in the resulting offset - so this marker will
|
||||||
|
|
18
doc/upx.pod
18
doc/upx.pod
|
@ -51,8 +51,8 @@ B<UPX> is a versatile executable packer with the following features:
|
||||||
- excellent compression ratio: compresses better than zip/gzip,
|
- excellent compression ratio: compresses better than zip/gzip,
|
||||||
use UPX to decrease the size of your distribution !
|
use UPX to decrease the size of your distribution !
|
||||||
|
|
||||||
- very fast decompression: about 10 MB/sec on an ancient Pentium 133,
|
- very fast decompression: about 10 MiB/sec on an ancient Pentium 133,
|
||||||
about 200 MB/sec on an Athlon XP 2000+.
|
about 200 MiB/sec on an Athlon XP 2000+.
|
||||||
|
|
||||||
- no memory overhead for your compressed executables for most of the
|
- no memory overhead for your compressed executables for most of the
|
||||||
supported formats
|
supported formats
|
||||||
|
@ -153,7 +153,7 @@ as compared to the first decompressed version.]
|
||||||
|
|
||||||
B<UPX> offers ten different compression levels from B<-1> to B<-9>,
|
B<UPX> offers ten different compression levels from B<-1> to B<-9>,
|
||||||
and B<--best>. The default compression level is B<-8> for files
|
and B<--best>. The default compression level is B<-8> for files
|
||||||
smaller than 512 kB, and B<-7> otherwise.
|
smaller than 512 KiB, and B<-7> otherwise.
|
||||||
|
|
||||||
=over 4
|
=over 4
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ Extra options available for this executable format:
|
||||||
First of all, it is recommended to use B<UPX> *instead* of B<strip>. strip has
|
First of all, it is recommended to use B<UPX> *instead* of B<strip>. strip has
|
||||||
the very bad habit of replacing your stub with its own (outdated) version.
|
the very bad habit of replacing your stub with its own (outdated) version.
|
||||||
Additionally B<UPX> corrects a bug/feature in strip v2.8.x: it
|
Additionally B<UPX> corrects a bug/feature in strip v2.8.x: it
|
||||||
will fix the 4 KByte alignment of the stub.
|
will fix the 4 KiB alignment of the stub.
|
||||||
|
|
||||||
B<UPX> includes the full functionality of stubify. This means it will
|
B<UPX> includes the full functionality of stubify. This means it will
|
||||||
automatically stubify your COFF files. Use the option B<--coff> to
|
automatically stubify your COFF files. Use the option B<--coff> to
|
||||||
|
@ -660,8 +660,8 @@ Specific drawbacks:
|
||||||
|
|
||||||
- Because of temporary decompression to disk the decompression speed
|
- Because of temporary decompression to disk the decompression speed
|
||||||
is not as fast as with the other executable formats. Still, I can see
|
is not as fast as with the other executable formats. Still, I can see
|
||||||
no noticeable delay when starting programs like my ~3 MB emacs (which
|
no noticeable delay when starting programs like my ~3 MiB emacs (which
|
||||||
is less than 1 MB when compressed :-).
|
is less than 1 MiB when compressed :-).
|
||||||
|
|
||||||
Extra options available for this executable format:
|
Extra options available for this executable format:
|
||||||
|
|
||||||
|
@ -681,7 +681,7 @@ nostalgic feelings of one of the authors.
|
||||||
Packed programs will be byte-identical to the original after uncompression,
|
Packed programs will be byte-identical to the original after uncompression,
|
||||||
until further notice.
|
until further notice.
|
||||||
|
|
||||||
Maximum uncompressed size: ~1.89 / ~7.60 Mbytes.
|
Maximum uncompressed size: ~1.89 / ~7.60 MiB.
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
||||||
|
@ -708,7 +708,7 @@ Extra options available for this executable format:
|
||||||
|
|
||||||
--8-bit Uses 8 bit size compression [default: 32 bit]
|
--8-bit Uses 8 bit size compression [default: 32 bit]
|
||||||
|
|
||||||
--8mb-ram PSone has 8 MB ram available [default: 2 MB]
|
--8mib-ram PSone has 8 MiB ram available [default: 2 MiB]
|
||||||
|
|
||||||
--boot-only This format is for main exes and CD-Mastering only !
|
--boot-only This format is for main exes and CD-Mastering only !
|
||||||
It may slightly improve the compression ratio,
|
It may slightly improve the compression ratio,
|
||||||
|
@ -838,7 +838,7 @@ must end with ".scr" (as screensavers are handled slightly different
|
||||||
than normal exe files).
|
than normal exe files).
|
||||||
|
|
||||||
UPX compressed PE files have some minor memory overhead (usually in the
|
UPX compressed PE files have some minor memory overhead (usually in the
|
||||||
10 - 30 kbytes range) which can be seen by specifying the "-i" command
|
10 - 30 KiB range) which can be seen by specifying the "-i" command
|
||||||
line switch during compression.
|
line switch during compression.
|
||||||
|
|
||||||
Extra options available for this executable format:
|
Extra options available for this executable format:
|
||||||
|
|
|
@ -276,7 +276,7 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
||||||
#if 0
|
#if 0
|
||||||
// DEBUG - set sizes so that we use a maxmimum amount of stack.
|
// DEBUG - set sizes so that we use a maxmimum amount of stack.
|
||||||
// These settings cause res->num_probs == 3147574, i.e. we will
|
// These settings cause res->num_probs == 3147574, i.e. we will
|
||||||
// need about 6 MB of stack during runtime decompression.
|
// need about 6 MiB of stack during runtime decompression.
|
||||||
pr[1].uintVal = 4;
|
pr[1].uintVal = 4;
|
||||||
pr[2].uintVal = 8;
|
pr[2].uintVal = 8;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -47,7 +47,7 @@ static int F(Filter *f)
|
||||||
unsigned calls = 0, noncalls = 0, noncalls2 = 0;
|
unsigned calls = 0, noncalls = 0, noncalls2 = 0;
|
||||||
unsigned lastnoncall = size, lastcall = 0;
|
unsigned lastnoncall = size, lastcall = 0;
|
||||||
|
|
||||||
// find a 16MB large empty address space
|
// find a 16 MiB large empty address space
|
||||||
{
|
{
|
||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
memset(buf,0,256);
|
memset(buf,0,256);
|
||||||
|
|
|
@ -51,7 +51,7 @@ static int F(Filter *f)
|
||||||
unsigned calls = 0, noncalls = 0, noncalls2 = 0;
|
unsigned calls = 0, noncalls = 0, noncalls2 = 0;
|
||||||
unsigned lastnoncall = size, lastcall = 0;
|
unsigned lastnoncall = size, lastcall = 0;
|
||||||
|
|
||||||
// find a 16MB large empty address space
|
// find a 16 MiB large empty address space
|
||||||
{
|
{
|
||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
memset(buf,0,256);
|
memset(buf,0,256);
|
||||||
|
|
|
@ -123,8 +123,8 @@ static int F(Filter *f)
|
||||||
N_MRU : 0;
|
N_MRU : 0;
|
||||||
#endif //}
|
#endif //}
|
||||||
|
|
||||||
// FIXME: We must fit into 8MB because we steal one bit.
|
// FIXME: We must fit into 8 MiB because we steal one bit.
|
||||||
// find a 16MB large empty address space
|
// find a 16 MiB large empty address space
|
||||||
{
|
{
|
||||||
int which;
|
int which;
|
||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
|
|
|
@ -52,7 +52,7 @@ static int F(Filter *f)
|
||||||
unsigned calls = 0, noncalls = 0, noncalls2 = 0;
|
unsigned calls = 0, noncalls = 0, noncalls2 = 0;
|
||||||
unsigned lastnoncall = size, lastcall = 0;
|
unsigned lastnoncall = size, lastcall = 0;
|
||||||
|
|
||||||
// find a 16MB large empty address space
|
// find a 16 MiB large empty address space
|
||||||
{
|
{
|
||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
memset(buf,0,256);
|
memset(buf,0,256);
|
||||||
|
|
|
@ -263,7 +263,7 @@ void show_help(int verbose)
|
||||||
fg = con_fg(f,fg);
|
fg = con_fg(f,fg);
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" --8-bit uses 8 bit size compression [default: 32 bit]\n"
|
" --8-bit uses 8 bit size compression [default: 32 bit]\n"
|
||||||
" --8mb-ram 8 megabyte memory limit [default: 2 mb]\n"
|
" --8mib-ram 8 megabyte memory limit [default: 2 MiB]\n"
|
||||||
" --boot-only disables client/host transfer compatibility\n"
|
" --boot-only disables client/host transfer compatibility\n"
|
||||||
" --no-align don't align to 2048 bytes [enables: --console-run]\n"
|
" --no-align don't align to 2048 bytes [enables: --console-run]\n"
|
||||||
"\n");
|
"\n");
|
||||||
|
|
|
@ -881,7 +881,7 @@ static int do_option(int optc, const char *arg)
|
||||||
opt->ps1_exe.do_8bit = true;
|
opt->ps1_exe.do_8bit = true;
|
||||||
break;
|
break;
|
||||||
case 673:
|
case 673:
|
||||||
opt->ps1_exe.do_8mb = false;
|
opt->ps1_exe.do_8mib = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\0':
|
case '\0':
|
||||||
|
@ -1045,6 +1045,7 @@ static const struct mfx_option longopts[] =
|
||||||
{"boot-only", 0x10, 0, 670},
|
{"boot-only", 0x10, 0, 670},
|
||||||
{"no-align", 0x10, 0, 671},
|
{"no-align", 0x10, 0, 671},
|
||||||
{"8-bit", 0x10, 0, 672},
|
{"8-bit", 0x10, 0, 672},
|
||||||
|
{"8mib-ram", 0x10, 0, 673},
|
||||||
{"8mb-ram", 0x10, 0, 673},
|
{"8mb-ram", 0x10, 0, 673},
|
||||||
|
|
||||||
// mp (meta) options
|
// mp (meta) options
|
||||||
|
|
|
@ -134,7 +134,7 @@ struct options_t {
|
||||||
bool boot_only;
|
bool boot_only;
|
||||||
bool no_align;
|
bool no_align;
|
||||||
bool do_8bit;
|
bool do_8bit;
|
||||||
bool do_8mb;
|
bool do_8mib;
|
||||||
} ps1_exe;
|
} ps1_exe;
|
||||||
struct {
|
struct {
|
||||||
unsigned blocksize;
|
unsigned blocksize;
|
||||||
|
|
|
@ -714,7 +714,7 @@ void PackArmPe::pack(OutputFile *fo)
|
||||||
|
|
||||||
// limit stack size needed for runtime decompression
|
// limit stack size needed for runtime decompression
|
||||||
upx_compress_config_t cconf; cconf.reset();
|
upx_compress_config_t cconf; cconf.reset();
|
||||||
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28KB stack
|
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
|
||||||
compressWithFilters(&ft, 2048, &cconf, filter_strategy,
|
compressWithFilters(&ft, 2048, &cconf, filter_strategy,
|
||||||
ih.codebase, rvamin, 0, NULL, 0);
|
ih.codebase, rvamin, 0, NULL, 0);
|
||||||
// info: see buildLoader()
|
// info: see buildLoader()
|
||||||
|
@ -898,7 +898,7 @@ void PackArmPe::pack(OutputFile *fo)
|
||||||
// set_le32(ibuf + ic,get_le32("UPX "));
|
// set_le32(ibuf + ic,get_le32("UPX "));
|
||||||
ibuf.clear(0, oh.filealign);
|
ibuf.clear(0, oh.filealign);
|
||||||
|
|
||||||
info("Image size change: %u -> %u kBytes",
|
info("Image size change: %u -> %u KiB",
|
||||||
ih.imagesize / 1024, oh.imagesize / 1024);
|
ih.imagesize / 1024, oh.imagesize / 1024);
|
||||||
|
|
||||||
infoHeader("[Writing compressed file]");
|
infoHeader("[Writing compressed file]");
|
||||||
|
|
|
@ -303,7 +303,7 @@ void PackDjgpp2::pack(OutputFile *fo)
|
||||||
// compress
|
// compress
|
||||||
upx_compress_config_t cconf; cconf.reset();
|
upx_compress_config_t cconf; cconf.reset();
|
||||||
// limit stack size needed for runtime decompression
|
// limit stack size needed for runtime decompression
|
||||||
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28KB stack
|
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
|
||||||
compressWithFilters(&ft, 512, &cconf);
|
compressWithFilters(&ft, 512, &cconf);
|
||||||
|
|
||||||
// patch coff header #2
|
// patch coff header #2
|
||||||
|
|
|
@ -506,7 +506,7 @@ void PackExe::pack(OutputFile *fo)
|
||||||
// compress (max_match = 8192)
|
// compress (max_match = 8192)
|
||||||
upx_compress_config_t cconf; cconf.reset();
|
upx_compress_config_t cconf; cconf.reset();
|
||||||
cconf.conf_ucl.max_match = MAXMATCH;
|
cconf.conf_ucl.max_match = MAXMATCH;
|
||||||
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28KB stack
|
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
|
||||||
compressWithFilters(&ft, 32, &cconf);
|
compressWithFilters(&ft, 32, &cconf);
|
||||||
|
|
||||||
if (M_IS_NRV2B(ph.method) || M_IS_NRV2D(ph.method) || M_IS_NRV2E(ph.method))
|
if (M_IS_NRV2B(ph.method) || M_IS_NRV2D(ph.method) || M_IS_NRV2E(ph.method))
|
||||||
|
|
|
@ -95,7 +95,7 @@ PackPs1::PackPs1(InputFile *f) :
|
||||||
COMPILE_TIME_ASSERT(SZ_IH_BKUP == 40)
|
COMPILE_TIME_ASSERT(SZ_IH_BKUP == 40)
|
||||||
|
|
||||||
fdata_size = file_size - PS_HDR_SIZE;
|
fdata_size = file_size - PS_HDR_SIZE;
|
||||||
ram_size = !opt->ps1_exe.do_8mb ? 0x200000 : 0x800000;
|
ram_size = !opt->ps1_exe.do_8mib ? 0x200000 : 0x800000;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int *PackPs1::getCompressionMethods(int method, int level) const
|
const int *PackPs1::getCompressionMethods(int method, int level) const
|
||||||
|
@ -500,7 +500,7 @@ void PackPs1::pack(OutputFile *fo)
|
||||||
// compress (max_match = 65535)
|
// compress (max_match = 65535)
|
||||||
upx_compress_config_t cconf; cconf.reset();
|
upx_compress_config_t cconf; cconf.reset();
|
||||||
cconf.conf_ucl.max_match = 65535;
|
cconf.conf_ucl.max_match = 65535;
|
||||||
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28KB stack
|
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
|
||||||
compressWithFilters(&ft, sa_cnt, &cconf);
|
compressWithFilters(&ft, sa_cnt, &cconf);
|
||||||
|
|
||||||
if (overlap)
|
if (overlap)
|
||||||
|
|
|
@ -242,7 +242,7 @@ void PackTmt::pack(OutputFile *fo)
|
||||||
// compress
|
// compress
|
||||||
upx_compress_config_t cconf; cconf.reset();
|
upx_compress_config_t cconf; cconf.reset();
|
||||||
// limit stack size needed for runtime decompression
|
// limit stack size needed for runtime decompression
|
||||||
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28KB stack
|
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
|
||||||
compressWithFilters(&ft, 512, &cconf);
|
compressWithFilters(&ft, 512, &cconf);
|
||||||
|
|
||||||
const unsigned lsize = getLoaderSize();
|
const unsigned lsize = getLoaderSize();
|
||||||
|
|
|
@ -507,7 +507,7 @@ void PackTos::pack(OutputFile *fo)
|
||||||
// compress (max_match = 65535)
|
// compress (max_match = 65535)
|
||||||
upx_compress_config_t cconf; cconf.reset();
|
upx_compress_config_t cconf; cconf.reset();
|
||||||
cconf.conf_ucl.max_match = 65535;
|
cconf.conf_ucl.max_match = 65535;
|
||||||
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28KB stack
|
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
|
||||||
compressWithFilters(&ft, 512, &cconf);
|
compressWithFilters(&ft, 512, &cconf);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -269,7 +269,7 @@ void PackVmlinuxBase<T>::pack(OutputFile *fo)
|
||||||
|
|
||||||
upx_compress_config_t cconf; cconf.reset();
|
upx_compress_config_t cconf; cconf.reset();
|
||||||
// limit stack size needed for runtime decompression
|
// limit stack size needed for runtime decompression
|
||||||
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28KB stack
|
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
|
||||||
|
|
||||||
unsigned ppc32_extra = 0;
|
unsigned ppc32_extra = 0;
|
||||||
if (Ehdr::EM_PPC==my_e_machine) {
|
if (Ehdr::EM_PPC==my_e_machine) {
|
||||||
|
@ -837,7 +837,7 @@ const int *PackVmlinuxPPC32::getFilters() const
|
||||||
|
|
||||||
bool PackVmlinuxI386::is_valid_e_entry(Addr e_entry)
|
bool PackVmlinuxI386::is_valid_e_entry(Addr e_entry)
|
||||||
{
|
{
|
||||||
return 0==(0x000fffff & e_entry); // entry on whole 1MB
|
return 0==(0x000fffff & e_entry); // entry on whole 1 MiB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1390,8 +1390,8 @@ bool PackVmlinuxAMD64::has_valid_vmlinux_head()
|
||||||
// pushl $0
|
// pushl $0
|
||||||
// pushl $ MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED
|
// pushl $ MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED
|
||||||
// pushl $ PROT_EXEC | PROT_WRITE | PROT_READ
|
// pushl $ PROT_EXEC | PROT_WRITE | PROT_READ
|
||||||
// pushl $0x600000 # 6MB length
|
// pushl $0x600000 # 6 MiB length
|
||||||
// pushl $0x100000 # 1MB address
|
// pushl $0x100000 # 1 MiB address
|
||||||
// call mmap
|
// call mmap
|
||||||
// leal -0x9000(%esp),%esi # expect "lea 0x9000(%esi),%esp" later
|
// leal -0x9000(%esp),%esi # expect "lea 0x9000(%esi),%esp" later
|
||||||
///* Fall into .text of upx-compressed vmlinux. */
|
///* Fall into .text of upx-compressed vmlinux. */
|
||||||
|
@ -1440,7 +1440,7 @@ const int *PackVmlinuxAMD64::getFilters() const
|
||||||
|
|
||||||
bool PackVmlinuxAMD64::is_valid_e_entry(Addr e_entry)
|
bool PackVmlinuxAMD64::is_valid_e_entry(Addr e_entry)
|
||||||
{
|
{
|
||||||
return 0x200000<=e_entry; // 2MB
|
return 0x200000<=e_entry; // 2 MiB
|
||||||
}
|
}
|
||||||
|
|
||||||
Linker* PackVmlinuxAMD64::newLinker() const
|
Linker* PackVmlinuxAMD64::newLinker() const
|
||||||
|
|
|
@ -202,14 +202,14 @@ int PackVmlinuzI386::decompressKernel()
|
||||||
}
|
}
|
||||||
// Find "ljmp $__BOOT_CS,$__PHYSICAL_START" if any.
|
// Find "ljmp $__BOOT_CS,$__PHYSICAL_START" if any.
|
||||||
if (0==memcmp("\xEA\x00\x00", p, 3) && 0==(0xf & p[3]) && 0==p[4]) {
|
if (0==memcmp("\xEA\x00\x00", p, 3) && 0==(0xf & p[3]) && 0==p[4]) {
|
||||||
/* whole megabyte < 16MB */
|
/* whole megabyte < 16 MiB */
|
||||||
physical_start = get_te32(1+ p);
|
physical_start = get_te32(1+ p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (base && relocated) {
|
if (base && relocated) {
|
||||||
p = base + relocated;
|
p = base + relocated;
|
||||||
for (int j= 0; j < 0x200; ++j, ++p) {
|
for (j = 0; j < 0x200; ++j, ++p) {
|
||||||
if (0==memcmp("\x01\x9c\x0b", p, 3) // addl %ebx,d32(%ebx,%ecx)
|
if (0==memcmp("\x01\x9c\x0b", p, 3) // addl %ebx,d32(%ebx,%ecx)
|
||||||
) {
|
) {
|
||||||
page_offset = 0u - get_te32(3+ p);
|
page_offset = 0u - get_te32(3+ p);
|
||||||
|
@ -401,7 +401,7 @@ void PackVmlinuzI386::pack(OutputFile *fo)
|
||||||
// compress
|
// compress
|
||||||
upx_compress_config_t cconf; cconf.reset();
|
upx_compress_config_t cconf; cconf.reset();
|
||||||
// limit stack size needed for runtime decompression
|
// limit stack size needed for runtime decompression
|
||||||
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28KB stack
|
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
|
||||||
compressWithFilters(&ft, 512, &cconf);
|
compressWithFilters(&ft, 512, &cconf);
|
||||||
|
|
||||||
const unsigned lsize = getLoaderSize();
|
const unsigned lsize = getLoaderSize();
|
||||||
|
@ -516,7 +516,7 @@ void PackBvmlinuzI386::pack(OutputFile *fo)
|
||||||
|
|
||||||
upx_compress_config_t cconf; cconf.reset();
|
upx_compress_config_t cconf; cconf.reset();
|
||||||
// limit stack size needed for runtime decompression
|
// limit stack size needed for runtime decompression
|
||||||
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28KB stack
|
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
|
||||||
|
|
||||||
// FIXME: new stub allows most of low memory as stack for Bvmlinuz ?
|
// FIXME: new stub allows most of low memory as stack for Bvmlinuz ?
|
||||||
//cconf.conf_lzma.max_num_probs = (0x99000 - 0x10250)>>1; // ushort: 560560 stack
|
//cconf.conf_lzma.max_num_probs = (0x99000 - 0x10250)>>1; // ushort: 560560 stack
|
||||||
|
@ -624,7 +624,7 @@ int PackVmlinuzI386::canUnpack()
|
||||||
void PackVmlinuzI386::unpack(OutputFile *fo)
|
void PackVmlinuzI386::unpack(OutputFile *fo)
|
||||||
{
|
{
|
||||||
// no uncompression support for this format, so that
|
// no uncompression support for this format, so that
|
||||||
// it is possible to remove the original deflate code (>10KB)
|
// it is possible to remove the original deflate code (>10 KiB)
|
||||||
|
|
||||||
// FIXME: but we could write the uncompressed "vmlinux" image
|
// FIXME: but we could write the uncompressed "vmlinux" image
|
||||||
|
|
||||||
|
|
|
@ -1037,7 +1037,7 @@ void PackW32Pe::pack(OutputFile *fo)
|
||||||
// set_le32(ibuf + ic,get_le32("UPX "));
|
// set_le32(ibuf + ic,get_le32("UPX "));
|
||||||
ibuf.clear(0, oh.filealign);
|
ibuf.clear(0, oh.filealign);
|
||||||
|
|
||||||
info("Image size change: %u -> %u kBytes",
|
info("Image size change: %u -> %u KiB",
|
||||||
ih.imagesize / 1024, oh.imagesize / 1024);
|
ih.imagesize / 1024, oh.imagesize / 1024);
|
||||||
|
|
||||||
infoHeader("[Writing compressed file]");
|
infoHeader("[Writing compressed file]");
|
||||||
|
|
|
@ -433,7 +433,7 @@ void PackWcle::encodeImage(Filter *ft)
|
||||||
// prepare filter [already done]
|
// prepare filter [already done]
|
||||||
// compress
|
// compress
|
||||||
upx_compress_config_t cconf; cconf.reset();
|
upx_compress_config_t cconf; cconf.reset();
|
||||||
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28KB stack
|
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
|
||||||
compressWithFilters(ibuf, isize,
|
compressWithFilters(ibuf, isize,
|
||||||
oimage + RESERVED,
|
oimage + RESERVED,
|
||||||
ibuf + ft->addvalue, ft->buf_len,
|
ibuf + ft->addvalue, ft->buf_len,
|
||||||
|
|
|
@ -225,7 +225,7 @@ unfold:
|
||||||
|
|
||||||
/* Get some pages. If small, then get 1 page located just after the end
|
/* Get some pages. If small, then get 1 page located just after the end
|
||||||
of the first PT_LOAD of the compressed program. This will still be below
|
of the first PT_LOAD of the compressed program. This will still be below
|
||||||
all of the uncompressed program. If large (>=3MB uncompressed), then enough
|
all of the uncompressed program. If large (>=3 MiB uncompressed), then enough
|
||||||
to duplicate the entire compressed PT_LOAD, plus 1 page, located just after
|
to duplicate the entire compressed PT_LOAD, plus 1 page, located just after
|
||||||
the brk() of the _un_compressed program. The address and length are pre-
|
the brk() of the _un_compressed program. The address and length are pre-
|
||||||
calculated by PackLinuxElf64amd::defineSymbols().
|
calculated by PackLinuxElf64amd::defineSymbols().
|
||||||
|
|
|
@ -56,7 +56,7 @@ decompress_kernel: # (char *out, char *tmp, char *tmp_end, int arch_id)
|
||||||
// Value stored from r1 to memory will be overwritten by outsize.
|
// Value stored from r1 to memory will be overwritten by outsize.
|
||||||
stmdb r1!,{r0,r1,r2,r3,sp} // &indata, space, &outdata, arch_id, sp_in
|
stmdb r1!,{r0,r1,r2,r3,sp} // &indata, space, &outdata, arch_id, sp_in
|
||||||
loadcon8 3,METHOD // mov r3,#METHOD
|
loadcon8 3,METHOD // mov r3,#METHOD
|
||||||
mov sp,r1 // switch stacks to tmp_end area (64KB)
|
mov sp,r1 // switch stacks to tmp_end area (64 KiB)
|
||||||
ldr r1,1f // insize
|
ldr r1,1f // insize
|
||||||
str r3,[sp,#-4]! // method
|
str r3,[sp,#-4]! // method
|
||||||
ldr r3,2f // outsize
|
ldr r3,2f // outsize
|
||||||
|
|
|
@ -99,7 +99,7 @@ section EXEENTRY
|
||||||
push ds
|
push ds
|
||||||
.byte 0xa9
|
.byte 0xa9
|
||||||
do_copy:
|
do_copy:
|
||||||
mov ch, 0x80 /* 64 kbyte */
|
mov ch, 0x80 /* 64 KiB */
|
||||||
mov ax, cs
|
mov ax, cs
|
||||||
addaxds:
|
addaxds:
|
||||||
add ax, offset source_segment /* MSB is referenced by the "sub" below */
|
add ax, offset source_segment /* MSB is referenced by the "sub" below */
|
||||||
|
|
|
@ -38,7 +38,7 @@ PHDRS
|
||||||
}
|
}
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
/* 0x00c01000: 12MB+4KB for Fedora Core 5 vDSO at 0xc00000 */
|
/* 0x00c01000: 12 MiB + 4 KiB for Fedora Core 5 vDSO at 0xc00000 */
|
||||||
. = 0x00c01000 + SIZEOF_HEADERS + 12; /* 12==sizeof(l_info) */
|
. = 0x00c01000 + SIZEOF_HEADERS + 12; /* 12==sizeof(l_info) */
|
||||||
.text : {
|
.text : {
|
||||||
*(.text)
|
*(.text)
|
||||||
|
|
|
@ -371,7 +371,7 @@ umax(unsigned a, unsigned b)
|
||||||
// OpenBSD 3.9 wants all .text from all modules together, then (above that)
|
// OpenBSD 3.9 wants all .text from all modules together, then (above that)
|
||||||
// all .data from all modules together, in order to maximize the effectiveness
|
// all .data from all modules together, in order to maximize the effectiveness
|
||||||
// of lowering the segment limit on %cs as an implementation of "no-execute
|
// of lowering the segment limit on %cs as an implementation of "no-execute
|
||||||
// .data". Thus OpenBSD 3.9 puts a gap of 0x20000000 (512MB) between the
|
// .data". Thus OpenBSD 3.9 puts a gap of 0x20000000 (512 MiB) between the
|
||||||
// origins of .text and .data in each module. So, mapping ET_DYN must "level"
|
// origins of .text and .data in each module. So, mapping ET_DYN must "level"
|
||||||
// the excursion in .text and .data of anything which preceeded it,
|
// the excursion in .text and .data of anything which preceeded it,
|
||||||
// then add the new PT_LOAD.
|
// then add the new PT_LOAD.
|
||||||
|
|
|
@ -281,7 +281,7 @@ unfold: // s7= &decompress; s6= &b_info(fold); s5= sz_pack2
|
||||||
|
|
||||||
/* Get some pages. If small, then get 1 page located just after the end
|
/* Get some pages. If small, then get 1 page located just after the end
|
||||||
of the first PT_LOAD of the compressed program. This will still be below
|
of the first PT_LOAD of the compressed program. This will still be below
|
||||||
all of the uncompressed program. If large (>=3MB uncompressed), then enough
|
all of the uncompressed program. If large (>=3 MiB uncompressed), then enough
|
||||||
to duplicate the entire compressed PT_LOAD, plus 1 page, located just after
|
to duplicate the entire compressed PT_LOAD, plus 1 page, located just after
|
||||||
the brk() of the _un_compressed program. The address and length are pre-
|
the brk() of the _un_compressed program. The address and length are pre-
|
||||||
calculated by PackLinuxElf64amd::defineSymbols().
|
calculated by PackLinuxElf64amd::defineSymbols().
|
||||||
|
|
|
@ -71,7 +71,7 @@ L90:
|
||||||
lwz a1,-8(r31) # offset to {l_info; p_info; b_info}
|
lwz a1,-8(r31) # offset to {l_info; p_info; b_info}
|
||||||
subf a0,a1,r31 # &l_info
|
subf a0,a1,r31 # &l_info
|
||||||
lwz a3,sz_unc+sz_p_info+sz_l_info(a0) # sz_mach_headers
|
lwz a3,sz_unc+sz_p_info+sz_l_info(a0) # sz_mach_headers
|
||||||
cmpli 0,a3,2048; bgt L100; li a3,2048 # at least 2KB for /usr/lib/dyld
|
cmpli 0,a3,2048; bgt L100; li a3,2048 # at least 2 KiB for /usr/lib/dyld
|
||||||
L100:
|
L100:
|
||||||
movr r29,sp # remember for restoring later
|
movr r29,sp # remember for restoring later
|
||||||
subf sp,a3,sp # alloca
|
subf sp,a3,sp # alloca
|
||||||
|
|
Loading…
Reference in New Issue
Block a user