1 |
578 |
markom |
/* `a.out' object-file definitions, including extensions to 64-bit fields
|
2 |
|
|
|
3 |
|
|
Copyright 2001 Free Software Foundation, Inc.
|
4 |
|
|
|
5 |
|
|
This program is free software; you can redistribute it and/or modify
|
6 |
|
|
it under the terms of the GNU General Public License as published by
|
7 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
8 |
|
|
(at your option) any later version.
|
9 |
|
|
|
10 |
|
|
This program is distributed in the hope that it will be useful,
|
11 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
|
|
GNU General Public License for more details.
|
14 |
|
|
|
15 |
|
|
You should have received a copy of the GNU General Public License
|
16 |
|
|
along with this program; if not, write to the Free Software
|
17 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
18 |
|
|
|
19 |
|
|
#ifndef __A_OUT_64_H__
|
20 |
|
|
#define __A_OUT_64_H__
|
21 |
|
|
|
22 |
|
|
/* This is the layout on disk of the 32-bit or 64-bit exec header. */
|
23 |
|
|
|
24 |
|
|
#ifndef external_exec
|
25 |
|
|
struct external_exec
|
26 |
|
|
{
|
27 |
|
|
bfd_byte e_info[4]; /* magic number and stuff */
|
28 |
|
|
bfd_byte e_text[BYTES_IN_WORD]; /* length of text section in bytes */
|
29 |
|
|
bfd_byte e_data[BYTES_IN_WORD]; /* length of data section in bytes */
|
30 |
|
|
bfd_byte e_bss[BYTES_IN_WORD]; /* length of bss area in bytes */
|
31 |
|
|
bfd_byte e_syms[BYTES_IN_WORD]; /* length of symbol table in bytes */
|
32 |
|
|
bfd_byte e_entry[BYTES_IN_WORD]; /* start address */
|
33 |
|
|
bfd_byte e_trsize[BYTES_IN_WORD]; /* length of text relocation info */
|
34 |
|
|
bfd_byte e_drsize[BYTES_IN_WORD]; /* length of data relocation info */
|
35 |
|
|
};
|
36 |
|
|
|
37 |
|
|
#define EXEC_BYTES_SIZE (4 + BYTES_IN_WORD * 7)
|
38 |
|
|
|
39 |
|
|
/* Magic numbers for a.out files */
|
40 |
|
|
|
41 |
|
|
#if ARCH_SIZE==64
|
42 |
|
|
#define OMAGIC 0x1001 /* Code indicating object file */
|
43 |
|
|
#define ZMAGIC 0x1002 /* Code indicating demand-paged executable. */
|
44 |
|
|
#define NMAGIC 0x1003 /* Code indicating pure executable. */
|
45 |
|
|
|
46 |
|
|
/* There is no 64-bit QMAGIC as far as I know. */
|
47 |
|
|
|
48 |
|
|
#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
|
49 |
|
|
&& N_MAGIC(x) != NMAGIC \
|
50 |
|
|
&& N_MAGIC(x) != ZMAGIC)
|
51 |
|
|
#else
|
52 |
|
|
#define OMAGIC 0407 /* ...object file or impure executable. */
|
53 |
|
|
#define NMAGIC 0410 /* Code indicating pure executable. */
|
54 |
|
|
#define ZMAGIC 0413 /* Code indicating demand-paged executable. */
|
55 |
|
|
#define BMAGIC 0415 /* Used by a b.out object. */
|
56 |
|
|
|
57 |
|
|
/* This indicates a demand-paged executable with the header in the text.
|
58 |
|
|
It is used by 386BSD (and variants) and Linux, at least. */
|
59 |
|
|
#ifndef QMAGIC
|
60 |
|
|
#define QMAGIC 0314
|
61 |
|
|
#endif
|
62 |
|
|
# ifndef N_BADMAG
|
63 |
|
|
# define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
|
64 |
|
|
&& N_MAGIC(x) != NMAGIC \
|
65 |
|
|
&& N_MAGIC(x) != ZMAGIC \
|
66 |
|
|
&& N_MAGIC(x) != QMAGIC)
|
67 |
|
|
# endif /* N_BADMAG */
|
68 |
|
|
#endif
|
69 |
|
|
|
70 |
|
|
#endif
|
71 |
|
|
|
72 |
|
|
#ifdef QMAGIC
|
73 |
|
|
#define N_IS_QMAGIC(x) (N_MAGIC (x) == QMAGIC)
|
74 |
|
|
#else
|
75 |
|
|
#define N_IS_QMAGIC(x) (0)
|
76 |
|
|
#endif
|
77 |
|
|
|
78 |
|
|
/* The difference between TARGET_PAGE_SIZE and N_SEGSIZE is that TARGET_PAGE_SIZE is
|
79 |
|
|
the finest granularity at which you can page something, thus it
|
80 |
|
|
controls the padding (if any) before the text segment of a ZMAGIC
|
81 |
|
|
file. N_SEGSIZE is the resolution at which things can be marked as
|
82 |
|
|
read-only versus read/write, so it controls the padding between the
|
83 |
|
|
text segment and the data segment (in memory; on disk the padding
|
84 |
|
|
between them is TARGET_PAGE_SIZE). TARGET_PAGE_SIZE and N_SEGSIZE are the same
|
85 |
|
|
for most machines, but different for sun3. */
|
86 |
|
|
|
87 |
|
|
/* By default, segment size is constant. But some machines override this
|
88 |
|
|
to be a function of the a.out header (e.g. machine type). */
|
89 |
|
|
|
90 |
|
|
#ifndef N_SEGSIZE
|
91 |
|
|
#define N_SEGSIZE(x) SEGMENT_SIZE
|
92 |
|
|
#endif
|
93 |
|
|
|
94 |
|
|
/* Virtual memory address of the text section.
|
95 |
|
|
This is getting very complicated. A good reason to discard a.out format
|
96 |
|
|
for something that specifies these fields explicitly. But til then...
|
97 |
|
|
|
98 |
|
|
* OMAGIC and NMAGIC files:
|
99 |
|
|
(object files: text for "relocatable addr 0" right after the header)
|
100 |
|
|
start at 0, offset is EXEC_BYTES_SIZE, size as stated.
|
101 |
|
|
* The text address, offset, and size of ZMAGIC files depend
|
102 |
|
|
on the entry point of the file:
|
103 |
|
|
* entry point below TEXT_START_ADDR:
|
104 |
|
|
(hack for SunOS shared libraries)
|
105 |
|
|
start at 0, offset is 0, size as stated.
|
106 |
|
|
* If N_HEADER_IN_TEXT(x) is true (which defaults to being the
|
107 |
|
|
case when the entry point is EXEC_BYTES_SIZE or further into a page):
|
108 |
|
|
no padding is needed; text can start after exec header. Sun
|
109 |
|
|
considers the text segment of such files to include the exec header;
|
110 |
|
|
for BFD's purposes, we don't, which makes more work for us.
|
111 |
|
|
start at TEXT_START_ADDR + EXEC_BYTES_SIZE, offset is EXEC_BYTES_SIZE,
|
112 |
|
|
size as stated minus EXEC_BYTES_SIZE.
|
113 |
|
|
* If N_HEADER_IN_TEXT(x) is false (which defaults to being the case when
|
114 |
|
|
the entry point is less than EXEC_BYTES_SIZE into a page (e.g. page
|
115 |
|
|
aligned)): (padding is needed so that text can start at a page boundary)
|
116 |
|
|
start at TEXT_START_ADDR, offset TARGET_PAGE_SIZE, size as stated.
|
117 |
|
|
|
118 |
|
|
Specific configurations may want to hardwire N_HEADER_IN_TEXT,
|
119 |
|
|
for efficiency or to allow people to play games with the entry point.
|
120 |
|
|
In that case, you would #define N_HEADER_IN_TEXT(x) as 1 for sunos,
|
121 |
|
|
and as 0 for most other hosts (Sony News, Vax Ultrix, etc).
|
122 |
|
|
(Do this in the appropriate bfd target file.)
|
123 |
|
|
(The default is a heuristic that will break if people try changing
|
124 |
|
|
the entry point, perhaps with the ld -e flag.)
|
125 |
|
|
|
126 |
|
|
* QMAGIC is always like a ZMAGIC for which N_HEADER_IN_TEXT is true,
|
127 |
|
|
and for which the starting address is TARGET_PAGE_SIZE (or should this be
|
128 |
|
|
SEGMENT_SIZE?) (TEXT_START_ADDR only applies to ZMAGIC, not to QMAGIC).
|
129 |
|
|
*/
|
130 |
|
|
|
131 |
|
|
/* This macro is only relevant for ZMAGIC files; QMAGIC always has the header
|
132 |
|
|
in the text. */
|
133 |
|
|
#ifndef N_HEADER_IN_TEXT
|
134 |
|
|
#define N_HEADER_IN_TEXT(x) (((x).a_entry & (TARGET_PAGE_SIZE-1)) >= EXEC_BYTES_SIZE)
|
135 |
|
|
#endif
|
136 |
|
|
|
137 |
|
|
/* Sun shared libraries, not linux. This macro is only relevant for ZMAGIC
|
138 |
|
|
files. */
|
139 |
|
|
#ifndef N_SHARED_LIB
|
140 |
|
|
#if defined (TEXT_START_ADDR) && TEXT_START_ADDR == 0
|
141 |
|
|
#define N_SHARED_LIB(x) (0)
|
142 |
|
|
#else
|
143 |
|
|
#define N_SHARED_LIB(x) ((x).a_entry < TEXT_START_ADDR)
|
144 |
|
|
#endif
|
145 |
|
|
#endif
|
146 |
|
|
|
147 |
|
|
/* Returning 0 not TEXT_START_ADDR for OMAGIC and NMAGIC is based on
|
148 |
|
|
the assumption that we are dealing with a .o file, not an
|
149 |
|
|
executable. This is necessary for OMAGIC (but means we don't work
|
150 |
|
|
right on the output from ld -N); more questionable for NMAGIC. */
|
151 |
|
|
|
152 |
|
|
#ifndef N_TXTADDR
|
153 |
|
|
#define N_TXTADDR(x) \
|
154 |
|
|
(/* The address of a QMAGIC file is always one page in, */ \
|
155 |
|
|
/* with the header in the text. */ \
|
156 |
|
|
N_IS_QMAGIC (x) ? TARGET_PAGE_SIZE + EXEC_BYTES_SIZE : \
|
157 |
|
|
N_MAGIC(x) != ZMAGIC ? 0 : /* object file or NMAGIC */\
|
158 |
|
|
N_SHARED_LIB(x) ? 0 : \
|
159 |
|
|
N_HEADER_IN_TEXT(x) ? \
|
160 |
|
|
TEXT_START_ADDR + EXEC_BYTES_SIZE : /* no padding */\
|
161 |
|
|
TEXT_START_ADDR /* a page of padding */\
|
162 |
|
|
)
|
163 |
|
|
#endif
|
164 |
|
|
|
165 |
|
|
/* If N_HEADER_IN_TEXT is not true for ZMAGIC, there is some padding
|
166 |
|
|
to make the text segment start at a certain boundary. For most
|
167 |
|
|
systems, this boundary is TARGET_PAGE_SIZE. But for Linux, in the
|
168 |
|
|
time-honored tradition of crazy ZMAGIC hacks, it is 1024 which is
|
169 |
|
|
not what TARGET_PAGE_SIZE needs to be for QMAGIC. */
|
170 |
|
|
|
171 |
|
|
#ifndef ZMAGIC_DISK_BLOCK_SIZE
|
172 |
|
|
#define ZMAGIC_DISK_BLOCK_SIZE TARGET_PAGE_SIZE
|
173 |
|
|
#endif
|
174 |
|
|
|
175 |
|
|
#define N_DISK_BLOCK_SIZE(x) \
|
176 |
|
|
(N_MAGIC(x) == ZMAGIC ? ZMAGIC_DISK_BLOCK_SIZE : TARGET_PAGE_SIZE)
|
177 |
|
|
|
178 |
|
|
/* Offset in an a.out of the start of the text section. */
|
179 |
|
|
#ifndef N_TXTOFF
|
180 |
|
|
#define N_TXTOFF(x) \
|
181 |
|
|
(/* For {O,N,Q}MAGIC, no padding. */ \
|
182 |
|
|
N_MAGIC(x) != ZMAGIC ? EXEC_BYTES_SIZE : \
|
183 |
|
|
N_SHARED_LIB(x) ? 0 : \
|
184 |
|
|
N_HEADER_IN_TEXT(x) ? \
|
185 |
|
|
EXEC_BYTES_SIZE : /* no padding */\
|
186 |
|
|
ZMAGIC_DISK_BLOCK_SIZE /* a page of padding */\
|
187 |
|
|
)
|
188 |
|
|
#endif
|
189 |
|
|
/* Size of the text section. It's always as stated, except that we
|
190 |
|
|
offset it to `undo' the adjustment to N_TXTADDR and N_TXTOFF
|
191 |
|
|
for ZMAGIC files that nominally include the exec header
|
192 |
|
|
as part of the first page of text. (BFD doesn't consider the
|
193 |
|
|
exec header to be part of the text segment.) */
|
194 |
|
|
#ifndef N_TXTSIZE
|
195 |
|
|
#define N_TXTSIZE(x) \
|
196 |
|
|
(/* For QMAGIC, we don't consider the header part of the text section. */\
|
197 |
|
|
N_IS_QMAGIC (x) ? (x).a_text - EXEC_BYTES_SIZE : \
|
198 |
|
|
(N_MAGIC(x) != ZMAGIC || N_SHARED_LIB(x)) ? (x).a_text : \
|
199 |
|
|
N_HEADER_IN_TEXT(x) ? \
|
200 |
|
|
(x).a_text - EXEC_BYTES_SIZE: /* no padding */\
|
201 |
|
|
(x).a_text /* a page of padding */\
|
202 |
|
|
)
|
203 |
|
|
#endif
|
204 |
|
|
/* The address of the data segment in virtual memory.
|
205 |
|
|
It is the text segment address, plus text segment size, rounded
|
206 |
|
|
up to a N_SEGSIZE boundary for pure or pageable files. */
|
207 |
|
|
#ifndef N_DATADDR
|
208 |
|
|
#define N_DATADDR(x) \
|
209 |
|
|
(N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+N_TXTSIZE(x)) \
|
210 |
|
|
: (N_SEGSIZE(x) + ((N_TXTADDR(x)+N_TXTSIZE(x)-1) & ~(N_SEGSIZE(x)-1))))
|
211 |
|
|
#endif
|
212 |
|
|
/* The address of the BSS segment -- immediately after the data segment. */
|
213 |
|
|
|
214 |
|
|
#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
|
215 |
|
|
|
216 |
|
|
/* Offsets of the various portions of the file after the text segment. */
|
217 |
|
|
|
218 |
|
|
/* For {Q,Z}MAGIC, there is padding to make the data segment start on
|
219 |
|
|
a page boundary. Most of the time the a_text field (and thus
|
220 |
|
|
N_TXTSIZE) already contains this padding. It is possible that for
|
221 |
|
|
BSDI and/or 386BSD it sometimes doesn't contain the padding, and
|
222 |
|
|
perhaps we should be adding it here. But this seems kind of
|
223 |
|
|
questionable and probably should be BSDI/386BSD-specific if we do
|
224 |
|
|
do it.
|
225 |
|
|
|
226 |
|
|
For NMAGIC (at least for hp300 BSD, probably others), there is
|
227 |
|
|
padding in memory only, not on disk, so we must *not* ever pad here
|
228 |
|
|
for NMAGIC. */
|
229 |
|
|
|
230 |
|
|
#ifndef N_DATOFF
|
231 |
|
|
#define N_DATOFF(x) \
|
232 |
|
|
(N_TXTOFF(x) + N_TXTSIZE(x))
|
233 |
|
|
#endif
|
234 |
|
|
|
235 |
|
|
#ifndef N_TRELOFF
|
236 |
|
|
#define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data )
|
237 |
|
|
#endif
|
238 |
|
|
#ifndef N_DRELOFF
|
239 |
|
|
#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize )
|
240 |
|
|
#endif
|
241 |
|
|
#ifndef N_SYMOFF
|
242 |
|
|
#define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize )
|
243 |
|
|
#endif
|
244 |
|
|
#ifndef N_STROFF
|
245 |
|
|
#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
|
246 |
|
|
#endif
|
247 |
|
|
|
248 |
|
|
/* Symbols */
|
249 |
|
|
#ifndef external_nlist
|
250 |
|
|
struct external_nlist {
|
251 |
|
|
bfd_byte e_strx[BYTES_IN_WORD]; /* index into string table of name */
|
252 |
|
|
bfd_byte e_type[1]; /* type of symbol */
|
253 |
|
|
bfd_byte e_other[1]; /* misc info (usually empty) */
|
254 |
|
|
bfd_byte e_desc[2]; /* description field */
|
255 |
|
|
bfd_byte e_value[BYTES_IN_WORD]; /* value of symbol */
|
256 |
|
|
};
|
257 |
|
|
#define EXTERNAL_NLIST_SIZE (BYTES_IN_WORD+4+BYTES_IN_WORD)
|
258 |
|
|
#endif
|
259 |
|
|
|
260 |
|
|
struct internal_nlist {
|
261 |
|
|
unsigned long n_strx; /* index into string table of name */
|
262 |
|
|
unsigned char n_type; /* type of symbol */
|
263 |
|
|
unsigned char n_other; /* misc info (usually empty) */
|
264 |
|
|
unsigned short n_desc; /* description field */
|
265 |
|
|
bfd_vma n_value; /* value of symbol */
|
266 |
|
|
};
|
267 |
|
|
|
268 |
|
|
/* The n_type field is the symbol type, containing: */
|
269 |
|
|
|
270 |
|
|
#define N_UNDF 0 /* Undefined symbol */
|
271 |
|
|
#define N_ABS 2 /* Absolute symbol -- defined at particular addr */
|
272 |
|
|
#define N_TEXT 4 /* Text sym -- defined at offset in text seg */
|
273 |
|
|
#define N_DATA 6 /* Data sym -- defined at offset in data seg */
|
274 |
|
|
#define N_BSS 8 /* BSS sym -- defined at offset in zero'd seg */
|
275 |
|
|
#define N_COMM 0x12 /* Common symbol (visible after shared lib dynlink) */
|
276 |
|
|
#define N_FN 0x1f /* File name of .o file */
|
277 |
|
|
#define N_FN_SEQ 0x0C /* N_FN from Sequent compilers (sigh) */
|
278 |
|
|
/* Note: N_EXT can only be usefully OR-ed with N_UNDF, N_ABS, N_TEXT,
|
279 |
|
|
N_DATA, or N_BSS. When the low-order bit of other types is set,
|
280 |
|
|
(e.g. N_WARNING versus N_FN), they are two different types. */
|
281 |
|
|
#define N_EXT 1 /* External symbol (as opposed to local-to-this-file) */
|
282 |
|
|
#define N_TYPE 0x1e
|
283 |
|
|
#define N_STAB 0xe0 /* If any of these bits are on, it's a debug symbol */
|
284 |
|
|
|
285 |
|
|
#define N_INDR 0x0a
|
286 |
|
|
|
287 |
|
|
/* The following symbols refer to set elements.
|
288 |
|
|
All the N_SET[ATDB] symbols with the same name form one set.
|
289 |
|
|
Space is allocated for the set in the text section, and each set
|
290 |
|
|
elements value is stored into one word of the space.
|
291 |
|
|
The first word of the space is the length of the set (number of elements).
|
292 |
|
|
|
293 |
|
|
The address of the set is made into an N_SETV symbol
|
294 |
|
|
whose name is the same as the name of the set.
|
295 |
|
|
This symbol acts like a N_DATA global symbol
|
296 |
|
|
in that it can satisfy undefined external references. */
|
297 |
|
|
|
298 |
|
|
/* These appear as input to LD, in a .o file. */
|
299 |
|
|
#define N_SETA 0x14 /* Absolute set element symbol */
|
300 |
|
|
#define N_SETT 0x16 /* Text set element symbol */
|
301 |
|
|
#define N_SETD 0x18 /* Data set element symbol */
|
302 |
|
|
#define N_SETB 0x1A /* Bss set element symbol */
|
303 |
|
|
|
304 |
|
|
/* This is output from LD. */
|
305 |
|
|
#define N_SETV 0x1C /* Pointer to set vector in data area. */
|
306 |
|
|
|
307 |
|
|
/* Warning symbol. The text gives a warning message, the next symbol
|
308 |
|
|
in the table will be undefined. When the symbol is referenced, the
|
309 |
|
|
message is printed. */
|
310 |
|
|
|
311 |
|
|
#define N_WARNING 0x1e
|
312 |
|
|
|
313 |
|
|
/* Weak symbols. These are a GNU extension to the a.out format. The
|
314 |
|
|
semantics are those of ELF weak symbols. Weak symbols are always
|
315 |
|
|
externally visible. The N_WEAK? values are squeezed into the
|
316 |
|
|
available slots. The value of a N_WEAKU symbol is 0. The values
|
317 |
|
|
of the other types are the definitions. */
|
318 |
|
|
#define N_WEAKU 0x0d /* Weak undefined symbol. */
|
319 |
|
|
#define N_WEAKA 0x0e /* Weak absolute symbol. */
|
320 |
|
|
#define N_WEAKT 0x0f /* Weak text symbol. */
|
321 |
|
|
#define N_WEAKD 0x10 /* Weak data symbol. */
|
322 |
|
|
#define N_WEAKB 0x11 /* Weak bss symbol. */
|
323 |
|
|
|
324 |
|
|
/* Relocations
|
325 |
|
|
|
326 |
|
|
There are two types of relocation flavours for a.out systems,
|
327 |
|
|
standard and extended. The standard form is used on systems where the
|
328 |
|
|
instruction has room for all the bits of an offset to the operand, whilst
|
329 |
|
|
the extended form is used when an address operand has to be split over n
|
330 |
|
|
instructions. Eg, on the 68k, each move instruction can reference
|
331 |
|
|
the target with a displacement of 16 or 32 bits. On the sparc, move
|
332 |
|
|
instructions use an offset of 14 bits, so the offset is stored in
|
333 |
|
|
the reloc field, and the data in the section is ignored.
|
334 |
|
|
*/
|
335 |
|
|
|
336 |
|
|
/* This structure describes a single relocation to be performed.
|
337 |
|
|
The text-relocation section of the file is a vector of these structures,
|
338 |
|
|
all of which apply to the text section.
|
339 |
|
|
Likewise, the data-relocation section applies to the data section. */
|
340 |
|
|
|
341 |
|
|
struct reloc_std_external {
|
342 |
|
|
bfd_byte r_address[BYTES_IN_WORD]; /* offset of of data to relocate */
|
343 |
|
|
bfd_byte r_index[3]; /* symbol table index of symbol */
|
344 |
|
|
bfd_byte r_type[1]; /* relocation type */
|
345 |
|
|
};
|
346 |
|
|
|
347 |
|
|
#define RELOC_STD_BITS_PCREL_BIG ((unsigned int) 0x80)
|
348 |
|
|
#define RELOC_STD_BITS_PCREL_LITTLE ((unsigned int) 0x01)
|
349 |
|
|
|
350 |
|
|
#define RELOC_STD_BITS_LENGTH_BIG ((unsigned int) 0x60)
|
351 |
|
|
#define RELOC_STD_BITS_LENGTH_SH_BIG 5
|
352 |
|
|
#define RELOC_STD_BITS_LENGTH_LITTLE ((unsigned int) 0x06)
|
353 |
|
|
#define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
|
354 |
|
|
|
355 |
|
|
#define RELOC_STD_BITS_EXTERN_BIG ((unsigned int) 0x10)
|
356 |
|
|
#define RELOC_STD_BITS_EXTERN_LITTLE ((unsigned int) 0x08)
|
357 |
|
|
|
358 |
|
|
#define RELOC_STD_BITS_BASEREL_BIG ((unsigned int) 0x08)
|
359 |
|
|
#define RELOC_STD_BITS_BASEREL_LITTLE ((unsigned int) 0x10)
|
360 |
|
|
|
361 |
|
|
#define RELOC_STD_BITS_JMPTABLE_BIG ((unsigned int) 0x04)
|
362 |
|
|
#define RELOC_STD_BITS_JMPTABLE_LITTLE ((unsigned int) 0x20)
|
363 |
|
|
|
364 |
|
|
#define RELOC_STD_BITS_RELATIVE_BIG ((unsigned int) 0x02)
|
365 |
|
|
#define RELOC_STD_BITS_RELATIVE_LITTLE ((unsigned int) 0x40)
|
366 |
|
|
|
367 |
|
|
#define RELOC_STD_SIZE (BYTES_IN_WORD + 3 + 1) /* Bytes per relocation entry */
|
368 |
|
|
|
369 |
|
|
struct reloc_std_internal
|
370 |
|
|
{
|
371 |
|
|
bfd_vma r_address; /* Address (within segment) to be relocated. */
|
372 |
|
|
/* The meaning of r_symbolnum depends on r_extern. */
|
373 |
|
|
unsigned int r_symbolnum:24;
|
374 |
|
|
/* Nonzero means value is a pc-relative offset
|
375 |
|
|
and it should be relocated for changes in its own address
|
376 |
|
|
as well as for changes in the symbol or section specified. */
|
377 |
|
|
unsigned int r_pcrel:1;
|
378 |
|
|
/* Length (as exponent of 2) of the field to be relocated.
|
379 |
|
|
Thus, a value of 2 indicates 1<<2 bytes. */
|
380 |
|
|
unsigned int r_length:2;
|
381 |
|
|
/* 1 => relocate with value of symbol.
|
382 |
|
|
r_symbolnum is the index of the symbol
|
383 |
|
|
in files the symbol table.
|
384 |
|
|
|
385 |
|
|
r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
|
386 |
|
|
(the N_EXT bit may be set also, but signifies nothing). */
|
387 |
|
|
unsigned int r_extern:1;
|
388 |
|
|
/* The next three bits are for SunOS shared libraries, and seem to
|
389 |
|
|
be undocumented. */
|
390 |
|
|
unsigned int r_baserel:1; /* Linkage table relative */
|
391 |
|
|
unsigned int r_jmptable:1; /* pc-relative to jump table */
|
392 |
|
|
unsigned int r_relative:1; /* "relative relocation" */
|
393 |
|
|
/* unused */
|
394 |
|
|
unsigned int r_pad:1; /* Padding -- set to zero */
|
395 |
|
|
};
|
396 |
|
|
|
397 |
|
|
|
398 |
|
|
/* EXTENDED RELOCS */
|
399 |
|
|
|
400 |
|
|
struct reloc_ext_external {
|
401 |
|
|
bfd_byte r_address[BYTES_IN_WORD]; /* offset of of data to relocate */
|
402 |
|
|
bfd_byte r_index[3]; /* symbol table index of symbol */
|
403 |
|
|
bfd_byte r_type[1]; /* relocation type */
|
404 |
|
|
bfd_byte r_addend[BYTES_IN_WORD]; /* datum addend */
|
405 |
|
|
};
|
406 |
|
|
|
407 |
|
|
#ifndef RELOC_EXT_BITS_EXTERN_BIG
|
408 |
|
|
#define RELOC_EXT_BITS_EXTERN_BIG ((unsigned int) 0x80)
|
409 |
|
|
#endif
|
410 |
|
|
|
411 |
|
|
#ifndef RELOC_EXT_BITS_EXTERN_LITTLE
|
412 |
|
|
#define RELOC_EXT_BITS_EXTERN_LITTLE ((unsigned int) 0x01)
|
413 |
|
|
#endif
|
414 |
|
|
|
415 |
|
|
#ifndef RELOC_EXT_BITS_TYPE_BIG
|
416 |
|
|
#define RELOC_EXT_BITS_TYPE_BIG ((unsigned int) 0x1F)
|
417 |
|
|
#endif
|
418 |
|
|
|
419 |
|
|
#ifndef RELOC_EXT_BITS_TYPE_SH_BIG
|
420 |
|
|
#define RELOC_EXT_BITS_TYPE_SH_BIG 0
|
421 |
|
|
#endif
|
422 |
|
|
|
423 |
|
|
#ifndef RELOC_EXT_BITS_TYPE_LITTLE
|
424 |
|
|
#define RELOC_EXT_BITS_TYPE_LITTLE ((unsigned int) 0xF8)
|
425 |
|
|
#endif
|
426 |
|
|
|
427 |
|
|
#ifndef RELOC_EXT_BITS_TYPE_SH_LITTLE
|
428 |
|
|
#define RELOC_EXT_BITS_TYPE_SH_LITTLE 3
|
429 |
|
|
#endif
|
430 |
|
|
|
431 |
|
|
/* Bytes per relocation entry */
|
432 |
|
|
#define RELOC_EXT_SIZE (BYTES_IN_WORD + 3 + 1 + BYTES_IN_WORD)
|
433 |
|
|
|
434 |
|
|
enum reloc_type
|
435 |
|
|
{
|
436 |
|
|
/* simple relocations */
|
437 |
|
|
RELOC_8, /* data[0:7] = addend + sv */
|
438 |
|
|
RELOC_16, /* data[0:15] = addend + sv */
|
439 |
|
|
RELOC_32, /* data[0:31] = addend + sv */
|
440 |
|
|
/* pc-rel displacement */
|
441 |
|
|
RELOC_DISP8, /* data[0:7] = addend - pc + sv */
|
442 |
|
|
RELOC_DISP16, /* data[0:15] = addend - pc + sv */
|
443 |
|
|
RELOC_DISP32, /* data[0:31] = addend - pc + sv */
|
444 |
|
|
/* Special */
|
445 |
|
|
RELOC_WDISP30, /* data[0:29] = (addend + sv - pc)>>2 */
|
446 |
|
|
RELOC_WDISP22, /* data[0:21] = (addend + sv - pc)>>2 */
|
447 |
|
|
RELOC_HI22, /* data[0:21] = (addend + sv)>>10 */
|
448 |
|
|
RELOC_22, /* data[0:21] = (addend + sv) */
|
449 |
|
|
RELOC_13, /* data[0:12] = (addend + sv) */
|
450 |
|
|
RELOC_LO10, /* data[0:9] = (addend + sv) */
|
451 |
|
|
RELOC_SFA_BASE,
|
452 |
|
|
RELOC_SFA_OFF13,
|
453 |
|
|
/* P.I.C. (base-relative) */
|
454 |
|
|
RELOC_BASE10, /* Not sure - maybe we can do this the */
|
455 |
|
|
RELOC_BASE13, /* right way now */
|
456 |
|
|
RELOC_BASE22,
|
457 |
|
|
/* for some sort of pc-rel P.I.C. (?) */
|
458 |
|
|
RELOC_PC10,
|
459 |
|
|
RELOC_PC22,
|
460 |
|
|
/* P.I.C. jump table */
|
461 |
|
|
RELOC_JMP_TBL,
|
462 |
|
|
/* reputedly for shared libraries somehow */
|
463 |
|
|
RELOC_SEGOFF16,
|
464 |
|
|
RELOC_GLOB_DAT,
|
465 |
|
|
RELOC_JMP_SLOT,
|
466 |
|
|
RELOC_RELATIVE,
|
467 |
|
|
|
468 |
|
|
RELOC_11,
|
469 |
|
|
RELOC_WDISP2_14,
|
470 |
|
|
RELOC_WDISP19,
|
471 |
|
|
RELOC_HHI22, /* data[0:21] = (addend + sv) >> 42 */
|
472 |
|
|
RELOC_HLO10, /* data[0:9] = (addend + sv) >> 32 */
|
473 |
|
|
|
474 |
|
|
/* 29K relocation types */
|
475 |
|
|
RELOC_JUMPTARG,
|
476 |
|
|
RELOC_CONST,
|
477 |
|
|
RELOC_CONSTH,
|
478 |
|
|
|
479 |
|
|
/* All the new ones I can think of, for sparc v9 */
|
480 |
|
|
|
481 |
|
|
RELOC_64, /* data[0:63] = addend + sv */
|
482 |
|
|
RELOC_DISP64, /* data[0:63] = addend - pc + sv */
|
483 |
|
|
RELOC_WDISP21, /* data[0:20] = (addend + sv - pc)>>2 */
|
484 |
|
|
RELOC_DISP21, /* data[0:20] = addend - pc + sv */
|
485 |
|
|
RELOC_DISP14, /* data[0:13] = addend - pc + sv */
|
486 |
|
|
/* Q .
|
487 |
|
|
What are the other ones,
|
488 |
|
|
Since this is a clean slate, can we throw away the ones we dont
|
489 |
|
|
understand ? Should we sort the values ? What about using a
|
490 |
|
|
microcode format like the 68k ?
|
491 |
|
|
*/
|
492 |
|
|
NO_RELOC
|
493 |
|
|
};
|
494 |
|
|
|
495 |
|
|
|
496 |
|
|
struct reloc_internal {
|
497 |
|
|
bfd_vma r_address; /* offset of of data to relocate */
|
498 |
|
|
long r_index; /* symbol table index of symbol */
|
499 |
|
|
enum reloc_type r_type; /* relocation type */
|
500 |
|
|
bfd_vma r_addend; /* datum addend */
|
501 |
|
|
};
|
502 |
|
|
|
503 |
|
|
/* Q.
|
504 |
|
|
Should the length of the string table be 4 bytes or 8 bytes ?
|
505 |
|
|
|
506 |
|
|
Q.
|
507 |
|
|
What about archive indexes ?
|
508 |
|
|
|
509 |
|
|
*/
|
510 |
|
|
|
511 |
|
|
#endif /* __A_OUT_64_H__ */
|