>>>> "Dwight" == Dwight K Elvey
<dwight.elvey(a)amd.com> writes:
Dwight> Hi It is interesting that different people have different
Dwight> ideas as to what self modifying code is. Actually, the
Dwight> ability to load code and execute from a mass storage is self
Dwight> modifying.
Indeed.
Dwight> Code that uses a variable value for a table to
Dwight> look up execution addresses is self modifying.
Not as the term is usually used. You're changing a pointer, and
pointers are data. Ask yourself "do I have to flush the I-cache for
this to work?" The answer in this case is NO.
Dwight> Most every
Dwight> multitasking system I've seen are self modifying. I think
Dwight> what people consider dangerous self modifying is when the
Dwight> program alters the actual execution instructions in memory
Dwight> and then executes them. It is strange that this form gets
Dwight> such a large amount of emotional negative response while
Dwight> other types are hardly considered issues. No matter how the
Dwight> code is written, one can make bad code in most any form.
True.
Part of the issue, for modern machines, is that the hardware gets in
the way. If you change code, the I-cache doesn't change (in machines
I'm familiar with) so the old instruction may still execute. This
makes instruction modification a tricky business. Debuggers do it,
operating systems do it -- and both have to pay attention to all the
cache magic you have to perform for it to be right.
paul