Last file for preliminary support of the we32k (AT&T 3b2 family).
[external/binutils.git] / include / coff / we32k.h
1 /*** coff information for we32k */
2
3 /********************** FILE HEADER **********************/
4
5 struct external_filehdr {
6         char f_magic[2];        /* magic number                 */
7         char f_nscns[2];        /* number of sections           */
8         char f_timdat[4];       /* time & date stamp            */
9         char f_symptr[4];       /* file pointer to symtab       */
10         char f_nsyms[4];        /* number of symtab entries     */
11         char f_opthdr[2];       /* sizeof(optional hdr)         */
12         char f_flags[2];        /* flags                        */
13 };
14
15
16 /* Bits for f_flags:
17  *      F_RELFLG        relocation info stripped from file
18  *      F_EXEC          file is executable (no unresolved external references)
19  *      F_LNNO          line numbers stripped from file
20  *      F_LSYMS         local symbols stripped from file
21  *      F_AR32WR        file has byte ordering of an AR32WR machine (e.g. vax)
22  */
23
24 #define F_RELFLG        (0x0001)
25 #define F_EXEC          (0x0002)
26 #define F_LNNO          (0x0004)
27 #define F_LSYMS         (0x0008)
28 #define F_BM32B         (0020000)
29 #define F_BM32MAU       (0040000)
30
31 #define WE32KMAGIC      0x170   /* we32k sans transfer vector */
32 #define FBOMAGIC        0x170   /* we32k sans transfer vector */
33 #define MTVMAGIC        0x171   /* we32k with transfer vector */
34 #define RBOMAGIC        0x172   /* reserved */
35 #define WE32KBADMAG(x) (((x).f_magic != WE32KMAGIC) \
36                         && ((x).f_magic != FBOMAGIC) \
37                         && ((x).f_magic != RBOMAGIC) \
38                         && ((x).f_magic != MTVMAGIC))
39
40 #define FILHDR  struct external_filehdr
41 #define FILHSZ  sizeof(FILHDR)
42
43
44 /********************** AOUT "OPTIONAL HEADER" **********************/
45
46
47 typedef struct 
48 {
49   char  magic[2];               /* type of file                         */
50   char  vstamp[2];              /* version stamp                        */
51   char  tsize[4];               /* text size in bytes, padded to FW bdry*/
52   char  dsize[4];               /* initialized data "  "                */
53   char  bsize[4];               /* uninitialized data "   "             */
54   char  entry[4];               /* entry pt.                            */
55   char  text_start[4];          /* base of text used for this file */
56   char  data_start[4];          /* base of data used for this file */
57 }
58 AOUTHDR;
59
60 #define AOUTSZ (sizeof(AOUTHDR))
61
62
63 /********************** STORAGE CLASSES **********************/
64
65 #define C_EFCN          -1      /* physical end of function     */
66 #define C_NULL          0
67 #define C_AUTO          1       /* automatic variable           */
68 #define C_EXT           2       /* external symbol              */
69 #define C_STAT          3       /* static                       */
70 #define C_REG           4       /* register variable            */
71 #define C_EXTDEF        5       /* external definition          */
72 #define C_LABEL         6       /* label                        */
73 #define C_ULABEL        7       /* undefined label              */
74 #define C_MOS           8       /* member of structure          */
75 #define C_ARG           9       /* function argument            */
76 #define C_STRTAG        10      /* structure tag                */
77 #define C_MOU           11      /* member of union              */
78 #define C_UNTAG         12      /* union tag                    */
79 #define C_TPDEF         13      /* type definition              */
80 #define C_USTATIC       14      /* undefined static             */
81 #define C_ENTAG         15      /* enumeration tag              */
82 #define C_MOE           16      /* member of enumeration        */
83 #define C_REGPARM       17      /* register parameter           */
84 #define C_FIELD         18      /* bit field                    */
85 #define C_AUTOARG       19      /* auto argument                */
86 #define C_LASTENT       20      /* dummy entry (end of block)   */
87 #define C_BLOCK         100     /* ".bb" or ".eb"               */
88 #define C_FCN           101     /* ".bf" or ".ef"               */
89 #define C_EOS           102     /* end of structure             */
90 #define C_FILE          103     /* file name                    */
91 #define C_LINE          104     /* line # reformatted as symbol table entry */
92 #define C_ALIAS         105     /* duplicate tag                */
93 #define C_HIDDEN        106     /* ext symbol in dmert public lib */
94
95 /********************** SECTION HEADER **********************/
96
97
98 struct external_scnhdr {
99         char            s_name[8];      /* section name                 */
100         char            s_paddr[4];     /* physical address, aliased s_nlib */
101         char            s_vaddr[4];     /* virtual address              */
102         char            s_size[4];      /* section size                 */
103         char            s_scnptr[4];    /* file ptr to raw data for section */
104         char            s_relptr[4];    /* file ptr to relocation       */
105         char            s_lnnoptr[4];   /* file ptr to line numbers     */
106         char            s_nreloc[2];    /* number of relocation entries */
107         char            s_nlnno[2];     /* number of line number entries*/
108         char            s_flags[4];     /* flags                        */
109 };
110
111 /*
112  * names of "special" sections
113  */
114 #define _TEXT   ".text"
115 #define _DATA   ".data"
116 #define _BSS    ".bss"
117 #define _TV     ".tv"
118 #define _INIT   ".init"
119 #define _FINI   ".fini"
120
121 /*
122  * s_flags "type"
123  */
124 #define STYP_REG         (0x0000) /* "regular": allocated, relocated, loaded */
125 #define STYP_DSECT       (0x0001) /* "dummy":  relocated only*/
126 #define STYP_NOLOAD      (0x0002) /* "noload": allocated, relocated, not loaded */
127 #define STYP_GROUP       (0x0004) /* "grouped": formed of input sections */
128 #define STYP_PAD         (0x0008) /* "padding": not allocated, not relocated, loaded */
129 #define STYP_COPY        (0x0010) /* "copy": for decision function used by field update;  not allocated, not relocated,
130                                      loaded; reloc & lineno entries processed normally */
131 #define STYP_TEXT        (0x0020) /* section contains text only */
132 #define S_SHRSEG         (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile
133                                      will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will
134                                      update all process invocations. */
135 #define STYP_DATA        (0x0040) /* section contains data only */
136 #define STYP_BSS         (0x0080) /* section contains bss only */
137 #define S_NEWFCN         (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */
138 #define STYP_INFO        (0x0200) /* comment: not allocated not relocated, not loaded */
139 #define STYP_OVER        (0x0400) /* overlay: relocated not allocated or loaded */
140 #define STYP_LIB         (0x0800) /* for .lib: same as INFO */
141
142 #define SCNHDR  struct external_scnhdr
143 #define SCNHSZ  sizeof(SCNHDR)
144
145
146 /********************** LINE NUMBERS **********************/
147
148 /* 1 line number entry for every "breakpointable" source line in a section.
149  * Line numbers are grouped on a per function basis; first entry in a function
150  * grouping will have l_lnno = 0 and in place of physical address will be the
151  * symbol table index of the function name.
152  */
153 struct external_lineno {
154         union {
155                 char l_symndx[4];       /* function name symbol index, iff l_lnno == 0*/
156                 char l_paddr[4];        /* (physical) address of line number    */
157         } l_addr;
158         char l_lnno[2]; /* line number          */
159 };
160
161
162 #define LINENO  struct external_lineno
163 #define LINESZ  sizeof(LINENO)
164
165
166 /********************** SYMBOLS **********************/
167
168 #define E_SYMNMLEN      8       /* # characters in a symbol name        */
169 #define E_FILNMLEN      14      /* # characters in a file name          */
170 #define E_DIMNUM        4       /* # array dimensions in auxiliary entry */
171
172 struct external_syment 
173 {
174   union {
175     char e_name[E_SYMNMLEN];
176     struct {
177       char e_zeroes[4];
178       char e_offset[4];
179     } e;
180   } e;
181   char e_value[4];
182   char e_scnum[2];
183   char e_type[2];
184   char e_sclass[1];
185   char e_numaux[1];
186 };
187
188 /*
189  * Relocatable symbols have number of the section in which they are defined,
190  * or one of the following:
191  */
192 #define N_UNDEF ((short)0)  /* undefined symbol */
193 #define N_ABS   ((short)-1) /* value of symbol is absolute */
194 #define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */
195 #define N_TV    ((short)-3) /* indicates symbol needs preload transfer vector */
196 #define P_TV    ((short)-4) /* indicates symbol needs postload transfer vector*/
197
198 /*
199  * Type of a symbol, in low 4 bits of the word
200  */
201 #define T_NULL          0
202 #define T_VOID          1       /* function argument (only used by compiler) */
203 #define T_CHAR          2       /* character            */
204 #define T_SHORT         3       /* short integer        */
205 #define T_INT           4       /* integer              */
206 #define T_LONG          5       /* long integer         */
207 #define T_FLOAT         6       /* floating point       */
208 #define T_DOUBLE        7       /* double word          */
209 #define T_STRUCT        8       /* structure            */
210 #define T_UNION         9       /* union                */
211 #define T_ENUM          10      /* enumeration          */
212 #define T_MOE           11      /* member of enumeration*/
213 #define T_UCHAR         12      /* unsigned character   */
214 #define T_USHORT        13      /* unsigned short       */
215 #define T_UINT          14      /* unsigned integer     */
216 #define T_ULONG         15      /* unsigned long        */
217 #define T_LNGDBL        16      /* long double          */
218
219 /*
220  * derived types, in n_type
221 */
222 #define DT_NON          (0)     /* no derived type */
223 #define DT_PTR          (1)     /* pointer */
224 #define DT_FCN          (2)     /* function */
225 #define DT_ARY          (3)     /* array */
226
227 #define N_BTMASK        (0xf)
228 #define N_TMASK         (0x30)
229 #define N_BTSHFT        (4)
230 #define N_TSHIFT        (2)
231   
232 #define BTYPE(x)        ((x) & N_BTMASK)
233
234 #define ISPTR(x)        (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
235 #define ISFCN(x)        (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
236 #define ISARY(x)        (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
237
238 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
239
240 union external_auxent {
241         struct {
242                 char x_tagndx[4];       /* str, un, or enum tag indx */
243                 union {
244                         struct {
245                             char  x_lnno[2]; /* declaration line number */
246                             char  x_size[2]; /* str/union/array size */
247                         } x_lnsz;
248                         char x_fsize[4];        /* size of function */
249                 } x_misc;
250                 union {
251                         struct {                /* if ISFCN, tag, or .bb */
252                             char x_lnnoptr[4];  /* ptr to fcn line # */
253                             char x_endndx[4];   /* entry ndx past block end */
254                         } x_fcn;
255                         struct {                /* if ISARY, up to 4 dimen. */
256                             char x_dimen[E_DIMNUM][2];
257                         } x_ary;
258                 } x_fcnary;
259                 char x_tvndx[2];                /* tv index */
260         } x_sym;
261
262         union {
263                 char x_fname[E_FILNMLEN];
264                 struct {
265                         char x_zeroes[4];
266                         char x_offset[4];
267                 } x_n;
268         } x_file;
269
270         struct {
271                 char x_scnlen[4];                       /* section length */
272                 char x_nreloc[2];       /* # relocation entries */
273                 char x_nlinno[2];       /* # line numbers */
274         } x_scn;
275
276         struct {
277                 char x_tvfill[4];       /* tv fill value */
278                 char x_tvlen[2];        /* length of .tv */
279                 char x_tvran[2][2];     /* tv range */
280         } x_tv;         /* info about .tv section (in auxent of symbol .tv)) */
281
282
283 };
284
285 #define SYMENT  struct external_syment
286 #define SYMESZ  18      
287 #define AUXENT  union external_auxent
288 #define AUXESZ  18
289
290
291 #       define _ETEXT   "etext"
292
293
294 /********************** RELOCATION DIRECTIVES **********************/
295
296
297
298 struct external_reloc {
299   char r_vaddr[4];
300   char r_symndx[4];
301   char r_type[2];
302 };
303
304
305 #define RELOC struct external_reloc
306 #define RELSZ sizeof(RELOC)
307
308 #define DEFAULT_DATA_SECTION_ALIGNMENT 4
309 #define DEFAULT_BSS_SECTION_ALIGNMENT 4
310 #define DEFAULT_TEXT_SECTION_ALIGNMENT 4
311 /* For new sections we havn't heard of before */
312 #define DEFAULT_SECTION_ALIGNMENT 4