The format of the machine language executable file is based on hard offsets, and not on parsing a byte stream (for example, the text source code of a program). When you insert a byte somewhere, the file format continues to refer to the information that follows the insertion point at the original offsets.
Offsets can occur in the file format itself, such as a header that tells the loader where things are in the file and how big they are.
Hard offsets are also found in the machine language itself, for example, in instructions that relate to program data or branch instructions.
Suppose the instruction says โbranch 200 bytes down from where we are nowโ and you insert bytes into these 200 bytes (because there is a character string that you want to change). Unfortunately, the branch still spans 200 bytes.
On some machines, the branch may not even be 201 bytes, even if you fixed it, because it will be biased and will throw a CPU exception; you will have to add, say, four bytes to fix it up to 204 (along with many other things necessary to ensure the file is correct).
source share