Chapter Contents

Previous

Next
Prelinking C and C++ Programs

The cool Prelinker

The cool utility program is an object code preprocessor that assists in the link-editing of C and C++ programs. cool merges initialization CSECTs for static and external variables; the IBM linkage editor does not have this capability. When the -Krent or -Krentext compiler option is used to allow reentrant modification of data, the compiler creates a separate CSECT to contain the external variable initialization data for each compilation. Data to be used for the initialization of external variables are read during program start-up and copied to dynamically allocated memory. This copy process is necessary to support reentrant execution. (If no external variables are initialized in a compilation, then the CSECT is not created. When the -Krent option is used, this applies to static as well as external variables.)

If more than one compilation initializes external variables, then all of the initialization CSECTs must be merged before the program can be linked. If they are not combined, the linkage editor ignores all but the first compilation's data since they all have the same CSECT name. Therefore, some initializations would be skipped during execution, with unpredictable results.

The cool utility merges this initialization data by combining all of the object code for a given program in a manner similar to the CMS loader or OS/390 linkage editor. If any of the object files contain an initialization CSECT, cool retains the initialization data and then deletes the CSECT from the object file. When all of the object files are processed, cool produces a single object file containing one copy of the initialization CSECT, followed by the preprocessed object files.

The cool utility also checks for external variables with multiple initial values during the merge. cool issues a warning for external variables with multiple initial values.

When the use of extended names is specified by the -Kextname compiler option, cool performs additional preprocessing. Under the -Kextname option, the compiler creates special data objects in the object file that contains the original C or C++ identifiers and their associated short forms. The cool utility reads these data objects and then creates unique external symbols in the output object file, thus enabling the linkage editor or loader to properly link the output object file by using these unique external symbols.

Note the following:


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.