Loading and Executing Object Code at Runtime

Michael Meissner meissner at osf.org
Mon Feb 18 08:47:51 AEST 1991


In article <1991Feb16.163527.25147 at virtech.uucp> cpcahil at virtech.uucp
(Conor P. Cahill) writes:

| Obviously you cannot execute data since it probably doesn't make much
| sense as a stream of instructions.  However, if you copied a function from
| code to data space and then branched throught a pointer to that data area,
| it does work.  So you can execute from data space.  This works on ISC UNIX,
| Bell Tech UNIX, Sun OS and several other OS's.  I don't have SCO lying
| around to try, but I would bet that it does in fact work.

This doesn't always work.  On 88k systems, the 88Open standard
mandates that sections with execute access enabled do not have write
access enabled and reverse holds as well.  You have to do a system
call (memctl) to change access modes.  The reason for this is the fact
that the 88k is a 'Harvard' architecture, and has separate caches for
instructions and data.  Thus, even if you can write into an area and
jump to it, the cache may contain invalid data/instructions, because
it has no idea the memory changed underneath it.....

Another potential problem is PC-relative addressing.  If you move a
code fragment that refers to an external/static memory address, the
code fragment in the new location will reference a different piece of
memory.
--
Michael Meissner	email: meissner at osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Considering the flames and intolerance, shouldn't USENET be spelled ABUSENET?



More information about the Comp.unix.internals mailing list