Technical Addendum for HP Link Editor/iX ABCDE HP Part No. 32650-90845 Printed in U.S.A.
The information contained in this document is subject to change without notice. HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Hewlett-Packard shall not be liable for errors contained herein or for incidental or consequential damages in connection with the furnishing, performance, or use of this material.
Contents 1. Technical Addendum for HP Link Editor/iX A Technical Addendum Is: . . . . . . . . . . . . Overview . . . . . . . . . . . . . . . . . . . Dependent Libraries . . . . . . . . . . . . . . . Example . . . . . . . . . . . . . . . . . . . New Commands for Maintaining Executable Libraries ALTXL Command . . . . . . . . . . . . . . Syntax: . . . . . . . . . . . . . . . . . . Parameters . . . . . . . . . . . . . . . . . Examples . . . . . . . . . . . . . . . . . BUILDXL Command . . . . . . . . . . . . .
Loading a Shared Global Data Program File or XL Loader Binding Rules . . . . . . . . . . . . Compatibility . . . . . . . . . . . . . . . Linking with Compatibility Mode Files . . . . Advanced Topics . . . . . . . . . . . . . . . External Data References . . . . . . . . . . Duplicate Data . . . . . . . . . . . . . . . Sample Listings . . . . . . . . . . . . . . . . Symbol Transformation Example . . . . . . . LISTPROG Example . . . . . . . . . . . . LISTXL Example . . . . . . . . . . . . . .
Tables 1-1. Shared Global Commands or Syntax . . . . . . . . . . . 1-2. Library Symbol Table . . . . . . . . . . . . . . . . . . 1-3. Compiler Options for Additional External Data References . .
Technical Addendum for HP Link Editor/iX A Technical Addendum Is: A Hewlett-Packard technical addendum is an informal document that delivers the latest information to customers and support personnel before formal revisions to the HP manual sets. The characteristics of these addendums are listed below: Technical addendums are published when signi cant improvements are made to an HP product. Technical addendums supplement the information contained in the existing manual set.
Dependent Libraries Dependent libraries are a new feature available on MPE/iX. They are libraries that must be loaded in addition to the executable library (XL) currently loaded. When a program runs and the loader loads each XL, it checks the dependent library list for that XL and loads any dependent libraries that have not been loaded already. This allows the dependencies to be isolated within the libraries. You only need to specify the rst-level libraries when linking or running the program.
New Commands for Maintaining Executable Libraries ALTXL Command This ALTXL command changes the dependent library string for an executable library (XL). It accepts two options, both are required: the target XL name and the dependent library string. Dependent libraries can be speci ed in an indirect le or directly in the argument to the LIB= parameter. When the Link Editor builds an XL, it inserts an MPE Program Auxiliary Header after the LST header.
Note You must supply at least one dependent library since the LIB= parameter is required. Examples :PRINT MYINDF1 NEWLIB.LIB.MYACCT LIB2.LIB.SYS :LINKEDIT LinkEd> ALTXL MYLIB1; LIB=^MYINDF1 LinkEd> ALTXL NEWLIB.LIB.MYACCT; LIB=NEW2.TMP.SYS LinkEd> EXIT :RUN MYOUT;XL="MYLIB1" The loader loads the program le, MYOUT, then the executable library, MYLIB1. Since MYLIB1 has dependent libraries, NEWLIB.LIB.MYACCT and LIB2.LIB.SYS, the loader loads them. NEWLIB.LIB.MYACCT has a dependent library NEW2.TMP.
BUILDXL Command This command now accepts a third parameter, LIB=, used to specify dependent libraries. This parameter accepts an indirect le or a list of fully quali ed library names. The Link Editor concatenates the dependent library names into a string and inserts the string into the LST Program Auxiliary header for the loader to search at run time.
Shared Global Data Shared global data are data de nitions, initialized or uninitialized, that are exported to or imported from other compilation units. The data de nitions are visible to other modules if the de nitions are exportable. This means that they are not marked as hidden and, therefore, not ignored by the loader. Table 1-1 shows the languages and the appropriate shared global command and syntax. Table 1-1.
Additionally, the loader initializes a Data Cross Reference Table (DXRT) with data de nition addresses. The DXRT holds entries for all data references that need a corresponding de nition. This allows externally referenced data to be tracked and shared. Table 1-2 shows the data types and scopes that are inserted into the Library Symbol Table. Table 1-2.
Compiling for Shared Global Data To share global data across object modules, you do not need to recompile an application. You only need to relink the application. Refer to \Linking for Shared Global Data". Global Data Limit There is a limit to the number of data references (approximately 2000) allowed per program le and per module in an XL. If this limit is exceeded, the Link Editor emits an error message instructing you to recompile the appropriate modules to allow more external data references.
Table 1-3 lists the new compiler options available to allow more external data references. Table 1-3. Compiler Options for Additional External Data References Option Languages $MORE_GLOBALS ON$ MPE/iX compiler option available on HP Pascal/iX. $CONTROL MOREGLOBALS MPE/iX compiler option available on HP COBOL II/iX. +k Note Command-line option, available on HP C/iX.
Linking for Shared Global Data To link a program le for shared global data, it is not necessary to specify RL les at link time if you want any unresolved data references to be satis ed 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.
New LIBC/iX Library A new C library, libcshr.lib.sys, takes advantage of the Shared Global feature. This library allows you to link your program with other executable libraries (XLs) in addition to xl.pub.sys. You can use it in the same way you use other libc libraries, but you must have the new share keyword. For example: link from=myobj;to=myprog;rl=libcansi.lib.sys,libcshr.lib.
3. Shared Linking - Link with LIBCSHR , which is completely sharable. All the libc functions are in XL.PUB.SYS . They are shared by the application's linked executable libraries. It is the recommended method for sharing global data. link from= cobj;to=cprog;rl=libcansi.lib.sys,libcshr.lib.sys;share Guidelines for the Linkage Method Use non-shared linkage for self-contained and highly portable applications. This is the traditional linkage method.
DATA=data item Speci es 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 le and can satisfy imports in the program le.
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 speci ed. 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 les.
Building a Shared Global Data XL An XL can have shared global data modules and non-shared global data modules. You can determine if a module in an XL contains shared global data by using the LISTXL command. If the SHARED DATA header eld is set to YES, the module is a shared global data module. If the SHARED DATA header eld is set to NO, the module does not contain shared global data. As before, the BUILDXL command builds an empty XL. The ADDXL command is used to add shared global data modules to an XL.
importable because Data Universals in program les always take precedence over Data Universal exports in an XL. For more information on the loader binding rules, refer to \Loader Binding Rules". The Link Editor now allows modules in an XL to contain unresolved data symbols when linking for shared code and data. At load time, the loader attempts to resolve these symbols. If the symbols are not resolved, the loader emits an error message and aborts the load.
Example ADDXL FROM=TESTRL2;TO=MYXL3 ADDXL FROM=DKRL;DATA=MYTIME,index,link_time;TO=MYXL4;SHARE In the rst line, modules from TESTRL2 are added to MYXL3. Data is not shared, so the linking behavior is the same as for non-shared global data environments. Data will not be exported nor imported in MYXL3. In the second line, modules from the RL DKRL are added to MYXL4. Only modules that export MYTIME, index, and link_time (Data Universal exports) are added to the XL.
The PURGEXL Link Editor command allows modules to be purged, based on exports (Data Universals only). This implies that the XL was built for shared data and, therefore, has data exports. The PURGEXL command accepts a new parameter: DATA=data name Note that data name is case-sensitive. The rst module found that exports the speci ed data symbol is purged from the XL. If the module is not a shared global data module, the DATA= option is ignored.
There are new eld values for shared global data modules in the LISTPROG and LISTXL output. The eld values are: Under Sym Type, there is a new symbol type , s_req, which denotes a storage request. Under Sym Scope, there is an unsatis ed scope , unsat, which is now valid with symbol type data. Under Sym Value, the DP-relative DXRT o set is printed for Data Unsats: dp = data pointer . For Data Universals in program les, the address of the literal or the o set from DP is printed.
Loading a Shared Global Data Program File or XL The loader is responsible for binding code and data imports and exports at load time. The loader will: Set up DP according to the initialization pointers. Set up LP and XRT entries according to LST import records. Initialize the DXRT entries with addresses at load time according to the loader xups and LST import records. Implement a new binding scheme for data that allows program le global data exports to bind XL data imports and vice versa.
already loaded module, those de nitions take precedence over all others. All imports for foo will bind to the one just loaded. Violation of any of the above rules for any data symbol results in a failed load. The precedence is established for each distinct data symbol only once per process. Therefore, libraries loaded dynamically, through the HPGETPROCPLABEL intrinsic, are subject to the same rules as static XLs (XLs speci ed at link time).
Advanced Topics This section describes additional information on shared global data in XLs. External Data References An external data reference, also known as an import, is a reference to a data symbol that is not de ned in the module. External data references are now allowed in program les and XLs if they are linked for shared data. These references are not resolved at link time because the Link Editor builds one load module at a time, using LINK or ADDXL.
program les always take precedence over symbols in an XL. Therefore, Data Universals in the program can never be overridden at run time. Duplicate Data Duplicate data exports are allowed in an XL, as long as the duplicates occur in separate modules. Duplicate Data Universal exports are not allowed in program les and are not recommended in XLs. Duplicate Data Universals are not recommended in XLs because duplicate data exports are not allowed in HP-UX Shared Libraries.
Example The following example demonstrates how the PURGEXL and LISTXL commands process an XL that contains duplicate data exports. Assume that after each PURGEXL command is executed, the process starts over with the same MYXL XL.
PURGEXL XL=MYXL;DATA=foo PURGEXL XL=MYXL;DATA=fee PURGEXL XL=MYXL;DATA=fum PURGEXL XL=MYXL;DATA=bar PURGEXL XL=MYXL;ENTRY=bar LISTXL XL=MYXL;DATA_ITEM=fee Deletes module DKTEST from MYXL because DKTEST is the rst module found that exports foo. Does not delete any module from MYXL because no module was found that exports a data universal symbol named fee. Does not delete any module from MYXL because no module was found that exports a data universal symbol named fum.
Sample Listings Symbol Transformation Example C source file int i; int foo=0; extern int bar; ... main () { i++; foo++; bar++; ...
Shared Data XL -------------------------------------------------|Symbol| Type | Scope |LST Import |LST Export | |------------------------------------------------| |i |Storage|Universal| Yes | Yes | |foo |Data |Universal| Yes | Yes | |bar |Data |Unsat | Yes | No | -------------------------------------------------Non-Shared Data Program File or Non-Shared Data XL -------------------------------------------------|Symbol| Type | Scope |LST Import |LST Export | |------------------------------------------------|
LISTPROG Example LinkEd> listprog myprog PROGRAM CAPABILITIES NMHEAP SIZE NMSTACK SIZE ENTRY NAME UNSAT NAME PRIORITY MAX PRIORITY POSIX SHARED DATA TEXT SIZE DATA SIZE VERSION Sym Name ---$START$ main $RECOVER_END $RECOVER_START $START$ $UNWIND_END $UNWIND_START 28 : : : : : : : : : : : : : MYPROG BA, IA NO YES 000002F8 0000001C 85082112 C H X P Sym Type - - - - ---0 3 3 pri_p 0 3 3 entry 0 code 0 code 0 code 0 code 0 code Sym Scope ----univ univ univ univ univ univ univ Technical Addendum for HP Li
_start main M$6 foption myopt ARITRAP U_INIT_TRAPS _exit _close _dup _init_c_globals _init_x11_globals _open_std_file _parse_info_string foo printf foption mystring myvalue 0 H 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 code code data s_req data stub stub stub stub stub stub stub stub stub stub stub data data data univ univ local univ univ ext ext ext ext ext ext ext ext ext ext ext unsat unsat unsat 00005218 0000509C dp+00000008 dp+00000018 dp+00000000 lp+000000A0 lp+000000C0 lp+00000160 lp+00000060 lp+000001
LISTXL Example listxl dkxl4 LIBRARY NAME VERSION MODULE COUNT MODULE LIMIT : : : : DKXL4 85082112 2 500 MODULE NAME ----------HIMOMC MYBAR MODULE NAME TEXT SIZE DATA SIZE VERSION LENGTH SHARED DATA Sym Name ---main $RECOVER_END $RECOVER_START $UNWIND_END $UNWIND_START main printf 30 START ----00129000 00139000 : : : : : : LENGTH -----0000355C 0000336C HIMOMC 00000080 00000008 87102412 0000355C NO C H X P Sym Type - - - - ---0 3 3 entry 0 code 0 code 0 code 0 code 0 code 0 stub Sym Scope ----univ un
MODULE NAME TEXT SIZE DATA SIZE VERSION LENGTH SHARED DATA Sym Name ---$RECOVER_END $RECOVER_START $UNWIND_END $UNWIND_START d f fee k foo : : : : : : MYBAR 00000004 00000010 87102412 0000336C YES C H X P Sym Type - - - - ---0 code 0 code 0 code 0 code 0 s_req 0 data 0 data 0 s_req 0 data Sym Scope ----univ univ univ univ univ univ univ univ unsat Sym Lset Value Name -------0013B000 0013B000 0013B000 0013B000 dp+00000008 dp+00000004 dp+00000000 dp+0000000C dp-0000000C Technical Addendum for HP Link Edi
Diagnostic Messages New warning and error messages returned by the Link Editor. User Errors (1000-1499) 1167 MESSAGE Expected NMXL file. File "!" is a CM file (LINKERR 1167) CAUSE The Link Editor encountered a compatibility mode le when linking and shared data was enabled. ACTION Make sure LKSHAREDATA is unset or set to FALSE before attempting to link with compatibility mode les. Warning Messages (1500-1999) 1562 32 MESSAGE SYMBOL "!1" IS HIDDEN/NOT HIDDEN IN DIFFERENT MODULES.
Language Subsystem Errors (3000-3999) 3060 MESSAGE REFERENCE TO "!" IN FILE "!" NEEDS 3-INSTRUCTION SEQUENCE -- USE +k OR $MORE_GLOBALS$ TO RECOMPILE (LINKERR 3060) CAUSE DXRT limit of approximately 2k was hit. There are too many data imports and/or too many imports requiring multiple DXRT slots. ACTION Recompile with the +k option or $MORE_GLOBALS$ pragma to compile for 3-instruction load and store sequences.
Glossary Data Universal An initialized data symbol de ned in an object module that is visible (exportable) to other object modules. Data Unsat A data symbol that is referenced by an object module but not de ned in it. These symbols are allowed in XLs and program les for shared global data. DXRT A Data Cross Reference Table. The table is initialized by the loader at run time with data de nition addresses. All data references that need a corresponding de nition has an entry in this table.
Process Data Dictionary The Process Data Dictionary (PDD) is the repository of all data symbol resolution that has taken place on a process. Its main functions are to: Maintain information on all resolutions. Enforce resolution semantics by controlling the addition of new symbols. All arbitration between duplicate de nitions is done by the dictionary. Maintain information to undo the e ects of a failed load.