4f21df913777f7cdee9dc17ba934bf428ab3bf1d
[fw/sdcc] / as / link / aslink.h
1 /* aslink.h */
2
3 /*
4  * (C) Copyright 1989-1996
5  * All Rights Reserved
6  *
7  * Alan R. Baldwin
8  * 721 Berkeley St.
9  * Kent, Ohio  44240
10  *
11  * 28-Oct-97 JLH:
12  *           - add proto for StoreString
13  *           - change s_id from [NCPS] to pointer
14  *           - change NCPS to 80
15  *           - case sensitive
16  *           - add R_J11 for 8051 assembler
17  * 31-Oct-97 JLH:
18  *           - add jflag and jfp for NoICE output
19  * 30-Jan-98 JLH:
20  *           - add memory space flags to a_flag for 8051
21  *
22  * Extensions: P. Felber
23  */
24
25 #define VERSION "V01.75 + NoICE + SDCC Feb 1999"
26
27 /*
28  * Case Sensitivity Flag
29  */
30 #define CASE_SENSITIVE  1
31
32 /*)Module       asmlnk.h
33  *
34  *      The module asmlnk.h contains the definitions for constants,
35  *      structures, global variables, and LKxxxx functions
36  *      contained in the LKxxxx.c files.
37  */
38
39 /*)BUILD
40         $(PROGRAM) =    ASLINK
41         $(INCLUDE) =    ASLINK.H
42         $(FILES) = {
43                 LKMAIN.C
44                 LKLEX.C
45                 LKAREA.C
46                 LKHEAD.C
47                 LKSYM.C
48                 LKEVAL.C
49                 LKDATA.C
50                 LKLIST.C
51                 LKRLOC.C
52                 LKLIBR.C
53                 LKS19.C
54                 LKIHX.C
55         }
56         $(STACK) = 2000
57 */
58
59 #if defined  decus
60 /* DECUS C void definition */
61 /* File/extension seperator */
62
63 #define VOID        char
64 #define FSEPX       '.'
65
66 #elif defined  PDOS
67 /* PDOS C void definition */
68 /* File/extension seperator */
69
70 #define VOID        char
71 #define FSEPX       ':'
72
73 #elif defined UNIX
74 /* UNIX void definition */
75 /* File/extension seperator */
76
77 #define VOID        void
78 #define FSEPX       '.'
79 #define LKDIRSEP    '/'
80 #define LKDIRSEPSTR "/"
81 #define OTHERSYSTEM
82
83 #else
84 /* DOS/WINDOWS void definition */
85 /* File/extension seperator */
86
87 #define VOID        void
88 #define FSEPX       '.'
89 #define LKDIRSEP    '\\'
90 #define LKDIRSEPSTR "\\"
91 #define OTHERSYSTEM
92
93 #endif
94
95 /*
96  * PATH_MAX
97  */
98 #include <limits.h>
99 #ifndef PATH_MAX                /* POSIX, but not required   */
100  #if defined(__BORLANDC__) || defined(_MSC_VER)
101   #include <stdlib.h>
102   #define PATH_MAX      _MAX_PATH
103  #else
104   #define PATH_MAX      255     /* define a reasonable value */
105  #endif
106 #endif
107
108 #ifdef SDK
109     #define LKOBJEXT "o"
110 #else /* SDK */
111     #define LKOBJEXT "rel"
112 #endif /* SDK */
113
114 /*
115  * This file defines the format of the
116  * relocatable binary file.
117  */
118
119 #define NCPS    80              /* characters per symbol (JLH: change from 8) */
120 #define NDATA   16              /* actual data */
121 #define NINPUT  PATH_MAX        /* Input buffer size */
122 #define NHASH   64              /* Buckets in hash table */
123 #define HMASK   077             /* Hash mask */
124 #define NLPP    60              /* Lines per page */
125 #define NTXT    16              /* T values */
126
127 /*
128  *      The "R_" relocation constants define values used in
129  *      generating the assembler relocation output data for
130  *      areas, symbols, and code.
131  *
132  *
133  *      Relocation types.
134  *
135  *             7     6     5     4     3     2     1     0
136  *          +-----+-----+-----+-----+-----+-----+-----+-----+
137  *          | MSB | PAGn| PAG0| USGN| BYT2| PCR | SYM | BYT |
138  *          +-----+-----+-----+-----+-----+-----+-----+-----+
139  */
140
141 #define R_WORD  0x00            /* 16 bit */
142 #define R_BYTE  0x01            /*  8 bit */
143
144 #define R_AREA  0x00            /* Base type */
145 #define R_SYM   0x02
146
147 #define R_NORM  0x00            /* PC adjust */
148 #define R_PCR   0x04
149
150 #define R_BYT1  0x00            /* Byte count for R_BYTE = 1 */
151 #define R_BYT2  0x08            /* Byte count for R_BYTE = 2 */
152
153 #define R_SGND  0x00            /* Signed Byte */
154 #define R_USGN  0x10            /* Unsigned Byte */
155
156 #define R_NOPAG 0x00            /* Page Mode */
157 #define R_PAG0  0x20            /* Page '0' */
158 #define R_PAG   0x40            /* Page 'nnn' */
159
160 #define R_LSB   0x00            /* low byte */
161 #define R_MSB   0x80            /* high byte */
162
163 #define R_BYT3  0x100           /* if R_BYTE is set, this is a
164                                  * 3 byte address, of which
165                                  * the linker must select one byte.
166                                  */
167 #define R_HIB   0x200           /* If R_BYTE & R_BYT3 are set, linker
168                                  * will select byte 3 of the relocated
169                                  * 24 bit address.
170                                  */
171
172 #define R_BIT   0x400           /* Linker will convert from byte-addressable
173                                  * space to bit-addressable space.
174                                  */
175
176 #define R_J11   (R_WORD|R_BYT2) /* JLH: 11 bit JMP and CALL (8051) */
177 #define R_J19   (R_WORD|R_BYT2|R_MSB) /* 19 bit JMP/CALL (DS80C390) */
178 #define R_C24   (R_WORD|R_BYT1|R_MSB) /* 24 bit address (DS80C390) */
179 #define R_J19_MASK (R_BYTE|R_BYT2|R_MSB)
180
181 #define IS_R_J19(x) (((x) & R_J19_MASK) == R_J19)
182 #define IS_R_J11(x) (((x) & R_J19_MASK) == R_J11)
183 #define IS_C24(x) (((x) & R_J19_MASK) == R_C24)
184
185 #define R_ESCAPE_MASK   0xf0    /* Used to escape relocation modes
186                                  * greater than 0xff in the .rel
187                                  * file.
188                                  */
189
190 /*
191  * Global symbol types.
192  */
193 #define S_REF   1               /* referenced */
194 #define S_DEF   2               /* defined */
195
196 /*
197  * Area type flags
198  */
199 #define A_CON     0000          /* concatenate */
200 #define A_OVR     0004          /* overlay */
201 #define A_REL     0000          /* relocatable */
202 #define A_ABS     0010          /* absolute */
203 #define A_NOPAG   0000          /* non-paged */
204 #define A_PAG     0020          /* paged */
205
206 /* Additional flags for 8051 address spaces */
207 #define A_DATA    0000          /* data space (default)*/
208 #define A_CODE    0040          /* code space */
209 #define A_XDATA   0100          /* external data space */
210 #define A_BIT     0200          /* bit addressable space */
211
212 /* Additional flags for hc08 */
213 #define A_NOLOAD  0400          /* nonloadable */
214 #define A_LOAD    0000          /* loadable (default) */
215
216 /*
217  * File types
218  */
219 #define F_INV   0               /* invalid */
220 #define F_STD   1               /* stdin */
221 #define F_LNK   2               /* File.lnk */
222 #define F_REL   3               /* File.rel */
223 #define F_CMD   4               /* Command line */
224
225 #ifdef GAMEBOY
226 /*
227  * Multiple banks support
228  */
229 extern int nb_rom_banks;
230 extern int nb_ram_banks;
231 extern int current_rom_bank;
232 extern int mbc_type;
233 extern char cart_name[];
234 /*
235  * ROM patching support
236  */
237 typedef struct _patch {
238   unsigned int addr;
239   unsigned char value;
240   struct _patch *next;
241 } patch;
242 extern patch* patches;
243 #endif /* GAMEBOY */
244
245 /*
246  *      General assembler address type
247  */
248 typedef unsigned int Addr_T;
249
250 /*
251  *      The structures of head, area, areax, and sym are created
252  *      as the REL files are read during the first pass of the
253  *      linker.  The struct head is created upon encountering a
254  *      H directive in the REL file.  The structure contains a
255  *      link to a link file structure (struct lfile) which describes
256  *      the file containing the H directive, the number of data/code
257  *      areas contained in this header segment, the number of
258  *      symbols referenced/defined in this header segment, a pointer
259  *      to an array of pointers to areax structures (struct areax)
260  *      created as each A directive is read, and a pointer to an
261  *      array of pointers to symbol structures (struct sym) for
262  *      all referenced/defined symbols.  As H directives are read
263  *      from the REL files a linked list of head structures is
264  *      created by placing a link to the new head structure
265  *      in the previous head structure.
266  */
267 struct  head
268 {
269         struct  head   *h_hp;   /* Header link */
270         struct  lfile  *h_lfile;/* Associated file */
271         int     h_narea;        /* # of areas */
272         struct  areax **a_list; /* Area list */
273         int     h_nglob;        /* # of global symbols */
274         struct  sym   **s_list; /* Globle symbol list */
275         char    m_id[NCPS];     /* Module name */
276 };
277
278 /*
279  *      A structure area is created for each 'unique' data/code
280  *      area definition found as the REL files are read.  The
281  *      struct area contains the name of the area, a flag byte
282  *      which contains the area attributes (REL/CON/OVR/ABS),
283  *      an area subtype (not used in this assembler), and the
284  *      area base address and total size which will be filled
285  *      in at the end of the first pass through the REL files.
286  *      As A directives are read from the REL files a linked
287  *      list of unique area structures is created by placing a
288  *      link to the new area structure in the previous area structure.
289  */
290 struct  area
291 {
292         struct  area    *a_ap;  /* Area link */
293         struct  areax   *a_axp; /* Area extension link */
294         Addr_T  a_addr;         /* Beginning address of area */
295         Addr_T  a_size;         /* Total size of the area */
296         Addr_T  a_unaloc;       /* Total number of unallocated bytes, for error reporting */
297         char    a_type;         /* Area subtype */
298         int     a_flag;         /* Flag byte */
299         char    a_id[NCPS];     /* Name */
300         char    *a_image;       /* Something for hc08/lkelf */
301         char    *a_used;        /* Something for hc08/lkelf */
302 };
303
304 /*
305  *      An areax structure is created for every A directive found
306  *      while reading the REL files.  The struct areax contains a
307  *      link to the 'unique' area structure referenced by the A
308  *      directive and to the head structure this area segment is
309  *      a part of.  The size of this area segment as read from the
310  *      A directive is placed in the areax structure.  The beginning
311  *      address of this segment will be filled in at the end of the
312  *      first pass through the REL files.  As A directives are read
313  *      from the REL files a linked list of areax structures is
314  *      created for each unique area.  The final areax linked
315  *      list has at its head the 'unique' area structure linked
316  *      to the linked areax structures (one areax structure for
317  *      each A directive for this area).
318  */
319 struct  areax
320 {
321         struct  areax   *a_axp; /* Area extension link */
322         struct  area    *a_bap; /* Base area link */
323         struct  head    *a_bhp; /* Base header link */
324         Addr_T  a_addr;         /* Beginning address of section */
325         Addr_T  a_size;         /* Size of the area in section */
326 };
327
328 /*
329  *      A sym structure is created for every unique symbol
330  *      referenced/defined while reading the REL files.  The
331  *      struct sym contains the symbol's name, a flag value
332  *      (not used in this linker), a symbol type denoting
333  *      referenced/defined, and an address which is loaded
334  *      with the relative address within the area in which
335  *      the symbol was defined.  The sym structure also
336  *      contains a link to the area where the symbol was defined.
337  *      The sym structures are linked into linked lists using
338  *      the symbol link element.
339  */
340 struct  sym
341 {
342         struct  sym     *s_sp;  /* Symbol link */
343         struct  areax   *s_axp; /* Symbol area link */
344         char    s_type;         /* Symbol subtype */
345         char    s_flag;         /* Flag byte */
346         Addr_T  s_addr;         /* Address */
347         char    *s_id;          /* Name: JLH change from [NCPS] */
348 };
349
350 /*
351  *      The structure lfile contains a pointer to a
352  *      file specification string, the file type, and
353  *      a link to the next lfile structure.
354  */
355 struct  lfile
356 {
357         struct  lfile   *f_flp; /* lfile link */
358         int     f_type;         /* File type */
359         char    *f_idp;         /* Pointer to file spec */
360 };
361
362 /*
363  *      The struct base contains a pointer to a
364  *      base definition string and a link to the next
365  *      base structure.
366  */
367 struct  base
368 {
369         struct  base  *b_base;  /* Base link */
370         char          *b_strp;  /* String pointer */
371 };
372
373 /*
374  *      The struct globl contains a pointer to a
375  *      global definition string and a link to the next
376  *      global structure.
377  */
378 struct  globl
379 {
380         struct  globl *g_globl; /* Global link */
381         char          *g_strp;  /* String pointer */
382 };
383
384 /*
385  *      A structure sdp is created for each 'unique' paged
386  *      area definition found as the REL files are read.
387  *      As P directives are read from the REL files a linked
388  *      list of unique sdp structures is created by placing a
389  *      link to the new sdp structure in the previous area structure.
390  */
391 struct  sdp
392 {
393         struct  area  *s_area;  /* Paged Area link */
394         struct  areax *s_areax; /* Paged Area Extension Link */
395         Addr_T  s_addr;         /* Page address offset */
396 };
397
398 /*
399  *      The structure rerr is loaded with the information
400  *      required to report an error during the linking
401  *      process.  The structure contains an index value
402  *      which selects the areax structure from the header
403  *      areax structure list, a mode value which selects
404  *      symbol or area relocation, the base address in the
405  *      area section, an area/symbol list index value, and
406  *      an area/symbol offset value.
407  */
408 struct  rerr
409 {
410         int     aindex;         /* Linking area */
411         int     mode;           /* Relocation mode */
412         Addr_T  rtbase;         /* Base address in section */
413         int     rindex;         /* Area/Symbol reloaction index */
414         Addr_T  rval;           /* Area/Symbol offset value */
415 };
416
417 /*
418  *      The structure lbpath is created for each library
419  *      path specification input by the -k option.  The
420  *      lbpath structures are linked into a list using
421  *      the next link element.
422  */
423 struct lbpath {
424         struct  lbpath  *next;
425         char            *path;
426 };
427
428 /*
429  *      The structure lbname is created for all combinations of the
430  *      library path specifications (input by the -k option) and the
431  *      library file specifications (input by the -l option) that
432  *      lead to an existing file.  The element path points to
433  *      the path string, element libfil points to the library
434  *      file string, and the element libspc is the concatenation
435  *      of the valid path and libfil strings.
436  *
437  *      The lbpath structures are linked into a list
438  *      using the next link element.
439  *
440  *      Each library file contains a list of object files
441  *      that are contained in the particular library. e.g.:
442  *
443  *              \iolib\termio
444  *              \inilib\termio
445  *
446  *      Only one specification per line is allowed.
447  */
448 struct lbname {
449         struct  lbname  *next;
450         char            *path;
451         char            *libfil;
452         char            *libspc;
453 };
454
455 /*
456  *      The function fndsym() searches through all combinations of the
457  *      library path specifications (input by the -k option) and the
458  *      library file specifications (input by the -l option) that
459  *      lead to an existing file for a symbol definition.
460  *
461  *      The structure lbfile is created for the first library
462  *      object file which contains the definition for the
463  *      specified undefined symbol.
464  *
465  *      The element libspc points to the library file path specification
466  *      and element relfil points to the object file specification string.
467  *      The element filspc is the complete path/file specification for
468  *      the library file to be imported into the linker.  The
469  *      file specicifation may be formed in one of two ways:
470  *
471  *      (1)     If the library file contained an absolute
472  *              path/file specification then this becomes filspc.
473  *              (i.e. C:\...)
474  *
475  *      (2)     If the library file contains a relative path/file
476  *              specification then the concatenation of the path
477  *              and this file specification becomes filspc.
478  *              (i.e. \...)
479  *
480  *      The lbpath structures are linked into a list
481  *      using the next link element.
482  */
483 struct lbfile {
484         struct  lbfile  *next;
485         char            *libspc;
486         char            *relfil;
487         char            *filspc;
488         long            offset;
489         unsigned int    type;
490 };
491
492 /*
493  *      External Definitions for all Global Variables
494  */
495
496 extern  char    *_abs_;         /*      = { ".  .ABS." };
497                                  */
498 extern  int     lkerr;          /*      ASLink error flag
499                                  */
500 extern  char    *ip;            /*      pointer into the REL file
501                                  *      text line in ib[]
502                                  */
503 extern  char    ib[NINPUT];     /*      REL file text line
504                                  */
505 extern  char    *rp;            /*      pointer into the LST file
506                                  *      text line in rb[]
507                                  */
508 extern  char    rb[NINPUT];     /*      LST file text line being
509                                  *      address relocated
510                                  */
511 extern  unsigned char   ctype[];        /*      array of character types, one per
512                                  *      ASCII character
513                                  */
514
515 extern char sdccopt[NINPUT];
516 extern char sdccopt_module[NINPUT];
517 extern char curr_module[NINPUT];
518
519 /*
520  *      Character Type Definitions
521  */
522 #define SPACE   0000
523 #define ETC     0000
524 #define LETTER  0001
525 #define DIGIT   0002
526 #define BINOP   0004
527 #define RAD2    0010
528 #define RAD8    0020
529 #define RAD10   0040
530 #define RAD16   0100
531 #define ILL     0200
532
533 #define DGT2    DIGIT|RAD16|RAD10|RAD8|RAD2
534 #define DGT8    DIGIT|RAD16|RAD10|RAD8
535 #define DGT10   DIGIT|RAD16|RAD10
536 #define LTR16   LETTER|RAD16
537
538 #if     CASE_SENSITIVE
539 #else
540 extern  char    ccase[];        /*      an array of characters which
541                                  *      perform the case translation function
542                                  */
543 #endif
544
545 extern  struct  lfile   *filep; /*      The pointers (lfile *) filep,
546                                  *      (lfile *) cfp, and (FILE *) sfp
547                                  *      are used in conjunction with
548                                  *      the routine lk_getline() to read
549                                  *      asmlnk commands from
550                                  *      (1) the standard input or
551                                  *      (2) or a command file
552                                  *      and to read the REL files
553                                  *      sequentially as defined by the
554                                  *      asmlnk input commands.
555                                  *
556                                  *      The pointer *filep points to the
557                                  *      beginning of a linked list of
558                                  *      lfile structures.
559                                  */
560 extern  struct  lfile   *cfp;   /*      The pointer *cfp points to the
561                                  *      current lfile structure
562                                  */
563 extern  struct  lfile   *startp;/*      asmlnk startup file structure
564                                  */
565 extern  struct  lfile   *linkp; /*      pointer to first lfile structure
566                                  *      containing an input REL file
567                                  *      specification
568                                  */
569 extern  struct  lfile   *lfp;   /*      pointer to current lfile structure
570                                  *      being processed by parse()
571                                  */
572 extern  struct  head    *headp; /*      The pointer to the first
573                                  *      head structure of a linked list
574                                  */
575 extern  struct  head    *hp;    /*      Pointer to the current
576                                  *      head structure
577                                  */
578 extern  struct  area    *areap; /*      The pointer to the first
579                                  *      area structure of a linked list
580                                  */
581 extern  struct  area    *ap;    /*      Pointer to the current
582                                  *      area structure
583                                  */
584 extern  struct  areax   *axp;   /*      Pointer to the current
585                                  *      areax structure
586                                  */
587 extern  struct  sym *symhash[NHASH]; /* array of pointers to NHASH
588                                       * linked symbol lists
589                                       */
590 extern  struct  base    *basep; /*      The pointer to the first
591                                  *      base structure
592                                  */
593 extern  struct  base    *bsp;   /*      Pointer to the current
594                                  *      base structure
595                                  */
596 extern  struct  globl   *globlp;/*      The pointer to the first
597                                  *      globl structure
598                                  */
599 extern  struct  globl   *gsp;   /*      Pointer to the current
600                                  *      globl structure
601                                  */
602 extern  struct  sdp     sdp;    /*      Base Paged structure
603                                  */
604 extern  struct  rerr    rerr;   /*      Structure containing the
605                                  *      linker error information
606                                  */
607 extern  FILE    *ofp;           /*      Linker Output file handle
608                                  */
609 extern  FILE    *mfp;           /*      Map output file handle
610                                  */
611 extern  FILE    *jfp;           /*      NoICE output file handle
612                                  */
613 extern  FILE    *rfp;           /*      File handle for output
614                                  *      address relocated ASxxxx
615                                  *      listing file
616                                  */
617 extern  FILE    *sfp;           /*      The file handle sfp points to the
618                                  *      currently open file
619                                  */
620 extern  FILE    *tfp;           /*      File handle for input
621                                  *      ASxxxx listing file
622                                  */
623 extern  FILE    *dfp;           /*      File handle for debug info output
624                                  */
625 extern  int     dflag;          /*      Output debug information flag
626                                  */
627 extern  int     oflag;          /*      Output file type flag
628                                  */
629 extern  int     mflag;          /*      Map output flag
630                                  */
631 extern  int     sflag;          /*      JCF: Memory usage output flag
632                                  */
633 extern  int     packflag;       /*      Pack data memory flag
634                                  */
635 extern  int     stacksize;      /*      Pack data memory flag
636                                  */
637 extern  int     jflag;          /*      NoICE output flag
638                                  */
639 extern  int     symflag;        /*      no$gmb .sym output flag
640                                  */
641 extern  int     xflag;          /*      Map file radix type flag
642                                  */
643 extern  int     pflag;          /*      print linker command file flag
644                                  */
645 extern  int     uflag;          /*      Listing relocation flag
646                                  */
647 extern int      rflag;          /*      Extended linear address record flag.
648                                 */
649 extern  int     radix;          /*      current number conversion radix:
650                                  *      2 (binary), 8 (octal), 10 (decimal),
651                                  *      16 (hexadecimal)
652                                  */
653 extern  int     line;           /*      current line number
654                                  */
655 extern  int     page;           /*      current page number
656                                  */
657 extern  int     lop;            /*      current line number on page
658                                  */
659 extern  int     pass;           /*      linker pass number
660                                  */
661 extern  int     rtcnt;          /*      count of elements in the
662                                  *      rtval[] and rtflg[] arrays
663                                  */
664 extern  Addr_T  rtval[];        /*      data associated with relocation
665                                  */
666 extern  int     rtflg[];        /*      indicates if rtval[] value is
667                                  *      to be sent to the output file.
668                                  *      (always set in this linker)
669                                  */
670 extern  int     hilo;           /*      REL file byte ordering
671                                  */
672 extern  int     gline;          /*      LST file relocation active
673                                  *      for current line
674                                  */
675 extern  int     gcntr;          /*      LST file relocation active
676                                  *      counter
677                                  */
678 extern  struct lbpath *lbphead; /*      pointer to the first
679                                  *      library path structure
680                                  */
681 extern  struct lbname *lbnhead; /*      pointer to the first
682                                  *      library name structure
683                                  */
684 extern  struct lbfile *lbfhead; /*      pointer to the first
685                                  *      library file structure
686                                  */
687 extern  Addr_T iram_size;       /*      internal ram size
688                                  */
689 extern  long xram_size;         /*      external ram size
690                                  */
691 extern  long code_size;         /*      code size
692                                  */
693
694
695 /* C Library function definitions */
696 /* for reference only
697 extern  VOID            exit();
698 extern  int             fclose();
699 extern  char *          fgets();
700 extern  FILE *          fopen();
701 extern  int             fprintf();
702 extern  VOID            free();
703 extern  VOID *          malloc();
704 extern  char            putc();
705 extern  char *          strcpy();
706 extern  int             strlen();
707 extern  char *          strncpy();
708 */
709
710 /* Program function definitions */
711
712 /* lkmain.c */
713 extern  FILE *          afile();
714 extern  VOID            bassav();
715 extern  VOID            gblsav();
716 extern  VOID            iramsav();
717 extern  VOID            xramsav();
718 extern  VOID            codesav();
719 extern  VOID            iramcheck();
720 extern  VOID            link_main();
721 extern  VOID            lkexit();
722 extern  int             main();
723 extern  VOID            map();
724 extern  VOID            sym();
725 extern  int             parse();
726 extern  VOID            setbas();
727 extern  VOID            setgbl();
728 extern  VOID            usage();
729 extern  VOID            copyfile();
730
731 /* lklex.c */
732 extern  char            endline();
733 extern  char            get();
734 extern  VOID            getfid();
735 extern  VOID            getid();
736 extern  VOID            getSid(char *id);
737 extern  int             lk_getline();
738 extern  int             getmap();
739 extern  char            getnb();
740 extern  int             more();
741 extern  VOID            skip();
742 extern  VOID            unget();
743 extern  VOID            chop_crlf();
744
745 /* lkarea.c */
746 extern  VOID            lkparea();
747 extern  VOID            lnkarea();
748 extern  VOID            lnkarea2();
749 extern  VOID            newarea();
750
751 /* lkhead.c */
752 extern  VOID            module();
753 extern  VOID            newhead();
754
755 /* lksym.c */
756 extern  int             hash();
757 extern  struct  sym *   lkpsym();
758 extern  VOID *          new();
759 extern  struct  sym *   newsym();
760 extern  VOID            symdef();
761 extern  int             symeq();
762 extern  VOID            syminit();
763 extern  VOID            symmod();
764 extern  Addr_T          symval();
765
766 /* lkeval.c */
767 extern  int             digit();
768 extern  Addr_T          eval();
769 extern  Addr_T          expr();
770 extern  int             oprio();
771 extern  Addr_T          term();
772
773 /* lklist.c */
774 extern  int             dgt();
775 extern  VOID            lkulist();
776 extern  VOID            lkalist();
777 extern  VOID            lkglist();
778 extern  VOID            lstarea();
779 extern  VOID            newpag();
780 extern  VOID            slew();
781
782 /* lkrloc.c */
783 extern  Addr_T          adb_b(register Addr_T v, register int i);
784 extern  Addr_T          adb_bit(register Addr_T v, register int i);
785 extern  Addr_T          adb_hi(Addr_T  v, int i);
786 extern  Addr_T          adb_lo(Addr_T  v, int i);
787 extern  Addr_T          adb_24_bit(register Addr_T v, register int i);
788 extern  Addr_T          adb_24_hi(Addr_T v, int i);
789 extern  Addr_T          adb_24_mid(Addr_T v, int i);
790 extern  Addr_T          adb_24_lo(Addr_T v, int i);
791 extern  Addr_T          adw_w(register Addr_T v, register int i);
792 extern  Addr_T          adw_24(Addr_T v, int i);
793 extern  Addr_T          adw_hi(Addr_T  v, int i);
794 extern  Addr_T          adw_lo(Addr_T  v, int i);
795 extern  Addr_T          evword(VOID);
796 extern  VOID            rele(VOID);
797 extern  VOID            reloc(char c);
798 extern  VOID            relt(VOID);
799 extern  VOID            relr(VOID);
800 extern  VOID            relp(VOID);
801 extern  VOID            relerr(char *str);
802 extern  char *          errmsg[];
803 extern  VOID            errdmp(FILE *fptr, char *str);
804 extern  VOID            relerp(char *str);
805 extern  VOID            erpdmp(FILE *fptr, char *str);
806 extern  VOID            prntval(FILE *fptr, Addr_T v);
807 extern  int             lastExtendedAddress;
808
809 /* lklibr.c */
810 extern  int             addfile();
811 extern  VOID            addlib();
812 extern  VOID            addpath();
813 extern  int             fndsym();
814 extern  VOID            library();
815 extern  VOID            loadfile();
816 extern  VOID            search();
817
818 /* lks19.c */
819 extern  VOID            s19();
820
821 /* lkihx.c */
822 extern  VOID            ihx();
823 extern  VOID            ihxExtendedLinearAddress(Addr_T);
824 extern  VOID            ihxNewArea();
825
826 /* lkstore.c */
827 extern  char *          StoreString( char *str );
828
829 /* lknoice.c */
830 extern  void            DefineNoICE( char *name, Addr_T value, int page );
831
832 /* EEP: lkelf.c */
833 extern  VOID            elf();
834
835 /* JCF: lkmem.c */
836 extern int summary(struct area * xp);
837 extern int summary2(struct area * xp);
838
839 /* JCF: lkaomf51.c */
840 extern void SaveLinkedFilePath(char * filepath);
841 extern void CreateAOMF51(void);
842
843 /* lkgb.h */
844 VOID gb(int in);
845 VOID gg(int in);
846
847 /* strcmpi.h */
848 extern int as_strcmpi(const char *s1, const char *s2);
849 extern int as_strncmpi(const char *s1, const char *s2, size_t n);