Microsoft KB Archive/70934

PRB: Module Definition (DEF) File Documentation Errors ID Number: Q70934

3.00 WINDOWS docerr

Summary:

Chapter 10 in the “Microsoft Windows Software Development Kit Reference” manual discusses module definition (DEF) files. The information below discusses two areas of that chapter and clarifies some misconceptions.

More Information:

Each Windows application and dynamic-link library (DLL) must have a module definition file. The DEF file is used by the linker when it creates the executable image (EXE or DLL) file. The DEF file specifies the sizes for the application’s stack and heap segments, and the desired attributes for code and data segments.

The errors in the documentation relate to defining the default attributes for CODE and DATA segments. The following information uses the CODE statement and code segments as an example; however, analogous rules apply to the DATA statement and data segments.

The CODE statement declares segment attributes for all code segments, not specifically the _TEXT segment, as stated on page 10-2 of the “Microsoft Windows Software Development Kit Reference” manual.

Microsoft has confirmed this to be a documentation error on page 10-2 of the “Microsoft Windows Software Development Kit Reference” manual. We will post new information here once this error has been corrected.

Because all code segments acquire the attributes specified in the CODE statement, the SEGMENTS statement is not required to provide attributes for other code segments. The CODE statement is required because Windows does not assign any default attributes to code segments. The requirement for the SEGMENTS statement can be inferred from the “Comments” section on page 10-2 of the “Microsoft Windows Software Development Kit Reference” manual.

Microsoft has confirmed this to be a documentation error on page 10-2 of the “Microsoft Windows Software Development Kit Reference” manual. We will post new information here once this error has been corrected.

The following is an example of the CODE and SEGMENTS statements for a standard DEF file:

CODE MOVEABLE PRELOAD DISCARDABLE SEGMENTS TEST_TEXT NONDISCARDABLE OTHER_TEXT LOADONCALL NONDISCARDABLE

In this example, all segments are given the attributes of MOVEABLE, PRELOAD, and DISCARDABLE. The SEGMENTS statement then overrides some of the attributes for the TEST_TEXT and OTHER_TEXT segments. The final attributes are:

Segment Name Attributes ———— ———-

TEST_TEXT MOVEABLE PRELOAD NONDISCARDABLE

OTHER_TEXT MOVEABLE LOADONCALL NONDISCARDABLE

All others MOVEABLE PRELOAD DISCARDABLE

For more information, see pages 33-42 in the “Microsoft C Reference” for version 6.0.