1 /* COFF specification for OpenRISC 1000.
2 Copyright (C) 1993-2000, 2002, 2010 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
27 /* File Header and related definitions. */
28 struct external_filehdr
30 char f_magic
[2]; /* magic number */
31 char f_nscns
[2]; /* number of sections */
32 char f_timdat
[4]; /* time & date stamp */
33 char f_symptr
[4]; /* file pointer to symtab */
34 char f_nsyms
[4]; /* number of symtab entries */
35 char f_opthdr
[2]; /* sizeof(optional hdr) */
36 char f_flags
[2]; /* flags */
39 #define FILHDR struct external_filehdr
42 /* Magic numbers for OpenRISC 1000. As it is know we use the
45 (AT&T will assign the "real" magic number). */
46 #define SIPFBOMAGIC 0572 /* Am29000 (Byte 0 is MSB). */
47 #define SIPRBOMAGIC 0573 /* Am29000 (Byte 0 is LSB). */
49 #define OR32_MAGIC_BIG SIPFBOMAGIC
50 #define OR32_MAGIC_LITTLE SIPRBOMAGIC
51 #define OR32BADMAG(x) (((x).f_magic!=OR32_MAGIC_BIG) && \
52 ((x).f_magic!=OR32_MAGIC_LITTLE))
54 #define OMAGIC OR32_MAGIC_BIG
56 /* Optional (a.out) header. */
57 typedef struct external_aouthdr
59 char magic
[2]; /* type of file */
60 char vstamp
[2]; /* version stamp */
61 char tsize
[4]; /* text size in bytes, padded to FW bdry */
62 char dsize
[4]; /* initialized data " " */
63 char bsize
[4]; /* uninitialized data " " */
64 char entry
[4]; /* entry pt. */
65 char text_start
[4]; /* base of text used for this file */
66 char data_start
[4]; /* base of data used for this file */
72 /* aouthdr magic numbers. */
73 #define NMAGIC 0410 /* separate i/d executable. */
74 #define SHMAGIC 0406 /* NYU/Ultra3 shared data executable
77 #define _ETEXT "_etext"
79 /* Section header and related definitions. */
80 struct external_scnhdr
82 char s_name
[8]; /* section name */
83 char s_paddr
[4]; /* physical address, aliased s_nlib */
84 char s_vaddr
[4]; /* virtual address */
85 char s_size
[4]; /* section size */
86 char s_scnptr
[4]; /* file ptr to raw data for section */
87 char s_relptr
[4]; /* file ptr to relocation */
88 char s_lnnoptr
[4]; /* file ptr to line numbers */
89 char s_nreloc
[2]; /* number of relocation entries */
90 char s_nlnno
[2]; /* number of line number entries */
91 char s_flags
[4]; /* flags */
94 #define SCNHDR struct external_scnhdr
97 /* Names of "special" sections: */
103 /* Section types - with additional section type for global
104 registers which will be relocatable for the OpenRISC 1000.
106 In instances where it is necessary for a linker to produce an
107 output file which contains text or data not based at virtual
108 address 0, e.g. for a ROM, then the linker should accept
109 address base information as command input and use PAD sections
110 to skip over unused addresses. */
111 #define STYP_BSSREG 0x1200 /* Global register area (like STYP_INFO) */
112 #define STYP_ENVIR 0x2200 /* Environment (like STYP_INFO) */
113 #define STYP_ABS 0x4000 /* Absolute (allocated, not reloc, loaded) */
115 /* Relocation information declaration and related definitions: */
116 struct external_reloc
118 char r_vaddr
[4]; /* (virtual) address of reference */
119 char r_symndx
[4]; /* index into symbol table */
120 char r_type
[2]; /* relocation type */
123 #define RELOC struct external_reloc
124 #define RELSZ 10 /* sizeof (RELOC) */
126 /* Relocation types for the OpenRISC 1000: */
128 #define R_ABS 0 /* reference is absolute */
129 #define R_IREL 030 /* instruction relative (jmp/call) */
130 #define R_IABS 031 /* instruction absolute (jmp/call) */
131 #define R_ILOHALF 032 /* instruction low half (const) */
132 #define R_IHIHALF 033 /* instruction high half (consth) part 1 */
133 #define R_IHCONST 034 /* instruction high half (consth) part 2 */
134 /* constant offset of R_IHIHALF relocation */
135 #define R_BYTE 035 /* relocatable byte value */
136 #define R_HWORD 036 /* relocatable halfword value */
137 #define R_WORD 037 /* relocatable word value */
139 #define R_IGLBLRC 040 /* instruction global register RC */
140 #define R_IGLBLRA 041 /* instruction global register RA */
141 #define R_IGLBLRB 042 /* instruction global register RB */
145 All the "I" forms refer to 29000 instruction formats. The linker is
146 expected to know how the numeric information is split and/or aligned
147 within the instruction word(s). R_BYTE works for instructions, too.
149 If the parameter to a CONSTH instruction is a relocatable type, two
150 relocation records are written. The first has an r_type of R_IHIHALF
151 (33 octal) and a normal r_vaddr and r_symndx. The second relocation
152 record has an r_type of R_IHCONST (34 octal), a normal r_vaddr (which
153 is redundant), and an r_symndx containing the 32-bit constant offset
154 to the relocation instead of the actual symbol table index. This
155 second record is always written, even if the constant offset is zero.
156 The constant fields of the instruction are set to zero. */
158 /* Line number entry declaration and related definitions: */
159 struct external_lineno
163 char l_symndx
[4]; /* function name symbol index, iff l_lnno == 0*/
164 char l_paddr
[4]; /* (physical) address of line number */
168 char l_lnno
[2]; /* line number */
171 #define LINENO struct external_lineno
172 #define LINESZ 6 /* sizeof (LINENO) */
174 /* Symbol entry declaration and related definitions: */
175 #define E_SYMNMLEN 8 /* Number of characters in a symbol name */
177 struct external_syment
181 char e_name
[E_SYMNMLEN
];
198 #define SYMENT struct external_syment
201 /* Storage class definitions - new classes for global registers: */
202 #define C_GLBLREG 19 /* global register */
203 #define C_EXTREG 20 /* external global register */
204 #define C_DEFREG 21 /* ext. def. of global register */
206 /* Derived symbol mask/shifts: */
207 #define N_BTMASK (0xf)
209 #define N_TMASK (0x30)
212 /* Auxiliary symbol table entry declaration and related
214 #define E_FILNMLEN 14 /* # characters in a file name */
215 #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
217 union external_auxent
221 char x_tagndx
[4]; /* str, un, or enum tag indx */
226 char x_lnno
[2]; /* declaration line number */
227 char x_size
[2]; /* str/union/array size */
231 char x_fsize
[4]; /* size of function */
237 struct /* if ISFCN, tag, or .bb */
239 char x_lnnoptr
[4]; /* ptr to fcn line # */
240 char x_endndx
[4]; /* entry ndx past block end */
244 struct /* if ISARY, up to 4 dimen. */
246 char x_dimen
[E_DIMNUM
][2];
252 char x_tvndx
[2]; /* tv index */
258 char x_fname
[E_FILNMLEN
];
271 char x_scnlen
[4]; /* section length */
272 char x_nreloc
[2]; /* # relocation entries */
273 char x_nlinno
[2]; /* # line numbers */
279 char x_tvfill
[4]; /* tv fill value */
280 char x_tvlen
[2]; /* length of .tv */
281 char x_tvran
[2][2]; /* tv range */
283 x_tv
; /* info about .tv section
284 (in auxent of symbol .tv)) */
287 #define AUXENT union external_auxent