Overview | Creating a GRIP Program | Compiling a GRIP Program | Running a GRIP Program | Debugging a GRIP Program


Linking GRIP Object Files

The third step of GRIP program development is the linking of previously generated object files into an executable module. The executable module consists of the main program and any subprograms that are arranged in such a manner as to allow data to pass from one segment of the program to another. During this process, the linker generates a listing that contains the main program name and the names of all subprograms in the order in which they are referenced. If the link operation completes without errors, the linker generates and files an executable module.

Referencing Subroutines

The Link option links the object file of a main GRIP program with the object files of any subroutines that can be referenced. If a subroutine file does not reside in your current directory, enter the full file specification. You can specify a wildcard such as "*.grs" or just "*". You can issue a single line link:

l <filespec>

Where "filespec" can be either the full pathname or just the filename if the file is in your current directory. You do not need to include the ".gri" file extension.

When you choose this option, the system prompts you to enter the file specifications for the main programs only. The names of the subprograms are not included because they are automatically resolved by the Link routine. You can specify a file template, such as *.gri.

Locating Subroutines Using a Search File

You can link object files together even if they reside in different directories or on different volumes. To do so, use a text file named gri.sea which consists of directory specifications where the object files reside.

The search path for the gri.sea file is:

  1. The current directory

  2. The $UGII_UTIL directory

When linking an executable, the search path for an object file is:

  1. The current directory

  2. The first directory in the gri.sea file

  3. The second directory in the gri.sea file, etc.

Understanding the Linker Listing

When a GRIP program is compiled, the object file created is in two parts, the program area and the data area. The program area contains the compiled program instructions, and the data area contains the program variables. In the linker listing, these two program areas are indicated by the headings PROG and DATA. In addition the listing contains two fields for each of these areas which indicate the sector number (SECT) and starting address or displacement (DISP). This process is repeated for subprograms as well as main programs.

Sample Linker Listing

The following listing shows the linker output with errors.

UNIGRAPHICS GRIP LINKER
PROGRAM NAME PROG PROG DATA DATA
SECT DISP SECT DISP
FLOWCHART 0 0 0 245
INTERACTION 0 315 1 140
PROCESS IS UNDEFINED
OFF-PAGE 1 248 2 404
DECISION 3 194 4 86
SPECIAL 4 239 5 131
GUIDE-LINE 5 255 5 442
1 LINKER ERRORS
PROGRAM SIZE = 0 0
LINKING TERMINATED

Without errors, the linker output listing displays as:

UNIGRAPHICS GRIP LINKER
PROGRAM NAME PROG PROG DATA DATA
SECT DISP SECT DISP
FLOWCHART 0 0 0 245
INTERACTION 0 315 1 140
PROCESS 1 248 2 99
OFF-PAGE 1 248 3 404
DECISION 4 194 5 86
SPECIAL 5 239 6 131
GUIDE-LINE 6 255 6 442
LINKING COMPLETE
PROGRAM SIZE = 6 491

An NX sector is 512 words long and the starting address of the area is from (0-511). Also indicated is the total program size in sectors and words. The successfully linked program above has 6 sectors and 491 words.