Static linking mechanisms

Because object file formats vary widely by architecture, Mindy does not support dynamic loading of object files or automatic symbol table look up for all architectures. In the general case, it is necessary to depend upon a less elegant technique for explicitly making certain C objects available.

Simple instructions for using this mechanism from within Melange are given in the Section called Loading and Finding Objects. This section simply provides more information on the underlying mechanism.

In order to make sure that the desired symbols can be located, it is necessary to build an explicit table which maps between the symbol's name and its address. This table is automatically created by running the "make-init.pl" script [This requires you to have PERL installed on your system.] upon a list of "interface definition files". This will create two files ",extern1.def" and ",extern2.def", which should then be renamed to "extern1.def" and "extern2.def" respectively. These files are automatically included by "ext-init.c" so that the table will be created after Mindy is rebuilt.

The interface definition files consist of zero or more lines of text, each of which should contain the name of one object. If the object is a function, it should be immediately followed by a set of parentheses. For example, the file which defines the memory allocation routines used by Melange's support code contains the following four lines:

free()
malloc()
strcmp()
strlen()

The only other step required to make the objects available is simply to ensure that the library which contains them is linked into Mindy. The easiest way to accomplish all of this is to simply modify the Makefile in Mindy's source directory. If you add the names of the required libraries to LIBS and the names of the interface definition files to EXTERN-INCLUDES, make will do the necessary work for you. You should be sure to leave "../compat/libcompat.a" or "-lm" in LIBS and "malloc.inc" in EXTERN-INCLUDES.