Do you mean like this?
Basically, UPX replaces your executable with the UPX executable and places your executable as a block at the end of the UPX executable file, which it then decompresses.
This produces a number of problems:
• You need to make sure to modify the UPX info block to represent your application.
• On Windows, at least, you must have a disk lock to execute code.
That is, the executable parts must be duplicated to disk, when you could just decompress only the data you want to memory.
• UPX these days can handle file signing, but it is still a bit clunky (to my mind, at least)
• Reducing file size is really only an issue for two reasons:
○ Limited disk space
For transmission, just 7zip the file. For limited disk space, UPX requires more
to unpack and execute your executable.
• Multiple instances are unique — they do not share the base image file lock.
• UPXers don’t like this, but UPX executables are still
routinely tagged as malware by AV scanners.
• Cross-platform, it necessarily behaves differently to work.
My preference is skip any wrapper overhead. It is easy to pack a resource in the executable cross-platform that you can then decompress to memory (or file, or whatever). You can still sign your executable and adjust its info header — all unique to your actual executable and not hijacked by the UPX executable and therefore winding up in some AV database as (not) your code.
Anyway, those are my quick thoughts. I may have missed something...