You need to be aware of the following when you write and compile a C program that will be overlaid:
An overlaid program must be in either a medium or large model. Only the medium and large combined libraries in C 7.0 contain the MOVE library. Code references in an overlaid program must be far.
An individual function can be assigned to an overlay independently from other functions in the same segment only if it is a “packaged function.” A packaged function is visible to the linker in the form of a COMDAT record. To compile a C function as a packaged function, use the /Gy option on the CL command line (or in the Microsoft Programmer's WorkBench, choose Enable Function Level Linking from the Additional Global Options dialog box, which is available from the C or C++ Compiler Options dialog boxes). In a C++ program, member functions are automatically packaged.
If an object file is compiled without /Gy, relocation information is not available to the linker. A function that is not packaged cannot be assigned to an overlay; however, the segment in which it resides can be placed in an overlay.
An explicitly allocated function is one that is assigned to a segment at compile time. Its behavior is described in “Creating the Module-Definition File”. The following methods of explicit allocation are available:
In C source code, the __based keyword (or its predecessor, the alloc_text pragma) specifies the segment where an individual function is to reside.
On the CL command line, the /NT option specifies the segment where all functions in an object file are to reside.
A function not explicitly allocated to a segment is sometimes referred to as an anonymous function. In programs compiled in medium and large models, anonymous functions are allocated to a segment that has a name in the form:
objfile_TEXT
where objfile is the name of the object file containing the functions.
The MOVE library provides several routines for use in advanced techniques of overlay programming. These routines are described in the MOVEAPI.TXT file distributed with Microsoft C version 7.0. Some uses of these routines are discussed in “Memory Allocation”.