linux下编译upx

1、准备源码包
直接去github下载zip包或者直接克隆一下。

git clone https://github.com/upx/upx.git
cd upx
rmdir lzma-sdk
git clone https://github.com/upx/upx-lzma-sdk.git lzma-sdk
Copy
lzma库无需编译。

然后去下载UCL库。
UCL是完全使用ANSI C编写的NRV(Not Really Vanished)算法的一个开源实现。 具体的介绍请查阅http://www.oberhumer.com/opensource/ucl/

wget http://www.oberhumer.com/opensource/ucl/download/ucl-1.03.tar.gz
Copy
国外的网站下载比较慢,可以直接点击此处下载我已经下好的。

2、编译
UCL编译
先生成Makefile文件

tar -xzvf ucl-1.03.tar.gz
cd ucl-1.03
./configure --prefix=/home/o/ucl CC=clang
Copy
注意上面,指定了C编译器为clang。这里是因为gcc的一个bug,导致 ACC一致性测试失败 ,所以使用clang。
gcc出现的错误情况在这里FTBFS with GCC 6: compiler failed the ACC conformance test有详细描述。
如果没有安装clang,安装
sudo apt install clang

编译UPX
使用下面命令编译upx

make all UPX_UCLDIR=/home/o/upx/ucl/ucl-1.03 UPX_LZMADIR=./src/lzma-sdk
Copy
注意,这里的UPX_UCLDIR变量的值必须是绝对路径。
编译出的结果是upx.out程序,在src目录下。

报错1:
relocation R_X86_64_32S against `.text' can not be used when making a PIE object; recompile with -fPIC:链接时 加上  -no-pie,修改makefile
vim src/Makefile
CPPFLAGS += $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
ifeq ($(BUILD_TYPE_DEBUG),1)
CXXFLAGS_OPTIMIZE ?=  -no-pie -O0 -g
else
CXXFLAGS_OPTIMIZE ?= -no-pie -O2
endif

报错2:

home/ubuntu/upx/process/upx-3.94/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); }
    }

参考https://www.cnblogs.com/oloroso/p/6377807.html

https://blog.csdn.net/sunyoop/article/details/78301268

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值