Path: utzoo!utgpu!water!watmath!clyde!rutgers!umd5!brl-adm!husc6!sri-unix!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.arch Subject: Re: self-modifying code Message-ID: <674@cresswell.quintus.UUCP> Date: 22 Feb 88 03:10:00 GMT References: <486@taux01.UUCP> <666@cresswell.quintus.UUCP> <815@spar.SPAR.SLB.COM> <2169@bsu-cs.UUCP> Organization: Quintus Computer Systems, Mountain View, CA Lines: 29 In article <2169@bsu-cs.UUCP>, dhesi@bsu-cs.UUCP (Rahul Dhesi) writes: > [re: how to overcome the code versus data distinction] > For those implementors who wish to allow data to be safely treated as > code, I suggest a system call that will accept a range of memory > addresses and a request to change it from code to data or from data to > code. E.g.: > > #include > if (modech(startadd, endadd, TO_CODE) == -1) > error ("could not change data into code for execution"); > It won't work in a separate I&D machine. To start with, that range of data addresses may *already* be in use in the code space, or it may not be valid. (Imagine a machine where code space is negative and data space is positive.) Another thing that can go wrong is that, as on the B6700, code and data may be different *kinds* of address. If you can use the same addresses for code and data as Rahul Dhesi suggests, your problem is just an unco-operative operating systems. That's why I suggested "load this .obj file where you like, and tell me where you put it", because that *does* make sense in genuinely separate I&D machines. Of course it doesn't have to be a .obj file; the thing you hand to the kernel might be a chunk of data memory to copy, or for that matter a Postscript program to set individual bits (:-). The important thing is that it has to be a copy, because "separate I&D" means *separate*. An interesting point of dynamic *extension* of programs is that (if the code space allocator grain size is a multiple of the instruction cache entry size) you don't need to flush the instruction cache, because valid entries are still valid.