Page 1 of 1

Difference between an Object Module and Load Module

Posted: Fri May 23, 2008 2:23 pm
by Shamik123
Hi,

Let me start with the shortest COBOL program.

IDENTIFICATION DIVISION.
PROGRAM-ID. SHORTEST.
PROCEDURE DIVISION.
DISPLAY "THE SHORTEST COBOL PROGRAM IS OF 5 LINES".
STOP RUN.

We get the Object Module which contains the machine instructions when we compile the above 5 lines of source code.

My question is:
What is specific use of Link Edit in this case? The Link Editor in general resolves all the external references and transforms the Object Module in an executable Load Module form. What are the crucial differences between the Object Module and the Load Module of the above 5 lines of code? Please, let me know your opinion. I know that even the above Object Module cannot be directly run without beinf LinkEdited. But, I am not aware of the technical reason.

Please, help me. Thanking you a lot in anticipation.

With high regards,
Shamik Banerjee

Posted: Thu Sep 30, 2010 12:59 pm
by chandana
Hi ..
I also have the same doubt..
Please let me know if you have found the answer..

Thank you
Chandana

Posted: Thu Sep 30, 2010 1:39 pm
by dbzTHEdinosauer
actually, you can remove the display instruction, and have a cobol prg with only 4 lines.

and join the 20th century of computing. stop using STOP RUN and start using GOBACK.

suggest you start by reading the following Redbooks z/os systems programming

it would be better for both of you to extend your knowledge by reading the documentation that exists,
than having any of us providing paraphrased (from what is already well written)
answers to 'select topics'.

The answer to this question, and probably many more that you have,
(possibly don't realize that you have)
is contained in the above publications in an easy to read manner.
Using the Redbook library allows you to 'evade'
the hard to read and sometimes obscurely organized Technical Manuals normally produced by IBM
and learn about the system that you are (or should be) becoming proficient.

Posted: Fri Oct 01, 2010 10:58 am
by Shamik123
To answer Chandana's query: "The verb DISPLAY in COBOL generates a lot of code in mainframe Assembler. Included in it is a call to output your message. The link edit program pulls together the common routines necessary to actually define the location (SYSOUT by default on many systems), the methods used to actually output something and then to output it.

Go ahead and compile this and save both the object file and the results of the link edit. If you can read hex and know your way around a load module well enough, you'll see the routines added to the object file to support the DISPLAY. You can't run the object file because it doesn't have the other routines necessary to support the calls for service. That is what is in the link book."

Cheers,
Shamik Banerjee

Posted: Fri Oct 01, 2010 3:07 pm
by dbzTHEdinosauer
Shamik123 wrote:The link edit program pulls together the common routines necessary to actually define the location (SYSOUT by default on many systems)
Shamik123,
I suggested to you that you do some reading.
as you have decided to just pontificate on things you only know a little,
I am going to correct the above quote.

the actually definition of the output is accomplished in other SECTIONs of the COBOL program.
The default output is defined by the COBOL Program and not the OS.
the actual location is accomplished via ALLOCATE either (normally) thru DD Statements in your JCL or by dynamic allocation by a CALL from within the COBOL Program.

//SYSOUT DD SYSOUT=* << will drive to the sysout dsid in the spool.
//SYSOUT DD DSN=hlq.mlq.llq,DCB=(parms)

as you can see, your sysout can be directly written to a dataset.

so, the linkeditor (or binder) binds/completes CALLs to system output routines which will accomplish the actual i/o.