mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Make it compile again by adding a more portable setfold.sh script.
committer: mfx <mfx> 962038500 +0000
This commit is contained in:
parent
9be680108e
commit
aba09d07c9
0
.cvsignore
Normal file
0
.cvsignore
Normal file
6
doc/.cvsignore
Normal file
6
doc/.cvsignore
Normal file
|
@ -0,0 +1,6 @@
|
|||
upx.1
|
||||
upx.doc
|
||||
upx.html
|
||||
upx.man
|
||||
upx.ps
|
||||
upx.tex
|
0
patches/.cvsignore
Normal file
0
patches/.cvsignore
Normal file
3
src/.cvsignore
Normal file
3
src/.cvsignore
Normal file
|
@ -0,0 +1,3 @@
|
|||
*.upx
|
||||
upx
|
||||
upx.map
|
0
src/config_h/.cvsignore
Normal file
0
src/config_h/.cvsignore
Normal file
27
src/stub/.cvsignore
Normal file
27
src/stub/.cvsignore
Normal file
|
@ -0,0 +1,27 @@
|
|||
*.asx
|
||||
*.asy
|
||||
*.bin
|
||||
*.i
|
||||
*.lst
|
||||
*.map
|
||||
*.o
|
||||
l_com.h
|
||||
l_djgpp2.h
|
||||
l_exe.h
|
||||
l_le_n2b.h
|
||||
l_le_n2d.h
|
||||
l_lx_n2b.h
|
||||
l_lx_n2d.h
|
||||
l_sh_n2b.h
|
||||
l_sh_n2d.h
|
||||
l_sys.h
|
||||
l_tmt.h
|
||||
l_t_n2b.h
|
||||
l_t_n2bs.h
|
||||
l_t_n2d.h
|
||||
l_t_n2ds.h
|
||||
l_w32pe.h
|
||||
l_wcle.h
|
||||
stubify.h
|
||||
upxb
|
||||
upxd
|
|
@ -61,7 +61,7 @@ APP = perl -w scripts/app.pl
|
|||
BIN2H = perl -w scripts/bin2h.pl
|
||||
BRANDELF = perl -w scripts/brandelf.pl
|
||||
O2BIN = perl -w scripts/o2bin.pl
|
||||
SETFOLD = perl -w scripts/setfold.pl
|
||||
SETFOLD = /bin/sh scripts/setfold.sh
|
||||
##STRIPELF = perl -w scripts/stripelf.pl
|
||||
STRIPELF = ./util/sstrip/sstrip
|
||||
|
||||
|
@ -95,14 +95,14 @@ mostlyclean:
|
|||
-rm -f *~ *.bin *.bkp *.i *.lst *.map
|
||||
|
||||
clean: mostlyclean
|
||||
-rm -f *.o *.asx *.asy upxb upxd
|
||||
-rm -f *.o *.asx *.asy
|
||||
|
||||
distclean: clean
|
||||
|
||||
# This command is intended for maintainers to use; it deletes files
|
||||
# that may require special tools to rebuild.
|
||||
maintainer-clean: distclean
|
||||
-rm -f $(STUBS)
|
||||
-rm -f $(STUBS) upxb upxd
|
||||
|
||||
ident: all
|
||||
ident *.bin
|
||||
|
@ -188,12 +188,9 @@ l_w32pe.h: l_w32pe.asx
|
|||
|
||||
l_lx_n2b.h: l_lx_exec.c l_xe_n2b.o l_lx_exec86.lds Makefile
|
||||
$(CC_LINUX) -DNRV2B -o $T.o -c $<
|
||||
ld -T l_lx_exec86.lds -Map l_lx_n2b.map -o $T.bin \
|
||||
ld -T l_lx_exec86.lds -Map $T.map -o $T.bin \
|
||||
l_xe_n2b.o $T.o
|
||||
fold=`nm $T.bin | grep fold_begin | sed 's/.....\(...\).*/0x\1/'`; \
|
||||
objcopy -S -R .comment -R .note $T.bin; \
|
||||
$(SETFOLD) $T.bin $$fold
|
||||
$(STRIPELF) $T.bin
|
||||
$(SETFOLD) $T.bin
|
||||
$(BRANDELF) $T.bin
|
||||
$(BIN2H) $T.bin linux_i386exec_nrv2b_loader $@
|
||||
|
||||
|
@ -201,10 +198,7 @@ l_le_n2b.h: l_lx_elf.c l_6e_n2b.o l_lx_elf86.lds
|
|||
$(CC_LINUX) -DNRV2B -o $T.o -c $<
|
||||
ld -T l_lx_elf86.lds -Map $T.map -o $T.bin \
|
||||
l_6e_n2b.o $T.o
|
||||
fold=`nm $T.bin | grep fold_begin | sed 's/.....\(...\).*/0x\1/'`; \
|
||||
objcopy -S -R .comment -R .note $T.bin; \
|
||||
$(SETFOLD) $T.bin $$fold
|
||||
$(STRIPELF) $T.bin
|
||||
$(SETFOLD) $T.bin
|
||||
$(BRANDELF) $T.bin
|
||||
$(BIN2H) $T.bin linux_i386elf_nrv2b_loader $@
|
||||
|
||||
|
@ -212,10 +206,7 @@ l_sh_n2b.h: l_lx_sh.c l_6h_n2b.o l_lx_sh86.lds
|
|||
$(CC_LINUX) -DNRV2B -o $T.o -c $<
|
||||
ld -T l_lx_sh86.lds -Map $T.map -o $T.bin \
|
||||
l_6h_n2b.o $T.o
|
||||
fold=`nm $T.bin | grep fold_begin | sed 's/.....\(...\).*/0x\1/'`; \
|
||||
objcopy -S -R .comment -R .note $T.bin; \
|
||||
$(SETFOLD) $T.bin $$fold
|
||||
$(STRIPELF) $T.bin
|
||||
$(SETFOLD) $T.bin
|
||||
$(BRANDELF) $T.bin
|
||||
$(BIN2H) $T.bin linux_i386sh_nrv2b_loader $@
|
||||
|
||||
|
@ -233,10 +224,7 @@ l_lx_n2d.h: l_lx_exec.c l_xe_n2d.o l_lx_exec86.lds
|
|||
$(CC_LINUX) -DNRV2D -o $T.o -c $<
|
||||
ld -T l_lx_exec86.lds -Map $T.map -o $T.bin \
|
||||
l_xe_n2d.o $T.o
|
||||
fold=`nm $T.bin | grep fold_begin | sed 's/.....\(...\).*/0x\1/'`; \
|
||||
objcopy -S -R .comment -R .note $T.bin; \
|
||||
$(SETFOLD) $T.bin $$fold
|
||||
$(STRIPELF) $T.bin
|
||||
$(SETFOLD) $T.bin
|
||||
$(BRANDELF) $T.bin
|
||||
$(BIN2H) $T.bin linux_i386exec_nrv2d_loader $@
|
||||
|
||||
|
@ -244,10 +232,7 @@ l_le_n2d.h: l_lx_elf.c l_6e_n2d.o l_lx_elf86.lds
|
|||
$(CC_LINUX) -DNRV2D -o $T.o -c $<
|
||||
ld -T l_lx_elf86.lds -Map $T.map -o $T.bin \
|
||||
l_6e_n2d.o $T.o
|
||||
fold=`nm $T.bin | grep fold_begin | sed 's/.....\(...\).*/0x\1/'`; \
|
||||
objcopy -S -R .comment -R .note $T.bin; \
|
||||
$(SETFOLD) $T.bin $$fold
|
||||
$(STRIPELF) $T.bin
|
||||
$(SETFOLD) $T.bin
|
||||
$(BRANDELF) $T.bin
|
||||
$(BIN2H) $T.bin linux_i386elf_nrv2d_loader $@
|
||||
|
||||
|
@ -255,10 +240,7 @@ l_sh_n2d.h: l_lx_sh.c l_6h_n2d.o l_lx_sh86.lds
|
|||
$(CC_LINUX) -DNRV2D -o $T.o -c $<
|
||||
ld -T l_lx_sh86.lds -Map $T.map -o $T.bin \
|
||||
l_6h_n2d.o $T.o
|
||||
fold=`nm $T.bin | grep fold_begin | sed 's/.....\(...\).*/0x\1/'`; \
|
||||
objcopy -S -R .comment -R .note $T.bin; \
|
||||
$(SETFOLD) $T.bin $$fold
|
||||
$(STRIPELF) $T.bin
|
||||
$(SETFOLD) $T.bin
|
||||
$(BRANDELF) $T.bin
|
||||
$(BIN2H) $T.bin linux_i386sh_nrv2d_loader $@
|
||||
|
||||
|
@ -273,20 +255,21 @@ l_6h_n2d.o: l_lx_sh86.asm
|
|||
|
||||
l_lx_sep.o: l_lx_sep.c
|
||||
$(CC_LINUX) -c $<
|
||||
|
||||
|
||||
upxb: l_lx_sep.o l_lx_sep86.asm
|
||||
$(NASM) -i$(UCL_I386)/ -f elf -dNRV2B -o upxb.o l_lx_sep86.asm
|
||||
ld -T l_lx_sep86.lds -Map upxb.map -o upxb upxb.o l_lx_sep.o
|
||||
objcopy -S -R .comment -R .note upxb
|
||||
$(STRIPELF) upxb
|
||||
$(BRANDELF) upxb
|
||||
$(NASM) -i$(UCL_I386)/ -f elf -dNRV2B -o $T.o l_lx_sep86.asm
|
||||
ld -T l_lx_sep86.lds -Map $T.map -o $@ $T.o l_lx_sep.o
|
||||
objcopy -S -R .comment -R .note $@
|
||||
$(STRIPELF) $@
|
||||
$(BRANDELF) $@
|
||||
|
||||
upxd: l_lx_sep.o l_lx_sep86.asm
|
||||
$(NASM) -i$(UCL_I386)/ -f elf -dNRV2D -o upxd.o l_lx_sep86.asm
|
||||
ld -T l_lx_sep86.lds -Map upxd.map -o upxd upxd.o l_lx_sep.o
|
||||
objcopy -S -R .comment -R .note upxd
|
||||
$(STRIPELF) upxd
|
||||
$(BRANDELF) upxd
|
||||
$(NASM) -i$(UCL_I386)/ -f elf -dNRV2D -o $T.o l_lx_sep86.asm
|
||||
ld -T l_lx_sep86.lds -Map $T.map -o $@ $T.o l_lx_sep.o
|
||||
objcopy -S -R .comment -R .note $@
|
||||
$(STRIPELF) $@
|
||||
$(BRANDELF) $@
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# // dependencies
|
||||
|
@ -316,14 +299,14 @@ l_xe_n2d.o: n2d_d32.ash $(DEPS1)
|
|||
l_6e_n2d.o: n2d_d32.ash $(DEPS1)
|
||||
l_6h_n2d.o: n2d_d32.ash $(DEPS1)
|
||||
|
||||
l_lx_n2b.h: linux.hh
|
||||
l_lx_n2d.h: linux.hh
|
||||
l_le_n2b.h: linux.hh
|
||||
l_le_n2d.h: linux.hh
|
||||
l_sh_n2b.h: linux.hh
|
||||
l_sh_n2d.h: linux.hh
|
||||
upxb: linux.hh
|
||||
upxd: linux.hh
|
||||
l_lx_n2b.h: linux.hh
|
||||
l_lx_n2d.h: linux.hh
|
||||
l_le_n2b.h: linux.hh
|
||||
l_le_n2d.h: linux.hh
|
||||
l_sh_n2b.h: linux.hh
|
||||
l_sh_n2d.h: linux.hh
|
||||
upxb: linux.hh
|
||||
upxd: linux.hh
|
||||
|
||||
.NOEXPORT:
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ do_xmap(int fdi, Elf32_Ehdr const *const ehdr, f_expand *const f_decompress,
|
|||
(char const *)ehdr);
|
||||
unsigned long base = (ET_DYN==ehdr->e_type) ? 0x40000000 : 0;
|
||||
int j;
|
||||
for (j=0; j < ehdr->e_phnum; ++phdr, ++j)
|
||||
for (j=0; j < ehdr->e_phnum; ++phdr, ++j)
|
||||
if (PT_PHDR==phdr->p_type) {
|
||||
a->a_un.a_val = phdr->p_vaddr;
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ ERR_LAB
|
|||
do_brk(haddr);
|
||||
}
|
||||
}
|
||||
if (close(fdi) != 0)
|
||||
if (close(fdi) != 0)
|
||||
err_exit(11);
|
||||
if (ET_DYN==ehdr->e_type) {
|
||||
return ehdr->e_entry + base;
|
||||
|
@ -402,7 +402,7 @@ void *upx_main(
|
|||
// ----- Step 4: decompress blocks -----
|
||||
//
|
||||
|
||||
// Get Elf32_Ehdr. First set xo.size = size[0] = uncompressed size
|
||||
// Get Elf32_Ehdr. First set xo.size = size[0] = uncompressed size
|
||||
if (0!=xread(fdi, (void *)&xo, sizeof(xo))) {
|
||||
err_exit(15);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,11 @@ $fname = shift || die;
|
|||
sysopen (FH,$fname,2) || die;
|
||||
binmode FH;
|
||||
|
||||
$val = oct shift || die;
|
||||
$val = shift || die "$val";
|
||||
###print STDERR "$val\n";
|
||||
$val = oct($val); # acutally hex()
|
||||
###print STDERR "$val\n";
|
||||
die unless $val;
|
||||
$num = pack("V", $val);
|
||||
|
||||
# 0x34 = sizeof(Elf32_Ehdr)
|
||||
|
|
23
src/stub/scripts/setfold.sh
Normal file
23
src/stub/scripts/setfold.sh
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
file="$1"
|
||||
|
||||
# get directory of this script
|
||||
bindir=`echo "$0" | sed -e 's|[^/][^/]*$||'`
|
||||
bindir=`cd "$bindir" && pwd`
|
||||
|
||||
sstrip="$bindir/../util/sstrip/sstrip"
|
||||
|
||||
# get address of symbol "fold_begin"
|
||||
fold=`nm -f bsd "$file" | grep fold_begin | sed 's/^0*\([0-9a-fA-F]*\).*/0x\1/'`
|
||||
|
||||
# strip
|
||||
objcopy -S -R .comment -R .note "$file"
|
||||
"$sstrip" "$file"
|
||||
|
||||
# patch address
|
||||
perl -w "$bindir/setfold.pl" "$file" "$fold"
|
||||
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user