Commit Graph

176 Commits

Author SHA1 Message Date
Markus F.X.J. Oberhumer dd1d5a92d2 all: welcome 2023 2023-01-01 19:49:30 +01:00
John Reiser f9f28ff176 More work on "upx -d" de-compression
https://github.com/upx/upx/issues/629
https://github.com/upx/upx/issues/635
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_unix.cpp
2022-12-19 13:49:43 -08:00
John Reiser d89813e911 Implement de-compress of --android-shlib
64-bit (arm64, aarch64) only for now.  NYI: 32-bit (armv7).
(Also: implied catch-up with all changes by Markus in the meantime.)
https://github.com/upx/upx/issues/599

	modified:   src/p_lx_elf.cpp
	modified:   src/p_lx_elf.h
2022-12-11 13:46:44 -08:00
Markus F.X.J. Oberhumer 16de3e78a5 src: try to fix canUnpack() confusion - see packer.h 2022-11-10 06:00:53 +01:00
John Reiser d3ad6d25d8 PackLinuxElf64::asl_pack2_Shdrs() for better fit in logical flow
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2022-10-24 12:56:49 +02:00
John Reiser 5d9f71bb13 asl_pack1_Shdrs()
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2022-10-24 12:56:49 +02:00
John Reiser 82ed25bb44 Major fix 64-bit un_shlib_1() and unpack(), but not --android-shlib
Also canUnpack() is really a 'bool' which sets overlay_offset
when 'true'; confusing!
        https://github.com/upx/upx/issues/599 (partial)
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_unix.h
2022-10-24 12:56:49 +02:00
John Reiser ec33109b22 clang-10 requires the use of 'override'
Discovered during gitlab auto-build for https://github.com/upx/upx/issues/595
	modified:   Makefile
	modified:   p_armpe.h
	modified:   p_djgpp2.h
	modified:   p_lx_elf.h
	modified:   p_lx_exc.h
	modified:   p_lx_interp.h
	modified:   p_lx_sh.h
	modified:   p_mach.h
	modified:   p_ps1.h
	modified:   p_tmt.h
	modified:   p_unix.h
	modified:   p_vmlinx.h
	modified:   p_vmlinz.h
	modified:   p_w32pe.h
	modified:   p_w64pep.h
	modified:   pefile.h
2022-09-27 18:15:48 +02:00
John Reiser a13b4d10d9 After upx-3.96, the de-compressing stub for ELF moved
... so unpack() of newly-compressed ELF by upx-3.96 now says
"CantUnpackException: need a newer version of UPX"
        https://github.com/upx/upx/issues/595
	modified:   p_lx_elf.h
	modified:   packer.h
2022-09-27 18:09:20 +02:00
Markus F.X.J. Oberhumer d001a63bce Welcome 2022. 2022-09-04 04:24:39 +02:00
John Reiser 03436d2415 Bug in handling DT_GNU_HASH table.
Fix includes a more-general and stronger heuristic to find the end of
GNU_HASH table when there is no ElfXX_Shdr for it.  64-bit only for now.
(This is needed to help prevent SIGSEGV when processing tampered .exe.)

https://github.com/upx/upx/issues/577
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2022-05-30 14:24:21 -07:00
John Reiser 076aaf829a WIP: Elf64 shlib compress+decompress seems to work
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_unix.cpp
2021-07-05 13:47:19 -07:00
John Reiser 85f0c5a445 WIP: Elf64 shlib cleanup
modified:   file.cpp
	modified:   file.h
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2021-07-02 18:33:38 -07:00
John Reiser 181c752488 WIP: un_shlib_1
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2021-05-08 11:14:31 -07:00
John Reiser 0a69e7803b Fix errors detected by "make run-testsuite".
total_out does not matter when option -t writes no output file.
Subtle error in generateElfHdr() [noted by address sanitizer].
New member function is_LOAD32() to avoid confusion with (1+ LO_PROC).
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2021-03-06 15:31:56 -08:00
John Reiser 35555bfb8a WIP: PackLinuxElf64::unpack working for shared libraries (non-Android)
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_unix.cpp
2021-03-05 16:20:36 -08:00
John Reiser 2be03028f4 WIP: un_shlib_1
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2021-02-27 19:27:12 -08:00
John Reiser fb844a8ed1 total_in, total_out move to PackUnix
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_lx_interp.cpp
	modified:   p_mach.cpp
	modified:   p_unix.cpp
	modified:   p_unix.h
