|
|
1.1 root 1: /*
2: * General Loader-Binder
3: *
4: * Knows about FILE struct to the extent it is revealed in putc
5: * if BREADBOX is non-zero
6: *
7: */
8:
9: #include <stdio.h>
10: #include <canon.h>
11: #include <l.out.h>
12: #include <ar.h>
13: #include <sys/stat.h>
14:
15: typedef unsigned long uaddr_t; /* universal address type */
16:
17: /*
18: * Macro to test for symbol equality.
19: */
20: #define eq( s1, s2 ) ( strncmp( s1, s2, NCPLN ) == 0 )
21:
22: /*
23: * Segment descriptor
24: */
25: typedef struct seg_s {
26: uaddr_t vbase; /* virtual address base */
27: fsize_t daddr, /* seek addr of segment */
28: size; /* size */
29: } seg_t;
30:
31: /*
32: * Symbol descriptor
33: */
34: typedef struct sym_t {
35: struct sym_t *next; /* chained together */
36: struct ldsym s; /* id and value */
37: struct mod_t *mod; /* pass 1; defining module */
38: unsigned int symno; /* pass 2; symbol number */
39: } sym_t; /* above 2 items could be united */
40:
41: /*
42: * Descriptor for each input module
43: */
44: typedef struct mod_t {
45: struct mod_t *next; /* chained together */
46: char *fname; /* file containing module */
47: char mname[DIRSIZ]; /* module name if in archive */
48: seg_t seg[NLSEG]; /* descriptor for each segment */
49: unsigned int nsym; /* #symbols for this module */
50: sym_t *sym[]; /* array of nsym symbol ptrs */
51: } mod_t;
52:
53: /*
54: * Command line flag option
55: */
56: typedef int flag_t;
57:
58: typedef struct ar_hdr arh_t;
59: typedef struct ar_sym ars_t;
60: typedef struct ldheader ldh_t;
61: typedef struct ldsym lds_t;
62:
63: /*
64: * Structures built in pass 1, used in pass 2
65: */
66: #define NHASH 64
67:
68: /*
69: * Seconds between ranlib update and archive modify times
70: */
71: #define SLOPTIME 150
72:
73: /*
74: * Values for worder
75: */
76: #define LOHI 0
77: #define HILO 1
78:
79: /*
80: * For pass 2; these will change if format of relocation changed
81: */
82: #define getaddr getlohi
83: #define putaddr(addr, fp, sgp) putlohi((short)(addr), fp, sgp)
84: #define getsymno getlohi
85: #define putsymno putlohi
86:
87: /*
88: * C requires this...
89: */
90: void baseall(), endbind(), undef();
91: uaddr_t setbase(), newpage(), lentry();
92: fsize_t segoffs();
93: void symredef(), rdsystem();
94: sym_t *addsym(), *symref(), *newsym();
95: fsize_t symoff();
96: void loadmod(), putstruc(), putword(), putlohi(), puthilo(), putbyte();
97: unsigned short getword(), getlohi(), gethilo();
98: void message(), fatal(), usage(), filemsg(), modmsg(), mpmsg(), spmsg();
99:
100: /*
101: * Start variables & constants
102: */
103:
104: extern sym_t * symtable[NHASH]; /* hashed symbol table */
105: extern mod_t * modhead, *modtail; /* module list head and tail */
106: extern sym_t * etext_s,*edata_s,*end_s;/* special loader generated symbols */
107: extern char etext_id[NCPLN], /* and their names */
108: edata_id[NCPLN],
109: end_id[NCPLN];
110: extern ldh_t oldh; /* output load file header */
111: extern char *mchname[]; /* names of known machines */
112: extern uaddr_t segsize[], /* size of segment on target machine */
113: drvbase[], /* base of loadable driver */
114: drvtop[]; /* address limit of loadable driver */
115:
116: extern flag_t noilcl, /* discard internal symbols `L...' */
117: nolcl, /* discard local symbols */
118: watch, /* watch everything happen */
119: worder; /* byte order in word; depends on machine */
120:
121: /*
122: * Structures associated with storage economy
123: */
124: extern char pbuf1[BUFSIZ], /* permanent i/o buffers */
125: pbuf2[BUFSIZ];
126: extern mod_t *mtemp; /* only one module in core at a time */
127: extern FILE *mfp; /* temp file for module structures */
128: extern int mdisk, /* flag <>0 means module struct to disk */
129: nmod, /* module count */
130: mxmsym; /* max # of symbols ref'd by 1 module */
131:
132: extern sym_t *symtable[NHASH]; /* hashed symbol table */
133: extern mod_t *modhead, *modtail; /* module list head and tail */
134: extern seg_t oseg[NLSEG]; /* output segment descriptors */
135: extern int nundef; /* number of undefined symbols */
136: extern uaddr_t commons; /* accumulate size of commons */
137:
138: extern char *outbuf; /* buffer for in-memory load */
139: extern FILE *outputf[NLSEG]; /* output ptrs (for each segment) */
140:
141: /*
142: * Kludge for maximum size of a loadable data segment
143: * for the 8086, used in both fixstack and ld
144: */
145:
146: #define MAXSEG86 0x10000L /* Maximum Segment Size */
147: #define DEFSTACK 0x1000 /* Initial Stack Size by Kernel */
148: #define WARNSIZE 0x1000 /* Warning Tolerance Distance */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.