81bb81895f9cbfc197234b2a9a3da00fa3edaf09
[deliverable/binutils-gdb.git] / include / coff / ecoff.h
1 #ifndef ECOFF_H
2 #define ECOFF_H
3
4 /* Generic ECOFF support.
5 This does not include symbol information, found in sym.h and
6 symconst.h. */
7
8 /* Mips magic numbers used in filehdr. MIPS_MAGIC_LITTLE is used on
9 little endian machines. MIPS_MAGIC_BIG is used on big endian
10 machines. Where is MIPS_MAGIC_1 from? */
11 #define MIPS_MAGIC_1 0x0180
12 #define MIPS_MAGIC_LITTLE 0x0162
13 #define MIPS_MAGIC_BIG 0x0160
14
15 /* Alpha magic numbers used in filehdr. */
16 #define ALPHA_MAGIC 0x183
17
18 /* Magic numbers used in a.out header. */
19 #define ECOFF_AOUT_OMAGIC 0407 /* not demand paged (ld -N). */
20 #define ECOFF_AOUT_ZMAGIC 0413 /* demand load format, eg normal ld output */
21
22 /* Names of special sections. */
23 #define _TEXT ".text"
24 #define _DATA ".data"
25 #define _BSS ".bss"
26 #define _RDATA ".rdata"
27 #define _SDATA ".sdata"
28 #define _SBSS ".sbss"
29 #define _LIT4 ".lit4"
30 #define _LIT8 ".lit8"
31 #define _LIB ".lib"
32 #define _INIT ".init"
33
34 /* ECOFF uses some additional section flags. */
35 #define STYP_RDATA 0x100
36 #define STYP_SDATA 0x200
37 #define STYP_SBSS 0x400
38 #define STYP_LIT8 0x8000000
39 #define STYP_LIT4 0x10000000
40 #define STYP_ECOFF_INIT 0x80000000
41 #define STYP_OTHER_LOAD STYP_ECOFF_INIT
42
43 /* The linker needs a section to hold small common variables while
44 linking. There is no convenient way to create it when the linker
45 needs it, so we always create one for each BFD. We then avoid
46 writing it out. */
47 #define SCOMMON ".scommon"
48
49 /* If the extern bit in a reloc is 1, then r_symndx is an index into
50 the external symbol table. If the extern bit is 0, then r_symndx
51 indicates a section, and is one of the following values. */
52 #define RELOC_SECTION_NONE 0
53 #define RELOC_SECTION_TEXT 1
54 #define RELOC_SECTION_RDATA 2
55 #define RELOC_SECTION_DATA 3
56 #define RELOC_SECTION_SDATA 4
57 #define RELOC_SECTION_SBSS 5
58 #define RELOC_SECTION_BSS 6
59 #define RELOC_SECTION_INIT 7
60 #define RELOC_SECTION_LIT8 8
61 #define RELOC_SECTION_LIT4 9
62 #define RELOC_SECTION_XDATA 10
63 #define RELOC_SECTION_PDATA 11
64 #define RELOC_SECTION_FINI 12
65 #define RELOC_SECTION_LITA 13
66 #define RELOC_SECTION_ABS 14
67
68 /********************** STABS **********************/
69
70 /* gcc uses mips-tfile to output type information in special stabs
71 entries. These must match the corresponding definition in
72 gcc/config/mips.h. At some point, these should probably go into a
73 shared include file, but currently gcc and gdb do not share any
74 directories. */
75 #define CODE_MASK 0x8F300
76 #define ECOFF_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
77 #define ECOFF_MARK_STAB(code) ((code)+CODE_MASK)
78 #define ECOFF_UNMARK_STAB(code) ((code)-CODE_MASK)
79 #define STABS_SYMBOL "@stabs"
80
81 /********************** COFF **********************/
82
83 /* gcc also uses mips-tfile to output COFF debugging information.
84 These are the values it uses when outputting the .type directive.
85 These should also be in a shared include file. */
86 #define N_BTMASK (017)
87 #define N_TMASK (060)
88 #define N_BTSHFT (4)
89 #define N_TSHIFT (2)
90
91 /********************** AUX **********************/
92
93 /* The auxiliary type information is the same on all known ECOFF
94 targets. I can't see any reason that it would ever change, so I am
95 going to gamble and define the external structures here, in the
96 target independent ECOFF header file. The internal forms are
97 defined in coff/sym.h, which was originally donated by MIPS
98 Computer Systems. */
99
100 /* Type information external record */
101
102 struct tir_ext {
103 unsigned char t_bits1[1];
104 unsigned char t_tq45[1];
105 unsigned char t_tq01[1];
106 unsigned char t_tq23[1];
107 };
108
109 #define TIR_BITS1_FBITFIELD_BIG 0x80
110 #define TIR_BITS1_FBITFIELD_LITTLE 0x01
111
112 #define TIR_BITS1_CONTINUED_BIG 0x40
113 #define TIR_BITS1_CONTINUED_LITTLE 0x02
114
115 #define TIR_BITS1_BT_BIG 0x3F
116 #define TIR_BITS1_BT_SH_BIG 0
117 #define TIR_BITS1_BT_LITTLE 0xFC
118 #define TIR_BITS1_BT_SH_LITTLE 2
119
120 #define TIR_BITS_TQ4_BIG 0xF0
121 #define TIR_BITS_TQ4_SH_BIG 4
122 #define TIR_BITS_TQ5_BIG 0x0F
123 #define TIR_BITS_TQ5_SH_BIG 0
124 #define TIR_BITS_TQ4_LITTLE 0x0F
125 #define TIR_BITS_TQ4_SH_LITTLE 0
126 #define TIR_BITS_TQ5_LITTLE 0xF0
127 #define TIR_BITS_TQ5_SH_LITTLE 4
128
129 #define TIR_BITS_TQ0_BIG 0xF0
130 #define TIR_BITS_TQ0_SH_BIG 4
131 #define TIR_BITS_TQ1_BIG 0x0F
132 #define TIR_BITS_TQ1_SH_BIG 0
133 #define TIR_BITS_TQ0_LITTLE 0x0F
134 #define TIR_BITS_TQ0_SH_LITTLE 0
135 #define TIR_BITS_TQ1_LITTLE 0xF0
136 #define TIR_BITS_TQ1_SH_LITTLE 4
137
138 #define TIR_BITS_TQ2_BIG 0xF0
139 #define TIR_BITS_TQ2_SH_BIG 4
140 #define TIR_BITS_TQ3_BIG 0x0F
141 #define TIR_BITS_TQ3_SH_BIG 0
142 #define TIR_BITS_TQ2_LITTLE 0x0F
143 #define TIR_BITS_TQ2_SH_LITTLE 0
144 #define TIR_BITS_TQ3_LITTLE 0xF0
145 #define TIR_BITS_TQ3_SH_LITTLE 4
146
147 /* Relative symbol external record */
148
149 struct rndx_ext {
150 unsigned char r_bits[4];
151 };
152
153 #define RNDX_BITS0_RFD_SH_LEFT_BIG 4
154 #define RNDX_BITS1_RFD_BIG 0xF0
155 #define RNDX_BITS1_RFD_SH_BIG 4
156
157 #define RNDX_BITS0_RFD_SH_LEFT_LITTLE 0
158 #define RNDX_BITS1_RFD_LITTLE 0x0F
159 #define RNDX_BITS1_RFD_SH_LEFT_LITTLE 8
160
161 #define RNDX_BITS1_INDEX_BIG 0x0F
162 #define RNDX_BITS1_INDEX_SH_LEFT_BIG 16
163 #define RNDX_BITS2_INDEX_SH_LEFT_BIG 8
164 #define RNDX_BITS3_INDEX_SH_LEFT_BIG 0
165
166 #define RNDX_BITS1_INDEX_LITTLE 0xF0
167 #define RNDX_BITS1_INDEX_SH_LITTLE 4
168 #define RNDX_BITS2_INDEX_SH_LEFT_LITTLE 4
169 #define RNDX_BITS3_INDEX_SH_LEFT_LITTLE 12
170
171 /* Auxiliary symbol information external record */
172
173 union aux_ext {
174 struct tir_ext a_ti;
175 struct rndx_ext a_rndx;
176 unsigned char a_dnLow[4];
177 unsigned char a_dnHigh[4];
178 unsigned char a_isym[4];
179 unsigned char a_iss[4];
180 unsigned char a_width[4];
181 unsigned char a_count[4];
182 };
183
184 #define AUX_GET_ANY(bigend, ax, field) \
185 ((bigend) ? bfd_getb32 ((ax)->field) : bfd_getl32 ((ax)->field))
186
187 #define AUX_GET_DNLOW(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_dnLow)
188 #define AUX_GET_DNHIGH(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_dnHigh)
189 #define AUX_GET_ISYM(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_isym)
190 #define AUX_GET_ISS(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_iss)
191 #define AUX_GET_WIDTH(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_width)
192 #define AUX_GET_COUNT(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_count)
193
194 #define AUX_PUT_ANY(bigend, val, ax, field) \
195 ((bigend) \
196 ? (bfd_putb32 ((val), (ax)->field), 0) \
197 : (bfd_putl32 ((val), (ax)->field), 0))
198
199 #define AUX_PUT_DNLOW(bigend, val, ax) \
200 AUX_PUT_ANY ((bigend), (val), (ax), a_dnLow)
201 #define AUX_PUT_DNHIGH(bigend, val, ax) \
202 AUX_PUT_ANY ((bigend), (val), (ax), a_dnHigh)
203 #define AUX_PUT_ISYM(bigend, val, ax) \
204 AUX_PUT_ANY ((bigend), (val), (ax), a_isym)
205 #define AUX_PUT_ISS(bigend, val, ax) \
206 AUX_PUT_ANY ((bigend), (val), (ax), a_iss)
207 #define AUX_PUT_WIDTH(bigend, val, ax) \
208 AUX_PUT_ANY ((bigend), (val), (ax), a_width)
209 #define AUX_PUT_COUNT(bigend, val, ax) \
210 AUX_PUT_ANY ((bigend), (val), (ax), a_count)
211
212 /* Prototypes for the swapping functions. These require that sym.h be
213 included before this file. */
214
215 extern void ecoff_swap_tir_in PARAMS ((int bigend, struct tir_ext *, TIR *));
216 extern void ecoff_swap_tir_out PARAMS ((int bigend, TIR *, struct tir_ext *));
217 extern void ecoff_swap_rndx_in PARAMS ((int bigend, struct rndx_ext *,
218 RNDXR *));
219 extern void ecoff_swap_rndx_out PARAMS ((int bigend, RNDXR *,
220 struct rndx_ext *));
221
222 #endif /* ! defined (ECOFF_H) */
This page took 0.03514 seconds and 4 git commands to generate.