ElfLinker started. Dos/com & dos/sys formats converted
This commit is contained in:
+15
-17
@@ -32,6 +32,7 @@
|
||||
#include "packer.h"
|
||||
#include "p_com.h"
|
||||
#include "p_sys.h"
|
||||
#include "linker.h"
|
||||
|
||||
static const
|
||||
#include "stub/i086-dos16.sys.h"
|
||||
@@ -67,7 +68,6 @@ void PackSys::patchLoader(OutputFile *fo,
|
||||
upx_byte *loader, int lsize,
|
||||
unsigned calls)
|
||||
{
|
||||
const int filter_id = ph.filter;
|
||||
const int e_len = getLoaderSectionStart("SYSCUTPO");
|
||||
const int d_len = lsize - e_len;
|
||||
assert(e_len > 0 && e_len < 256);
|
||||
@@ -76,25 +76,23 @@ void PackSys::patchLoader(OutputFile *fo,
|
||||
if (ph.u_len + d_len + ph.overlap_overhead > 0xfffe)
|
||||
throwNotCompressible();
|
||||
|
||||
memcpy(loader,ibuf,6); // copy from orig. header
|
||||
memcpy(loader+8,ibuf+8,2); // opendos wants this word too
|
||||
// use some fields of the original file
|
||||
linker->defineSymbol("next", get_le32(ibuf));
|
||||
linker->defineSymbol("attribute", get_le16(ibuf + 4));
|
||||
linker->defineSymbol("interrupt", get_le16(ibuf + 8));
|
||||
|
||||
unsigned copy_to = ph.u_len + d_len + ph.overlap_overhead;
|
||||
|
||||
patch_le16(loader,lsize,"JO",get_le16(ibuf+6)-copy_to-1);
|
||||
if (filter_id)
|
||||
{
|
||||
assert(calls > 0);
|
||||
patch_le16(loader,lsize,"CT",calls);
|
||||
}
|
||||
linker->defineSymbol("sys_entry", get_le16(ibuf + 6) - copy_to - 1);
|
||||
linker->defineSymbol("calltrick_calls", calls);
|
||||
linker->defineSymbol("copy_source", ph.c_len + lsize -1);
|
||||
linker->defineSymbol("copy_destination", copy_to);
|
||||
linker->defineSymbol("decompressor", ph.u_len + ph.overlap_overhead + 2);
|
||||
|
||||
linker->relocate();
|
||||
loader = getLoader();
|
||||
|
||||
patchPackHeader(loader,e_len);
|
||||
|
||||
const unsigned jmp_pos = find_le16(loader,e_len,get_le16("JM"));
|
||||
patch_le16(loader,e_len,"JM",ph.u_len+ph.overlap_overhead+2-jmp_pos-2);
|
||||
loader[getLoaderSectionStart("SYSSUBSI") - 1] = (upx_byte) -e_len;
|
||||
patch_le16(loader,e_len,"DI",copy_to);
|
||||
patch_le16(loader,e_len,"SI",ph.c_len+e_len+d_len-1);
|
||||
|
||||
// write loader + compressed file
|
||||
fo->write(loader,e_len); // entry
|
||||
fo->write(obuf,ph.c_len);
|
||||
@@ -107,7 +105,7 @@ int PackSys::buildLoader(const Filter *ft)
|
||||
initLoader(nrv2b_loader,sizeof(nrv2b_loader));
|
||||
addLoader("SYSMAIN1",
|
||||
opt->cpu == opt->CPU_8086 ? "SYSI0861" : "SYSI2861",
|
||||
"SYSMAIN2,SYSSUBSI",
|
||||
"SYSMAIN2",
|
||||
ph.first_offset_found == 1 ? "SYSSBBBP" : "",
|
||||
ft->id ? "SYSCALLT" : "",
|
||||
"SYSMAIN3,UPX1HEAD,SYSCUTPO,NRV2B160,NRVDDONE,NRVDECO1",
|
||||
|
||||
Reference in New Issue
Block a user