Commit Graph

3610 Commits

Author SHA1 Message Date
John Reiser 252143d0bb WIP: smallest executable on Apple M1 (aarch64 or arm64)
Requirements for success after snipping a loader_command:
    "codesign -s - my_app" must succeed.
    "lldb my_app; process launch -s; continue" must succeed.

Optional loader_commands (macho-snip can remove these successfully):
    LC_UUID, LC_BUILD_VERSION, LC_SOURCE_VERISON,
    LC_DATA_IN_CODE (when 0==datasize)

Apple "strip -N" clears out LC_SYMTAB and LC_DYSYMTAB, but leaves
LC_DYLD_INFO_ONLY.export_size.  Perhaps this could be zero if
constructed that way; snipping seems tedious because codesign
requires that __LINKEDIT must have no gaps.

LC_FUNCTION_STARTS seems to be required by codesign.
codesign wants offsets that point into __LINKEDIT to be in order:
    LC_DYLD_INFO_ONLY, LC_FUNCTION_STARTS, LC_DATA_IN_CODE, LC_SYMTAB

MacOS seesm to require LC_LOAD_DYLINKER (else "zsh: Kiled"),
which seems to require LD_LOAD_DYLIB (else SIGABRT).

https://github.com/upx/upx/issues/446
----
        modified:   macho-snip.c
	modified:   udf.s
2022-03-01 15:06:58 -08:00
John Reiser 480ab51650 Evade poratbility constraints of UPX build system
when building a tool to investigate "minimal" Mach-O executable
on Apple MacOS Big Sur using Apple M1 hardware (aarch64).
https://github.com/upx/upx/issues/567
	modified:   stub/tools/macho-snip/Makefile
	modified:   stub/tools/macho-snip/macho-snip.c
	modified:   stub/tools/macho-snip/udf.s
2022-03-01 11:12:19 -08:00
John Reiser 972c76eb42 Tool for snipping loader_commands in Mach-O on Apple M1 (aarch64) on BigSur.
experimental!
https://github.com/upx/upx/issues/424
	new file:   macho-snip/Makefile
	new file:   macho-snip/macho-snip.c
	new file:   macho-snip/udf.s
2022-02-28 19:53:25 -08:00
John Reiser e5aeea9ed2 Check more carefully in invert_pt_dynamic()
https://github.com/upx/upx/issues/566
	modified:   p_lx_elf.cpp
2022-02-28 07:55:49 -08:00
John Reiser f204670008 Mach unpack checks for bad load_command in compressed input
https://github.com/upx/upx/issues/564
	modified:   p_mach.cpp
2022-02-25 10:17:04 -08:00
John Reiser 651155c64d Check Mach_header.ncmds at unpack
https://github.com/upx/upx/issues/563
	modified:   p_mach.cpp
2022-02-25 09:32:29 -08:00
John Reiser 660aee6d22 More checking for unpack of tampered Elf_Phdr
https://github.com/upx/upx/issues/562
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
2022-02-25 09:23:55 -08:00
John Reiser a646231630 aligned_sotls, per Laszlo
https://github.com/upx/upx/issues/556
	modified:   pefile.cpp
2022-02-07 08:39:13 -08:00
John Reiser 1050de5171 Native alignment for the "load config" table
https://github.com/upx/upx/issues/556
	modified:   pefile.cpp
2022-01-15 06:45:47 -08:00
John Reiser b7a5b9437a Fix checking of sh_name versus shstrsec->sh_size
https://github.com/upx/upx/issues/509
	modified:   p_vmlinx.cpp
2022-01-01 14:20:18 -08:00
Kornel Pal 620955a724 PE: Fix has_oxrelocs (TLS always has oxrelocs) 2021-12-31 20:45:28 +01:00
John Reiser 2e64a277f8 Fix headway during optimizeReloc()
Later: "Assertion `(soxrelocs == 0) == !has_oxrelocs' failed."
https://github.com/upx/upx/issues/552
	modified:   packer.cpp
	modified:   packer.h
	modified:   pefile.cpp
2021-12-31 10:27:58 -08:00
John Reiser ea567a8b14 Check when optimizeRelocs()
https://github.com/upx/upx/issues/513
	modified:   packer.h
	modified:   packer.cpp
	modified:   pefile.cpp
	modified:   p_wcle.cpp
	modified:   p_tmt.cpp
2021-12-29 16:57:52 -08:00
John Reiser be23f93ee6 upx_uint8_t
https://github.com/upx/upx/issues/545
	modified:   p_mach.h
2021-12-27 08:49:05 -08:00
John Reiser fcdf0e92c1 Use upx_uint32_t, upx_uint64_t
Avoid complaints from x86_64-w64-mingw32-gcc (GCC) 9.3-win32 20200320
https://github.com/upx/upx/issues/545
	modified:   p_mach.h
2021-12-27 08:33:54 -08:00
John Reiser 2d6987252e is_bad_linker_command()
https://github.com/upx/upx/issues/545
	modified:   p_mach.cpp
2021-12-27 08:14:19 -08:00
John Reiser 4a9c46253e Validate input LC_ commands in order to defend against fuzzers
TODO: validate in ::unpack(), too
https://github.com/upx/upx/issues/545
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   p_mach_enum.h
2021-12-26 19:40:34 -08:00
John Reiser 5bcf9dd8af Do not complain for minimal DT_GNU_HASH as by Rust.
Also: .p_type is 32 bits only!

