HP 3000 Manuals

Linking for Shared Global Data [ Technical Addendum for HP Link Editor/iX ] MPE/iX 5.0 Documentation


Technical Addendum for HP Link Editor/iX

Linking for Shared Global Data 

To link a program file for shared global data, it is not necessary to
specify RL files at link time if you want any unresolved data references
to be satisfied at load time by an XL. The default behavior remains
linking for non-shared data.  To link for shared data, you must use the
new SHARE option.  The loader automatically searches XL.PUB.SYS at
run-time if you did not specify it at link time.  You can override an XL
specified at link time by specifying the XL at run time using the XL=
option in the RUN command.

SHARE Option 

The SHARE option instructs the Link Editor to link for shared data.
Linking for shared data means all non-hidden Data Universals and Storage
Universals are exported, and all Data Unsats and Storage Universals are
imported.  If you want to selectively export Data Universals and Storage
Universals, you can take the definitions out of the source code of the
program file or library and add the objects to an RL. Use the HIDERL
command to hide the definitions and add the resulting RL to an XL. At
link time, specify the XL on the link line so the loader will know it
needs to search that XL first.  The data symbols you want hidden are not
exportable from the XL or program file.

Example 

     LINK FROM=^indirect_file;SHARE;XL=MYXL;TO=MYOUT;RL=LIBCSHR.LIB.SYS

The object files in indirect_file and the RL LIBCSHR are linked to form
an executable program file called MYOUT. At run time, the loader loads
the XL MYXL followed by XL.PUB.SYS and attempts to satisfy unresolved
data references in MYOUT with data exports in MYXL and XL.PUB.SYS. The
loader issues an error message if it cannot resolve a data reference.


NOTE If you are using C and want to link for shared global data, you must link with LIBCSHR. If you do not want to link for shared global data you can continue to link with LIBCINIT. Refer to the HP C/iX Enhancements for MPE/iX 5.0 Communicator Article.
POSIX Links All POSIX links using c89 or /lib/libc.a/ are linked for shared code and data. Hiding Data Symbols You are now able to hide data symbols as well as code symbols in RLs. The HIDERL command sets a bit called the hidden bit for each symbol marked as hidden in an RL. When the RL is added to an XL or program file, the Link Editor does not build LST export records for these symbols. The symbols are not visible or accessible to modules in the same XL, other XLs, or program files. There are two options to the HIDERL command to support hiding data symbols: ALL_DATA Specifies that all Data Universals and Storage Requests are marked as hidden in the RL. The hidden bit is set in the symbol dictionary for these symbols. DATA=data_item Specifies that data_item is marked as hidden in the RL. Note that data_item is case-sensitive and must be a Data Universal or Storage Request. As with code symbols, the hiding takes place when the RL is added to the XL or program. Therefore, if you link with an RL that has hidden symbols, those hidden symbols are still exportable to the program file and can satisfy imports in the program file. When the RL is added to an XL or program file, no LST import or export record is generated in the XL's LST area for the hidden symbols. The hidden symbols are therefore not sharable with other modules. Like Code Unsats, Data Unsats cannot be hidden even though the hidden bit is set. Duplicate data symbols are allowed in RLs. When hiding data or storage symbols, the Link Editor hides each occurrence of the symbol. For example, if there are five data or storage symbols called foo, all five are marked as hidden. Using HIDERL to hide data symbols is the recommended way to keep data symbols internal (that is, not externally visible) to the load module. Example HIDERL RL=MYRL;DATA=foo HIDERL RL=MYRL2;ALL_DATA ADDXL FROM=MYRL;TO=MYXL ADDXL FROM=MYRL2;TO=MYXLA2 MYXL does not export foo because it is marked as hidden. foo is not visible to any other module in MYXL, other XLs, or program files. MYXLA2 does not export any data symbols because all data symbols are marked as hidden. Linking With Hidden Data Symbols Because data in RLs can be hidden, when linking or doing an ADDXL;MERGE with modules that have hidden data symbols, if a hidden data symbol is processed, all occurrences of that symbol must also be marked as hidden. If one of the occurrences is not marked as hidden, the Link Editor emits a warning message and marks the symbol as hidden. Refer to "Diagnostic Messages" for the warning message. Revealing Data Symbols You are now able to reveal, or unhide, data symbols as well as code symbols in RLs. The REVEALRL command unsets the hidden bit for each symbol specified. When the RL is added to an XL, the Link Editor exports all unhidden symbols. The symbols become visible and accessible to the same XL, other XLs, and program files. There are two new options to the REVEALRL command to support unhiding data symbols: ALL_DATA Specifies that all Data Universals and Storage Requests are marked as unhidden in the RL. The hidden bit, if set, is unset for these symbols. DATA=data_item Specifies that data_item is marked as unhidden in the RL. Note that data_item is case-sensitive and must be a Data Universal or Storage Request. As with code symbols, the revealing takes place when the RL is added to the XL or program file. When this happens, the symbols become sharable with other modules. Duplicate data symbols are allowed in RLs. When revealing data or storage symbols, the Link Editor reveals each occurrence of the symbol. For example, if there are five data or storage symbols called foo, all five are revealed. Example REVEALRL RL=MYRL;DATA=foo REVEALRL RL=MYRL2;ALL_DATA ADDXL FROM=MYRL;TO=MYXL ADDXL FROM=MYRL2;TO=MYXL2 MYXL exports foo because it is revealed, or unhidden. Modules in MYXL, as well as in other XLs or program files, can access foo. MYXL2 exports all data symbols. Modules in MYXL2, as well as other XLs or program files, can access those data symbols.


MPE/iX 5.0 Documentation