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