LIBVECs

A LIBVEC is provided for the Language Environment library routines. A pointer to it is kept in the CAA and in the EDB. Additional LIBVECs are provided for members to use for their own libraries. Members define their own LIBVEC pointer fields.

Figure 1. Library subroutine access table (LIBVEC)
Library subroutine access table (LIBVEC)

As Figure 1 shows, a LIBVEC has three contiguous parts. The first part is made up of fields that contain parameters relating to the table itself. The subroutine loader uses this information. The second part is pointed to by the LIBVEC pointer and contains a 4 byte entry (SLOTn) at a fixed offset for each subroutine. If the subroutine has been loaded and AMODE switching is not being performed, each SLOTn contains the entry point address of its subroutine. Otherwise SLOTn points to its corresponding GLUE AREAn within the third part of the table. The third part is the GLUEAREAn. The size of each GLUE AREAn is 20 bytes. If the subroutine has been loaded and AMODE switching is being performed, the corresponding GLUE AREAn contains AMODE switching code.

Access to library routines through LIBVEC can be direct (though a known fixed LIBVEC offset) or indirectly (through an externally-defined address constant and a library owner supplied stub). Library owners can choose to provide a macro for direct access to their library routines and a stub for indirect access.

Note: Language Environment library routines can be accessed only through a stub in compiled code; Language Environment provides stubs for this purpose. Library to library calls can access the Language Environment LIBVEC vector table directly.
The following instructions are used to access library routines through LIBVEC directly using fixed offset:
L     R15,libvec_pointer        Get address of LIBVEC
L     R15,xxx(,15)              Get address of Subroutine or GLUE AREAn
                                from LIBVEC slot
BALR  R14,R15

When the access is indirect, through a stub,

  1. The calling program performs the following instruction sequence:
    AL    15,=V(LIBSUBx)
    BALR 14,15
  2. A stub routine is provided for each library routine entry point. It is link-edited with the user program.
    There is one type of stub routine that generates the LIBVEC calling sequence. When the stub is entered from the above code, it performs the following calling sequence:
    L     15,libvec_pointer        Get address of LIBVEC
    L     15,xxx(,15)              Get address of Subroutine or GLUE AREAn
                                   from LIBVEC slot
    BR    15
  3. If the subroutine has not yet been loaded, then the direct or stub branch goes to GLUE AREAn, which contains code to invoke the subroutine loader.
  4. If the subroutine has been loaded and AMODE switching is being done, the direct or stub branch goes to GLUE AREAn, which contains switching code. AMODE switching is done whenever the ALL31(OFF) runtime option is in effect.
  5. If the subroutine has been loaded and AMODE switching is not being done, the direct or stub branch goes directly to the subroutine's entry address.