Microsoft KB Archive/83082

{|
 * width="100%"|

Segments Created By the C Run Time

 * }

Q83082

-

The information in this article applies to:


 * The C Run-Time (CRT), included with:
 * Microsoft C for MS-DOS, versions 6.0, 6.0a, and 6.0ax
 * Microsoft C for OS/2, versions 6.0 and 6.0a
 * Microsoft C/C++ for MS-DOS, version 7.0
 * Microsoft Visual C++, versions 1.0, 1.5

-

SUMMARY
The following is a summary of many of the segments created by the C run-time library for Microsoft C versions 6.0, 6.0a, 6.0ax, C/C++ version 7.0, and Visual C/C++ version 1.0. Some of these segments are reserved for internal use and their implementation may be subject to change. The segments do vary slightly between MS-DOS, Windows, and OS/2. More detailed information can be obtained through the study of the C startup source provided with the product.

Kevin J. Goodman also covers some of this information in his article &quot;A Comprehensive Examination of the Microsoft C Version 6.0 Startup Code,&quot; which can be found in the January 1992 issue of the &quot;Microsoft Systems Journal&quot; (Volume 7, number 1).

  Name          Class    Description =================================================================

_TEXT        CODE     Contains C run time; code segment with /AS /AM &lt;Module&gt;_TEXT CODE    Code segment for each module with /AC /AL /AH EMULATOR_TEXT CODE    Code segment for x87 math emulator ---  C_ETEXT       ENDCODE  Indicates the end of the CODE segments ---  NULL          BEGDATA  Beginning of the DATA segments ---  _DATA         DATA     Initialized global &amp; static data, /GT not used CDATA        DATA     Used to share data between float &amp; standard libraries DBDATA       DATA     Used for debug data for QuickC XIQC         DATA     Initialization/termination segment for QuickC XIFB         DATA     Initialization/termination segment XIF          DATA                  &quot; XIFE         DATA                  &quot; XIFCB        DATA                  &quot;    (C/C++ 7.0) XIFC         DATA                  &quot;    (C/C++ 7.0) XIFCE        DATA                  &quot;    (C/C++ 7.0) XIFM         DATA                  &quot;    (C/C++ 7.0) XIFU         DATA                  &quot;    (C/C++ 7.0) XIB          DATA                  &quot; XI           DATA                  &quot; XIE          DATA                  &quot; XPB          DATA                  &quot; XP           DATA                  &quot; XPE          DATA                  &quot; XCB          DATA                  &quot; XC           DATA                  &quot; XCE          DATA                  &quot; XCFB         DATA                  &quot; XCF          DATA                  &quot; XCFE         DATA                  &quot; ---  CONST         CONST    FP and integer constants; far data seg values ---  _BSS          BSS      Uninitialized static data XOB          BSS      Initialization/termination segment XO           BSS                   &quot; XOE          BSS                   &quot; C_COMMON     BSS      Uninitialized global data with /AS, /AM ---  HDR           MSG      Message text segment MSG          MSG                   &quot; PAD          MSG                   &quot; EPAD         MSG                   &quot; ---  STACK         STACK    Local data and parameters ---  EMULATOR_DATA FAR_DATA Data segment for x87 math emulator FAR_DATA     FAR_DATA Initialized global &amp; static, /Gt or _far used Uninitialized static data, _far used ---  FAR_BSS       FAR_BSS  Uninitialized global data, /AC,/AL,/AH, _far ---

MORE INFORMATION
Segment CDATA is used to share data between the floating-point portion of the C run-time library and the standard portion of the library. Support for floating-point math will be loaded only if your program uses floating-point variables. This procedure is used to keep the size of the executable file as small as possible.

The initialization and termination routines are grouped in threes as follows:

  XIB     &quot;B&quot; for beginning segment XI            middle segment XIE    &quot;E&quot; for ending segment These routines contain pointers to routines that the C run-time library calls at either startup or termination. Contributions are made to these segments at link time so that you only get routines that you need. For example, if you use standard input/output (stdio) routines, you will get a pointer to the &quot;flushall&quot; routine stored in an ending segment. A label is put in a beginning segment (for example, &quot;start&quot; in XIB) and one in the ending segment (for example, &quot;end&quot; in XIE). At startup/termination, the code walks the table from &quot;start&quot; to &quot;end&quot; and calls any routine whose pointer is stored in the middle segment (that is, XI).

Contributions to the message text segments are also made at link time. Therefore, you get only the message text that your program might need. One example of the text contained here is the C run-time fatal error messages (R6XXX).

The C run-time library also creates the default data segment, DGROUP, which is composed of the above segments with class BEGDATA, DATA, CONST, MSG, BSS, and STACK. Segments that did not receive contributions will be zero length and won't take up any space in the executable file. The remainder of the 64K segment is the near heap and is used for dynamic allocation with _nmalloc and _ncalloc.

Additional query words: kbinf 6.00 6.00a 6.00ax 7.00 1.00 1.50

Keywords : kb16bitonly

Issue type :

Technology : kbVCsearch kbAudDeveloper kbCRT