https://github.com/upx/upx/issues/525
	modified:   p_lx_elf.cpp
2021-12-25 12:39:31 -08:00
John Reiser 284adb203f Better checking of DT_HASH.nbuckets
https://github.com/upx/upx/issues/507
	modified:   p_lx_elf.cpp
2021-12-24 15:52:16 -08:00
John Reiser adafa841f7 Some PT_LOAD must have (p_flags & PF_X)
https://github.com/upx/upx/issues/511
	modified:   p_lx_elf.cpp
2021-12-24 15:32:19 -08:00
John Reiser fdc5d25d03 Require DT_STRSZ
https://github.com/upx/upx/issues/512
	modified:   p_lx_elf.cpp
2021-12-24 15:08:22 -08:00
John Reiser 294a7077de Announce support for EFI files (PE x86)
modified:   NEWS
2021-12-24 15:05:53 -08:00
Kornel Pal 990d0ec543 PE: Remove duplicate oxrelocs write 2021-12-22 05:07:54 +01:00
John Reiser bb90c4dff4 Sync PE stubs
modified:   ../.github/travis_testsuite_1-expected_sha256sums.sh
2021-12-24 07:34:06 -08:00
Kornel Pal 00e3d992e8 Sync stubs 2021-12-22 03:05:53 +01:00
Kornel Pal 937bfa4e49 PE: Add support for EFI images 2021-12-22 03:05:24 +01:00
Kornel Pal 1d9c211eed PE: Make imports in decompressor stub optional 2021-12-22 03:00:17 +01:00
Kornel Pal 76ddf6b8da PE: Add position independent decompressor stub for i386 2021-12-22 02:58:09 +01:00
Kornel Pal 7f1f29b0d8 PE: Remove empty non-compressed section 2021-12-22 02:57:10 +01:00
Kornel Pal 222471744f PE: Remove file alignment restriction 2021-12-22 02:56:09 +01:00
Kornel Pal cc100be26e PE: Fix stripped relocation handling 2021-12-22 02:55:33 +01:00
Kornel Pal 966b571b7c PE: Use no red zone on AMD64 2021-12-16 06:59:26 +01:00
Kornel Pal f3e710394a PE: Set header size on 64-bit too 2021-12-16 06:57:39 +01:00
Kornel Pal bfd1f1fbfa PE: Fix relocation parsing and validation 2021-12-16 06:56:01 +01:00
Efreak a09146b5e0 unreferenced variable breaks build 2021-12-02 14:00:40 -08:00
John Reiser bbf2b08f48 Update testsuite with new signatures for i386-linux.elf
https://github.com/upx/upx/issues/540
	modified:   ../.github/travis_testsuite_1-expected_sha256sums.sh
2021-12-03 08:53:08 -08:00
John Reiser e2dbc661f1 Sync stub
modified:   stub/i386-linux.elf-entry.h
2021-12-03 08:38:26 -08:00
John Reiser 7626e09f66 Fix jl ==> jb (unsigned compare)
modified:   stub/src/i386-linux.elf-entry.S
2021-12-03 08:27:23 -08:00
Kirill A. Korinsky 248a6980cf Revert `-std=c++14`
This commit reverts 648fa30f22 which was removed by d60c46371d which is fixed https://github.com/upx/upx/issues/440
2021-11-27 13:22:54 +01:00
John Reiser f956bfc797 Allow slack for non-GLIBC tool chains versus -Wzero-as-null-pointer-constant
https://github.com/upx/upx/pull/531
	modified:   conf.h
2021-11-27 06:58:38 -08:00
bitraid 6da79783ea PE: Handle empty imports 2021-05-15 21:41:31 +03:00
a1346054 22329e0ab2 trim excess whitespace 2021-08-22 11:23:41 +00:00
a1346054 a94b0329c9 update codestyle in travis scripts to conform to guidelines
* adds and fixes indentation in a few places
* removes redundant quotes
* adds quotes around some arguments to silence shellcheck warnings
* fixes spelling
2021-08-22 11:21:28 +00:00
a1346054 be8601f8cc use grep -E instead of egrep
egrep will go away at some point, and grep -E is standardized
2021-08-22 11:19:38 +00:00
John Reiser bd441e83ae WIP: de-compression of old-style shlib
modified:   p_lx_elf.cpp
2021-09-06 08:43:20 -07:00
John Reiser 02bd9cc403 IMAGE_SUBSYSTEM_EFI_APPLICATION
Beginning of support for compressing EFI files; lacks run-time decompressor.
https://github.com/upx/upx/issues/518
	modified:   p_armpe.cpp
	modified:   p_w32pe.cpp
	modified:   p_w64pep.cpp
	modified:   pefile.cpp
	modified:   pefile.h
2021-09-06 08:38:51 -07:00
John Reiser c9f6a3583c WIP 64-bit shlib
modified:   p_lx_elf.cpp
2021-08-07 06:45:01 -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 d5263a56ce WIP: handling shared library
modified:   p_lx_elf.cpp
	modified:   p_unix.cpp
	modified:   p_unix.h
2021-05-22 16:03:53 -07:00