UPX NotCompressibleException

upx
QianBin Piao picture QianBin Piao · Sep 23, 2012 · Viewed 8.8k times · Source

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.

Answer

perror picture perror · Nov 7, 2012

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.