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
This commit is contained in:
John Reiser
2017-10-01 15:56:34 -07:00
parent 26be845563
commit 9e8de4abe5
30 changed files with 2943 additions and 3118 deletions
+2 -1
View File
@@ -246,7 +246,7 @@ PackUnix::patchLoaderChecksum()
set_te32(&lp->l_checksum, upx_adler32(ptr, lsize));
}
void PackUnix::pack3(OutputFile *fo, Filter &ft)
off_t PackUnix::pack3(OutputFile *fo, Filter &ft)
{
if (0==linker) {
// If no filter, then linker is not constructed by side effect
@@ -259,6 +259,7 @@ void PackUnix::pack3(OutputFile *fo, Filter &ft)
updateLoader(fo);
patchLoaderChecksum();
fo->write(p, lsize);
return fo->getBytesWritten();
}
void PackUnix::pack4(OutputFile *fo, Filter &)