HP 3000 Manuals

Using Both Relocatable and Executable Libraries within a Program [ HP Link Editor/XL Reference Manual ] MPE/iX 5.0 Documentation


HP Link Editor/XL Reference Manual

Using Both Relocatable and Executable Libraries within a Program 

A complex program may use a combination of several types of libraries,
and additionally, might also require certain calls to system intrinsic
routines to complete its tasks.

The next three sections show how to link a program that incorporates both
a relocatable library and an executable library, as well as calls to
specific system intrinsics.

Creating the Relocatable Library 

Figure 2-11 shows how to create a relocatable library using the HP Pascal
source file, EX3CSRC. The relocatable object file created is named
EX3COBJ. The commands entered are identical to those shown in figure 2-4
with the exception that :PASXL is used as the compile command.
___________________________________________________________________
|                                                                 |
|     :PASXL EX3CSRC,EX3COBJ                                      |
|     :LINKEDIT                                                   |
|     LinkEd> BUILDRL RL=EX3LIBRL                                 |
|     LinkEd> ADDRL FROM=EX3COBJ                                  |
|     LinkEd> EXIT                                                |
___________________________________________________________________

          Figure 2-11.  Creating a Relocatable Library and Adding a Module 

Creating the Executable Library 

Figure 2-12 shows how to create an executable library using the HP Pascal
source file, EX3DSRC. First, a relocatable object file is created named
EX3DOBJ. Next, the BUILDXL command creates the executable library
EX3LIBXL. Finally, ADDXL adds the relocatable object file EX3DOBJ to the
executable library.  The commands entered are identical to those shown in
figure 2-7 with the exception that :PASXL is used as the compile command.
___________________________________________________________________
|                                                                 |
|     :PASXL EX3DSRC,EX3DOBJ                                      |
|     :LINKEDIT                                                   |
|     LinkEd> BUILDXL XL=EX3LIBXL                                 |
|     LinkEd> ADDXL FROM=EX3DOBJ                                  |
|     LinkEd> EXIT                                                |
___________________________________________________________________

          Figure 2-12.  Creating an Executable Library and Adding a Module 

Linking with Libraries and Relocatable Object Files 

Figure 2-13 shows how to link object files with a relocatable library
using the link editor LINK command while specifying a needed executable
library with a parameter to the :RUN command.  First, the :PASXL compile
command is used to create a relocatable object named EX3AOBJ from the
source file EX3ASRC. EX3ASRC represents the main program; see figure 2-23
in the "Sample Programs".  Next, a subprogram EX3BSRC is compiled,
producing the relocatable object file EX3BOBJ; see figure 2-24 for the
source.  Its code includes a procedure call to the system intrinsic who;
who is used to determine the device number of the current user.

In order to link the above two relocatable object files with the
relocatable library module created in figure 2-11, the link editor LINK
command is used.  After exiting the link editor, the :RUN command
executes the program.  Note that EX3AOBJ and EX3BOBJ as well as any
modules needed from the relocatable library, EX3LIBRL, will be included
in the resulting program file.  The program file created will still have
unsatisfied symbols because the modules on the command line use but do
not define those symbols.  These symbols will be resolved with the
EX3LIBXL or the system libraries; the XL= parameter of the :RUN command
is used to resolve these symbols at run time.

Specifically, the procedures and system intrinsics referenced in figures
2-23 through 2-26 are defined as follows:

       p1 is defined in EX3BOBJ.

       p2 is defined in EX3LIBRL.

       p3 is defined in EX3LIBXL.

       who and dateline are defined in NL.PUB.SYS or XL.PUB.SYS.

Both p1 and p2 are resolved in the program file whereas p3, who, and
dateline are left as unsatisfied symbols in the program file which are
resolved at run time.
___________________________________________________________________
|                                                                 |
|     :PASXL EX3ASRC,EX3AOBJ                                      |
|     :PASXL EX3BSRC,EX3BOBJ                                      |
|                                                                 |
|     :LINKEDIT                                                   |
|     LinkEd> LINK FROM=EX3AOBJ,EX3BOBJ;RL=EX3LIBRL               |
|     LinkEd> EXIT                                                |
|     :RUN $OLDPASS;XL="EX3LIBXL"                                 |
___________________________________________________________________

          Figure 2-13.  Linking Libraries and Relocatable Object Files 

As an alternative to specifying the executable libraries needed on the
:RUN command, it might be useful to specify them at the time of linking.
This allows you to simply invoke the :RUN command with no knowledge of
the executable libraries needed at run time.
____________________________________________________________________
|                                                                  |
|     :LINKEDIT                                                    |
|     LinkEd> LINK FROM=EX3AOBJ,EX3BOBJ;RL=EX3LIBRL;XL="EX3LIBXL"  |
|     LinkEd> EXIT                                                 |
|     :RUN $OLDPASS                                                |
____________________________________________________________________

          Figure 2-14.  Alternative Specification for Executable Libraries 



MPE/iX 5.0 Documentation