executing a stream

Casper H.S. Dik casper at fwi.uva.nl
Thu Jan 17 20:27:10 AEST 1991


barmar at think.com (Barry Margolin) writes:

>In article <1991Jan15.204849 at IASTATE.EDU> spam at IASTATE.EDU (Begley Michael L) writes:
>>   uncompress -c microemacs|execute   /* uncompress microemacs.Z     */
>>                                      /* into a stream, and execute  */

>>I've been told that it can't be done because of swapping...
>>Can anyone help?

>It's doable, but not trivial.  Basically, the execute command would have to
>duplicate the functionality of the kernel's exec*() system calls.  It could
>fork a process, and then use something like ptrace() to initialize the
>process from the contents of stdin.  It would have to recognize all the
>appropriate magic numbers, parse executable file headers, locate all the
>sections of the input stream (text, bss, data), perhaps fill in the user
>data structure with something more useful than "execute", fill in argv,
>argc, hardware registers, and set the PC so that execution begins at the
>appropriate place.  I don't think it can be written portably.

In SunOS 4.x, you could make execute position independent and create the
image using mmap, after relocating the code of execute.
Then you jump to the entry point.

I have one problem with this program: what should the new executable have
for stdin?
--
NOTE: Some machine instructions			|	Casper H.S. Dik
      must be executed on the CPU.		|	casper at fwi.uva.nl
(a manual page on the Gould PowerNode)		|	NIC: !cd151



More information about the Comp.unix.internals mailing list