Segments Created By the C Run Time

ID: Q83082


The information in this article applies to:


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 "A Comprehensive Examination of the Microsoft C Version 6.0 Startup Code," which can be found in the January 1992 issue of the "Microsoft Systems Journal" (Volume 7, number 1).


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

   _TEXT         CODE     Contains C run time; code segment with
                          /AS /AM
   <Module>_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 & static data,
                          /GT not used
   CDATA         DATA     Used to share data between float &
                          standard libraries
   DBDATA        DATA     Used for debug data for QuickC
   XIQC          DATA     Initialization/termination segment
                          for QuickC
   XIFB          DATA     Initialization/termination segment
   XIF           DATA                  "
   XIFE          DATA                  "
   XIFCB         DATA                  "    (C/C++ 7.0)
   XIFC          DATA                  "    (C/C++ 7.0)
   XIFCE         DATA                  "    (C/C++ 7.0)
   XIFM          DATA                  "    (C/C++ 7.0)
   XIFU          DATA                  "    (C/C++ 7.0)
   XIB           DATA                  "
   XI            DATA                  "
   XIE           DATA                  "
   XPB           DATA                  "
   XP            DATA                  "
   XPE           DATA                  "
   XCB           DATA                  "
   XC            DATA                  "
   XCE           DATA                  "
   XCFB          DATA                  "
   XCF           DATA                  "
   XCFE          DATA                  "
   -------------------------------------------------------------------
   CONST         CONST    FP and integer constants;
                          far data seg values
   -------------------------------------------------------------------
   _BSS          BSS      Uninitialized static data
   XOB           BSS      Initialization/termination segment
   XO            BSS                   "
   XOE           BSS                   "
   C_COMMON      BSS      Uninitialized global data with /AS, /AM
   -------------------------------------------------------------------
   HDR           MSG      Message text segment
   MSG           MSG                   "
   PAD           MSG                   "
   EPAD          MSG                   "
   -------------------------------------------------------------------
   STACK         STACK    Local data and parameters
   -------------------------------------------------------------------
   EMULATOR_DATA FAR_DATA Data segment for x87 math emulator
   FAR_DATA      FAR_DATA Initialized global & 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     "B" for beginning segment
    XI             middle segment
   XIE     "E" 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 "flushall" routine stored in an ending segment. A label is put in a beginning segment (for example, "start" in XIB) and one in the ending segment (for example, "end" in XIE). At startup/termination, the code walks the table from "start" to "end" 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 
Version           : 
Platform          : 
Issue type        : 

Last Reviewed: July 21, 1999