mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Remove Makefile fragment from p_vmlinx.cpp.
This commit is contained in:
parent
c97765de14
commit
272fe5488c
220
src/p_vmlinx.cpp
220
src/p_vmlinx.cpp
|
@ -1282,226 +1282,6 @@ bool PackVmlinuxAMD64::has_valid_vmlinux_head()
|
|||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// Example usage within build system of Linux kernel-2.6.18:
|
||||
//
|
||||
//----- arch/i386/boot/compressed/Makefile
|
||||
//#
|
||||
//# linux/arch/i386/boot/compressed/Makefile
|
||||
//#
|
||||
//# create a compressed vmlinux image from the original vmlinux
|
||||
//#
|
||||
//
|
||||
//targets := vmlinux upx-piggy.o
|
||||
//
|
||||
//LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup_32
|
||||
//
|
||||
//$(obj)/vmlinux: $(obj)/upx-piggy.o FORCE
|
||||
// $(call if_changed,ld)
|
||||
// @:
|
||||
//
|
||||
//$(obj)/upx-piggy.o: vmlinux FORCE
|
||||
// upx --lzma -f -o $@ $<; touch $@
|
||||
//
|
||||
//#
|
||||
//# The ORIGINAL build sequence using gzip is:
|
||||
//# vmlinux Elf executable at top level in tree
|
||||
//# (in same directory as MAINTAINERS)
|
||||
//# In arch/i386:
|
||||
//# boot/compressed/vmlinux.bin by objcopy -O binary
|
||||
//# boot/compressed/vmlinux.bin.gz by gzip
|
||||
//# boot/compressed/piggy.o by ld --format binary --oformat elf32-i386
|
||||
//#
|
||||
//# The 3 steps above create a linkable
|
||||
//# compressed blob.
|
||||
//# In arch/i386:
|
||||
//# boot/compressed/vmlinux by ld head.o misc.o piggy.o
|
||||
//# boot/vmlinux.bin by objcopy
|
||||
//# boot/bzImage by arch/i386/boot/tools/build with
|
||||
//# bootsect and setup
|
||||
//#
|
||||
//#
|
||||
//# The MODIFIED build sequence using upx is:
|
||||
//# vmlinux Elf executable at top level in tree
|
||||
//# (in same directory as MAINTAINERS)
|
||||
//# In arch/i386:
|
||||
//# boot/compressed/upx-piggy.o by upx format vmlinux/386
|
||||
//#
|
||||
//# In arch/i386/boot:
|
||||
//# 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
|
||||
//#
|
||||
//-----
|
||||
|
||||
#if 0 /*{*/
|
||||
// For Debian nslu2-linux (2.6.19), only this Makefile changes:
|
||||
--- ./debian/build/build-arm-none-ixp4xx/arch/arm/boot/compressed/Makefile.orig 2006-11-29 13:57:37.000000000 -0800
|
||||
+++ ./debian/build/build-arm-none-ixp4xx/arch/arm/boot/compressed/Makefile 2006-12-16 02:39:38.000000000 -0800
|
||||
@@ -5,7 +5,7 @@
|
||||
#
|
||||
|
||||
HEAD = head.o
|
||||
-OBJS = misc.o
|
||||
+OBJS =
|
||||
FONTC = drivers/video/console/font_acorn_8x8.c
|
||||
|
||||
FONT = $(addprefix ../../../../drivers/video/console/, font_acorn_8x8.o)
|
||||
@@ -73,8 +73,8 @@
|
||||
|
||||
SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/BSS_START/$(ZBSSADDR)/
|
||||
|
||||
-targets := vmlinux vmlinux.lds piggy.gz piggy.o $(FONT) \
|
||||
- head.o misc.o $(OBJS)
|
||||
+targets := vmlinux vmlinux.lds upx-piggy.o $(FONT) \
|
||||
+ head.o $(OBJS)
|
||||
EXTRA_CFLAGS := -fpic
|
||||
EXTRA_AFLAGS :=
|
||||
|
||||
@@ -95,20 +95,16 @@
|
||||
# would otherwise mess up our GOT table
|
||||
CFLAGS_misc.o := -Dstatic=
|
||||
|
||||
-$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \
|
||||
- $(addprefix $(obj)/, $(OBJS)) FORCE
|
||||
+$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) \
|
||||
+ $(addprefix $(obj)/, $(OBJS)) $(obj)/upx-piggy.o FORCE
|
||||
$(call if_changed,ld)
|
||||
@:
|
||||
|
||||
-$(obj)/piggy.gz: $(obj)/../Image FORCE
|
||||
- $(call if_changed,gzip)
|
||||
-
|
||||
-$(obj)/piggy.o: $(obj)/piggy.gz FORCE
|
||||
+$(obj)/upx-piggy.o: vmlinux FORCE
|
||||
+ upx --lzma -f -o $@ $<; touch $@
|
||||
|
||||
CFLAGS_font_acorn_8x8.o := -Dstatic=
|
||||
|
||||
$(obj)/vmlinux.lds: $(obj)/vmlinux.lds.in arch/arm/boot/Makefile .config
|
||||
@sed "$(SEDFLAGS)" < $< > $@
|
||||
|
||||
-$(obj)/misc.o: $(obj)/misc.c include/asm/arch/uncompress.h lib/inflate.c
|
||||
-
|
||||
#endif /*}*/
|
||||
|
||||
// Approximate translation for Linux 2.4.x:
|
||||
// - - -
|
||||
// arch/i386/Makefile: LD_FLAGS=-e startup_32
|
||||
//----- arch/i386/boot/compressed/Makefile
|
||||
//# linux/arch/i386/boot/compressed/Makefile
|
||||
//#
|
||||
//# create a compressed vmlinux image from the original vmlinux
|
||||
//#
|
||||
//
|
||||
//HEAD =
|
||||
//SYSTEM = $(TOPDIR)/vmlinux
|
||||
//
|
||||
//OBJECTS = $(HEAD)
|
||||
//
|
||||
//ZLDFLAGS = -e startup_32
|
||||
//
|
||||
//#
|
||||
//# ZIMAGE_OFFSET is the load offset of the compression loader
|
||||
//# BZIMAGE_OFFSET is the load offset of the high loaded compression loader
|
||||
//#
|
||||
//ZIMAGE_OFFSET = 0x1000
|
||||
//BZIMAGE_OFFSET = 0x100000
|
||||
//
|
||||
//ZLINKFLAGS = -Ttext $(ZIMAGE_OFFSET) $(ZLDFLAGS)
|
||||
//BZLINKFLAGS = -Ttext $(BZIMAGE_OFFSET) $(ZLDFLAGS)
|
||||
//
|
||||
//all: vmlinux
|
||||
//
|
||||
//vmlinux: upx-piggy.o $(OBJECTS)
|
||||
// $(LD) $(ZLINKFLAGS) -o vmlinux $(OBJECTS) upx-piggy.o
|
||||
//
|
||||
//bvmlinux: upx-piggy.o $(OBJECTS)
|
||||
// $(LD) $(BZLINKFLAGS) -o bvmlinux $(OBJECTS) upx-piggy.o
|
||||
//
|
||||
//upx-piggy.o: $(SYSTEM)
|
||||
// $(RM) -f $@
|
||||
// upx --best -o $@ $<
|
||||
// touch $@
|
||||
//
|
||||
//clean:
|
||||
// rm -f vmlinux bvmlinux _tmp_*
|
||||
//-----
|
||||
|
||||
//
|
||||
// Example test jig:
|
||||
// $ gcc -m32 -o test-piggy -nostartfiles -nostdlib test-piggy.o piggy.o
|
||||
// $ gdb test-piggy
|
||||
// (gdb) run >dumped
|
||||
// (gdb) /* Execute [single step, etc.; the decompressor+unfilter moves!]
|
||||
// * until reaching the 'lret' at the end of unfilter.
|
||||
// */
|
||||
// (gdb) set $pc= &dump
|
||||
// (gdb) stepi
|
||||
// (gdb) set $edx=<actual_uncompressed_length>
|
||||
// (gdb) continue
|
||||
// (gdb) q
|
||||
// $ # Compare file 'dumped' with the portion of vmlinux that made piggy.o.
|
||||
// $ dd if=vmlinux bs=<leader_size> skip=1 | cmp - dumped
|
||||
// cmp: EOF on dumped
|
||||
// $
|
||||
//----- test-piggy.S
|
||||
//#include <asm/mman.h>
|
||||
//#include <asm/unistd.h>
|
||||
//
|
||||
//dump:
|
||||
// movl $0x456789,%edx # length MODIFY THIS VALUE TO SUIT YOUR CASE
|
||||
// movl $0x100000,%ecx # base
|
||||
// movl $1,%ebx # stdout
|
||||
// movl $ __NR_write,%eax
|
||||
// int $0x80
|
||||
// nop
|
||||
// hlt
|
||||
//mmap:
|
||||
// pushl %ebx
|
||||
// leal 2*4(%esp),%ebx
|
||||
// pushl $ __NR_mmap; popl %eax
|
||||
// int $0x80
|
||||
// popl %ebx
|
||||
// ret $6*4
|
||||
//
|
||||
//_start: .globl _start
|
||||
// nop
|
||||
// int3 # enter debugger!
|
||||
// pushl $0
|
||||
// pushl $0
|
||||
// pushl $ MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED
|
||||
// pushl $ PROT_EXEC | PROT_WRITE | PROT_READ
|
||||
// pushl $0x600000 # 6 MiB length
|
||||
// pushl $0x100000 # 1 MiB address
|
||||
// call mmap
|
||||
// leal -0x9000(%esp),%esi # expect "lea 0x9000(%esi),%esp" later
|
||||
///* Fall into .text of upx-compressed vmlinux. */
|
||||
//-----
|
||||
|
||||
// Example test jig for ARM:
|
||||
//-----main.c
|
||||
//unsigned work[(1<<16)/sizeof(unsigned)];
|
||||
//unsigned kernel[(3<<20)/sizeof(unsigned)];
|
||||
//
|
||||
///* In order to avoid complaints such as
|
||||
// /usr/bin/ld: ERROR: libgcc_s.so uses hardware FP, whereas main uses software FP
|
||||
// when building this test program, then you must change the .e_flags
|
||||
// in the header of the compressed, relocatble output from upx, from
|
||||
// Flags: 0x202, has entry point, GNU EABI, software FP
|
||||
// to
|
||||
// Flags: 0x0
|
||||
//*/
|
||||
//
|
||||
//main()
|
||||
//{
|
||||
// char *const end = decompress_kernel(kernel, work, (1<<(16-2))+work, 0x1234);
|
||||
// write(1, kernel, (char *)end - (char *)kernel);
|
||||
// return 0;
|
||||
//}
|
||||
//-----
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue
Block a user