]>
Commit | Line | Data |
---|---|---|
42e15245 SC |
1 | /********************** FILE HEADER **********************/ |
2 | struct internal_filehdr | |
3 | { | |
4 | unsigned short f_magic; /* magic number */ | |
5 | unsigned short f_nscns; /* number of sections */ | |
6 | long f_timdat; /* time & date stamp */ | |
7 | long f_symptr; /* file pointer to symtab */ | |
8 | long f_nsyms; /* number of symtab entries */ | |
9 | unsigned short f_opthdr; /* sizeof(optional hdr) */ | |
10 | unsigned short f_flags; /* flags */ | |
11 | }; | |
12 | ||
13 | /* Bits for f_flags: | |
14 | * F_RELFLG relocation info stripped from file | |
15 | * F_EXEC file is executable (no unresolved external references) | |
16 | * F_LNNO line numbers stripped from file | |
17 | * F_LSYMS local symbols stripped from file | |
18 | * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) | |
19 | */ | |
20 | ||
8215bbac JG |
21 | #define F_RELFLG (0x0001) |
22 | #define F_EXEC (0x0002) | |
23 | #define F_LNNO (0x0004) | |
24 | #define F_LSYMS (0x0008) | |
25 | #define F_AR32WR (0x0010) | |
26 | #define F_AR32W 0x200 | |
42e15245 SC |
27 | /********************** AOUT "OPTIONAL HEADER" **********************/ |
28 | struct internal_aouthdr { | |
29 | short magic; /* type of file */ | |
30 | short vstamp; /* version stamp */ | |
31 | unsigned long tsize; /* text size in bytes, padded to FW bdry*/ | |
32 | unsigned long dsize; /* initialized data " " */ | |
33 | unsigned long bsize; /* uninitialized data " " */ | |
34 | unsigned long entry; /* entry pt. */ | |
35 | unsigned long text_start; /* base of text used for this file */ | |
36 | unsigned long data_start; /* base of data used for this file */ | |
37 | unsigned long tagentries; /* number of tag entries to follow */ | |
38 | } ; | |
39 | ||
40 | /********************** STORAGE CLASSES **********************/ | |
41 | ||
42 | #define C_EFCN -1 /* physical end of function */ | |
43 | #define C_NULL 0 | |
44 | #define C_AUTO 1 /* automatic variable */ | |
45 | #define C_EXT 2 /* external symbol */ | |
46 | #define C_STAT 3 /* static */ | |
47 | #define C_REG 4 /* register variable */ | |
48 | #define C_EXTDEF 5 /* external definition */ | |
49 | #define C_LABEL 6 /* label */ | |
50 | #define C_ULABEL 7 /* undefined label */ | |
51 | #define C_MOS 8 /* member of structure */ | |
52 | #define C_ARG 9 /* function argument */ | |
53 | #define C_STRTAG 10 /* structure tag */ | |
54 | #define C_MOU 11 /* member of union */ | |
55 | #define C_UNTAG 12 /* union tag */ | |
56 | #define C_TPDEF 13 /* type definition */ | |
57 | #define C_USTATIC 14 /* undefined static */ | |
58 | #define C_ENTAG 15 /* enumeration tag */ | |
59 | #define C_MOE 16 /* member of enumeration */ | |
60 | #define C_REGPARM 17 /* register parameter */ | |
61 | #define C_FIELD 18 /* bit field */ | |
62 | #define C_AUTOARG 19 /* auto argument */ | |
63 | #define C_LASTENT 20 /* dummy entry (end of block) */ | |
64 | #define C_BLOCK 100 /* ".bb" or ".eb" */ | |
65 | #define C_FCN 101 /* ".bf" or ".ef" */ | |
66 | #define C_EOS 102 /* end of structure */ | |
67 | #define C_FILE 103 /* file name */ | |
68 | #define C_LINE 104 /* line # reformatted as symbol table entry */ | |
69 | #define C_ALIAS 105 /* duplicate tag */ | |
70 | #define C_HIDDEN 106 /* ext symbol in dmert public lib */ | |
71 | ||
72 | /* New storage classes for 80960 */ | |
73 | ||
74 | /* C_LEAFPROC is obsolete. Use C_LEAFEXT or C_LEAFSTAT */ | |
75 | #define C_LEAFPROC 108 /* Leaf procedure, "call" via BAL */ | |
76 | ||
77 | #define C_SCALL 107 /* Procedure reachable via system call */ | |
78 | #define C_LEAFEXT 108 /* External leaf */ | |
79 | #define C_LEAFSTAT 113 /* Static leaf */ | |
80 | #define C_OPTVAR 109 /* Optimized variable */ | |
81 | #define C_DEFINE 110 /* Preprocessor #define */ | |
82 | #define C_PRAGMA 111 /* Advice to compiler or linker */ | |
83 | #define C_SEGMENT 112 /* 80960 segment name */ | |
84 | ||
85 | /********************** SECTION HEADER **********************/ | |
86 | struct internal_scnhdr { | |
87 | char s_name[8]; /* section name */ | |
88 | long s_paddr; /* physical address, aliased s_nlib */ | |
89 | long s_vaddr; /* virtual address */ | |
90 | long s_size; /* section size */ | |
91 | long s_scnptr; /* file ptr to raw data for section */ | |
92 | long s_relptr; /* file ptr to relocation */ | |
93 | long s_lnnoptr; /* file ptr to line numbers */ | |
a737c70b SC |
94 | #ifdef M88 |
95 | unsigned long s_nreloc; | |
96 | unsigned long s_nlnno; | |
97 | #else | |
42e15245 SC |
98 | unsigned short s_nreloc; /* number of relocation entries */ |
99 | unsigned short s_nlnno; /* number of line number entries*/ | |
a737c70b | 100 | #endif |
42e15245 SC |
101 | long s_flags; /* flags */ |
102 | #ifdef I960 | |
103 | long s_align; | |
104 | #endif | |
105 | }; | |
106 | ||
107 | ||
42e15245 SC |
108 | /* |
109 | * s_flags "type" | |
110 | */ | |
111 | #define STYP_REG (0x0000) /* "regular": allocated, relocated, loaded */ | |
112 | #define STYP_DSECT (0x0001) /* "dummy": relocated only*/ | |
113 | #define STYP_NOLOAD (0x0002) /* "noload": allocated, relocated, not loaded */ | |
114 | #define STYP_GROUP (0x0004) /* "grouped": formed of input sections */ | |
115 | #define STYP_PAD (0x0008) /* "padding": not allocated, not relocated, loaded */ | |
116 | #define STYP_COPY (0x0010) /* "copy": for decision function used by field update; not allocated, not relocated, | |
117 | loaded; reloc & lineno entries processed normally */ | |
118 | #define STYP_TEXT (0x0020) /* section contains text only */ | |
119 | #define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile | |
120 | will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will | |
121 | update all process invocations. */ | |
122 | #define STYP_DATA (0x0040) /* section contains data only */ | |
123 | #define STYP_BSS (0x0080) /* section contains bss only */ | |
124 | #define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */ | |
125 | #define STYP_INFO (0x0200) /* comment: not allocated not relocated, not loaded */ | |
126 | #define STYP_OVER (0x0400) /* overlay: relocated not allocated or loaded */ | |
127 | #define STYP_LIB (0x0800) /* for .lib: same as INFO */ | |
128 | #define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */ | |
129 | #define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions wherever padding is necessary and there is a | |
130 | word of contiguous bytes beginning on a word boundary. */ | |
131 | /********************** LINE NUMBERS **********************/ | |
132 | ||
133 | /* 1 line number entry for every "breakpointable" source line in a section. | |
134 | * Line numbers are grouped on a per function basis; first entry in a function | |
135 | * grouping will have l_lnno = 0 and in place of physical address will be the | |
136 | * symbol table index of the function name. | |
137 | */ | |
138 | ||
139 | struct internal_lineno { | |
140 | union { | |
141 | long l_symndx; /* function name symbol index, iff l_lnno == 0*/ | |
142 | long l_paddr; /* (physical) address of line number */ | |
143 | } l_addr; | |
a737c70b SC |
144 | #ifdef M88 |
145 | unsigned long l_lnno; /* line number */ | |
146 | #else | |
42e15245 | 147 | unsigned short l_lnno; /* line number */ |
a737c70b | 148 | #endif |
42e15245 SC |
149 | }; |
150 | ||
50651e5e | 151 | |
42e15245 | 152 | /********************** SYMBOLS **********************/ |
50651e5e | 153 | |
054862cf JG |
154 | #define SYMNMLEN 8 /* # characters in a symbol name */ |
155 | #define FILNMLEN 14 /* # characters in a file name */ | |
156 | #define DIMNUM 4 /* # array dimensions in auxiliary entry */ | |
157 | ||
42e15245 SC |
158 | struct internal_syment { |
159 | union { | |
160 | char _n_name[SYMNMLEN]; /* old COFF version */ | |
161 | struct { | |
162 | long _n_zeroes; /* new == 0 */ | |
163 | long _n_offset; /* offset into string table */ | |
164 | } _n_n; | |
165 | char *_n_nptr[2]; /* allows for overlaying */ | |
166 | } _n; | |
167 | long n_value; /* value of symbol */ | |
168 | short n_scnum; /* section number */ | |
169 | unsigned short n_flags; /* copy of flags from filhdr */ | |
170 | unsigned short n_type; /* type and derived type */ | |
a737c70b SC |
171 | #if __STDC__ |
172 | signed | |
173 | #endif | |
42e15245 SC |
174 | char n_sclass; /* storage class */ |
175 | char n_numaux; /* number of aux. entries */ | |
176 | }; | |
177 | ||
50651e5e JG |
178 | /* Relocatable symbols have number of the section in which they are defined, |
179 | or one of the following: */ | |
180 | ||
42e15245 SC |
181 | #define N_UNDEF ((short)0) /* undefined symbol */ |
182 | #define N_ABS ((short)-1) /* value of symbol is absolute */ | |
183 | #define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */ | |
184 | #define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */ | |
185 | #define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/ | |
186 | ||
187 | /* | |
188 | * Type of a symbol, in low N bits of the word | |
189 | */ | |
190 | #define T_NULL 0 | |
191 | #define T_VOID 1 /* function argument (only used by compiler) */ | |
192 | #define T_CHAR 2 /* character */ | |
193 | #define T_SHORT 3 /* short integer */ | |
194 | #define T_INT 4 /* integer */ | |
195 | #define T_LONG 5 /* long integer */ | |
196 | #define T_FLOAT 6 /* floating point */ | |
197 | #define T_DOUBLE 7 /* double word */ | |
198 | #define T_STRUCT 8 /* structure */ | |
199 | #define T_UNION 9 /* union */ | |
200 | #define T_ENUM 10 /* enumeration */ | |
201 | #define T_MOE 11 /* member of enumeration*/ | |
202 | #define T_UCHAR 12 /* unsigned character */ | |
203 | #define T_USHORT 13 /* unsigned short */ | |
204 | #define T_UINT 14 /* unsigned integer */ | |
205 | #define T_ULONG 15 /* unsigned long */ | |
206 | #define T_LNGDBL 16 /* long double */ | |
207 | ||
208 | /* | |
209 | * derived types, in n_type | |
210 | */ | |
211 | #define DT_NON (0) /* no derived type */ | |
212 | #define DT_PTR (1) /* pointer */ | |
213 | #define DT_FCN (2) /* function */ | |
214 | #define DT_ARY (3) /* array */ | |
215 | ||
216 | #define BTYPE(x) ((x) & N_BTMASK) | |
217 | ||
218 | #define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) | |
219 | #define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) | |
220 | #define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) | |
221 | #define ISTAG(x) ((x)==C_STRTAG||(x)==C_UNTAG||(x)==C_ENTAG) | |
222 | #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) | |
223 | ||
224 | ||
225 | union internal_auxent | |
226 | { | |
227 | struct { | |
228 | union { | |
229 | long l; /* str, un, or enum tag indx */ | |
230 | struct coff_ptr_struct *p; | |
231 | } x_tagndx; | |
232 | ||
233 | union { | |
234 | struct { | |
235 | unsigned short x_lnno; /* declaration line number */ | |
236 | unsigned short x_size; /* str/union/array size */ | |
237 | } x_lnsz; | |
238 | long x_fsize; /* size of function */ | |
239 | } x_misc; | |
240 | union { | |
241 | ||
242 | struct { /* if ISFCN, tag, or .bb */ | |
243 | long x_lnnoptr; /* ptr to fcn line # */ | |
244 | union { /* entry ndx past block end */ | |
245 | long l; | |
246 | struct coff_ptr_struct *p; | |
247 | ||
248 | } x_endndx; | |
249 | ||
250 | ||
251 | } x_fcn; | |
252 | struct { /* if ISARY, up to 4 dimen. */ | |
253 | unsigned short x_dimen[DIMNUM]; | |
254 | } x_ary; | |
255 | } x_fcnary; | |
256 | unsigned short x_tvndx; /* tv index */ | |
257 | } x_sym; | |
258 | ||
259 | union { | |
260 | char x_fname[FILNMLEN]; | |
261 | struct { | |
262 | long x_zeroes; | |
263 | long x_offset; | |
264 | } x_n; | |
265 | } x_file; | |
266 | ||
267 | struct { | |
268 | long x_scnlen; /* section length */ | |
269 | unsigned short x_nreloc; /* # relocation entries */ | |
270 | unsigned short x_nlinno; /* # line numbers */ | |
271 | } x_scn; | |
272 | ||
273 | struct { | |
274 | long x_tvfill; /* tv fill value */ | |
275 | unsigned short x_tvlen; /* length of .tv */ | |
276 | unsigned short x_tvran[2]; /* tv range */ | |
277 | } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ | |
278 | ||
279 | /****************************************** | |
280 | * I960-specific *2nd* aux. entry formats | |
281 | ******************************************/ | |
282 | struct { | |
283 | /* This is a very old typo that keeps getting propagated. */ | |
284 | #define x_stdindx x_stindx | |
285 | long x_stindx; /* sys. table entry */ | |
286 | } x_sc; /* system call entry */ | |
287 | ||
288 | struct { | |
289 | unsigned long x_balntry; /* BAL entry point */ | |
290 | } x_bal; /* BAL-callable function */ | |
291 | ||
292 | struct { | |
293 | unsigned long x_timestamp; /* time stamp */ | |
294 | char x_idstring[20]; /* producer identity string */ | |
295 | } x_ident; /* Producer ident info */ | |
296 | ||
297 | ||
298 | }; | |
299 | ||
300 | /********************** RELOCATION DIRECTIVES **********************/ | |
301 | ||
302 | struct internal_reloc { | |
303 | long r_vaddr; /* Virtual address of reference */ | |
304 | long r_symndx; /* Index into symbol table */ | |
305 | unsigned short r_type; /* Relocation type */ | |
306 | #if M88 | |
307 | unsigned short r_offset; | |
308 | #endif | |
309 | }; | |
310 | ||
311 | #define R_RELBYTE 017 | |
312 | #define R_RELWORD 020 | |
313 | #define R_PCRBYTE 022 | |
314 | #define R_PCRWORD 023 | |
315 | #define R_PCRLONG 024 | |
316 | ||
317 | #define R_DIR32 06 | |
318 | #define R_PCLONG 020 | |
319 | #define R_RELBYTE 017 | |
320 | #define R_RELWORD 020 | |
321 | ||
322 | #define R_PCRBYTE 022 | |
323 | #define R_PCRWORD 023 | |
324 | #define R_PCRLONG 024 | |
325 | ||
326 | #define R_PCR16L 128 | |
327 | #define R_PCR26L 129 | |
328 | #define R_VRT16 130 | |
329 | #define R_HVRT16 131 | |
330 | #define R_LVRT16 132 | |
331 | #define R_VRT32 133 | |
332 | #define R_RELLONG (0x11) /* Direct 32-bit relocation */ | |
333 | #define R_IPRSHORT (0x18) | |
334 | #define R_IPRMED (0x19) /* 24-bit ip-relative relocation */ | |
335 | #define R_IPRLONG (0x1a) | |
336 | #define R_OPTCALL (0x1b) /* 32-bit optimizable call (leafproc/sysproc) */ | |
337 | #define R_OPTCALLX (0x1c) /* 64-bit optimizable call (leafproc/sysproc) */ | |
338 | #define R_GETSEG (0x1d) | |
339 | #define R_GETPA (0x1e) | |
340 | #define R_TAGWORD (0x1f) |