12.2 Image File Background

Gforth consists not only of primitives (in the engine), but also of definitions written in Forth. Since the Forth compiler itself belongs to those definitions, it is not possible to start the system with the engine and the Forth source alone. Therefore we provide the Forth code as an image file in nearly executable form: Integers, strings etc. are represented as-is, data addresses in in relocatable form (section index and offset from the start of the section), and tokens (integers) for code addresses of primitives.

When Gforth starts up, a C routine loads the image file into memory, relocates the addresses and generates native code for the primitive invocations and replaces the tokens with code addresses of this native code (or of the code for the primitives in the engine), then sets up the memory (stacks etc.) according to information in the image file, and (finally) starts executing Forth code.

The default image file is gforth.fi (in the GFORTHPATH). You can use a different image by using the -i, --image-file or --appl-image options (see Invoking Gforth), e.g.:

gforth-fast -i myimage.fi

Gforth image files have several limitations:


Footnotes

(36)

In my opinion, though, you should think thrice before using a doubly-linked list (whatever implementation).