]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* BFD support for handling relocation entries. |
5b93d8bb | 2 | Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 |
252b5132 RH |
3 | Free Software Foundation, Inc. |
4 | Written by Cygnus Support. | |
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 | /* | |
23 | SECTION | |
24 | Relocations | |
25 | ||
26 | BFD maintains relocations in much the same way it maintains | |
27 | symbols: they are left alone until required, then read in | |
3f9b03b5 | 28 | en-masse and translated into an internal form. A common |
252b5132 RH |
29 | routine <<bfd_perform_relocation>> acts upon the |
30 | canonical form to do the fixup. | |
31 | ||
32 | Relocations are maintained on a per section basis, | |
33 | while symbols are maintained on a per BFD basis. | |
34 | ||
35 | All that a back end has to do to fit the BFD interface is to create | |
36 | a <<struct reloc_cache_entry>> for each relocation | |
37 | in a particular section, and fill in the right bits of the structures. | |
38 | ||
39 | @menu | |
40 | @* typedef arelent:: | |
41 | @* howto manager:: | |
42 | @end menu | |
43 | ||
44 | */ | |
45 | ||
46 | /* DO compile in the reloc_code name table from libbfd.h. */ | |
47 | #define _BFD_MAKE_TABLE_bfd_reloc_code_real | |
48 | ||
49 | #include "bfd.h" | |
50 | #include "sysdep.h" | |
51 | #include "bfdlink.h" | |
52 | #include "libbfd.h" | |
53 | /* | |
54 | DOCDD | |
55 | INODE | |
56 | typedef arelent, howto manager, Relocations, Relocations | |
57 | ||
58 | SUBSECTION | |
59 | typedef arelent | |
60 | ||
61 | This is the structure of a relocation entry: | |
62 | ||
63 | CODE_FRAGMENT | |
64 | . | |
65 | .typedef enum bfd_reloc_status | |
66 | .{ | |
67 | . {* No errors detected *} | |
68 | . bfd_reloc_ok, | |
69 | . | |
70 | . {* The relocation was performed, but there was an overflow. *} | |
71 | . bfd_reloc_overflow, | |
72 | . | |
73 | . {* The address to relocate was not within the section supplied. *} | |
74 | . bfd_reloc_outofrange, | |
75 | . | |
76 | . {* Used by special functions *} | |
77 | . bfd_reloc_continue, | |
78 | . | |
79 | . {* Unsupported relocation size requested. *} | |
80 | . bfd_reloc_notsupported, | |
81 | . | |
82 | . {* Unused *} | |
83 | . bfd_reloc_other, | |
84 | . | |
85 | . {* The symbol to relocate against was undefined. *} | |
86 | . bfd_reloc_undefined, | |
87 | . | |
88 | . {* The relocation was performed, but may not be ok - presently | |
89 | . generated only when linking i960 coff files with i960 b.out | |
90 | . symbols. If this type is returned, the error_message argument | |
91 | . to bfd_perform_relocation will be set. *} | |
92 | . bfd_reloc_dangerous | |
93 | . } | |
94 | . bfd_reloc_status_type; | |
95 | . | |
96 | . | |
97 | .typedef struct reloc_cache_entry | |
98 | .{ | |
99 | . {* A pointer into the canonical table of pointers *} | |
100 | . struct symbol_cache_entry **sym_ptr_ptr; | |
101 | . | |
102 | . {* offset in section *} | |
103 | . bfd_size_type address; | |
104 | . | |
105 | . {* addend for relocation value *} | |
106 | . bfd_vma addend; | |
107 | . | |
108 | . {* Pointer to how to perform the required relocation *} | |
109 | . reloc_howto_type *howto; | |
110 | . | |
111 | .} arelent; | |
112 | ||
113 | */ | |
114 | ||
115 | /* | |
116 | DESCRIPTION | |
117 | ||
118 | Here is a description of each of the fields within an <<arelent>>: | |
119 | ||
120 | o <<sym_ptr_ptr>> | |
121 | ||
122 | The symbol table pointer points to a pointer to the symbol | |
123 | associated with the relocation request. It is | |
124 | the pointer into the table returned by the back end's | |
125 | <<get_symtab>> action. @xref{Symbols}. The symbol is referenced | |
126 | through a pointer to a pointer so that tools like the linker | |
127 | can fix up all the symbols of the same name by modifying only | |
128 | one pointer. The relocation routine looks in the symbol and | |
129 | uses the base of the section the symbol is attached to and the | |
130 | value of the symbol as the initial relocation offset. If the | |
131 | symbol pointer is zero, then the section provided is looked up. | |
132 | ||
133 | o <<address>> | |
134 | ||
135 | The <<address>> field gives the offset in bytes from the base of | |
136 | the section data which owns the relocation record to the first | |
137 | byte of relocatable information. The actual data relocated | |
138 | will be relative to this point; for example, a relocation | |
139 | type which modifies the bottom two bytes of a four byte word | |
140 | would not touch the first byte pointed to in a big endian | |
141 | world. | |
142 | ||
143 | o <<addend>> | |
144 | ||
145 | The <<addend>> is a value provided by the back end to be added (!) | |
146 | to the relocation offset. Its interpretation is dependent upon | |
147 | the howto. For example, on the 68k the code: | |
148 | ||
252b5132 RH |
149 | | char foo[]; |
150 | | main() | |
151 | | { | |
152 | | return foo[0x12345678]; | |
153 | | } | |
154 | ||
155 | Could be compiled into: | |
156 | ||
157 | | linkw fp,#-4 | |
158 | | moveb @@#12345678,d0 | |
159 | | extbl d0 | |
160 | | unlk fp | |
161 | | rts | |
162 | ||
252b5132 RH |
163 | This could create a reloc pointing to <<foo>>, but leave the |
164 | offset in the data, something like: | |
165 | ||
252b5132 RH |
166 | |RELOCATION RECORDS FOR [.text]: |
167 | |offset type value | |
168 | |00000006 32 _foo | |
169 | | | |
170 | |00000000 4e56 fffc ; linkw fp,#-4 | |
171 | |00000004 1039 1234 5678 ; moveb @@#12345678,d0 | |
172 | |0000000a 49c0 ; extbl d0 | |
173 | |0000000c 4e5e ; unlk fp | |
174 | |0000000e 4e75 ; rts | |
175 | ||
252b5132 RH |
176 | Using coff and an 88k, some instructions don't have enough |
177 | space in them to represent the full address range, and | |
178 | pointers have to be loaded in two parts. So you'd get something like: | |
179 | ||
252b5132 RH |
180 | | or.u r13,r0,hi16(_foo+0x12345678) |
181 | | ld.b r2,r13,lo16(_foo+0x12345678) | |
182 | | jmp r1 | |
183 | ||
252b5132 RH |
184 | This should create two relocs, both pointing to <<_foo>>, and with |
185 | 0x12340000 in their addend field. The data would consist of: | |
186 | ||
252b5132 RH |
187 | |RELOCATION RECORDS FOR [.text]: |
188 | |offset type value | |
189 | |00000002 HVRT16 _foo+0x12340000 | |
190 | |00000006 LVRT16 _foo+0x12340000 | |
191 | | | |
192 | |00000000 5da05678 ; or.u r13,r0,0x5678 | |
193 | |00000004 1c4d5678 ; ld.b r2,r13,0x5678 | |
194 | |00000008 f400c001 ; jmp r1 | |
195 | ||
252b5132 RH |
196 | The relocation routine digs out the value from the data, adds |
197 | it to the addend to get the original offset, and then adds the | |
198 | value of <<_foo>>. Note that all 32 bits have to be kept around | |
199 | somewhere, to cope with carry from bit 15 to bit 16. | |
200 | ||
201 | One further example is the sparc and the a.out format. The | |
202 | sparc has a similar problem to the 88k, in that some | |
203 | instructions don't have room for an entire offset, but on the | |
204 | sparc the parts are created in odd sized lumps. The designers of | |
205 | the a.out format chose to not use the data within the section | |
206 | for storing part of the offset; all the offset is kept within | |
207 | the reloc. Anything in the data should be ignored. | |
208 | ||
209 | | save %sp,-112,%sp | |
210 | | sethi %hi(_foo+0x12345678),%g2 | |
211 | | ldsb [%g2+%lo(_foo+0x12345678)],%i0 | |
212 | | ret | |
213 | | restore | |
214 | ||
215 | Both relocs contain a pointer to <<foo>>, and the offsets | |
216 | contain junk. | |
217 | ||
252b5132 RH |
218 | |RELOCATION RECORDS FOR [.text]: |
219 | |offset type value | |
220 | |00000004 HI22 _foo+0x12345678 | |
221 | |00000008 LO10 _foo+0x12345678 | |
222 | | | |
223 | |00000000 9de3bf90 ; save %sp,-112,%sp | |
224 | |00000004 05000000 ; sethi %hi(_foo+0),%g2 | |
225 | |00000008 f048a000 ; ldsb [%g2+%lo(_foo+0)],%i0 | |
226 | |0000000c 81c7e008 ; ret | |
227 | |00000010 81e80000 ; restore | |
228 | ||
252b5132 RH |
229 | o <<howto>> |
230 | ||
231 | The <<howto>> field can be imagined as a | |
232 | relocation instruction. It is a pointer to a structure which | |
233 | contains information on what to do with all of the other | |
234 | information in the reloc record and data section. A back end | |
235 | would normally have a relocation instruction set and turn | |
236 | relocations into pointers to the correct structure on input - | |
237 | but it would be possible to create each howto field on demand. | |
238 | ||
239 | */ | |
240 | ||
241 | /* | |
242 | SUBSUBSECTION | |
243 | <<enum complain_overflow>> | |
244 | ||
245 | Indicates what sort of overflow checking should be done when | |
246 | performing a relocation. | |
247 | ||
248 | CODE_FRAGMENT | |
249 | . | |
250 | .enum complain_overflow | |
251 | .{ | |
252 | . {* Do not complain on overflow. *} | |
253 | . complain_overflow_dont, | |
254 | . | |
255 | . {* Complain if the bitfield overflows, whether it is considered | |
256 | . as signed or unsigned. *} | |
257 | . complain_overflow_bitfield, | |
258 | . | |
259 | . {* Complain if the value overflows when considered as signed | |
260 | . number. *} | |
261 | . complain_overflow_signed, | |
262 | . | |
263 | . {* Complain if the value overflows when considered as an | |
264 | . unsigned number. *} | |
265 | . complain_overflow_unsigned | |
266 | .}; | |
267 | ||
268 | */ | |
269 | ||
270 | /* | |
271 | SUBSUBSECTION | |
272 | <<reloc_howto_type>> | |
273 | ||
274 | The <<reloc_howto_type>> is a structure which contains all the | |
275 | information that libbfd needs to know to tie up a back end's data. | |
276 | ||
277 | CODE_FRAGMENT | |
278 | .struct symbol_cache_entry; {* Forward declaration *} | |
279 | . | |
280 | .struct reloc_howto_struct | |
281 | .{ | |
282 | . {* The type field has mainly a documentary use - the back end can | |
283 | . do what it wants with it, though normally the back end's | |
284 | . external idea of what a reloc number is stored | |
285 | . in this field. For example, a PC relative word relocation | |
286 | . in a coff environment has the type 023 - because that's | |
287 | . what the outside world calls a R_PCRWORD reloc. *} | |
288 | . unsigned int type; | |
289 | . | |
290 | . {* The value the final relocation is shifted right by. This drops | |
291 | . unwanted data from the relocation. *} | |
292 | . unsigned int rightshift; | |
293 | . | |
294 | . {* The size of the item to be relocated. This is *not* a | |
295 | . power-of-two measure. To get the number of bytes operated | |
296 | . on by a type of relocation, use bfd_get_reloc_size. *} | |
297 | . int size; | |
298 | . | |
299 | . {* The number of bits in the item to be relocated. This is used | |
300 | . when doing overflow checking. *} | |
301 | . unsigned int bitsize; | |
302 | . | |
303 | . {* Notes that the relocation is relative to the location in the | |
304 | . data section of the addend. The relocation function will | |
305 | . subtract from the relocation value the address of the location | |
306 | . being relocated. *} | |
307 | . boolean pc_relative; | |
308 | . | |
309 | . {* The bit position of the reloc value in the destination. | |
310 | . The relocated value is left shifted by this amount. *} | |
311 | . unsigned int bitpos; | |
312 | . | |
313 | . {* What type of overflow error should be checked for when | |
314 | . relocating. *} | |
315 | . enum complain_overflow complain_on_overflow; | |
316 | . | |
317 | . {* If this field is non null, then the supplied function is | |
318 | . called rather than the normal function. This allows really | |
319 | . strange relocation methods to be accomodated (e.g., i960 callj | |
320 | . instructions). *} | |
321 | . bfd_reloc_status_type (*special_function) | |
322 | . PARAMS ((bfd *abfd, | |
323 | . arelent *reloc_entry, | |
324 | . struct symbol_cache_entry *symbol, | |
325 | . PTR data, | |
326 | . asection *input_section, | |
327 | . bfd *output_bfd, | |
328 | . char **error_message)); | |
329 | . | |
330 | . {* The textual name of the relocation type. *} | |
331 | . char *name; | |
332 | . | |
c1b7949f DE |
333 | . {* Some formats record a relocation addend in the section contents |
334 | . rather than with the relocation. For ELF formats this is the | |
335 | . distinction between USE_REL and USE_RELA (though the code checks | |
336 | . for USE_REL == 1/0). The value of this field is TRUE if the | |
337 | . addend is recorded with the section contents; when performing a | |
338 | . partial link (ld -r) the section contents (the data) will be | |
339 | . modified. The value of this field is FALSE if addends are | |
340 | . recorded with the relocation (in arelent.addend); when performing | |
341 | . a partial link the relocation will be modified. | |
342 | . All relocations for all ELF USE_RELA targets should set this field | |
343 | . to FALSE (values of TRUE should be looked on with suspicion). | |
344 | . However, the converse is not true: not all relocations of all ELF | |
345 | . USE_REL targets set this field to TRUE. Why this is so is peculiar | |
346 | . to each particular target. For relocs that aren't used in partial | |
347 | . links (e.g. GOT stuff) it doesn't matter what this is set to. *} | |
252b5132 RH |
348 | . boolean partial_inplace; |
349 | . | |
350 | . {* The src_mask selects which parts of the read in data | |
351 | . are to be used in the relocation sum. E.g., if this was an 8 bit | |
88b6bae0 | 352 | . byte of data which we read and relocated, this would be |
252b5132 RH |
353 | . 0x000000ff. When we have relocs which have an addend, such as |
354 | . sun4 extended relocs, the value in the offset part of a | |
355 | . relocating field is garbage so we never use it. In this case | |
356 | . the mask would be 0x00000000. *} | |
357 | . bfd_vma src_mask; | |
358 | . | |
359 | . {* The dst_mask selects which parts of the instruction are replaced | |
360 | . into the instruction. In most cases src_mask == dst_mask, | |
361 | . except in the above special case, where dst_mask would be | |
362 | . 0x000000ff, and src_mask would be 0x00000000. *} | |
363 | . bfd_vma dst_mask; | |
364 | . | |
365 | . {* When some formats create PC relative instructions, they leave | |
366 | . the value of the pc of the place being relocated in the offset | |
367 | . slot of the instruction, so that a PC relative relocation can | |
368 | . be made just by adding in an ordinary offset (e.g., sun3 a.out). | |
369 | . Some formats leave the displacement part of an instruction | |
370 | . empty (e.g., m88k bcs); this flag signals the fact.*} | |
371 | . boolean pcrel_offset; | |
372 | . | |
373 | .}; | |
374 | ||
375 | */ | |
376 | ||
377 | /* | |
378 | FUNCTION | |
379 | The HOWTO Macro | |
380 | ||
381 | DESCRIPTION | |
382 | The HOWTO define is horrible and will go away. | |
383 | ||
252b5132 RH |
384 | .#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ |
385 | . {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC} | |
386 | ||
387 | DESCRIPTION | |
388 | And will be replaced with the totally magic way. But for the | |
389 | moment, we are compatible, so do it this way. | |
390 | ||
252b5132 RH |
391 | .#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN) |
392 | . | |
5f771d47 ILT |
393 | |
394 | DESCRIPTION | |
395 | This is used to fill in an empty howto entry in an array. | |
396 | ||
397 | .#define EMPTY_HOWTO(C) \ | |
398 | . HOWTO((C),0,0,0,false,0,complain_overflow_dont,NULL,NULL,false,0,0,false) | |
399 | . | |
400 | ||
252b5132 RH |
401 | DESCRIPTION |
402 | Helper routine to turn a symbol into a relocation value. | |
403 | ||
404 | .#define HOWTO_PREPARE(relocation, symbol) \ | |
405 | . { \ | |
406 | . if (symbol != (asymbol *)NULL) { \ | |
407 | . if (bfd_is_com_section (symbol->section)) { \ | |
408 | . relocation = 0; \ | |
409 | . } \ | |
410 | . else { \ | |
411 | . relocation = symbol->value; \ | |
412 | . } \ | |
413 | . } \ | |
414 | .} | |
415 | ||
416 | */ | |
417 | ||
418 | /* | |
419 | FUNCTION | |
420 | bfd_get_reloc_size | |
421 | ||
422 | SYNOPSIS | |
423 | unsigned int bfd_get_reloc_size (reloc_howto_type *); | |
424 | ||
425 | DESCRIPTION | |
426 | For a reloc_howto_type that operates on a fixed number of bytes, | |
427 | this returns the number of bytes operated on. | |
428 | */ | |
429 | ||
430 | unsigned int | |
431 | bfd_get_reloc_size (howto) | |
432 | reloc_howto_type *howto; | |
433 | { | |
434 | switch (howto->size) | |
435 | { | |
436 | case 0: return 1; | |
437 | case 1: return 2; | |
438 | case 2: return 4; | |
439 | case 3: return 0; | |
440 | case 4: return 8; | |
441 | case 8: return 16; | |
442 | case -2: return 4; | |
443 | default: abort (); | |
444 | } | |
445 | } | |
446 | ||
447 | /* | |
448 | TYPEDEF | |
449 | arelent_chain | |
450 | ||
451 | DESCRIPTION | |
452 | ||
453 | How relocs are tied together in an <<asection>>: | |
454 | ||
455 | .typedef struct relent_chain { | |
456 | . arelent relent; | |
457 | . struct relent_chain *next; | |
458 | .} arelent_chain; | |
459 | ||
460 | */ | |
461 | ||
462 | /* N_ONES produces N one bits, without overflowing machine arithmetic. */ | |
463 | #define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1) | |
464 | ||
465 | /* | |
466 | FUNCTION | |
467 | bfd_check_overflow | |
468 | ||
469 | SYNOPSIS | |
470 | bfd_reloc_status_type | |
471 | bfd_check_overflow | |
472 | (enum complain_overflow how, | |
473 | unsigned int bitsize, | |
474 | unsigned int rightshift, | |
475 | unsigned int addrsize, | |
476 | bfd_vma relocation); | |
477 | ||
478 | DESCRIPTION | |
479 | Perform overflow checking on @var{relocation} which has | |
480 | @var{bitsize} significant bits and will be shifted right by | |
481 | @var{rightshift} bits, on a machine with addresses containing | |
482 | @var{addrsize} significant bits. The result is either of | |
483 | @code{bfd_reloc_ok} or @code{bfd_reloc_overflow}. | |
484 | ||
485 | */ | |
486 | ||
487 | bfd_reloc_status_type | |
488 | bfd_check_overflow (how, bitsize, rightshift, addrsize, relocation) | |
489 | enum complain_overflow how; | |
490 | unsigned int bitsize; | |
491 | unsigned int rightshift; | |
492 | unsigned int addrsize; | |
493 | bfd_vma relocation; | |
494 | { | |
495 | bfd_vma fieldmask, addrmask, signmask, ss, a; | |
496 | bfd_reloc_status_type flag = bfd_reloc_ok; | |
497 | ||
498 | a = relocation; | |
499 | ||
500 | /* Note: BITSIZE should always be <= ADDRSIZE, but in case it's not, | |
501 | we'll be permissive: extra bits in the field mask will | |
502 | automatically extend the address mask for purposes of the | |
503 | overflow check. */ | |
504 | fieldmask = N_ONES (bitsize); | |
505 | addrmask = N_ONES (addrsize) | fieldmask; | |
506 | ||
507 | switch (how) | |
508 | { | |
509 | case complain_overflow_dont: | |
510 | break; | |
511 | ||
512 | case complain_overflow_signed: | |
513 | /* If any sign bits are set, all sign bits must be set. That | |
514 | is, A must be a valid negative address after shifting. */ | |
515 | a = (a & addrmask) >> rightshift; | |
516 | signmask = ~ (fieldmask >> 1); | |
517 | ss = a & signmask; | |
518 | if (ss != 0 && ss != ((addrmask >> rightshift) & signmask)) | |
519 | flag = bfd_reloc_overflow; | |
520 | break; | |
521 | ||
522 | case complain_overflow_unsigned: | |
523 | /* We have an overflow if the address does not fit in the field. */ | |
524 | a = (a & addrmask) >> rightshift; | |
525 | if ((a & ~ fieldmask) != 0) | |
526 | flag = bfd_reloc_overflow; | |
527 | break; | |
528 | ||
529 | case complain_overflow_bitfield: | |
530 | /* Bitfields are sometimes signed, sometimes unsigned. We | |
d5afc56e AM |
531 | explicitly allow an address wrap too, which means a bitfield |
532 | of n bits is allowed to store -2**n to 2**n-1. Thus overflow | |
533 | if the value has some, but not all, bits set outside the | |
534 | field. */ | |
252b5132 | 535 | a >>= rightshift; |
d5afc56e AM |
536 | ss = a & ~ fieldmask; |
537 | if (ss != 0 && ss != (((bfd_vma) -1 >> rightshift) & ~ fieldmask)) | |
538 | flag = bfd_reloc_overflow; | |
252b5132 RH |
539 | break; |
540 | ||
541 | default: | |
542 | abort (); | |
543 | } | |
544 | ||
545 | return flag; | |
546 | } | |
547 | ||
548 | /* | |
549 | FUNCTION | |
550 | bfd_perform_relocation | |
551 | ||
552 | SYNOPSIS | |
553 | bfd_reloc_status_type | |
554 | bfd_perform_relocation | |
555 | (bfd *abfd, | |
556 | arelent *reloc_entry, | |
557 | PTR data, | |
558 | asection *input_section, | |
559 | bfd *output_bfd, | |
560 | char **error_message); | |
561 | ||
562 | DESCRIPTION | |
563 | If @var{output_bfd} is supplied to this function, the | |
564 | generated image will be relocatable; the relocations are | |
565 | copied to the output file after they have been changed to | |
566 | reflect the new state of the world. There are two ways of | |
567 | reflecting the results of partial linkage in an output file: | |
568 | by modifying the output data in place, and by modifying the | |
569 | relocation record. Some native formats (e.g., basic a.out and | |
570 | basic coff) have no way of specifying an addend in the | |
571 | relocation type, so the addend has to go in the output data. | |
572 | This is no big deal since in these formats the output data | |
573 | slot will always be big enough for the addend. Complex reloc | |
574 | types with addends were invented to solve just this problem. | |
575 | The @var{error_message} argument is set to an error message if | |
576 | this return @code{bfd_reloc_dangerous}. | |
577 | ||
578 | */ | |
579 | ||
252b5132 RH |
580 | bfd_reloc_status_type |
581 | bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd, | |
582 | error_message) | |
583 | bfd *abfd; | |
584 | arelent *reloc_entry; | |
585 | PTR data; | |
586 | asection *input_section; | |
587 | bfd *output_bfd; | |
588 | char **error_message; | |
589 | { | |
590 | bfd_vma relocation; | |
591 | bfd_reloc_status_type flag = bfd_reloc_ok; | |
9a968f43 | 592 | bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd); |
252b5132 RH |
593 | bfd_vma output_base = 0; |
594 | reloc_howto_type *howto = reloc_entry->howto; | |
595 | asection *reloc_target_output_section; | |
596 | asymbol *symbol; | |
597 | ||
598 | symbol = *(reloc_entry->sym_ptr_ptr); | |
599 | if (bfd_is_abs_section (symbol->section) | |
600 | && output_bfd != (bfd *) NULL) | |
601 | { | |
602 | reloc_entry->address += input_section->output_offset; | |
603 | return bfd_reloc_ok; | |
604 | } | |
605 | ||
606 | /* If we are not producing relocateable output, return an error if | |
607 | the symbol is not defined. An undefined weak symbol is | |
608 | considered to have a value of zero (SVR4 ABI, p. 4-27). */ | |
609 | if (bfd_is_und_section (symbol->section) | |
610 | && (symbol->flags & BSF_WEAK) == 0 | |
611 | && output_bfd == (bfd *) NULL) | |
612 | flag = bfd_reloc_undefined; | |
613 | ||
614 | /* If there is a function supplied to handle this relocation type, | |
615 | call it. It'll return `bfd_reloc_continue' if further processing | |
616 | can be done. */ | |
617 | if (howto->special_function) | |
618 | { | |
619 | bfd_reloc_status_type cont; | |
620 | cont = howto->special_function (abfd, reloc_entry, symbol, data, | |
621 | input_section, output_bfd, | |
622 | error_message); | |
623 | if (cont != bfd_reloc_continue) | |
624 | return cont; | |
625 | } | |
626 | ||
627 | /* Is the address of the relocation really within the section? */ | |
9a968f43 NC |
628 | if (reloc_entry->address > input_section->_cooked_size / |
629 | bfd_octets_per_byte (abfd)) | |
252b5132 RH |
630 | return bfd_reloc_outofrange; |
631 | ||
632 | /* Work out which section the relocation is targetted at and the | |
633 | initial relocation command value. */ | |
634 | ||
635 | /* Get symbol value. (Common symbols are special.) */ | |
636 | if (bfd_is_com_section (symbol->section)) | |
637 | relocation = 0; | |
638 | else | |
639 | relocation = symbol->value; | |
640 | ||
252b5132 RH |
641 | reloc_target_output_section = symbol->section->output_section; |
642 | ||
643 | /* Convert input-section-relative symbol value to absolute. */ | |
644 | if (output_bfd && howto->partial_inplace == false) | |
645 | output_base = 0; | |
646 | else | |
647 | output_base = reloc_target_output_section->vma; | |
648 | ||
649 | relocation += output_base + symbol->section->output_offset; | |
650 | ||
651 | /* Add in supplied addend. */ | |
652 | relocation += reloc_entry->addend; | |
653 | ||
654 | /* Here the variable relocation holds the final address of the | |
655 | symbol we are relocating against, plus any addend. */ | |
656 | ||
657 | if (howto->pc_relative == true) | |
658 | { | |
659 | /* This is a PC relative relocation. We want to set RELOCATION | |
660 | to the distance between the address of the symbol and the | |
661 | location. RELOCATION is already the address of the symbol. | |
662 | ||
663 | We start by subtracting the address of the section containing | |
664 | the location. | |
665 | ||
666 | If pcrel_offset is set, we must further subtract the position | |
667 | of the location within the section. Some targets arrange for | |
668 | the addend to be the negative of the position of the location | |
669 | within the section; for example, i386-aout does this. For | |
670 | i386-aout, pcrel_offset is false. Some other targets do not | |
671 | include the position of the location; for example, m88kbcs, | |
672 | or ELF. For those targets, pcrel_offset is true. | |
673 | ||
674 | If we are producing relocateable output, then we must ensure | |
675 | that this reloc will be correctly computed when the final | |
676 | relocation is done. If pcrel_offset is false we want to wind | |
677 | up with the negative of the location within the section, | |
678 | which means we must adjust the existing addend by the change | |
679 | in the location within the section. If pcrel_offset is true | |
680 | we do not want to adjust the existing addend at all. | |
681 | ||
682 | FIXME: This seems logical to me, but for the case of | |
683 | producing relocateable output it is not what the code | |
684 | actually does. I don't want to change it, because it seems | |
685 | far too likely that something will break. */ | |
686 | ||
687 | relocation -= | |
688 | input_section->output_section->vma + input_section->output_offset; | |
689 | ||
690 | if (howto->pcrel_offset == true) | |
691 | relocation -= reloc_entry->address; | |
692 | } | |
693 | ||
694 | if (output_bfd != (bfd *) NULL) | |
695 | { | |
696 | if (howto->partial_inplace == false) | |
697 | { | |
698 | /* This is a partial relocation, and we want to apply the relocation | |
699 | to the reloc entry rather than the raw data. Modify the reloc | |
700 | inplace to reflect what we now know. */ | |
701 | reloc_entry->addend = relocation; | |
702 | reloc_entry->address += input_section->output_offset; | |
703 | return flag; | |
704 | } | |
705 | else | |
706 | { | |
707 | /* This is a partial relocation, but inplace, so modify the | |
708 | reloc record a bit. | |
709 | ||
710 | If we've relocated with a symbol with a section, change | |
711 | into a ref to the section belonging to the symbol. */ | |
712 | ||
713 | reloc_entry->address += input_section->output_offset; | |
714 | ||
715 | /* WTF?? */ | |
716 | if (abfd->xvec->flavour == bfd_target_coff_flavour | |
252b5132 RH |
717 | && strcmp (abfd->xvec->name, "coff-Intel-little") != 0 |
718 | && strcmp (abfd->xvec->name, "coff-Intel-big") != 0) | |
719 | { | |
720 | #if 1 | |
721 | /* For m68k-coff, the addend was being subtracted twice during | |
722 | relocation with -r. Removing the line below this comment | |
723 | fixes that problem; see PR 2953. | |
724 | ||
725 | However, Ian wrote the following, regarding removing the line below, | |
726 | which explains why it is still enabled: --djm | |
727 | ||
728 | If you put a patch like that into BFD you need to check all the COFF | |
729 | linkers. I am fairly certain that patch will break coff-i386 (e.g., | |
730 | SCO); see coff_i386_reloc in coff-i386.c where I worked around the | |
731 | problem in a different way. There may very well be a reason that the | |
732 | code works as it does. | |
733 | ||
734 | Hmmm. The first obvious point is that bfd_perform_relocation should | |
735 | not have any tests that depend upon the flavour. It's seem like | |
736 | entirely the wrong place for such a thing. The second obvious point | |
737 | is that the current code ignores the reloc addend when producing | |
738 | relocateable output for COFF. That's peculiar. In fact, I really | |
739 | have no idea what the point of the line you want to remove is. | |
740 | ||
741 | A typical COFF reloc subtracts the old value of the symbol and adds in | |
742 | the new value to the location in the object file (if it's a pc | |
743 | relative reloc it adds the difference between the symbol value and the | |
744 | location). When relocating we need to preserve that property. | |
745 | ||
746 | BFD handles this by setting the addend to the negative of the old | |
747 | value of the symbol. Unfortunately it handles common symbols in a | |
748 | non-standard way (it doesn't subtract the old value) but that's a | |
749 | different story (we can't change it without losing backward | |
750 | compatibility with old object files) (coff-i386 does subtract the old | |
751 | value, to be compatible with existing coff-i386 targets, like SCO). | |
752 | ||
753 | So everything works fine when not producing relocateable output. When | |
754 | we are producing relocateable output, logically we should do exactly | |
755 | what we do when not producing relocateable output. Therefore, your | |
756 | patch is correct. In fact, it should probably always just set | |
757 | reloc_entry->addend to 0 for all cases, since it is, in fact, going to | |
758 | add the value into the object file. This won't hurt the COFF code, | |
759 | which doesn't use the addend; I'm not sure what it will do to other | |
760 | formats (the thing to check for would be whether any formats both use | |
761 | the addend and set partial_inplace). | |
762 | ||
763 | When I wanted to make coff-i386 produce relocateable output, I ran | |
764 | into the problem that you are running into: I wanted to remove that | |
765 | line. Rather than risk it, I made the coff-i386 relocs use a special | |
766 | function; it's coff_i386_reloc in coff-i386.c. The function | |
767 | specifically adds the addend field into the object file, knowing that | |
768 | bfd_perform_relocation is not going to. If you remove that line, then | |
769 | coff-i386.c will wind up adding the addend field in twice. It's | |
770 | trivial to fix; it just needs to be done. | |
771 | ||
772 | The problem with removing the line is just that it may break some | |
773 | working code. With BFD it's hard to be sure of anything. The right | |
774 | way to deal with this is simply to build and test at least all the | |
775 | supported COFF targets. It should be straightforward if time and disk | |
776 | space consuming. For each target: | |
777 | 1) build the linker | |
778 | 2) generate some executable, and link it using -r (I would | |
779 | probably use paranoia.o and link against newlib/libc.a, which | |
780 | for all the supported targets would be available in | |
781 | /usr/cygnus/progressive/H-host/target/lib/libc.a). | |
782 | 3) make the change to reloc.c | |
783 | 4) rebuild the linker | |
784 | 5) repeat step 2 | |
785 | 6) if the resulting object files are the same, you have at least | |
786 | made it no worse | |
787 | 7) if they are different you have to figure out which version is | |
788 | right | |
789 | */ | |
790 | relocation -= reloc_entry->addend; | |
791 | #endif | |
792 | reloc_entry->addend = 0; | |
793 | } | |
794 | else | |
795 | { | |
796 | reloc_entry->addend = relocation; | |
797 | } | |
798 | } | |
799 | } | |
800 | else | |
801 | { | |
802 | reloc_entry->addend = 0; | |
803 | } | |
804 | ||
805 | /* FIXME: This overflow checking is incomplete, because the value | |
806 | might have overflowed before we get here. For a correct check we | |
807 | need to compute the value in a size larger than bitsize, but we | |
808 | can't reasonably do that for a reloc the same size as a host | |
809 | machine word. | |
810 | FIXME: We should also do overflow checking on the result after | |
811 | adding in the value contained in the object file. */ | |
812 | if (howto->complain_on_overflow != complain_overflow_dont | |
813 | && flag == bfd_reloc_ok) | |
814 | flag = bfd_check_overflow (howto->complain_on_overflow, | |
815 | howto->bitsize, | |
816 | howto->rightshift, | |
817 | bfd_arch_bits_per_address (abfd), | |
818 | relocation); | |
819 | ||
820 | /* | |
821 | Either we are relocating all the way, or we don't want to apply | |
822 | the relocation to the reloc entry (probably because there isn't | |
823 | any room in the output format to describe addends to relocs) | |
824 | */ | |
825 | ||
826 | /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler | |
827 | (OSF version 1.3, compiler version 3.11). It miscompiles the | |
828 | following program: | |
829 | ||
830 | struct str | |
831 | { | |
832 | unsigned int i0; | |
833 | } s = { 0 }; | |
834 | ||
835 | int | |
836 | main () | |
837 | { | |
838 | unsigned long x; | |
839 | ||
840 | x = 0x100000000; | |
841 | x <<= (unsigned long) s.i0; | |
842 | if (x == 0) | |
843 | printf ("failed\n"); | |
844 | else | |
845 | printf ("succeeded (%lx)\n", x); | |
846 | } | |
847 | */ | |
848 | ||
849 | relocation >>= (bfd_vma) howto->rightshift; | |
850 | ||
851 | /* Shift everything up to where it's going to be used */ | |
852 | ||
853 | relocation <<= (bfd_vma) howto->bitpos; | |
854 | ||
855 | /* Wait for the day when all have the mask in them */ | |
856 | ||
857 | /* What we do: | |
858 | i instruction to be left alone | |
859 | o offset within instruction | |
860 | r relocation offset to apply | |
861 | S src mask | |
862 | D dst mask | |
863 | N ~dst mask | |
864 | A part 1 | |
865 | B part 2 | |
866 | R result | |
867 | ||
868 | Do this: | |
88b6bae0 AM |
869 | (( i i i i i o o o o o from bfd_get<size> |
870 | and S S S S S) to get the size offset we want | |
871 | + r r r r r r r r r r) to get the final value to place | |
252b5132 RH |
872 | and D D D D D to chop to right size |
873 | ----------------------- | |
88b6bae0 | 874 | = A A A A A |
252b5132 | 875 | And this: |
88b6bae0 AM |
876 | ( i i i i i o o o o o from bfd_get<size> |
877 | and N N N N N ) get instruction | |
252b5132 | 878 | ----------------------- |
88b6bae0 | 879 | = B B B B B |
252b5132 RH |
880 | |
881 | And then: | |
88b6bae0 AM |
882 | ( B B B B B |
883 | or A A A A A) | |
252b5132 | 884 | ----------------------- |
88b6bae0 | 885 | = R R R R R R R R R R put into bfd_put<size> |
252b5132 RH |
886 | */ |
887 | ||
888 | #define DOIT(x) \ | |
889 | x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask)) | |
890 | ||
891 | switch (howto->size) | |
892 | { | |
893 | case 0: | |
894 | { | |
9a968f43 | 895 | char x = bfd_get_8 (abfd, (char *) data + octets); |
252b5132 | 896 | DOIT (x); |
9a968f43 | 897 | bfd_put_8 (abfd, x, (unsigned char *) data + octets); |
252b5132 RH |
898 | } |
899 | break; | |
900 | ||
901 | case 1: | |
902 | { | |
9a968f43 | 903 | short x = bfd_get_16 (abfd, (bfd_byte *) data + octets); |
252b5132 | 904 | DOIT (x); |
9a968f43 | 905 | bfd_put_16 (abfd, x, (unsigned char *) data + octets); |
252b5132 RH |
906 | } |
907 | break; | |
908 | case 2: | |
909 | { | |
9a968f43 | 910 | long x = bfd_get_32 (abfd, (bfd_byte *) data + octets); |
252b5132 | 911 | DOIT (x); |
9a968f43 | 912 | bfd_put_32 (abfd, x, (bfd_byte *) data + octets); |
252b5132 RH |
913 | } |
914 | break; | |
915 | case -2: | |
916 | { | |
9a968f43 | 917 | long x = bfd_get_32 (abfd, (bfd_byte *) data + octets); |
252b5132 RH |
918 | relocation = -relocation; |
919 | DOIT (x); | |
9a968f43 | 920 | bfd_put_32 (abfd, x, (bfd_byte *) data + octets); |
252b5132 RH |
921 | } |
922 | break; | |
923 | ||
924 | case -1: | |
925 | { | |
9a968f43 | 926 | long x = bfd_get_16 (abfd, (bfd_byte *) data + octets); |
252b5132 RH |
927 | relocation = -relocation; |
928 | DOIT (x); | |
9a968f43 | 929 | bfd_put_16 (abfd, x, (bfd_byte *) data + octets); |
252b5132 RH |
930 | } |
931 | break; | |
932 | ||
933 | case 3: | |
934 | /* Do nothing */ | |
935 | break; | |
936 | ||
937 | case 4: | |
938 | #ifdef BFD64 | |
939 | { | |
9a968f43 | 940 | bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data + octets); |
252b5132 | 941 | DOIT (x); |
9a968f43 | 942 | bfd_put_64 (abfd, x, (bfd_byte *) data + octets); |
252b5132 RH |
943 | } |
944 | #else | |
945 | abort (); | |
946 | #endif | |
947 | break; | |
948 | default: | |
949 | return bfd_reloc_other; | |
950 | } | |
951 | ||
952 | return flag; | |
953 | } | |
954 | ||
955 | /* | |
956 | FUNCTION | |
957 | bfd_install_relocation | |
958 | ||
959 | SYNOPSIS | |
960 | bfd_reloc_status_type | |
961 | bfd_install_relocation | |
962 | (bfd *abfd, | |
963 | arelent *reloc_entry, | |
964 | PTR data, bfd_vma data_start, | |
965 | asection *input_section, | |
966 | char **error_message); | |
967 | ||
968 | DESCRIPTION | |
969 | This looks remarkably like <<bfd_perform_relocation>>, except it | |
970 | does not expect that the section contents have been filled in. | |
971 | I.e., it's suitable for use when creating, rather than applying | |
972 | a relocation. | |
973 | ||
974 | For now, this function should be considered reserved for the | |
975 | assembler. | |
976 | ||
977 | */ | |
978 | ||
252b5132 RH |
979 | bfd_reloc_status_type |
980 | bfd_install_relocation (abfd, reloc_entry, data_start, data_start_offset, | |
981 | input_section, error_message) | |
982 | bfd *abfd; | |
983 | arelent *reloc_entry; | |
984 | PTR data_start; | |
985 | bfd_vma data_start_offset; | |
986 | asection *input_section; | |
987 | char **error_message; | |
988 | { | |
989 | bfd_vma relocation; | |
990 | bfd_reloc_status_type flag = bfd_reloc_ok; | |
9a968f43 | 991 | bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd); |
252b5132 RH |
992 | bfd_vma output_base = 0; |
993 | reloc_howto_type *howto = reloc_entry->howto; | |
994 | asection *reloc_target_output_section; | |
995 | asymbol *symbol; | |
996 | bfd_byte *data; | |
997 | ||
998 | symbol = *(reloc_entry->sym_ptr_ptr); | |
999 | if (bfd_is_abs_section (symbol->section)) | |
1000 | { | |
1001 | reloc_entry->address += input_section->output_offset; | |
1002 | return bfd_reloc_ok; | |
1003 | } | |
1004 | ||
1005 | /* If there is a function supplied to handle this relocation type, | |
1006 | call it. It'll return `bfd_reloc_continue' if further processing | |
1007 | can be done. */ | |
1008 | if (howto->special_function) | |
1009 | { | |
1010 | bfd_reloc_status_type cont; | |
88b6bae0 | 1011 | |
252b5132 RH |
1012 | /* XXX - The special_function calls haven't been fixed up to deal |
1013 | with creating new relocations and section contents. */ | |
1014 | cont = howto->special_function (abfd, reloc_entry, symbol, | |
1015 | /* XXX - Non-portable! */ | |
1016 | ((bfd_byte *) data_start | |
1017 | - data_start_offset), | |
1018 | input_section, abfd, error_message); | |
1019 | if (cont != bfd_reloc_continue) | |
1020 | return cont; | |
1021 | } | |
1022 | ||
1023 | /* Is the address of the relocation really within the section? */ | |
1024 | if (reloc_entry->address > input_section->_cooked_size) | |
1025 | return bfd_reloc_outofrange; | |
1026 | ||
1027 | /* Work out which section the relocation is targetted at and the | |
1028 | initial relocation command value. */ | |
1029 | ||
1030 | /* Get symbol value. (Common symbols are special.) */ | |
1031 | if (bfd_is_com_section (symbol->section)) | |
1032 | relocation = 0; | |
1033 | else | |
1034 | relocation = symbol->value; | |
1035 | ||
1036 | reloc_target_output_section = symbol->section->output_section; | |
1037 | ||
1038 | /* Convert input-section-relative symbol value to absolute. */ | |
1039 | if (howto->partial_inplace == false) | |
1040 | output_base = 0; | |
1041 | else | |
1042 | output_base = reloc_target_output_section->vma; | |
1043 | ||
1044 | relocation += output_base + symbol->section->output_offset; | |
1045 | ||
1046 | /* Add in supplied addend. */ | |
1047 | relocation += reloc_entry->addend; | |
1048 | ||
1049 | /* Here the variable relocation holds the final address of the | |
1050 | symbol we are relocating against, plus any addend. */ | |
1051 | ||
1052 | if (howto->pc_relative == true) | |
1053 | { | |
1054 | /* This is a PC relative relocation. We want to set RELOCATION | |
1055 | to the distance between the address of the symbol and the | |
1056 | location. RELOCATION is already the address of the symbol. | |
1057 | ||
1058 | We start by subtracting the address of the section containing | |
1059 | the location. | |
1060 | ||
1061 | If pcrel_offset is set, we must further subtract the position | |
1062 | of the location within the section. Some targets arrange for | |
1063 | the addend to be the negative of the position of the location | |
1064 | within the section; for example, i386-aout does this. For | |
1065 | i386-aout, pcrel_offset is false. Some other targets do not | |
1066 | include the position of the location; for example, m88kbcs, | |
1067 | or ELF. For those targets, pcrel_offset is true. | |
1068 | ||
1069 | If we are producing relocateable output, then we must ensure | |
1070 | that this reloc will be correctly computed when the final | |
1071 | relocation is done. If pcrel_offset is false we want to wind | |
1072 | up with the negative of the location within the section, | |
1073 | which means we must adjust the existing addend by the change | |
1074 | in the location within the section. If pcrel_offset is true | |
1075 | we do not want to adjust the existing addend at all. | |
1076 | ||
1077 | FIXME: This seems logical to me, but for the case of | |
1078 | producing relocateable output it is not what the code | |
1079 | actually does. I don't want to change it, because it seems | |
1080 | far too likely that something will break. */ | |
1081 | ||
1082 | relocation -= | |
1083 | input_section->output_section->vma + input_section->output_offset; | |
1084 | ||
1085 | if (howto->pcrel_offset == true && howto->partial_inplace == true) | |
1086 | relocation -= reloc_entry->address; | |
1087 | } | |
1088 | ||
1089 | if (howto->partial_inplace == false) | |
1090 | { | |
1091 | /* This is a partial relocation, and we want to apply the relocation | |
1092 | to the reloc entry rather than the raw data. Modify the reloc | |
1093 | inplace to reflect what we now know. */ | |
1094 | reloc_entry->addend = relocation; | |
1095 | reloc_entry->address += input_section->output_offset; | |
1096 | return flag; | |
1097 | } | |
1098 | else | |
1099 | { | |
1100 | /* This is a partial relocation, but inplace, so modify the | |
1101 | reloc record a bit. | |
1102 | ||
1103 | If we've relocated with a symbol with a section, change | |
1104 | into a ref to the section belonging to the symbol. */ | |
1105 | ||
1106 | reloc_entry->address += input_section->output_offset; | |
1107 | ||
1108 | /* WTF?? */ | |
1109 | if (abfd->xvec->flavour == bfd_target_coff_flavour | |
252b5132 RH |
1110 | && strcmp (abfd->xvec->name, "coff-Intel-little") != 0 |
1111 | && strcmp (abfd->xvec->name, "coff-Intel-big") != 0) | |
1112 | { | |
1113 | #if 1 | |
1114 | /* For m68k-coff, the addend was being subtracted twice during | |
1115 | relocation with -r. Removing the line below this comment | |
1116 | fixes that problem; see PR 2953. | |
1117 | ||
1118 | However, Ian wrote the following, regarding removing the line below, | |
1119 | which explains why it is still enabled: --djm | |
1120 | ||
1121 | If you put a patch like that into BFD you need to check all the COFF | |
1122 | linkers. I am fairly certain that patch will break coff-i386 (e.g., | |
1123 | SCO); see coff_i386_reloc in coff-i386.c where I worked around the | |
1124 | problem in a different way. There may very well be a reason that the | |
1125 | code works as it does. | |
1126 | ||
1127 | Hmmm. The first obvious point is that bfd_install_relocation should | |
1128 | not have any tests that depend upon the flavour. It's seem like | |
1129 | entirely the wrong place for such a thing. The second obvious point | |
1130 | is that the current code ignores the reloc addend when producing | |
1131 | relocateable output for COFF. That's peculiar. In fact, I really | |
1132 | have no idea what the point of the line you want to remove is. | |
1133 | ||
1134 | A typical COFF reloc subtracts the old value of the symbol and adds in | |
1135 | the new value to the location in the object file (if it's a pc | |
1136 | relative reloc it adds the difference between the symbol value and the | |
1137 | location). When relocating we need to preserve that property. | |
1138 | ||
1139 | BFD handles this by setting the addend to the negative of the old | |
1140 | value of the symbol. Unfortunately it handles common symbols in a | |
1141 | non-standard way (it doesn't subtract the old value) but that's a | |
1142 | different story (we can't change it without losing backward | |
1143 | compatibility with old object files) (coff-i386 does subtract the old | |
1144 | value, to be compatible with existing coff-i386 targets, like SCO). | |
1145 | ||
1146 | So everything works fine when not producing relocateable output. When | |
1147 | we are producing relocateable output, logically we should do exactly | |
1148 | what we do when not producing relocateable output. Therefore, your | |
1149 | patch is correct. In fact, it should probably always just set | |
1150 | reloc_entry->addend to 0 for all cases, since it is, in fact, going to | |
1151 | add the value into the object file. This won't hurt the COFF code, | |
1152 | which doesn't use the addend; I'm not sure what it will do to other | |
1153 | formats (the thing to check for would be whether any formats both use | |
1154 | the addend and set partial_inplace). | |
1155 | ||
1156 | When I wanted to make coff-i386 produce relocateable output, I ran | |
1157 | into the problem that you are running into: I wanted to remove that | |
1158 | line. Rather than risk it, I made the coff-i386 relocs use a special | |
1159 | function; it's coff_i386_reloc in coff-i386.c. The function | |
1160 | specifically adds the addend field into the object file, knowing that | |
1161 | bfd_install_relocation is not going to. If you remove that line, then | |
1162 | coff-i386.c will wind up adding the addend field in twice. It's | |
1163 | trivial to fix; it just needs to be done. | |
1164 | ||
1165 | The problem with removing the line is just that it may break some | |
1166 | working code. With BFD it's hard to be sure of anything. The right | |
1167 | way to deal with this is simply to build and test at least all the | |
1168 | supported COFF targets. It should be straightforward if time and disk | |
1169 | space consuming. For each target: | |
1170 | 1) build the linker | |
1171 | 2) generate some executable, and link it using -r (I would | |
1172 | probably use paranoia.o and link against newlib/libc.a, which | |
1173 | for all the supported targets would be available in | |
1174 | /usr/cygnus/progressive/H-host/target/lib/libc.a). | |
1175 | 3) make the change to reloc.c | |
1176 | 4) rebuild the linker | |
1177 | 5) repeat step 2 | |
1178 | 6) if the resulting object files are the same, you have at least | |
1179 | made it no worse | |
1180 | 7) if they are different you have to figure out which version is | |
1181 | right | |
1182 | */ | |
1183 | relocation -= reloc_entry->addend; | |
1184 | #endif | |
1185 | reloc_entry->addend = 0; | |
1186 | } | |
1187 | else | |
1188 | { | |
1189 | reloc_entry->addend = relocation; | |
1190 | } | |
1191 | } | |
1192 | ||
1193 | /* FIXME: This overflow checking is incomplete, because the value | |
1194 | might have overflowed before we get here. For a correct check we | |
1195 | need to compute the value in a size larger than bitsize, but we | |
1196 | can't reasonably do that for a reloc the same size as a host | |
1197 | machine word. | |
1198 | FIXME: We should also do overflow checking on the result after | |
1199 | adding in the value contained in the object file. */ | |
1200 | if (howto->complain_on_overflow != complain_overflow_dont) | |
1201 | flag = bfd_check_overflow (howto->complain_on_overflow, | |
1202 | howto->bitsize, | |
1203 | howto->rightshift, | |
1204 | bfd_arch_bits_per_address (abfd), | |
1205 | relocation); | |
1206 | ||
1207 | /* | |
1208 | Either we are relocating all the way, or we don't want to apply | |
1209 | the relocation to the reloc entry (probably because there isn't | |
1210 | any room in the output format to describe addends to relocs) | |
1211 | */ | |
1212 | ||
1213 | /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler | |
1214 | (OSF version 1.3, compiler version 3.11). It miscompiles the | |
1215 | following program: | |
1216 | ||
1217 | struct str | |
1218 | { | |
1219 | unsigned int i0; | |
1220 | } s = { 0 }; | |
1221 | ||
1222 | int | |
1223 | main () | |
1224 | { | |
1225 | unsigned long x; | |
1226 | ||
1227 | x = 0x100000000; | |
1228 | x <<= (unsigned long) s.i0; | |
1229 | if (x == 0) | |
1230 | printf ("failed\n"); | |
1231 | else | |
1232 | printf ("succeeded (%lx)\n", x); | |
1233 | } | |
1234 | */ | |
1235 | ||
1236 | relocation >>= (bfd_vma) howto->rightshift; | |
1237 | ||
1238 | /* Shift everything up to where it's going to be used */ | |
1239 | ||
1240 | relocation <<= (bfd_vma) howto->bitpos; | |
1241 | ||
1242 | /* Wait for the day when all have the mask in them */ | |
1243 | ||
1244 | /* What we do: | |
1245 | i instruction to be left alone | |
1246 | o offset within instruction | |
1247 | r relocation offset to apply | |
1248 | S src mask | |
1249 | D dst mask | |
1250 | N ~dst mask | |
1251 | A part 1 | |
1252 | B part 2 | |
1253 | R result | |
1254 | ||
1255 | Do this: | |
88b6bae0 AM |
1256 | (( i i i i i o o o o o from bfd_get<size> |
1257 | and S S S S S) to get the size offset we want | |
1258 | + r r r r r r r r r r) to get the final value to place | |
252b5132 RH |
1259 | and D D D D D to chop to right size |
1260 | ----------------------- | |
88b6bae0 | 1261 | = A A A A A |
252b5132 | 1262 | And this: |
88b6bae0 AM |
1263 | ( i i i i i o o o o o from bfd_get<size> |
1264 | and N N N N N ) get instruction | |
252b5132 | 1265 | ----------------------- |
88b6bae0 | 1266 | = B B B B B |
252b5132 RH |
1267 | |
1268 | And then: | |
88b6bae0 AM |
1269 | ( B B B B B |
1270 | or A A A A A) | |
252b5132 | 1271 | ----------------------- |
88b6bae0 | 1272 | = R R R R R R R R R R put into bfd_put<size> |
252b5132 RH |
1273 | */ |
1274 | ||
1275 | #define DOIT(x) \ | |
1276 | x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask)) | |
1277 | ||
9a968f43 | 1278 | data = (bfd_byte *) data_start + (octets - data_start_offset); |
252b5132 RH |
1279 | |
1280 | switch (howto->size) | |
1281 | { | |
1282 | case 0: | |
1283 | { | |
1284 | char x = bfd_get_8 (abfd, (char *) data); | |
1285 | DOIT (x); | |
1286 | bfd_put_8 (abfd, x, (unsigned char *) data); | |
1287 | } | |
1288 | break; | |
1289 | ||
1290 | case 1: | |
1291 | { | |
1292 | short x = bfd_get_16 (abfd, (bfd_byte *) data); | |
1293 | DOIT (x); | |
1294 | bfd_put_16 (abfd, x, (unsigned char *) data); | |
1295 | } | |
1296 | break; | |
1297 | case 2: | |
1298 | { | |
1299 | long x = bfd_get_32 (abfd, (bfd_byte *) data); | |
1300 | DOIT (x); | |
1301 | bfd_put_32 (abfd, x, (bfd_byte *) data); | |
1302 | } | |
1303 | break; | |
1304 | case -2: | |
1305 | { | |
1306 | long x = bfd_get_32 (abfd, (bfd_byte *) data); | |
1307 | relocation = -relocation; | |
1308 | DOIT (x); | |
1309 | bfd_put_32 (abfd, x, (bfd_byte *) data); | |
1310 | } | |
1311 | break; | |
1312 | ||
1313 | case 3: | |
1314 | /* Do nothing */ | |
1315 | break; | |
1316 | ||
1317 | case 4: | |
1318 | { | |
1319 | bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data); | |
1320 | DOIT (x); | |
1321 | bfd_put_64 (abfd, x, (bfd_byte *) data); | |
1322 | } | |
1323 | break; | |
1324 | default: | |
1325 | return bfd_reloc_other; | |
1326 | } | |
1327 | ||
1328 | return flag; | |
1329 | } | |
1330 | ||
1331 | /* This relocation routine is used by some of the backend linkers. | |
1332 | They do not construct asymbol or arelent structures, so there is no | |
1333 | reason for them to use bfd_perform_relocation. Also, | |
1334 | bfd_perform_relocation is so hacked up it is easier to write a new | |
1335 | function than to try to deal with it. | |
1336 | ||
1337 | This routine does a final relocation. Whether it is useful for a | |
1338 | relocateable link depends upon how the object format defines | |
1339 | relocations. | |
1340 | ||
1341 | FIXME: This routine ignores any special_function in the HOWTO, | |
1342 | since the existing special_function values have been written for | |
1343 | bfd_perform_relocation. | |
1344 | ||
1345 | HOWTO is the reloc howto information. | |
1346 | INPUT_BFD is the BFD which the reloc applies to. | |
1347 | INPUT_SECTION is the section which the reloc applies to. | |
1348 | CONTENTS is the contents of the section. | |
1349 | ADDRESS is the address of the reloc within INPUT_SECTION. | |
1350 | VALUE is the value of the symbol the reloc refers to. | |
1351 | ADDEND is the addend of the reloc. */ | |
1352 | ||
1353 | bfd_reloc_status_type | |
1354 | _bfd_final_link_relocate (howto, input_bfd, input_section, contents, address, | |
1355 | value, addend) | |
1356 | reloc_howto_type *howto; | |
1357 | bfd *input_bfd; | |
1358 | asection *input_section; | |
1359 | bfd_byte *contents; | |
1360 | bfd_vma address; | |
1361 | bfd_vma value; | |
1362 | bfd_vma addend; | |
1363 | { | |
1364 | bfd_vma relocation; | |
1365 | ||
1366 | /* Sanity check the address. */ | |
1367 | if (address > input_section->_raw_size) | |
1368 | return bfd_reloc_outofrange; | |
1369 | ||
1370 | /* This function assumes that we are dealing with a basic relocation | |
1371 | against a symbol. We want to compute the value of the symbol to | |
1372 | relocate to. This is just VALUE, the value of the symbol, plus | |
1373 | ADDEND, any addend associated with the reloc. */ | |
1374 | relocation = value + addend; | |
1375 | ||
1376 | /* If the relocation is PC relative, we want to set RELOCATION to | |
1377 | the distance between the symbol (currently in RELOCATION) and the | |
1378 | location we are relocating. Some targets (e.g., i386-aout) | |
1379 | arrange for the contents of the section to be the negative of the | |
1380 | offset of the location within the section; for such targets | |
1381 | pcrel_offset is false. Other targets (e.g., m88kbcs or ELF) | |
1382 | simply leave the contents of the section as zero; for such | |
1383 | targets pcrel_offset is true. If pcrel_offset is false we do not | |
1384 | need to subtract out the offset of the location within the | |
1385 | section (which is just ADDRESS). */ | |
1386 | if (howto->pc_relative) | |
1387 | { | |
1388 | relocation -= (input_section->output_section->vma | |
1389 | + input_section->output_offset); | |
1390 | if (howto->pcrel_offset) | |
1391 | relocation -= address; | |
1392 | } | |
1393 | ||
1394 | return _bfd_relocate_contents (howto, input_bfd, relocation, | |
1395 | contents + address); | |
1396 | } | |
1397 | ||
1398 | /* Relocate a given location using a given value and howto. */ | |
1399 | ||
1400 | bfd_reloc_status_type | |
1401 | _bfd_relocate_contents (howto, input_bfd, relocation, location) | |
1402 | reloc_howto_type *howto; | |
1403 | bfd *input_bfd; | |
1404 | bfd_vma relocation; | |
1405 | bfd_byte *location; | |
1406 | { | |
1407 | int size; | |
7442e600 | 1408 | bfd_vma x = 0; |
d5afc56e | 1409 | bfd_reloc_status_type flag; |
252b5132 RH |
1410 | unsigned int rightshift = howto->rightshift; |
1411 | unsigned int bitpos = howto->bitpos; | |
1412 | ||
1413 | /* If the size is negative, negate RELOCATION. This isn't very | |
1414 | general. */ | |
1415 | if (howto->size < 0) | |
1416 | relocation = -relocation; | |
1417 | ||
1418 | /* Get the value we are going to relocate. */ | |
1419 | size = bfd_get_reloc_size (howto); | |
1420 | switch (size) | |
1421 | { | |
1422 | default: | |
1423 | case 0: | |
1424 | abort (); | |
1425 | case 1: | |
1426 | x = bfd_get_8 (input_bfd, location); | |
1427 | break; | |
1428 | case 2: | |
1429 | x = bfd_get_16 (input_bfd, location); | |
1430 | break; | |
1431 | case 4: | |
1432 | x = bfd_get_32 (input_bfd, location); | |
1433 | break; | |
1434 | case 8: | |
1435 | #ifdef BFD64 | |
1436 | x = bfd_get_64 (input_bfd, location); | |
1437 | #else | |
1438 | abort (); | |
1439 | #endif | |
1440 | break; | |
1441 | } | |
1442 | ||
1443 | /* Check for overflow. FIXME: We may drop bits during the addition | |
1444 | which we don't check for. We must either check at every single | |
1445 | operation, which would be tedious, or we must do the computations | |
1446 | in a type larger than bfd_vma, which would be inefficient. */ | |
d5afc56e | 1447 | flag = bfd_reloc_ok; |
252b5132 RH |
1448 | if (howto->complain_on_overflow != complain_overflow_dont) |
1449 | { | |
1450 | bfd_vma addrmask, fieldmask, signmask, ss; | |
1451 | bfd_vma a, b, sum; | |
1452 | ||
1453 | /* Get the values to be added together. For signed and unsigned | |
1454 | relocations, we assume that all values should be truncated to | |
1455 | the size of an address. For bitfields, all the bits matter. | |
1456 | See also bfd_check_overflow. */ | |
1457 | fieldmask = N_ONES (howto->bitsize); | |
1458 | addrmask = N_ONES (bfd_arch_bits_per_address (input_bfd)) | fieldmask; | |
1459 | a = relocation; | |
1460 | b = x & howto->src_mask; | |
1461 | ||
1462 | switch (howto->complain_on_overflow) | |
1463 | { | |
1464 | case complain_overflow_signed: | |
1465 | a = (a & addrmask) >> rightshift; | |
1466 | ||
1467 | /* If any sign bits are set, all sign bits must be set. | |
1468 | That is, A must be a valid negative address after | |
1469 | shifting. */ | |
1470 | signmask = ~ (fieldmask >> 1); | |
1471 | ss = a & signmask; | |
1472 | if (ss != 0 && ss != ((addrmask >> rightshift) & signmask)) | |
d5afc56e | 1473 | flag = bfd_reloc_overflow; |
252b5132 RH |
1474 | |
1475 | /* We only need this next bit of code if the sign bit of B | |
1476 | is below the sign bit of A. This would only happen if | |
1477 | SRC_MASK had fewer bits than BITSIZE. Note that if | |
1478 | SRC_MASK has more bits than BITSIZE, we can get into | |
1479 | trouble; we would need to verify that B is in range, as | |
1480 | we do for A above. */ | |
1481 | signmask = ((~ howto->src_mask) >> 1) & howto->src_mask; | |
8a4ac871 AM |
1482 | |
1483 | /* Set all the bits above the sign bit. */ | |
1484 | b = (b ^ signmask) - signmask; | |
252b5132 RH |
1485 | |
1486 | b = (b & addrmask) >> bitpos; | |
1487 | ||
1488 | /* Now we can do the addition. */ | |
1489 | sum = a + b; | |
1490 | ||
1491 | /* See if the result has the correct sign. Bits above the | |
1492 | sign bit are junk now; ignore them. If the sum is | |
1493 | positive, make sure we did not have all negative inputs; | |
1494 | if the sum is negative, make sure we did not have all | |
1495 | positive inputs. The test below looks only at the sign | |
1496 | bits, and it really just | |
1497 | SIGN (A) == SIGN (B) && SIGN (A) != SIGN (SUM) | |
1498 | */ | |
1499 | signmask = (fieldmask >> 1) + 1; | |
1500 | if (((~ (a ^ b)) & (a ^ sum)) & signmask) | |
d5afc56e | 1501 | flag = bfd_reloc_overflow; |
252b5132 RH |
1502 | |
1503 | break; | |
1504 | ||
1505 | case complain_overflow_unsigned: | |
1506 | /* Checking for an unsigned overflow is relatively easy: | |
1507 | trim the addresses and add, and trim the result as well. | |
1508 | Overflow is normally indicated when the result does not | |
1509 | fit in the field. However, we also need to consider the | |
1510 | case when, e.g., fieldmask is 0x7fffffff or smaller, an | |
1511 | input is 0x80000000, and bfd_vma is only 32 bits; then we | |
1512 | will get sum == 0, but there is an overflow, since the | |
1513 | inputs did not fit in the field. Instead of doing a | |
1514 | separate test, we can check for this by or-ing in the | |
1515 | operands when testing for the sum overflowing its final | |
1516 | field. */ | |
1517 | a = (a & addrmask) >> rightshift; | |
1518 | b = (b & addrmask) >> bitpos; | |
1519 | sum = (a + b) & addrmask; | |
1520 | if ((a | b | sum) & ~ fieldmask) | |
d5afc56e | 1521 | flag = bfd_reloc_overflow; |
252b5132 RH |
1522 | |
1523 | break; | |
1524 | ||
1525 | case complain_overflow_bitfield: | |
d5afc56e | 1526 | /* Much like the signed check, but for a field one bit |
8a4ac871 | 1527 | wider, and no trimming inputs with addrmask. We allow a |
d5afc56e AM |
1528 | bitfield to represent numbers in the range -2**n to |
1529 | 2**n-1, where n is the number of bits in the field. | |
1530 | Note that when bfd_vma is 32 bits, a 32-bit reloc can't | |
1531 | overflow, which is exactly what we want. */ | |
252b5132 | 1532 | a >>= rightshift; |
252b5132 | 1533 | |
d5afc56e AM |
1534 | signmask = ~ fieldmask; |
1535 | ss = a & signmask; | |
1536 | if (ss != 0 && ss != (((bfd_vma) -1 >> rightshift) & signmask)) | |
1537 | flag = bfd_reloc_overflow; | |
252b5132 | 1538 | |
d5afc56e | 1539 | signmask = ((~ howto->src_mask) >> 1) & howto->src_mask; |
8a4ac871 | 1540 | b = (b ^ signmask) - signmask; |
252b5132 | 1541 | |
d5afc56e | 1542 | b >>= bitpos; |
44257b8b | 1543 | |
252b5132 | 1544 | sum = a + b; |
d5afc56e | 1545 | |
8a4ac871 AM |
1546 | /* We mask with addrmask here to explicitly allow an address |
1547 | wrap-around. The Linux kernel relies on it, and it is | |
1548 | the only way to write assembler code which can run when | |
1549 | loaded at a location 0x80000000 away from the location at | |
1550 | which it is linked. */ | |
d5afc56e | 1551 | signmask = fieldmask + 1; |
8a4ac871 | 1552 | if (((~ (a ^ b)) & (a ^ sum)) & signmask & addrmask) |
d5afc56e | 1553 | flag = bfd_reloc_overflow; |
252b5132 RH |
1554 | |
1555 | break; | |
1556 | ||
1557 | default: | |
1558 | abort (); | |
1559 | } | |
1560 | } | |
1561 | ||
1562 | /* Put RELOCATION in the right bits. */ | |
1563 | relocation >>= (bfd_vma) rightshift; | |
1564 | relocation <<= (bfd_vma) bitpos; | |
1565 | ||
1566 | /* Add RELOCATION to the right bits of X. */ | |
1567 | x = ((x & ~howto->dst_mask) | |
1568 | | (((x & howto->src_mask) + relocation) & howto->dst_mask)); | |
1569 | ||
1570 | /* Put the relocated value back in the object file. */ | |
1571 | switch (size) | |
1572 | { | |
1573 | default: | |
1574 | case 0: | |
1575 | abort (); | |
1576 | case 1: | |
1577 | bfd_put_8 (input_bfd, x, location); | |
1578 | break; | |
1579 | case 2: | |
1580 | bfd_put_16 (input_bfd, x, location); | |
1581 | break; | |
1582 | case 4: | |
1583 | bfd_put_32 (input_bfd, x, location); | |
1584 | break; | |
1585 | case 8: | |
1586 | #ifdef BFD64 | |
1587 | bfd_put_64 (input_bfd, x, location); | |
1588 | #else | |
1589 | abort (); | |
1590 | #endif | |
1591 | break; | |
1592 | } | |
1593 | ||
d5afc56e | 1594 | return flag; |
252b5132 RH |
1595 | } |
1596 | ||
1597 | /* | |
1598 | DOCDD | |
1599 | INODE | |
1600 | howto manager, , typedef arelent, Relocations | |
1601 | ||
1602 | SECTION | |
1603 | The howto manager | |
1604 | ||
1605 | When an application wants to create a relocation, but doesn't | |
1606 | know what the target machine might call it, it can find out by | |
1607 | using this bit of code. | |
1608 | ||
1609 | */ | |
1610 | ||
1611 | /* | |
1612 | TYPEDEF | |
1613 | bfd_reloc_code_type | |
1614 | ||
1615 | DESCRIPTION | |
1616 | The insides of a reloc code. The idea is that, eventually, there | |
1617 | will be one enumerator for every type of relocation we ever do. | |
1618 | Pass one of these values to <<bfd_reloc_type_lookup>>, and it'll | |
1619 | return a howto pointer. | |
1620 | ||
1621 | This does mean that the application must determine the correct | |
1622 | enumerator value; you can't get a howto pointer from a random set | |
1623 | of attributes. | |
1624 | ||
1625 | SENUM | |
1626 | bfd_reloc_code_real | |
1627 | ||
1628 | ENUM | |
1629 | BFD_RELOC_64 | |
1630 | ENUMX | |
1631 | BFD_RELOC_32 | |
1632 | ENUMX | |
1633 | BFD_RELOC_26 | |
1634 | ENUMX | |
1635 | BFD_RELOC_24 | |
1636 | ENUMX | |
1637 | BFD_RELOC_16 | |
1638 | ENUMX | |
1639 | BFD_RELOC_14 | |
1640 | ENUMX | |
1641 | BFD_RELOC_8 | |
1642 | ENUMDOC | |
1643 | Basic absolute relocations of N bits. | |
1644 | ||
1645 | ENUM | |
1646 | BFD_RELOC_64_PCREL | |
1647 | ENUMX | |
1648 | BFD_RELOC_32_PCREL | |
1649 | ENUMX | |
1650 | BFD_RELOC_24_PCREL | |
1651 | ENUMX | |
1652 | BFD_RELOC_16_PCREL | |
1653 | ENUMX | |
1654 | BFD_RELOC_12_PCREL | |
1655 | ENUMX | |
1656 | BFD_RELOC_8_PCREL | |
1657 | ENUMDOC | |
1658 | PC-relative relocations. Sometimes these are relative to the address | |
1659 | of the relocation itself; sometimes they are relative to the start of | |
1660 | the section containing the relocation. It depends on the specific target. | |
1661 | ||
1662 | The 24-bit relocation is used in some Intel 960 configurations. | |
1663 | ||
1664 | ENUM | |
1665 | BFD_RELOC_32_GOT_PCREL | |
1666 | ENUMX | |
1667 | BFD_RELOC_16_GOT_PCREL | |
1668 | ENUMX | |
1669 | BFD_RELOC_8_GOT_PCREL | |
1670 | ENUMX | |
1671 | BFD_RELOC_32_GOTOFF | |
1672 | ENUMX | |
1673 | BFD_RELOC_16_GOTOFF | |
1674 | ENUMX | |
1675 | BFD_RELOC_LO16_GOTOFF | |
1676 | ENUMX | |
1677 | BFD_RELOC_HI16_GOTOFF | |
1678 | ENUMX | |
1679 | BFD_RELOC_HI16_S_GOTOFF | |
1680 | ENUMX | |
1681 | BFD_RELOC_8_GOTOFF | |
1682 | ENUMX | |
1683 | BFD_RELOC_32_PLT_PCREL | |
1684 | ENUMX | |
1685 | BFD_RELOC_24_PLT_PCREL | |
1686 | ENUMX | |
1687 | BFD_RELOC_16_PLT_PCREL | |
1688 | ENUMX | |
1689 | BFD_RELOC_8_PLT_PCREL | |
1690 | ENUMX | |
1691 | BFD_RELOC_32_PLTOFF | |
1692 | ENUMX | |
1693 | BFD_RELOC_16_PLTOFF | |
1694 | ENUMX | |
1695 | BFD_RELOC_LO16_PLTOFF | |
1696 | ENUMX | |
1697 | BFD_RELOC_HI16_PLTOFF | |
1698 | ENUMX | |
1699 | BFD_RELOC_HI16_S_PLTOFF | |
1700 | ENUMX | |
1701 | BFD_RELOC_8_PLTOFF | |
1702 | ENUMDOC | |
1703 | For ELF. | |
1704 | ||
1705 | ENUM | |
1706 | BFD_RELOC_68K_GLOB_DAT | |
1707 | ENUMX | |
1708 | BFD_RELOC_68K_JMP_SLOT | |
1709 | ENUMX | |
1710 | BFD_RELOC_68K_RELATIVE | |
1711 | ENUMDOC | |
1712 | Relocations used by 68K ELF. | |
1713 | ||
1714 | ENUM | |
1715 | BFD_RELOC_32_BASEREL | |
1716 | ENUMX | |
1717 | BFD_RELOC_16_BASEREL | |
1718 | ENUMX | |
1719 | BFD_RELOC_LO16_BASEREL | |
1720 | ENUMX | |
1721 | BFD_RELOC_HI16_BASEREL | |
1722 | ENUMX | |
1723 | BFD_RELOC_HI16_S_BASEREL | |
1724 | ENUMX | |
1725 | BFD_RELOC_8_BASEREL | |
1726 | ENUMX | |
1727 | BFD_RELOC_RVA | |
1728 | ENUMDOC | |
1729 | Linkage-table relative. | |
1730 | ||
1731 | ENUM | |
1732 | BFD_RELOC_8_FFnn | |
1733 | ENUMDOC | |
1734 | Absolute 8-bit relocation, but used to form an address like 0xFFnn. | |
1735 | ||
1736 | ENUM | |
1737 | BFD_RELOC_32_PCREL_S2 | |
1738 | ENUMX | |
1739 | BFD_RELOC_16_PCREL_S2 | |
1740 | ENUMX | |
1741 | BFD_RELOC_23_PCREL_S2 | |
1742 | ENUMDOC | |
1743 | These PC-relative relocations are stored as word displacements -- | |
1744 | i.e., byte displacements shifted right two bits. The 30-bit word | |
1745 | displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the | |
1746 | SPARC. (SPARC tools generally refer to this as <<WDISP30>>.) The | |
1747 | signed 16-bit displacement is used on the MIPS, and the 23-bit | |
1748 | displacement is used on the Alpha. | |
1749 | ||
1750 | ENUM | |
1751 | BFD_RELOC_HI22 | |
1752 | ENUMX | |
1753 | BFD_RELOC_LO10 | |
1754 | ENUMDOC | |
1755 | High 22 bits and low 10 bits of 32-bit value, placed into lower bits of | |
1756 | the target word. These are used on the SPARC. | |
1757 | ||
1758 | ENUM | |
1759 | BFD_RELOC_GPREL16 | |
1760 | ENUMX | |
1761 | BFD_RELOC_GPREL32 | |
1762 | ENUMDOC | |
1763 | For systems that allocate a Global Pointer register, these are | |
1764 | displacements off that register. These relocation types are | |
1765 | handled specially, because the value the register will have is | |
1766 | decided relatively late. | |
1767 | ||
252b5132 RH |
1768 | ENUM |
1769 | BFD_RELOC_I960_CALLJ | |
1770 | ENUMDOC | |
1771 | Reloc types used for i960/b.out. | |
1772 | ||
1773 | ENUM | |
1774 | BFD_RELOC_NONE | |
1775 | ENUMX | |
1776 | BFD_RELOC_SPARC_WDISP22 | |
1777 | ENUMX | |
1778 | BFD_RELOC_SPARC22 | |
1779 | ENUMX | |
1780 | BFD_RELOC_SPARC13 | |
1781 | ENUMX | |
1782 | BFD_RELOC_SPARC_GOT10 | |
1783 | ENUMX | |
1784 | BFD_RELOC_SPARC_GOT13 | |
1785 | ENUMX | |
1786 | BFD_RELOC_SPARC_GOT22 | |
1787 | ENUMX | |
1788 | BFD_RELOC_SPARC_PC10 | |
1789 | ENUMX | |
1790 | BFD_RELOC_SPARC_PC22 | |
1791 | ENUMX | |
1792 | BFD_RELOC_SPARC_WPLT30 | |
1793 | ENUMX | |
1794 | BFD_RELOC_SPARC_COPY | |
1795 | ENUMX | |
1796 | BFD_RELOC_SPARC_GLOB_DAT | |
1797 | ENUMX | |
1798 | BFD_RELOC_SPARC_JMP_SLOT | |
1799 | ENUMX | |
1800 | BFD_RELOC_SPARC_RELATIVE | |
1801 | ENUMX | |
1802 | BFD_RELOC_SPARC_UA32 | |
1803 | ENUMDOC | |
1804 | SPARC ELF relocations. There is probably some overlap with other | |
1805 | relocation types already defined. | |
1806 | ||
1807 | ENUM | |
1808 | BFD_RELOC_SPARC_BASE13 | |
1809 | ENUMX | |
1810 | BFD_RELOC_SPARC_BASE22 | |
1811 | ENUMDOC | |
1812 | I think these are specific to SPARC a.out (e.g., Sun 4). | |
1813 | ||
1814 | ENUMEQ | |
1815 | BFD_RELOC_SPARC_64 | |
1816 | BFD_RELOC_64 | |
1817 | ENUMX | |
1818 | BFD_RELOC_SPARC_10 | |
1819 | ENUMX | |
1820 | BFD_RELOC_SPARC_11 | |
1821 | ENUMX | |
1822 | BFD_RELOC_SPARC_OLO10 | |
1823 | ENUMX | |
1824 | BFD_RELOC_SPARC_HH22 | |
1825 | ENUMX | |
1826 | BFD_RELOC_SPARC_HM10 | |
1827 | ENUMX | |
1828 | BFD_RELOC_SPARC_LM22 | |
1829 | ENUMX | |
1830 | BFD_RELOC_SPARC_PC_HH22 | |
1831 | ENUMX | |
1832 | BFD_RELOC_SPARC_PC_HM10 | |
1833 | ENUMX | |
1834 | BFD_RELOC_SPARC_PC_LM22 | |
1835 | ENUMX | |
1836 | BFD_RELOC_SPARC_WDISP16 | |
1837 | ENUMX | |
1838 | BFD_RELOC_SPARC_WDISP19 | |
1839 | ENUMX | |
1840 | BFD_RELOC_SPARC_7 | |
1841 | ENUMX | |
1842 | BFD_RELOC_SPARC_6 | |
1843 | ENUMX | |
1844 | BFD_RELOC_SPARC_5 | |
1845 | ENUMEQX | |
1846 | BFD_RELOC_SPARC_DISP64 | |
1847 | BFD_RELOC_64_PCREL | |
1848 | ENUMX | |
1849 | BFD_RELOC_SPARC_PLT64 | |
1850 | ENUMX | |
1851 | BFD_RELOC_SPARC_HIX22 | |
1852 | ENUMX | |
1853 | BFD_RELOC_SPARC_LOX10 | |
1854 | ENUMX | |
1855 | BFD_RELOC_SPARC_H44 | |
1856 | ENUMX | |
1857 | BFD_RELOC_SPARC_M44 | |
1858 | ENUMX | |
1859 | BFD_RELOC_SPARC_L44 | |
1860 | ENUMX | |
1861 | BFD_RELOC_SPARC_REGISTER | |
1862 | ENUMDOC | |
1863 | SPARC64 relocations | |
1864 | ||
1865 | ENUM | |
1866 | BFD_RELOC_SPARC_REV32 | |
1867 | ENUMDOC | |
1868 | SPARC little endian relocation | |
1869 | ||
1870 | ENUM | |
1871 | BFD_RELOC_ALPHA_GPDISP_HI16 | |
1872 | ENUMDOC | |
1873 | Alpha ECOFF and ELF relocations. Some of these treat the symbol or | |
1874 | "addend" in some special way. | |
1875 | For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when | |
1876 | writing; when reading, it will be the absolute section symbol. The | |
1877 | addend is the displacement in bytes of the "lda" instruction from | |
1878 | the "ldah" instruction (which is at the address of this reloc). | |
1879 | ENUM | |
1880 | BFD_RELOC_ALPHA_GPDISP_LO16 | |
1881 | ENUMDOC | |
1882 | For GPDISP_LO16 ("ignore") relocations, the symbol is handled as | |
1883 | with GPDISP_HI16 relocs. The addend is ignored when writing the | |
1884 | relocations out, and is filled in with the file's GP value on | |
1885 | reading, for convenience. | |
1886 | ||
1887 | ENUM | |
1888 | BFD_RELOC_ALPHA_GPDISP | |
1889 | ENUMDOC | |
1890 | The ELF GPDISP relocation is exactly the same as the GPDISP_HI16 | |
1891 | relocation except that there is no accompanying GPDISP_LO16 | |
1892 | relocation. | |
1893 | ||
1894 | ENUM | |
1895 | BFD_RELOC_ALPHA_LITERAL | |
1896 | ENUMX | |
1897 | BFD_RELOC_ALPHA_ELF_LITERAL | |
1898 | ENUMX | |
1899 | BFD_RELOC_ALPHA_LITUSE | |
1900 | ENUMDOC | |
1901 | The Alpha LITERAL/LITUSE relocs are produced by a symbol reference; | |
1902 | the assembler turns it into a LDQ instruction to load the address of | |
1903 | the symbol, and then fills in a register in the real instruction. | |
1904 | ||
1905 | The LITERAL reloc, at the LDQ instruction, refers to the .lita | |
1906 | section symbol. The addend is ignored when writing, but is filled | |
1907 | in with the file's GP value on reading, for convenience, as with the | |
1908 | GPDISP_LO16 reloc. | |
1909 | ||
1910 | The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16. | |
1911 | It should refer to the symbol to be referenced, as with 16_GOTOFF, | |
1912 | but it generates output not based on the position within the .got | |
1913 | section, but relative to the GP value chosen for the file during the | |
1914 | final link stage. | |
1915 | ||
1916 | The LITUSE reloc, on the instruction using the loaded address, gives | |
1917 | information to the linker that it might be able to use to optimize | |
1918 | away some literal section references. The symbol is ignored (read | |
1919 | as the absolute section symbol), and the "addend" indicates the type | |
1920 | of instruction using the register: | |
1921 | 1 - "memory" fmt insn | |
1922 | 2 - byte-manipulation (byte offset reg) | |
1923 | 3 - jsr (target of branch) | |
1924 | ||
1925 | The GNU linker currently doesn't do any of this optimizing. | |
1926 | ||
fe174262 MM |
1927 | ENUM |
1928 | BFD_RELOC_ALPHA_USER_LITERAL | |
1929 | ENUMX | |
1930 | BFD_RELOC_ALPHA_USER_LITUSE_BASE | |
1931 | ENUMX | |
1932 | BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF | |
1933 | ENUMX | |
1934 | BFD_RELOC_ALPHA_USER_LITUSE_JSR | |
1935 | ENUMX | |
1936 | BFD_RELOC_ALPHA_USER_GPDISP | |
1937 | ENUMX | |
1938 | BFD_RELOC_ALPHA_USER_GPRELHIGH | |
1939 | ENUMX | |
1940 | BFD_RELOC_ALPHA_USER_GPRELLOW | |
1941 | ENUMDOC | |
1942 | The BFD_RELOC_ALPHA_USER_* relocations are used by the assembler to | |
1943 | process the explicit !<reloc>!sequence relocations, and are mapped | |
1944 | into the normal relocations at the end of processing. | |
1945 | ||
252b5132 RH |
1946 | ENUM |
1947 | BFD_RELOC_ALPHA_HINT | |
1948 | ENUMDOC | |
1949 | The HINT relocation indicates a value that should be filled into the | |
1950 | "hint" field of a jmp/jsr/ret instruction, for possible branch- | |
1951 | prediction logic which may be provided on some processors. | |
1952 | ||
1953 | ENUM | |
1954 | BFD_RELOC_ALPHA_LINKAGE | |
1955 | ENUMDOC | |
1956 | The LINKAGE relocation outputs a linkage pair in the object file, | |
1957 | which is filled by the linker. | |
1958 | ||
1959 | ENUM | |
1960 | BFD_RELOC_ALPHA_CODEADDR | |
1961 | ENUMDOC | |
1962 | The CODEADDR relocation outputs a STO_CA in the object file, | |
1963 | which is filled by the linker. | |
1964 | ||
1965 | ENUM | |
1966 | BFD_RELOC_MIPS_JMP | |
1967 | ENUMDOC | |
1968 | Bits 27..2 of the relocation address shifted right 2 bits; | |
1969 | simple reloc otherwise. | |
1970 | ||
1971 | ENUM | |
1972 | BFD_RELOC_MIPS16_JMP | |
1973 | ENUMDOC | |
1974 | The MIPS16 jump instruction. | |
1975 | ||
1976 | ENUM | |
1977 | BFD_RELOC_MIPS16_GPREL | |
1978 | ENUMDOC | |
1979 | MIPS16 GP relative reloc. | |
1980 | ||
1981 | ENUM | |
1982 | BFD_RELOC_HI16 | |
1983 | ENUMDOC | |
1984 | High 16 bits of 32-bit value; simple reloc. | |
1985 | ENUM | |
1986 | BFD_RELOC_HI16_S | |
1987 | ENUMDOC | |
1988 | High 16 bits of 32-bit value but the low 16 bits will be sign | |
1989 | extended and added to form the final result. If the low 16 | |
1990 | bits form a negative number, we need to add one to the high value | |
1991 | to compensate for the borrow when the low bits are added. | |
1992 | ENUM | |
1993 | BFD_RELOC_LO16 | |
1994 | ENUMDOC | |
1995 | Low 16 bits. | |
1996 | ENUM | |
1997 | BFD_RELOC_PCREL_HI16_S | |
1998 | ENUMDOC | |
1999 | Like BFD_RELOC_HI16_S, but PC relative. | |
2000 | ENUM | |
2001 | BFD_RELOC_PCREL_LO16 | |
2002 | ENUMDOC | |
2003 | Like BFD_RELOC_LO16, but PC relative. | |
2004 | ||
2005 | ENUMEQ | |
2006 | BFD_RELOC_MIPS_GPREL | |
2007 | BFD_RELOC_GPREL16 | |
2008 | ENUMDOC | |
2009 | Relocation relative to the global pointer. | |
2010 | ||
2011 | ENUM | |
2012 | BFD_RELOC_MIPS_LITERAL | |
2013 | ENUMDOC | |
2014 | Relocation against a MIPS literal section. | |
2015 | ||
2016 | ENUM | |
2017 | BFD_RELOC_MIPS_GOT16 | |
2018 | ENUMX | |
2019 | BFD_RELOC_MIPS_CALL16 | |
2020 | ENUMEQX | |
2021 | BFD_RELOC_MIPS_GPREL32 | |
2022 | BFD_RELOC_GPREL32 | |
2023 | ENUMX | |
2024 | BFD_RELOC_MIPS_GOT_HI16 | |
2025 | ENUMX | |
2026 | BFD_RELOC_MIPS_GOT_LO16 | |
2027 | ENUMX | |
2028 | BFD_RELOC_MIPS_CALL_HI16 | |
2029 | ENUMX | |
2030 | BFD_RELOC_MIPS_CALL_LO16 | |
3f830999 MM |
2031 | ENUMX |
2032 | BFD_RELOC_MIPS_SUB | |
2033 | ENUMX | |
2034 | BFD_RELOC_MIPS_GOT_PAGE | |
2035 | ENUMX | |
2036 | BFD_RELOC_MIPS_GOT_OFST | |
2037 | ENUMX | |
2038 | BFD_RELOC_MIPS_GOT_DISP | |
252b5132 RH |
2039 | COMMENT |
2040 | ENUMDOC | |
2041 | MIPS ELF relocations. | |
2042 | ||
2043 | COMMENT | |
2044 | ||
2045 | ENUM | |
2046 | BFD_RELOC_386_GOT32 | |
2047 | ENUMX | |
2048 | BFD_RELOC_386_PLT32 | |
2049 | ENUMX | |
2050 | BFD_RELOC_386_COPY | |
2051 | ENUMX | |
2052 | BFD_RELOC_386_GLOB_DAT | |
2053 | ENUMX | |
2054 | BFD_RELOC_386_JUMP_SLOT | |
2055 | ENUMX | |
2056 | BFD_RELOC_386_RELATIVE | |
2057 | ENUMX | |
2058 | BFD_RELOC_386_GOTOFF | |
2059 | ENUMX | |
2060 | BFD_RELOC_386_GOTPC | |
2061 | ENUMDOC | |
2062 | i386/elf relocations | |
2063 | ||
8d88c4ca NC |
2064 | ENUM |
2065 | BFD_RELOC_X86_64_GOT32 | |
2066 | ENUMX | |
2067 | BFD_RELOC_X86_64_PLT32 | |
2068 | ENUMX | |
2069 | BFD_RELOC_X86_64_COPY | |
2070 | ENUMX | |
2071 | BFD_RELOC_X86_64_GLOB_DAT | |
2072 | ENUMX | |
2073 | BFD_RELOC_X86_64_JUMP_SLOT | |
2074 | ENUMX | |
2075 | BFD_RELOC_X86_64_RELATIVE | |
2076 | ENUMX | |
2077 | BFD_RELOC_X86_64_GOTPCREL | |
2078 | ENUMX | |
2079 | BFD_RELOC_X86_64_32S | |
2080 | ENUMDOC | |
2081 | x86-64/elf relocations | |
2082 | ||
252b5132 RH |
2083 | ENUM |
2084 | BFD_RELOC_NS32K_IMM_8 | |
2085 | ENUMX | |
2086 | BFD_RELOC_NS32K_IMM_16 | |
2087 | ENUMX | |
2088 | BFD_RELOC_NS32K_IMM_32 | |
2089 | ENUMX | |
2090 | BFD_RELOC_NS32K_IMM_8_PCREL | |
2091 | ENUMX | |
2092 | BFD_RELOC_NS32K_IMM_16_PCREL | |
2093 | ENUMX | |
2094 | BFD_RELOC_NS32K_IMM_32_PCREL | |
2095 | ENUMX | |
2096 | BFD_RELOC_NS32K_DISP_8 | |
2097 | ENUMX | |
2098 | BFD_RELOC_NS32K_DISP_16 | |
2099 | ENUMX | |
2100 | BFD_RELOC_NS32K_DISP_32 | |
2101 | ENUMX | |
2102 | BFD_RELOC_NS32K_DISP_8_PCREL | |
2103 | ENUMX | |
2104 | BFD_RELOC_NS32K_DISP_16_PCREL | |
2105 | ENUMX | |
2106 | BFD_RELOC_NS32K_DISP_32_PCREL | |
2107 | ENUMDOC | |
2108 | ns32k relocations | |
2109 | ||
0bcb993b ILT |
2110 | ENUM |
2111 | BFD_RELOC_PJ_CODE_HI16 | |
2112 | ENUMX | |
2113 | BFD_RELOC_PJ_CODE_LO16 | |
2114 | ENUMX | |
2115 | BFD_RELOC_PJ_CODE_DIR16 | |
2116 | ENUMX | |
2117 | BFD_RELOC_PJ_CODE_DIR32 | |
2118 | ENUMX | |
2119 | BFD_RELOC_PJ_CODE_REL16 | |
2120 | ENUMX | |
2121 | BFD_RELOC_PJ_CODE_REL32 | |
2122 | ENUMDOC | |
2123 | Picojava relocs. Not all of these appear in object files. | |
88b6bae0 | 2124 | |
252b5132 RH |
2125 | ENUM |
2126 | BFD_RELOC_PPC_B26 | |
2127 | ENUMX | |
2128 | BFD_RELOC_PPC_BA26 | |
2129 | ENUMX | |
2130 | BFD_RELOC_PPC_TOC16 | |
2131 | ENUMX | |
2132 | BFD_RELOC_PPC_B16 | |
2133 | ENUMX | |
2134 | BFD_RELOC_PPC_B16_BRTAKEN | |
2135 | ENUMX | |
2136 | BFD_RELOC_PPC_B16_BRNTAKEN | |
2137 | ENUMX | |
2138 | BFD_RELOC_PPC_BA16 | |
2139 | ENUMX | |
2140 | BFD_RELOC_PPC_BA16_BRTAKEN | |
2141 | ENUMX | |
2142 | BFD_RELOC_PPC_BA16_BRNTAKEN | |
2143 | ENUMX | |
2144 | BFD_RELOC_PPC_COPY | |
2145 | ENUMX | |
2146 | BFD_RELOC_PPC_GLOB_DAT | |
2147 | ENUMX | |
2148 | BFD_RELOC_PPC_JMP_SLOT | |
2149 | ENUMX | |
2150 | BFD_RELOC_PPC_RELATIVE | |
2151 | ENUMX | |
2152 | BFD_RELOC_PPC_LOCAL24PC | |
2153 | ENUMX | |
2154 | BFD_RELOC_PPC_EMB_NADDR32 | |
2155 | ENUMX | |
2156 | BFD_RELOC_PPC_EMB_NADDR16 | |
2157 | ENUMX | |
2158 | BFD_RELOC_PPC_EMB_NADDR16_LO | |
2159 | ENUMX | |
2160 | BFD_RELOC_PPC_EMB_NADDR16_HI | |
2161 | ENUMX | |
2162 | BFD_RELOC_PPC_EMB_NADDR16_HA | |
2163 | ENUMX | |
2164 | BFD_RELOC_PPC_EMB_SDAI16 | |
2165 | ENUMX | |
2166 | BFD_RELOC_PPC_EMB_SDA2I16 | |
2167 | ENUMX | |
2168 | BFD_RELOC_PPC_EMB_SDA2REL | |
2169 | ENUMX | |
2170 | BFD_RELOC_PPC_EMB_SDA21 | |
2171 | ENUMX | |
2172 | BFD_RELOC_PPC_EMB_MRKREF | |
2173 | ENUMX | |
2174 | BFD_RELOC_PPC_EMB_RELSEC16 | |
2175 | ENUMX | |
2176 | BFD_RELOC_PPC_EMB_RELST_LO | |
2177 | ENUMX | |
2178 | BFD_RELOC_PPC_EMB_RELST_HI | |
2179 | ENUMX | |
2180 | BFD_RELOC_PPC_EMB_RELST_HA | |
2181 | ENUMX | |
2182 | BFD_RELOC_PPC_EMB_BIT_FLD | |
2183 | ENUMX | |
2184 | BFD_RELOC_PPC_EMB_RELSDA | |
2185 | ENUMDOC | |
2186 | Power(rs6000) and PowerPC relocations. | |
2187 | ||
5b93d8bb AM |
2188 | ENUM |
2189 | BFD_RELOC_I370_D12 | |
2190 | ENUMDOC | |
2191 | IBM 370/390 relocations | |
2192 | ||
252b5132 RH |
2193 | ENUM |
2194 | BFD_RELOC_CTOR | |
2195 | ENUMDOC | |
2196 | The type of reloc used to build a contructor table - at the moment | |
2197 | probably a 32 bit wide absolute relocation, but the target can choose. | |
2198 | It generally does map to one of the other relocation types. | |
2199 | ||
2200 | ENUM | |
2201 | BFD_RELOC_ARM_PCREL_BRANCH | |
2202 | ENUMDOC | |
2203 | ARM 26 bit pc-relative branch. The lowest two bits must be zero and are | |
2204 | not stored in the instruction. | |
dfc5f959 NC |
2205 | ENUM |
2206 | BFD_RELOC_ARM_PCREL_BLX | |
2207 | ENUMDOC | |
2208 | ARM 26 bit pc-relative branch. The lowest bit must be zero and is | |
2209 | not stored in the instruction. The 2nd lowest bit comes from a 1 bit | |
2210 | field in the instruction. | |
2211 | ENUM | |
2212 | BFD_RELOC_THUMB_PCREL_BLX | |
2213 | ENUMDOC | |
2214 | Thumb 22 bit pc-relative branch. The lowest bit must be zero and is | |
2215 | not stored in the instruction. The 2nd lowest bit comes from a 1 bit | |
2216 | field in the instruction. | |
252b5132 RH |
2217 | ENUM |
2218 | BFD_RELOC_ARM_IMMEDIATE | |
752149a0 NC |
2219 | ENUMX |
2220 | BFD_RELOC_ARM_ADRL_IMMEDIATE | |
252b5132 RH |
2221 | ENUMX |
2222 | BFD_RELOC_ARM_OFFSET_IMM | |
2223 | ENUMX | |
2224 | BFD_RELOC_ARM_SHIFT_IMM | |
2225 | ENUMX | |
2226 | BFD_RELOC_ARM_SWI | |
2227 | ENUMX | |
2228 | BFD_RELOC_ARM_MULTI | |
2229 | ENUMX | |
2230 | BFD_RELOC_ARM_CP_OFF_IMM | |
2231 | ENUMX | |
2232 | BFD_RELOC_ARM_ADR_IMM | |
2233 | ENUMX | |
2234 | BFD_RELOC_ARM_LDR_IMM | |
2235 | ENUMX | |
2236 | BFD_RELOC_ARM_LITERAL | |
2237 | ENUMX | |
2238 | BFD_RELOC_ARM_IN_POOL | |
2239 | ENUMX | |
2240 | BFD_RELOC_ARM_OFFSET_IMM8 | |
2241 | ENUMX | |
2242 | BFD_RELOC_ARM_HWLITERAL | |
2243 | ENUMX | |
2244 | BFD_RELOC_ARM_THUMB_ADD | |
2245 | ENUMX | |
2246 | BFD_RELOC_ARM_THUMB_IMM | |
2247 | ENUMX | |
2248 | BFD_RELOC_ARM_THUMB_SHIFT | |
2249 | ENUMX | |
2250 | BFD_RELOC_ARM_THUMB_OFFSET | |
2251 | ENUMX | |
2252 | BFD_RELOC_ARM_GOT12 | |
2253 | ENUMX | |
2254 | BFD_RELOC_ARM_GOT32 | |
2255 | ENUMX | |
2256 | BFD_RELOC_ARM_JUMP_SLOT | |
2257 | ENUMX | |
2258 | BFD_RELOC_ARM_COPY | |
2259 | ENUMX | |
2260 | BFD_RELOC_ARM_GLOB_DAT | |
2261 | ENUMX | |
2262 | BFD_RELOC_ARM_PLT32 | |
2263 | ENUMX | |
2264 | BFD_RELOC_ARM_RELATIVE | |
2265 | ENUMX | |
2266 | BFD_RELOC_ARM_GOTOFF | |
2267 | ENUMX | |
2268 | BFD_RELOC_ARM_GOTPC | |
2269 | ENUMDOC | |
2270 | These relocs are only used within the ARM assembler. They are not | |
2271 | (at present) written to any object files. | |
2272 | ||
2273 | ENUM | |
2274 | BFD_RELOC_SH_PCDISP8BY2 | |
2275 | ENUMX | |
2276 | BFD_RELOC_SH_PCDISP12BY2 | |
2277 | ENUMX | |
2278 | BFD_RELOC_SH_IMM4 | |
2279 | ENUMX | |
2280 | BFD_RELOC_SH_IMM4BY2 | |
2281 | ENUMX | |
2282 | BFD_RELOC_SH_IMM4BY4 | |
2283 | ENUMX | |
2284 | BFD_RELOC_SH_IMM8 | |
2285 | ENUMX | |
2286 | BFD_RELOC_SH_IMM8BY2 | |
2287 | ENUMX | |
2288 | BFD_RELOC_SH_IMM8BY4 | |
2289 | ENUMX | |
2290 | BFD_RELOC_SH_PCRELIMM8BY2 | |
2291 | ENUMX | |
2292 | BFD_RELOC_SH_PCRELIMM8BY4 | |
2293 | ENUMX | |
2294 | BFD_RELOC_SH_SWITCH16 | |
2295 | ENUMX | |
2296 | BFD_RELOC_SH_SWITCH32 | |
2297 | ENUMX | |
2298 | BFD_RELOC_SH_USES | |
2299 | ENUMX | |
2300 | BFD_RELOC_SH_COUNT | |
2301 | ENUMX | |
2302 | BFD_RELOC_SH_ALIGN | |
2303 | ENUMX | |
2304 | BFD_RELOC_SH_CODE | |
2305 | ENUMX | |
2306 | BFD_RELOC_SH_DATA | |
2307 | ENUMX | |
2308 | BFD_RELOC_SH_LABEL | |
015551fc JR |
2309 | ENUMX |
2310 | BFD_RELOC_SH_LOOP_START | |
2311 | ENUMX | |
2312 | BFD_RELOC_SH_LOOP_END | |
3d96075c L |
2313 | ENUMX |
2314 | BFD_RELOC_SH_COPY | |
2315 | ENUMX | |
2316 | BFD_RELOC_SH_GLOB_DAT | |
2317 | ENUMX | |
2318 | BFD_RELOC_SH_JMP_SLOT | |
2319 | ENUMX | |
2320 | BFD_RELOC_SH_RELATIVE | |
2321 | ENUMX | |
2322 | BFD_RELOC_SH_GOTPC | |
252b5132 RH |
2323 | ENUMDOC |
2324 | Hitachi SH relocs. Not all of these appear in object files. | |
2325 | ||
2326 | ENUM | |
2327 | BFD_RELOC_THUMB_PCREL_BRANCH9 | |
2328 | ENUMX | |
2329 | BFD_RELOC_THUMB_PCREL_BRANCH12 | |
2330 | ENUMX | |
2331 | BFD_RELOC_THUMB_PCREL_BRANCH23 | |
2332 | ENUMDOC | |
2333 | Thumb 23-, 12- and 9-bit pc-relative branches. The lowest bit must | |
2334 | be zero and is not stored in the instruction. | |
2335 | ||
2336 | ENUM | |
2337 | BFD_RELOC_ARC_B22_PCREL | |
2338 | ENUMDOC | |
0d2bcfaf | 2339 | ARC Cores relocs. |
252b5132 RH |
2340 | ARC 22 bit pc-relative branch. The lowest two bits must be zero and are |
2341 | not stored in the instruction. The high 20 bits are installed in bits 26 | |
2342 | through 7 of the instruction. | |
2343 | ENUM | |
2344 | BFD_RELOC_ARC_B26 | |
2345 | ENUMDOC | |
2346 | ARC 26 bit absolute branch. The lowest two bits must be zero and are not | |
2347 | stored in the instruction. The high 24 bits are installed in bits 23 | |
2348 | through 0. | |
2349 | ||
2350 | ENUM | |
2351 | BFD_RELOC_D10V_10_PCREL_R | |
2352 | ENUMDOC | |
2353 | Mitsubishi D10V relocs. | |
2354 | This is a 10-bit reloc with the right 2 bits | |
2355 | assumed to be 0. | |
2356 | ENUM | |
2357 | BFD_RELOC_D10V_10_PCREL_L | |
2358 | ENUMDOC | |
2359 | Mitsubishi D10V relocs. | |
2360 | This is a 10-bit reloc with the right 2 bits | |
2361 | assumed to be 0. This is the same as the previous reloc | |
2362 | except it is in the left container, i.e., | |
2363 | shifted left 15 bits. | |
2364 | ENUM | |
2365 | BFD_RELOC_D10V_18 | |
2366 | ENUMDOC | |
2367 | This is an 18-bit reloc with the right 2 bits | |
2368 | assumed to be 0. | |
2369 | ENUM | |
2370 | BFD_RELOC_D10V_18_PCREL | |
2371 | ENUMDOC | |
2372 | This is an 18-bit reloc with the right 2 bits | |
2373 | assumed to be 0. | |
2374 | ||
2375 | ENUM | |
2376 | BFD_RELOC_D30V_6 | |
2377 | ENUMDOC | |
2378 | Mitsubishi D30V relocs. | |
2379 | This is a 6-bit absolute reloc. | |
2380 | ENUM | |
2381 | BFD_RELOC_D30V_9_PCREL | |
2382 | ENUMDOC | |
88b6bae0 AM |
2383 | This is a 6-bit pc-relative reloc with |
2384 | the right 3 bits assumed to be 0. | |
252b5132 RH |
2385 | ENUM |
2386 | BFD_RELOC_D30V_9_PCREL_R | |
2387 | ENUMDOC | |
88b6bae0 | 2388 | This is a 6-bit pc-relative reloc with |
252b5132 RH |
2389 | the right 3 bits assumed to be 0. Same |
2390 | as the previous reloc but on the right side | |
88b6bae0 | 2391 | of the container. |
252b5132 RH |
2392 | ENUM |
2393 | BFD_RELOC_D30V_15 | |
2394 | ENUMDOC | |
88b6bae0 AM |
2395 | This is a 12-bit absolute reloc with the |
2396 | right 3 bitsassumed to be 0. | |
252b5132 RH |
2397 | ENUM |
2398 | BFD_RELOC_D30V_15_PCREL | |
2399 | ENUMDOC | |
88b6bae0 AM |
2400 | This is a 12-bit pc-relative reloc with |
2401 | the right 3 bits assumed to be 0. | |
252b5132 RH |
2402 | ENUM |
2403 | BFD_RELOC_D30V_15_PCREL_R | |
2404 | ENUMDOC | |
88b6bae0 | 2405 | This is a 12-bit pc-relative reloc with |
252b5132 RH |
2406 | the right 3 bits assumed to be 0. Same |
2407 | as the previous reloc but on the right side | |
88b6bae0 | 2408 | of the container. |
252b5132 RH |
2409 | ENUM |
2410 | BFD_RELOC_D30V_21 | |
2411 | ENUMDOC | |
88b6bae0 | 2412 | This is an 18-bit absolute reloc with |
252b5132 RH |
2413 | the right 3 bits assumed to be 0. |
2414 | ENUM | |
2415 | BFD_RELOC_D30V_21_PCREL | |
2416 | ENUMDOC | |
88b6bae0 | 2417 | This is an 18-bit pc-relative reloc with |
252b5132 RH |
2418 | the right 3 bits assumed to be 0. |
2419 | ENUM | |
2420 | BFD_RELOC_D30V_21_PCREL_R | |
2421 | ENUMDOC | |
88b6bae0 | 2422 | This is an 18-bit pc-relative reloc with |
252b5132 RH |
2423 | the right 3 bits assumed to be 0. Same |
2424 | as the previous reloc but on the right side | |
2425 | of the container. | |
2426 | ENUM | |
2427 | BFD_RELOC_D30V_32 | |
2428 | ENUMDOC | |
2429 | This is a 32-bit absolute reloc. | |
2430 | ENUM | |
2431 | BFD_RELOC_D30V_32_PCREL | |
2432 | ENUMDOC | |
2433 | This is a 32-bit pc-relative reloc. | |
2434 | ||
2435 | ENUM | |
2436 | BFD_RELOC_M32R_24 | |
2437 | ENUMDOC | |
2438 | Mitsubishi M32R relocs. | |
2439 | This is a 24 bit absolute address. | |
2440 | ENUM | |
2441 | BFD_RELOC_M32R_10_PCREL | |
2442 | ENUMDOC | |
2443 | This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0. | |
2444 | ENUM | |
2445 | BFD_RELOC_M32R_18_PCREL | |
2446 | ENUMDOC | |
2447 | This is an 18-bit reloc with the right 2 bits assumed to be 0. | |
2448 | ENUM | |
2449 | BFD_RELOC_M32R_26_PCREL | |
2450 | ENUMDOC | |
2451 | This is a 26-bit reloc with the right 2 bits assumed to be 0. | |
2452 | ENUM | |
2453 | BFD_RELOC_M32R_HI16_ULO | |
2454 | ENUMDOC | |
2455 | This is a 16-bit reloc containing the high 16 bits of an address | |
2456 | used when the lower 16 bits are treated as unsigned. | |
2457 | ENUM | |
2458 | BFD_RELOC_M32R_HI16_SLO | |
2459 | ENUMDOC | |
2460 | This is a 16-bit reloc containing the high 16 bits of an address | |
2461 | used when the lower 16 bits are treated as signed. | |
2462 | ENUM | |
2463 | BFD_RELOC_M32R_LO16 | |
2464 | ENUMDOC | |
2465 | This is a 16-bit reloc containing the lower 16 bits of an address. | |
2466 | ENUM | |
2467 | BFD_RELOC_M32R_SDA16 | |
2468 | ENUMDOC | |
2469 | This is a 16-bit reloc containing the small data area offset for use in | |
2470 | add3, load, and store instructions. | |
2471 | ||
2472 | ENUM | |
2473 | BFD_RELOC_V850_9_PCREL | |
2474 | ENUMDOC | |
2475 | This is a 9-bit reloc | |
2476 | ENUM | |
2477 | BFD_RELOC_V850_22_PCREL | |
2478 | ENUMDOC | |
2479 | This is a 22-bit reloc | |
2480 | ||
2481 | ENUM | |
2482 | BFD_RELOC_V850_SDA_16_16_OFFSET | |
2483 | ENUMDOC | |
2484 | This is a 16 bit offset from the short data area pointer. | |
2485 | ENUM | |
2486 | BFD_RELOC_V850_SDA_15_16_OFFSET | |
2487 | ENUMDOC | |
2488 | This is a 16 bit offset (of which only 15 bits are used) from the | |
2489 | short data area pointer. | |
2490 | ENUM | |
2491 | BFD_RELOC_V850_ZDA_16_16_OFFSET | |
2492 | ENUMDOC | |
2493 | This is a 16 bit offset from the zero data area pointer. | |
2494 | ENUM | |
2495 | BFD_RELOC_V850_ZDA_15_16_OFFSET | |
2496 | ENUMDOC | |
2497 | This is a 16 bit offset (of which only 15 bits are used) from the | |
2498 | zero data area pointer. | |
2499 | ENUM | |
2500 | BFD_RELOC_V850_TDA_6_8_OFFSET | |
2501 | ENUMDOC | |
2502 | This is an 8 bit offset (of which only 6 bits are used) from the | |
2503 | tiny data area pointer. | |
2504 | ENUM | |
2505 | BFD_RELOC_V850_TDA_7_8_OFFSET | |
2506 | ENUMDOC | |
2507 | This is an 8bit offset (of which only 7 bits are used) from the tiny | |
2508 | data area pointer. | |
2509 | ENUM | |
2510 | BFD_RELOC_V850_TDA_7_7_OFFSET | |
2511 | ENUMDOC | |
2512 | This is a 7 bit offset from the tiny data area pointer. | |
2513 | ENUM | |
2514 | BFD_RELOC_V850_TDA_16_16_OFFSET | |
2515 | ENUMDOC | |
2516 | This is a 16 bit offset from the tiny data area pointer. | |
2517 | COMMENT | |
2518 | ENUM | |
2519 | BFD_RELOC_V850_TDA_4_5_OFFSET | |
2520 | ENUMDOC | |
2521 | This is a 5 bit offset (of which only 4 bits are used) from the tiny | |
2522 | data area pointer. | |
2523 | ENUM | |
2524 | BFD_RELOC_V850_TDA_4_4_OFFSET | |
2525 | ENUMDOC | |
2526 | This is a 4 bit offset from the tiny data area pointer. | |
2527 | ENUM | |
2528 | BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET | |
2529 | ENUMDOC | |
2530 | This is a 16 bit offset from the short data area pointer, with the | |
2531 | bits placed non-contigously in the instruction. | |
2532 | ENUM | |
2533 | BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET | |
2534 | ENUMDOC | |
2535 | This is a 16 bit offset from the zero data area pointer, with the | |
2536 | bits placed non-contigously in the instruction. | |
2537 | ENUM | |
2538 | BFD_RELOC_V850_CALLT_6_7_OFFSET | |
2539 | ENUMDOC | |
2540 | This is a 6 bit offset from the call table base pointer. | |
2541 | ENUM | |
2542 | BFD_RELOC_V850_CALLT_16_16_OFFSET | |
2543 | ENUMDOC | |
2544 | This is a 16 bit offset from the call table base pointer. | |
2545 | COMMENT | |
2546 | ||
2547 | ENUM | |
2548 | BFD_RELOC_MN10300_32_PCREL | |
2549 | ENUMDOC | |
2550 | This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the | |
2551 | instruction. | |
2552 | ENUM | |
2553 | BFD_RELOC_MN10300_16_PCREL | |
2554 | ENUMDOC | |
2555 | This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the | |
2556 | instruction. | |
2557 | ||
2558 | ENUM | |
2559 | BFD_RELOC_TIC30_LDP | |
2560 | ENUMDOC | |
2561 | This is a 8bit DP reloc for the tms320c30, where the most | |
2562 | significant 8 bits of a 24 bit word are placed into the least | |
2563 | significant 8 bits of the opcode. | |
2564 | ||
81635ce4 TW |
2565 | ENUM |
2566 | BFD_RELOC_TIC54X_PARTLS7 | |
2567 | ENUMDOC | |
2568 | This is a 7bit reloc for the tms320c54x, where the least | |
2569 | significant 7 bits of a 16 bit word are placed into the least | |
2570 | significant 7 bits of the opcode. | |
2571 | ||
2572 | ENUM | |
2573 | BFD_RELOC_TIC54X_PARTMS9 | |
2574 | ENUMDOC | |
2575 | This is a 9bit DP reloc for the tms320c54x, where the most | |
2576 | significant 9 bits of a 16 bit word are placed into the least | |
2577 | significant 9 bits of the opcode. | |
2578 | ||
2579 | ENUM | |
2580 | BFD_RELOC_TIC54X_23 | |
2581 | ENUMDOC | |
2582 | This is an extended address 23-bit reloc for the tms320c54x. | |
2583 | ||
2584 | ENUM | |
2585 | BFD_RELOC_TIC54X_16_OF_23 | |
2586 | ENUMDOC | |
3d855632 KH |
2587 | This is a 16-bit reloc for the tms320c54x, where the least |
2588 | significant 16 bits of a 23-bit extended address are placed into | |
81635ce4 TW |
2589 | the opcode. |
2590 | ||
2591 | ENUM | |
2592 | BFD_RELOC_TIC54X_MS7_OF_23 | |
2593 | ENUMDOC | |
2594 | This is a reloc for the tms320c54x, where the most | |
3d855632 | 2595 | significant 7 bits of a 23-bit extended address are placed into |
81635ce4 | 2596 | the opcode. |
81635ce4 | 2597 | |
252b5132 RH |
2598 | ENUM |
2599 | BFD_RELOC_FR30_48 | |
2600 | ENUMDOC | |
2601 | This is a 48 bit reloc for the FR30 that stores 32 bits. | |
2602 | ENUM | |
2603 | BFD_RELOC_FR30_20 | |
2604 | ENUMDOC | |
2605 | This is a 32 bit reloc for the FR30 that stores 20 bits split up into | |
2606 | two sections. | |
2607 | ENUM | |
2608 | BFD_RELOC_FR30_6_IN_4 | |
2609 | ENUMDOC | |
2610 | This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in | |
2611 | 4 bits. | |
2612 | ENUM | |
2613 | BFD_RELOC_FR30_8_IN_8 | |
2614 | ENUMDOC | |
2615 | This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset | |
2616 | into 8 bits. | |
2617 | ENUM | |
2618 | BFD_RELOC_FR30_9_IN_8 | |
2619 | ENUMDOC | |
2620 | This is a 16 bit reloc for the FR30 that stores a 9 bit short offset | |
2621 | into 8 bits. | |
2622 | ENUM | |
2623 | BFD_RELOC_FR30_10_IN_8 | |
2624 | ENUMDOC | |
2625 | This is a 16 bit reloc for the FR30 that stores a 10 bit word offset | |
2626 | into 8 bits. | |
2627 | ENUM | |
2628 | BFD_RELOC_FR30_9_PCREL | |
2629 | ENUMDOC | |
2630 | This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative | |
2631 | short offset into 8 bits. | |
2632 | ENUM | |
2633 | BFD_RELOC_FR30_12_PCREL | |
2634 | ENUMDOC | |
2635 | This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative | |
2636 | short offset into 11 bits. | |
88b6bae0 | 2637 | |
252b5132 RH |
2638 | ENUM |
2639 | BFD_RELOC_MCORE_PCREL_IMM8BY4 | |
2640 | ENUMX | |
2641 | BFD_RELOC_MCORE_PCREL_IMM11BY2 | |
2642 | ENUMX | |
2643 | BFD_RELOC_MCORE_PCREL_IMM4BY2 | |
2644 | ENUMX | |
2645 | BFD_RELOC_MCORE_PCREL_32 | |
2646 | ENUMX | |
2647 | BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2 | |
36797d47 NC |
2648 | ENUMX |
2649 | BFD_RELOC_MCORE_RVA | |
252b5132 RH |
2650 | ENUMDOC |
2651 | Motorola Mcore relocations. | |
88b6bae0 | 2652 | |
adde6300 AM |
2653 | ENUM |
2654 | BFD_RELOC_AVR_7_PCREL | |
2655 | ENUMDOC | |
2656 | This is a 16 bit reloc for the AVR that stores 8 bit pc relative | |
2657 | short offset into 7 bits. | |
2658 | ENUM | |
2659 | BFD_RELOC_AVR_13_PCREL | |
2660 | ENUMDOC | |
2661 | This is a 16 bit reloc for the AVR that stores 13 bit pc relative | |
2662 | short offset into 12 bits. | |
2663 | ENUM | |
2664 | BFD_RELOC_AVR_16_PM | |
2665 | ENUMDOC | |
2666 | This is a 16 bit reloc for the AVR that stores 17 bit value (usually | |
3d855632 | 2667 | program memory address) into 16 bits. |
adde6300 AM |
2668 | ENUM |
2669 | BFD_RELOC_AVR_LO8_LDI | |
2670 | ENUMDOC | |
2671 | This is a 16 bit reloc for the AVR that stores 8 bit value (usually | |
2672 | data memory address) into 8 bit immediate value of LDI insn. | |
2673 | ENUM | |
2674 | BFD_RELOC_AVR_HI8_LDI | |
2675 | ENUMDOC | |
2676 | This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit | |
2677 | of data memory address) into 8 bit immediate value of LDI insn. | |
2678 | ENUM | |
2679 | BFD_RELOC_AVR_HH8_LDI | |
2680 | ENUMDOC | |
2681 | This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit | |
2682 | of program memory address) into 8 bit immediate value of LDI insn. | |
2683 | ENUM | |
2684 | BFD_RELOC_AVR_LO8_LDI_NEG | |
2685 | ENUMDOC | |
2686 | This is a 16 bit reloc for the AVR that stores negated 8 bit value | |
2687 | (usually data memory address) into 8 bit immediate value of SUBI insn. | |
2688 | ENUM | |
2689 | BFD_RELOC_AVR_HI8_LDI_NEG | |
2690 | ENUMDOC | |
2691 | This is a 16 bit reloc for the AVR that stores negated 8 bit value | |
2692 | (high 8 bit of data memory address) into 8 bit immediate value of | |
2693 | SUBI insn. | |
2694 | ENUM | |
2695 | BFD_RELOC_AVR_HH8_LDI_NEG | |
2696 | ENUMDOC | |
2697 | This is a 16 bit reloc for the AVR that stores negated 8 bit value | |
2698 | (most high 8 bit of program memory address) into 8 bit immediate value | |
2699 | of LDI or SUBI insn. | |
2700 | ENUM | |
2701 | BFD_RELOC_AVR_LO8_LDI_PM | |
2702 | ENUMDOC | |
2703 | This is a 16 bit reloc for the AVR that stores 8 bit value (usually | |
2704 | command address) into 8 bit immediate value of LDI insn. | |
2705 | ENUM | |
2706 | BFD_RELOC_AVR_HI8_LDI_PM | |
2707 | ENUMDOC | |
2708 | This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit | |
2709 | of command address) into 8 bit immediate value of LDI insn. | |
2710 | ENUM | |
2711 | BFD_RELOC_AVR_HH8_LDI_PM | |
2712 | ENUMDOC | |
2713 | This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit | |
2714 | of command address) into 8 bit immediate value of LDI insn. | |
2715 | ENUM | |
2716 | BFD_RELOC_AVR_LO8_LDI_PM_NEG | |
2717 | ENUMDOC | |
2718 | This is a 16 bit reloc for the AVR that stores negated 8 bit value | |
2719 | (usually command address) into 8 bit immediate value of SUBI insn. | |
2720 | ENUM | |
2721 | BFD_RELOC_AVR_HI8_LDI_PM_NEG | |
2722 | ENUMDOC | |
2723 | This is a 16 bit reloc for the AVR that stores negated 8 bit value | |
2724 | (high 8 bit of 16 bit command address) into 8 bit immediate value | |
2725 | of SUBI insn. | |
2726 | ENUM | |
2727 | BFD_RELOC_AVR_HH8_LDI_PM_NEG | |
2728 | ENUMDOC | |
2729 | This is a 16 bit reloc for the AVR that stores negated 8 bit value | |
2730 | (high 6 bit of 22 bit command address) into 8 bit immediate | |
2731 | value of SUBI insn. | |
2732 | ENUM | |
2733 | BFD_RELOC_AVR_CALL | |
2734 | ENUMDOC | |
2735 | This is a 32 bit reloc for the AVR that stores 23 bit value | |
2736 | into 22 bits. | |
2737 | ||
252b5132 RH |
2738 | ENUM |
2739 | BFD_RELOC_VTABLE_INHERIT | |
2740 | ENUMX | |
2741 | BFD_RELOC_VTABLE_ENTRY | |
2742 | ENUMDOC | |
88b6bae0 | 2743 | These two relocations are used by the linker to determine which of |
252b5132 RH |
2744 | the entries in a C++ virtual function table are actually used. When |
2745 | the --gc-sections option is given, the linker will zero out the entries | |
2746 | that are not used, so that the code for those functions need not be | |
2747 | included in the output. | |
2748 | ||
2749 | VTABLE_INHERIT is a zero-space relocation used to describe to the | |
2750 | linker the inheritence tree of a C++ virtual function table. The | |
2751 | relocation's symbol should be the parent class' vtable, and the | |
2752 | relocation should be located at the child vtable. | |
2753 | ||
2754 | VTABLE_ENTRY is a zero-space relocation that describes the use of a | |
2755 | virtual function table entry. The reloc's symbol should refer to the | |
2756 | table of the class mentioned in the code. Off of that base, an offset | |
88b6bae0 | 2757 | describes the entry that is being used. For Rela hosts, this offset |
252b5132 RH |
2758 | is stored in the reloc's addend. For Rel hosts, we are forced to put |
2759 | this offset in the reloc's section offset. | |
2760 | ||
800eeca4 JW |
2761 | ENUM |
2762 | BFD_RELOC_IA64_IMM14 | |
2763 | ENUMX | |
2764 | BFD_RELOC_IA64_IMM22 | |
2765 | ENUMX | |
2766 | BFD_RELOC_IA64_IMM64 | |
2767 | ENUMX | |
2768 | BFD_RELOC_IA64_DIR32MSB | |
2769 | ENUMX | |
2770 | BFD_RELOC_IA64_DIR32LSB | |
2771 | ENUMX | |
2772 | BFD_RELOC_IA64_DIR64MSB | |
2773 | ENUMX | |
2774 | BFD_RELOC_IA64_DIR64LSB | |
2775 | ENUMX | |
2776 | BFD_RELOC_IA64_GPREL22 | |
2777 | ENUMX | |
2778 | BFD_RELOC_IA64_GPREL64I | |
2779 | ENUMX | |
2780 | BFD_RELOC_IA64_GPREL32MSB | |
2781 | ENUMX | |
2782 | BFD_RELOC_IA64_GPREL32LSB | |
2783 | ENUMX | |
2784 | BFD_RELOC_IA64_GPREL64MSB | |
2785 | ENUMX | |
2786 | BFD_RELOC_IA64_GPREL64LSB | |
2787 | ENUMX | |
2788 | BFD_RELOC_IA64_LTOFF22 | |
2789 | ENUMX | |
2790 | BFD_RELOC_IA64_LTOFF64I | |
2791 | ENUMX | |
2792 | BFD_RELOC_IA64_PLTOFF22 | |
2793 | ENUMX | |
2794 | BFD_RELOC_IA64_PLTOFF64I | |
2795 | ENUMX | |
2796 | BFD_RELOC_IA64_PLTOFF64MSB | |
2797 | ENUMX | |
2798 | BFD_RELOC_IA64_PLTOFF64LSB | |
2799 | ENUMX | |
2800 | BFD_RELOC_IA64_FPTR64I | |
2801 | ENUMX | |
2802 | BFD_RELOC_IA64_FPTR32MSB | |
2803 | ENUMX | |
2804 | BFD_RELOC_IA64_FPTR32LSB | |
2805 | ENUMX | |
2806 | BFD_RELOC_IA64_FPTR64MSB | |
2807 | ENUMX | |
2808 | BFD_RELOC_IA64_FPTR64LSB | |
2809 | ENUMX | |
2810 | BFD_RELOC_IA64_PCREL21B | |
748abff6 RH |
2811 | ENUMX |
2812 | BFD_RELOC_IA64_PCREL21BI | |
800eeca4 JW |
2813 | ENUMX |
2814 | BFD_RELOC_IA64_PCREL21M | |
2815 | ENUMX | |
2816 | BFD_RELOC_IA64_PCREL21F | |
748abff6 RH |
2817 | ENUMX |
2818 | BFD_RELOC_IA64_PCREL22 | |
2819 | ENUMX | |
2820 | BFD_RELOC_IA64_PCREL60B | |
2821 | ENUMX | |
2822 | BFD_RELOC_IA64_PCREL64I | |
800eeca4 JW |
2823 | ENUMX |
2824 | BFD_RELOC_IA64_PCREL32MSB | |
2825 | ENUMX | |
2826 | BFD_RELOC_IA64_PCREL32LSB | |
2827 | ENUMX | |
2828 | BFD_RELOC_IA64_PCREL64MSB | |
2829 | ENUMX | |
2830 | BFD_RELOC_IA64_PCREL64LSB | |
2831 | ENUMX | |
2832 | BFD_RELOC_IA64_LTOFF_FPTR22 | |
2833 | ENUMX | |
2834 | BFD_RELOC_IA64_LTOFF_FPTR64I | |
2835 | ENUMX | |
2836 | BFD_RELOC_IA64_LTOFF_FPTR64MSB | |
2837 | ENUMX | |
2838 | BFD_RELOC_IA64_LTOFF_FPTR64LSB | |
800eeca4 JW |
2839 | ENUMX |
2840 | BFD_RELOC_IA64_SEGREL32MSB | |
2841 | ENUMX | |
2842 | BFD_RELOC_IA64_SEGREL32LSB | |
2843 | ENUMX | |
2844 | BFD_RELOC_IA64_SEGREL64MSB | |
2845 | ENUMX | |
2846 | BFD_RELOC_IA64_SEGREL64LSB | |
2847 | ENUMX | |
2848 | BFD_RELOC_IA64_SECREL32MSB | |
2849 | ENUMX | |
2850 | BFD_RELOC_IA64_SECREL32LSB | |
2851 | ENUMX | |
2852 | BFD_RELOC_IA64_SECREL64MSB | |
2853 | ENUMX | |
2854 | BFD_RELOC_IA64_SECREL64LSB | |
2855 | ENUMX | |
2856 | BFD_RELOC_IA64_REL32MSB | |
2857 | ENUMX | |
2858 | BFD_RELOC_IA64_REL32LSB | |
2859 | ENUMX | |
2860 | BFD_RELOC_IA64_REL64MSB | |
2861 | ENUMX | |
2862 | BFD_RELOC_IA64_REL64LSB | |
2863 | ENUMX | |
2864 | BFD_RELOC_IA64_LTV32MSB | |
2865 | ENUMX | |
2866 | BFD_RELOC_IA64_LTV32LSB | |
2867 | ENUMX | |
2868 | BFD_RELOC_IA64_LTV64MSB | |
2869 | ENUMX | |
2870 | BFD_RELOC_IA64_LTV64LSB | |
2871 | ENUMX | |
2872 | BFD_RELOC_IA64_IPLTMSB | |
2873 | ENUMX | |
2874 | BFD_RELOC_IA64_IPLTLSB | |
800eeca4 JW |
2875 | ENUMX |
2876 | BFD_RELOC_IA64_COPY | |
2877 | ENUMX | |
2878 | BFD_RELOC_IA64_TPREL22 | |
2879 | ENUMX | |
2880 | BFD_RELOC_IA64_TPREL64MSB | |
2881 | ENUMX | |
2882 | BFD_RELOC_IA64_TPREL64LSB | |
2883 | ENUMX | |
2884 | BFD_RELOC_IA64_LTOFF_TP22 | |
2885 | ENUMX | |
2886 | BFD_RELOC_IA64_LTOFF22X | |
2887 | ENUMX | |
2888 | BFD_RELOC_IA64_LDXMOV | |
2889 | ENUMDOC | |
2890 | Intel IA64 Relocations. | |
60bcf0fa NC |
2891 | |
2892 | ENUM | |
2893 | BFD_RELOC_M68HC11_HI8 | |
2894 | ENUMDOC | |
2895 | Motorola 68HC11 reloc. | |
2896 | This is the 8 bits high part of an absolute address. | |
2897 | ENUM | |
2898 | BFD_RELOC_M68HC11_LO8 | |
2899 | ENUMDOC | |
2900 | Motorola 68HC11 reloc. | |
2901 | This is the 8 bits low part of an absolute address. | |
2902 | ENUM | |
2903 | BFD_RELOC_M68HC11_3B | |
2904 | ENUMDOC | |
2905 | Motorola 68HC11 reloc. | |
2906 | This is the 3 bits of a value. | |
2907 | ||
06c15ad7 HPN |
2908 | ENUM |
2909 | BFD_RELOC_CRIS_BDISP8 | |
2910 | ENUMX | |
2911 | BFD_RELOC_CRIS_UNSIGNED_5 | |
2912 | ENUMX | |
2913 | BFD_RELOC_CRIS_SIGNED_6 | |
2914 | ENUMX | |
2915 | BFD_RELOC_CRIS_UNSIGNED_6 | |
2916 | ENUMX | |
2917 | BFD_RELOC_CRIS_UNSIGNED_4 | |
2918 | ENUMDOC | |
2919 | These relocs are only used within the CRIS assembler. They are not | |
2920 | (at present) written to any object files. | |
2921 | ||
a87fdb8d JE |
2922 | ENUM |
2923 | BFD_RELOC_860_COPY | |
2924 | ENUMX | |
2925 | BFD_RELOC_860_GLOB_DAT | |
2926 | ENUMX | |
2927 | BFD_RELOC_860_JUMP_SLOT | |
2928 | ENUMX | |
2929 | BFD_RELOC_860_RELATIVE | |
2930 | ENUMX | |
2931 | BFD_RELOC_860_PC26 | |
2932 | ENUMX | |
2933 | BFD_RELOC_860_PLT26 | |
2934 | ENUMX | |
2935 | BFD_RELOC_860_PC16 | |
2936 | ENUMX | |
2937 | BFD_RELOC_860_LOW0 | |
2938 | ENUMX | |
2939 | BFD_RELOC_860_SPLIT0 | |
2940 | ENUMX | |
2941 | BFD_RELOC_860_LOW1 | |
2942 | ENUMX | |
2943 | BFD_RELOC_860_SPLIT1 | |
2944 | ENUMX | |
2945 | BFD_RELOC_860_LOW2 | |
2946 | ENUMX | |
2947 | BFD_RELOC_860_SPLIT2 | |
2948 | ENUMX | |
2949 | BFD_RELOC_860_LOW3 | |
2950 | ENUMX | |
2951 | BFD_RELOC_860_LOGOT0 | |
2952 | ENUMX | |
2953 | BFD_RELOC_860_SPGOT0 | |
2954 | ENUMX | |
2955 | BFD_RELOC_860_LOGOT1 | |
2956 | ENUMX | |
2957 | BFD_RELOC_860_SPGOT1 | |
2958 | ENUMX | |
2959 | BFD_RELOC_860_LOGOTOFF0 | |
2960 | ENUMX | |
2961 | BFD_RELOC_860_SPGOTOFF0 | |
2962 | ENUMX | |
2963 | BFD_RELOC_860_LOGOTOFF1 | |
2964 | ENUMX | |
2965 | BFD_RELOC_860_SPGOTOFF1 | |
2966 | ENUMX | |
2967 | BFD_RELOC_860_LOGOTOFF2 | |
2968 | ENUMX | |
2969 | BFD_RELOC_860_LOGOTOFF3 | |
2970 | ENUMX | |
2971 | BFD_RELOC_860_LOPC | |
2972 | ENUMX | |
2973 | BFD_RELOC_860_HIGHADJ | |
2974 | ENUMX | |
2975 | BFD_RELOC_860_HAGOT | |
2976 | ENUMX | |
2977 | BFD_RELOC_860_HAGOTOFF | |
2978 | ENUMX | |
2979 | BFD_RELOC_860_HAPC | |
2980 | ENUMX | |
2981 | BFD_RELOC_860_HIGH | |
2982 | ENUMX | |
2983 | BFD_RELOC_860_HIGOT | |
2984 | ENUMX | |
2985 | BFD_RELOC_860_HIGOTOFF | |
2986 | ENUMDOC | |
2987 | Intel i860 Relocations. | |
2988 | ||
252b5132 RH |
2989 | ENDSENUM |
2990 | BFD_RELOC_UNUSED | |
2991 | CODE_FRAGMENT | |
2992 | . | |
2993 | .typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; | |
2994 | */ | |
2995 | ||
252b5132 RH |
2996 | /* |
2997 | FUNCTION | |
2998 | bfd_reloc_type_lookup | |
2999 | ||
3000 | SYNOPSIS | |
3001 | reloc_howto_type * | |
3002 | bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code); | |
3003 | ||
3004 | DESCRIPTION | |
3005 | Return a pointer to a howto structure which, when | |
3006 | invoked, will perform the relocation @var{code} on data from the | |
3007 | architecture noted. | |
3008 | ||
3009 | */ | |
3010 | ||
252b5132 RH |
3011 | reloc_howto_type * |
3012 | bfd_reloc_type_lookup (abfd, code) | |
3013 | bfd *abfd; | |
3014 | bfd_reloc_code_real_type code; | |
3015 | { | |
3016 | return BFD_SEND (abfd, reloc_type_lookup, (abfd, code)); | |
3017 | } | |
3018 | ||
3019 | static reloc_howto_type bfd_howto_32 = | |
3020 | HOWTO (0, 00, 2, 32, false, 0, complain_overflow_bitfield, 0, "VRT32", false, 0xffffffff, 0xffffffff, true); | |
3021 | ||
252b5132 RH |
3022 | /* |
3023 | INTERNAL_FUNCTION | |
3024 | bfd_default_reloc_type_lookup | |
3025 | ||
3026 | SYNOPSIS | |
3027 | reloc_howto_type *bfd_default_reloc_type_lookup | |
3028 | (bfd *abfd, bfd_reloc_code_real_type code); | |
3029 | ||
3030 | DESCRIPTION | |
3031 | Provides a default relocation lookup routine for any architecture. | |
3032 | ||
252b5132 RH |
3033 | */ |
3034 | ||
3035 | reloc_howto_type * | |
3036 | bfd_default_reloc_type_lookup (abfd, code) | |
3037 | bfd *abfd; | |
3038 | bfd_reloc_code_real_type code; | |
3039 | { | |
3040 | switch (code) | |
3041 | { | |
3042 | case BFD_RELOC_CTOR: | |
3043 | /* The type of reloc used in a ctor, which will be as wide as the | |
3044 | address - so either a 64, 32, or 16 bitter. */ | |
3045 | switch (bfd_get_arch_info (abfd)->bits_per_address) | |
3046 | { | |
3047 | case 64: | |
3048 | BFD_FAIL (); | |
3049 | case 32: | |
3050 | return &bfd_howto_32; | |
3051 | case 16: | |
3052 | BFD_FAIL (); | |
3053 | default: | |
3054 | BFD_FAIL (); | |
3055 | } | |
3056 | default: | |
3057 | BFD_FAIL (); | |
3058 | } | |
3059 | return (reloc_howto_type *) NULL; | |
3060 | } | |
3061 | ||
3062 | /* | |
3063 | FUNCTION | |
3064 | bfd_get_reloc_code_name | |
3065 | ||
3066 | SYNOPSIS | |
3067 | const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code); | |
3068 | ||
3069 | DESCRIPTION | |
3070 | Provides a printable name for the supplied relocation code. | |
3071 | Useful mainly for printing error messages. | |
3072 | */ | |
3073 | ||
3074 | const char * | |
3075 | bfd_get_reloc_code_name (code) | |
3076 | bfd_reloc_code_real_type code; | |
3077 | { | |
3078 | if (code > BFD_RELOC_UNUSED) | |
3079 | return 0; | |
3080 | return bfd_reloc_code_real_names[(int)code]; | |
3081 | } | |
3082 | ||
3083 | /* | |
3084 | INTERNAL_FUNCTION | |
3085 | bfd_generic_relax_section | |
3086 | ||
3087 | SYNOPSIS | |
3088 | boolean bfd_generic_relax_section | |
3089 | (bfd *abfd, | |
3090 | asection *section, | |
3091 | struct bfd_link_info *, | |
3092 | boolean *); | |
3093 | ||
3094 | DESCRIPTION | |
3095 | Provides default handling for relaxing for back ends which | |
3096 | don't do relaxing -- i.e., does nothing. | |
3097 | */ | |
3098 | ||
3099 | /*ARGSUSED*/ | |
3100 | boolean | |
3101 | bfd_generic_relax_section (abfd, section, link_info, again) | |
7442e600 ILT |
3102 | bfd *abfd ATTRIBUTE_UNUSED; |
3103 | asection *section ATTRIBUTE_UNUSED; | |
3104 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED; | |
252b5132 RH |
3105 | boolean *again; |
3106 | { | |
3107 | *again = false; | |
3108 | return true; | |
3109 | } | |
3110 | ||
3111 | /* | |
3112 | INTERNAL_FUNCTION | |
3113 | bfd_generic_gc_sections | |
3114 | ||
3115 | SYNOPSIS | |
3116 | boolean bfd_generic_gc_sections | |
3117 | (bfd *, struct bfd_link_info *); | |
3118 | ||
3119 | DESCRIPTION | |
3120 | Provides default handling for relaxing for back ends which | |
3121 | don't do section gc -- i.e., does nothing. | |
3122 | */ | |
3123 | ||
3124 | /*ARGSUSED*/ | |
3125 | boolean | |
3126 | bfd_generic_gc_sections (abfd, link_info) | |
7442e600 ILT |
3127 | bfd *abfd ATTRIBUTE_UNUSED; |
3128 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED; | |
252b5132 RH |
3129 | { |
3130 | return true; | |
3131 | } | |
3132 | ||
3133 | /* | |
3134 | INTERNAL_FUNCTION | |
3135 | bfd_generic_get_relocated_section_contents | |
3136 | ||
3137 | SYNOPSIS | |
3138 | bfd_byte * | |
3139 | bfd_generic_get_relocated_section_contents (bfd *abfd, | |
3140 | struct bfd_link_info *link_info, | |
3141 | struct bfd_link_order *link_order, | |
3142 | bfd_byte *data, | |
3143 | boolean relocateable, | |
3144 | asymbol **symbols); | |
3145 | ||
3146 | DESCRIPTION | |
3147 | Provides default handling of relocation effort for back ends | |
3148 | which can't be bothered to do it efficiently. | |
3149 | ||
3150 | */ | |
3151 | ||
3152 | bfd_byte * | |
3153 | bfd_generic_get_relocated_section_contents (abfd, link_info, link_order, data, | |
3154 | relocateable, symbols) | |
3155 | bfd *abfd; | |
3156 | struct bfd_link_info *link_info; | |
3157 | struct bfd_link_order *link_order; | |
3158 | bfd_byte *data; | |
3159 | boolean relocateable; | |
3160 | asymbol **symbols; | |
3161 | { | |
3162 | /* Get enough memory to hold the stuff */ | |
3163 | bfd *input_bfd = link_order->u.indirect.section->owner; | |
3164 | asection *input_section = link_order->u.indirect.section; | |
3165 | ||
3166 | long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); | |
3167 | arelent **reloc_vector = NULL; | |
3168 | long reloc_count; | |
3169 | ||
3170 | if (reloc_size < 0) | |
3171 | goto error_return; | |
3172 | ||
3173 | reloc_vector = (arelent **) bfd_malloc ((size_t) reloc_size); | |
3174 | if (reloc_vector == NULL && reloc_size != 0) | |
3175 | goto error_return; | |
3176 | ||
3177 | /* read in the section */ | |
3178 | if (!bfd_get_section_contents (input_bfd, | |
3179 | input_section, | |
3180 | (PTR) data, | |
3181 | 0, | |
3182 | input_section->_raw_size)) | |
3183 | goto error_return; | |
3184 | ||
3185 | /* We're not relaxing the section, so just copy the size info */ | |
3186 | input_section->_cooked_size = input_section->_raw_size; | |
3187 | input_section->reloc_done = true; | |
3188 | ||
3189 | reloc_count = bfd_canonicalize_reloc (input_bfd, | |
3190 | input_section, | |
3191 | reloc_vector, | |
3192 | symbols); | |
3193 | if (reloc_count < 0) | |
3194 | goto error_return; | |
3195 | ||
3196 | if (reloc_count > 0) | |
3197 | { | |
3198 | arelent **parent; | |
3199 | for (parent = reloc_vector; *parent != (arelent *) NULL; | |
3200 | parent++) | |
3201 | { | |
3202 | char *error_message = (char *) NULL; | |
3203 | bfd_reloc_status_type r = | |
3204 | bfd_perform_relocation (input_bfd, | |
3205 | *parent, | |
3206 | (PTR) data, | |
3207 | input_section, | |
3208 | relocateable ? abfd : (bfd *) NULL, | |
3209 | &error_message); | |
3210 | ||
3211 | if (relocateable) | |
3212 | { | |
3213 | asection *os = input_section->output_section; | |
3214 | ||
3215 | /* A partial link, so keep the relocs */ | |
3216 | os->orelocation[os->reloc_count] = *parent; | |
3217 | os->reloc_count++; | |
3218 | } | |
3219 | ||
3220 | if (r != bfd_reloc_ok) | |
3221 | { | |
3222 | switch (r) | |
3223 | { | |
3224 | case bfd_reloc_undefined: | |
3225 | if (!((*link_info->callbacks->undefined_symbol) | |
3226 | (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr), | |
5cc7c785 L |
3227 | input_bfd, input_section, (*parent)->address, |
3228 | true))) | |
252b5132 RH |
3229 | goto error_return; |
3230 | break; | |
3231 | case bfd_reloc_dangerous: | |
3232 | BFD_ASSERT (error_message != (char *) NULL); | |
3233 | if (!((*link_info->callbacks->reloc_dangerous) | |
3234 | (link_info, error_message, input_bfd, input_section, | |
3235 | (*parent)->address))) | |
3236 | goto error_return; | |
3237 | break; | |
3238 | case bfd_reloc_overflow: | |
3239 | if (!((*link_info->callbacks->reloc_overflow) | |
3240 | (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr), | |
3241 | (*parent)->howto->name, (*parent)->addend, | |
3242 | input_bfd, input_section, (*parent)->address))) | |
3243 | goto error_return; | |
3244 | break; | |
3245 | case bfd_reloc_outofrange: | |
3246 | default: | |
3247 | abort (); | |
3248 | break; | |
3249 | } | |
3250 | ||
3251 | } | |
3252 | } | |
3253 | } | |
3254 | if (reloc_vector != NULL) | |
3255 | free (reloc_vector); | |
3256 | return data; | |
3257 | ||
3258 | error_return: | |
3259 | if (reloc_vector != NULL) | |
3260 | free (reloc_vector); | |
3261 | return NULL; | |
3262 | } |