* alpha.c, basic_blocks.c, basic_blocks.h, bb_exit_func.c,
[binutils.git] / include / coff / or32.h
blobc2797aa9029ff30d5a976dd53f775f1e8a347a29
1 /* COFF specification for OpenRISC 1000.
2 Copyright (C) 1993-2000, 2002 Free Software Foundation, Inc.
3 Contributed by David Wood @ New York University.
4 Modified by Johan Rydberg, <johan.rydberg@netinsight.se>
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 #ifndef OR32
23 # define OR32
24 #endif
26 /* File Header and related definitions. */
27 struct external_filehdr
29 char f_magic[2]; /* magic number */
30 char f_nscns[2]; /* number of sections */
31 char f_timdat[4]; /* time & date stamp */
32 char f_symptr[4]; /* file pointer to symtab */
33 char f_nsyms[4]; /* number of symtab entries */
34 char f_opthdr[2]; /* sizeof(optional hdr) */
35 char f_flags[2]; /* flags */
38 #define FILHDR struct external_filehdr
39 #define FILHSZ 20
41 /* Magic numbers for OpenRISC 1000. As it is know we use the
42 numbers for Am29000.
44 (AT&T will assign the "real" magic number). */
45 #define SIPFBOMAGIC 0572 /* Am29000 (Byte 0 is MSB). */
46 #define SIPRBOMAGIC 0573 /* Am29000 (Byte 0 is LSB). */
48 #define OR32_MAGIC_BIG SIPFBOMAGIC
49 #define OR32_MAGIC_LITTLE SIPRBOMAGIC
50 #define OR32BADMAG(x) (((x).f_magic!=OR32_MAGIC_BIG) && \
51 ((x).f_magic!=OR32_MAGIC_LITTLE))
53 #define OMAGIC OR32_MAGIC_BIG
55 /* Optional (a.out) header. */
56 typedef struct external_aouthdr
58 char magic[2]; /* type of file */
59 char vstamp[2]; /* version stamp */
60 char tsize[4]; /* text size in bytes, padded to FW bdry */
61 char dsize[4]; /* initialized data " " */
62 char bsize[4]; /* uninitialized data " " */
63 char entry[4]; /* entry pt. */
64 char text_start[4]; /* base of text used for this file */
65 char data_start[4]; /* base of data used for this file */
66 } AOUTHDR;
68 #define AOUTSZ 28
69 #define AOUTHDRSZ 28
71 /* aouthdr magic numbers. */
72 #define NMAGIC 0410 /* separate i/d executable. */
73 #define SHMAGIC 0406 /* NYU/Ultra3 shared data executable
74 (writable text). */
76 #define _ETEXT "_etext"
78 /* Section header and related definitions. */
79 struct external_scnhdr
81 char s_name[8]; /* section name */
82 char s_paddr[4]; /* physical address, aliased s_nlib */
83 char s_vaddr[4]; /* virtual address */
84 char s_size[4]; /* section size */
85 char s_scnptr[4]; /* file ptr to raw data for section */
86 char s_relptr[4]; /* file ptr to relocation */
87 char s_lnnoptr[4]; /* file ptr to line numbers */
88 char s_nreloc[2]; /* number of relocation entries */
89 char s_nlnno[2]; /* number of line number entries */
90 char s_flags[4]; /* flags */
93 #define SCNHDR struct external_scnhdr
94 #define SCNHSZ 40
96 /* Names of "special" sections: */
97 #define _TEXT ".text"
98 #define _DATA ".data"
99 #define _BSS ".bss"
100 #define _LIT ".lit"
102 /* Section types - with additional section type for global
103 registers which will be relocatable for the OpenRISC 1000.
105 In instances where it is necessary for a linker to produce an
106 output file which contains text or data not based at virtual
107 address 0, e.g. for a ROM, then the linker should accept
108 address base information as command input and use PAD sections
109 to skip over unused addresses. */
110 #define STYP_BSSREG 0x1200 /* Global register area (like STYP_INFO) */
111 #define STYP_ENVIR 0x2200 /* Environment (like STYP_INFO) */
112 #define STYP_ABS 0x4000 /* Absolute (allocated, not reloc, loaded) */
114 /* Relocation information declaration and related definitions: */
115 struct external_reloc
117 char r_vaddr[4]; /* (virtual) address of reference */
118 char r_symndx[4]; /* index into symbol table */
119 char r_type[2]; /* relocation type */
122 #define RELOC struct external_reloc
123 #define RELSZ 10 /* sizeof (RELOC) */
125 /* Relocation types for the OpenRISC 1000: */
127 #define R_ABS 0 /* reference is absolute */
128 #define R_IREL 030 /* instruction relative (jmp/call) */
129 #define R_IABS 031 /* instruction absolute (jmp/call) */
130 #define R_ILOHALF 032 /* instruction low half (const) */
131 #define R_IHIHALF 033 /* instruction high half (consth) part 1 */
132 #define R_IHCONST 034 /* instruction high half (consth) part 2 */
133 /* constant offset of R_IHIHALF relocation */
134 #define R_BYTE 035 /* relocatable byte value */
135 #define R_HWORD 036 /* relocatable halfword value */
136 #define R_WORD 037 /* relocatable word value */
138 #define R_IGLBLRC 040 /* instruction global register RC */
139 #define R_IGLBLRA 041 /* instruction global register RA */
140 #define R_IGLBLRB 042 /* instruction global register RB */
143 NOTE:
144 All the "I" forms refer to 29000 instruction formats. The linker is
145 expected to know how the numeric information is split and/or aligned
146 within the instruction word(s). R_BYTE works for instructions, too.
148 If the parameter to a CONSTH instruction is a relocatable type, two
149 relocation records are written. The first has an r_type of R_IHIHALF
150 (33 octal) and a normal r_vaddr and r_symndx. The second relocation
151 record has an r_type of R_IHCONST (34 octal), a normal r_vaddr (which
152 is redundant), and an r_symndx containing the 32-bit constant offset
153 to the relocation instead of the actual symbol table index. This
154 second record is always written, even if the constant offset is zero.
155 The constant fields of the instruction are set to zero. */
157 /* Line number entry declaration and related definitions: */
158 struct external_lineno
160 union
162 char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
163 char l_paddr[4]; /* (physical) address of line number */
165 l_addr;
167 char l_lnno[2]; /* line number */
170 #define LINENO struct external_lineno
171 #define LINESZ 6 /* sizeof (LINENO) */
173 /* Symbol entry declaration and related definitions: */
174 #define E_SYMNMLEN 8 /* Number of characters in a symbol name */
176 struct external_syment
178 union
180 char e_name[E_SYMNMLEN];
181 struct
183 char e_zeroes[4];
184 char e_offset[4];
190 char e_value[4];
191 char e_scnum[2];
192 char e_type[2];
193 char e_sclass[1];
194 char e_numaux[1];
197 #define SYMENT struct external_syment
198 #define SYMESZ 18
200 /* Storage class definitions - new classes for global registers: */
201 #define C_GLBLREG 19 /* global register */
202 #define C_EXTREG 20 /* external global register */
203 #define C_DEFREG 21 /* ext. def. of global register */
205 /* Derived symbol mask/shifts: */
206 #define N_BTMASK (0xf)
207 #define N_BTSHFT (4)
208 #define N_TMASK (0x30)
209 #define N_TSHIFT (2)
211 /* Auxiliary symbol table entry declaration and related
212 definitions. */
213 #define E_FILNMLEN 14 /* # characters in a file name */
214 #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
216 union external_auxent
218 struct
220 char x_tagndx[4]; /* str, un, or enum tag indx */
221 union
223 struct
225 char x_lnno[2]; /* declaration line number */
226 char x_size[2]; /* str/union/array size */
228 x_lnsz;
230 char x_fsize[4]; /* size of function */
232 x_misc;
234 union
236 struct /* if ISFCN, tag, or .bb */
238 char x_lnnoptr[4]; /* ptr to fcn line # */
239 char x_endndx[4]; /* entry ndx past block end */
241 x_fcn;
243 struct /* if ISARY, up to 4 dimen. */
245 char x_dimen[E_DIMNUM][2];
247 x_ary;
249 x_fcnary;
251 char x_tvndx[2]; /* tv index */
253 x_sym;
255 union
257 char x_fname[E_FILNMLEN];
259 struct
261 char x_zeroes[4];
262 char x_offset[4];
264 x_n;
266 x_file;
268 struct
270 char x_scnlen[4]; /* section length */
271 char x_nreloc[2]; /* # relocation entries */
272 char x_nlinno[2]; /* # line numbers */
274 x_scn;
276 struct
278 char x_tvfill[4]; /* tv fill value */
279 char x_tvlen[2]; /* length of .tv */
280 char x_tvran[2][2]; /* tv range */
282 x_tv; /* info about .tv section
283 (in auxent of symbol .tv)) */
286 #define AUXENT union external_auxent
287 #define AUXESZ 18