Commit | Line | Data |
---|---|---|
db688e87 NC |
1 | /* ARM COFF support for BFD. |
2 | Copyright (C) 1998, 1999 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of BFD, the Binary File Descriptor library. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software Foundation, | |
18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
252b5132 RH |
19 | |
20 | #define COFFARM 1 | |
21 | ||
22 | /********************** FILE HEADER **********************/ | |
23 | ||
db688e87 NC |
24 | struct external_filehdr |
25 | { | |
252b5132 RH |
26 | char f_magic[2]; /* magic number */ |
27 | char f_nscns[2]; /* number of sections */ | |
28 | char f_timdat[4]; /* time & date stamp */ | |
29 | char f_symptr[4]; /* file pointer to symtab */ | |
30 | char f_nsyms[4]; /* number of symtab entries */ | |
31 | char f_opthdr[2]; /* sizeof(optional hdr) */ | |
32 | char f_flags[2]; /* flags */ | |
33 | }; | |
34 | ||
35 | /* Bits for f_flags: | |
36 | * F_RELFLG relocation info stripped from file | |
37 | * F_EXEC file is executable (no unresolved external references) | |
38 | * F_LNNO line numbers stripped from file | |
39 | * F_LSYMS local symbols stripped from file | |
40 | * F_INTERWORK file supports switching between ARM and Thumb instruction sets | |
41 | * F_INTERWORK_SET the F_INTERWORK bit is valid | |
42 | * F_APCS_FLOAT code passes float arguments in float registers | |
43 | * F_PIC code is reentrant/position-independent | |
44 | * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) | |
45 | * F_APCS_26 file uses 26 bit ARM Procedure Calling Standard | |
46 | * F_APCS_SET the F_APCS_26, F_APCS_FLOAT and F_PIC bits have been initialised | |
c2c594b8 | 47 | * F_SOFT_FLOAT code does not use floating point instructions |
252b5132 RH |
48 | */ |
49 | ||
50 | #define F_RELFLG (0x0001) | |
51 | #define F_EXEC (0x0002) | |
52 | #define F_LNNO (0x0004) | |
53 | #define F_LSYMS (0x0008) | |
54 | #define F_INTERWORK (0x0010) | |
55 | #define F_INTERWORK_SET (0x0020) | |
56 | #define F_APCS_FLOAT (0x0040) | |
57 | #undef F_AR16WR | |
58 | #define F_PIC (0x0080) | |
59 | #define F_AR32WR (0x0100) | |
60 | #define F_APCS_26 (0x0400) | |
61 | #define F_APCS_SET (0x0800) | |
c2c594b8 | 62 | #define F_SOFT_FLOAT (0x2000) |
252b5132 RH |
63 | |
64 | /* Bits stored in flags field of the internal_f structure */ | |
65 | ||
66 | #define F_INTERWORK (0x0010) | |
252b5132 | 67 | #define F_APCS_FLOAT (0x0040) |
a74ffb02 NC |
68 | #define F_PIC (0x0080) |
69 | #define F_APCS26 (0x1000) | |
70 | #define F_ARM_ARCHITECTURE_MASK (0x4000+0x0800+0x0400) | |
71 | #define F_ARM_2 (0x0400) | |
72 | #define F_ARM_2a (0x0800) | |
73 | #define F_ARM_3 (0x0c00) | |
74 | #define F_ARM_3M (0x4000) | |
75 | #define F_ARM_4 (0x4400) | |
76 | #define F_ARM_4T (0x4800) | |
849a0ebf | 77 | #define F_ARM_5 (0x4c00) |
252b5132 RH |
78 | |
79 | /* | |
80 | * ARMMAGIC ought to encoded the procesor type, | |
81 | * but it is too late to change it now, instead | |
82 | * the flags field of the internal_f structure | |
83 | * is used as shown above. | |
84 | * | |
85 | * XXX - NC 5/6/97 | |
86 | */ | |
87 | ||
056350c6 | 88 | #define ARMMAGIC 0xa00 /* I just made this up */ |
252b5132 RH |
89 | |
90 | #define ARMBADMAG(x) (((x).f_magic != ARMMAGIC)) | |
91 | ||
056350c6 NC |
92 | #define ARMPEMAGIC 0x1c0 |
93 | #define THUMBPEMAGIC 0x1c2 | |
94 | ||
95 | #undef ARMBADMAG | |
96 | #define ARMBADMAG(x) (((x).f_magic != ARMMAGIC) && ((x).f_magic != ARMPEMAGIC) && ((x).f_magic != THUMBPEMAGIC)) | |
97 | ||
252b5132 RH |
98 | #define FILHDR struct external_filehdr |
99 | #define FILHSZ 20 | |
100 | ||
101 | ||
102 | /********************** AOUT "OPTIONAL HEADER" **********************/ | |
103 | ||
104 | ||
105 | typedef struct | |
106 | { | |
107 | char magic[2]; /* type of file */ | |
108 | char vstamp[2]; /* version stamp */ | |
109 | char tsize[4]; /* text size in bytes, padded to FW bdry*/ | |
110 | char dsize[4]; /* initialized data " " */ | |
111 | char bsize[4]; /* uninitialized data " " */ | |
112 | char entry[4]; /* entry pt. */ | |
113 | char text_start[4]; /* base of text used for this file */ | |
114 | char data_start[4]; /* base of data used for this file */ | |
252b5132 RH |
115 | } |
116 | AOUTHDR; | |
117 | ||
118 | ||
119 | #define AOUTSZ 28 | |
120 | #define AOUTHDRSZ 28 | |
121 | ||
122 | #define OMAGIC 0404 /* object files, eg as output */ | |
123 | #define ZMAGIC 0413 /* demand load format, eg normal ld output */ | |
124 | #define STMAGIC 0401 /* target shlib */ | |
125 | #define SHMAGIC 0443 /* host shlib */ | |
126 | ||
127 | ||
128 | /* define some NT default values */ | |
129 | /* #define NT_IMAGE_BASE 0x400000 moved to internal.h */ | |
130 | #define NT_SECTION_ALIGNMENT 0x1000 | |
131 | #define NT_FILE_ALIGNMENT 0x200 | |
132 | #define NT_DEF_RESERVE 0x100000 | |
133 | #define NT_DEF_COMMIT 0x1000 | |
134 | ||
135 | /********************** SECTION HEADER **********************/ | |
db688e87 NC |
136 | struct external_scnhdr |
137 | { | |
252b5132 RH |
138 | char s_name[8]; /* section name */ |
139 | char s_paddr[4]; /* physical address, aliased s_nlib */ | |
140 | char s_vaddr[4]; /* virtual address */ | |
141 | char s_size[4]; /* section size */ | |
142 | char s_scnptr[4]; /* file ptr to raw data for section */ | |
143 | char s_relptr[4]; /* file ptr to relocation */ | |
144 | char s_lnnoptr[4]; /* file ptr to line numbers */ | |
145 | char s_nreloc[2]; /* number of relocation entries */ | |
146 | char s_nlnno[2]; /* number of line number entries*/ | |
147 | char s_flags[4]; /* flags */ | |
148 | }; | |
149 | ||
150 | #define SCNHDR struct external_scnhdr | |
151 | #define SCNHSZ 40 | |
152 | ||
153 | /* | |
154 | * names of "special" sections | |
155 | */ | |
156 | #define _TEXT ".text" | |
157 | #define _DATA ".data" | |
158 | #define _BSS ".bss" | |
159 | #define _COMMENT ".comment" | |
160 | #define _LIB ".lib" | |
161 | ||
162 | /* We use the .rdata section to hold read only data. */ | |
163 | #define _LIT ".rdata" | |
164 | ||
165 | /********************** LINE NUMBERS **********************/ | |
166 | ||
167 | /* 1 line number entry for every "breakpointable" source line in a section. | |
168 | * Line numbers are grouped on a per function basis; first entry in a function | |
169 | * grouping will have l_lnno = 0 and in place of physical address will be the | |
170 | * symbol table index of the function name. | |
171 | */ | |
db688e87 NC |
172 | struct external_lineno |
173 | { | |
174 | union | |
175 | { | |
252b5132 RH |
176 | char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ |
177 | char l_paddr[4]; /* (physical) address of line number */ | |
178 | } l_addr; | |
179 | char l_lnno[2]; /* line number */ | |
180 | }; | |
181 | ||
182 | ||
183 | #define LINENO struct external_lineno | |
184 | #define LINESZ 6 | |
185 | ||
186 | ||
187 | /********************** SYMBOLS **********************/ | |
188 | ||
189 | #define E_SYMNMLEN 8 /* # characters in a symbol name */ | |
190 | #define E_FILNMLEN 14 /* # characters in a file name */ | |
191 | #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ | |
192 | ||
193 | struct external_syment | |
194 | { | |
db688e87 NC |
195 | union |
196 | { | |
252b5132 | 197 | char e_name[E_SYMNMLEN]; |
db688e87 NC |
198 | struct |
199 | { | |
252b5132 RH |
200 | char e_zeroes[4]; |
201 | char e_offset[4]; | |
202 | } e; | |
203 | } e; | |
204 | char e_value[4]; | |
205 | char e_scnum[2]; | |
206 | char e_type[2]; | |
207 | char e_sclass[1]; | |
208 | char e_numaux[1]; | |
209 | }; | |
210 | ||
211 | #define N_BTMASK (0xf) | |
212 | #define N_TMASK (0x30) | |
213 | #define N_BTSHFT (4) | |
214 | #define N_TSHIFT (2) | |
215 | ||
db688e87 NC |
216 | union external_auxent |
217 | { | |
218 | struct | |
219 | { | |
252b5132 | 220 | char x_tagndx[4]; /* str, un, or enum tag indx */ |
db688e87 NC |
221 | union |
222 | { | |
223 | struct | |
224 | { | |
252b5132 RH |
225 | char x_lnno[2]; /* declaration line number */ |
226 | char x_size[2]; /* str/union/array size */ | |
227 | } x_lnsz; | |
228 | char x_fsize[4]; /* size of function */ | |
229 | } x_misc; | |
db688e87 NC |
230 | union |
231 | { | |
232 | struct /* if ISFCN, tag, or .bb */ | |
233 | { | |
252b5132 RH |
234 | char x_lnnoptr[4]; /* ptr to fcn line # */ |
235 | char x_endndx[4]; /* entry ndx past block end */ | |
236 | } x_fcn; | |
db688e87 NC |
237 | struct /* if ISARY, up to 4 dimen. */ |
238 | { | |
252b5132 RH |
239 | char x_dimen[E_DIMNUM][2]; |
240 | } x_ary; | |
241 | } x_fcnary; | |
242 | char x_tvndx[2]; /* tv index */ | |
243 | } x_sym; | |
244 | ||
db688e87 NC |
245 | union |
246 | { | |
252b5132 | 247 | char x_fname[E_FILNMLEN]; |
db688e87 NC |
248 | struct |
249 | { | |
252b5132 RH |
250 | char x_zeroes[4]; |
251 | char x_offset[4]; | |
252 | } x_n; | |
253 | } x_file; | |
254 | ||
db688e87 NC |
255 | struct |
256 | { | |
252b5132 RH |
257 | char x_scnlen[4]; /* section length */ |
258 | char x_nreloc[2]; /* # relocation entries */ | |
259 | char x_nlinno[2]; /* # line numbers */ | |
260 | char x_checksum[4]; /* section COMDAT checksum */ | |
261 | char x_associated[2]; /* COMDAT associated section index */ | |
262 | char x_comdat[1]; /* COMDAT selection number */ | |
263 | } x_scn; | |
264 | ||
db688e87 NC |
265 | struct |
266 | { | |
252b5132 RH |
267 | char x_tvfill[4]; /* tv fill value */ |
268 | char x_tvlen[2]; /* length of .tv */ | |
269 | char x_tvran[2][2]; /* tv range */ | |
270 | } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ | |
252b5132 RH |
271 | }; |
272 | ||
273 | #define SYMENT struct external_syment | |
274 | #define SYMESZ 18 | |
275 | #define AUXENT union external_auxent | |
276 | #define AUXESZ 18 | |
277 | ||
db688e87 | 278 | #define _ETEXT "etext" |
252b5132 RH |
279 | |
280 | /********************** RELOCATION DIRECTIVES **********************/ | |
056350c6 NC |
281 | #ifdef ARM_WINCE |
282 | struct external_reloc | |
283 | { | |
284 | char r_vaddr[4]; | |
285 | char r_symndx[4]; | |
286 | char r_type[2]; | |
287 | }; | |
288 | ||
289 | #define RELOC struct external_reloc | |
290 | #define RELSZ 10 | |
291 | ||
292 | #else | |
db688e87 NC |
293 | struct external_reloc |
294 | { | |
252b5132 RH |
295 | char r_vaddr[4]; |
296 | char r_symndx[4]; | |
297 | char r_type[2]; | |
298 | char r_offset[4]; | |
299 | }; | |
300 | ||
252b5132 RH |
301 | #define RELOC struct external_reloc |
302 | #define RELSZ 14 | |
056350c6 | 303 | #endif |