Re: Make sure of new instructions, support old processors.
Posted: Wed Jul 01, 2009 11:14 am
Hi Brendan,
In a hosted environment your points are valid, however my advice was aimed at being for an OS kernel; in which case noexecute has no effect, bugs and malicious code neither as you're in kernel mode - anything can be destroyed!
Your response seems to be based on the assumption that the OP is developing in a hosted environment. A scan-read didn't tell me this, maybe I missed something?IMHO using self modifying code (e.g. copying the best version of some code into a fixed location) is usually a bad idea - it means that your code needs to be writable and can be modified by bugs (e.g. uninitialized pointer) or malicious code (e.g. bad plugins or libraries). The overhead of modifying the code is often larger than the overhead of using function pointers and/or conditional branches (assuming function pointers and/or conditional branches are used sensibly). Worst case is if the OS supports memory mapped executable files; where unmodified pages are loaded from the file system if/when needed and can be freed at any time to save RAM. In this case modified pages would need to loaded from disk when they're modified, then sent to swap to reclaim the RAM, and then reloaded from swap if/when needed; which either means a lot more file I/O, or means that less RAM is left free for more important things.
In a hosted environment your points are valid, however my advice was aimed at being for an OS kernel; in which case noexecute has no effect, bugs and malicious code neither as you're in kernel mode - anything can be destroyed!