Loading and Executing Object Code at Runtime

Tom Christiansen tchrist at convex.COM
Sat Feb 16 04:30:24 AEST 1991


>From the keyboard of uunet!bria!mike:
:If you're trying to do what it looks like you're trying to do, the answer
:is "you can't get there from here."  You would have open the object file,
:load the function within the context of the current process (a real trick),
:allocate the core for data, stack, and bbs, push the stack frame, and
:jump to the address of this arbitrary function.  Just ain't no way you
:can be doin' this in user mode.

Never say never.  It certainly is on some architectures.  Just malloc or
mmap in some pages as RWX, then load the position-independently compiled
functions in there from disk, and call through a function pointer.  There
are also overlay schemes available -- that's what I used to do on Z80
machines.  You could also use overlays on PDP-11's.

--tom
--
Tom Christiansen		tchrist at convex.com	convex!tchrist
 "All things are possible, but not all expedient."  (in life, UNIX, and perl)



More information about the Comp.unix.wizards mailing list