Put upx stub loader at high end of ELF output file on linux,

and allow for block-by-block specification of filter and parameters.
	linker.cpp linker.h mem.cpp mem.h p_elf.h
	p_lx_elf.cpp p_lx_elf.h
	p_lx_exc.cpp p_lx_exc.h
	p_lx_sh.cpp  p_lx_sh.h
	p_unix.cpp p_unix.h
	packer.cpp packer.h
	stub/fold_elf86.asm stub/fold_exec86.asm stub/fold_sh86.asm
	stub/l_lx_elf.c  stub/l_lx_elf86.asm  stub/l_lx_elf86.lds
	stub/l_lx_exec.c stub/l_lx_exec86.asm stub/l_lx_exec86.lds
	stub/l_lx_sh.c   stub/l_lx_sh86.asm   stub/l_lx_sh86.lds
	stub/linux.hh

committer: jreiser <jreiser> 981084316 +0000
This commit is contained in:
John Reiser
2001-02-02 03:25:16 +00:00
parent 9005e50049
commit 40fddf1715
28 changed files with 797 additions and 614 deletions
+16 -6
View File
@@ -53,6 +53,7 @@ Linker::Linker(const void *pdata, int plen, int pinfo)
oloader = new char[plen];
olen = 0;
align_hack = 0;
align_offset = 0;
info = pinfo;
njumps = nsections = frozen = 0;
jumps = new jump[200];
@@ -100,6 +101,16 @@ Linker::~Linker()
}
void Linker::setLoaderAlignOffset(int offset)
{
align_offset = offset;
}
static int hex(char c)
{
return (c & 0xf) + (c > '9' ? 9 : 0);
}
int Linker::addSection(const char *sect)
{
int ic;
@@ -108,14 +119,13 @@ int Linker::addSection(const char *sect)
if (*sect == '+') // alignment
{
if (sect[1] == '0')
align_hack = olen;
align_hack = olen + align_offset;
else
{
ic = (sect[1] & 0xf) + (sect[1] > '9' ? 9 : 0);
ic = (ic + (sect[2] & 0xf) + (sect[2] > '9' ? 9 : 0)
- (olen - align_hack) % ic) % ic;
memset(oloader+olen,sect[3] == 'C' ? 0x90 : 0,ic);
olen += ic;
unsigned j = hex(sect[1]);
j = (hex(sect[2]) - ((olen + align_offset) - align_hack) ) % j;
memset(oloader+olen, (sect[3] == 'C' ? 0x90 : 0), j);
olen += j;
}
}
else