Commit | Line | Data |
---|---|---|
2013f9b4 SC |
1 | /* COFF spec for AMD 290*0 |
2 | Contributed by David Wood @ New York University. | |
3 | */ | |
4 | ||
5 | #ifndef AMD | |
6 | # define AMD | |
7 | #endif | |
8 | ||
9 | /****************************************************************/ | |
10 | ||
11 | /* | |
12 | ** File Header and related definitions | |
13 | */ | |
14 | ||
15 | struct external_filehdr | |
16 | { | |
17 | char f_magic[2]; /* magic number */ | |
18 | char f_nscns[2]; /* number of sections */ | |
19 | char f_timdat[4]; /* time & date stamp */ | |
20 | char f_symptr[4]; /* file pointer to symtab */ | |
21 | char f_nsyms[4]; /* number of symtab entries */ | |
22 | char f_opthdr[2]; /* sizeof(optional hdr) */ | |
23 | char f_flags[2]; /* flags */ | |
24 | }; | |
25 | ||
26 | #define FILHDR struct external_filehdr | |
27 | #define FILHSZ sizeof (FILHDR) | |
28 | ||
29 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ | |
30 | ||
31 | /* | |
32 | ** Magic numbers for Am29000 | |
33 | ** (AT&T will assign the "real" magic number) | |
34 | */ | |
35 | ||
36 | #define SIPFBOMAGIC 0572 /* Am29000 (Byte 0 is MSB) */ | |
37 | #define SIPRBOMAGIC 0573 /* Am29000 (Byte 0 is LSB) */ | |
38 | ||
39 | #define A29K_MAGIC_BIG SIPFBOMAGIC | |
40 | #define A29K_MAGIC_LITTLE SIPRBOMAGIC | |
41 | #define A29KBADMAG(x) (((x).f_magic!=A29K_MAGIC_BIG) && \ | |
42 | ((x).f_magic!=A29K_MAGIC_LITTLE)) | |
43 | ||
44 | ||
45 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ | |
46 | ||
47 | /* | |
48 | ** File header flags currently known to us. | |
49 | ** | |
50 | ** Am29000 will use the F_AR32WR and F_AR32W flags to indicate | |
51 | ** the byte ordering in the file. | |
52 | */ | |
53 | ||
54 | /*--------------------------------------------------------------*/ | |
55 | ||
56 | /* | |
57 | ** Optional (a.out) header | |
58 | */ | |
59 | ||
60 | typedef struct external_aouthdr | |
61 | { | |
62 | char magic[2]; /* type of file */ | |
63 | char vstamp[2]; /* version stamp */ | |
64 | char tsize[4]; /* text size in bytes, padded to FW bdry*/ | |
65 | char dsize[4]; /* initialized data " " */ | |
66 | char bsize[4]; /* uninitialized data " " */ | |
67 | char entry[4]; /* entry pt. */ | |
68 | char text_start[4]; /* base of text used for this file */ | |
69 | char data_start[4]; /* base of data used for this file */ | |
70 | } AOUTHDR; | |
71 | ||
72 | #define AOUTSZ (sizeof(AOUTHDR)) | |
73 | ||
74 | /* aouthdr magic numbers */ | |
75 | #define NMAGIC 0410 /* separate i/d executable */ | |
76 | #define SHMAGIC 0406 /* NYU/Ultra3 shared data executable | |
77 | (writable text) */ | |
78 | ||
79 | #define _ETEXT "_etext" | |
80 | ||
81 | /*--------------------------------------------------------------*/ | |
82 | ||
83 | /* | |
84 | ** Section header and related definitions | |
85 | */ | |
86 | ||
87 | struct external_scnhdr | |
88 | { | |
89 | char s_name[8]; /* section name */ | |
90 | char s_paddr[4]; /* physical address, aliased s_nlib */ | |
91 | char s_vaddr[4]; /* virtual address */ | |
92 | char s_size[4]; /* section size */ | |
93 | char s_scnptr[4]; /* file ptr to raw data for section */ | |
94 | char s_relptr[4]; /* file ptr to relocation */ | |
95 | char s_lnnoptr[4]; /* file ptr to line numbers */ | |
96 | char s_nreloc[2]; /* number of relocation entries */ | |
97 | char s_nlnno[2]; /* number of line number entries*/ | |
98 | char s_flags[4]; /* flags */ | |
99 | }; | |
100 | ||
101 | #define SCNHDR struct external_scnhdr | |
102 | #define SCNHSZ sizeof (SCNHDR) | |
103 | ||
104 | /* | |
105 | * names of "special" sections | |
106 | */ | |
107 | #define _TEXT ".text" | |
108 | #define _DATA ".data" | |
109 | #define _BSS ".bss" | |
110 | ||
111 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ | |
112 | ||
113 | /* | |
114 | ** Section types - with additional section type for global | |
115 | ** registers which will be relocatable for the Am29000. | |
116 | ** | |
117 | ** In instances where it is necessary for a linker to produce an | |
118 | ** output file which contains text or data not based at virtual | |
119 | ** address 0, e.g. for a ROM, then the linker should accept | |
120 | ** address base information as command input and use PAD sections | |
121 | ** to skip over unused addresses. | |
122 | */ | |
123 | ||
124 | #define STYP_BSSREG 0x1200 /* Global register area (like STYP_INFO) */ | |
125 | #define STYP_ENVIR 0x2200 /* Environment (like STYP_INFO) */ | |
126 | #define STYP_ABS 0x4000 /* Absolute (allocated, not reloc, loaded) */ | |
127 | #define STYP_LIT 0x8020 /* Literal data (like STYP_TEXT) */ | |
128 | ||
129 | /*--------------------------------------------------------------*/ | |
130 | ||
131 | /* | |
132 | ** Relocation information declaration and related definitions | |
133 | */ | |
134 | ||
135 | struct external_reloc { | |
136 | char r_vaddr[4]; /* (virtual) address of reference */ | |
137 | char r_symndx[4]; /* index into symbol table */ | |
138 | char r_type[2]; /* relocation type */ | |
139 | }; | |
140 | ||
141 | #define RELOC struct external_reloc | |
142 | #define RELSZ 10 /* sizeof (RELOC) */ | |
143 | ||
144 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ | |
145 | ||
146 | /* | |
147 | ** Relocation types for the Am29000 | |
148 | */ | |
149 | ||
150 | #define R_ABS 0 /* reference is absolute */ | |
151 | ||
152 | #define R_IREL 030 /* instruction relative (jmp/call) */ | |
153 | #define R_IABS 031 /* instruction absolute (jmp/call) */ | |
154 | #define R_ILOHALF 032 /* instruction low half (const) */ | |
155 | #define R_IHIHALF 033 /* instruction high half (consth) part 1 */ | |
156 | #define R_IHCONST 034 /* instruction high half (consth) part 2 */ | |
157 | /* constant offset of R_IHIHALF relocation */ | |
158 | #define R_BYTE 035 /* relocatable byte value */ | |
159 | #define R_HWORD 036 /* relocatable halfword value */ | |
160 | #define R_WORD 037 /* relocatable word value */ | |
161 | ||
162 | #define R_IGLBLRC 040 /* instruction global register RC */ | |
163 | #define R_IGLBLRA 041 /* instruction global register RA */ | |
164 | #define R_IGLBLRB 042 /* instruction global register RB */ | |
165 | ||
166 | /* | |
167 | NOTE: | |
168 | All the "I" forms refer to 29000 instruction formats. The linker is | |
169 | expected to know how the numeric information is split and/or aligned | |
170 | within the instruction word(s). R_BYTE works for instructions, too. | |
171 | ||
172 | If the parameter to a CONSTH instruction is a relocatable type, two | |
173 | relocation records are written. The first has an r_type of R_IHIHALF | |
174 | (33 octal) and a normal r_vaddr and r_symndx. The second relocation | |
175 | record has an r_type of R_IHCONST (34 octal), a normal r_vaddr (which | |
176 | is redundant), and an r_symndx containing the 32-bit constant offset | |
177 | to the relocation instead of the actual symbol table index. This | |
178 | second record is always written, even if the constant offset is zero. | |
179 | The constant fields of the instruction are set to zero. | |
180 | */ | |
181 | ||
182 | /*--------------------------------------------------------------*/ | |
183 | ||
184 | /* | |
185 | ** Line number entry declaration and related definitions | |
186 | */ | |
187 | ||
188 | struct external_lineno | |
189 | { | |
190 | union { | |
191 | char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ | |
192 | char l_paddr[4]; /* (physical) address of line number */ | |
193 | } l_addr; | |
194 | char l_lnno[2]; /* line number */ | |
195 | }; | |
196 | ||
197 | #define LINENO struct external_lineno | |
198 | #define LINESZ 6 /* sizeof (LINENO) */ | |
199 | ||
200 | /*--------------------------------------------------------------*/ | |
201 | ||
202 | /* | |
203 | ** Symbol entry declaration and related definitions | |
204 | */ | |
205 | ||
054862cf | 206 | #define E_SYMNMLEN 8 /* Number of characters in a symbol name */ |
2013f9b4 SC |
207 | |
208 | struct external_syment | |
209 | { | |
210 | union { | |
054862cf | 211 | char e_name[E_SYMNMLEN]; |
2013f9b4 SC |
212 | struct { |
213 | char e_zeroes[4]; | |
214 | char e_offset[4]; | |
215 | } e; | |
216 | } e; | |
217 | char e_value[4]; | |
218 | char e_scnum[2]; | |
219 | char e_type[2]; | |
220 | char e_sclass[1]; | |
221 | char e_numaux[1]; | |
222 | }; | |
223 | ||
224 | #define SYMENT struct external_syment | |
225 | #define SYMESZ sizeof(SYMENT) | |
226 | ||
227 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ | |
228 | ||
229 | /* | |
230 | ** Storage class definitions - new classes for global registers. | |
231 | */ | |
232 | ||
233 | #define C_GLBLREG 19 /* global register */ | |
234 | #define C_EXTREG 20 /* external global register */ | |
235 | #define C_DEFREG 21 /* ext. def. of global register */ | |
236 | ||
237 | ||
238 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ | |
239 | ||
240 | /* | |
241 | ** Derived symbol mask/shifts. | |
242 | */ | |
243 | ||
244 | #define N_BTMASK (0xf) | |
245 | #define N_BTSHFT (4) | |
246 | #define N_TMASK (0x30) | |
247 | #define N_TSHIFT (2) | |
248 | ||
249 | /*--------------------------------------------------------------*/ | |
250 | ||
251 | /* | |
252 | ** Auxiliary symbol table entry declaration and related | |
253 | ** definitions. | |
254 | */ | |
255 | ||
054862cf JG |
256 | #define E_FILNMLEN 14 /* # characters in a file name */ |
257 | #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ | |
2013f9b4 SC |
258 | |
259 | union external_auxent { | |
260 | struct { | |
261 | char x_tagndx[4]; /* str, un, or enum tag indx */ | |
262 | union { | |
263 | struct { | |
264 | char x_lnno[2]; /* declaration line number */ | |
265 | char x_size[2]; /* str/union/array size */ | |
266 | } x_lnsz; | |
267 | char x_fsize[4]; /* size of function */ | |
268 | } x_misc; | |
269 | union { | |
270 | struct { /* if ISFCN, tag, or .bb */ | |
271 | char x_lnnoptr[4]; /* ptr to fcn line # */ | |
272 | char x_endndx[4]; /* entry ndx past block end */ | |
273 | } x_fcn; | |
274 | struct { /* if ISARY, up to 4 dimen. */ | |
054862cf | 275 | char x_dimen[E_DIMNUM][2]; |
2013f9b4 SC |
276 | } x_ary; |
277 | } x_fcnary; | |
278 | char x_tvndx[2]; /* tv index */ | |
279 | } x_sym; | |
280 | ||
281 | union { | |
054862cf | 282 | char x_fname[E_FILNMLEN]; |
2013f9b4 SC |
283 | struct { |
284 | char x_zeroes[4]; | |
285 | char x_offset[4]; | |
286 | } x_n; | |
287 | } x_file; | |
288 | ||
289 | struct { | |
290 | char x_scnlen[4]; /* section length */ | |
291 | char x_nreloc[2]; /* # relocation entries */ | |
292 | char x_nlinno[2]; /* # line numbers */ | |
293 | } x_scn; | |
294 | ||
295 | struct { | |
296 | char x_tvfill[4]; /* tv fill value */ | |
297 | char x_tvlen[2]; /* length of .tv */ | |
298 | char x_tvran[2][2]; /* tv range */ | |
299 | } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ | |
300 | }; | |
301 | ||
302 | #define AUXENT union external_auxent | |
303 | #define AUXESZ 18 |