Resolving Unresolved References in Callable Shared Objects

For programs compiled with the LITLINK Compiler directive, calls made using the COBOL syntax CALL "literal" produce a direct reference to literal. Any such references are tightly bound to any entry point of the same name, that is defined in a program specified on the cob line, when creating a callable shared object. Any direct reference to a name that does not have a corresponding entry point name, in any program specified when creating a callable shared object, is called an unresolved reference.

When a callable shared object is loaded at run time any unresolved references are resolved by the operating system dynamic linker using symbols in the system executable file, loaded shared libraries and any loaded callable shared objects. If any symbol remains unresolved then the callable shared object cannot be loaded and a load error results. On some platforms, one or any of the unresolved symbol names might also be listed.

To prevent a load error all unresolved references must be resolved when the callable shared object is created. This can be done using the -d or -U cob options.

If the name of an unresolved reference is known it can be resolved using the -d option. For example, the following command resolves reference to myref in one of the specified COBOL programs. When called at run time myref is dynamically loaded using the standard search rules that first look at the currently loaded entry points and then, if myref cannot be found, search for myref on disk (for example, for myref.so).

cob -z myprog.cbl subprog.cbl entry.cbl -d myref

To get a list of all unresolved references when you create the callable shared object, you can use the -z,U cob option. For example, the following command creates myprog.so and lists any unresolved references.

cob -z,U myprog.cbl subprog.cbl entry.cbl

You can then add -d cob options to resolve the references. You do not need to use -d options for any symbols that you know will be linked into the calling system executable (if not using cobrun or cobrun_t), or which are defined in callable shared objects that you know will have been already loaded.

If you want to resolve all unresolved references then you can use the -U cob option. For example, the following command creates myprog.so resolving any (and all) unresolved references.

cob -z myprog.cbl subprog.cbl entry.cbl -U