New option --catch-sigsegv on amd64, arm64, arm.v4a

Catch SIGSEGV during de-compression, and print state info
("auto debug") using /proc/self/maps and gdb.
This was motivated by suspicion of unreliable hardware
which triggered "Heisenbugs": a crash which cannot be reproduced.
If SIGSGV occurs without the "auto debug" info, then that
implies an error user code after de-compression, often when
user code accesses /proc/self/exe, which is not the un-compressed file.
	modified:   misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   src/help.cpp
	modified:   src/main.cpp
	modified:   src/options.h
	modified:   src/p_lx_elf.cpp
	modified:   src/stub/Makefile
	modified:   src/stub/src/amd64-linux.elf-entry.S
	modified:   src/stub/src/amd64-linux.elf-fold.S
	modified:   src/stub/src/arm.v4a-linux.elf-entry.S
	modified:   src/stub/src/arm.v4a-linux.elf-fold.S
	modified:   src/stub/src/arm64-linux.elf-entry.S
	modified:   src/stub/src/arm64-linux.elf-fold.S
           plus generated .h .dump .map
This commit is contained in:
John Reiser
2025-08-19 12:10:32 -07:00
parent 4530e5c264
commit e85e8bec5d
26 changed files with 6223 additions and 5639 deletions
+13 -2
View File
@@ -1681,7 +1681,11 @@ PackLinuxElf32::buildLinuxLoader(
|| this->e_machine==Elf32_Ehdr::EM_MIPS
) { // main program with ELF2 de-compressor
addLoader("ELFMAINX");
if (this->e_machine==Elf32_Ehdr::EM_ARM) { // hardware is more problematic
if (opt->o_unix.catch_sigsegv && hasLoaderSection("ELFSIGSEGV"))
addLoader("ELFSIGSEGV");
addLoader("ELFMAINX2");
}
// Only if $ARCH-linux.elf-entry.S calls upx_mmap_and_fd instead of memfd_create
if (this->e_machine != Elf32_Ehdr::EM_PPC
&& this->e_machine != Elf32_Ehdr::EM_MIPS)
@@ -1871,7 +1875,14 @@ PackLinuxElf64::buildLinuxLoader(
|| this->e_machine==Elf64_Ehdr::EM_AARCH64
|| this->e_machine==Elf64_Ehdr::EM_PPC64
) { // main program with ELF2 de-compressor
addLoader("ELFMAINX,ELFMAINZ,FOLDEXEC,IDENTSTR");
addLoader("ELFMAINX");
// NYI for PPC64 {
if (opt->o_unix.catch_sigsegv && hasLoaderSection("ELFSIGSEGV"))
addLoader("ELFSIGSEGV");
if (this->e_machine!=Elf64_Ehdr::EM_PPC64)
addLoader("ELFMAINX2");
// } end NYI for PPC64
addLoader("ELFMAINZ,FOLDEXEC,IDENTSTR");
if (this->e_machine==Elf64_Ehdr::EM_PPC64
&& ehdri.e_ident[Elf64_Ehdr::EI_DATA]==Elf64_Ehdr::ELFDATA2MSB) {
addLoader("ELFMAINZe");