This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

execve() of in-memory data


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.

--



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]