Skip to content

macho/arm64 incorrect executable header after compression #446

@fayep

Description

@fayep

What's the problem (or question)?

on a darwin/arm64 binary:
src/upx.out src/upx.out -o upx
objdump -m -x upx returns error: 'upx': truncated or malformed object (load command 4 cmdsize not a multiple of 8)
It doesn't seem to matter if code is signed or not.
src/upx.out -t upx reports a successful test

What should have happened?

Headers of properly formed binary should have been printed as they are when you run objdump -m -x src/upx.out. Ideally code is re-signed (codesign -s -)

Do you have an idea for a solution?

perhaps pad the compressed cmdsize to ensure it is a multiple of 8? (maybe just ensure that there is a Load command 4 section?)

How can we reproduce the issue?

  1. start with arm64 macho Darwin executable src/upx.out
  2. src/upx.out src/upx.out -o ./upx
  3. objdump -mx ./upx

Please tell us details about your environment.

  • UPX version used (upx --version): UPX git-680ed5+ (fixed ucl includes in Makefile)
  • Host Operating System and version: MacOS 11 Apple Silicon
  • Host CPU architecture: ARM64
  • Target Operating System and version: MacOS 11 Apple Silicon
  • Target CPU architecture: ARM64
index 07273ccb,7351fe65..00000000
--- a/src/Makefile
+++ b/src/Makefile
@@@ -54,8 -47,8 +54,8 @@@ endi
  
  # we need UCL and zlib - you can set envvar UPX_UCLDIR
  ifneq ($(wildcard $(UPX_UCLDIR)/include/ucl/ucl.h),)
 -INCLUDES += -I$(UPX_UCLDIR)/include
 -LIBS += $(addprefix -L,$(dir $(wildcard $(UPX_UCLDIR)/lib/libucl$(libext) $(UPX_UCLDIR)/src/.libs/libucl$(libext))))
 +  INCLUDES += -I$(UPX_UCLDIR)/include
-   LIBS += $(addprefix -L,$(dir $(wildcard $(UPX_UCLDIR)/libucl$(libext) $(UPX_UCLDIR)/src/.libs/libucl$(libext))))
++  LIBS += $(addprefix -L,$(dir $(wildcard $(UPX_UCLDIR)/lib/libucl$(libext) $(UPX_UCLDIR)/src/.libs/libucl$(libext))))
  endif
  LIBS += -lucl -lz
  # LZMA from https://github.com/upx/upx-lzma-sdk

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions