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