Commit | Line | Data |
---|---|---|
3f61fc96 ILT |
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_TEXT 1 | |
53 | #define RELOC_SECTION_RDATA 2 | |
54 | #define RELOC_SECTION_DATA 3 | |
55 | #define RELOC_SECTION_SDATA 4 | |
56 | #define RELOC_SECTION_SBSS 5 | |
57 | #define RELOC_SECTION_BSS 6 | |
58 | #define RELOC_SECTION_INIT 7 | |
59 | #define RELOC_SECTION_LIT8 8 | |
60 | #define RELOC_SECTION_LIT4 9 | |
61 | #define RELOC_SECTION_XDATA 10 | |
62 | #define RELOC_SECTION_PDATA 11 | |
63 | #define RELOC_SECTION_FINI 12 | |
64 | #define RELOC_SECTION_LITA 13 | |
65 | #define RELOC_SECTION_ABS 14 | |
66 | ||
67 | /********************** STABS **********************/ | |
68 | ||
69 | /* gcc uses mips-tfile to output type information in special stabs | |
70 | entries. These must match the corresponding definition in | |
71 | gcc/config/mips.h. At some point, these should probably go into a | |
72 | shared include file, but currently gcc and gdb do not share any | |
73 | directories. */ | |
74 | #define CODE_MASK 0x8F300 | |
75 | #define ECOFF_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK) | |
76 | #define ECOFF_MARK_STAB(code) ((code)+CODE_MASK) | |
77 | #define ECOFF_UNMARK_STAB(code) ((code)-CODE_MASK) | |
78 | #define STABS_SYMBOL "@stabs" | |
79 | ||
80 | /********************** COFF **********************/ | |
81 | ||
82 | /* gcc also uses mips-tfile to output COFF debugging information. | |
83 | These are the values it uses when outputting the .type directive. | |
84 | These should also be in a shared include file. */ | |
85 | #define N_BTMASK (017) | |
86 | #define N_TMASK (060) | |
87 | #define N_BTSHFT (4) | |
88 | #define N_TSHIFT (2) | |
89 | ||
90 | /********************** AUX **********************/ | |
91 | ||
92 | /* The auxiliary type information is the same on all known ECOFF | |
93 | targets. I can't see any reason that it would ever change, so I am | |
94 | going to gamble and define the external structures here, in the | |
95 | target independent ECOFF header file. The internal forms are | |
96 | defined in coff/sym.h, which was originally donated by MIPS | |
97 | Computer Systems. */ | |
98 | ||
99 | /* Type information external record */ | |
100 | ||
101 | struct tir_ext { | |
102 | unsigned char t_bits1[1]; | |
103 | unsigned char t_tq45[1]; | |
104 | unsigned char t_tq01[1]; | |
105 | unsigned char t_tq23[1]; | |
106 | }; | |
107 | ||
108 | #define TIR_BITS1_FBITFIELD_BIG 0x80 | |
109 | #define TIR_BITS1_FBITFIELD_LITTLE 0x01 | |
110 | ||
111 | #define TIR_BITS1_CONTINUED_BIG 0x40 | |
112 | #define TIR_BITS1_CONTINUED_LITTLE 0x02 | |
113 | ||
114 | #define TIR_BITS1_BT_BIG 0x3F | |
115 | #define TIR_BITS1_BT_SH_BIG 0 | |
116 | #define TIR_BITS1_BT_LITTLE 0xFC | |
117 | #define TIR_BITS1_BT_SH_LITTLE 2 | |
118 | ||
119 | #define TIR_BITS_TQ4_BIG 0xF0 | |
120 | #define TIR_BITS_TQ4_SH_BIG 4 | |
121 | #define TIR_BITS_TQ5_BIG 0x0F | |
122 | #define TIR_BITS_TQ5_SH_BIG 0 | |
123 | #define TIR_BITS_TQ4_LITTLE 0x0F | |
124 | #define TIR_BITS_TQ4_SH_LITTLE 0 | |
125 | #define TIR_BITS_TQ5_LITTLE 0xF0 | |
126 | #define TIR_BITS_TQ5_SH_LITTLE 4 | |
127 | ||
128 | #define TIR_BITS_TQ0_BIG 0xF0 | |
129 | #define TIR_BITS_TQ0_SH_BIG 4 | |
130 | #define TIR_BITS_TQ1_BIG 0x0F | |
131 | #define TIR_BITS_TQ1_SH_BIG 0 | |
132 | #define TIR_BITS_TQ0_LITTLE 0x0F | |
133 | #define TIR_BITS_TQ0_SH_LITTLE 0 | |
134 | #define TIR_BITS_TQ1_LITTLE 0xF0 | |
135 | #define TIR_BITS_TQ1_SH_LITTLE 4 | |
136 | ||
137 | #define TIR_BITS_TQ2_BIG 0xF0 | |
138 | #define TIR_BITS_TQ2_SH_BIG 4 | |
139 | #define TIR_BITS_TQ3_BIG 0x0F | |
140 | #define TIR_BITS_TQ3_SH_BIG 0 | |
141 | #define TIR_BITS_TQ2_LITTLE 0x0F | |
142 | #define TIR_BITS_TQ2_SH_LITTLE 0 | |
143 | #define TIR_BITS_TQ3_LITTLE 0xF0 | |
144 | #define TIR_BITS_TQ3_SH_LITTLE 4 | |
145 | ||
146 | /* Relative symbol external record */ | |
147 | ||
148 | struct rndx_ext { | |
149 | unsigned char r_bits[4]; | |
150 | }; | |
151 | ||
152 | #define RNDX_BITS0_RFD_SH_LEFT_BIG 4 | |
153 | #define RNDX_BITS1_RFD_BIG 0xF0 | |
154 | #define RNDX_BITS1_RFD_SH_BIG 4 | |
155 | ||
156 | #define RNDX_BITS0_RFD_SH_LEFT_LITTLE 0 | |
157 | #define RNDX_BITS1_RFD_LITTLE 0x0F | |
158 | #define RNDX_BITS1_RFD_SH_LEFT_LITTLE 8 | |
159 | ||
160 | #define RNDX_BITS1_INDEX_BIG 0x0F | |
161 | #define RNDX_BITS1_INDEX_SH_LEFT_BIG 16 | |
162 | #define RNDX_BITS2_INDEX_SH_LEFT_BIG 8 | |
163 | #define RNDX_BITS3_INDEX_SH_LEFT_BIG 0 | |
164 | ||
165 | #define RNDX_BITS1_INDEX_LITTLE 0xF0 | |
166 | #define RNDX_BITS1_INDEX_SH_LITTLE 4 | |
167 | #define RNDX_BITS2_INDEX_SH_LEFT_LITTLE 4 | |
168 | #define RNDX_BITS3_INDEX_SH_LEFT_LITTLE 12 | |
169 | ||
170 | /* Auxiliary symbol information external record */ | |
171 | ||
172 | union aux_ext { | |
173 | struct tir_ext a_ti; | |
174 | struct rndx_ext a_rndx; | |
175 | unsigned char a_dnLow[4]; | |
176 | unsigned char a_dnHigh[4]; | |
177 | unsigned char a_isym[4]; | |
178 | unsigned char a_iss[4]; | |
179 | unsigned char a_width[4]; | |
180 | unsigned char a_count[4]; | |
181 | }; | |
182 | ||
183 | /* FIXME! These are copied from ../bfd/libbfd.h */ | |
184 | extern bfd_vma _do_getb32 PARAMS ((unsigned char *addr)); | |
185 | extern bfd_vma _do_getl32 PARAMS ((unsigned char *addr)); | |
186 | extern void _do_putb32 PARAMS ((bfd_vma data, unsigned char *addr)); | |
187 | extern void _do_putl32 PARAMS ((bfd_vma data, unsigned char *addr)); | |
188 | ||
189 | #define AUX_GET_ANY(bigend, ax, field) \ | |
190 | ((bigend) ? _do_getb32 ((ax)->field) : _do_getl32 ((ax)->field)) | |
191 | ||
192 | #define AUX_GET_DNLOW(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_dnLow) | |
193 | #define AUX_GET_DNHIGH(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_dnHigh) | |
194 | #define AUX_GET_ISYM(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_isym) | |
195 | #define AUX_GET_ISS(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_iss) | |
196 | #define AUX_GET_WIDTH(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_width) | |
197 | #define AUX_GET_COUNT(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_count) | |
198 | ||
199 | #define AUX_PUT_ANY(bigend, val, ax, field) \ | |
200 | ((bigend) \ | |
201 | ? (_do_putb32 ((val), (ax)->field), 0) \ | |
202 | : (_do_putl32 ((val), (ax)->field), 0)) | |
203 | ||
204 | #define AUX_PUT_DNLOW(bigend, val, ax) \ | |
205 | AUX_PUT_ANY ((bigend), (val), (ax), a_dnLow) | |
206 | #define AUX_PUT_DNHIGH(bigend, val, ax) \ | |
207 | AUX_PUT_ANY ((bigend), (val), (ax), a_dnHigh) | |
208 | #define AUX_PUT_ISYM(bigend, val, ax) \ | |
209 | AUX_PUT_ANY ((bigend), (val), (ax), a_isym) | |
210 | #define AUX_PUT_ISS(bigend, val, ax) \ | |
211 | AUX_PUT_ANY ((bigend), (val), (ax), a_iss) | |
212 | #define AUX_PUT_WIDTH(bigend, val, ax) \ | |
213 | AUX_PUT_ANY ((bigend), (val), (ax), a_width) | |
214 | #define AUX_PUT_COUNT(bigend, val, ax) \ | |
215 | AUX_PUT_ANY ((bigend), (val), (ax), a_count) | |
216 | ||
217 | /* Prototypes for the swapping functions. These require that sym.h be | |
218 | included before this file. */ | |
219 | ||
220 | extern void ecoff_swap_tir_in PARAMS ((int bigend, struct tir_ext *, TIR *)); | |
221 | extern void ecoff_swap_tir_out PARAMS ((int bigend, TIR *, struct tir_ext *)); | |
222 | extern void ecoff_swap_rndx_in PARAMS ((int bigend, struct rndx_ext *, | |
223 | RNDXR *)); | |
224 | extern void ecoff_swap_rndx_out PARAMS ((int bigend, RNDXR *, | |
225 | struct rndx_ext *)); | |
226 | ||
227 | #endif /* ! defined (ECOFF_H) */ |