Cobol: Add -export-dynamic by default.
COBOL programs now export symbols by default to resolve dynamic CALL issues.
The GNU Cobol compiler (gcobc) now enables the -export-dynamic option by default. This change addresses an issue where dynamic CALLs between programs within the same executable could fail if symbols were not exported to the dynamic symbol table. By default, GCC does not export unreferenced symbols, and since GNU Cobol uses dynamic linking for CALLs by default, this could lead to ‘symbol not found’ warnings. -export-dynamic ensures all symbols are exported, resolving this potential runtime problem.
In Details
The GNU Cobol compiler driver (gcobc) now unconditionally adds -export-dynamic to its default link-time options. This is to mitigate a common issue where dynamic CALLs between modules linked into the same executable fail when -fno-static-call (the default in gcobc) is in effect. Since GCC's default linker behavior does not export unreferenced symbols, and gcobc defers CALL resolution to dlopen/dlsym, symbols can be discarded by the linker, leading to runtime errors. Exporting all symbols resolves this.
- cobol
- A high-level programming language primarily used in business applications. GCC includes a compiler for COBOL (GNU Cobol).
- -export-dynamic
- A linker option that causes all symbols, including unreferenced ones, to be exported to the dynamic symbol table. This makes them available for dynamic linking at runtime.
- dynamic CALL
- In COBOL, a CALL statement that resolves the target program's symbol at runtime using dynamic linking, rather than at compile or link time.
- dynamic symbol table
- A table within an executable or shared library that lists symbols (functions, variables) that are available for linking by other dynamic objects at runtime.
- dlopen
- A POSIX function that loads a shared library into the calling process's address space.
- dlsym
- A POSIX function used to find the address of a symbol within a dynamically loaded shared library.