|
|
1.1 root 1: /*
2: * ld/data.c
3: * General Loader-Binder
4: *
5: * Knows about FILE struct to the extent it is revealed in putc
6: * if BREADBOX is non-zero
7: */
8:
9: #include "data.h"
10:
11: /*
12: * Start variables & constants
13: */
14:
15: sym_t *symtable[NHASH]; /* hashed symbol table */
16: mod_t *modhead, *modtail; /* module list head and tail */
17: seg_t oseg[NLSEG]; /* output segment descriptors */
18: int nundef; /* number of undefined symbols */
19: uaddr_t commons; /* accumulate size of commons */
20: sym_t *etext_s, *edata_s, *end_s; /* special loader generated symbols */
21: char etext_id[NCPLN] = "etext_", /* and their names */
22: edata_id[NCPLN] = "edata_",
23: end_id[NCPLN] = "end_";
24: ldh_t oldh /* output load file header */
25: = { L_MAGIC };
26: char *mchname[] /* names of known machines */
27: = { "Turing Machine",
28: "PDP-11",
29: "VAX-11",
30: "3sickly",
31: "Z8001",
32: "Z8002",
33: "iAPX 86",
34: "i8080",
35: "6800",
36: "6809",
37: "68000"
38: };
39: uaddr_t segsize[] /* size of segment on target machine */
40: = { 0,
41: 8192,
42: 512,
43: 2048,
44: 0,
45: 512,
46: 16,
47: 0,
48: 0,
49: 0,
50: 0
51: },
52: drvbase[] /* base of loadable driver */
53: = { 0,
54: 0120000,
55: 0,
56: 0,
57: 0,
58: 0xD000,
59: 0xD000,
60: 0,
61: 0,
62: 0,
63: 0
64: },
65: drvtop[] /* address limit of loadable driver */
66: = { 0,
67: 0140000,
68: 0,
69: 0,
70: 0,
71: 0xF000,
72: 0xF000,
73: 0,
74: 0,
75: 0,
76: 0
77: };
78: flag_t noilcl, /* discard internal symbols `L...' */
79: nolcl, /* discard local symbols */
80: watch, /* watch everything happen */
81: worder; /* byte order in word; depends on machine */
82: char *outbuf; /* buffer for in-memory load */
83: FILE *outputf[NLSEG]; /* output ptrs (for each segment) */
84:
85: /*
86: * Structures associated with storage economy
87: */
88: char pbuf1[BUFSIZ], /* permanent i/o buffers */
89: pbuf2[BUFSIZ];
90: mod_t *mtemp; /* only one module in core at a time */
91: FILE *mfp; /* temp file for module structures */
92: int mdisk, /* flag <>0 means module struct to disk */
93: nmod, /* module count */
94: mxmsym; /* max # of symbols ref'd by 1 module */
95:
96: /*
97: * Seconds between ranlib update and archive modify times
98: */
99: #define SLOPTIME 150
100:
101: /* values for worder */
102: #define LOHI 0
103: #define HILO 1
104:
105: /*
106: * For pass 2; these will change if format of relocation changed
107: */
108: #define getaddr getlohi
109: #define putaddr(addr, fp, sgp) putlohi((short)(addr), fp, sgp)
110: #define getsymno getlohi
111: #define putsymno putlohi
112:
113: /*
114: * C requires this...
115: */
116: void baseall(), endbind(), undef();
117: uaddr_t setbase(), newpage(), lentry();
118: fsize_t segoffs();
119: void symredef(), rdsystem();
120: sym_t *addsym(), *symref(), *newsym();
121: fsize_t symoff();
122: void loadmod(), putstruc(), putword(), putlohi(), puthilo(), putbyte();
123: unsigned short getword(), getlohi(), gethilo();
124: void message(), fatal(), usage(), filemsg(), modmsg(), mpmsg(), spmsg();
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.