mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
PackVmlinuxBase my_boot_label; kernel Makefiles
This commit is contained in:
parent
3a6c574376
commit
11b92172fe
|
@ -52,9 +52,11 @@ static const
|
|||
|
||||
template <class T>
|
||||
PackVmlinuxBase<T>::PackVmlinuxBase(InputFile *f,
|
||||
unsigned e_machine, unsigned elfclass, unsigned elfdata) :
|
||||
unsigned e_machine, unsigned elfclass, unsigned elfdata,
|
||||
char const *const boot_label) :
|
||||
super(f),
|
||||
my_e_machine(e_machine), my_elfclass(elfclass), my_elfdata(elfdata),
|
||||
my_boot_label(boot_label),
|
||||
n_ptload(0), phdri(NULL), shdri(NULL), shstrtab(NULL)
|
||||
{
|
||||
ElfClass::compileTimeAssertions();
|
||||
|
@ -370,16 +372,16 @@ void PackVmlinuxBase<T>::pack(OutputFile *fo)
|
|||
unc_ker.st_shndx = 1; // .text
|
||||
fo->write(&unc_ker, sizeof(unc_ker)); fo_off += sizeof(unc_ker);
|
||||
|
||||
// '\0' before and after the name we want
|
||||
char const strtab[] = "\0decompress_kernel";
|
||||
|
||||
unsigned const lablen = strlen(my_boot_label);
|
||||
while (0!=*p++) ;
|
||||
shdro[6].sh_name = ptr_diff(p, shstrtab);
|
||||
shdro[6].sh_type = Shdr::SHT_STRTAB;
|
||||
shdro[6].sh_offset = fo_off;
|
||||
shdro[6].sh_size = sizeof(strtab); // includes both '\0'
|
||||
shdro[6].sh_size = 2+ lablen; // '\0' before and after
|
||||
shdro[6].sh_addralign = 1;
|
||||
fo->write(strtab, sizeof(strtab)); fo_off += sizeof(strtab);
|
||||
fo->seek(1, SEEK_CUR); // the '\0' before
|
||||
fo->write(my_boot_label, 1+ lablen); // include the '\0' terminator
|
||||
fo_off += 2+ lablen;
|
||||
|
||||
fo->seek(0, SEEK_SET);
|
||||
fo->write(&ehdro, sizeof(ehdro));
|
||||
|
@ -738,18 +740,16 @@ bool PackVmlinuxAMD64::has_valid_vmlinux_head()
|
|||
//# create a compressed vmlinux image from the original vmlinux
|
||||
//#
|
||||
//
|
||||
//targets := vmlinux upx-head.o upx-piggy.o
|
||||
//targets := vmlinux upx-piggy.o
|
||||
//
|
||||
//LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup_32
|
||||
//
|
||||
//$(obj)/vmlinux: $(obj)/upx-head.o $(obj)/upx-piggy.o FORCE
|
||||
//$(obj)/vmlinux: $(obj)/upx-piggy.o FORCE
|
||||
// $(call if_changed,ld)
|
||||
// @:
|
||||
//
|
||||
//$(obj)/upx-piggy.o: vmlinux FORCE
|
||||
// rm -f $@
|
||||
// upx --best -o $@ $<
|
||||
// touch $@
|
||||
// upx --lzma -f -o $@ $<; touch $@
|
||||
//
|
||||
//#
|
||||
//# The ORIGINAL build sequence using gzip is:
|
||||
|
@ -776,17 +776,12 @@ bool PackVmlinuxAMD64::has_valid_vmlinux_head()
|
|||
//# boot/compressed/upx-piggy.o by upx format vmlinux/386
|
||||
//#
|
||||
//# In arch/i386/boot:
|
||||
//# boot/compressed/vmlinux by ld upx-head.o upx-piggy.o
|
||||
//# boot/compressed/vmlinux by ld upx-piggy.o
|
||||
//# boot/vmlinux.bin by objcopy
|
||||
//# boot/bzImage by arch/i386/boot/tools/build with
|
||||
//# bootsect and setup
|
||||
//#
|
||||
//-----
|
||||
//
|
||||
//----- arch/i386/boot/compressed/upx-head.S
|
||||
//startup_32: .globl startup_32 # In: %esi=0x90000 setup data "real_mode pointer"
|
||||
// /* All code is in stub/src/i386-linux.kernel.vmlinux-head.S */
|
||||
//-----
|
||||
|
||||
#if 0 /*{*/
|
||||
// For Debian nslu2-linux (2.6.19), only this Makefile changes:
|
||||
|
@ -828,7 +823,7 @@ bool PackVmlinuxAMD64::has_valid_vmlinux_head()
|
|||
-
|
||||
-$(obj)/piggy.o: $(obj)/piggy.gz FORCE
|
||||
+$(obj)/upx-piggy.o: vmlinux FORCE
|
||||
+ rm -f $@; upx --lzma -o $@ $<; touch $@
|
||||
+ upx --lzma -f -o $@ $<; touch $@
|
||||
|
||||
CFLAGS_font_acorn_8x8.o := -Dstatic=
|
||||
|
||||
|
@ -848,7 +843,7 @@ bool PackVmlinuxAMD64::has_valid_vmlinux_head()
|
|||
//# create a compressed vmlinux image from the original vmlinux
|
||||
//#
|
||||
//
|
||||
//HEAD = upx-head.o
|
||||
//HEAD =
|
||||
//SYSTEM = $(TOPDIR)/vmlinux
|
||||
//
|
||||
//OBJECTS = $(HEAD)
|
||||
|
|
|
@ -57,7 +57,7 @@ protected:
|
|||
typedef typename ElfClass::Sym Sym;
|
||||
|
||||
public:
|
||||
PackVmlinuxBase(InputFile *, unsigned, unsigned, unsigned);
|
||||
PackVmlinuxBase(InputFile *, unsigned, unsigned, unsigned, char const *);
|
||||
virtual ~PackVmlinuxBase();
|
||||
virtual int getVersion() const { return 13; }
|
||||
|
||||
|
@ -65,6 +65,7 @@ protected:
|
|||
unsigned int const my_e_machine;
|
||||
unsigned char const my_elfclass;
|
||||
unsigned char const my_elfdata;
|
||||
char const *const my_boot_label;
|
||||
|
||||
int n_ptload;
|
||||
unsigned sz_ptload;
|
||||
|
@ -97,7 +98,7 @@ class PackVmlinuxI386 : public PackVmlinuxBase<ElfClass_LE32>
|
|||
typedef PackVmlinuxBase<ElfClass_LE32> super;
|
||||
public:
|
||||
PackVmlinuxI386(InputFile *f) : super(f, Ehdr::EM_386,
|
||||
Ehdr::ELFCLASS32, Ehdr::ELFDATA2LSB) { }
|
||||
Ehdr::ELFCLASS32, Ehdr::ELFDATA2LSB, "startup_32") { }
|
||||
virtual int getFormat() const { return UPX_F_VMLINUX_i386; }
|
||||
virtual const char *getName() const { return "vmlinux/386"; }
|
||||
virtual const char *getFullName(const options_t *) const { return "i386-linux.kernel.vmlinux"; }
|
||||
|
@ -121,7 +122,7 @@ class PackVmlinuxARM : public PackVmlinuxBase<ElfClass_LE32>
|
|||
typedef PackVmlinuxBase<ElfClass_LE32> super;
|
||||
public:
|
||||
PackVmlinuxARM(InputFile *f) : super(f, Ehdr::EM_ARM,
|
||||
Ehdr::ELFCLASS32, Ehdr::ELFDATA2LSB) { }
|
||||
Ehdr::ELFCLASS32, Ehdr::ELFDATA2LSB, "decompress_kernel") { }
|
||||
virtual int getFormat() const { return UPX_F_VMLINUX_ARM; }
|
||||
virtual const char *getName() const { return "vmlinux/ARM"; }
|
||||
virtual const char *getFullName(const options_t *) const { return "ARM-linux.kernel.vmlinux"; }
|
||||
|
@ -146,7 +147,7 @@ class PackVmlinuxAMD64 : public PackVmlinuxBase<ElfClass_LE64>
|
|||
typedef PackVmlinuxBase<ElfClass_LE64> super;
|
||||
public:
|
||||
PackVmlinuxAMD64(InputFile *f) : super(f, Ehdr::EM_X86_64,
|
||||
Ehdr::ELFCLASS64, Ehdr::ELFDATA2LSB) { }
|
||||
Ehdr::ELFCLASS64, Ehdr::ELFDATA2LSB, "startup_32") { }
|
||||
virtual int getFormat() const { return UPX_F_VMLINUX_AMD64; }
|
||||
virtual const char *getName() const { return "vmlinux/AMD64"; }
|
||||
virtual const char *getFullName(const options_t *) const { return "amd64-linux.kernel.vmlinux"; }
|
||||
|
|
Loading…
Reference in New Issue
Block a user