Re: linking to libraries on A series



On 11/2/2008 10:47 AM, Tim McCaffrey wrote:
In article <2ad2182b-3ac1-403e-9670-40106f1ee904@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, dvdconroy@xxxxxxxxxxxxxx says...
Hi all
I am not able to grasp on how does a program link to a Library .I
think it does with the CHANGE ATTRIBUTE LIBACCESS command but I cant
say for sure
there is also a direct LINK TO command ( I cant figure out what that
is)and there is also some mention of a Binder program.Can you please
throw some light on these?
David.

You link to library either by title (file name) or by function (the function name to file title is established through the SL command). By title is easier during program development, and by function is easier when the program is in production, because you don't have to recompile to point it at a different file.

Both of these are declared in the program source, the exact syntax being language dependent. Some languages cannot directly talk to system libraries (like C), and you need to write a jacket library to translate parameters and results from one environment to the other.

An A series library is akin to a Windows DLL, BTW, not a Windows .lib file.

- Tim


CHANGE ATTRIBUTE LIBACCESS OF ... TO BYTITLE or BYFUNCTION are the ways you configure how a library is going to be linked, but I think the question David was asking is how is the linkage actually established, i.e., what initiates it?

The answer is: on first reference. There is no explicit library linkage call, at least in COBOL (there are some explicit linkage controls available in Algol, but these are normally used only with connection libraries). The first time a program calls an entry point in a server library, the MCP traps the call, checks for compatible parameter sequences, sets up the address linkage, and restarts the call. Subsequent calls suffer only a one-level address indirection, which is handled by the hardware without further MCP involvement.

This automatic linkage process is quite efficient, and is heavily based on the E-mode hardware architecture that underlies MCP systems. The compilers generate control blocks in both the calling program and the library with the necessary information needed to find entry points and check parameter sequences. The address in the calling program for the entry point is initially set up using a control word that causes an interrupt when first referenced. The MCP traps this interrupt, and using the information in the compiler-generated control blocks, establishes the hardware addressing that will be used on subsequent calls. Attempting to call an non-existent entry point or to pass an incompatible set of parameters produces a fatal error for the calling program.

The Binder is something like a link editor on other systems -- it combines separately-compiled object files into a single executable. It is a form of compiler. In my experience, it hasn't been used much since libraries came along almost 30 years ago, except perhaps in FORTRAN and C environments. Libraries are so easy to use and so efficient that MCP applications tend to use those instead.

--
Paul
.



Relevant Pages

  • Re: Linker Errors 2005 and 1104
    ... Still compiles OK, but failing on linkage. ... > single-threaded and multithreaded libraries. ... > project file includes only the appropriate libraries and that any ...
    (microsoft.public.vc.mfc)
  • Re: linking to libraries on A series
    ...  Some languages cannot directly talk to system libraries ... There is no explicit library linkage ... handled by the hardware without further MCP involvement. ... environments, and the most common of these was when the primary ...
    (comp.sys.unisys)
  • Re: Extracting data symbols from an archive using dlsym
    ... This is because using extern is not giving me linkage to tvar for some ... reason. ... I have opened libraries before using dlopen, ...
    (comp.unix.programmer)
  • error C2733: second C linkage of overloaded function not allowed
    ... I am getting name collision by using two different libraries. ... The compiler is giving following ... I cant link with this function the C++ way .i.e. C linkage is a must for me. ...
    (microsoft.public.vc.language)
  • Re: how do static import libraries actually work?
    ... "I could create an import library called xxx.lib that contained an entry ... One thing I've never really understood are import libraries for DLLs ... Without linking to user32.lib in VS I get a link error, ... What happens when you statically link to a DLL import library (i.e. ...
    (microsoft.public.vc.language)