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