Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!spool.mu.edu!think.com!paperboy!meissner From: meissner@osf.org (Michael Meissner) Newsgroups: comp.unix.internals Subject: Re: Loading and Executing Object Code at Runtime Message-ID: Date: 17 Feb 91 21:47:51 GMT References: <1991Feb14.182925.15793@mtxinu.COM> <6073@auspex.auspex.com> <1991Feb16.100946.601@kithrup.COM> <1991Feb16.163527.25147@virtech.uucp> Sender: news@OSF.ORG Organization: Open Software Foundation Lines: 28 In-reply-to: cpcahil@virtech.uucp's message of 16 Feb 91 16:35:27 GMT In article <1991Feb16.163527.25147@virtech.uucp> cpcahil@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@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?