2021-02-22 16:13:40 -08:00
John Reiser 23f63e4196 WIP unpacking ELF shared library
modified:   Makefile
	modified:   lzma-sdk
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_mach.cpp
	modified:   p_unix.cpp
	modified:   p_unix.h
	modified:   packer.cpp
	modified:   packer.h
	modified:   stub/arm64-linux.elf-fold.h
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/tmp/arm64-linux.elf-fold.map
2021-01-15 14:11:09 -08:00
Markus F.X.J. Oberhumer 9131d5216f Welcome 2021. 2021-01-01 20:39:22 +01:00
John Reiser 7841e15583 Prefer MemBuffer instead of New()+delete
https://github.com/upx/upx/issues/428
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2020-12-05 10:31:55 -08:00
John Reiser 4e2fdb464a Defend against bad PT_DYNAMIC
https://github.com/upx/upx/issues/391
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2020-07-23 05:09:52 -07:00
Markus F.X.J. Oberhumer 92f072cf70 Silence some compiler warnings. 2020-01-08 04:49:27 +01:00
Markus F.X.J. Oberhumer d1174385ef Welcome 2020. 2020-01-08 04:13:28 +01:00
John Reiser 49766388bc Fix compression and de-compression of Android shared libraries
Handle relocation (and DT_INIT_ARRAY[0]==NULL) when !DT_INIT.
Warn about missing --android-shlib if (ET_DYN && !DF_1_PIE && Arm*).
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
https://github.com/upx/upx/issues/265
https://github.com/upx/upx/issues/262
https://github.com/upx/upx/issues/259
https://github.com/upx/upx/issues/243
https://github.com/upx/upx/issues/229
https://github.com/upx/upx/issues/220
2019-04-14 19:59:08 -07:00
Markus F.X.J. Oberhumer 3667fa4e44 Welcome 2019. 2019-02-15 11:04:09 +01:00
John Reiser d60fef753f check_pt_load(); u32_t, u64_t; (off_t) is not unsigned!
https://github.com/upx/upx/issues/247
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2019-02-01 19:31:57 -08:00
John Reiser 0509edf08d ElfXX_Sym.st_name is always 32 bits
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-12-16 11:32:58 -08:00
John Reiser 780a4347b8 Check DT_HASH and DT_GNU_HASH.
https://github.com/upx/upx/issues/235  POC2,POC4
Also cleanup checking of symbol number and .st_name
in POC1,POC3,POC5,POC7,POC9,POC11
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-12-15 19:16:14 -08:00
John Reiser 606ad08dd1 Check symbol number and .st_name
https://github.com/upx/upx/issues/235  POC1,POC3,POC7,POC9
	modified:   p_elf_enum.h
	modified:   p_lx_elf.h
	modified:   p_lx_elf.cpp
2018-12-14 21:32:49 -08:00
John Reiser 0051dfc84f --android-shlib: Relocate ABS _edata etc.
https://github.com/upx/upx/issues/220
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-09-16 15:10:40 -07:00
John Reiser 8a793d5942 ELF shlib when no DT_INIT (especially --android-shlib)
https://github.com/upx/upx/issues/191
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-04-04 09:15:18 -07:00
John Reiser 5e9b6bd69d more ELF shlib when no DT_INIT (especially Android): hook DT_INIT_ARRAY[0]
https://github.com/upx/upx/issues/191  [partial, not finished]
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   stub/src/arm.v4a-linux.shlib-init.S
	modified:   stub/src/arm.v4t-linux.shlib-init.S
