Malware and packers do this with overlap between them. Let's say you have a 10MB executable, you can pack it to be a lot less. Tamper protection is also another, VMProtect is the packer I run into in that area where it tries hard to detect if it is inside a VM before self modifying and unpacking.