[comp.lang.c] making executables do tricks

bouma@cs.purdue.EDU (William J. Bouma) (03/26/90)

Please provide the unix calls to do the following:

1. State saving executable.

main()
{
    INTITIALIZATIONS;
    ...;
    savecore(filename);
    X;
    ...;
}

'savecore' should create an executable file which begins execution at
statement X and retains the state information from the INTITIALIZATIONS.
I realize that some state info could not be saved, (eg open file pointers),
but I am mainly interested in 'malloc'ed memory. Is it possible to save
the dynamically allocated memory in a binary?

2. Dynamic loading of functions.

main()
{
    ...;
    loadfile("func.o");
    exec_named_function("func", arg1, arg2);
    ...;
}

'loadfile' should make the functions in "func.o" accessible to the currently
running binary. 'exec_named_function' should find the function named "func"
and execute it like func(arg1, arg2).
-- 
Bill <bouma@cs.purdue.edu>  |  And don't forget my dog... "Astronomy" -- BOC

henry@utzoo.uucp (Henry Spencer) (03/27/90)

In article <10126@medusa.cs.purdue.edu> bouma@cs.purdue.EDU (William J. Bouma) writes:
>Please provide the unix calls to do the following:
>1. State saving executable.
>2. Dynamic loading of functions.

There are no standard Unix calls to do either of those jobs.  Number 2, in
particular, isn't always even possible, depending on the machine.
-- 
"Apparently IBM is not IBM    |     Henry Spencer at U of Toronto Zoology
compatible." -Andy Tanenbaum  | uunet!attcan!utzoo!henry henry@zoo.toronto.edu