4 /* Generic ECOFF support.
5 This does not include symbol information, found in sym.h and
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
15 /* Alpha magic numbers used in filehdr. */
16 #define ALPHA_MAGIC 0x183
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 */
22 /* Names of special sections. */
26 #define _RDATA ".rdata"
27 #define _SDATA ".sdata"
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
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
47 #define SCOMMON ".scommon"
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
68 /********************** STABS **********************/
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
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"
81 /********************** COFF **********************/
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)
91 /********************** AUX **********************/
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
100 /* Type information external record */
103 unsigned char t_bits1[1];
104 unsigned char t_tq45[1];
105 unsigned char t_tq01[1];
106 unsigned char t_tq23[1];
109 #define TIR_BITS1_FBITFIELD_BIG 0x80
110 #define TIR_BITS1_FBITFIELD_LITTLE 0x01
112 #define TIR_BITS1_CONTINUED_BIG 0x40
113 #define TIR_BITS1_CONTINUED_LITTLE 0x02
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
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
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
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
147 /* Relative symbol external record */
150 unsigned char r_bits[4];
153 #define RNDX_BITS0_RFD_SH_LEFT_BIG 4
154 #define RNDX_BITS1_RFD_BIG 0xF0
155 #define RNDX_BITS1_RFD_SH_BIG 4
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
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
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
171 /* Auxiliary symbol information external record */
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];
184 /* FIXME! These are copied from ../bfd/libbfd.h. They are used by
186 extern bfd_vma _bfd__do_getb32 PARAMS ((unsigned char *addr));
187 extern bfd_vma _bfd__do_getl32 PARAMS ((unsigned char *addr));
189 /* These don't seem to be used. */
190 extern void _do_putb32 PARAMS ((bfd_vma data, unsigned char *addr));
191 extern void _do_putl32 PARAMS ((bfd_vma data, unsigned char *addr));
194 #define AUX_GET_ANY(bigend, ax, field) \
195 ((bigend) ? _bfd__do_getb32 ((ax)->field) : _bfd__do_getl32 ((ax)->field))
197 #define AUX_GET_DNLOW(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_dnLow)
198 #define AUX_GET_DNHIGH(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_dnHigh)
199 #define AUX_GET_ISYM(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_isym)
200 #define AUX_GET_ISS(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_iss)
201 #define AUX_GET_WIDTH(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_width)
202 #define AUX_GET_COUNT(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_count)
205 /* These don't seem to be used. */
206 #define AUX_PUT_ANY(bigend, val, ax, field) \
208 ? (_do_putb32 ((val), (ax)->field), 0) \
209 : (_do_putl32 ((val), (ax)->field), 0))
211 #define AUX_PUT_DNLOW(bigend, val, ax) \
212 AUX_PUT_ANY ((bigend), (val), (ax), a_dnLow)
213 #define AUX_PUT_DNHIGH(bigend, val, ax) \
214 AUX_PUT_ANY ((bigend), (val), (ax), a_dnHigh)
215 #define AUX_PUT_ISYM(bigend, val, ax) \
216 AUX_PUT_ANY ((bigend), (val), (ax), a_isym)
217 #define AUX_PUT_ISS(bigend, val, ax) \
218 AUX_PUT_ANY ((bigend), (val), (ax), a_iss)
219 #define AUX_PUT_WIDTH(bigend, val, ax) \
220 AUX_PUT_ANY ((bigend), (val), (ax), a_width)
221 #define AUX_PUT_COUNT(bigend, val, ax) \
222 AUX_PUT_ANY ((bigend), (val), (ax), a_count)
225 /* Prototypes for the swapping functions. These require that sym.h be
226 included before this file. */
228 extern void ecoff_swap_tir_in PARAMS ((int bigend, struct tir_ext *, TIR *));
229 extern void ecoff_swap_tir_out PARAMS ((int bigend, TIR *, struct tir_ext *));
230 extern void ecoff_swap_rndx_in PARAMS ((int bigend, struct rndx_ext *,
232 extern void ecoff_swap_rndx_out PARAMS ((int bigend, RNDXR *,
235 #endif /* ! defined (ECOFF_H) */