4 * (C) Copyright 1989-1995
12 * - change s_id from [NCPS] to pointer (comment)
14 * - add jflag and jfp for NoICE output
23 * The module lkdata contains the global variables
24 * and structures used in the linker aslink.
28 * Definitions for all Global Variables
31 char *_abs_ = { ". .ABS." };
33 int lkerr; /* Linker error flag
35 char *ip; /* Pointer into the REL file text line in ib[]
37 char ib[NINPUT]; /* REL file text line
39 char *rp; /* pointer into the LST file
42 char rb[NINPUT]; /* LST file text line being
45 int dflag; /* Debug information output flag
47 int oflag; /* Output file type flag
49 int mflag; /* Map output flag
51 int aflag; /* Overlapping area warning flag
53 int jflag; /* NoICE output flag
55 int xflag; /* Map file radix type flag
57 int pflag; /* print linker command file flag
59 int uflag; /* Listing relocation flag
61 int rflag; /* Extended linear address record flag.
63 int radix; /* current number conversion radix:
64 * 2 (binary), 8 (octal), 10 (decimal),
67 int line; /* current line number
69 int page; /* current page number
71 int lop; /* current line number on page
73 int pass; /* linker pass number
75 int rtcnt; /* count of elements in the
76 * rtval[] and rtflg[] arrays
78 Addr_T rtval[NTXT]; /* data associated with relocation
80 int rtflg[NTXT]; /* indicates if rtval[] value is
81 * to be sent to the output file.
82 * (always set in this linker)
84 int hilo; /* REL file byte ordering
86 int gline; /* LST file relocation active
89 int gcntr; /* LST file relocation active
92 Addr_T iram_size; /* internal ram size
96 * The structure lfile contains a pointer to a
97 * file specification string, the file type, and
98 * a link to the next lfile structure.
102 * struct lfile *f_flp; lfile link
103 * int f_type; File type
104 * char *f_idp; Pointer to file spec
107 struct lfile *filep; /* The pointers (lfile *) filep,
108 * (lfile *) cfp, and (FILE *) sfp
109 * are used in conjunction with
110 * the routine getline() to read
111 * asmlnk commands from
112 * (1) the standard input or
113 * (2) or a command file
114 * and to read the REL files
115 * sequentially as defined by the
116 * asmlnk input commands.
118 * The pointer *filep points to the
119 * beginning of a linked list of
122 struct lfile *cfp; /* The pointer *cfp points to the
123 * current lfile structure
125 struct lfile *startp;/* asmlnk startup file structure
127 struct lfile *linkp; /* pointer to first lfile structure
128 * containing an input REL file
131 struct lfile *lfp; /* pointer to current lfile structure
132 * being processed by parse()
134 FILE *ofp; /* Output file handle
137 FILE *mfp; /* Map output file handle
139 FILE *jfp; /* NoICE output file handle
141 FILE *rfp; /* File handle for output
142 * address relocated ASxxxx
145 FILE *sfp; /* The file handle sfp points to the
146 * currently open file
148 FILE *tfp; /* File handle for input
149 * ASxxxx listing file
151 FILE *dfp = NULL ; /*
152 * File handle for debug
153 * information output file
156 * The structures of head, area, areax, and sym are created
157 * as the REL files are read during the first pass of the
158 * linker. The struct head is created upon encountering a
159 * H directive in the REL file. The structure contains a
160 * link to a link file structure (struct lfile) which describes
161 * the file containing the H directive, the number of data/code
162 * areas contained in this header segment, the number of
163 * symbols referenced/defined in this header segment, a pointer
164 * to an array of pointers to areax structures (struct areax)
165 * created as each A directive is read, and a pointer to an
166 * array of pointers to symbol structures (struct sym) for
167 * all referenced/defined symbols. As H directives are read
168 * from the REL files a linked list of head structures is
169 * created by placing a link to the new head structure
170 * in the previous head structure.
174 * struct head *h_hp; Header link
175 * struct lfile *h_lfile; Associated file
176 * int h_narea; # of areas
177 * struct areax **a_list; Area list
178 * int h_nglob; # of global symbols
179 * struct sym **s_list; Global symbol list
180 * char m_id[NCPS]; Module name
183 struct head *headp; /* The pointer to the first
184 * head structure of a linked list
186 struct head *hp; /* Pointer to the current
191 * A structure area is created for each 'unique' data/code
192 * area definition found as the REL files are read. The
193 * struct area contains the name of the area, a flag byte
194 * which contains the area attributes (REL/CON/OVR/ABS),
195 * an area subtype (not used in this assembler), and the
196 * area base address and total size which will be filled
197 * in at the end of the first pass through the REL files.
198 * As A directives are read from the REL files a linked
199 * list of unique area structures is created by placing a
200 * link to the new area structure in the previous area structure.
204 * struct area *a_ap; Area link
205 * struct areax *a_axp; Area extension link
206 * Addr_T a_addr; Beginning address of area
207 * Addr_T a_size; Total size of the area
208 * char a_type; Area subtype
209 * char a_flag; Flag byte
210 * char a_id[NCPS]; Name
213 struct area *areap; /* The pointer to the first
214 * area structure of a linked list
216 struct area *ap; /* Pointer to the current
221 * An areax structure is created for every A directive found
222 * while reading the REL files. The struct areax contains a
223 * link to the 'unique' area structure referenced by the A
224 * directive and to the head structure this area segment is
225 * a part of. The size of this area segment as read from the
226 * A directive is placed in the areax structure. The beginning
227 * address of this segment will be filled in at the end of the
228 * first pass through the REL files. As A directives are read
229 * from the REL files a linked list of areax structures is
230 * created for each unique area. The final areax linked
231 * list has at its head the 'unique' area structure linked
232 * to the linked areax structures (one areax structure for
233 * each A directive for this area).
237 * struct areax *a_axp; Area extension link
238 * struct area *a_bap; Base area link
239 * struct head *a_bhp; Base header link
240 * Addr_T a_addr; Beginning address of section
241 * Addr_T a_size; Size of the area in section
244 struct areax *axp; /* Pointer to the current
249 * A sym structure is created for every unique symbol
250 * referenced/defined while reading the REL files. The
251 * struct sym contains the symbol's name, a flag value
252 * (not used in this linker), a symbol type denoting
253 * referenced/defined, and an address which is loaded
254 * with the relative address within the area in which
255 * the symbol was defined. The sym structure also
256 * contains a link to the area where the symbol was defined.
257 * The sym structures are linked into linked lists using
258 * the symbol link element.
262 * struct sym *s_sp; Symbol link
263 * struct areax *s_axp; Symbol area link
264 * char s_type; Symbol subtype
265 * char s_flag; Flag byte
266 * Addr_T s_addr; Address
267 * char *s_id; Name (JLH)
270 struct sym *symhash[NHASH]; /* array of pointers to NHASH
271 * linked symbol lists
274 * The struct base contains a pointer to a
275 * base definition string and a link to the next
280 * struct base *b_base; Base link
281 * char *b_strp; String pointer
284 struct base *basep; /* The pointer to the first
287 struct base *bsp; /* Pointer to the current
292 * The struct globl contains a pointer to a
293 * global definition string and a link to the next
298 * struct globl *g_globl; Global link
299 * char *g_strp; String pointer
302 struct globl *globlp;/* The pointer to the first
305 struct globl *gsp; /* Pointer to the current
310 * A structure sdp is created for each 'unique' paged
311 * area definition found as the REL files are read.
312 * As P directives are read from the REL files a linked
313 * list of unique sdp structures is created by placing a
314 * link to the new sdp structure in the previous area structure.
318 * struct area *s_area; Paged Area link
319 * struct areax *s_areax; Paged Area Extension Link
320 * Addr_T s_addr; Page address offset
323 struct sdp sdp; /* Base Page Structure */
326 * The structure rerr is loaded with the information
327 * required to report an error during the linking
328 * process. The structure contains an index value
329 * which selects the areax structure from the header
330 * areax structure list, a mode value which selects
331 * symbol or area relocation, the base address in the
332 * area section, an area/symbol list index value, and
333 * an area/symbol offset value.
337 * int aindex; Linking area
338 * int mode; Relocation mode
339 * Addr_T rtbase; Base address in section
340 * int rindex; Area/Symbol reloaction index
341 * Addr_T rval; Area/Symbol offset value
344 struct rerr rerr; /* Structure containing the
345 * linker error information
349 * The structure lbpath is created for each library
350 * path specification input by the -k option. The
351 * lbpath structures are linked into a list using
352 * the next link element.
355 * struct lbpath *next;
359 struct lbpath *lbphead; /* pointer to the first
360 * library path structure
364 * The structure lbname is created for all combinations of the
365 * library path specifications (input by the -k option) and the
366 * library file specifications (input by the -l option) that
367 * lead to an existing file. The element path points to
368 * the path string, element libfil points to the library
369 * file string, and the element libspc is the concatenation
370 * of the valid path and libfil strings.
372 * The lbpath structures are linked into a list
373 * using the next link element.
375 * Each library file contains a list of object files
376 * that are contained in the particular library. e.g.:
381 * Only one specification per line is allowed.
384 * struct lbname *next;
390 struct lbname *lbnhead; /* pointer to the first
391 * library name structure
395 * The function fndsym() searches through all combinations of the
396 * library path specifications (input by the -k option) and the
397 * library file specifications (input by the -l option) that
398 * lead to an existing file for a symbol definition.
400 * The structure lbfile is created for the first library
401 * object file which contains the definition for the
402 * specified undefined symbol.
404 * The element libspc points to the library file path specification
405 * and element relfil points to the object file specification string.
406 * The element filspc is the complete path/file specification for
407 * the library file to be imported into the linker. The
408 * file specicifation may be formed in one of two ways:
410 * (1) If the library file contained an absolute
411 * path/file specification then this becomes filspc.
414 * (2) If the library file contains a relative path/file
415 * specification then the concatenation of the path
416 * and this file specification becomes filspc.
419 * The lbpath structures are linked into a list
420 * using the next link element.
423 * struct lbfile *next;
429 struct lbfile *lbfhead; /* pointer to the first
430 * library file structure
434 * array of character types, one per
438 /*NUL*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
439 /*BS*/ ILL, SPACE, ILL, ILL, SPACE, ILL, ILL, ILL,
440 /*DLE*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
441 /*CAN*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
442 /*SPC*/ SPACE, ETC, ETC, ETC, LETTER, BINOP, BINOP, ETC,
443 /*(*/ ETC, ETC, BINOP, BINOP, ETC, BINOP, LETTER, BINOP,
444 /*0*/ DGT2, DGT2, DGT8, DGT8, DGT8, DGT8, DGT8, DGT8,
445 /*8*/ DGT10, DGT10, ETC, ETC, BINOP, ETC, BINOP, ETC,
446 /*@*/ ETC, LTR16, LTR16, LTR16, LTR16, LTR16, LTR16, LETTER,
447 /*H*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
448 /*P*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
449 /*X*/ LETTER, LETTER, LETTER, ETC, ETC, ETC, BINOP, LETTER,
450 /*`*/ ETC, LTR16, LTR16, LTR16, LTR16, LTR16, LTR16, LETTER,
451 /*h*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
452 /*p*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
453 /*x*/ LETTER, LETTER, LETTER, ETC, BINOP, ETC, ETC, ETC
457 * an array of characters which
458 * perform the case translation function
463 /*NUL*/ '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
464 /*BS*/ '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
465 /*DLE*/ '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
466 /*CAN*/ '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
467 /*SPC*/ '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
468 /*(*/ '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
469 /*0*/ '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
470 /*8*/ '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
471 /*@*/ '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
472 /*H*/ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
473 /*P*/ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
474 /*X*/ '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
475 /*`*/ '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
476 /*h*/ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
477 /*p*/ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
478 /*x*/ '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177'