1 /* BFD support for handling relocation entries.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 Free Software Foundation, Inc.
5 Written by Cygnus Support.
7 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
27 BFD maintains relocations in much the same way it maintains
28 symbols: they are left alone until required, then read in
29 en-masse and translated into an internal form. A common
30 routine <<bfd_perform_relocation>> acts upon the
31 canonical form to do the fixup.
33 Relocations are maintained on a per section basis,
34 while symbols are maintained on a per BFD basis.
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.
47 /* DO compile in the reloc_code name table from libbfd.h. */
48 #define _BFD_MAKE_TABLE_bfd_reloc_code_real
57 typedef arelent, howto manager, Relocations, Relocations
62 This is the structure of a relocation entry:
66 .typedef enum bfd_reloc_status
68 . {* No errors detected *}
71 . {* The relocation was performed, but there was an overflow. *}
74 . {* The address to relocate was not within the section supplied. *}
75 . bfd_reloc_outofrange,
77 . {* Used by special functions *}
80 . {* Unsupported relocation size requested. *}
81 . bfd_reloc_notsupported,
86 . {* The symbol to relocate against was undefined. *}
87 . bfd_reloc_undefined,
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. *}
95 . bfd_reloc_status_type;
98 .typedef struct reloc_cache_entry
100 . {* A pointer into the canonical table of pointers *}
101 . struct symbol_cache_entry **sym_ptr_ptr;
103 . {* offset in section *}
104 . bfd_size_type address;
106 . {* addend for relocation value *}
109 . {* Pointer to how to perform the required relocation *}
110 . reloc_howto_type *howto;
119 Here is a description of each of the fields within an <<arelent>>:
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.
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
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:
153 | return foo[0x12345678];
156 Could be compiled into:
159 | moveb @@#12345678,d0
164 This could create a reloc pointing to <<foo>>, but leave the
165 offset in the data, something like:
167 |RELOCATION RECORDS FOR [.text]:
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
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:
181 | or.u r13,r0,hi16(_foo+0x12345678)
182 | ld.b r2,r13,lo16(_foo+0x12345678)
185 This should create two relocs, both pointing to <<_foo>>, and with
186 0x12340000 in their addend field. The data would consist of:
188 |RELOCATION RECORDS FOR [.text]:
190 |00000002 HVRT16 _foo+0x12340000
191 |00000006 LVRT16 _foo+0x12340000
193 |00000000 5da05678 ; or.u r13,r0,0x5678
194 |00000004 1c4d5678 ; ld.b r2,r13,0x5678
195 |00000008 f400c001 ; jmp r1
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.
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.
211 | sethi %hi(_foo+0x12345678),%g2
212 | ldsb [%g2+%lo(_foo+0x12345678)],%i0
216 Both relocs contain a pointer to <<foo>>, and the offsets
219 |RELOCATION RECORDS FOR [.text]:
221 |00000004 HI22 _foo+0x12345678
222 |00000008 LO10 _foo+0x12345678
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
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.
244 <<enum complain_overflow>>
246 Indicates what sort of overflow checking should be done when
247 performing a relocation.
251 .enum complain_overflow
253 . {* Do not complain on overflow. *}
254 . complain_overflow_dont,
256 . {* Complain if the bitfield overflows, whether it is considered
257 . as signed or unsigned. *}
258 . complain_overflow_bitfield,
260 . {* Complain if the value overflows when considered as signed
262 . complain_overflow_signed,
264 . {* Complain if the value overflows when considered as an
265 . unsigned number. *}
266 . complain_overflow_unsigned
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.
279 .struct symbol_cache_entry; {* Forward declaration *}
281 .struct reloc_howto_struct
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. *}
291 . {* The value the final relocation is shifted right by. This drops
292 . unwanted data from the relocation. *}
293 . unsigned int rightshift;
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. *}
300 . {* The number of bits in the item to be relocated. This is used
301 . when doing overflow checking. *}
302 . unsigned int bitsize;
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;
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;
314 . {* What type of overflow error should be checked for when
316 . enum complain_overflow complain_on_overflow;
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
322 . bfd_reloc_status_type (*special_function)
323 . PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR, asection *,
326 . {* The textual name of the relocation type. *}
329 . {* Some formats record a relocation addend in the section contents
330 . rather than with the relocation. For ELF formats this is the
331 . distinction between USE_REL and USE_RELA (though the code checks
332 . for USE_REL == 1/0). The value of this field is TRUE if the
333 . addend is recorded with the section contents; when performing a
334 . partial link (ld -r) the section contents (the data) will be
335 . modified. The value of this field is FALSE if addends are
336 . recorded with the relocation (in arelent.addend); when performing
337 . a partial link the relocation will be modified.
338 . All relocations for all ELF USE_RELA targets should set this field
339 . to FALSE (values of TRUE should be looked on with suspicion).
340 . However, the converse is not true: not all relocations of all ELF
341 . USE_REL targets set this field to TRUE. Why this is so is peculiar
342 . to each particular target. For relocs that aren't used in partial
343 . links (e.g. GOT stuff) it doesn't matter what this is set to. *}
344 . boolean partial_inplace;
346 . {* The src_mask selects which parts of the read in data
347 . are to be used in the relocation sum. E.g., if this was an 8 bit
348 . byte of data which we read and relocated, this would be
349 . 0x000000ff. When we have relocs which have an addend, such as
350 . sun4 extended relocs, the value in the offset part of a
351 . relocating field is garbage so we never use it. In this case
352 . the mask would be 0x00000000. *}
355 . {* The dst_mask selects which parts of the instruction are replaced
356 . into the instruction. In most cases src_mask == dst_mask,
357 . except in the above special case, where dst_mask would be
358 . 0x000000ff, and src_mask would be 0x00000000. *}
361 . {* When some formats create PC relative instructions, they leave
362 . the value of the pc of the place being relocated in the offset
363 . slot of the instruction, so that a PC relative relocation can
364 . be made just by adding in an ordinary offset (e.g., sun3 a.out).
365 . Some formats leave the displacement part of an instruction
366 . empty (e.g., m88k bcs); this flag signals the fact. *}
367 . boolean pcrel_offset;
377 The HOWTO define is horrible and will go away.
379 .#define HOWTO(C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
380 . { (unsigned) C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC }
383 And will be replaced with the totally magic way. But for the
384 moment, we are compatible, so do it this way.
386 .#define NEWHOWTO(FUNCTION, NAME, SIZE, REL, IN) \
387 . HOWTO (0, 0, SIZE, 0, REL, 0, complain_overflow_dont, FUNCTION, \
388 . NAME, false, 0, 0, IN)
392 This is used to fill in an empty howto entry in an array.
394 .#define EMPTY_HOWTO(C) \
395 . HOWTO ((C), 0, 0, 0, false, 0, complain_overflow_dont, NULL, \
396 . NULL, false, 0, 0, false)
400 Helper routine to turn a symbol into a relocation value.
402 .#define HOWTO_PREPARE(relocation, symbol) \
404 . if (symbol != (asymbol *) NULL) \
406 . if (bfd_is_com_section (symbol->section)) \
412 . relocation = symbol->value; \
424 unsigned int bfd_get_reloc_size (reloc_howto_type *);
427 For a reloc_howto_type that operates on a fixed number of bytes,
428 this returns the number of bytes operated on.
432 bfd_get_reloc_size (howto
)
433 reloc_howto_type
*howto
;
454 How relocs are tied together in an <<asection>>:
456 .typedef struct relent_chain
459 . struct relent_chain *next;
464 /* N_ONES produces N one bits, without overflowing machine arithmetic. */
465 #define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1)
472 bfd_reloc_status_type
474 (enum complain_overflow how,
475 unsigned int bitsize,
476 unsigned int rightshift,
477 unsigned int addrsize,
481 Perform overflow checking on @var{relocation} which has
482 @var{bitsize} significant bits and will be shifted right by
483 @var{rightshift} bits, on a machine with addresses containing
484 @var{addrsize} significant bits. The result is either of
485 @code{bfd_reloc_ok} or @code{bfd_reloc_overflow}.
489 bfd_reloc_status_type
490 bfd_check_overflow (how
, bitsize
, rightshift
, addrsize
, relocation
)
491 enum complain_overflow how
;
492 unsigned int bitsize
;
493 unsigned int rightshift
;
494 unsigned int addrsize
;
497 bfd_vma fieldmask
, addrmask
, signmask
, ss
, a
;
498 bfd_reloc_status_type flag
= bfd_reloc_ok
;
502 /* Note: BITSIZE should always be <= ADDRSIZE, but in case it's not,
503 we'll be permissive: extra bits in the field mask will
504 automatically extend the address mask for purposes of the
506 fieldmask
= N_ONES (bitsize
);
507 addrmask
= N_ONES (addrsize
) | fieldmask
;
511 case complain_overflow_dont
:
514 case complain_overflow_signed
:
515 /* If any sign bits are set, all sign bits must be set. That
516 is, A must be a valid negative address after shifting. */
517 a
= (a
& addrmask
) >> rightshift
;
518 signmask
= ~ (fieldmask
>> 1);
520 if (ss
!= 0 && ss
!= ((addrmask
>> rightshift
) & signmask
))
521 flag
= bfd_reloc_overflow
;
524 case complain_overflow_unsigned
:
525 /* We have an overflow if the address does not fit in the field. */
526 a
= (a
& addrmask
) >> rightshift
;
527 if ((a
& ~ fieldmask
) != 0)
528 flag
= bfd_reloc_overflow
;
531 case complain_overflow_bitfield
:
532 /* Bitfields are sometimes signed, sometimes unsigned. We
533 explicitly allow an address wrap too, which means a bitfield
534 of n bits is allowed to store -2**n to 2**n-1. Thus overflow
535 if the value has some, but not all, bits set outside the
538 ss
= a
& ~ fieldmask
;
539 if (ss
!= 0 && ss
!= (((bfd_vma
) -1 >> rightshift
) & ~ fieldmask
))
540 flag
= bfd_reloc_overflow
;
552 bfd_perform_relocation
555 bfd_reloc_status_type
556 bfd_perform_relocation
558 arelent *reloc_entry,
560 asection *input_section,
562 char **error_message);
565 If @var{output_bfd} is supplied to this function, the
566 generated image will be relocatable; the relocations are
567 copied to the output file after they have been changed to
568 reflect the new state of the world. There are two ways of
569 reflecting the results of partial linkage in an output file:
570 by modifying the output data in place, and by modifying the
571 relocation record. Some native formats (e.g., basic a.out and
572 basic coff) have no way of specifying an addend in the
573 relocation type, so the addend has to go in the output data.
574 This is no big deal since in these formats the output data
575 slot will always be big enough for the addend. Complex reloc
576 types with addends were invented to solve just this problem.
577 The @var{error_message} argument is set to an error message if
578 this return @code{bfd_reloc_dangerous}.
582 bfd_reloc_status_type
583 bfd_perform_relocation (abfd
, reloc_entry
, data
, input_section
, output_bfd
,
586 arelent
*reloc_entry
;
588 asection
*input_section
;
590 char **error_message
;
593 bfd_reloc_status_type flag
= bfd_reloc_ok
;
594 bfd_size_type octets
= reloc_entry
->address
* bfd_octets_per_byte (abfd
);
595 bfd_vma output_base
= 0;
596 reloc_howto_type
*howto
= reloc_entry
->howto
;
597 asection
*reloc_target_output_section
;
600 symbol
= *(reloc_entry
->sym_ptr_ptr
);
601 if (bfd_is_abs_section (symbol
->section
)
602 && output_bfd
!= (bfd
*) NULL
)
604 reloc_entry
->address
+= input_section
->output_offset
;
608 /* If we are not producing relocateable output, return an error if
609 the symbol is not defined. An undefined weak symbol is
610 considered to have a value of zero (SVR4 ABI, p. 4-27). */
611 if (bfd_is_und_section (symbol
->section
)
612 && (symbol
->flags
& BSF_WEAK
) == 0
613 && output_bfd
== (bfd
*) NULL
)
614 flag
= bfd_reloc_undefined
;
616 /* If there is a function supplied to handle this relocation type,
617 call it. It'll return `bfd_reloc_continue' if further processing
619 if (howto
->special_function
)
621 bfd_reloc_status_type cont
;
622 cont
= howto
->special_function (abfd
, reloc_entry
, symbol
, data
,
623 input_section
, output_bfd
,
625 if (cont
!= bfd_reloc_continue
)
629 /* Is the address of the relocation really within the section? */
630 if (reloc_entry
->address
> (input_section
->_cooked_size
631 / bfd_octets_per_byte (abfd
)))
632 return bfd_reloc_outofrange
;
634 /* Work out which section the relocation is targetted at and the
635 initial relocation command value. */
637 /* Get symbol value. (Common symbols are special.) */
638 if (bfd_is_com_section (symbol
->section
))
641 relocation
= symbol
->value
;
643 reloc_target_output_section
= symbol
->section
->output_section
;
645 /* Convert input-section-relative symbol value to absolute. */
646 if (output_bfd
&& howto
->partial_inplace
== false)
649 output_base
= reloc_target_output_section
->vma
;
651 relocation
+= output_base
+ symbol
->section
->output_offset
;
653 /* Add in supplied addend. */
654 relocation
+= reloc_entry
->addend
;
656 /* Here the variable relocation holds the final address of the
657 symbol we are relocating against, plus any addend. */
659 if (howto
->pc_relative
== true)
661 /* This is a PC relative relocation. We want to set RELOCATION
662 to the distance between the address of the symbol and the
663 location. RELOCATION is already the address of the symbol.
665 We start by subtracting the address of the section containing
668 If pcrel_offset is set, we must further subtract the position
669 of the location within the section. Some targets arrange for
670 the addend to be the negative of the position of the location
671 within the section; for example, i386-aout does this. For
672 i386-aout, pcrel_offset is false. Some other targets do not
673 include the position of the location; for example, m88kbcs,
674 or ELF. For those targets, pcrel_offset is true.
676 If we are producing relocateable output, then we must ensure
677 that this reloc will be correctly computed when the final
678 relocation is done. If pcrel_offset is false we want to wind
679 up with the negative of the location within the section,
680 which means we must adjust the existing addend by the change
681 in the location within the section. If pcrel_offset is true
682 we do not want to adjust the existing addend at all.
684 FIXME: This seems logical to me, but for the case of
685 producing relocateable output it is not what the code
686 actually does. I don't want to change it, because it seems
687 far too likely that something will break. */
690 input_section
->output_section
->vma
+ input_section
->output_offset
;
692 if (howto
->pcrel_offset
== true)
693 relocation
-= reloc_entry
->address
;
696 if (output_bfd
!= (bfd
*) NULL
)
698 if (howto
->partial_inplace
== false)
700 /* This is a partial relocation, and we want to apply the relocation
701 to the reloc entry rather than the raw data. Modify the reloc
702 inplace to reflect what we now know. */
703 reloc_entry
->addend
= relocation
;
704 reloc_entry
->address
+= input_section
->output_offset
;
709 /* This is a partial relocation, but inplace, so modify the
712 If we've relocated with a symbol with a section, change
713 into a ref to the section belonging to the symbol. */
715 reloc_entry
->address
+= input_section
->output_offset
;
718 if (abfd
->xvec
->flavour
== bfd_target_coff_flavour
719 && strcmp (abfd
->xvec
->name
, "coff-Intel-little") != 0
720 && strcmp (abfd
->xvec
->name
, "coff-Intel-big") != 0)
723 /* For m68k-coff, the addend was being subtracted twice during
724 relocation with -r. Removing the line below this comment
725 fixes that problem; see PR 2953.
727 However, Ian wrote the following, regarding removing the line below,
728 which explains why it is still enabled: --djm
730 If you put a patch like that into BFD you need to check all the COFF
731 linkers. I am fairly certain that patch will break coff-i386 (e.g.,
732 SCO); see coff_i386_reloc in coff-i386.c where I worked around the
733 problem in a different way. There may very well be a reason that the
734 code works as it does.
736 Hmmm. The first obvious point is that bfd_perform_relocation should
737 not have any tests that depend upon the flavour. It's seem like
738 entirely the wrong place for such a thing. The second obvious point
739 is that the current code ignores the reloc addend when producing
740 relocateable output for COFF. That's peculiar. In fact, I really
741 have no idea what the point of the line you want to remove is.
743 A typical COFF reloc subtracts the old value of the symbol and adds in
744 the new value to the location in the object file (if it's a pc
745 relative reloc it adds the difference between the symbol value and the
746 location). When relocating we need to preserve that property.
748 BFD handles this by setting the addend to the negative of the old
749 value of the symbol. Unfortunately it handles common symbols in a
750 non-standard way (it doesn't subtract the old value) but that's a
751 different story (we can't change it without losing backward
752 compatibility with old object files) (coff-i386 does subtract the old
753 value, to be compatible with existing coff-i386 targets, like SCO).
755 So everything works fine when not producing relocateable output. When
756 we are producing relocateable output, logically we should do exactly
757 what we do when not producing relocateable output. Therefore, your
758 patch is correct. In fact, it should probably always just set
759 reloc_entry->addend to 0 for all cases, since it is, in fact, going to
760 add the value into the object file. This won't hurt the COFF code,
761 which doesn't use the addend; I'm not sure what it will do to other
762 formats (the thing to check for would be whether any formats both use
763 the addend and set partial_inplace).
765 When I wanted to make coff-i386 produce relocateable output, I ran
766 into the problem that you are running into: I wanted to remove that
767 line. Rather than risk it, I made the coff-i386 relocs use a special
768 function; it's coff_i386_reloc in coff-i386.c. The function
769 specifically adds the addend field into the object file, knowing that
770 bfd_perform_relocation is not going to. If you remove that line, then
771 coff-i386.c will wind up adding the addend field in twice. It's
772 trivial to fix; it just needs to be done.
774 The problem with removing the line is just that it may break some
775 working code. With BFD it's hard to be sure of anything. The right
776 way to deal with this is simply to build and test at least all the
777 supported COFF targets. It should be straightforward if time and disk
778 space consuming. For each target:
780 2) generate some executable, and link it using -r (I would
781 probably use paranoia.o and link against newlib/libc.a, which
782 for all the supported targets would be available in
783 /usr/cygnus/progressive/H-host/target/lib/libc.a).
784 3) make the change to reloc.c
785 4) rebuild the linker
787 6) if the resulting object files are the same, you have at least
789 7) if they are different you have to figure out which version is
792 relocation
-= reloc_entry
->addend
;
794 reloc_entry
->addend
= 0;
798 reloc_entry
->addend
= relocation
;
804 reloc_entry
->addend
= 0;
807 /* FIXME: This overflow checking is incomplete, because the value
808 might have overflowed before we get here. For a correct check we
809 need to compute the value in a size larger than bitsize, but we
810 can't reasonably do that for a reloc the same size as a host
812 FIXME: We should also do overflow checking on the result after
813 adding in the value contained in the object file. */
814 if (howto
->complain_on_overflow
!= complain_overflow_dont
815 && flag
== bfd_reloc_ok
)
816 flag
= bfd_check_overflow (howto
->complain_on_overflow
,
819 bfd_arch_bits_per_address (abfd
),
823 Either we are relocating all the way, or we don't want to apply
824 the relocation to the reloc entry (probably because there isn't
825 any room in the output format to describe addends to relocs)
828 /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler
829 (OSF version 1.3, compiler version 3.11). It miscompiles the
843 x <<= (unsigned long) s.i0;
847 printf ("succeeded (%lx)\n", x);
851 relocation
>>= (bfd_vma
) howto
->rightshift
;
853 /* Shift everything up to where it's going to be used */
855 relocation
<<= (bfd_vma
) howto
->bitpos
;
857 /* Wait for the day when all have the mask in them */
860 i instruction to be left alone
861 o offset within instruction
862 r relocation offset to apply
871 (( i i i i i o o o o o from bfd_get<size>
872 and S S S S S) to get the size offset we want
873 + r r r r r r r r r r) to get the final value to place
874 and D D D D D to chop to right size
875 -----------------------
878 ( i i i i i o o o o o from bfd_get<size>
879 and N N N N N ) get instruction
880 -----------------------
886 -----------------------
887 = R R R R R R R R R R put into bfd_put<size>
891 x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
897 char x
= bfd_get_8 (abfd
, (char *) data
+ octets
);
899 bfd_put_8 (abfd
, x
, (unsigned char *) data
+ octets
);
905 short x
= bfd_get_16 (abfd
, (bfd_byte
*) data
+ octets
);
907 bfd_put_16 (abfd
, (bfd_vma
) x
, (unsigned char *) data
+ octets
);
912 long x
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ octets
);
914 bfd_put_32 (abfd
, (bfd_vma
) x
, (bfd_byte
*) data
+ octets
);
919 long x
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ octets
);
920 relocation
= -relocation
;
922 bfd_put_32 (abfd
, (bfd_vma
) x
, (bfd_byte
*) data
+ octets
);
928 long x
= bfd_get_16 (abfd
, (bfd_byte
*) data
+ octets
);
929 relocation
= -relocation
;
931 bfd_put_16 (abfd
, (bfd_vma
) x
, (bfd_byte
*) data
+ octets
);
942 bfd_vma x
= bfd_get_64 (abfd
, (bfd_byte
*) data
+ octets
);
944 bfd_put_64 (abfd
, x
, (bfd_byte
*) data
+ octets
);
951 return bfd_reloc_other
;
959 bfd_install_relocation
962 bfd_reloc_status_type
963 bfd_install_relocation
965 arelent *reloc_entry,
966 PTR data, bfd_vma data_start,
967 asection *input_section,
968 char **error_message);
971 This looks remarkably like <<bfd_perform_relocation>>, except it
972 does not expect that the section contents have been filled in.
973 I.e., it's suitable for use when creating, rather than applying
976 For now, this function should be considered reserved for the
981 bfd_reloc_status_type
982 bfd_install_relocation (abfd
, reloc_entry
, data_start
, data_start_offset
,
983 input_section
, error_message
)
985 arelent
*reloc_entry
;
987 bfd_vma data_start_offset
;
988 asection
*input_section
;
989 char **error_message
;
992 bfd_reloc_status_type flag
= bfd_reloc_ok
;
993 bfd_size_type octets
= reloc_entry
->address
* bfd_octets_per_byte (abfd
);
994 bfd_vma output_base
= 0;
995 reloc_howto_type
*howto
= reloc_entry
->howto
;
996 asection
*reloc_target_output_section
;
1000 symbol
= *(reloc_entry
->sym_ptr_ptr
);
1001 if (bfd_is_abs_section (symbol
->section
))
1003 reloc_entry
->address
+= input_section
->output_offset
;
1004 return bfd_reloc_ok
;
1007 /* If there is a function supplied to handle this relocation type,
1008 call it. It'll return `bfd_reloc_continue' if further processing
1010 if (howto
->special_function
)
1012 bfd_reloc_status_type cont
;
1014 /* XXX - The special_function calls haven't been fixed up to deal
1015 with creating new relocations and section contents. */
1016 cont
= howto
->special_function (abfd
, reloc_entry
, symbol
,
1017 /* XXX - Non-portable! */
1018 ((bfd_byte
*) data_start
1019 - data_start_offset
),
1020 input_section
, abfd
, error_message
);
1021 if (cont
!= bfd_reloc_continue
)
1025 /* Is the address of the relocation really within the section? */
1026 if (reloc_entry
->address
> (input_section
->_cooked_size
1027 / bfd_octets_per_byte (abfd
)))
1028 return bfd_reloc_outofrange
;
1030 /* Work out which section the relocation is targetted at and the
1031 initial relocation command value. */
1033 /* Get symbol value. (Common symbols are special.) */
1034 if (bfd_is_com_section (symbol
->section
))
1037 relocation
= symbol
->value
;
1039 reloc_target_output_section
= symbol
->section
->output_section
;
1041 /* Convert input-section-relative symbol value to absolute. */
1042 if (howto
->partial_inplace
== false)
1045 output_base
= reloc_target_output_section
->vma
;
1047 relocation
+= output_base
+ symbol
->section
->output_offset
;
1049 /* Add in supplied addend. */
1050 relocation
+= reloc_entry
->addend
;
1052 /* Here the variable relocation holds the final address of the
1053 symbol we are relocating against, plus any addend. */
1055 if (howto
->pc_relative
== true)
1057 /* This is a PC relative relocation. We want to set RELOCATION
1058 to the distance between the address of the symbol and the
1059 location. RELOCATION is already the address of the symbol.
1061 We start by subtracting the address of the section containing
1064 If pcrel_offset is set, we must further subtract the position
1065 of the location within the section. Some targets arrange for
1066 the addend to be the negative of the position of the location
1067 within the section; for example, i386-aout does this. For
1068 i386-aout, pcrel_offset is false. Some other targets do not
1069 include the position of the location; for example, m88kbcs,
1070 or ELF. For those targets, pcrel_offset is true.
1072 If we are producing relocateable output, then we must ensure
1073 that this reloc will be correctly computed when the final
1074 relocation is done. If pcrel_offset is false we want to wind
1075 up with the negative of the location within the section,
1076 which means we must adjust the existing addend by the change
1077 in the location within the section. If pcrel_offset is true
1078 we do not want to adjust the existing addend at all.
1080 FIXME: This seems logical to me, but for the case of
1081 producing relocateable output it is not what the code
1082 actually does. I don't want to change it, because it seems
1083 far too likely that something will break. */
1086 input_section
->output_section
->vma
+ input_section
->output_offset
;
1088 if (howto
->pcrel_offset
== true && howto
->partial_inplace
== true)
1089 relocation
-= reloc_entry
->address
;
1092 if (howto
->partial_inplace
== false)
1094 /* This is a partial relocation, and we want to apply the relocation
1095 to the reloc entry rather than the raw data. Modify the reloc
1096 inplace to reflect what we now know. */
1097 reloc_entry
->addend
= relocation
;
1098 reloc_entry
->address
+= input_section
->output_offset
;
1103 /* This is a partial relocation, but inplace, so modify the
1106 If we've relocated with a symbol with a section, change
1107 into a ref to the section belonging to the symbol. */
1109 reloc_entry
->address
+= input_section
->output_offset
;
1112 if (abfd
->xvec
->flavour
== bfd_target_coff_flavour
1113 && strcmp (abfd
->xvec
->name
, "coff-Intel-little") != 0
1114 && strcmp (abfd
->xvec
->name
, "coff-Intel-big") != 0)
1117 /* For m68k-coff, the addend was being subtracted twice during
1118 relocation with -r. Removing the line below this comment
1119 fixes that problem; see PR 2953.
1121 However, Ian wrote the following, regarding removing the line below,
1122 which explains why it is still enabled: --djm
1124 If you put a patch like that into BFD you need to check all the COFF
1125 linkers. I am fairly certain that patch will break coff-i386 (e.g.,
1126 SCO); see coff_i386_reloc in coff-i386.c where I worked around the
1127 problem in a different way. There may very well be a reason that the
1128 code works as it does.
1130 Hmmm. The first obvious point is that bfd_install_relocation should
1131 not have any tests that depend upon the flavour. It's seem like
1132 entirely the wrong place for such a thing. The second obvious point
1133 is that the current code ignores the reloc addend when producing
1134 relocateable output for COFF. That's peculiar. In fact, I really
1135 have no idea what the point of the line you want to remove is.
1137 A typical COFF reloc subtracts the old value of the symbol and adds in
1138 the new value to the location in the object file (if it's a pc
1139 relative reloc it adds the difference between the symbol value and the
1140 location). When relocating we need to preserve that property.
1142 BFD handles this by setting the addend to the negative of the old
1143 value of the symbol. Unfortunately it handles common symbols in a
1144 non-standard way (it doesn't subtract the old value) but that's a
1145 different story (we can't change it without losing backward
1146 compatibility with old object files) (coff-i386 does subtract the old
1147 value, to be compatible with existing coff-i386 targets, like SCO).
1149 So everything works fine when not producing relocateable output. When
1150 we are producing relocateable output, logically we should do exactly
1151 what we do when not producing relocateable output. Therefore, your
1152 patch is correct. In fact, it should probably always just set
1153 reloc_entry->addend to 0 for all cases, since it is, in fact, going to
1154 add the value into the object file. This won't hurt the COFF code,
1155 which doesn't use the addend; I'm not sure what it will do to other
1156 formats (the thing to check for would be whether any formats both use
1157 the addend and set partial_inplace).
1159 When I wanted to make coff-i386 produce relocateable output, I ran
1160 into the problem that you are running into: I wanted to remove that
1161 line. Rather than risk it, I made the coff-i386 relocs use a special
1162 function; it's coff_i386_reloc in coff-i386.c. The function
1163 specifically adds the addend field into the object file, knowing that
1164 bfd_install_relocation is not going to. If you remove that line, then
1165 coff-i386.c will wind up adding the addend field in twice. It's
1166 trivial to fix; it just needs to be done.
1168 The problem with removing the line is just that it may break some
1169 working code. With BFD it's hard to be sure of anything. The right
1170 way to deal with this is simply to build and test at least all the
1171 supported COFF targets. It should be straightforward if time and disk
1172 space consuming. For each target:
1174 2) generate some executable, and link it using -r (I would
1175 probably use paranoia.o and link against newlib/libc.a, which
1176 for all the supported targets would be available in
1177 /usr/cygnus/progressive/H-host/target/lib/libc.a).
1178 3) make the change to reloc.c
1179 4) rebuild the linker
1181 6) if the resulting object files are the same, you have at least
1183 7) if they are different you have to figure out which version is
1186 relocation
-= reloc_entry
->addend
;
1188 reloc_entry
->addend
= 0;
1192 reloc_entry
->addend
= relocation
;
1196 /* FIXME: This overflow checking is incomplete, because the value
1197 might have overflowed before we get here. For a correct check we
1198 need to compute the value in a size larger than bitsize, but we
1199 can't reasonably do that for a reloc the same size as a host
1201 FIXME: We should also do overflow checking on the result after
1202 adding in the value contained in the object file. */
1203 if (howto
->complain_on_overflow
!= complain_overflow_dont
)
1204 flag
= bfd_check_overflow (howto
->complain_on_overflow
,
1207 bfd_arch_bits_per_address (abfd
),
1211 Either we are relocating all the way, or we don't want to apply
1212 the relocation to the reloc entry (probably because there isn't
1213 any room in the output format to describe addends to relocs)
1216 /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler
1217 (OSF version 1.3, compiler version 3.11). It miscompiles the
1231 x <<= (unsigned long) s.i0;
1233 printf ("failed\n");
1235 printf ("succeeded (%lx)\n", x);
1239 relocation
>>= (bfd_vma
) howto
->rightshift
;
1241 /* Shift everything up to where it's going to be used */
1243 relocation
<<= (bfd_vma
) howto
->bitpos
;
1245 /* Wait for the day when all have the mask in them */
1248 i instruction to be left alone
1249 o offset within instruction
1250 r relocation offset to apply
1259 (( i i i i i o o o o o from bfd_get<size>
1260 and S S S S S) to get the size offset we want
1261 + r r r r r r r r r r) to get the final value to place
1262 and D D D D D to chop to right size
1263 -----------------------
1266 ( i i i i i o o o o o from bfd_get<size>
1267 and N N N N N ) get instruction
1268 -----------------------
1274 -----------------------
1275 = R R R R R R R R R R put into bfd_put<size>
1279 x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
1281 data
= (bfd_byte
*) data_start
+ (octets
- data_start_offset
);
1283 switch (howto
->size
)
1287 char x
= bfd_get_8 (abfd
, (char *) data
);
1289 bfd_put_8 (abfd
, x
, (unsigned char *) data
);
1295 short x
= bfd_get_16 (abfd
, (bfd_byte
*) data
);
1297 bfd_put_16 (abfd
, (bfd_vma
) x
, (unsigned char *) data
);
1302 long x
= bfd_get_32 (abfd
, (bfd_byte
*) data
);
1304 bfd_put_32 (abfd
, (bfd_vma
) x
, (bfd_byte
*) data
);
1309 long x
= bfd_get_32 (abfd
, (bfd_byte
*) data
);
1310 relocation
= -relocation
;
1312 bfd_put_32 (abfd
, (bfd_vma
) x
, (bfd_byte
*) data
);
1322 bfd_vma x
= bfd_get_64 (abfd
, (bfd_byte
*) data
);
1324 bfd_put_64 (abfd
, x
, (bfd_byte
*) data
);
1328 return bfd_reloc_other
;
1334 /* This relocation routine is used by some of the backend linkers.
1335 They do not construct asymbol or arelent structures, so there is no
1336 reason for them to use bfd_perform_relocation. Also,
1337 bfd_perform_relocation is so hacked up it is easier to write a new
1338 function than to try to deal with it.
1340 This routine does a final relocation. Whether it is useful for a
1341 relocateable link depends upon how the object format defines
1344 FIXME: This routine ignores any special_function in the HOWTO,
1345 since the existing special_function values have been written for
1346 bfd_perform_relocation.
1348 HOWTO is the reloc howto information.
1349 INPUT_BFD is the BFD which the reloc applies to.
1350 INPUT_SECTION is the section which the reloc applies to.
1351 CONTENTS is the contents of the section.
1352 ADDRESS is the address of the reloc within INPUT_SECTION.
1353 VALUE is the value of the symbol the reloc refers to.
1354 ADDEND is the addend of the reloc. */
1356 bfd_reloc_status_type
1357 _bfd_final_link_relocate (howto
, input_bfd
, input_section
, contents
, address
,
1359 reloc_howto_type
*howto
;
1361 asection
*input_section
;
1369 /* Sanity check the address. */
1370 if (address
> input_section
->_raw_size
)
1371 return bfd_reloc_outofrange
;
1373 /* This function assumes that we are dealing with a basic relocation
1374 against a symbol. We want to compute the value of the symbol to
1375 relocate to. This is just VALUE, the value of the symbol, plus
1376 ADDEND, any addend associated with the reloc. */
1377 relocation
= value
+ addend
;
1379 /* If the relocation is PC relative, we want to set RELOCATION to
1380 the distance between the symbol (currently in RELOCATION) and the
1381 location we are relocating. Some targets (e.g., i386-aout)
1382 arrange for the contents of the section to be the negative of the
1383 offset of the location within the section; for such targets
1384 pcrel_offset is false. Other targets (e.g., m88kbcs or ELF)
1385 simply leave the contents of the section as zero; for such
1386 targets pcrel_offset is true. If pcrel_offset is false we do not
1387 need to subtract out the offset of the location within the
1388 section (which is just ADDRESS). */
1389 if (howto
->pc_relative
)
1391 relocation
-= (input_section
->output_section
->vma
1392 + input_section
->output_offset
);
1393 if (howto
->pcrel_offset
)
1394 relocation
-= address
;
1397 return _bfd_relocate_contents (howto
, input_bfd
, relocation
,
1398 contents
+ address
);
1401 /* Relocate a given location using a given value and howto. */
1403 bfd_reloc_status_type
1404 _bfd_relocate_contents (howto
, input_bfd
, relocation
, location
)
1405 reloc_howto_type
*howto
;
1412 bfd_reloc_status_type flag
;
1413 unsigned int rightshift
= howto
->rightshift
;
1414 unsigned int bitpos
= howto
->bitpos
;
1416 /* If the size is negative, negate RELOCATION. This isn't very
1418 if (howto
->size
< 0)
1419 relocation
= -relocation
;
1421 /* Get the value we are going to relocate. */
1422 size
= bfd_get_reloc_size (howto
);
1429 x
= bfd_get_8 (input_bfd
, location
);
1432 x
= bfd_get_16 (input_bfd
, location
);
1435 x
= bfd_get_32 (input_bfd
, location
);
1439 x
= bfd_get_64 (input_bfd
, location
);
1446 /* Check for overflow. FIXME: We may drop bits during the addition
1447 which we don't check for. We must either check at every single
1448 operation, which would be tedious, or we must do the computations
1449 in a type larger than bfd_vma, which would be inefficient. */
1450 flag
= bfd_reloc_ok
;
1451 if (howto
->complain_on_overflow
!= complain_overflow_dont
)
1453 bfd_vma addrmask
, fieldmask
, signmask
, ss
;
1456 /* Get the values to be added together. For signed and unsigned
1457 relocations, we assume that all values should be truncated to
1458 the size of an address. For bitfields, all the bits matter.
1459 See also bfd_check_overflow. */
1460 fieldmask
= N_ONES (howto
->bitsize
);
1461 addrmask
= N_ONES (bfd_arch_bits_per_address (input_bfd
)) | fieldmask
;
1463 b
= x
& howto
->src_mask
;
1465 switch (howto
->complain_on_overflow
)
1467 case complain_overflow_signed
:
1468 a
= (a
& addrmask
) >> rightshift
;
1470 /* If any sign bits are set, all sign bits must be set.
1471 That is, A must be a valid negative address after
1473 signmask
= ~ (fieldmask
>> 1);
1475 if (ss
!= 0 && ss
!= ((addrmask
>> rightshift
) & signmask
))
1476 flag
= bfd_reloc_overflow
;
1478 /* We only need this next bit of code if the sign bit of B
1479 is below the sign bit of A. This would only happen if
1480 SRC_MASK had fewer bits than BITSIZE. Note that if
1481 SRC_MASK has more bits than BITSIZE, we can get into
1482 trouble; we would need to verify that B is in range, as
1483 we do for A above. */
1484 signmask
= ((~ howto
->src_mask
) >> 1) & howto
->src_mask
;
1486 /* Set all the bits above the sign bit. */
1487 b
= (b
^ signmask
) - signmask
;
1489 b
= (b
& addrmask
) >> bitpos
;
1491 /* Now we can do the addition. */
1494 /* See if the result has the correct sign. Bits above the
1495 sign bit are junk now; ignore them. If the sum is
1496 positive, make sure we did not have all negative inputs;
1497 if the sum is negative, make sure we did not have all
1498 positive inputs. The test below looks only at the sign
1499 bits, and it really just
1500 SIGN (A) == SIGN (B) && SIGN (A) != SIGN (SUM)
1502 signmask
= (fieldmask
>> 1) + 1;
1503 if (((~ (a
^ b
)) & (a
^ sum
)) & signmask
)
1504 flag
= bfd_reloc_overflow
;
1508 case complain_overflow_unsigned
:
1509 /* Checking for an unsigned overflow is relatively easy:
1510 trim the addresses and add, and trim the result as well.
1511 Overflow is normally indicated when the result does not
1512 fit in the field. However, we also need to consider the
1513 case when, e.g., fieldmask is 0x7fffffff or smaller, an
1514 input is 0x80000000, and bfd_vma is only 32 bits; then we
1515 will get sum == 0, but there is an overflow, since the
1516 inputs did not fit in the field. Instead of doing a
1517 separate test, we can check for this by or-ing in the
1518 operands when testing for the sum overflowing its final
1520 a
= (a
& addrmask
) >> rightshift
;
1521 b
= (b
& addrmask
) >> bitpos
;
1522 sum
= (a
+ b
) & addrmask
;
1523 if ((a
| b
| sum
) & ~ fieldmask
)
1524 flag
= bfd_reloc_overflow
;
1528 case complain_overflow_bitfield
:
1529 /* Much like the signed check, but for a field one bit
1530 wider, and no trimming inputs with addrmask. We allow a
1531 bitfield to represent numbers in the range -2**n to
1532 2**n-1, where n is the number of bits in the field.
1533 Note that when bfd_vma is 32 bits, a 32-bit reloc can't
1534 overflow, which is exactly what we want. */
1537 signmask
= ~ fieldmask
;
1539 if (ss
!= 0 && ss
!= (((bfd_vma
) -1 >> rightshift
) & signmask
))
1540 flag
= bfd_reloc_overflow
;
1542 signmask
= ((~ howto
->src_mask
) >> 1) & howto
->src_mask
;
1543 b
= (b
^ signmask
) - signmask
;
1549 /* We mask with addrmask here to explicitly allow an address
1550 wrap-around. The Linux kernel relies on it, and it is
1551 the only way to write assembler code which can run when
1552 loaded at a location 0x80000000 away from the location at
1553 which it is linked. */
1554 signmask
= fieldmask
+ 1;
1555 if (((~ (a
^ b
)) & (a
^ sum
)) & signmask
& addrmask
)
1556 flag
= bfd_reloc_overflow
;
1565 /* Put RELOCATION in the right bits. */
1566 relocation
>>= (bfd_vma
) rightshift
;
1567 relocation
<<= (bfd_vma
) bitpos
;
1569 /* Add RELOCATION to the right bits of X. */
1570 x
= ((x
& ~howto
->dst_mask
)
1571 | (((x
& howto
->src_mask
) + relocation
) & howto
->dst_mask
));
1573 /* Put the relocated value back in the object file. */
1580 bfd_put_8 (input_bfd
, x
, location
);
1583 bfd_put_16 (input_bfd
, x
, location
);
1586 bfd_put_32 (input_bfd
, x
, location
);
1590 bfd_put_64 (input_bfd
, x
, location
);
1603 howto manager, , typedef arelent, Relocations
1608 When an application wants to create a relocation, but doesn't
1609 know what the target machine might call it, it can find out by
1610 using this bit of code.
1619 The insides of a reloc code. The idea is that, eventually, there
1620 will be one enumerator for every type of relocation we ever do.
1621 Pass one of these values to <<bfd_reloc_type_lookup>>, and it'll
1622 return a howto pointer.
1624 This does mean that the application must determine the correct
1625 enumerator value; you can't get a howto pointer from a random set
1646 Basic absolute relocations of N bits.
1661 PC-relative relocations. Sometimes these are relative to the address
1662 of the relocation itself; sometimes they are relative to the start of
1663 the section containing the relocation. It depends on the specific target.
1665 The 24-bit relocation is used in some Intel 960 configurations.
1668 BFD_RELOC_32_GOT_PCREL
1670 BFD_RELOC_16_GOT_PCREL
1672 BFD_RELOC_8_GOT_PCREL
1678 BFD_RELOC_LO16_GOTOFF
1680 BFD_RELOC_HI16_GOTOFF
1682 BFD_RELOC_HI16_S_GOTOFF
1686 BFD_RELOC_64_PLT_PCREL
1688 BFD_RELOC_32_PLT_PCREL
1690 BFD_RELOC_24_PLT_PCREL
1692 BFD_RELOC_16_PLT_PCREL
1694 BFD_RELOC_8_PLT_PCREL
1702 BFD_RELOC_LO16_PLTOFF
1704 BFD_RELOC_HI16_PLTOFF
1706 BFD_RELOC_HI16_S_PLTOFF
1713 BFD_RELOC_68K_GLOB_DAT
1715 BFD_RELOC_68K_JMP_SLOT
1717 BFD_RELOC_68K_RELATIVE
1719 Relocations used by 68K ELF.
1722 BFD_RELOC_32_BASEREL
1724 BFD_RELOC_16_BASEREL
1726 BFD_RELOC_LO16_BASEREL
1728 BFD_RELOC_HI16_BASEREL
1730 BFD_RELOC_HI16_S_BASEREL
1736 Linkage-table relative.
1741 Absolute 8-bit relocation, but used to form an address like 0xFFnn.
1744 BFD_RELOC_32_PCREL_S2
1746 BFD_RELOC_16_PCREL_S2
1748 BFD_RELOC_23_PCREL_S2
1750 These PC-relative relocations are stored as word displacements --
1751 i.e., byte displacements shifted right two bits. The 30-bit word
1752 displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the
1753 SPARC. (SPARC tools generally refer to this as <<WDISP30>>.) The
1754 signed 16-bit displacement is used on the MIPS, and the 23-bit
1755 displacement is used on the Alpha.
1762 High 22 bits and low 10 bits of 32-bit value, placed into lower bits of
1763 the target word. These are used on the SPARC.
1770 For systems that allocate a Global Pointer register, these are
1771 displacements off that register. These relocation types are
1772 handled specially, because the value the register will have is
1773 decided relatively late.
1776 BFD_RELOC_I960_CALLJ
1778 Reloc types used for i960/b.out.
1783 BFD_RELOC_SPARC_WDISP22
1789 BFD_RELOC_SPARC_GOT10
1791 BFD_RELOC_SPARC_GOT13
1793 BFD_RELOC_SPARC_GOT22
1795 BFD_RELOC_SPARC_PC10
1797 BFD_RELOC_SPARC_PC22
1799 BFD_RELOC_SPARC_WPLT30
1801 BFD_RELOC_SPARC_COPY
1803 BFD_RELOC_SPARC_GLOB_DAT
1805 BFD_RELOC_SPARC_JMP_SLOT
1807 BFD_RELOC_SPARC_RELATIVE
1809 BFD_RELOC_SPARC_UA16
1811 BFD_RELOC_SPARC_UA32
1813 BFD_RELOC_SPARC_UA64
1815 SPARC ELF relocations. There is probably some overlap with other
1816 relocation types already defined.
1819 BFD_RELOC_SPARC_BASE13
1821 BFD_RELOC_SPARC_BASE22
1823 I think these are specific to SPARC a.out (e.g., Sun 4).
1833 BFD_RELOC_SPARC_OLO10
1835 BFD_RELOC_SPARC_HH22
1837 BFD_RELOC_SPARC_HM10
1839 BFD_RELOC_SPARC_LM22
1841 BFD_RELOC_SPARC_PC_HH22
1843 BFD_RELOC_SPARC_PC_HM10
1845 BFD_RELOC_SPARC_PC_LM22
1847 BFD_RELOC_SPARC_WDISP16
1849 BFD_RELOC_SPARC_WDISP19
1857 BFD_RELOC_SPARC_DISP64
1860 BFD_RELOC_SPARC_PLT32
1862 BFD_RELOC_SPARC_PLT64
1864 BFD_RELOC_SPARC_HIX22
1866 BFD_RELOC_SPARC_LOX10
1874 BFD_RELOC_SPARC_REGISTER
1879 BFD_RELOC_SPARC_REV32
1881 SPARC little endian relocation
1884 BFD_RELOC_ALPHA_GPDISP_HI16
1886 Alpha ECOFF and ELF relocations. Some of these treat the symbol or
1887 "addend" in some special way.
1888 For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when
1889 writing; when reading, it will be the absolute section symbol. The
1890 addend is the displacement in bytes of the "lda" instruction from
1891 the "ldah" instruction (which is at the address of this reloc).
1893 BFD_RELOC_ALPHA_GPDISP_LO16
1895 For GPDISP_LO16 ("ignore") relocations, the symbol is handled as
1896 with GPDISP_HI16 relocs. The addend is ignored when writing the
1897 relocations out, and is filled in with the file's GP value on
1898 reading, for convenience.
1901 BFD_RELOC_ALPHA_GPDISP
1903 The ELF GPDISP relocation is exactly the same as the GPDISP_HI16
1904 relocation except that there is no accompanying GPDISP_LO16
1908 BFD_RELOC_ALPHA_LITERAL
1910 BFD_RELOC_ALPHA_ELF_LITERAL
1912 BFD_RELOC_ALPHA_LITUSE
1914 The Alpha LITERAL/LITUSE relocs are produced by a symbol reference;
1915 the assembler turns it into a LDQ instruction to load the address of
1916 the symbol, and then fills in a register in the real instruction.
1918 The LITERAL reloc, at the LDQ instruction, refers to the .lita
1919 section symbol. The addend is ignored when writing, but is filled
1920 in with the file's GP value on reading, for convenience, as with the
1923 The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16.
1924 It should refer to the symbol to be referenced, as with 16_GOTOFF,
1925 but it generates output not based on the position within the .got
1926 section, but relative to the GP value chosen for the file during the
1929 The LITUSE reloc, on the instruction using the loaded address, gives
1930 information to the linker that it might be able to use to optimize
1931 away some literal section references. The symbol is ignored (read
1932 as the absolute section symbol), and the "addend" indicates the type
1933 of instruction using the register:
1934 1 - "memory" fmt insn
1935 2 - byte-manipulation (byte offset reg)
1936 3 - jsr (target of branch)
1939 BFD_RELOC_ALPHA_HINT
1941 The HINT relocation indicates a value that should be filled into the
1942 "hint" field of a jmp/jsr/ret instruction, for possible branch-
1943 prediction logic which may be provided on some processors.
1946 BFD_RELOC_ALPHA_LINKAGE
1948 The LINKAGE relocation outputs a linkage pair in the object file,
1949 which is filled by the linker.
1952 BFD_RELOC_ALPHA_CODEADDR
1954 The CODEADDR relocation outputs a STO_CA in the object file,
1955 which is filled by the linker.
1958 BFD_RELOC_ALPHA_GPREL_HI16
1960 BFD_RELOC_ALPHA_GPREL_LO16
1962 The GPREL_HI/LO relocations together form a 32-bit offset from the
1968 Bits 27..2 of the relocation address shifted right 2 bits;
1969 simple reloc otherwise.
1972 BFD_RELOC_MIPS16_JMP
1974 The MIPS16 jump instruction.
1977 BFD_RELOC_MIPS16_GPREL
1979 MIPS16 GP relative reloc.
1984 High 16 bits of 32-bit value; simple reloc.
1988 High 16 bits of 32-bit value but the low 16 bits will be sign
1989 extended and added to form the final result. If the low 16
1990 bits form a negative number, we need to add one to the high value
1991 to compensate for the borrow when the low bits are added.
1997 BFD_RELOC_PCREL_HI16_S
1999 Like BFD_RELOC_HI16_S, but PC relative.
2001 BFD_RELOC_PCREL_LO16
2003 Like BFD_RELOC_LO16, but PC relative.
2006 BFD_RELOC_MIPS_LITERAL
2008 Relocation against a MIPS literal section.
2011 BFD_RELOC_MIPS_GOT16
2013 BFD_RELOC_MIPS_CALL16
2015 BFD_RELOC_MIPS_GOT_HI16
2017 BFD_RELOC_MIPS_GOT_LO16
2019 BFD_RELOC_MIPS_CALL_HI16
2021 BFD_RELOC_MIPS_CALL_LO16
2025 BFD_RELOC_MIPS_GOT_PAGE
2027 BFD_RELOC_MIPS_GOT_OFST
2029 BFD_RELOC_MIPS_GOT_DISP
2031 BFD_RELOC_MIPS_SHIFT5
2033 BFD_RELOC_MIPS_SHIFT6
2035 BFD_RELOC_MIPS_INSERT_A
2037 BFD_RELOC_MIPS_INSERT_B
2039 BFD_RELOC_MIPS_DELETE
2041 BFD_RELOC_MIPS_HIGHEST
2043 BFD_RELOC_MIPS_HIGHER
2045 BFD_RELOC_MIPS_SCN_DISP
2047 BFD_RELOC_MIPS_REL16
2049 BFD_RELOC_MIPS_RELGOT
2054 MIPS ELF relocations.
2065 BFD_RELOC_386_GLOB_DAT
2067 BFD_RELOC_386_JUMP_SLOT
2069 BFD_RELOC_386_RELATIVE
2071 BFD_RELOC_386_GOTOFF
2075 i386/elf relocations
2078 BFD_RELOC_X86_64_GOT32
2080 BFD_RELOC_X86_64_PLT32
2082 BFD_RELOC_X86_64_COPY
2084 BFD_RELOC_X86_64_GLOB_DAT
2086 BFD_RELOC_X86_64_JUMP_SLOT
2088 BFD_RELOC_X86_64_RELATIVE
2090 BFD_RELOC_X86_64_GOTPCREL
2092 BFD_RELOC_X86_64_32S
2094 x86-64/elf relocations
2097 BFD_RELOC_NS32K_IMM_8
2099 BFD_RELOC_NS32K_IMM_16
2101 BFD_RELOC_NS32K_IMM_32
2103 BFD_RELOC_NS32K_IMM_8_PCREL
2105 BFD_RELOC_NS32K_IMM_16_PCREL
2107 BFD_RELOC_NS32K_IMM_32_PCREL
2109 BFD_RELOC_NS32K_DISP_8
2111 BFD_RELOC_NS32K_DISP_16
2113 BFD_RELOC_NS32K_DISP_32
2115 BFD_RELOC_NS32K_DISP_8_PCREL
2117 BFD_RELOC_NS32K_DISP_16_PCREL
2119 BFD_RELOC_NS32K_DISP_32_PCREL
2124 BFD_RELOC_PDP11_DISP_8_PCREL
2126 BFD_RELOC_PDP11_DISP_6_PCREL
2131 BFD_RELOC_PJ_CODE_HI16
2133 BFD_RELOC_PJ_CODE_LO16
2135 BFD_RELOC_PJ_CODE_DIR16
2137 BFD_RELOC_PJ_CODE_DIR32
2139 BFD_RELOC_PJ_CODE_REL16
2141 BFD_RELOC_PJ_CODE_REL32
2143 Picojava relocs. Not all of these appear in object files.
2154 BFD_RELOC_PPC_B16_BRTAKEN
2156 BFD_RELOC_PPC_B16_BRNTAKEN
2160 BFD_RELOC_PPC_BA16_BRTAKEN
2162 BFD_RELOC_PPC_BA16_BRNTAKEN
2166 BFD_RELOC_PPC_GLOB_DAT
2168 BFD_RELOC_PPC_JMP_SLOT
2170 BFD_RELOC_PPC_RELATIVE
2172 BFD_RELOC_PPC_LOCAL24PC
2174 BFD_RELOC_PPC_EMB_NADDR32
2176 BFD_RELOC_PPC_EMB_NADDR16
2178 BFD_RELOC_PPC_EMB_NADDR16_LO
2180 BFD_RELOC_PPC_EMB_NADDR16_HI
2182 BFD_RELOC_PPC_EMB_NADDR16_HA
2184 BFD_RELOC_PPC_EMB_SDAI16
2186 BFD_RELOC_PPC_EMB_SDA2I16
2188 BFD_RELOC_PPC_EMB_SDA2REL
2190 BFD_RELOC_PPC_EMB_SDA21
2192 BFD_RELOC_PPC_EMB_MRKREF
2194 BFD_RELOC_PPC_EMB_RELSEC16
2196 BFD_RELOC_PPC_EMB_RELST_LO
2198 BFD_RELOC_PPC_EMB_RELST_HI
2200 BFD_RELOC_PPC_EMB_RELST_HA
2202 BFD_RELOC_PPC_EMB_BIT_FLD
2204 BFD_RELOC_PPC_EMB_RELSDA
2206 BFD_RELOC_PPC64_HIGHER
2208 BFD_RELOC_PPC64_HIGHER_S
2210 BFD_RELOC_PPC64_HIGHEST
2212 BFD_RELOC_PPC64_HIGHEST_S
2214 BFD_RELOC_PPC64_TOC16_LO
2216 BFD_RELOC_PPC64_TOC16_HI
2218 BFD_RELOC_PPC64_TOC16_HA
2222 BFD_RELOC_PPC64_PLTGOT16
2224 BFD_RELOC_PPC64_PLTGOT16_LO
2226 BFD_RELOC_PPC64_PLTGOT16_HI
2228 BFD_RELOC_PPC64_PLTGOT16_HA
2230 BFD_RELOC_PPC64_ADDR16_DS
2232 BFD_RELOC_PPC64_ADDR16_LO_DS
2234 BFD_RELOC_PPC64_GOT16_DS
2236 BFD_RELOC_PPC64_GOT16_LO_DS
2238 BFD_RELOC_PPC64_PLT16_LO_DS
2240 BFD_RELOC_PPC64_SECTOFF_DS
2242 BFD_RELOC_PPC64_SECTOFF_LO_DS
2244 BFD_RELOC_PPC64_TOC16_DS
2246 BFD_RELOC_PPC64_TOC16_LO_DS
2248 BFD_RELOC_PPC64_PLTGOT16_DS
2250 BFD_RELOC_PPC64_PLTGOT16_LO_DS
2252 Power(rs6000) and PowerPC relocations.
2257 IBM 370/390 relocations
2262 The type of reloc used to build a contructor table - at the moment
2263 probably a 32 bit wide absolute relocation, but the target can choose.
2264 It generally does map to one of the other relocation types.
2267 BFD_RELOC_ARM_PCREL_BRANCH
2269 ARM 26 bit pc-relative branch. The lowest two bits must be zero and are
2270 not stored in the instruction.
2272 BFD_RELOC_ARM_PCREL_BLX
2274 ARM 26 bit pc-relative branch. The lowest bit must be zero and is
2275 not stored in the instruction. The 2nd lowest bit comes from a 1 bit
2276 field in the instruction.
2278 BFD_RELOC_THUMB_PCREL_BLX
2280 Thumb 22 bit pc-relative branch. The lowest bit must be zero and is
2281 not stored in the instruction. The 2nd lowest bit comes from a 1 bit
2282 field in the instruction.
2284 BFD_RELOC_ARM_IMMEDIATE
2286 BFD_RELOC_ARM_ADRL_IMMEDIATE
2288 BFD_RELOC_ARM_OFFSET_IMM
2290 BFD_RELOC_ARM_SHIFT_IMM
2296 BFD_RELOC_ARM_CP_OFF_IMM
2298 BFD_RELOC_ARM_ADR_IMM
2300 BFD_RELOC_ARM_LDR_IMM
2302 BFD_RELOC_ARM_LITERAL
2304 BFD_RELOC_ARM_IN_POOL
2306 BFD_RELOC_ARM_OFFSET_IMM8
2308 BFD_RELOC_ARM_HWLITERAL
2310 BFD_RELOC_ARM_THUMB_ADD
2312 BFD_RELOC_ARM_THUMB_IMM
2314 BFD_RELOC_ARM_THUMB_SHIFT
2316 BFD_RELOC_ARM_THUMB_OFFSET
2322 BFD_RELOC_ARM_JUMP_SLOT
2326 BFD_RELOC_ARM_GLOB_DAT
2330 BFD_RELOC_ARM_RELATIVE
2332 BFD_RELOC_ARM_GOTOFF
2336 These relocs are only used within the ARM assembler. They are not
2337 (at present) written to any object files.
2340 BFD_RELOC_SH_PCDISP8BY2
2342 BFD_RELOC_SH_PCDISP12BY2
2346 BFD_RELOC_SH_IMM4BY2
2348 BFD_RELOC_SH_IMM4BY4
2352 BFD_RELOC_SH_IMM8BY2
2354 BFD_RELOC_SH_IMM8BY4
2356 BFD_RELOC_SH_PCRELIMM8BY2
2358 BFD_RELOC_SH_PCRELIMM8BY4
2360 BFD_RELOC_SH_SWITCH16
2362 BFD_RELOC_SH_SWITCH32
2376 BFD_RELOC_SH_LOOP_START
2378 BFD_RELOC_SH_LOOP_END
2382 BFD_RELOC_SH_GLOB_DAT
2384 BFD_RELOC_SH_JMP_SLOT
2386 BFD_RELOC_SH_RELATIVE
2390 Hitachi SH relocs. Not all of these appear in object files.
2393 BFD_RELOC_THUMB_PCREL_BRANCH9
2395 BFD_RELOC_THUMB_PCREL_BRANCH12
2397 BFD_RELOC_THUMB_PCREL_BRANCH23
2399 Thumb 23-, 12- and 9-bit pc-relative branches. The lowest bit must
2400 be zero and is not stored in the instruction.
2403 BFD_RELOC_ARC_B22_PCREL
2406 ARC 22 bit pc-relative branch. The lowest two bits must be zero and are
2407 not stored in the instruction. The high 20 bits are installed in bits 26
2408 through 7 of the instruction.
2412 ARC 26 bit absolute branch. The lowest two bits must be zero and are not
2413 stored in the instruction. The high 24 bits are installed in bits 23
2417 BFD_RELOC_D10V_10_PCREL_R
2419 Mitsubishi D10V relocs.
2420 This is a 10-bit reloc with the right 2 bits
2423 BFD_RELOC_D10V_10_PCREL_L
2425 Mitsubishi D10V relocs.
2426 This is a 10-bit reloc with the right 2 bits
2427 assumed to be 0. This is the same as the previous reloc
2428 except it is in the left container, i.e.,
2429 shifted left 15 bits.
2433 This is an 18-bit reloc with the right 2 bits
2436 BFD_RELOC_D10V_18_PCREL
2438 This is an 18-bit reloc with the right 2 bits
2444 Mitsubishi D30V relocs.
2445 This is a 6-bit absolute reloc.
2447 BFD_RELOC_D30V_9_PCREL
2449 This is a 6-bit pc-relative reloc with
2450 the right 3 bits assumed to be 0.
2452 BFD_RELOC_D30V_9_PCREL_R
2454 This is a 6-bit pc-relative reloc with
2455 the right 3 bits assumed to be 0. Same
2456 as the previous reloc but on the right side
2461 This is a 12-bit absolute reloc with the
2462 right 3 bitsassumed to be 0.
2464 BFD_RELOC_D30V_15_PCREL
2466 This is a 12-bit pc-relative reloc with
2467 the right 3 bits assumed to be 0.
2469 BFD_RELOC_D30V_15_PCREL_R
2471 This is a 12-bit pc-relative reloc with
2472 the right 3 bits assumed to be 0. Same
2473 as the previous reloc but on the right side
2478 This is an 18-bit absolute reloc with
2479 the right 3 bits assumed to be 0.
2481 BFD_RELOC_D30V_21_PCREL
2483 This is an 18-bit pc-relative reloc with
2484 the right 3 bits assumed to be 0.
2486 BFD_RELOC_D30V_21_PCREL_R
2488 This is an 18-bit pc-relative reloc with
2489 the right 3 bits assumed to be 0. Same
2490 as the previous reloc but on the right side
2495 This is a 32-bit absolute reloc.
2497 BFD_RELOC_D30V_32_PCREL
2499 This is a 32-bit pc-relative reloc.
2504 Mitsubishi M32R relocs.
2505 This is a 24 bit absolute address.
2507 BFD_RELOC_M32R_10_PCREL
2509 This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0.
2511 BFD_RELOC_M32R_18_PCREL
2513 This is an 18-bit reloc with the right 2 bits assumed to be 0.
2515 BFD_RELOC_M32R_26_PCREL
2517 This is a 26-bit reloc with the right 2 bits assumed to be 0.
2519 BFD_RELOC_M32R_HI16_ULO
2521 This is a 16-bit reloc containing the high 16 bits of an address
2522 used when the lower 16 bits are treated as unsigned.
2524 BFD_RELOC_M32R_HI16_SLO
2526 This is a 16-bit reloc containing the high 16 bits of an address
2527 used when the lower 16 bits are treated as signed.
2531 This is a 16-bit reloc containing the lower 16 bits of an address.
2533 BFD_RELOC_M32R_SDA16
2535 This is a 16-bit reloc containing the small data area offset for use in
2536 add3, load, and store instructions.
2539 BFD_RELOC_V850_9_PCREL
2541 This is a 9-bit reloc
2543 BFD_RELOC_V850_22_PCREL
2545 This is a 22-bit reloc
2548 BFD_RELOC_V850_SDA_16_16_OFFSET
2550 This is a 16 bit offset from the short data area pointer.
2552 BFD_RELOC_V850_SDA_15_16_OFFSET
2554 This is a 16 bit offset (of which only 15 bits are used) from the
2555 short data area pointer.
2557 BFD_RELOC_V850_ZDA_16_16_OFFSET
2559 This is a 16 bit offset from the zero data area pointer.
2561 BFD_RELOC_V850_ZDA_15_16_OFFSET
2563 This is a 16 bit offset (of which only 15 bits are used) from the
2564 zero data area pointer.
2566 BFD_RELOC_V850_TDA_6_8_OFFSET
2568 This is an 8 bit offset (of which only 6 bits are used) from the
2569 tiny data area pointer.
2571 BFD_RELOC_V850_TDA_7_8_OFFSET
2573 This is an 8bit offset (of which only 7 bits are used) from the tiny
2576 BFD_RELOC_V850_TDA_7_7_OFFSET
2578 This is a 7 bit offset from the tiny data area pointer.
2580 BFD_RELOC_V850_TDA_16_16_OFFSET
2582 This is a 16 bit offset from the tiny data area pointer.
2585 BFD_RELOC_V850_TDA_4_5_OFFSET
2587 This is a 5 bit offset (of which only 4 bits are used) from the tiny
2590 BFD_RELOC_V850_TDA_4_4_OFFSET
2592 This is a 4 bit offset from the tiny data area pointer.
2594 BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET
2596 This is a 16 bit offset from the short data area pointer, with the
2597 bits placed non-contigously in the instruction.
2599 BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET
2601 This is a 16 bit offset from the zero data area pointer, with the
2602 bits placed non-contigously in the instruction.
2604 BFD_RELOC_V850_CALLT_6_7_OFFSET
2606 This is a 6 bit offset from the call table base pointer.
2608 BFD_RELOC_V850_CALLT_16_16_OFFSET
2610 This is a 16 bit offset from the call table base pointer.
2614 BFD_RELOC_MN10300_32_PCREL
2616 This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
2619 BFD_RELOC_MN10300_16_PCREL
2621 This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
2627 This is a 8bit DP reloc for the tms320c30, where the most
2628 significant 8 bits of a 24 bit word are placed into the least
2629 significant 8 bits of the opcode.
2632 BFD_RELOC_TIC54X_PARTLS7
2634 This is a 7bit reloc for the tms320c54x, where the least
2635 significant 7 bits of a 16 bit word are placed into the least
2636 significant 7 bits of the opcode.
2639 BFD_RELOC_TIC54X_PARTMS9
2641 This is a 9bit DP reloc for the tms320c54x, where the most
2642 significant 9 bits of a 16 bit word are placed into the least
2643 significant 9 bits of the opcode.
2648 This is an extended address 23-bit reloc for the tms320c54x.
2651 BFD_RELOC_TIC54X_16_OF_23
2653 This is a 16-bit reloc for the tms320c54x, where the least
2654 significant 16 bits of a 23-bit extended address are placed into
2658 BFD_RELOC_TIC54X_MS7_OF_23
2660 This is a reloc for the tms320c54x, where the most
2661 significant 7 bits of a 23-bit extended address are placed into
2667 This is a 48 bit reloc for the FR30 that stores 32 bits.
2671 This is a 32 bit reloc for the FR30 that stores 20 bits split up into
2674 BFD_RELOC_FR30_6_IN_4
2676 This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in
2679 BFD_RELOC_FR30_8_IN_8
2681 This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset
2684 BFD_RELOC_FR30_9_IN_8
2686 This is a 16 bit reloc for the FR30 that stores a 9 bit short offset
2689 BFD_RELOC_FR30_10_IN_8
2691 This is a 16 bit reloc for the FR30 that stores a 10 bit word offset
2694 BFD_RELOC_FR30_9_PCREL
2696 This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative
2697 short offset into 8 bits.
2699 BFD_RELOC_FR30_12_PCREL
2701 This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative
2702 short offset into 11 bits.
2705 BFD_RELOC_MCORE_PCREL_IMM8BY4
2707 BFD_RELOC_MCORE_PCREL_IMM11BY2
2709 BFD_RELOC_MCORE_PCREL_IMM4BY2
2711 BFD_RELOC_MCORE_PCREL_32
2713 BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2
2717 Motorola Mcore relocations.
2722 BFD_RELOC_MMIX_GETA_1
2724 BFD_RELOC_MMIX_GETA_2
2726 BFD_RELOC_MMIX_GETA_3
2728 These are relocations for the GETA instruction.
2730 BFD_RELOC_MMIX_CBRANCH
2732 BFD_RELOC_MMIX_CBRANCH_J
2734 BFD_RELOC_MMIX_CBRANCH_1
2736 BFD_RELOC_MMIX_CBRANCH_2
2738 BFD_RELOC_MMIX_CBRANCH_3
2740 These are relocations for a conditional branch instruction.
2742 BFD_RELOC_MMIX_PUSHJ
2744 BFD_RELOC_MMIX_PUSHJ_1
2746 BFD_RELOC_MMIX_PUSHJ_2
2748 BFD_RELOC_MMIX_PUSHJ_3
2750 These are relocations for the PUSHJ instruction.
2754 BFD_RELOC_MMIX_JMP_1
2756 BFD_RELOC_MMIX_JMP_2
2758 BFD_RELOC_MMIX_JMP_3
2760 These are relocations for the JMP instruction.
2762 BFD_RELOC_MMIX_ADDR19
2764 This is a relocation for a relative address as in a GETA instruction or
2767 BFD_RELOC_MMIX_ADDR27
2769 This is a relocation for a relative address as in a JMP instruction.
2771 BFD_RELOC_MMIX_REG_OR_BYTE
2773 This is a relocation for an instruction field that may be a general
2774 register or a value 0..255.
2778 This is a relocation for an instruction field that may be a general
2781 BFD_RELOC_MMIX_BASE_PLUS_OFFSET
2783 This is a relocation for two instruction fields holding a register and
2784 an offset, the equivalent of the relocation.
2786 BFD_RELOC_MMIX_LOCAL
2788 This relocation is an assertion that the expression is not allocated as
2789 a global register. It does not modify contents.
2792 BFD_RELOC_AVR_7_PCREL
2794 This is a 16 bit reloc for the AVR that stores 8 bit pc relative
2795 short offset into 7 bits.
2797 BFD_RELOC_AVR_13_PCREL
2799 This is a 16 bit reloc for the AVR that stores 13 bit pc relative
2800 short offset into 12 bits.
2804 This is a 16 bit reloc for the AVR that stores 17 bit value (usually
2805 program memory address) into 16 bits.
2807 BFD_RELOC_AVR_LO8_LDI
2809 This is a 16 bit reloc for the AVR that stores 8 bit value (usually
2810 data memory address) into 8 bit immediate value of LDI insn.
2812 BFD_RELOC_AVR_HI8_LDI
2814 This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit
2815 of data memory address) into 8 bit immediate value of LDI insn.
2817 BFD_RELOC_AVR_HH8_LDI
2819 This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit
2820 of program memory address) into 8 bit immediate value of LDI insn.
2822 BFD_RELOC_AVR_LO8_LDI_NEG
2824 This is a 16 bit reloc for the AVR that stores negated 8 bit value
2825 (usually data memory address) into 8 bit immediate value of SUBI insn.
2827 BFD_RELOC_AVR_HI8_LDI_NEG
2829 This is a 16 bit reloc for the AVR that stores negated 8 bit value
2830 (high 8 bit of data memory address) into 8 bit immediate value of
2833 BFD_RELOC_AVR_HH8_LDI_NEG
2835 This is a 16 bit reloc for the AVR that stores negated 8 bit value
2836 (most high 8 bit of program memory address) into 8 bit immediate value
2837 of LDI or SUBI insn.
2839 BFD_RELOC_AVR_LO8_LDI_PM
2841 This is a 16 bit reloc for the AVR that stores 8 bit value (usually
2842 command address) into 8 bit immediate value of LDI insn.
2844 BFD_RELOC_AVR_HI8_LDI_PM
2846 This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit
2847 of command address) into 8 bit immediate value of LDI insn.
2849 BFD_RELOC_AVR_HH8_LDI_PM
2851 This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit
2852 of command address) into 8 bit immediate value of LDI insn.
2854 BFD_RELOC_AVR_LO8_LDI_PM_NEG
2856 This is a 16 bit reloc for the AVR that stores negated 8 bit value
2857 (usually command address) into 8 bit immediate value of SUBI insn.
2859 BFD_RELOC_AVR_HI8_LDI_PM_NEG
2861 This is a 16 bit reloc for the AVR that stores negated 8 bit value
2862 (high 8 bit of 16 bit command address) into 8 bit immediate value
2865 BFD_RELOC_AVR_HH8_LDI_PM_NEG
2867 This is a 16 bit reloc for the AVR that stores negated 8 bit value
2868 (high 6 bit of 22 bit command address) into 8 bit immediate
2873 This is a 32 bit reloc for the AVR that stores 23 bit value
2887 32 bit PC relative PLT address.
2891 Copy symbol at runtime.
2893 BFD_RELOC_390_GLOB_DAT
2897 BFD_RELOC_390_JMP_SLOT
2901 BFD_RELOC_390_RELATIVE
2903 Adjust by program base.
2907 32 bit PC relative offset to GOT.
2913 BFD_RELOC_390_PC16DBL
2915 PC relative 16 bit shifted by 1.
2917 BFD_RELOC_390_PLT16DBL
2919 16 bit PC rel. PLT shifted by 1.
2921 BFD_RELOC_390_PC32DBL
2923 PC relative 32 bit shifted by 1.
2925 BFD_RELOC_390_PLT32DBL
2927 32 bit PC rel. PLT shifted by 1.
2929 BFD_RELOC_390_GOTPCDBL
2931 32 bit PC rel. GOT shifted by 1.
2939 64 bit PC relative PLT address.
2941 BFD_RELOC_390_GOTENT
2943 32 bit rel. offset to GOT entry.
2946 BFD_RELOC_VTABLE_INHERIT
2948 BFD_RELOC_VTABLE_ENTRY
2950 These two relocations are used by the linker to determine which of
2951 the entries in a C++ virtual function table are actually used. When
2952 the --gc-sections option is given, the linker will zero out the entries
2953 that are not used, so that the code for those functions need not be
2954 included in the output.
2956 VTABLE_INHERIT is a zero-space relocation used to describe to the
2957 linker the inheritence tree of a C++ virtual function table. The
2958 relocation's symbol should be the parent class' vtable, and the
2959 relocation should be located at the child vtable.
2961 VTABLE_ENTRY is a zero-space relocation that describes the use of a
2962 virtual function table entry. The reloc's symbol should refer to the
2963 table of the class mentioned in the code. Off of that base, an offset
2964 describes the entry that is being used. For Rela hosts, this offset
2965 is stored in the reloc's addend. For Rel hosts, we are forced to put
2966 this offset in the reloc's section offset.
2969 BFD_RELOC_IA64_IMM14
2971 BFD_RELOC_IA64_IMM22
2973 BFD_RELOC_IA64_IMM64
2975 BFD_RELOC_IA64_DIR32MSB
2977 BFD_RELOC_IA64_DIR32LSB
2979 BFD_RELOC_IA64_DIR64MSB
2981 BFD_RELOC_IA64_DIR64LSB
2983 BFD_RELOC_IA64_GPREL22
2985 BFD_RELOC_IA64_GPREL64I
2987 BFD_RELOC_IA64_GPREL32MSB
2989 BFD_RELOC_IA64_GPREL32LSB
2991 BFD_RELOC_IA64_GPREL64MSB
2993 BFD_RELOC_IA64_GPREL64LSB
2995 BFD_RELOC_IA64_LTOFF22
2997 BFD_RELOC_IA64_LTOFF64I
2999 BFD_RELOC_IA64_PLTOFF22
3001 BFD_RELOC_IA64_PLTOFF64I
3003 BFD_RELOC_IA64_PLTOFF64MSB
3005 BFD_RELOC_IA64_PLTOFF64LSB
3007 BFD_RELOC_IA64_FPTR64I
3009 BFD_RELOC_IA64_FPTR32MSB
3011 BFD_RELOC_IA64_FPTR32LSB
3013 BFD_RELOC_IA64_FPTR64MSB
3015 BFD_RELOC_IA64_FPTR64LSB
3017 BFD_RELOC_IA64_PCREL21B
3019 BFD_RELOC_IA64_PCREL21BI
3021 BFD_RELOC_IA64_PCREL21M
3023 BFD_RELOC_IA64_PCREL21F
3025 BFD_RELOC_IA64_PCREL22
3027 BFD_RELOC_IA64_PCREL60B
3029 BFD_RELOC_IA64_PCREL64I
3031 BFD_RELOC_IA64_PCREL32MSB
3033 BFD_RELOC_IA64_PCREL32LSB
3035 BFD_RELOC_IA64_PCREL64MSB
3037 BFD_RELOC_IA64_PCREL64LSB
3039 BFD_RELOC_IA64_LTOFF_FPTR22
3041 BFD_RELOC_IA64_LTOFF_FPTR64I
3043 BFD_RELOC_IA64_LTOFF_FPTR32MSB
3045 BFD_RELOC_IA64_LTOFF_FPTR32LSB
3047 BFD_RELOC_IA64_LTOFF_FPTR64MSB
3049 BFD_RELOC_IA64_LTOFF_FPTR64LSB
3051 BFD_RELOC_IA64_SEGREL32MSB
3053 BFD_RELOC_IA64_SEGREL32LSB
3055 BFD_RELOC_IA64_SEGREL64MSB
3057 BFD_RELOC_IA64_SEGREL64LSB
3059 BFD_RELOC_IA64_SECREL32MSB
3061 BFD_RELOC_IA64_SECREL32LSB
3063 BFD_RELOC_IA64_SECREL64MSB
3065 BFD_RELOC_IA64_SECREL64LSB
3067 BFD_RELOC_IA64_REL32MSB
3069 BFD_RELOC_IA64_REL32LSB
3071 BFD_RELOC_IA64_REL64MSB
3073 BFD_RELOC_IA64_REL64LSB
3075 BFD_RELOC_IA64_LTV32MSB
3077 BFD_RELOC_IA64_LTV32LSB
3079 BFD_RELOC_IA64_LTV64MSB
3081 BFD_RELOC_IA64_LTV64LSB
3083 BFD_RELOC_IA64_IPLTMSB
3085 BFD_RELOC_IA64_IPLTLSB
3089 BFD_RELOC_IA64_TPREL22
3091 BFD_RELOC_IA64_TPREL64MSB
3093 BFD_RELOC_IA64_TPREL64LSB
3095 BFD_RELOC_IA64_LTOFF_TP22
3097 BFD_RELOC_IA64_LTOFF22X
3099 BFD_RELOC_IA64_LDXMOV
3101 Intel IA64 Relocations.
3104 BFD_RELOC_M68HC11_HI8
3106 Motorola 68HC11 reloc.
3107 This is the 8 bits high part of an absolute address.
3109 BFD_RELOC_M68HC11_LO8
3111 Motorola 68HC11 reloc.
3112 This is the 8 bits low part of an absolute address.
3114 BFD_RELOC_M68HC11_3B
3116 Motorola 68HC11 reloc.
3117 This is the 3 bits of a value.
3120 BFD_RELOC_CRIS_BDISP8
3122 BFD_RELOC_CRIS_UNSIGNED_5
3124 BFD_RELOC_CRIS_SIGNED_6
3126 BFD_RELOC_CRIS_UNSIGNED_6
3128 BFD_RELOC_CRIS_UNSIGNED_4
3130 These relocs are only used within the CRIS assembler. They are not
3131 (at present) written to any object files.
3135 BFD_RELOC_CRIS_GLOB_DAT
3137 BFD_RELOC_CRIS_JUMP_SLOT
3139 BFD_RELOC_CRIS_RELATIVE
3141 Relocs used in ELF shared libraries for CRIS.
3143 BFD_RELOC_CRIS_32_GOT
3145 32-bit offset to symbol-entry within GOT.
3147 BFD_RELOC_CRIS_16_GOT
3149 16-bit offset to symbol-entry within GOT.
3151 BFD_RELOC_CRIS_32_GOTPLT
3153 32-bit offset to symbol-entry within GOT, with PLT handling.
3155 BFD_RELOC_CRIS_16_GOTPLT
3157 16-bit offset to symbol-entry within GOT, with PLT handling.
3159 BFD_RELOC_CRIS_32_GOTREL
3161 32-bit offset to symbol, relative to GOT.
3163 BFD_RELOC_CRIS_32_PLT_GOTREL
3165 32-bit offset to symbol with PLT entry, relative to GOT.
3167 BFD_RELOC_CRIS_32_PLT_PCREL
3169 32-bit offset to symbol with PLT entry, relative to this relocation.
3174 BFD_RELOC_860_GLOB_DAT
3176 BFD_RELOC_860_JUMP_SLOT
3178 BFD_RELOC_860_RELATIVE
3188 BFD_RELOC_860_SPLIT0
3192 BFD_RELOC_860_SPLIT1
3196 BFD_RELOC_860_SPLIT2
3200 BFD_RELOC_860_LOGOT0
3202 BFD_RELOC_860_SPGOT0
3204 BFD_RELOC_860_LOGOT1
3206 BFD_RELOC_860_SPGOT1
3208 BFD_RELOC_860_LOGOTOFF0
3210 BFD_RELOC_860_SPGOTOFF0
3212 BFD_RELOC_860_LOGOTOFF1
3214 BFD_RELOC_860_SPGOTOFF1
3216 BFD_RELOC_860_LOGOTOFF2
3218 BFD_RELOC_860_LOGOTOFF3
3222 BFD_RELOC_860_HIGHADJ
3226 BFD_RELOC_860_HAGOTOFF
3234 BFD_RELOC_860_HIGOTOFF
3236 Intel i860 Relocations.
3239 BFD_RELOC_OPENRISC_ABS_26
3241 BFD_RELOC_OPENRISC_REL_26
3243 OpenRISC Relocations.
3246 BFD_RELOC_H8_DIR16A8
3248 BFD_RELOC_H8_DIR16R8
3250 BFD_RELOC_H8_DIR24A8
3252 BFD_RELOC_H8_DIR24R8
3254 BFD_RELOC_H8_DIR32A16
3259 BFD_RELOC_XSTORMY16_REL_12
3261 BFD_RELOC_XSTORMY16_24
3263 BFD_RELOC_XSTORMY16_FPTR16
3265 Sony Xstormy16 Relocations.
3271 .typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
3276 bfd_reloc_type_lookup
3280 bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code);
3283 Return a pointer to a howto structure which, when
3284 invoked, will perform the relocation @var{code} on data from the
3290 bfd_reloc_type_lookup (abfd
, code
)
3292 bfd_reloc_code_real_type code
;
3294 return BFD_SEND (abfd
, reloc_type_lookup
, (abfd
, code
));
3297 static reloc_howto_type bfd_howto_32
=
3298 HOWTO (0, 00, 2, 32, false, 0, complain_overflow_bitfield
, 0, "VRT32", false, 0xffffffff, 0xffffffff, true);
3302 bfd_default_reloc_type_lookup
3305 reloc_howto_type *bfd_default_reloc_type_lookup
3306 (bfd *abfd, bfd_reloc_code_real_type code);
3309 Provides a default relocation lookup routine for any architecture.
3314 bfd_default_reloc_type_lookup (abfd
, code
)
3316 bfd_reloc_code_real_type code
;
3320 case BFD_RELOC_CTOR
:
3321 /* The type of reloc used in a ctor, which will be as wide as the
3322 address - so either a 64, 32, or 16 bitter. */
3323 switch (bfd_get_arch_info (abfd
)->bits_per_address
)
3328 return &bfd_howto_32
;
3337 return (reloc_howto_type
*) NULL
;
3342 bfd_get_reloc_code_name
3345 const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code);
3348 Provides a printable name for the supplied relocation code.
3349 Useful mainly for printing error messages.
3353 bfd_get_reloc_code_name (code
)
3354 bfd_reloc_code_real_type code
;
3356 if (code
> BFD_RELOC_UNUSED
)
3358 return bfd_reloc_code_real_names
[(int)code
];
3363 bfd_generic_relax_section
3366 boolean bfd_generic_relax_section
3369 struct bfd_link_info *,
3373 Provides default handling for relaxing for back ends which
3374 don't do relaxing -- i.e., does nothing.
3379 bfd_generic_relax_section (abfd
, section
, link_info
, again
)
3380 bfd
*abfd ATTRIBUTE_UNUSED
;
3381 asection
*section ATTRIBUTE_UNUSED
;
3382 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
3391 bfd_generic_gc_sections
3394 boolean bfd_generic_gc_sections
3395 (bfd *, struct bfd_link_info *);
3398 Provides default handling for relaxing for back ends which
3399 don't do section gc -- i.e., does nothing.
3404 bfd_generic_gc_sections (abfd
, link_info
)
3405 bfd
*abfd ATTRIBUTE_UNUSED
;
3406 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
3413 bfd_generic_merge_sections
3416 boolean bfd_generic_merge_sections
3417 (bfd *, struct bfd_link_info *);
3420 Provides default handling for SEC_MERGE section merging for back ends
3421 which don't have SEC_MERGE support -- i.e., does nothing.
3426 bfd_generic_merge_sections (abfd
, link_info
)
3427 bfd
*abfd ATTRIBUTE_UNUSED
;
3428 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
3435 bfd_generic_get_relocated_section_contents
3439 bfd_generic_get_relocated_section_contents (bfd *abfd,
3440 struct bfd_link_info *link_info,
3441 struct bfd_link_order *link_order,
3443 boolean relocateable,
3447 Provides default handling of relocation effort for back ends
3448 which can't be bothered to do it efficiently.
3453 bfd_generic_get_relocated_section_contents (abfd
, link_info
, link_order
, data
,
3454 relocateable
, symbols
)
3456 struct bfd_link_info
*link_info
;
3457 struct bfd_link_order
*link_order
;
3459 boolean relocateable
;
3462 /* Get enough memory to hold the stuff */
3463 bfd
*input_bfd
= link_order
->u
.indirect
.section
->owner
;
3464 asection
*input_section
= link_order
->u
.indirect
.section
;
3466 long reloc_size
= bfd_get_reloc_upper_bound (input_bfd
, input_section
);
3467 arelent
**reloc_vector
= NULL
;
3473 reloc_vector
= (arelent
**) bfd_malloc ((bfd_size_type
) reloc_size
);
3474 if (reloc_vector
== NULL
&& reloc_size
!= 0)
3477 /* read in the section */
3478 if (!bfd_get_section_contents (input_bfd
,
3482 input_section
->_raw_size
))
3485 /* We're not relaxing the section, so just copy the size info */
3486 input_section
->_cooked_size
= input_section
->_raw_size
;
3487 input_section
->reloc_done
= true;
3489 reloc_count
= bfd_canonicalize_reloc (input_bfd
,
3493 if (reloc_count
< 0)
3496 if (reloc_count
> 0)
3499 for (parent
= reloc_vector
; *parent
!= (arelent
*) NULL
;
3502 char *error_message
= (char *) NULL
;
3503 bfd_reloc_status_type r
=
3504 bfd_perform_relocation (input_bfd
,
3508 relocateable
? abfd
: (bfd
*) NULL
,
3513 asection
*os
= input_section
->output_section
;
3515 /* A partial link, so keep the relocs */
3516 os
->orelocation
[os
->reloc_count
] = *parent
;
3520 if (r
!= bfd_reloc_ok
)
3524 case bfd_reloc_undefined
:
3525 if (!((*link_info
->callbacks
->undefined_symbol
)
3526 (link_info
, bfd_asymbol_name (*(*parent
)->sym_ptr_ptr
),
3527 input_bfd
, input_section
, (*parent
)->address
,
3531 case bfd_reloc_dangerous
:
3532 BFD_ASSERT (error_message
!= (char *) NULL
);
3533 if (!((*link_info
->callbacks
->reloc_dangerous
)
3534 (link_info
, error_message
, input_bfd
, input_section
,
3535 (*parent
)->address
)))
3538 case bfd_reloc_overflow
:
3539 if (!((*link_info
->callbacks
->reloc_overflow
)
3540 (link_info
, bfd_asymbol_name (*(*parent
)->sym_ptr_ptr
),
3541 (*parent
)->howto
->name
, (*parent
)->addend
,
3542 input_bfd
, input_section
, (*parent
)->address
)))
3545 case bfd_reloc_outofrange
:
3554 if (reloc_vector
!= NULL
)
3555 free (reloc_vector
);
3559 if (reloc_vector
!= NULL
)
3560 free (reloc_vector
);