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

3249 Commits

Author SHA1 Message Date
John Reiser
b413f3da26 ELF shared library: PT_NOTE can prevent packing
Android build environment post-processing is adding a PT_NOTE
("Android", 21, "r16-beta1") at the high end of PT_LOAD[0],
above the stub; the runtime linker looks there before de-compression.
https://github.com/upx/upx/issues/124
	modified:   p_lx_elf.cpp
2017-11-20 10:08:24 -08:00
John Reiser
6eafa552bb Mach-o defend against bad crafted input
https://github.com/upx/upx/issues/146
	modified:   p_mach.cpp
2017-11-15 13:38:54 -08:00
John Reiser
7a0514d9b4 PeFile more checks for Section table
modified:   pefile.cpp
2017-11-12 21:47:47 -08:00
John Reiser
7e7565299e PeFile check Section table
https://github.com/upx/upx/issues/132
	modified:   pefile.cpp
2017-11-12 21:02:52 -08:00
László Molnár
ed34a089c6 minor update for a memory derefencing check 2017-11-12 16:19:40 +01:00
John Reiser
d14a2c5282 PeFile fix the recently-added interval checking.
https://github.com/upx/upx/issues/143
	modified:   pefile.cpp
2017-11-09 21:58:25 -08:00
John Reiser
f014406b65 MemBuffer.subref(errfmt, skip, take) checks that a subinterval is inside
modified:   mem.cpp
	modified:   mem.h
2017-11-09 21:55:41 -08:00
John Reiser
58771ecca6 PeFile: better checking for import descriptors
modified:   pefile.cpp
2017-11-08 12:38:54 -08:00
John Reiser
5d9dcb634b PeFile: Defend against bad crafted import descriptors
https://github.com/upx/upx/issues/143
	modified:   pefile.cpp
	modified:   pefile.h
2017-11-08 11:07:46 -08:00
John Reiser
19c2c1edcf Android 8.0 (Oreo) wants 0!=.e_shstrndx in a shared library
https://github.com/upx/upx/issues/142
It should not matter what the .sh_name is; only the .sh_type matters.
	modified:   p_lx_elf.cpp
