COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Figure 34 Internal and External References
When external references in two code blocks are resolved to entry points in each other, the two
code blocks are called “crossbound.” The system code block and the system library blocks are all
crossbound—a routine in any of these blocks can call a routine in any other of these blocks. The
blocks of a multiblock user code space are all crossbound, as are the blocks of user library space.
Linking
Linking is the operation of examining, collecting, and modifying code and data blocks from one
or more object files to produce a single object file. Two important aspects of linking a program
are:
Validating references to other programs or routines—determining whether the actual parameters
of the calling program or routine correspond to the formal parameters of the called program
or routine.
Resolving references to other programs or routines—generating the code that will transfer
control from the calling program or routine to the called program or routine at execution time.
A typical compilation resolves some references and leaves others unresolved. (In Figure 34, the
reference to program Y is resolved, and the reference to program Z is unresolved.)
Topics:
How the Compiler Validates and Resolves References
Unresolved References
How the Compiler Validates and Resolves References
The compiler translates each CALL statement and each ENTER statement in an HP COBOL source
program into an external reference. When the compiler generates an implicit call to a routine that
is to execute in another memory area, the parameters match those expected by the routine. When
you explicitly call a routine that is to execute in another memory area (with an ENTER or X/Open
CALL statement), the compiler must verify that the parameters in the ENTER or X/Open CALL
statement match those expected by the external routine. To verify this, the compiler searches for
the routine (and as Figure 35: How External References Are Resolved (page 815) illustrates):
If the ENTER or X/Open CALL statement identifies the file that contains the routine with a
mnemonic name, the compiler searches that file only. If the compiler does not find the routine
in that file, it reports an error.
If the compiler does not identify the file that contains the routine, it searches for the routine in
the files on the primary search list if one exists. (One or more SEARCH directives build the
primary search list; see Putting an Object File on the Primary Search List.)
814 Issues Related to Linking