vmlinu[xz] using nrv2e converted to ElfLinker

This commit is contained in:
László Molnár
2006-07-04 17:36:54 +02:00
parent db7086b5e6
commit f0d5a6ebac
10 changed files with 2411 additions and 1533 deletions
+31 -4
View File
@@ -36,6 +36,7 @@
#include "filter.h"
#include "packer.h"
#include "p_vmlinx.h"
#include "linker.h"
static const
#include "stub/i386-linux.kernel.vmlinux.h"
@@ -153,6 +154,13 @@ bool PackVmlinuxI386::canPack()
return 0 < n_ptload;
}
Linker* PackVmlinuxI386::newLinker() const
{
return new ElfLinkerX86;
}
int PackVmlinuxI386::buildLoader(const Filter *ft)
{
// prepare loader
@@ -180,6 +188,20 @@ int PackVmlinuxI386::buildLoader(const Filter *ft)
}
static bool defineFilterSymbols(Linker *linker, const Filter *ft)
{
if (ft->id == 0)
return false;
assert(ft->calls > 0);
linker->defineSymbol("filter_cto", ft->cto);
linker->defineSymbol("filter_length",
(ft->id & 0xf) % 3 == 0 ? ft->calls :
ft->lastcall - ft->calls * 4);
return true;
}
void PackVmlinuxI386::pack(OutputFile *fo)
{
unsigned fo_off = 0;
@@ -226,13 +248,18 @@ void PackVmlinuxI386::pack(OutputFile *fo)
compressWithFilters(&ft, 512, 0, NULL, &cconf);
const unsigned lsize = getLoaderSize();
defineFilterSymbols(linker, &ft);
if (0x40==(0xf0 & ft.id)) {
linker->defineSymbol("filter_length", ph.u_len); // redefine
}
linker->relocate();
// FIXME patchDecompressor(loader, lsize);
MemBuffer loader(lsize);
memcpy(loader, getLoader(), lsize);
patchPackHeader(loader, lsize);
patchDecompressor(loader, lsize);
patch_le32(loader, lsize, "ULEN", ph.u_len);
patchFilter32(loader, lsize, &ft);
while (0!=*p++) ;
shdro[1].sh_name = ptr_diff(p, shstrtab);