To specify the attributes of each code segment, you must add segment definitions to the module-definition file. This means you must add a SEGMENTS statement to the file and list each segment by name in the application. After you have made the changes, the module-definition file should look like this:
NAME Memory
DESCRIPTION 'Sample Microsoft Windows 3.1 Application'
EXETYPE WINDOWS
STUB 'WINSTUB.EXE'
SEGMENTS
MEMORY_MAIN PRELOAD MOVEABLE
MEMORY_INIT LOADONCALL MOVEABLE DISCARDABLE
MEMORY_WNDPROC LOADONCALL MOVEABLE
MEMORY_ABOUT LOADONCALL MOVEABLE DISCARDABLE
CODE MOVEABLE DISCARDABLE
DATA MOVEABLE MULTIPLE
HEAPSIZE 1024
STACKSIZE 8192
EXPORTS
MainWndProc @1
About @2
In this module-definition file, the SEGMENTS statement defines the attributes of each segment:
The MEMORY_MAIN segment contains WinMain.
The MEMORY_INIT segment contains the initialization functions.
The MEMORY_WNDPROC segment contains the window procedure.
The MEMORY_ABOUT segment contains the dialog box procedure.
Each segment has the MOVEABLE attribute, but only MEMORY_INIT and MEMORY_ABOUT have the DISCARDABLE attribute. Also, only the MEMORY_MAIN segment is loaded when the application starts. The other segments have the LOADONCALL attribute, which means they are loaded when needed.
Although each segment is explicitly defined, the CODE statement is still given. This statement specifies the attributes of any additional segments the linker may add to the application—for example, any segments containing C run-time functions called in the application source files.