1 |
106 |
markom |
/* COFF specification for OpenRISC 1000.
|
2 |
|
|
Copyright (C) 1993-2000 Free Software Foundation, Inc.
|
3 |
|
|
Contributed by David Wood @ New York University.
|
4 |
|
|
Modified by Johan Rydberg, <johan.rydberg@netinsight.se>
|
5 |
|
|
|
6 |
|
|
This file is part of BFD, the Binary File Descriptor library.
|
7 |
|
|
|
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.
|
12 |
|
|
|
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.
|
17 |
|
|
|
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. */
|
21 |
|
|
|
22 |
|
|
#ifndef OR32
|
23 |
|
|
# define OR32
|
24 |
|
|
#endif
|
25 |
|
|
|
26 |
|
|
/* File Header and related definitions: */
|
27 |
|
|
struct external_filehdr
|
28 |
|
|
{
|
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 */
|
36 |
|
|
};
|
37 |
|
|
|
38 |
|
|
#define FILHDR struct external_filehdr
|
39 |
|
|
#define FILHSZ 20
|
40 |
|
|
|
41 |
|
|
/* Magic numbers for OpenRISC 1000. As it is know we use the
|
42 |
|
|
numbers for Am29000.
|
43 |
|
|
|
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) */
|
47 |
|
|
|
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))
|
52 |
|
|
|
53 |
|
|
#define OMAGIC OR32_MAGIC_BIG
|
54 |
|
|
|
55 |
|
|
/* Optional (a.out) header: */
|
56 |
|
|
typedef struct external_aouthdr
|
57 |
|
|
{
|
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;
|
67 |
|
|
|
68 |
|
|
#define AOUTSZ 28
|
69 |
|
|
#define AOUTHDRSZ 28
|
70 |
|
|
|
71 |
|
|
/* aouthdr magic numbers */
|
72 |
|
|
#define NMAGIC 0410 /* separate i/d executable */
|
73 |
|
|
#define SHMAGIC 0406 /* NYU/Ultra3 shared data executable
|
74 |
|
|
(writable text) */
|
75 |
|
|
|
76 |
|
|
#define _ETEXT "_etext"
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
/* Section header and related definitions: */
|
80 |
|
|
struct external_scnhdr
|
81 |
|
|
{
|
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 */
|
92 |
|
|
};
|
93 |
|
|
|
94 |
|
|
#define SCNHDR struct external_scnhdr
|
95 |
|
|
#define SCNHSZ 40
|
96 |
|
|
|
97 |
|
|
/* Names of "special" sections: */
|
98 |
|
|
#define _TEXT ".text"
|
99 |
|
|
#define _DATA ".data"
|
100 |
|
|
#define _BSS ".bss"
|
101 |
|
|
#define _LIT ".lit"
|
102 |
|
|
|
103 |
|
|
/* Section types - with additional section type for global
|
104 |
|
|
registers which will be relocatable for the OpenRISC 1000.
|
105 |
|
|
|
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) */
|
114 |
|
|
|
115 |
|
|
/* Relocation information declaration and related definitions: */
|
116 |
|
|
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 */
|
120 |
|
|
};
|
121 |
|
|
|
122 |
|
|
#define RELOC struct external_reloc
|
123 |
|
|
#define RELSZ 10 /* sizeof (RELOC) */
|
124 |
|
|
|
125 |
|
|
/* Relocation types for the OpenRISC 1000: */
|
126 |
|
|
|
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 */
|
137 |
|
|
|
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 */
|
141 |
|
|
|
142 |
|
|
/*
|
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.
|
147 |
|
|
|
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.
|
156 |
|
|
*/
|
157 |
|
|
|
158 |
|
|
/* Line number entry declaration and related definitions: */
|
159 |
|
|
struct external_lineno
|
160 |
|
|
{
|
161 |
|
|
union {
|
162 |
|
|
char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
|
163 |
|
|
char l_paddr[4]; /* (physical) address of line number */
|
164 |
|
|
} l_addr;
|
165 |
|
|
char l_lnno[2]; /* line number */
|
166 |
|
|
};
|
167 |
|
|
|
168 |
|
|
#define LINENO struct external_lineno
|
169 |
|
|
#define LINESZ 6 /* sizeof (LINENO) */
|
170 |
|
|
|
171 |
|
|
/* Symbol entry declaration and related definitions: */
|
172 |
|
|
#define E_SYMNMLEN 8 /* Number of characters in a symbol name */
|
173 |
|
|
|
174 |
|
|
struct external_syment
|
175 |
|
|
{
|
176 |
|
|
union {
|
177 |
|
|
char e_name[E_SYMNMLEN];
|
178 |
|
|
struct {
|
179 |
|
|
char e_zeroes[4];
|
180 |
|
|
char e_offset[4];
|
181 |
|
|
} e;
|
182 |
|
|
} e;
|
183 |
|
|
char e_value[4];
|
184 |
|
|
char e_scnum[2];
|
185 |
|
|
char e_type[2];
|
186 |
|
|
char e_sclass[1];
|
187 |
|
|
char e_numaux[1];
|
188 |
|
|
};
|
189 |
|
|
|
190 |
|
|
#define SYMENT struct external_syment
|
191 |
|
|
#define SYMESZ 18
|
192 |
|
|
|
193 |
|
|
/* Storage class definitions - new classes for global registers: */
|
194 |
|
|
#define C_GLBLREG 19 /* global register */
|
195 |
|
|
#define C_EXTREG 20 /* external global register */
|
196 |
|
|
#define C_DEFREG 21 /* ext. def. of global register */
|
197 |
|
|
|
198 |
|
|
/* Derived symbol mask/shifts: */
|
199 |
|
|
#define N_BTMASK (0xf)
|
200 |
|
|
#define N_BTSHFT (4)
|
201 |
|
|
#define N_TMASK (0x30)
|
202 |
|
|
#define N_TSHIFT (2)
|
203 |
|
|
|
204 |
|
|
/* Auxiliary symbol table entry declaration and related
|
205 |
|
|
definitions. */
|
206 |
|
|
#define E_FILNMLEN 14 /* # characters in a file name */
|
207 |
|
|
#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
|
208 |
|
|
|
209 |
|
|
union external_auxent {
|
210 |
|
|
struct {
|
211 |
|
|
char x_tagndx[4]; /* str, un, or enum tag indx */
|
212 |
|
|
union {
|
213 |
|
|
struct {
|
214 |
|
|
char x_lnno[2]; /* declaration line number */
|
215 |
|
|
char x_size[2]; /* str/union/array size */
|
216 |
|
|
} x_lnsz;
|
217 |
|
|
char x_fsize[4]; /* size of function */
|
218 |
|
|
} x_misc;
|
219 |
|
|
union {
|
220 |
|
|
struct { /* if ISFCN, tag, or .bb */
|
221 |
|
|
char x_lnnoptr[4]; /* ptr to fcn line # */
|
222 |
|
|
char x_endndx[4]; /* entry ndx past block end */
|
223 |
|
|
} x_fcn;
|
224 |
|
|
struct { /* if ISARY, up to 4 dimen. */
|
225 |
|
|
char x_dimen[E_DIMNUM][2];
|
226 |
|
|
} x_ary;
|
227 |
|
|
} x_fcnary;
|
228 |
|
|
char x_tvndx[2]; /* tv index */
|
229 |
|
|
} x_sym;
|
230 |
|
|
|
231 |
|
|
union {
|
232 |
|
|
char x_fname[E_FILNMLEN];
|
233 |
|
|
struct {
|
234 |
|
|
char x_zeroes[4];
|
235 |
|
|
char x_offset[4];
|
236 |
|
|
} x_n;
|
237 |
|
|
} x_file;
|
238 |
|
|
|
239 |
|
|
struct {
|
240 |
|
|
char x_scnlen[4]; /* section length */
|
241 |
|
|
char x_nreloc[2]; /* # relocation entries */
|
242 |
|
|
char x_nlinno[2]; /* # line numbers */
|
243 |
|
|
} x_scn;
|
244 |
|
|
|
245 |
|
|
struct {
|
246 |
|
|
char x_tvfill[4]; /* tv fill value */
|
247 |
|
|
char x_tvlen[2]; /* length of .tv */
|
248 |
|
|
char x_tvran[2][2]; /* tv range */
|
249 |
|
|
} x_tv; /* info about .tv section
|
250 |
|
|
(in auxent of symbol .tv)) */
|
251 |
|
|
};
|
252 |
|
|
|
253 |
|
|
#define AUXENT union external_auxent
|
254 |
|
|
#define AUXESZ 18
|