Chapter Contents

Previous

Next
Linking C Programs

Linking Programs under CMS

The CMS LOAD command is limited in the number and size of pseudoregisters it can handle. The number and length of the pseudoregisters are directly related to the number and size of external variables in the program. For example, an external int array with 1000 elements causes a pseudoregister to be created that is 1000*sizeof(int) , or 4000 bytes long. C programs that have been compiled with the rent or rentext options may, in some cases, produce too many pseudoregisters or the cumulative length of the pseudoregisters may be too large for the LOAD command to process.

The CMS LOAD command cannot process pseudoregisters that have a cumulative length of more than 4K. If this length is exceeded, the LOAD command does not necessarily produce an error message. You can diagnose this situation in a MODULE by examining the LOAD MAP after the GENMOD command has completed. The pseudoregister addresses listed in the VALUE column should always be in increasing order. If they are not, the maximum cumulative length is exceeded.

The maximum number of pseudoregisters that the CMS LOAD command can handle is indeterminate. The LOAD command typically issues the following error message if the number is exceeded:

DMSLIO168S: PSEUDO-REGISTER TABLE OVERFLOW

COOL performs pseudoregister removal; it does not affect program execution or reentrancy in any way. The noprem option suppresses this function. The COOL output file, COOL370 TEXT, may not be reprocessed by COOL unless the noprem option has been used.


The COOL EXEC

The COOL EXEC invokes the COOL object code preprocessor and can optionally invoke the CMS LOAD, START, GENMOD, or LKED command. The format is as follows:

COOL  [filename1  [filename2 ...]]  [(options [)]]

where filename1, filename2, and so on are the names of the files that are to be the primary input to COOL. Each file should have a filetype of TEXT and contain either object code or COOL/linkage editor control statements. (INCLUDE statements are an example of control statements, as discussed later in this chapter.) If no filenames are specified, COOL prompts for the name of a primary input file. At the prompt, enter a filename. COOL continues to prompt until a null line is entered.

Before invoking COOL, issue the CMS command GLOBAL TXTLIB for any TEXT libraries that COOL should use for autocall resolution. For standard C programs, LC370BAS TXTLIB and LC370STD TXTLIB should be GLOBALed before invoking COOL for any program.

The RESET option

The CMS LOAD command may not select the correct entry point for your program. It is usually best to use the RESET option of the LOAD command to specify the entry point explicitly. If the main function is the C main function and you are using the normal C entry point, specify RESET MAIN. If you are using the LKED command to link the program, use the ENTRY control statement to specify MAIN as the entry point.

The CMS GENMOD command may not save all of the CSECTs in the program, especially if you use RESET to specify an entry point. Use the FROM option of the GENMOD command to specify the name of the initial CSECT. This name can be found by reading the LOAD MAP file produced by the LOAD command.

See Specifying the Correct Entry Point for additional information on defining an entry point.


COOL Listing Output

A number of COOL options, such as list , prmap , and enxref , cause output to be written to the COOL listing file. By default, the COOL listing file is named COOL370 COOLLIST. The print option may be used to direct the listing to a different file.


Linking All-Resident Programs

The all-resident library is LCARES TXTLIB. To link an all-resident program as a MODULE, issue the CMS GLOBAL TXTLIB command, naming LCARES before LC370STD and LC370BAS (the normal resident library), and then invoke COOL. For example, suppose a program is made up of three TEXT files, MAINPROG, SUB1, and SUB2, and autocalled routines are in MYLIB TXTLIB. The MODULE can be created with the following commands:

GLOBAL TXTLIB MYLIB LC370STD LC370BAS
COOL MAINPROG SUB1 SUB2 (GENMOD TESTPROG

Note:    See All-Resident C Programs for information on how to modify the source of an existing program to exploit the all-resident library.  [cautionend]

The CMS LOAD command may issue the following message:

DMSLIO116S LOADER TABLE OVERFLOW

This indicates that there are insufficient virtual machine loader tables to contain the symbols in the TEXT files. Use the CMS command SET LDRTBLS nn, where nn is an integer greater than 3, to define additional loader tables. In order to ensure that the loader tables are allocated successfully, this command should be issued immediately after IPL. Refer to the CMS Command Reference for more information about the SET LDRTBLS command.


Chapter Contents

Previous

Next

Top of Page

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