Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!rutgers!super.upenn.edu!linc.cis.upenn.edu!david From: david@linc.cis.upenn.edu (David Feldman) Newsgroups: comp.unix.wizards Subject: Re: Aliasing text and data segments of a process Message-ID: <3106@super.upenn.edu> Date: 21 Jan 88 20:01:27 GMT References: <202@sdti.UUCP> Sender: news@super.upenn.edu Reply-To: david@linc.cis.upenn.edu.UUCP (David Feldman) Distribution: na Organization: University of Pennsylvania Lines: 17 Keywords: Ultrix Summary: yes, but... You can execute out of the data segment, at least on SOME Unix systems. In Ultrix, you can tell the loader to make the code "IMPURE", although with cc you usually get demand paged pure executables unless you specify the right option for ld. You can also execute code out of the stack, of course, and if you catch signals you are forced to do this. On receiving a signal, Ultrix inserts a segment of code above the stack in the stack space - on a VAX at least. This code is the infamous 'sigtramp'. So, yes, a program can be modified while it is running. As an aside, I had planned on writing a machine simulator which executed code out of a malloc'ed memory space. I never started the project, but I was able to get some assembly running that jumped into a malloc space and then out again. I would assume that any Unix running on a machine that does not enforce separate I & D could do this. Check the manual page for ld. Dave F. david@linc.cis.upenn.edu