execve() of in-memory data

John Reiser jreiser@BitWagon.com
Sun Feb 1 20:03:00 GMT 2004


Brian Blietz <bblietz@iastate.edu> wrote:
[Subject: Re: use alternate stack, or the heap for local function variables]
> Is there any way for an application to open a file,
> copy it to RAM and then execute the copy in RAM,
> instead of the one on disk?

No.  Most operating systems, including the Single Unix Specification,
contain no "exec immediate" functionality which treats an array
as [a copy of the contents of] a file to be executed.  You can
write a new file from the RAM array, and then execve() the new file.
Or, you can arrange your own address space just like execve() would;
but on most *NIX-like systems execve() is the only way to set the
value which will be returned later by brk(0).  Example code which
does its own substitute for execve() can be found in
http://cvs.sourceforge.net/viewcvs.py/upx/cvsroot-upx/src/stub/l_lx_elf.c
and related files.

-- 




More information about the Libc-alpha mailing list