Aliasing text and data segments of a process

Michael J. Young mjy at sdti.UUCP
Tue Feb 2 04:52:00 AEST 1988


In article <246 at vcvax1.UUCP> naren at 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 at harvard.harvard.edu      Tel: +1 617 443 5779



More information about the Comp.unix.wizards mailing list