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 ARMPEMAGIC 0x1c0
93 #define THUMBPEMAGIC 0x1c2
96 #define ARMBADMAG(x) (((x).f_magic != ARMMAGIC) && ((x).f_magic != ARMPEMAGIC) && ((x).f_magic != THUMBPEMAGIC))
98 #define FILHDR struct external_filehdr
102 /********************** AOUT "OPTIONAL HEADER" **********************/
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 */
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 */
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
135 /********************** SECTION HEADER **********************/
136 struct external_scnhdr
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 */
150 #define SCNHDR struct external_scnhdr
154 * names of "special" sections
156 #define _TEXT ".text"
157 #define _DATA ".data"
159 #define _COMMENT ".comment"
162 /* We use the .rdata section to hold read only data. */
163 #define _LIT ".rdata"
165 /********************** LINE NUMBERS **********************/
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.
172 struct external_lineno
176 char l_symndx
[4]; /* function name symbol index, iff l_lnno == 0*/
177 char l_paddr
[4]; /* (physical) address of line number */
179 char l_lnno
[2]; /* line number */
183 #define LINENO struct external_lineno
187 /********************** SYMBOLS **********************/
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 */
193 struct external_syment
197 char e_name
[E_SYMNMLEN
];
211 #define N_BTMASK (0xf)
212 #define N_TMASK (0x30)
216 union external_auxent
220 char x_tagndx
[4]; /* str, un, or enum tag indx */
225 char x_lnno
[2]; /* declaration line number */
226 char x_size
[2]; /* str/union/array size */
228 char x_fsize
[4]; /* size of function */
232 struct /* if ISFCN, tag, or .bb */
234 char x_lnnoptr
[4]; /* ptr to fcn line # */
235 char x_endndx
[4]; /* entry ndx past block end */
237 struct /* if ISARY, up to 4 dimen. */
239 char x_dimen
[E_DIMNUM
][2];
242 char x_tvndx
[2]; /* tv index */
247 char x_fname
[E_FILNMLEN
];
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 */
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)) */
273 #define SYMENT struct external_syment
275 #define AUXENT union external_auxent
278 #define _ETEXT "etext"
280 /********************** RELOCATION DIRECTIVES **********************/
282 struct external_reloc
289 #define RELOC struct external_reloc
293 struct external_reloc
301 #define RELOC struct external_reloc