Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is the Link-edit step

Tags:

mainframe

Question

What exactly does the link-edit step in my COBOL complier do?

After the code is compiled, there is a link edit step performed. I am not really sure what this step does.

Background Information

Right out of school (3 years ago) I got a job as a mainframe application developer. Having learned nothing about mainframes in school, my knowledge has many gaps. Around my shop, we kind of have a "black box" attitude of we don't need to know how a lot of this stuff works, it just does. I am trying to understand why we need this link-edit step if the program as already compiled successfully.

like image 297
SaggingRufus Avatar asked Mar 29 '17 15:03

SaggingRufus


2 Answers

The linkedit/binderer step makes an executable program out of the output from the compiler (or the Assembler).

If you look at the output data set on SYSLIN from your COBOL compile step (if it is a temporary dataset, you can override it to an FB, LRECL 80 sequential dataset to be able to look at it) you'll see "card images", which contain (amongst some other stuff) the machine-code generated by the compiler.

These card-images are not executable. The code is not even contiguous, and many things like necessary runtime modules are missing.

The Program Binder/Binder (PGM=HEWL) takes the object code (card-images) from the compiler/assembler and does everything necessary (according to the options it was installed with, and further options you provide, and other libraries which many contain object-code or loadmodules or Program Objects) to create an executable program.

There used to be a thing called the Linkage Editor which accomplished this task. Hence linkedit, linkedited. Unfortunately, in English, bind does not conjugate in the same way as edit. There's no good word, so I use Binderer, and Bindered, partly to rail against the establishment which decided to call it the Program Binder (not to be so confused with Binding for DB2, either).

So, today, by linkedit people mean "use of the Program Binder". It is a process to make the output from your compile/assemble into an executable program, which can be a loadmodule, or a Program Object (Enterprise COBOL V5+ can only be bindered into Program Objects, not loadmodules), or a DLL (not to be confused with .dll).

It is worth looking at the output of SYSLIN, the SYSPRINT output from the binder step, and consulting manuals/presentations of the Program Binder which will give you an idea of what goes in, what happens (look up any IEW messages, especially for non-zero-RC executions of the step) by sticking the message in a browser search box. From the documentary material you'll start to get an idea of the breadth of the subject also. The Binder is able to do many useful things.

Here's a link to a useful diagram, some more detailed explanation, and the name of the main reference document for the binder for application programmes: z/OS MVS Program Management: User's Guide and Reference

The program management binder

As an end-note, the reason they are "card images" is because... back in olden times, the object deck from compiler/assembler would be punched onto physical cards. Which would then be used as input cards to the linkage editor. I'm not sorry that I missed out on having to do that ever...

like image 70
Bill Woodger Avatar answered Sep 28 '22 06:09

Bill Woodger


In addition to Bill's (great) answer, I think it is worth to also mention the related topics below ...

Static versus dynamic linking

If a (main) program 'calls' a subprogram, then you can either have such call to happen 'dynamic' or 'static':

  • dynamic: at run-time (when the main program is executed), the then current content of the subprogram is loaded and performed.
  • static: at link-time (when the mail program is(re-)linked), the then current content of the subprogram is included (= resolved) in the main program.

Link-edit control cards

The actual creation of the load module (output of the link-edit step) can be controlled by special directives for the link-editor, such as:

  • Entry points to be created.
  • Name of the load module to be created.
  • Includes (of statically linked subprograms) to be performed.
  • Alias-members to be created.

Storing the link-edit output in PDS or PDSE

The actual output (load module) can be stored in members located in either PDS or PDSE libraries. In doing so, you need to think ahead a bit about which format (PDS or PDSE) best fits your requirements, especially when it comes to concatenating multiple libraries (e.g a preprod environment for testing purposes).

like image 40
Pierre.Vriens Avatar answered Sep 28 '22 07:09

Pierre.Vriens