From 90fc018295e555b7df53fef041db38495dbc7e7b Mon Sep 17 00:00:00 2001 From: John Reiser Date: Wed, 18 Jan 2017 09:30:04 -0800 Subject: [PATCH] Avoid sigsegv after "patchelf --set-rpath" https://github.com/upx/upx/issues/47 Enhancement not yet implemented: non-adjacent ElfXX_Ehdr and ElfXX_Phdr. modified: p_unix.cpp --- src/p_unix.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/p_unix.cpp b/src/p_unix.cpp index 456e29c3..695c79b7 100644 --- a/src/p_unix.cpp +++ b/src/p_unix.cpp @@ -4,6 +4,7 @@ Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2017 Laszlo Molnar + Copyright (C) 2000-2017 John F. Reiser All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -23,6 +24,9 @@ Markus F.X.J. Oberhumer Laszlo Molnar + + John F. Reiser + */ @@ -242,8 +246,14 @@ PackUnix::patchLoaderChecksum() set_te32(&lp->l_checksum, upx_adler32(ptr, lsize)); } -void PackUnix::pack3(OutputFile *fo, Filter &/*ft*/) +void PackUnix::pack3(OutputFile *fo, Filter &ft) { + if (0==linker) { + // If no filter, then linker is not constructed by side effect + // of packExtent calling compressWithFilters. + // This is typical after "/usr/bin/patchelf --set-rpath". + buildLoader(&ft); + } upx_byte *p = getLoader(); lsize = getLoaderSize(); updateLoader(fo);