Does UPX magically transform binaries from dynamically linked into statically linked libarires?

1.2k views Asked by At

I'm trying to build a qt-based software with static libraries on gnu/linux amd64 without success (qt is successfuly statically built).

Now i see that some people are using UPX. So i tried on a dynamic built and, indeed, the 'file' command recognizes the binary as statically linked. Can I trust it ? Should i consider using statifier instead ?

Thanks in advance

edit

Sorry, i was not clear enough. I'm trying to build an application using the QT framework, but the building script is complex and is made for shared libraries. I am able to build the application in a binary dynamically linked, it's, working, but i would like to get a binary with static linked libraries. I tried the UPX software (http://upx.sourceforge.net/) as i saw on other topics that it was used in order to transform a binary with dynamic libraries into a binary with static libraries.

But it seems too magic for me, is it really working or is it just hiding some stuff and linux thinks the binary is now statically linked ?

Thanks for your answers.

1

There are 1 answers

0
tux3 On

No, UPX doesn't transform a dynamically linked progam into a staticaly linked one.

UPX is a packer for executables. It won't make your program statically linked because that would actually increase its size where the goal of UPX is to compress.

However due to the way UPX works tools like file will just see a small statically linked stub. This is UPX's decompression routine.

When you start a program compressed with UPX, this stub is what will run first (instead of the normal main function of your program). The stub itself is statically linked, but it will then decompress your program, load the dynamic libraries for your program, and start it normally. Thus you still need the dynamic librarires to be there or your program will not be loaded correctly after being decompressed.

So as you might have guessed, it's not actually magic, it's just hiding some things to keep the size down. You should consider opening another question if you still have problems with those other libraries.