2018-03-26 16:30:52 -07:00
John Reiser 7a625a449a ELF shlib without DT_INIT: steal a DT_NULL from PT_DYNAMIC
https://github.com/upx/upx/issues/191  [partial, not finished]
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-03-24 09:41:58 -07:00
John Reiser 6722e8972e cleanup dead variables: is_big, all_pages
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-03-23 08:06:31 -07:00
John Reiser 95cedb6640 upgrade ::unpack for --android-shlib
modified:   p_elf_enum.h
    	modified:   p_lx_elf.cpp
    	modified:   p_lx_elf.h
    	modified:   stub/src/arm64-linux.shlib-init.S
    	modified:   stub/src/arm.v4t-linux.shlib-init.S
2018-02-02 14:50:56 -08:00
John Reiser be83788666 --android-shlib for 32-bit ARM
Includes better handling of asl_delta in execution stub.

    	modified:   p_lx_elf.cpp
    	modified:   p_lx_elf.h
    	modified:   stub/src/arm.v4t-linux.shlib-init.S
    	modified:   stub/src/arm64-linux.shlib-init.S
2018-01-27 22:00:16 -08:00
John Reiser 85f53b210d de-compression of arm64 --android-shlib
modified:   src/p_lx_elf.cpp
	modified:   src/p_lx_elf.h
	modified:   src/stub/src/arm64-linux.shlib-init.S
2018-01-24 15:39:46 -08:00
John Reiser 7d2913709c MemBuffer lowmem; for shlib, especially android
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-01-21 14:03:52 -08:00
John Reiser 3623199e8d Merge branch 'devel' into jreiser-android 2018-01-21 10:55:56 -08:00
John Reiser a34deee4f5 work in progress for --android-shlib
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-01-20 16:34:52 -08:00
John Reiser 08c63f06eb p_lx_elf.h: phdro for --android-shlib
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-01-19 22:01:56 -08:00
Markus F.X.J. Oberhumer 021c8db58a Welcome 2018. 2018-01-19 10:55:32 +01:00
John Reiser 86745721ee MSVC strikes again
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-01-15 16:27:00 -08:00
John Reiser c34fe09a79 Revamp --android-shlib
Android "Oreo" wants to deal with ElfXX_Shdr[].  So splice 4KiB into PT_LOAD[0]
with an "extra" copy of them.  This requires careful relocation processing.
It also costs a page at run time, and an average of a page in the file
(depending on fragmentation at the boundary between r-x and rw- .)

https://github.com/upx/upx/issues/124
https://github.com/upx/upx/issues/139
https://github.com/upx/upx/issues/142

	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   stub/src/arm.v4a-linux.shlib-init.S
	modified:   stub/src/arm.v4t-linux.shlib-init.S
	modified:   stub/src/arm64-linux.shlib-init.S

	modified:   stub/arm.v5a-linux.shlib-init.h
	modified:   stub/arm.v5t-linux.shlib-init.h
	modified:   stub/arm64-linux.shlib-init.h

	modified:   ../.github/travis_testsuite_1.sh
2018-01-15 16:08:34 -08:00
John Reiser 4854c03096 uint64_t ==> upx_uint64_t
MSVC error C2065: 'uint64_t' : undeclared identifier
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_mach.cpp
2018-01-06 09:33:04 -08:00
John Reiser 507e19945e more checking of PT_DYNAMIC
https://github.com/upx/upx/issues/166
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2017-12-30 22:31:50 -08:00
John Reiser e04bf9e4bc more checking of PT_DYNAMIC
https://github.com/upx/upx/issues/164
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2017-12-28 17:40:04 -08: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 e7f1e99a5e Merge branch 'jreiser' into devel
O_BINFO simplifies stubs on linux Elf;
PowerPC64 (big endian: Apple Macintosh G5) and PowerPC* cleanup;
-fpie simplification; shlib for arm64, amd64.

