To make this possible, there are huge security vulnerabilities, which is why it is strictly prohibited in any reasonable environment. Newer Linux in particular (and much more on x86_64) strictly separates executable memory areas from mutable areas. In addition, modern processors do not voluntarily respond to code changes outside their caches, etc. Perhaps the next will be the dynamic loading of shared libraries.
This type of operation is part of the work of most scripting languages such as Perl or Python.
source
share