The binder recognizes C/C++ object modules and performs special processing for them.
C/C++ categorizes reentrant programs as natural or constructed. The binder supports both natural reentrancy and C/C++ constructed reentrancy. However, programs that contain constructed reentrancy need additional runtime library for support while executing.
C++ code always has DLL type references for all function references that require a function descriptor in C_WSA. This means that all C++ programs are made reentrant via constructed reentrancy.
To generate reentrant C/C++ code, follow these steps:
Each compile unit maps to a number of sections, which belong to the C_CODE, C_WSA, or B_TEXT binder classes. Named binder sections may be replaced and make the code potentially rebindable. You can name your C/C++ sections with either the CSECT compiler option, or with the use of the #pragma csect directive. The name of a section should not be the same as one of your functions or variables, as this will cause duplicate symbols.
Each section owns one or more parts. The names of the parts are the names that resolve references. The names of functions appear as labels, which also resolve references. Some parts that are owned by a section may be unnamed. Each part belongs to a binder class.
Each externally named object in the Writable Static Area appears as a part that is owned by a section of the same name in the program object. Such parts belong to the C_WSA binder class. The binder section that owns an object also owns the initialization information for the object in the Writable Static Area. A rebind replaces this initialization information.
The code parts belong to the binder class of C_CODE or B_TEXT. The code parts consist of assembly instructions, constants and literals, and potentially read only variables that are not in the Writable Static Area. The following example will produce two sections, i and CODE1:
#pragma csect(code,"CODE1")
int i=10;
int foo(void) { return i; }
When rebound, both sections i and CODE1 are replaced along with any information that is associated with them.
The names in the C_WSA class and in the C_CODE class are in the same namespace. A variable and a function cannot have the same name.
C++ constructor calls and destructor calls that need to be collected across compile units are collected in the class C_@@STINIT.
DLL initialization information, which needs to be collected across compile units, is collected in the class C_@@DLLI.