Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UPX NotCompressibleException

Tags:

upx

I recently do some study about executable compression. When compile the test.c C language source and compress it with UPX in Linux not windows. It is list in Terminal: UPX: test.so NotCompressibleException. The source code of test.c is:

int main(){
    int i = 0;
    printf("HelloWorld\n");
    return 0;
}

What am I guessing is that the executable file is too simple to compress? Or may be I missed something? If there is anyone know about this issue, Please tell me the reason. If nobody tell me I have to read source code to find out the issue. Ah! reading source code burden.

like image 844
QianBin Piao Avatar asked Sep 23 '12 13:09

QianBin Piao


1 Answers

There are several reasons to output a NotCompressibleException, but in your case it is simply because the size of your binary is too small. UPX cannot handle binaries under 40Kb.

The best way to workaround this problem is to compile your binary in static mode, in order to get a bigger executable file. So, just try: gcc -static -o mytest mytest.c and then upx -o mytest-upx mytest.

like image 184
perror Avatar answered Sep 21 '22 15:09

perror