Re: [OT] Debugger protection (was: Implementing Licensing ...)
Re: [OT] Debugger protection (was: Implementing Licensing ...)
- Subject: Re: [OT] Debugger protection (was: Implementing Licensing ...)
- From: Allan Odgaard <email@hidden>
- Date: Thu, 8 Apr 2004 23:33:19 +0200
On 8. Apr 2004, at 21:55, Howard Jones wrote:
Self-modifying code would of cause not be very good for non-x86
platforms.
Why is that? I don't see any reasons (aside from the obvious
horribleness of it) why it's an x86 specific thing... It was certainly
a fairly common thing to do back in my 68000 days.
The technical reason is that there is a separate data and code cache
(called a Harvard architecture AFAIK), so if you overwrite some of the
instructions, the changes will not take effect if these were in the
code cache (as the changes are made to the data cache) and/or if there
is no write-through.
It worked for the 68000 because the cache was either very small or
non-existent (I think it cached one instruction so only single line
loops would benefit) -- on the 68020 it would not work unless you
explicitly flushed the cache.
In some operation systems self-modifying code is not allowed by (an
enforced) convention, so memory pages are either set to be writable or
executable, but cannot be both. This is to prevent buffer overruns from
executing malicious code or similar.
I do not know the details about the x86, but have on several occasions
seen references to how it allowed self-modifying code -- wether it
allows it w/o a cache flush I do not know, but that was my
understanding (and thus this "allowance" has later been yet another
perplexing element for Intel and AMD to work with).
Of cause the PPC do allow self-modifying code on some level, as it
loads code from disk into memory, applies relocation etc. -- but
changing your own program on-the-fly will most likely fail to work
unless you flush caches, which will affect the performance
significantly.
** Cocoa FAQ: <
http://www.alastairs-place.net/cocoa/faq.txt> **
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.