#include <stdinc.h>#include <loadobj.h>void loadobj(string pathname)proc findfn(string fname)void mysymbols(string progname) DescriptionThese routines provide a uniform low-level I/O interface to loading object modules. Higher level I/O interfaces are present for a few standard operations (see e.g. potential(3NEMO) and bodytrans(3NEMO)). These routines are intended for applications where a set of mathematical expressions is specified at runtime as function strings, which are then evaluated for a large number of variable values. This is done by compiling the set of function strings into byte code sequences, which can be interpreted very efficiently for the various variable values. The routine mysymbols is generally called once and in the beginning of the program. It loads all symbols from the program pointed to by the argument progname, which is normally the current program. These symbols are then stored in an internally defined symbol tree symtree. In case progname is not the complete name, the PATH environment variable is used (see pathopen(3NEMO)). The undefined symbols in each object module that is loaded with loadobj are resolved against the already existing symbol tree, and new symbols are added to the tree. If a symbol is not found to be resolved, this is considered an error, and error(3NEMO) is called, which aborts the program. In addition the code loaded into memory is properly relocated using information in the object code. The argument pathname must be the proper filename, no search path is provided for. After all symbols have been defined, the programmer can obtain pointers to functions which is specified by name using findfn. ExampleIn the following section of code gives an example of use. proc fn; /* see defs in <stdinc.h> */ mysymbols(getparam("argv0")); /* get local symbols */ loadobj("test.o"); /* load object code */ fn = (proc) findfn("_test"); /* find function */ if (fn==NULL) error("No test"); /* catch error */ (*fn)(); /* execute routine test() in test.o */
~/src/kernel/loadobj loadobj.c, loadobj*.cMuch like yapp(3NEMO) , different implementations exist for different operating systems.
23-jul-90 created PJT 6-nov-91 slight doc improvements; loadobjNEXT.c PJT 30-jun-03 documented mach’s dyld PJT
Table of Contents