A big merge due to suspending activity on 'devel' branch
during stabilization for release of UPX-3.94.
There were intermediate merges with private branch 'jreiser',
and attempted rebase onto 'devel' did not go well.
Verfication of cases ({ET_EXEC, -fpie, shlib} x {$ARCH}) is in progress.

	modified:   ../.github/travis_testsuite_1.sh
	modified:   conf.h
	modified:   linker.cpp
	modified:   linker.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   p_mach_enum.h
	modified:   packmast.cpp
	modified:   stub/Makefile
	modified:   stub/scripts/xstrip.py

	modified:   stub/src/amd64-darwin.dylib-entry.S
	modified:   stub/src/amd64-darwin.macho-entry.S
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/arch/powerpc/32/bxx.S
	modified:   stub/src/arch/powerpc/32/lzma_d.S
	modified:   stub/src/arch/powerpc/32/nrv2b_d.S
	modified:   stub/src/arch/powerpc/32/nrv2d_d.S
	modified:   stub/src/arch/powerpc/32/nrv2e_d.S
	modified:   stub/src/arch/powerpc/32/ppc_regs.h
	new file:   stub/src/arch/powerpc/64/Makefile
	new file:   stub/src/arch/powerpc/64/Makefile.extra
	new file:   stub/src/arch/powerpc/64/bxx.S
	new file:   stub/src/arch/powerpc/64/lzma_d.S
	new file:   stub/src/arch/powerpc/64/lzma_d_cf.S
	new file:   stub/src/arch/powerpc/64/lzma_d_cs.S
	new file:   stub/src/arch/powerpc/64/macros.S
	new file:   stub/src/arch/powerpc/64/nrv2b_d.S
	new file:   stub/src/arch/powerpc/64/nrv2d_d.S
	new file:   stub/src/arch/powerpc/64/nrv2e_d.S
	new file:   stub/src/arch/powerpc/64/ppc_regs.h
	modified:   stub/src/arch/powerpc/64le/bxx.S
	copied:     stub/src/arch/powerpc/64le/lzma_d.S -> stub/src/arch/powerpc/64le/lzma_d-common.S
	modified:   stub/src/arch/powerpc/64le/lzma_d.S
	modified:   stub/src/arch/powerpc/64le/lzma_d_cs.S
	modified:   stub/src/arch/powerpc/64le/nrv2b_d.S
	modified:   stub/src/arch/powerpc/64le/nrv2d_d.S
	modified:   stub/src/arch/powerpc/64le/nrv2e_d.S
	modified:   stub/src/arch/powerpc/64le/ppc_regs.h
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/arm64-darwin.macho-entry.S
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/arm64-linux.shlib-init.S
	modified:   stub/src/i386-bsd.elf-entry.S
	modified:   stub/src/i386-darwin.macho-entry.S
	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	modified:   stub/src/powerpc-darwin.dylib-entry.S
	modified:   stub/src/powerpc-darwin.macho-entry.S
	modified:   stub/src/powerpc-darwin.macho-fold.S
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-main.c
	new file:   stub/src/powerpc64-darwin.dylib-entry.S
	new file:   stub/src/powerpc64-darwin.macho-entry.S
	new file:   stub/src/powerpc64-darwin.macho-fold.S
	new file:   stub/src/powerpc64-darwin.macho-main.c
	new file:   stub/src/powerpc64-linux.elf-entry.S
	new file:   stub/src/powerpc64-linux.elf-fold.S
	new file:   stub/src/powerpc64-linux.elf-fold.lds
	new file:   stub/src/powerpc64-linux.elf-main.c
	modified:   stub/src/powerpc64-savegpr0.S
	modified:   stub/src/powerpc64le-darwin.dylib-entry.S
	modified:   stub/src/powerpc64le-darwin.macho-entry.S
	modified:   stub/src/powerpc64le-darwin.macho-fold.S
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S
	modified:   stub/src/powerpc64le-linux.elf-main.c

	and most stub/*.h and stub/tmp/*.dump
2017-06-05 11:32:25 -07:00