|
|
1.1 root 1: /*
2: * Coff Loader header
3: *
4: * By Charles Fiterman for Mark Williams 3/30/92.
5: */
6: #include <misc.h>
7: #ifdef GEMDOS
8: #include <stat.h>
9: #define DIRSIZ 14
10: #else
11: #include <sys/stat.h>
12: #include <sys/dir.h>
13: #endif
14: #include <mtype.h>
15: #include <coff.h>
16: #include <arcoff.h>
17: #include <path.h>
18:
19: #define NHASH 128 /* Hash table divisor */
20:
21: #define S_TEXT 0 /* These segments and only these */
22: #define S_DATA 1 /* Go to all executables */
23: #define S_BSSD 2
24: #define S_COMM 3
25:
26: #define NLSEG 4 /* The output segment count */
27: #define MAXSEG 20 /* The maxamum segment count */
28:
29: #define SEGROUND 16
30: #define KERBASE 0xFFC00000UL /* Kernels start here */
31: #define DATABASE 0x000400000L /* .data starts here + some */
32:
33: #define undefined(s) ((C_EXT==(s)->n_sclass)&&!(s)->n_value&&!(s)->n_scnum)
34: #define common(s) ((C_EXT==(s)->n_sclass)&& (s)->n_value&&!(s)->n_scnum)
35:
36: #define w_message if (watch) watch_message
37:
38: typedef struct mod_t mod_t;
39: typedef struct sym_t sym_t;
40: typedef struct ren_t ren_t;
41: typedef char flag_t; /* command line flag option */
42:
43: /*
44: * Input modules are inhaled whole, this points to the module,
45: * the next module and any pieces not easily reached.
46: */
47: struct mod_t {
48: mod_t *next; /* the next module in the chain. */
49: FILEHDR *f; /* the file header */
50: SCNHDR *s; /* the first section header */
51: char *l; /* trailing long symbols */
52: char *fname; /* file name */
53: char *mname; /* module name */
54: };
55:
56: /*
57: * Symbol table entry.
58: */
59: struct sym_t {
60: sym_t *next; /* hash chain */
61: mod_t *mod; /* defining module */
62: int symno; /* output symbol number */
63: SYMENT sym; /* constructed symbol */
64: };
65:
66: /*
67: * Rename table entry.
68: */
69: struct ren_t {
70: ren_t *next; /* next rename entry */
71: char *to; /* change to string */
72: char *from; /* change from string */
73: };
74:
75: extern flag_t reloc, /* Combine input into a new .o not an executable */
76: nosym, /* No symbol table out. */
77: watch, /* Produce a trace */
78: nolcl, /* Discard C local symbols */
79: noilcl, /* Discard all local symbols */
80: qflag, /* No warn on commons of different length */
81: Qflag, /* Absolute silence */
82: debflg; /* Pass through aux symbols */
83:
84: extern int errCount;
85: extern int nundef;
86: extern int symno; /* Output symbol count */
87: extern mod_t *head, /* head of list of modules to load */
88: *tail, /* tail or list of modules */
89: *xhead, /* head of noload modules */
90: *xtail; /* tail of noload modules */
91: extern ren_t *rhead; /* rename chain */
92:
93: extern char *ofname; /* output file name */
94: extern long comnb, comns, comnl; /* common lengths */
95:
96: extern sym_t *symtable[NHASH]; /* hashed symbol table */
97:
98: extern unsigned short osegs; /* the number of output segments */
99: extern unsigned short segMap[MAXSEG]; /* Segment maping */
100:
101: extern FILEHDR fileh;
102: extern AOUTHDR aouth;
103: extern SCNHDR *secth; /* output segments */
104: extern char *argv0; /* main( , argv[0]) */
105: extern char *mktemp(), *optarg;
106: extern int optix;
107: extern char *strchr(), *realloc(), *strrchr(), *strcpy(), *alloca();
108: extern void driver_fail(), spwarn(), showUndef();
109: extern int driver_alloc();
110: extern void fatal();
111: extern char *symName();
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.