4 * (C) Copyright 1989-1995
19 * The module lkdata contains the global variables
20 * and structures used in the linker aslink.
24 * Definitions for all Global Variables
27 char *_abs_ = { ". .ABS." };
29 int lkerr; /* Linker error flag
31 char *ip; /* Pointer into the REL file text line in ib[]
33 char ib[NINPUT]; /* REL file text line
35 char *rp; /* pointer into the LST file
38 char rb[NINPUT]; /* LST file text line being
41 int oflag; /* Output file type flag
43 int mflag; /* Map output flag
46 int symflag; /* no$gmb .sym output flag
49 int xflag; /* Map file radix type flag
51 int pflag; /* print linker command file flag
53 int uflag; /* Listing relocation flag
55 int radix; /* current number conversion radix:
56 * 2 (binary), 8 (octal), 10 (decimal),
59 int line; /* current line number
61 int page; /* current page number
63 int lop; /* current line number on page
65 int pass; /* linker pass number
67 int rtcnt; /* count of elements in the
68 * rtval[] and rtflg[] arrays
70 Addr_T rtval[NTXT]; /* data associated with relocation
72 int rtflg[NTXT]; /* indicates if rtval[] value is
73 * to be sent to the output file.
74 * (always set in this linker)
76 int hilo; /* REL file byte ordering
78 int gline; /* LST file relocation active
81 int gcntr; /* LST file relocation active
86 * The structure lfile contains a pointer to a
87 * file specification string, the file type, and
88 * a link to the next lfile structure.
92 * struct lfile *f_flp; lfile link
93 * int f_type; File type
94 * char *f_idp; Pointer to file spec
97 struct lfile *filep; /* The pointers (lfile *) filep,
98 * (lfile *) cfp, and (FILE *) sfp
99 * are used in conjunction with
100 * the routine getline() to read
101 * asmlnk commands from
102 * (1) the standard input or
103 * (2) or a command file
104 * and to read the REL files
105 * sequentially as defined by the
106 * asmlnk input commands.
108 * The pointer *filep points to the
109 * beginning of a linked list of
112 struct lfile *cfp; /* The pointer *cfp points to the
113 * current lfile structure
115 struct lfile *startp;/* asmlnk startup file structure
117 struct lfile *linkp; /* pointer to first lfile structure
118 * containing an input REL file
121 struct lfile *lfp; /* pointer to current lfile structure
122 * being processed by parse()
124 FILE *ofp; /* Output file handle
127 FILE *mfp; /* Map output file handle
129 FILE *rfp; /* File handle for output
130 * address relocated ASxxxx
133 FILE *sfp; /* The file handle sfp points to the
134 * currently open file
136 FILE *tfp; /* File handle for input
137 * ASxxxx listing file
141 * The structures of head, area, areax, and sym are created
142 * as the REL files are read during the first pass of the
143 * linker. The struct head is created upon encountering a
144 * H directive in the REL file. The structure contains a
145 * link to a link file structure (struct lfile) which describes
146 * the file containing the H directive, the number of data/code
147 * areas contained in this header segment, the number of
148 * symbols referenced/defined in this header segment, a pointer
149 * to an array of pointers to areax structures (struct areax)
150 * created as each A directive is read, and a pointer to an
151 * array of pointers to symbol structures (struct sym) for
152 * all referenced/defined symbols. As H directives are read
153 * from the REL files a linked list of head structures is
154 * created by placing a link to the new head structure
155 * in the previous head structure.
159 * struct head *h_hp; Header link
160 * struct lfile *h_lfile; Associated file
161 * int h_narea; # of areas
162 * struct areax **a_list; Area list
163 * int h_nglob; # of global symbols
164 * struct sym **s_list; Global symbol list
165 * char m_id[NCPS]; Module name
168 struct head *headp; /* The pointer to the first
169 * head structure of a linked list
171 struct head *hp; /* Pointer to the current
176 * A structure area is created for each 'unique' data/code
177 * area definition found as the REL files are read. The
178 * struct area contains the name of the area, a flag byte
179 * which contains the area attributes (REL/CON/OVR/ABS),
180 * an area subtype (not used in this assembler), and the
181 * area base address and total size which will be filled
182 * in at the end of the first pass through the REL files.
183 * As A directives are read from the REL files a linked
184 * list of unique area structures is created by placing a
185 * link to the new area structure in the previous area structure.
189 * struct area *a_ap; Area link
190 * struct areax *a_axp; Area extension link
191 * Addr_T a_addr; Beginning address of area
192 * Addr_T a_size; Total size of the area
193 * char a_type; Area subtype
194 * char a_flag; Flag byte
195 * char a_id[NCPS]; Name
198 struct area *areap; /* The pointer to the first
199 * area structure of a linked list
201 struct area *ap; /* Pointer to the current
206 * An areax structure is created for every A directive found
207 * while reading the REL files. The struct areax contains a
208 * link to the 'unique' area structure referenced by the A
209 * directive and to the head structure this area segment is
210 * a part of. The size of this area segment as read from the
211 * A directive is placed in the areax structure. The beginning
212 * address of this segment will be filled in at the end of the
213 * first pass through the REL files. As A directives are read
214 * from the REL files a linked list of areax structures is
215 * created for each unique area. The final areax linked
216 * list has at its head the 'unique' area structure linked
217 * to the linked areax structures (one areax structure for
218 * each A directive for this area).
222 * struct areax *a_axp; Area extension link
223 * struct area *a_bap; Base area link
224 * struct head *a_bhp; Base header link
225 * Addr_T a_addr; Beginning address of section
226 * Addr_T a_size; Size of the area in section
229 struct areax *axp; /* Pointer to the current
234 * A sym structure is created for every unique symbol
235 * referenced/defined while reading the REL files. The
236 * struct sym contains the symbol's name, a flag value
237 * (not used in this linker), a symbol type denoting
238 * referenced/defined, and an address which is loaded
239 * with the relative address within the area in which
240 * the symbol was defined. The sym structure also
241 * contains a link to the area where the symbol was defined.
242 * The sym structures are linked into linked lists using
243 * the symbol link element.
247 * struct sym *s_sp; Symbol link
248 * struct areax *s_axp; Symbol area link
249 * char s_type; Symbol subtype
250 * char s_flag; Flag byte
251 * Addr_T s_addr; Address
252 * char s_id[NCPS]; Name
255 struct sym *symhash[NHASH]; /* array of pointers to NHASH
256 * linked symbol lists
259 * The struct base contains a pointer to a
260 * base definition string and a link to the next
265 * struct base *b_base; Base link
266 * char *b_strp; String pointer
269 struct base *basep; /* The pointer to the first
272 struct base *bsp; /* Pointer to the current
277 * The struct globl contains a pointer to a
278 * global definition string and a link to the next
283 * struct globl *g_globl; Global link
284 * char *g_strp; String pointer
287 struct globl *globlp;/* The pointer to the first
290 struct globl *gsp; /* Pointer to the current
295 * A structure sdp is created for each 'unique' paged
296 * area definition found as the REL files are read.
297 * As P directives are read from the REL files a linked
298 * list of unique sdp structures is created by placing a
299 * link to the new sdp structure in the previous area structure.
303 * struct area *s_area; Paged Area link
304 * struct areax *s_areax; Paged Area Extension Link
305 * Addr_T s_addr; Page address offset
308 struct sdp sdp; /* Base Page Structure */
311 * The structure rerr is loaded with the information
312 * required to report an error during the linking
313 * process. The structure contains an index value
314 * which selects the areax structure from the header
315 * areax structure list, a mode value which selects
316 * symbol or area relocation, the base address in the
317 * area section, an area/symbol list index value, and
318 * an area/symbol offset value.
322 * int aindex; Linking area
323 * int mode; Relocation mode
324 * Addr_T rtbase; Base address in section
325 * int rindex; Area/Symbol reloaction index
326 * Addr_T rval; Area/Symbol offset value
329 struct rerr rerr; /* Structure containing the
330 * linker error information
334 * The structure lbpath is created for each library
335 * path specification input by the -k option. The
336 * lbpath structures are linked into a list using
337 * the next link element.
340 * struct lbpath *next;
344 struct lbpath *lbphead; /* pointer to the first
345 * library path structure
349 * The structure lbname is created for all combinations of the
350 * library path specifications (input by the -k option) and the
351 * library file specifications (input by the -l option) that
352 * lead to an existing file. The element path points to
353 * the path string, element libfil points to the library
354 * file string, and the element libspc is the concatenation
355 * of the valid path and libfil strings.
357 * The lbpath structures are linked into a list
358 * using the next link element.
360 * Each library file contains a list of object files
361 * that are contained in the particular library. e.g.:
366 * Only one specification per line is allowed.
369 * struct lbname *next;
375 struct lbname *lbnhead; /* pointer to the first
376 * library name structure
380 * The function fndsym() searches through all combinations of the
381 * library path specifications (input by the -k option) and the
382 * library file specifications (input by the -l option) that
383 * lead to an existing file for a symbol definition.
385 * The structure lbfile is created for the first library
386 * object file which contains the definition for the
387 * specified undefined symbol.
389 * The element libspc points to the library file path specification
390 * and element relfil points to the object file specification string.
391 * The element filspc is the complete path/file specification for
392 * the library file to be imported into the linker. The
393 * file specicifation may be formed in one of two ways:
395 * (1) If the library file contained an absolute
396 * path/file specification then this becomes filspc.
399 * (2) If the library file contains a relative path/file
400 * specification then the concatenation of the path
401 * and this file specification becomes filspc.
404 * The lbpath structures are linked into a list
405 * using the next link element.
408 * struct lbfile *next;
414 struct lbfile *lbfhead; /* pointer to the first
415 * library file structure
419 * array of character types, one per
423 /*NUL*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
424 /*BS*/ ILL, SPACE, ILL, ILL, SPACE, ILL, ILL, ILL,
425 /*DLE*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
426 /*CAN*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
427 /*SPC*/ SPACE, ETC, ETC, ETC, LETTER, BINOP, BINOP, ETC,
428 /*(*/ ETC, ETC, BINOP, BINOP, ETC, BINOP, LETTER, BINOP,
429 /*0*/ DGT2, DGT2, DGT8, DGT8, DGT8, DGT8, DGT8, DGT8,
430 /*8*/ DGT10, DGT10, ETC, ETC, BINOP, ETC, BINOP, ETC,
431 /*@*/ ETC, LTR16, LTR16, LTR16, LTR16, LTR16, LTR16, LETTER,
432 /*H*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
433 /*P*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
434 /*X*/ LETTER, LETTER, LETTER, ETC, ETC, ETC, BINOP, LETTER,
435 /*`*/ ETC, LTR16, LTR16, LTR16, LTR16, LTR16, LTR16, LETTER,
436 /*h*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
437 /*p*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
438 /*x*/ LETTER, LETTER, LETTER, ETC, BINOP, ETC, ETC, ETC
442 * an array of characters which
443 * perform the case translation function
448 /*NUL*/ '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
449 /*BS*/ '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
450 /*DLE*/ '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
451 /*CAN*/ '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
452 /*SPC*/ '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
453 /*(*/ '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
454 /*0*/ '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
455 /*8*/ '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
456 /*@*/ '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
457 /*H*/ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
458 /*P*/ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
459 /*X*/ '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
460 /*`*/ '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
461 /*h*/ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
462 /*p*/ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
463 /*x*/ '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177'