1 /* ARM COFF support for BFD.
2 Copyright (C) 1998, 1999 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
22 /********************** FILE HEADER **********************/
24 struct external_filehdr
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 */
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
47 * F_SOFT_FLOAT code does not use floating point instructions
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)
58 #define F_PIC (0x0080)
59 #define F_AR32WR (0x0100)
60 #define F_APCS_26 (0x0400)
61 #define F_APCS_SET (0x0800)
62 #define F_SOFT_FLOAT (0x2000)
64 /* Bits stored in flags field of the internal_f structure */
66 #define F_INTERWORK (0x0010)
67 #define F_APCS_FLOAT (0x0040)
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)
77 #define F_ARM_5 (0x4c00)
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.
88 #define ARMMAGIC 0xa00 /* I just made this up */
90 #define ARMBADMAG(x) (((x).f_magic != ARMMAGIC))
92 #define FILHDR struct external_filehdr
96 /********************** AOUT "OPTIONAL HEADER" **********************/
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 */
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 */
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
129 /********************** SECTION HEADER **********************/
130 struct external_scnhdr
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 */
144 #define SCNHDR struct external_scnhdr
148 * names of "special" sections
150 #define _TEXT ".text"
151 #define _DATA ".data"
153 #define _COMMENT ".comment"
156 /* We use the .rdata section to hold read only data. */
157 #define _LIT ".rdata"
159 /********************** LINE NUMBERS **********************/
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.
166 struct external_lineno
170 char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
171 char l_paddr[4]; /* (physical) address of line number */
173 char l_lnno[2]; /* line number */
177 #define LINENO struct external_lineno
181 /********************** SYMBOLS **********************/
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 */
187 struct external_syment
191 char e_name[E_SYMNMLEN];
205 #define N_BTMASK (0xf)
206 #define N_TMASK (0x30)
210 union external_auxent
214 char x_tagndx[4]; /* str, un, or enum tag indx */
219 char x_lnno[2]; /* declaration line number */
220 char x_size[2]; /* str/union/array size */
222 char x_fsize[4]; /* size of function */
226 struct /* if ISFCN, tag, or .bb */
228 char x_lnnoptr[4]; /* ptr to fcn line # */
229 char x_endndx[4]; /* entry ndx past block end */
231 struct /* if ISARY, up to 4 dimen. */
233 char x_dimen[E_DIMNUM][2];
236 char x_tvndx[2]; /* tv index */
241 char x_fname[E_FILNMLEN];
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 */
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)) */
267 #define SYMENT struct external_syment
269 #define AUXENT union external_auxent
272 #define _ETEXT "etext"
274 /********************** RELOCATION DIRECTIVES **********************/
275 struct external_reloc
283 #define RELOC struct external_reloc