如果在ubuntu12.04下编译:
修改upx-master/src的Makefile:
26 # toolchain
27 CXX ?= g++
28 CXXLD = $(CXX)
g++ 换成arm-linux-androideabi-g++ ok。
sq@sq-Hasee:~$ cd /home/sq/upx-master
sq@sq-Hasee:~/upx-master$ make
出现:
UPX info: please choose a target for 'make'
使用:
sq@sq-Hasee:~/upx-master$ make all
出现:
make[1]: 正在进入目录 `/home/sq/upx-master/src'
../src/stub/src/c/Makevars.lzma:12: *** ERROR: missing directory src/lzma-sdk/; visit https://github.com/upx/upx-lzma-sdk 。 停止。
make[1]:正在离开目录 `/home/sq/upx-master/src'
make: *** [all] 错误 2
大概意思是没有src/lzma-sdk/压缩sdk,访问https://github.com/upx/upx-lzma-sdk
upx-lzma-sdk-master.zip
一样解压到。/src/lzma-sdk/目录下,
upx-lzma-sdk-master下的文件彩cp这个目录。
make all
make -C src all
make[1]: 正在进入目录 `/home/sq/upx-master/src'
Updating .depend
make[1]:正在离开目录 `/home/sq/upx-master/src'
make[1]: 正在进入目录 `/home/sq/upx-master/src'
没有ucl.h和uclconf.h
在linux 下
apt-get install libucl-dev 就好了。
在libucl 找到了。http://cn.archive.ubuntu.com/ubuntu/pool/main/u/ucl/ucl_1.03.orig.tar.gz
很简单:
cd ./ucl-1.03
export CC=arm-linux-androideabi-gcc
./configure --host=arm-linux --with-pcap=linux
make
导入完事。
根据这个也行:http://blog.csdn.net/iefswang/article/details/17166549
make all出现:
./../src/stub/scripts/check_whitespace.sh ./..
ERROR: binary file detected ./src/c_file.o:
src/stub/scripts/check_whitespace.sh内容修改。
#print("$ARGV\n");
if (m,[\x00\x01\x02\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); }
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
if (m,([ \t]+)$,) {
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files
if ($1 ne " " || $ARGV !~ m,\.md$,) {
print "ERROR: trailing whitespace detected $ARGV: $_"; exit(1);
}
}
if (m,\t,) {
if ($ARGV =~ m,(^|/)(gnu|m)?make(file|vars),i) { }
elsif ($ARGV =~ m,/tmp/.*\.(disasm|dump)$,) { }
elsif ($ARGV =~ m,/src/stub/src/arch/.*/lzma\w+\.S$,) { }
else { print "ERROR: hard TAB detected $ARGV: $_"; exit(1); }
}
上面的内容注释掉。不然辛苦就被无情删了。
upx.out
就在andoid 上运行了。
linux 打字不爽,没改。
picoc 615.5kb
压缩后的:230.81kb
u0_a186@pisces:/ $ cd /data/local/tmp
u0_a186@pisces:/data/local/tmp $ ./upx
Ultimate Packer for eXecutables
Copyright (C) 1996 - 2017
UPX 3.93 Markus Oberhumer, Laszlo Molnar & John Reiser Jan 29th 2017
Usage: upx [-123456789dlthVL] [-qvfk] [-o file] file..
Commands:
-1 compress faster -9 compress better
-d decompress -l list compressed file
-t test compressed file -V display version number
-h give more help -L display software license
Options:
-q be quiet -v be verbose
-oFILE write output to 'FILE'
-f force compression of suspicious files
-k keep backup files
file.. executables to (de)compress
Type 'upx --help' for more detailed help.
UPX comes with ABSOLUTELY NO WARRANTY; for details visit https://upx.github.io
1|u0_a186@pisces:/data/local/tmp $ upx -o ./picoc
/system/bin/sh: upx: not found
127|u0_a186@pisces:/data/local/tmp $ ./upx -o ./picoc
./upx: need exactly one argument when using '-o'
Usage: upx [-123456789dlthVL] [-qvfk] [-o file] file..
1|u0_a186@pisces:/data/local/tmp $ ./upx ./picoc
Ultimate Packer for eXecutables
Copyright (C) 1996 - 2017
UPX 3.93 Markus Oberhumer, Laszlo Molnar & John Reiser Jan 29th 2017
File size Ratio Format Name
-------------------- ------ ----------- -----------upx: ./picoc: IOException: ./picoc.upx: Permission denied
Packed 0 files.
1|u0_a186@pisces:/data/local/tmp $ su
root@pisces:/ # ./upx ./picoc
./upx ./picoc
sh: ./upx: not found
127|root@pisces:/ # cd /data/local/tmp
cd /data/local/tmp
root@pisces:/data/local/tmp # ./upx ./picoc
./upx ./picoc
Ultimate Packer for eXecutables
Copyright (C) 1996 - 2017
UPX 3.93 Markus Oberhumer, Laszlo Molnar & John Reiser Jan 29th 2017
File size Ratio Format Name
-------------------- ------ ----------- -----------picoc 1/5 [...............................................picoc 1/5 [*..............................................picoc 1/5 [**.............................................picoc 1/5 [***............................................picoc 1/5 [****...........................................picoc 1/5 [*****..........................................picoc 1/5 [******.........................................picoc 1/5 [******.........................................picoc 1/5 [*******........................................picoc 1/5 [********.......................................picoc 1/5 [*********......................................picoc 1/5 [**********.....................................picoc 1/5 [**********.....................................picoc 1/5 [***********....................................picoc 1/5 [************...................................picoc 1/5 [*************..................................picoc 1/5 [**************.................................picoc 1/5 [**************.................................picoc 1/5 [***************................................picoc 1/5 [****************...............................picoc 1/5 [*****************..............................picoc 1/5 [******************.............................picoc 1/5 [*******************............................picoc 1/5 [*******************............................picoc 1/5 [********************...........................picoc 1/5 [*********************..........................picoc 1/5 [**********************.........................picoc 1/5 [***********************........................picoc 1/5 [***********************........................picoc 1/5 [************************.......................picoc 1/5 [*************************......................picoc 1/5 [**************************.....................picoc 1/5 [***************************....................picoc 1/5 [***************************....................picoc 1/5 [****************************...................picoc 1/5 [*****************************..................picoc 1/5 [******************************.................picoc 1/5 [*******************************................picoc 1/5 [*******************************................picoc 1/5 [********************************...............picoc 1/5 [*********************************..............picoc 1/5 [**********************************.............picoc 1/5 [***********************************............picoc 1/5 [************************************...........picoc 1/5 [************************************...........picoc 1/5 [*************************************..........picoc 1/5 [**************************************.........picoc 1/5 [***************************************........picoc 1/5 [****************************************.......picoc 1/5 [****************************************.......picoc 1/5 [*****************************************......picoc 1/5 [******************************************.....picoc 1/5 [*******************************************....picoc 1/5 [********************************************...picoc 1/5 [********************************************...picoc 1/5 [*********************************************..picoc 1/5 [**********************************************.picoc 1/5 [***********************************************picoc 1/5 [***********************************************picoc 1/5 [***********************************************picoc 1/5 [***********************************************picoc 1/5 [***********************************************picoc 1/5 [***********************************************picoc 1/5 [***********************************************picoc 2/5 [...............................................picoc 2/5 [*..............................................picoc 2/5 [**.............................................picoc 2/5 [***............................................picoc 2/5 [****...........................................picoc 2/5 [*****..........................................picoc 2/5 [******.........................................picoc 2/5 [******.........................................picoc 2/5 [*******........................................picoc 2/5 [********.......................................picoc 2/5 [*********......................................picoc 2/5 [**********.....................................picoc 2/5 [**********.....................................picoc 2/5 [***********....................................picoc 2/5 [************...................................picoc 2/5 [*************..................................picoc 2/5 [**************.................................picoc 2/5 [**************.................................picoc 2/5 [***************................................picoc 2/5 [****************...............................picoc 2/5 [*****************..............................picoc 2/5 [******************.............................picoc 2/5 [*******************............................picoc 2/5 [*******************............................picoc 2/5 [********************...........................picoc 2/5 [*********************..........................picoc 2/5 [**********************.........................picoc 2/5 [***********************........................picoc 2/5 [***********************........................picoc 2/5 [************************.......................picoc 2/5 [*************************......................picoc 2/5 [**************************.....................picoc 2/5 [***************************....................picoc 2/5 [***************************....................picoc 2/5 [****************************...................picoc 2/5 [*****************************..................picoc 2/5 [******************************.................picoc 2/5 [*******************************................picoc 2/5 [*******************************................picoc 2/5 [********************************...............picoc 2/5 [*********************************..............picoc 2/5 [**********************************.............picoc 2/5 [***********************************............picoc 2/5 [************************************...........picoc 2/5 [************************************...........picoc 2/5 [*************************************..........picoc 2/5 [**************************************.........picoc 2/5 [***************************************........picoc 2/5 [****************************************.......picoc 2/5 [****************************************.......picoc 2/5 [*****************************************......picoc 2/5 [******************************************.....picoc 2/5 [*******************************************....picoc 2/5 [********************************************...picoc 2/5 [********************************************...picoc 2/5 [*********************************************..picoc 2/5 [**********************************************.picoc 2/5 [***********************************************picoc 2/5 [***********************************************picoc 2/5 [***********************************************picoc 2/5 [***********************************************picoc 2/5 [***********************************************picoc 2/5 [***********************************************picoc 2/5 [***********************************************picoc 3/5 [...............................................picoc 3/5 [*..............................................picoc 3/5 [***............................................picoc 3/5 [******.........................................picoc 3/5 [**********.....................................picoc 3/5 [*************..................................picoc 3/5 [**************.................................picoc 3/5 [*****************..............................picoc 3/5 [********************...........................picoc 3/5 [************************.......................picoc 3/5 [***************************....................picoc 3/5 [****************************...................picoc 3/5 [*********************************..............picoc 3/5 [**********************************.............picoc 3/5 [**************************************.........picoc 3/5 [***************************************........picoc 3/5 [********************************************...picoc 3/5 [*********************************************..picoc 3/5 [***********************************************picoc 3/5 [***********************************************picoc 4/5 [...............................................picoc 4/5 [*..............................................picoc 4/5 [********************************...............picoc 4/5 [***********************************************picoc 5/5 [...............................................picoc 5/5 [**.............................................picoc 5/5 [**.............................................picoc 5/5 [***............................................picoc 5/5 [****...........................................picoc 5/5 [*****..........................................picoc 5/5 [******.........................................picoc 5/5 [******.........................................picoc 5/5 [*******........................................picoc 5/5 [********.......................................picoc 5/5 [*********......................................picoc 5/5 [**********.....................................picoc 5/5 [**********.....................................picoc 5/5 [***********....................................picoc 5/5 [************...................................picoc 5/5 [*************..................................picoc 5/5 [**************.................................picoc 5/5 [**************.................................picoc 5/5 [***************................................picoc 5/5 [****************...............................picoc 5/5 [*****************..............................picoc 5/5 [******************.............................picoc 5/5 [******************.............................picoc 5/5 [*******************............................picoc 5/5 [********************...........................picoc 5/5 [*********************..........................picoc 5/5 [**********************.........................picoc 5/5 [**********************.........................picoc 5/5 [***********************........................picoc 5/5 [************************.......................picoc 5/5 [*************************......................picoc 5/5 [**************************.....................picoc 5/5 [***************************....................picoc 5/5 [****************************...................picoc 5/5 [****************************...................picoc 5/5 [*****************************..................picoc 5/5 [******************************.................picoc 5/5 [*******************************................picoc 5/5 [********************************...............picoc 5/5 [********************************...............picoc 5/5 [*********************************..............picoc 5/5 [**********************************.............picoc 5/5 [***********************************............picoc 5/5 [************************************...........picoc 5/5 [************************************...........picoc 5/5 [*************************************..........picoc 5/5 [**************************************.........picoc 5/5 [***************************************........picoc 5/5 [****************************************.......picoc 5/5 [****************************************.......picoc 5/5 [*****************************************......picoc 5/5 [******************************************.....picoc 5/5 [*******************************************....picoc 5/5 [********************************************...picoc 5/5 [********************************************...picoc 5/5 [*********************************************..picoc 5/5 [**********************************************.picoc 5/5 [***********************************************picoc 5/5 [***********************************************picoc 5/5 [***********************************************picoc 5/5 [***********************************************picoc 5/5 [***********************************************picoc 5/5 [***********************************************picoc 5/5 [*********************************************** 615451 -> 236348 38.40% linux/arm picoc
Packed 1 file.
root@pisces:/data/local/tmp # ./picoc
./picoc
Format: picoc <csource1.c>... [- <arg1>...] : run a program (calls main() to start it)
picoc -s <csource1.c>... [- <arg1>...] : script mode - runs the program without calling main()
picoc -i : interactive mode
1|root@pisces:/data/local/tmp #