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 | |
db688e87 | 47 | * F_SOFTFLOAT 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) | |
db688e87 | 62 | #define F_SOFTFLOAT (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 | ||
88 | #define ARMMAGIC 0xa00 /* I just made this up */ | |
89 | ||
90 | #define ARMBADMAG(x) (((x).f_magic != ARMMAGIC)) | |
91 | ||
92 | #define FILHDR struct external_filehdr | |
93 | #define FILHSZ 20 | |
94 | ||
95 | ||
96 | /********************** AOUT "OPTIONAL HEADER" **********************/ | |
97 | ||
98 | ||
99 | typedef struct | |
100 | { | |
101 | char magic[2]; /* type of file */ | |
102 | char vstamp[2]; /* version stamp */ | |
103 | char tsize[4]; /* text size in bytes, padded to FW bdry*/ | |
104 | char dsize[4]; /* initialized data " " */ | |
105 | char bsize[4]; /* uninitialized data " " */ | |
106 | char entry[4]; /* entry pt. */ | |
107 | char text_start[4]; /* base of text used for this file */ | |
108 | char data_start[4]; /* base of data used for this file */ | |
252b5132 RH |
109 | } |
110 | AOUTHDR; | |
111 | ||
112 | ||
113 | #define AOUTSZ 28 | |
114 | #define AOUTHDRSZ 28 | |
115 | ||
116 | #define OMAGIC 0404 /* object files, eg as output */ | |
117 | #define ZMAGIC 0413 /* demand load format, eg normal ld output */ | |
118 | #define STMAGIC 0401 /* target shlib */ | |
119 | #define SHMAGIC 0443 /* host shlib */ | |
120 | ||
121 | ||
122 | /* define some NT default values */ | |
123 | /* #define NT_IMAGE_BASE 0x400000 moved to internal.h */ | |
124 | #define NT_SECTION_ALIGNMENT 0x1000 | |
125 | #define NT_FILE_ALIGNMENT 0x200 | |
126 | #define NT_DEF_RESERVE 0x100000 | |
127 | #define NT_DEF_COMMIT 0x1000 | |
128 | ||
129 | /********************** SECTION HEADER **********************/ | |
db688e87 NC |
130 | struct external_scnhdr |
131 | { | |
252b5132 RH |
132 | char s_name[8]; /* section name */ |
133 | char s_paddr[4]; /* physical address, aliased s_nlib */ | |
134 | char s_vaddr[4]; /* virtual address */ | |
135 | char s_size[4]; /* section size */ | |
136 | char s_scnptr[4]; /* file ptr to raw data for section */ | |
137 | char s_relptr[4]; /* file ptr to relocation */ | |
138 | char s_lnnoptr[4]; /* file ptr to line numbers */ | |
139 | char s_nreloc[2]; /* number of relocation entries */ | |
140 | char s_nlnno[2]; /* number of line number entries*/ | |
141 | char s_flags[4]; /* flags */ | |
142 | }; | |
143 | ||
144 | #define SCNHDR struct external_scnhdr | |
145 | #define SCNHSZ 40 | |
146 | ||
147 | /* | |
148 | * names of "special" sections | |
149 | */ | |
150 | #define _TEXT ".text" | |
151 | #define _DATA ".data" | |
152 | #define _BSS ".bss" | |
153 | #define _COMMENT ".comment" | |
154 | #define _LIB ".lib" | |
155 | ||
156 | /* We use the .rdata section to hold read only data. */ | |
157 | #define _LIT ".rdata" | |
158 | ||
159 | /********************** LINE NUMBERS **********************/ | |
160 | ||
161 | /* 1 line number entry for every "breakpointable" source line in a section. | |
162 | * Line numbers are grouped on a per function basis; first entry in a function | |
163 | * grouping will have l_lnno = 0 and in place of physical address will be the | |
164 | * symbol table index of the function name. | |
165 | */ | |
db688e87 NC |
166 | struct external_lineno |
167 | { | |
168 | union | |
169 | { | |
252b5132 RH |
170 | char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ |
171 | char l_paddr[4]; /* (physical) address of line number */ | |
172 | } l_addr; | |
173 | char l_lnno[2]; /* line number */ | |
174 | }; | |
175 | ||
176 | ||
177 | #define LINENO struct external_lineno | |
178 | #define LINESZ 6 | |
179 | ||
180 | ||
181 | /********************** SYMBOLS **********************/ | |
182 | ||
183 | #define E_SYMNMLEN 8 /* # characters in a symbol name */ | |
184 | #define E_FILNMLEN 14 /* # characters in a file name */ | |
185 | #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ | |
186 | ||
187 | struct external_syment | |
188 | { | |
db688e87 NC |
189 | union |
190 | { | |
252b5132 | 191 | char e_name[E_SYMNMLEN]; |
db688e87 NC |
192 | struct |
193 | { | |
252b5132 RH |
194 | char e_zeroes[4]; |
195 | char e_offset[4]; | |
196 | } e; | |
197 | } e; | |
198 | char e_value[4]; | |
199 | char e_scnum[2]; | |
200 | char e_type[2]; | |
201 | char e_sclass[1]; | |
202 | char e_numaux[1]; | |
203 | }; | |
204 | ||
205 | #define N_BTMASK (0xf) | |
206 | #define N_TMASK (0x30) | |
207 | #define N_BTSHFT (4) | |
208 | #define N_TSHIFT (2) | |
209 | ||
db688e87 NC |
210 | union external_auxent |
211 | { | |
212 | struct | |
213 | { | |
252b5132 | 214 | char x_tagndx[4]; /* str, un, or enum tag indx */ |
db688e87 NC |
215 | union |
216 | { | |
217 | struct | |
218 | { | |
252b5132 RH |
219 | char x_lnno[2]; /* declaration line number */ |
220 | char x_size[2]; /* str/union/array size */ | |
221 | } x_lnsz; | |
222 | char x_fsize[4]; /* size of function */ | |
223 | } x_misc; | |
db688e87 NC |
224 | union |
225 | { | |
226 | struct /* if ISFCN, tag, or .bb */ | |
227 | { | |
252b5132 RH |
228 | char x_lnnoptr[4]; /* ptr to fcn line # */ |
229 | char x_endndx[4]; /* entry ndx past block end */ | |
230 | } x_fcn; | |
db688e87 NC |
231 | struct /* if ISARY, up to 4 dimen. */ |
232 | { | |
252b5132 RH |
233 | char x_dimen[E_DIMNUM][2]; |
234 | } x_ary; | |
235 | } x_fcnary; | |
236 | char x_tvndx[2]; /* tv index */ | |
237 | } x_sym; | |
238 | ||
db688e87 NC |
239 | union |
240 | { | |
252b5132 | 241 | char x_fname[E_FILNMLEN]; |
db688e87 NC |
242 | struct |
243 | { | |
252b5132 RH |
244 | char x_zeroes[4]; |
245 | char x_offset[4]; | |
246 | } x_n; | |
247 | } x_file; | |
248 | ||
db688e87 NC |
249 | struct |
250 | { | |
252b5132 RH |
251 | char x_scnlen[4]; /* section length */ |
252 | char x_nreloc[2]; /* # relocation entries */ | |
253 | char x_nlinno[2]; /* # line numbers */ | |
254 | char x_checksum[4]; /* section COMDAT checksum */ | |
255 | char x_associated[2]; /* COMDAT associated section index */ | |
256 | char x_comdat[1]; /* COMDAT selection number */ | |
257 | } x_scn; | |
258 | ||
db688e87 NC |
259 | struct |
260 | { | |
252b5132 RH |
261 | char x_tvfill[4]; /* tv fill value */ |
262 | char x_tvlen[2]; /* length of .tv */ | |
263 | char x_tvran[2][2]; /* tv range */ | |
264 | } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ | |
265 | ||
266 | ||
267 | }; | |
268 | ||
269 | #define SYMENT struct external_syment | |
270 | #define SYMESZ 18 | |
271 | #define AUXENT union external_auxent | |
272 | #define AUXESZ 18 | |
273 | ||
db688e87 | 274 | #define _ETEXT "etext" |
252b5132 RH |
275 | |
276 | /********************** RELOCATION DIRECTIVES **********************/ | |
db688e87 NC |
277 | struct external_reloc |
278 | { | |
252b5132 RH |
279 | char r_vaddr[4]; |
280 | char r_symndx[4]; | |
281 | char r_type[2]; | |
282 | char r_offset[4]; | |
283 | }; | |
284 | ||
285 | ||
286 | #define RELOC struct external_reloc | |
287 | #define RELSZ 14 |