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