Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!mordor!sri-spam!rutgers!mit-eddie!uw-beaver!apollo!mrst!sdti!mjy From: mjy@sdti.UUCP (Michael J. Young) Newsgroups: comp.unix.wizards Subject: Re: Aliasing text and data segments of a process Message-ID: <208@sdti.UUCP> Date: 1 Feb 88 18:52:00 GMT References: <202@sdti.UUCP> <730@umbc3.UMD.EDU> <7156@brl-smoke.ARPA> <452@minya.UUCP> <246@vcvax1.UUCP> Reply-To: mjy@sdti.UUCP (0000-Michael J. Young) Organization: Software Development Technologies, Sudbury MA Lines: 34 In article <246@vcvax1.UUCP> naren@vcvax1.UUCP (naren) writes: > Doug Gwyn is right about architectures that enforce distinctions >between code and data spaces (ex: 80386). On UNIX/386, an sbrk() allocates >space in the Data Segment of the process. Type casting this pointer and >issuing a 'call' to this address will result in a protection exception. This happens on many other 80x86 ports as well. Microport (the only 286 port I'm familiar with) enforces separation between text and data regions as well. Unfortunately, they don't seem to provide ld(1) options to override the protection. I received an email reply from T. Andrews, who said that Xenix/286 provides a service and an ld(1) option to support this, but I have no personal experience with it. > Now, if you REALLY want to do this, you could write a new system call >like mktext(vaddr, length) where vaddr is the start of the data space >you would like to fill in with code. mktext() would just create a new code >segment descriptor in the LDT of your task that includes the desired >section of data space and then you'd be all set. > I am of course leaving out a lot of the nitty-gritty details of >how this feature would interact with other things like shared texts, etc. ... and where to get the money to buy a source license! :-) Seriously, though. It seems to me that any implementation of Unix that enforces separation should also provide a means around it, preferably in a portable manner. Does POSIX address this issue? On systems that enforce separation of text and data, with no means of "turning it off", it seems you are forced into using exec(2). Can you imagine trying to implement an incremental compiler where each new function you create has to have its own a.out and be its own process? -- Mike Young - Software Development Technologies, Inc., Sudbury MA 01776 UUCP : {decvax,harvard,linus,mit-eddie}!necntc!necis!mrst!sdti!mjy Internet : mjy%sdti.uucp@harvard.harvard.edu Tel: +1 617 443 5779