2017-11-07 11:12:23 -08:00
John Reiser
0430e7931e PowerPC64 stub: on syscall, real Linux trashes r13 and below
(except r1, r2, and input args!) So, r12 .e_entry for musl
must copy from a saved register.  [qemu-ppc64 doesn't trash registers!]
	modified:   ../.github/travis_testsuite_1.sh
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/powerpc64le-linux.elf-fold.S
	also .h  .fold.map
2017-10-27 20:07:32 -07:00
John Reiser
bb8e607442 PowerPC64 musl 1.1.16 wants r12= .e_entry
modified:   stub/src/powerpc64le-linux.elf-fold.S
	also .h  .fold.map
2017-10-27 13:19:03 -07:00
John Reiser
e61ada944d debug info for shared library on stderr under "-D"
modified:   p_lx_elf.cpp
2017-10-25 21:32:17 -07:00
John Reiser
46730315e3 stub arm64-linux.shlib-init.S saves 1 instr and checks for assembly errors
modified:   arm64-linux.shlib-init.S
	also .h .bin.dump
2017-10-24 12:50:29 -07:00
John Reiser
4869142034 arm64 stub for shared library uses AT_PAGESZ
modified:   stub/src/arm64-linux.shlib-init.S
	also .h .bin.dump
2017-10-23 18:55:28 -07:00
John Reiser
8e42e17bbf typo
modified:   stub/src/amd64-linux.elf-entry.S
2017-10-23 18:53:42 -07:00
John Reiser
38c8b84a26 Align hatch_off.
modified:   p_lx_elf.cpp
2017-10-20 17:23:55 -07:00
John Reiser
c652626a37 32-bit shared libs reduce Phdr[1].p_align to 4096, like 64-bit.
This saves space when PAGE_SIZE is larger than 4096: MIPS, etc.
	modified:   p_lx_elf.cpp
2017-10-20 16:35:27 -07:00
John Reiser
06f6e47ebf Fix stub for MIPS shared libraries
https://github.com/upx/upx/issues/135
	modified:   p_lx_elf.cpp
	modified:   stub/src/mipsel.r3000-linux.shlib-init.S
	also .h .bin.dump
2017-10-20 16:16:35 -07:00
John Reiser
403b180b1d Compress shared libraries for mips and mipsel in ELF on Linux
modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	new file:   stub/mips.r3000-linux.shlib-init.h
	new file:   stub/mipsel.r3000-linux.shlib-init.h
	new file:   stub/src/mips.r3000-linux.shlib-init.S
	new file:   stub/src/mipsel.r3000-linux.shlib-init.S
	new file:   stub/tmp/mips.r3000-linux.shlib-init.bin.dump
	new file:   stub/tmp/mipsel.r3000-linux.shlib-init.bin.dump
2017-10-19 13:47:36 -07:00
John Reiser
ee008acfbd amd64 implements --is_ptinterp
https://github.com/upx/upx/issues/121
	modified:   ../.github/travis_testsuite_1.sh
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/amd64-linux.elf-main.c
	also .h, .map, .bin.dump
2017-10-18 13:10:49 -07:00
John Reiser
d149092ac0 Reference to external documentation only.
modified:   stub/src/arch/mips/r3000/macros.ash
2017-10-17 14:11:06 -07:00
John Reiser
eafa136c69 Appease error C4146 unary minus operator applied to unsigned type, result still unsigned
Microsoft Optimizing Compiler 16.00.40219.01, 19.00.24215.1, 19.11.25507.1; others
	modified:   p_lx_elf.cpp
2017-10-17 08:44:08 -07:00
John Reiser
402c885987 Merge branch 'jreiser-elfstub' into devel
New stub strategy on Linux:  Linux adds too many other segments
to the address space: [vdso], [sigpage], ...; and qemu might
arrange them differently.  Thus the only reliable mappings
are the PT_LOAD of the compressed file itself; all other
address space is unknown!  First, the compressed file uses
.bss to occupy all unused pages up to the original brk(0).
Then at run time, the stub gets another mapping of /proc/self/exe,
and uncompresses the user program on top of the original pages.
[*BSD unchanged for now?]

	modified:   stub/src/powerpc64le-linux.elf-fold.S
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-darwin.macho-entry.S
	modified:   stub/src/powerpc64le-darwin.dylib-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-main.c
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   p_unix.cpp
	modified:   p_mach.cpp
	modified:   p_lx_sh.cpp
	modified:   p_lx_interp.cpp
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_lx_interp.h
	modified:   p_lx_sh.h
	modified:   p_mach.h
	modified:   p_unix.h
	modified:   stub/src/arch/mips/r3000/macros.ash
	modified:   stub/src/arch/powerpc/32/ppc_regs.h
	modified:   stub/src/arch/powerpc/64le/ppc_regs.h
	modified:   stub/src/include/linux.h
	modified:   stub/Makefile
	modified:   ../.github/travis_testsuite_1.sh
	also .h .map .bin.dump
2017-10-14 14:26:11 -07:00
John Reiser
5e7e0508b9 sync stubs for "make run-testsuite"
modified:   ../.github/travis_testsuite_1.sh
2017-10-14 14:19:24 -07:00
John Reiser
ff1d5fb794 stub for 64-bit little-endian PowerPC also uses TOC
modified:   stub/src/arch/powerpc/64le/ppc_regs.h
	modified:   stub/src/powerpc64le-linux.elf-fold.S
2017-10-14 13:54:43 -07:00
John Reiser
ad3f63b5c4 stubs *.elf-main.c: tighten input to first decompress of ELF headers
modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/i386-linux.elf-main.c
	also .h, .map
2017-10-14 06:21:44 -07:00
John Reiser
a3e51e6dee stub for PowerPC 64-bit big endian: accommodate musl bare .func as .e_entry
modified:   stub/src/powerpc64le-linux.elf-fold.S
2017-10-14 06:18:00 -07:00
John Reiser
c1b9c79f54 arm,armeb stubs need endian-neutral code to set mflg_subr
modified:   stub/src/arm.v4a-linux.elf-entry.S
	also .h, .bin.dump
2017-10-13 12:27:07 -07:00
John Reiser
e0bc040b0a mips stub uses new strategy
modified:   p_lx_elf.cpp
	modified:   stub/src/arch/mips/r3000/macros.ash
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	also .h, .bin.dump, .map
2017-10-12 21:04:10 -07:00
John Reiser
85eb4c7537 powerpc stub: used wrong register
modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/arch/powerpc/32/ppc_regs.h
2017-10-11 17:17:45 -07:00
John Reiser
1f929d47d0 x86_64 stub also needs make_hatch()
https://github.com/upx/upx/issues/133
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   ../.github/travis_testsuite_1.sh
	also .h and .map
2017-10-11 09:06:50 -07:00
John Reiser
608662d73b x86_64 stub also needs make_hatch()
https://github.com/upx/upx/issues/133
	modified:   stub/src/amd64-linux.elf-main.c
2017-10-11 08:45:21 -07:00
John Reiser
7841d23e77 arm64: folded stub uses 64-bit TRACEing under DEBUG
modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
2017-10-10 21:39:50 -07:00
John Reiser
b72dda4ada arm64 spills a few registers because syscall can trash x18
modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
2017-10-10 20:31:11 -07:00
John Reiser
c59c8a1ea2 readability; no functional change
modified:   stub/src/powerpc64le-linux.elf-entry.S
2017-10-10 20:30:41 -07:00
John Reiser
1522293be0 arm64: stub uses new strategy
modified:   p_lx_elf.cpp
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/arm64-linux.elf-main.c
	also .h, .map, .bin.dump
2017-10-10 14:51:03 -07:00
John Reiser
b37bc99330 PowerPC64: stub uses new strategy
Needed: expert on TOC for big-endian.  glibc, musl, gcc disagree
on layout (is the .func first?) and usage for .e_entry.
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/arch/powerpc/64le/ppc_regs.h
	modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc64le-darwin.dylib-entry.S
	modified:   stub/src/powerpc64le-darwin.macho-entry.S
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S
	modified:   stub/Makefile
	also .h, .bin.dump, .map
2017-10-07 13:43:12 -07:00
John Reiser
7f905724b1 amd64: stub uses new strategy
modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   p_lx_elf.cpp
	also .h, .bin.dump, .map
2017-10-06 11:15:34 -07:00
John Reiser
2bf5bb1625 arm: stub uses new strategy
modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   p_lx_elf.cpp
	plus .h, .bin.dump, .map
2017-10-05 17:07:30 -07:00
John Reiser
08d3376740 Elf i386 stub: get enough space when unfolded code requires another page
modified:   src/i386-linux.elf-entry.S
2017-10-03 11:48:27 -07:00
John Reiser
7bace76176 Protect against bad crafted input.
https://github.com/upx/upx/issues/129
	modified:   p_lx_elf.cpp
2017-10-03 09:55:34 -07:00
John Reiser
ef336dbcc6 Protect against bad crafted input.
https://github.com/upx/upx/issues/128
	modified:   p_lx_elf.cpp
2017-10-02 21:47:40 -07:00
John Reiser
ca7217e717 powerpc: stub uses new strategy
First mmap must reserve enough space to decompress folded stub.
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	also .h, .map, .dump
2017-10-02 20:03:47 -07:00
John Reiser
3931cb7871 off_t is signed and long; keep the long when discarding the signed.
https://github.com/upx/upx/issues/127
	modified:   p_vmlinx.cpp
2017-10-01 16:14:09 -07:00
John Reiser
9e8de4abe5 i386: new stub strategy to avoid problems with early mmap layout
The stub occupies the same region that execve() would create
for the original progam.  The stub copies everything to a new area,
erases the original region, replaces it with the de-compressed
program, and erases the copy of itself via the escape hatch.
The copy is inexpensive via mmap() of /proc/self/exe.

	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-main.c

	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_lx_interp.cpp
	modified:   p_lx_interp.h
	modified:   p_lx_sh.cpp
	modified:   p_lx_sh.h
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   p_unix.cpp
	modified:   p_unix.h
	modified:   p_vmlinx.cpp

	plus .h, .map, .dump
2017-10-01 15:56:34 -07:00
John Reiser
26be845563 mips stubs: implement ET_DYN (-pie).
modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	plus associated *.h, *.bin.dump, and ../.github/travis_testsuite_1.sh
2017-09-26 10:05:22 -07:00
John Reiser
2f11a629fa Fix flub: "git --amend" after "git push" is not a good idea.
https://github.com/upx/upx/issues/126# Please enter the commit message for your changes. Lines starting
	modified:   arm64-linux.shlib-init.S
2017-09-25 11:43:38 -07:00
John Reiser
a295437e11 Merge branch 'devel' of https://github.com/upx/upx into devel 2017-09-25 11:39:13 -07:00
John Reiser
04597fb804 Fix bug in unfilter for shlib on arm64.
https://github.com/upx/upx/issues/126
	modified:   stub/src/arm64-linux.shlib-init.S
	and associated *.h, *.bin.dump
2017-09-25 11:38:33 -07:00