13.14 The SEGMENTS Statement

The SEGMENTS statement defines the attributes of one or more individual segments in the application or DLL. The attributes specified for a specific segment override the defaults set in the CODE and DATA statements (except as noted below). The total number of segment definitions cannot exceed the number set using LINK's /SEG option. (The default without /SEG is 128.)

The SEGMENTS keyword marks the beginning of the segment definitions, where each definition is on its own line. The SEGMENTS statement must appear once before the first specification (on the same or preceding line) and can be repeated before each additional specification. SEGMENTS statements can appear more than once in the file.

Syntax

SEGMENTS
[[']]segmentname[[']] [[CLASS 'classname']] [[attribute...]]

Remarks

Each segment definition begins with segmentname, optionally enclosed in single or double quotation marks (' or "). The quotation marks are required if segmentname is a reserved word.

The CLASS keyword optionally specifies the class of the segment. Single or double quotation marks (' or ") are required around classname. If you do not use the CLASS argument, the linker assumes that the class is CODE.

This statement accepts several optional attribute fields: conforming, discard, executeonly, iopl, load, movable, readonly, and shared. Each can appear once, in any order. These fields are described in the next section, “CODE, DATA, and SEGMENTS Attributes.”

Example

The following example specifies segments named cseg1, cseg2, and dseg. The first segment is assigned the class mycode and the second is assigned CODE by default. Each segment is given different attributes.

SEGMENTS

cseg1 CLASS 'mycode' IOPL

cseg2 EXECUTEONLY PRELOAD CONFORMING

dseg CLASS 'data' LOADONCALL READONLY