Modernization Hub

Dynamic Linking

Runtime Connection
Enhanced Definition

Dynamic linking, in the mainframe context, is a mechanism where external program modules (subroutines, functions, or entire programs) are resolved and loaded into memory *during program execution* rather than being fully incorporated at the initial link-edit phase. This allows for greater flexibility, efficient resource sharing, and easier maintenance of large applications by deferring the binding of program components until they are actually needed.

Key Characteristics

    • Late Binding: The resolution of external references to other program modules occurs at runtime, just before or during the execution of the calling instruction (e.g., a CALL statement or EXEC CICS LINK).
    • Shared Modules: Enables multiple programs or different instances of the same program to share a single copy of a common module in memory, reducing overall memory consumption.
    • Flexibility and Maintainability: Allows individual modules to be updated, replaced, or added without requiring the re-link-editing of all calling programs, simplifying maintenance and deployment.
    • Reduced Load Module Size: The main program's load module is smaller as it does not contain the code for all its dependencies, only references to them.
    • Operating System/Subsystem Management: z/OS Program Management facilities (e.g., LOAD and DELETE macros) or subsystem-specific mechanisms (like CICS Program Control) handle the location and loading of these modules.
    • Search Order: Modules are typically located by searching specified load libraries (STEPLIB, JOBLIB, LINKLIST, DFHRPL for CICS) in a defined order.

Use Cases

    • CICS Program Control: CICS applications extensively use dynamic linking via EXEC CICS LINK PROGRAM(...) or EXEC CICS XCTL PROGRAM(...) to transfer control between programs, manage transaction flow, and share common business logic or utility modules.
    • COBOL CALL Statements: When a COBOL program uses a CALL statement (especially CALL identifier or CALL literal where the called program is not part of the same link-edit unit), z/OS dynamically loads the target program.
    • Shared Utility Routines: Common utility functions (e.g., date/time formatting, data validation, error logging) used across multiple applications can be implemented as dynamically linked modules.
    • Application Modularity: Breaking down large applications into smaller, manageable load modules that are loaded on demand, improving development and testing cycles.
    • Dynamic Feature Loading: Loading optional or rarely used application features only when a user requests them, optimizing initial application startup time and resource usage.

Related Concepts

Dynamic linking stands in contrast to static linking, where all program components are resolved and combined into a single executable load module during the link-edit process. Dynamically linked modules are stored as separate load modules or program objects in PDS or PDSE libraries. The Linkage Editor or Program Management Binder is used to create these individual modules, which are then located and loaded at runtime by z/OS Program Management or by specific subsystems like CICS or IMS using their respective program control facilities.

Best Practices:
  • Consistent Naming: Establish clear and consistent naming conventions for dynamically linked modules to improve readability and maintainability.
  • Library Management: Carefully manage the placement of dynamically linked modules in appropriate load libraries (STEPLIB, JOBLIB, LINKLIST, CICS DFHRPL) to ensure efficient resolution and avoid PROGRAM NOT FOUND errors.
  • Error Handling: Implement robust error handling for CALL statements or LINK commands (e.g., using ON EXCEPTION in COBOL or checking return codes) to gracefully manage scenarios where a target module might not be found.
  • Version Control: Maintain strict version control for dynamically linked modules to prevent compatibility issues when updating shared components.
  • Performance Considerations: While dynamic linking offers flexibility, be mindful of the potential (though often negligible) overhead associated with loading modules at runtime, especially for frequently called, small modules.
  • Security: Control access to the load libraries containing dynamically linked modules to prevent unauthorized modifications or injections.

Related Vendors

ASE

3 products

Boole and Babbage

4 products

Applied Software

7 products

Related Categories

Operating System

154 products

Monitor

262 products

Encryption

41 products

Files and Datasets

168 products