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 *abfd,
324 . arelent *reloc_entry,
325 . struct symbol_cache_entry *symbol,
327 . asection *input_section,
329 . char **error_message));
331 . {* The textual name of the relocation type. *}
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. *}
349 . boolean partial_inplace;
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
353 . byte of data which we read and relocated, this would be
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. *}
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. *}
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;
383 The HOWTO define is horrible and will go away.
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}
389 And will be replaced with the totally magic way. But for the
390 moment, we are compatible, so do it this way.
392 .#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN)
396 This is used to fill in an empty howto entry in an array.
398 .#define EMPTY_HOWTO(C) \
399 . HOWTO((C),0,0,0,false,0,complain_overflow_dont,NULL,NULL,false,0,0,false)
403 Helper routine to turn a symbol into a relocation value.
405 .#define HOWTO_PREPARE(relocation, symbol) \
407 . if (symbol != (asymbol *)NULL) { \
408 . 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 {
458 . struct relent_chain *next;
463 /* N_ONES produces N one bits, without overflowing machine arithmetic. */
464 #define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1)
471 bfd_reloc_status_type
473 (enum complain_overflow how,
474 unsigned int bitsize,
475 unsigned int rightshift,
476 unsigned int addrsize,
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}.
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
;
496 bfd_vma fieldmask
, addrmask
, signmask
, ss
, a
;
497 bfd_reloc_status_type flag
= bfd_reloc_ok
;
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
505 fieldmask
= N_ONES (bitsize
);
506 addrmask
= N_ONES (addrsize
) | fieldmask
;
510 case complain_overflow_dont
:
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);
519 if (ss
!= 0 && ss
!= ((addrmask
>> rightshift
) & signmask
))
520 flag
= bfd_reloc_overflow
;
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
;
530 case complain_overflow_bitfield
:
531 /* Bitfields are sometimes signed, sometimes unsigned. We
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
537 ss
= a
& ~ fieldmask
;
538 if (ss
!= 0 && ss
!= (((bfd_vma
) -1 >> rightshift
) & ~ fieldmask
))
539 flag
= bfd_reloc_overflow
;
551 bfd_perform_relocation
554 bfd_reloc_status_type
555 bfd_perform_relocation
557 arelent *reloc_entry,
559 asection *input_section,
561 char **error_message);
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}.
581 bfd_reloc_status_type
582 bfd_perform_relocation (abfd
, reloc_entry
, data
, input_section
, output_bfd
,
585 arelent
*reloc_entry
;
587 asection
*input_section
;
589 char **error_message
;
592 bfd_reloc_status_type flag
= bfd_reloc_ok
;
593 bfd_size_type octets
= reloc_entry
->address
* bfd_octets_per_byte (abfd
);
594 bfd_vma output_base
= 0;
595 reloc_howto_type
*howto
= reloc_entry
->howto
;
596 asection
*reloc_target_output_section
;
599 symbol
= *(reloc_entry
->sym_ptr_ptr
);
600 if (bfd_is_abs_section (symbol
->section
)
601 && output_bfd
!= (bfd
*) NULL
)
603 reloc_entry
->address
+= input_section
->output_offset
;
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
;
615 /* If there is a function supplied to handle this relocation type,
616 call it. It'll return `bfd_reloc_continue' if further processing
618 if (howto
->special_function
)
620 bfd_reloc_status_type cont
;
621 cont
= howto
->special_function (abfd
, reloc_entry
, symbol
, data
,
622 input_section
, output_bfd
,
624 if (cont
!= bfd_reloc_continue
)
628 /* Is the address of the relocation really within the section? */
629 if (reloc_entry
->address
> input_section
->_cooked_size
/
630 bfd_octets_per_byte (abfd
))
631 return bfd_reloc_outofrange
;
633 /* Work out which section the relocation is targetted at and the
634 initial relocation command value. */
636 /* Get symbol value. (Common symbols are special.) */
637 if (bfd_is_com_section (symbol
->section
))
640 relocation
= symbol
->value
;
642 reloc_target_output_section
= symbol
->section
->output_section
;
644 /* Convert input-section-relative symbol value to absolute. */
645 if (output_bfd
&& howto
->partial_inplace
== false)
648 output_base
= reloc_target_output_section
->vma
;
650 relocation
+= output_base
+ symbol
->section
->output_offset
;
652 /* Add in supplied addend. */
653 relocation
+= reloc_entry
->addend
;
655 /* Here the variable relocation holds the final address of the
656 symbol we are relocating against, plus any addend. */
658 if (howto
->pc_relative
== true)
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.
664 We start by subtracting the address of the section containing
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.
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.
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. */
689 input_section
->output_section
->vma
+ input_section
->output_offset
;
691 if (howto
->pcrel_offset
== true)
692 relocation
-= reloc_entry
->address
;
695 if (output_bfd
!= (bfd
*) NULL
)
697 if (howto
->partial_inplace
== false)
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
;
708 /* This is a partial relocation, but inplace, so modify the
711 If we've relocated with a symbol with a section, change
712 into a ref to the section belonging to the symbol. */
714 reloc_entry
->address
+= input_section
->output_offset
;
717 if (abfd
->xvec
->flavour
== bfd_target_coff_flavour
718 && strcmp (abfd
->xvec
->name
, "coff-Intel-little") != 0
719 && strcmp (abfd
->xvec
->name
, "coff-Intel-big") != 0)
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.
726 However, Ian wrote the following, regarding removing the line below,
727 which explains why it is still enabled: --djm
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.
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.
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.
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).
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).
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.
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:
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
786 6) if the resulting object files are the same, you have at least
788 7) if they are different you have to figure out which version is
791 relocation
-= reloc_entry
->addend
;
793 reloc_entry
->addend
= 0;
797 reloc_entry
->addend
= relocation
;
803 reloc_entry
->addend
= 0;
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
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
,
818 bfd_arch_bits_per_address (abfd
),
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)
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
842 x <<= (unsigned long) s.i0;
846 printf ("succeeded (%lx)\n", x);
850 relocation
>>= (bfd_vma
) howto
->rightshift
;
852 /* Shift everything up to where it's going to be used */
854 relocation
<<= (bfd_vma
) howto
->bitpos
;
856 /* Wait for the day when all have the mask in them */
859 i instruction to be left alone
860 o offset within instruction
861 r relocation offset to apply
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
873 and D D D D D to chop to right size
874 -----------------------
877 ( i i i i i o o o o o from bfd_get<size>
878 and N N N N N ) get instruction
879 -----------------------
885 -----------------------
886 = R R R R R R R R R R put into bfd_put<size>
890 x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
896 char x
= bfd_get_8 (abfd
, (char *) data
+ octets
);
898 bfd_put_8 (abfd
, x
, (unsigned char *) data
+ octets
);
904 short x
= bfd_get_16 (abfd
, (bfd_byte
*) data
+ octets
);
906 bfd_put_16 (abfd
, x
, (unsigned char *) data
+ octets
);
911 long x
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ octets
);
913 bfd_put_32 (abfd
, x
, (bfd_byte
*) data
+ octets
);
918 long x
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ octets
);
919 relocation
= -relocation
;
921 bfd_put_32 (abfd
, x
, (bfd_byte
*) data
+ octets
);
927 long x
= bfd_get_16 (abfd
, (bfd_byte
*) data
+ octets
);
928 relocation
= -relocation
;
930 bfd_put_16 (abfd
, x
, (bfd_byte
*) data
+ octets
);
941 bfd_vma x
= bfd_get_64 (abfd
, (bfd_byte
*) data
+ octets
);
943 bfd_put_64 (abfd
, x
, (bfd_byte
*) data
+ octets
);
950 return bfd_reloc_other
;
958 bfd_install_relocation
961 bfd_reloc_status_type
962 bfd_install_relocation
964 arelent *reloc_entry,
965 PTR data, bfd_vma data_start,
966 asection *input_section,
967 char **error_message);
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
975 For now, this function should be considered reserved for the
980 bfd_reloc_status_type
981 bfd_install_relocation (abfd
, reloc_entry
, data_start
, data_start_offset
,
982 input_section
, error_message
)
984 arelent
*reloc_entry
;
986 bfd_vma data_start_offset
;
987 asection
*input_section
;
988 char **error_message
;
991 bfd_reloc_status_type flag
= bfd_reloc_ok
;
992 bfd_size_type octets
= reloc_entry
->address
* bfd_octets_per_byte (abfd
);
993 bfd_vma output_base
= 0;
994 reloc_howto_type
*howto
= reloc_entry
->howto
;
995 asection
*reloc_target_output_section
;
999 symbol
= *(reloc_entry
->sym_ptr_ptr
);
1000 if (bfd_is_abs_section (symbol
->section
))
1002 reloc_entry
->address
+= input_section
->output_offset
;
1003 return bfd_reloc_ok
;
1006 /* If there is a function supplied to handle this relocation type,
1007 call it. It'll return `bfd_reloc_continue' if further processing
1009 if (howto
->special_function
)
1011 bfd_reloc_status_type cont
;
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
)
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
;
1028 /* Work out which section the relocation is targetted at and the
1029 initial relocation command value. */
1031 /* Get symbol value. (Common symbols are special.) */
1032 if (bfd_is_com_section (symbol
->section
))
1035 relocation
= symbol
->value
;
1037 reloc_target_output_section
= symbol
->section
->output_section
;
1039 /* Convert input-section-relative symbol value to absolute. */
1040 if (howto
->partial_inplace
== false)
1043 output_base
= reloc_target_output_section
->vma
;
1045 relocation
+= output_base
+ symbol
->section
->output_offset
;
1047 /* Add in supplied addend. */
1048 relocation
+= reloc_entry
->addend
;
1050 /* Here the variable relocation holds the final address of the
1051 symbol we are relocating against, plus any addend. */
1053 if (howto
->pc_relative
== true)
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.
1059 We start by subtracting the address of the section containing
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.
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.
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. */
1084 input_section
->output_section
->vma
+ input_section
->output_offset
;
1086 if (howto
->pcrel_offset
== true && howto
->partial_inplace
== true)
1087 relocation
-= reloc_entry
->address
;
1090 if (howto
->partial_inplace
== false)
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
;
1101 /* This is a partial relocation, but inplace, so modify the
1104 If we've relocated with a symbol with a section, change
1105 into a ref to the section belonging to the symbol. */
1107 reloc_entry
->address
+= input_section
->output_offset
;
1110 if (abfd
->xvec
->flavour
== bfd_target_coff_flavour
1111 && strcmp (abfd
->xvec
->name
, "coff-Intel-little") != 0
1112 && strcmp (abfd
->xvec
->name
, "coff-Intel-big") != 0)
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.
1119 However, Ian wrote the following, regarding removing the line below,
1120 which explains why it is still enabled: --djm
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.
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.
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.
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).
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).
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.
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:
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
1179 6) if the resulting object files are the same, you have at least
1181 7) if they are different you have to figure out which version is
1184 relocation
-= reloc_entry
->addend
;
1186 reloc_entry
->addend
= 0;
1190 reloc_entry
->addend
= relocation
;
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
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
,
1205 bfd_arch_bits_per_address (abfd
),
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)
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
1229 x <<= (unsigned long) s.i0;
1231 printf ("failed\n");
1233 printf ("succeeded (%lx)\n", x);
1237 relocation
>>= (bfd_vma
) howto
->rightshift
;
1239 /* Shift everything up to where it's going to be used */
1241 relocation
<<= (bfd_vma
) howto
->bitpos
;
1243 /* Wait for the day when all have the mask in them */
1246 i instruction to be left alone
1247 o offset within instruction
1248 r relocation offset to apply
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
1260 and D D D D D to chop to right size
1261 -----------------------
1264 ( i i i i i o o o o o from bfd_get<size>
1265 and N N N N N ) get instruction
1266 -----------------------
1272 -----------------------
1273 = R R R R R R R R R R put into bfd_put<size>
1277 x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
1279 data
= (bfd_byte
*) data_start
+ (octets
- data_start_offset
);
1281 switch (howto
->size
)
1285 char x
= bfd_get_8 (abfd
, (char *) data
);
1287 bfd_put_8 (abfd
, x
, (unsigned char *) data
);
1293 short x
= bfd_get_16 (abfd
, (bfd_byte
*) data
);
1295 bfd_put_16 (abfd
, x
, (unsigned char *) data
);
1300 long x
= bfd_get_32 (abfd
, (bfd_byte
*) data
);
1302 bfd_put_32 (abfd
, x
, (bfd_byte
*) data
);
1307 long x
= bfd_get_32 (abfd
, (bfd_byte
*) data
);
1308 relocation
= -relocation
;
1310 bfd_put_32 (abfd
, x
, (bfd_byte
*) data
);
1320 bfd_vma x
= bfd_get_64 (abfd
, (bfd_byte
*) data
);
1322 bfd_put_64 (abfd
, x
, (bfd_byte
*) data
);
1326 return bfd_reloc_other
;
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.
1338 This routine does a final relocation. Whether it is useful for a
1339 relocateable link depends upon how the object format defines
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.
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. */
1354 bfd_reloc_status_type
1355 _bfd_final_link_relocate (howto
, input_bfd
, input_section
, contents
, address
,
1357 reloc_howto_type
*howto
;
1359 asection
*input_section
;
1367 /* Sanity check the address. */
1368 if (address
> input_section
->_raw_size
)
1369 return bfd_reloc_outofrange
;
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
;
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
)
1389 relocation
-= (input_section
->output_section
->vma
1390 + input_section
->output_offset
);
1391 if (howto
->pcrel_offset
)
1392 relocation
-= address
;
1395 return _bfd_relocate_contents (howto
, input_bfd
, relocation
,
1396 contents
+ address
);
1399 /* Relocate a given location using a given value and howto. */
1401 bfd_reloc_status_type
1402 _bfd_relocate_contents (howto
, input_bfd
, relocation
, location
)
1403 reloc_howto_type
*howto
;
1410 bfd_reloc_status_type flag
;
1411 unsigned int rightshift
= howto
->rightshift
;
1412 unsigned int bitpos
= howto
->bitpos
;
1414 /* If the size is negative, negate RELOCATION. This isn't very
1416 if (howto
->size
< 0)
1417 relocation
= -relocation
;
1419 /* Get the value we are going to relocate. */
1420 size
= bfd_get_reloc_size (howto
);
1427 x
= bfd_get_8 (input_bfd
, location
);
1430 x
= bfd_get_16 (input_bfd
, location
);
1433 x
= bfd_get_32 (input_bfd
, location
);
1437 x
= bfd_get_64 (input_bfd
, location
);
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. */
1448 flag
= bfd_reloc_ok
;
1449 if (howto
->complain_on_overflow
!= complain_overflow_dont
)
1451 bfd_vma addrmask
, fieldmask
, signmask
, ss
;
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
;
1461 b
= x
& howto
->src_mask
;
1463 switch (howto
->complain_on_overflow
)
1465 case complain_overflow_signed
:
1466 a
= (a
& addrmask
) >> rightshift
;
1468 /* If any sign bits are set, all sign bits must be set.
1469 That is, A must be a valid negative address after
1471 signmask
= ~ (fieldmask
>> 1);
1473 if (ss
!= 0 && ss
!= ((addrmask
>> rightshift
) & signmask
))
1474 flag
= bfd_reloc_overflow
;
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
;
1484 /* Set all the bits above the sign bit. */
1485 b
= (b
^ signmask
) - signmask
;
1487 b
= (b
& addrmask
) >> bitpos
;
1489 /* Now we can do the addition. */
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)
1500 signmask
= (fieldmask
>> 1) + 1;
1501 if (((~ (a
^ b
)) & (a
^ sum
)) & signmask
)
1502 flag
= bfd_reloc_overflow
;
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
1518 a
= (a
& addrmask
) >> rightshift
;
1519 b
= (b
& addrmask
) >> bitpos
;
1520 sum
= (a
+ b
) & addrmask
;
1521 if ((a
| b
| sum
) & ~ fieldmask
)
1522 flag
= bfd_reloc_overflow
;
1526 case complain_overflow_bitfield
:
1527 /* Much like the signed check, but for a field one bit
1528 wider, and no trimming inputs with addrmask. We allow a
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. */
1535 signmask
= ~ fieldmask
;
1537 if (ss
!= 0 && ss
!= (((bfd_vma
) -1 >> rightshift
) & signmask
))
1538 flag
= bfd_reloc_overflow
;
1540 signmask
= ((~ howto
->src_mask
) >> 1) & howto
->src_mask
;
1541 b
= (b
^ signmask
) - signmask
;
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. */
1552 signmask
= fieldmask
+ 1;
1553 if (((~ (a
^ b
)) & (a
^ sum
)) & signmask
& addrmask
)
1554 flag
= bfd_reloc_overflow
;
1563 /* Put RELOCATION in the right bits. */
1564 relocation
>>= (bfd_vma
) rightshift
;
1565 relocation
<<= (bfd_vma
) bitpos
;
1567 /* Add RELOCATION to the right bits of X. */
1568 x
= ((x
& ~howto
->dst_mask
)
1569 | (((x
& howto
->src_mask
) + relocation
) & howto
->dst_mask
));
1571 /* Put the relocated value back in the object file. */
1578 bfd_put_8 (input_bfd
, x
, location
);
1581 bfd_put_16 (input_bfd
, x
, location
);
1584 bfd_put_32 (input_bfd
, x
, location
);
1588 bfd_put_64 (input_bfd
, x
, location
);
1601 howto manager, , typedef arelent, Relocations
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.
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.
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
1644 Basic absolute relocations of N bits.
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.
1663 The 24-bit relocation is used in some Intel 960 configurations.
1666 BFD_RELOC_32_GOT_PCREL
1668 BFD_RELOC_16_GOT_PCREL
1670 BFD_RELOC_8_GOT_PCREL
1676 BFD_RELOC_LO16_GOTOFF
1678 BFD_RELOC_HI16_GOTOFF
1680 BFD_RELOC_HI16_S_GOTOFF
1684 BFD_RELOC_64_PLT_PCREL
1686 BFD_RELOC_32_PLT_PCREL
1688 BFD_RELOC_24_PLT_PCREL
1690 BFD_RELOC_16_PLT_PCREL
1692 BFD_RELOC_8_PLT_PCREL
1700 BFD_RELOC_LO16_PLTOFF
1702 BFD_RELOC_HI16_PLTOFF
1704 BFD_RELOC_HI16_S_PLTOFF
1711 BFD_RELOC_68K_GLOB_DAT
1713 BFD_RELOC_68K_JMP_SLOT
1715 BFD_RELOC_68K_RELATIVE
1717 Relocations used by 68K ELF.
1720 BFD_RELOC_32_BASEREL
1722 BFD_RELOC_16_BASEREL
1724 BFD_RELOC_LO16_BASEREL
1726 BFD_RELOC_HI16_BASEREL
1728 BFD_RELOC_HI16_S_BASEREL
1734 Linkage-table relative.
1739 Absolute 8-bit relocation, but used to form an address like 0xFFnn.
1742 BFD_RELOC_32_PCREL_S2
1744 BFD_RELOC_16_PCREL_S2
1746 BFD_RELOC_23_PCREL_S2
1748 These PC-relative relocations are stored as word displacements --
1749 i.e., byte displacements shifted right two bits. The 30-bit word
1750 displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the
1751 SPARC. (SPARC tools generally refer to this as <<WDISP30>>.) The
1752 signed 16-bit displacement is used on the MIPS, and the 23-bit
1753 displacement is used on the Alpha.
1760 High 22 bits and low 10 bits of 32-bit value, placed into lower bits of
1761 the target word. These are used on the SPARC.
1768 For systems that allocate a Global Pointer register, these are
1769 displacements off that register. These relocation types are
1770 handled specially, because the value the register will have is
1771 decided relatively late.
1774 BFD_RELOC_I960_CALLJ
1776 Reloc types used for i960/b.out.
1781 BFD_RELOC_SPARC_WDISP22
1787 BFD_RELOC_SPARC_GOT10
1789 BFD_RELOC_SPARC_GOT13
1791 BFD_RELOC_SPARC_GOT22
1793 BFD_RELOC_SPARC_PC10
1795 BFD_RELOC_SPARC_PC22
1797 BFD_RELOC_SPARC_WPLT30
1799 BFD_RELOC_SPARC_COPY
1801 BFD_RELOC_SPARC_GLOB_DAT
1803 BFD_RELOC_SPARC_JMP_SLOT
1805 BFD_RELOC_SPARC_RELATIVE
1807 BFD_RELOC_SPARC_UA16
1809 BFD_RELOC_SPARC_UA32
1811 BFD_RELOC_SPARC_UA64
1813 SPARC ELF relocations. There is probably some overlap with other
1814 relocation types already defined.
1817 BFD_RELOC_SPARC_BASE13
1819 BFD_RELOC_SPARC_BASE22
1821 I think these are specific to SPARC a.out (e.g., Sun 4).
1831 BFD_RELOC_SPARC_OLO10
1833 BFD_RELOC_SPARC_HH22
1835 BFD_RELOC_SPARC_HM10
1837 BFD_RELOC_SPARC_LM22
1839 BFD_RELOC_SPARC_PC_HH22
1841 BFD_RELOC_SPARC_PC_HM10
1843 BFD_RELOC_SPARC_PC_LM22
1845 BFD_RELOC_SPARC_WDISP16
1847 BFD_RELOC_SPARC_WDISP19
1855 BFD_RELOC_SPARC_DISP64
1858 BFD_RELOC_SPARC_PLT64
1860 BFD_RELOC_SPARC_HIX22
1862 BFD_RELOC_SPARC_LOX10
1870 BFD_RELOC_SPARC_REGISTER
1875 BFD_RELOC_SPARC_REV32
1877 SPARC little endian relocation
1880 BFD_RELOC_ALPHA_GPDISP_HI16
1882 Alpha ECOFF and ELF relocations. Some of these treat the symbol or
1883 "addend" in some special way.
1884 For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when
1885 writing; when reading, it will be the absolute section symbol. The
1886 addend is the displacement in bytes of the "lda" instruction from
1887 the "ldah" instruction (which is at the address of this reloc).
1889 BFD_RELOC_ALPHA_GPDISP_LO16
1891 For GPDISP_LO16 ("ignore") relocations, the symbol is handled as
1892 with GPDISP_HI16 relocs. The addend is ignored when writing the
1893 relocations out, and is filled in with the file's GP value on
1894 reading, for convenience.
1897 BFD_RELOC_ALPHA_GPDISP
1899 The ELF GPDISP relocation is exactly the same as the GPDISP_HI16
1900 relocation except that there is no accompanying GPDISP_LO16
1904 BFD_RELOC_ALPHA_LITERAL
1906 BFD_RELOC_ALPHA_ELF_LITERAL
1908 BFD_RELOC_ALPHA_LITUSE
1910 The Alpha LITERAL/LITUSE relocs are produced by a symbol reference;
1911 the assembler turns it into a LDQ instruction to load the address of
1912 the symbol, and then fills in a register in the real instruction.
1914 The LITERAL reloc, at the LDQ instruction, refers to the .lita
1915 section symbol. The addend is ignored when writing, but is filled
1916 in with the file's GP value on reading, for convenience, as with the
1919 The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16.
1920 It should refer to the symbol to be referenced, as with 16_GOTOFF,
1921 but it generates output not based on the position within the .got
1922 section, but relative to the GP value chosen for the file during the
1925 The LITUSE reloc, on the instruction using the loaded address, gives
1926 information to the linker that it might be able to use to optimize
1927 away some literal section references. The symbol is ignored (read
1928 as the absolute section symbol), and the "addend" indicates the type
1929 of instruction using the register:
1930 1 - "memory" fmt insn
1931 2 - byte-manipulation (byte offset reg)
1932 3 - jsr (target of branch)
1934 The GNU linker currently doesn't do any of this optimizing.
1937 BFD_RELOC_ALPHA_USER_LITERAL
1939 BFD_RELOC_ALPHA_USER_LITUSE_BASE
1941 BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF
1943 BFD_RELOC_ALPHA_USER_LITUSE_JSR
1945 BFD_RELOC_ALPHA_USER_GPDISP
1947 BFD_RELOC_ALPHA_USER_GPRELHIGH
1949 BFD_RELOC_ALPHA_USER_GPRELLOW
1951 The BFD_RELOC_ALPHA_USER_* relocations are used by the assembler to
1952 process the explicit !<reloc>!sequence relocations, and are mapped
1953 into the normal relocations at the end of processing.
1956 BFD_RELOC_ALPHA_HINT
1958 The HINT relocation indicates a value that should be filled into the
1959 "hint" field of a jmp/jsr/ret instruction, for possible branch-
1960 prediction logic which may be provided on some processors.
1963 BFD_RELOC_ALPHA_LINKAGE
1965 The LINKAGE relocation outputs a linkage pair in the object file,
1966 which is filled by the linker.
1969 BFD_RELOC_ALPHA_CODEADDR
1971 The CODEADDR relocation outputs a STO_CA in the object file,
1972 which is filled by the linker.
1977 Bits 27..2 of the relocation address shifted right 2 bits;
1978 simple reloc otherwise.
1981 BFD_RELOC_MIPS16_JMP
1983 The MIPS16 jump instruction.
1986 BFD_RELOC_MIPS16_GPREL
1988 MIPS16 GP relative reloc.
1993 High 16 bits of 32-bit value; simple reloc.
1997 High 16 bits of 32-bit value but the low 16 bits will be sign
1998 extended and added to form the final result. If the low 16
1999 bits form a negative number, we need to add one to the high value
2000 to compensate for the borrow when the low bits are added.
2006 BFD_RELOC_PCREL_HI16_S
2008 Like BFD_RELOC_HI16_S, but PC relative.
2010 BFD_RELOC_PCREL_LO16
2012 Like BFD_RELOC_LO16, but PC relative.
2015 BFD_RELOC_MIPS_GPREL
2018 Relocation relative to the global pointer.
2021 BFD_RELOC_MIPS_LITERAL
2023 Relocation against a MIPS literal section.
2026 BFD_RELOC_MIPS_GOT16
2028 BFD_RELOC_MIPS_CALL16
2030 BFD_RELOC_MIPS_GPREL32
2033 BFD_RELOC_MIPS_GOT_HI16
2035 BFD_RELOC_MIPS_GOT_LO16
2037 BFD_RELOC_MIPS_CALL_HI16
2039 BFD_RELOC_MIPS_CALL_LO16
2043 BFD_RELOC_MIPS_GOT_PAGE
2045 BFD_RELOC_MIPS_GOT_OFST
2047 BFD_RELOC_MIPS_GOT_DISP
2049 BFD_RELOC_MIPS_SHIFT5
2051 BFD_RELOC_MIPS_SHIFT6
2053 BFD_RELOC_MIPS_INSERT_A
2055 BFD_RELOC_MIPS_INSERT_B
2057 BFD_RELOC_MIPS_DELETE
2059 BFD_RELOC_MIPS_HIGHEST
2061 BFD_RELOC_MIPS_HIGHER
2063 BFD_RELOC_MIPS_SCN_DISP
2065 BFD_RELOC_MIPS_REL16
2067 BFD_RELOC_MIPS_RELGOT
2072 MIPS ELF relocations.
2083 BFD_RELOC_386_GLOB_DAT
2085 BFD_RELOC_386_JUMP_SLOT
2087 BFD_RELOC_386_RELATIVE
2089 BFD_RELOC_386_GOTOFF
2093 i386/elf relocations
2096 BFD_RELOC_X86_64_GOT32
2098 BFD_RELOC_X86_64_PLT32
2100 BFD_RELOC_X86_64_COPY
2102 BFD_RELOC_X86_64_GLOB_DAT
2104 BFD_RELOC_X86_64_JUMP_SLOT
2106 BFD_RELOC_X86_64_RELATIVE
2108 BFD_RELOC_X86_64_GOTPCREL
2110 BFD_RELOC_X86_64_32S
2112 x86-64/elf relocations
2115 BFD_RELOC_NS32K_IMM_8
2117 BFD_RELOC_NS32K_IMM_16
2119 BFD_RELOC_NS32K_IMM_32
2121 BFD_RELOC_NS32K_IMM_8_PCREL
2123 BFD_RELOC_NS32K_IMM_16_PCREL
2125 BFD_RELOC_NS32K_IMM_32_PCREL
2127 BFD_RELOC_NS32K_DISP_8
2129 BFD_RELOC_NS32K_DISP_16
2131 BFD_RELOC_NS32K_DISP_32
2133 BFD_RELOC_NS32K_DISP_8_PCREL
2135 BFD_RELOC_NS32K_DISP_16_PCREL
2137 BFD_RELOC_NS32K_DISP_32_PCREL
2142 BFD_RELOC_PDP11_DISP_8_PCREL
2144 BFD_RELOC_PDP11_DISP_6_PCREL
2149 BFD_RELOC_PJ_CODE_HI16
2151 BFD_RELOC_PJ_CODE_LO16
2153 BFD_RELOC_PJ_CODE_DIR16
2155 BFD_RELOC_PJ_CODE_DIR32
2157 BFD_RELOC_PJ_CODE_REL16
2159 BFD_RELOC_PJ_CODE_REL32
2161 Picojava relocs. Not all of these appear in object files.
2172 BFD_RELOC_PPC_B16_BRTAKEN
2174 BFD_RELOC_PPC_B16_BRNTAKEN
2178 BFD_RELOC_PPC_BA16_BRTAKEN
2180 BFD_RELOC_PPC_BA16_BRNTAKEN
2184 BFD_RELOC_PPC_GLOB_DAT
2186 BFD_RELOC_PPC_JMP_SLOT
2188 BFD_RELOC_PPC_RELATIVE
2190 BFD_RELOC_PPC_LOCAL24PC
2192 BFD_RELOC_PPC_EMB_NADDR32
2194 BFD_RELOC_PPC_EMB_NADDR16
2196 BFD_RELOC_PPC_EMB_NADDR16_LO
2198 BFD_RELOC_PPC_EMB_NADDR16_HI
2200 BFD_RELOC_PPC_EMB_NADDR16_HA
2202 BFD_RELOC_PPC_EMB_SDAI16
2204 BFD_RELOC_PPC_EMB_SDA2I16
2206 BFD_RELOC_PPC_EMB_SDA2REL
2208 BFD_RELOC_PPC_EMB_SDA21
2210 BFD_RELOC_PPC_EMB_MRKREF
2212 BFD_RELOC_PPC_EMB_RELSEC16
2214 BFD_RELOC_PPC_EMB_RELST_LO
2216 BFD_RELOC_PPC_EMB_RELST_HI
2218 BFD_RELOC_PPC_EMB_RELST_HA
2220 BFD_RELOC_PPC_EMB_BIT_FLD
2222 BFD_RELOC_PPC_EMB_RELSDA
2224 BFD_RELOC_PPC64_HIGHER
2226 BFD_RELOC_PPC64_HIGHER_S
2228 BFD_RELOC_PPC64_HIGHEST
2230 BFD_RELOC_PPC64_HIGHEST_S
2232 BFD_RELOC_PPC64_TOC16_LO
2234 BFD_RELOC_PPC64_TOC16_HI
2236 BFD_RELOC_PPC64_TOC16_HA
2240 BFD_RELOC_PPC64_PLTGOT16
2242 BFD_RELOC_PPC64_PLTGOT16_LO
2244 BFD_RELOC_PPC64_PLTGOT16_HI
2246 BFD_RELOC_PPC64_PLTGOT16_HA
2248 BFD_RELOC_PPC64_ADDR16_DS
2250 BFD_RELOC_PPC64_ADDR16_LO_DS
2252 BFD_RELOC_PPC64_GOT16_DS
2254 BFD_RELOC_PPC64_GOT16_LO_DS
2256 BFD_RELOC_PPC64_PLT16_LO_DS
2258 BFD_RELOC_PPC64_SECTOFF_DS
2260 BFD_RELOC_PPC64_SECTOFF_LO_DS
2262 BFD_RELOC_PPC64_TOC16_DS
2264 BFD_RELOC_PPC64_TOC16_LO_DS
2266 BFD_RELOC_PPC64_PLTGOT16_DS
2268 BFD_RELOC_PPC64_PLTGOT16_LO_DS
2270 Power(rs6000) and PowerPC relocations.
2275 IBM 370/390 relocations
2280 The type of reloc used to build a contructor table - at the moment
2281 probably a 32 bit wide absolute relocation, but the target can choose.
2282 It generally does map to one of the other relocation types.
2285 BFD_RELOC_ARM_PCREL_BRANCH
2287 ARM 26 bit pc-relative branch. The lowest two bits must be zero and are
2288 not stored in the instruction.
2290 BFD_RELOC_ARM_PCREL_BLX
2292 ARM 26 bit pc-relative branch. The lowest bit must be zero and is
2293 not stored in the instruction. The 2nd lowest bit comes from a 1 bit
2294 field in the instruction.
2296 BFD_RELOC_THUMB_PCREL_BLX
2298 Thumb 22 bit pc-relative branch. The lowest bit must be zero and is
2299 not stored in the instruction. The 2nd lowest bit comes from a 1 bit
2300 field in the instruction.
2302 BFD_RELOC_ARM_IMMEDIATE
2304 BFD_RELOC_ARM_ADRL_IMMEDIATE
2306 BFD_RELOC_ARM_OFFSET_IMM
2308 BFD_RELOC_ARM_SHIFT_IMM
2314 BFD_RELOC_ARM_CP_OFF_IMM
2316 BFD_RELOC_ARM_ADR_IMM
2318 BFD_RELOC_ARM_LDR_IMM
2320 BFD_RELOC_ARM_LITERAL
2322 BFD_RELOC_ARM_IN_POOL
2324 BFD_RELOC_ARM_OFFSET_IMM8
2326 BFD_RELOC_ARM_HWLITERAL
2328 BFD_RELOC_ARM_THUMB_ADD
2330 BFD_RELOC_ARM_THUMB_IMM
2332 BFD_RELOC_ARM_THUMB_SHIFT
2334 BFD_RELOC_ARM_THUMB_OFFSET
2340 BFD_RELOC_ARM_JUMP_SLOT
2344 BFD_RELOC_ARM_GLOB_DAT
2348 BFD_RELOC_ARM_RELATIVE
2350 BFD_RELOC_ARM_GOTOFF
2354 These relocs are only used within the ARM assembler. They are not
2355 (at present) written to any object files.
2358 BFD_RELOC_SH_PCDISP8BY2
2360 BFD_RELOC_SH_PCDISP12BY2
2364 BFD_RELOC_SH_IMM4BY2
2366 BFD_RELOC_SH_IMM4BY4
2370 BFD_RELOC_SH_IMM8BY2
2372 BFD_RELOC_SH_IMM8BY4
2374 BFD_RELOC_SH_PCRELIMM8BY2
2376 BFD_RELOC_SH_PCRELIMM8BY4
2378 BFD_RELOC_SH_SWITCH16
2380 BFD_RELOC_SH_SWITCH32
2394 BFD_RELOC_SH_LOOP_START
2396 BFD_RELOC_SH_LOOP_END
2400 BFD_RELOC_SH_GLOB_DAT
2402 BFD_RELOC_SH_JMP_SLOT
2404 BFD_RELOC_SH_RELATIVE
2408 Hitachi SH relocs. Not all of these appear in object files.
2411 BFD_RELOC_THUMB_PCREL_BRANCH9
2413 BFD_RELOC_THUMB_PCREL_BRANCH12
2415 BFD_RELOC_THUMB_PCREL_BRANCH23
2417 Thumb 23-, 12- and 9-bit pc-relative branches. The lowest bit must
2418 be zero and is not stored in the instruction.
2421 BFD_RELOC_ARC_B22_PCREL
2424 ARC 22 bit pc-relative branch. The lowest two bits must be zero and are
2425 not stored in the instruction. The high 20 bits are installed in bits 26
2426 through 7 of the instruction.
2430 ARC 26 bit absolute branch. The lowest two bits must be zero and are not
2431 stored in the instruction. The high 24 bits are installed in bits 23
2435 BFD_RELOC_D10V_10_PCREL_R
2437 Mitsubishi D10V relocs.
2438 This is a 10-bit reloc with the right 2 bits
2441 BFD_RELOC_D10V_10_PCREL_L
2443 Mitsubishi D10V relocs.
2444 This is a 10-bit reloc with the right 2 bits
2445 assumed to be 0. This is the same as the previous reloc
2446 except it is in the left container, i.e.,
2447 shifted left 15 bits.
2451 This is an 18-bit reloc with the right 2 bits
2454 BFD_RELOC_D10V_18_PCREL
2456 This is an 18-bit reloc with the right 2 bits
2462 Mitsubishi D30V relocs.
2463 This is a 6-bit absolute reloc.
2465 BFD_RELOC_D30V_9_PCREL
2467 This is a 6-bit pc-relative reloc with
2468 the right 3 bits assumed to be 0.
2470 BFD_RELOC_D30V_9_PCREL_R
2472 This is a 6-bit pc-relative reloc with
2473 the right 3 bits assumed to be 0. Same
2474 as the previous reloc but on the right side
2479 This is a 12-bit absolute reloc with the
2480 right 3 bitsassumed to be 0.
2482 BFD_RELOC_D30V_15_PCREL
2484 This is a 12-bit pc-relative reloc with
2485 the right 3 bits assumed to be 0.
2487 BFD_RELOC_D30V_15_PCREL_R
2489 This is a 12-bit pc-relative reloc with
2490 the right 3 bits assumed to be 0. Same
2491 as the previous reloc but on the right side
2496 This is an 18-bit absolute reloc with
2497 the right 3 bits assumed to be 0.
2499 BFD_RELOC_D30V_21_PCREL
2501 This is an 18-bit pc-relative reloc with
2502 the right 3 bits assumed to be 0.
2504 BFD_RELOC_D30V_21_PCREL_R
2506 This is an 18-bit pc-relative reloc with
2507 the right 3 bits assumed to be 0. Same
2508 as the previous reloc but on the right side
2513 This is a 32-bit absolute reloc.
2515 BFD_RELOC_D30V_32_PCREL
2517 This is a 32-bit pc-relative reloc.
2522 Mitsubishi M32R relocs.
2523 This is a 24 bit absolute address.
2525 BFD_RELOC_M32R_10_PCREL
2527 This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0.
2529 BFD_RELOC_M32R_18_PCREL
2531 This is an 18-bit reloc with the right 2 bits assumed to be 0.
2533 BFD_RELOC_M32R_26_PCREL
2535 This is a 26-bit reloc with the right 2 bits assumed to be 0.
2537 BFD_RELOC_M32R_HI16_ULO
2539 This is a 16-bit reloc containing the high 16 bits of an address
2540 used when the lower 16 bits are treated as unsigned.
2542 BFD_RELOC_M32R_HI16_SLO
2544 This is a 16-bit reloc containing the high 16 bits of an address
2545 used when the lower 16 bits are treated as signed.
2549 This is a 16-bit reloc containing the lower 16 bits of an address.
2551 BFD_RELOC_M32R_SDA16
2553 This is a 16-bit reloc containing the small data area offset for use in
2554 add3, load, and store instructions.
2557 BFD_RELOC_V850_9_PCREL
2559 This is a 9-bit reloc
2561 BFD_RELOC_V850_22_PCREL
2563 This is a 22-bit reloc
2566 BFD_RELOC_V850_SDA_16_16_OFFSET
2568 This is a 16 bit offset from the short data area pointer.
2570 BFD_RELOC_V850_SDA_15_16_OFFSET
2572 This is a 16 bit offset (of which only 15 bits are used) from the
2573 short data area pointer.
2575 BFD_RELOC_V850_ZDA_16_16_OFFSET
2577 This is a 16 bit offset from the zero data area pointer.
2579 BFD_RELOC_V850_ZDA_15_16_OFFSET
2581 This is a 16 bit offset (of which only 15 bits are used) from the
2582 zero data area pointer.
2584 BFD_RELOC_V850_TDA_6_8_OFFSET
2586 This is an 8 bit offset (of which only 6 bits are used) from the
2587 tiny data area pointer.
2589 BFD_RELOC_V850_TDA_7_8_OFFSET
2591 This is an 8bit offset (of which only 7 bits are used) from the tiny
2594 BFD_RELOC_V850_TDA_7_7_OFFSET
2596 This is a 7 bit offset from the tiny data area pointer.
2598 BFD_RELOC_V850_TDA_16_16_OFFSET
2600 This is a 16 bit offset from the tiny data area pointer.
2603 BFD_RELOC_V850_TDA_4_5_OFFSET
2605 This is a 5 bit offset (of which only 4 bits are used) from the tiny
2608 BFD_RELOC_V850_TDA_4_4_OFFSET
2610 This is a 4 bit offset from the tiny data area pointer.
2612 BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET
2614 This is a 16 bit offset from the short data area pointer, with the
2615 bits placed non-contigously in the instruction.
2617 BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET
2619 This is a 16 bit offset from the zero data area pointer, with the
2620 bits placed non-contigously in the instruction.
2622 BFD_RELOC_V850_CALLT_6_7_OFFSET
2624 This is a 6 bit offset from the call table base pointer.
2626 BFD_RELOC_V850_CALLT_16_16_OFFSET
2628 This is a 16 bit offset from the call table base pointer.
2632 BFD_RELOC_MN10300_32_PCREL
2634 This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
2637 BFD_RELOC_MN10300_16_PCREL
2639 This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
2645 This is a 8bit DP reloc for the tms320c30, where the most
2646 significant 8 bits of a 24 bit word are placed into the least
2647 significant 8 bits of the opcode.
2650 BFD_RELOC_TIC54X_PARTLS7
2652 This is a 7bit reloc for the tms320c54x, where the least
2653 significant 7 bits of a 16 bit word are placed into the least
2654 significant 7 bits of the opcode.
2657 BFD_RELOC_TIC54X_PARTMS9
2659 This is a 9bit DP reloc for the tms320c54x, where the most
2660 significant 9 bits of a 16 bit word are placed into the least
2661 significant 9 bits of the opcode.
2666 This is an extended address 23-bit reloc for the tms320c54x.
2669 BFD_RELOC_TIC54X_16_OF_23
2671 This is a 16-bit reloc for the tms320c54x, where the least
2672 significant 16 bits of a 23-bit extended address are placed into
2676 BFD_RELOC_TIC54X_MS7_OF_23
2678 This is a reloc for the tms320c54x, where the most
2679 significant 7 bits of a 23-bit extended address are placed into
2685 This is a 48 bit reloc for the FR30 that stores 32 bits.
2689 This is a 32 bit reloc for the FR30 that stores 20 bits split up into
2692 BFD_RELOC_FR30_6_IN_4
2694 This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in
2697 BFD_RELOC_FR30_8_IN_8
2699 This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset
2702 BFD_RELOC_FR30_9_IN_8
2704 This is a 16 bit reloc for the FR30 that stores a 9 bit short offset
2707 BFD_RELOC_FR30_10_IN_8
2709 This is a 16 bit reloc for the FR30 that stores a 10 bit word offset
2712 BFD_RELOC_FR30_9_PCREL
2714 This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative
2715 short offset into 8 bits.
2717 BFD_RELOC_FR30_12_PCREL
2719 This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative
2720 short offset into 11 bits.
2723 BFD_RELOC_MCORE_PCREL_IMM8BY4
2725 BFD_RELOC_MCORE_PCREL_IMM11BY2
2727 BFD_RELOC_MCORE_PCREL_IMM4BY2
2729 BFD_RELOC_MCORE_PCREL_32
2731 BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2
2735 Motorola Mcore relocations.
2738 BFD_RELOC_AVR_7_PCREL
2740 This is a 16 bit reloc for the AVR that stores 8 bit pc relative
2741 short offset into 7 bits.
2743 BFD_RELOC_AVR_13_PCREL
2745 This is a 16 bit reloc for the AVR that stores 13 bit pc relative
2746 short offset into 12 bits.
2750 This is a 16 bit reloc for the AVR that stores 17 bit value (usually
2751 program memory address) into 16 bits.
2753 BFD_RELOC_AVR_LO8_LDI
2755 This is a 16 bit reloc for the AVR that stores 8 bit value (usually
2756 data memory address) into 8 bit immediate value of LDI insn.
2758 BFD_RELOC_AVR_HI8_LDI
2760 This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit
2761 of data memory address) into 8 bit immediate value of LDI insn.
2763 BFD_RELOC_AVR_HH8_LDI
2765 This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit
2766 of program memory address) into 8 bit immediate value of LDI insn.
2768 BFD_RELOC_AVR_LO8_LDI_NEG
2770 This is a 16 bit reloc for the AVR that stores negated 8 bit value
2771 (usually data memory address) into 8 bit immediate value of SUBI insn.
2773 BFD_RELOC_AVR_HI8_LDI_NEG
2775 This is a 16 bit reloc for the AVR that stores negated 8 bit value
2776 (high 8 bit of data memory address) into 8 bit immediate value of
2779 BFD_RELOC_AVR_HH8_LDI_NEG
2781 This is a 16 bit reloc for the AVR that stores negated 8 bit value
2782 (most high 8 bit of program memory address) into 8 bit immediate value
2783 of LDI or SUBI insn.
2785 BFD_RELOC_AVR_LO8_LDI_PM
2787 This is a 16 bit reloc for the AVR that stores 8 bit value (usually
2788 command address) into 8 bit immediate value of LDI insn.
2790 BFD_RELOC_AVR_HI8_LDI_PM
2792 This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit
2793 of command address) into 8 bit immediate value of LDI insn.
2795 BFD_RELOC_AVR_HH8_LDI_PM
2797 This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit
2798 of command address) into 8 bit immediate value of LDI insn.
2800 BFD_RELOC_AVR_LO8_LDI_PM_NEG
2802 This is a 16 bit reloc for the AVR that stores negated 8 bit value
2803 (usually command address) into 8 bit immediate value of SUBI insn.
2805 BFD_RELOC_AVR_HI8_LDI_PM_NEG
2807 This is a 16 bit reloc for the AVR that stores negated 8 bit value
2808 (high 8 bit of 16 bit command address) into 8 bit immediate value
2811 BFD_RELOC_AVR_HH8_LDI_PM_NEG
2813 This is a 16 bit reloc for the AVR that stores negated 8 bit value
2814 (high 6 bit of 22 bit command address) into 8 bit immediate
2819 This is a 32 bit reloc for the AVR that stores 23 bit value
2833 32 bit PC relative PLT address.
2837 Copy symbol at runtime.
2839 BFD_RELOC_390_GLOB_DAT
2843 BFD_RELOC_390_JMP_SLOT
2847 BFD_RELOC_390_RELATIVE
2849 Adjust by program base.
2853 32 bit PC relative offset to GOT.
2859 BFD_RELOC_390_PC16DBL
2861 PC relative 16 bit shifted by 1.
2863 BFD_RELOC_390_PLT16DBL
2865 16 bit PC rel. PLT shifted by 1.
2867 BFD_RELOC_390_PC32DBL
2869 PC relative 32 bit shifted by 1.
2871 BFD_RELOC_390_PLT32DBL
2873 32 bit PC rel. PLT shifted by 1.
2875 BFD_RELOC_390_GOTPCDBL
2877 32 bit PC rel. GOT shifted by 1.
2885 64 bit PC relative PLT address.
2887 BFD_RELOC_390_GOTENT
2889 32 bit rel. offset to GOT entry.
2892 BFD_RELOC_VTABLE_INHERIT
2894 BFD_RELOC_VTABLE_ENTRY
2896 These two relocations are used by the linker to determine which of
2897 the entries in a C++ virtual function table are actually used. When
2898 the --gc-sections option is given, the linker will zero out the entries
2899 that are not used, so that the code for those functions need not be
2900 included in the output.
2902 VTABLE_INHERIT is a zero-space relocation used to describe to the
2903 linker the inheritence tree of a C++ virtual function table. The
2904 relocation's symbol should be the parent class' vtable, and the
2905 relocation should be located at the child vtable.
2907 VTABLE_ENTRY is a zero-space relocation that describes the use of a
2908 virtual function table entry. The reloc's symbol should refer to the
2909 table of the class mentioned in the code. Off of that base, an offset
2910 describes the entry that is being used. For Rela hosts, this offset
2911 is stored in the reloc's addend. For Rel hosts, we are forced to put
2912 this offset in the reloc's section offset.
2915 BFD_RELOC_IA64_IMM14
2917 BFD_RELOC_IA64_IMM22
2919 BFD_RELOC_IA64_IMM64
2921 BFD_RELOC_IA64_DIR32MSB
2923 BFD_RELOC_IA64_DIR32LSB
2925 BFD_RELOC_IA64_DIR64MSB
2927 BFD_RELOC_IA64_DIR64LSB
2929 BFD_RELOC_IA64_GPREL22
2931 BFD_RELOC_IA64_GPREL64I
2933 BFD_RELOC_IA64_GPREL32MSB
2935 BFD_RELOC_IA64_GPREL32LSB
2937 BFD_RELOC_IA64_GPREL64MSB
2939 BFD_RELOC_IA64_GPREL64LSB
2941 BFD_RELOC_IA64_LTOFF22
2943 BFD_RELOC_IA64_LTOFF64I
2945 BFD_RELOC_IA64_PLTOFF22
2947 BFD_RELOC_IA64_PLTOFF64I
2949 BFD_RELOC_IA64_PLTOFF64MSB
2951 BFD_RELOC_IA64_PLTOFF64LSB
2953 BFD_RELOC_IA64_FPTR64I
2955 BFD_RELOC_IA64_FPTR32MSB
2957 BFD_RELOC_IA64_FPTR32LSB
2959 BFD_RELOC_IA64_FPTR64MSB
2961 BFD_RELOC_IA64_FPTR64LSB
2963 BFD_RELOC_IA64_PCREL21B
2965 BFD_RELOC_IA64_PCREL21BI
2967 BFD_RELOC_IA64_PCREL21M
2969 BFD_RELOC_IA64_PCREL21F
2971 BFD_RELOC_IA64_PCREL22
2973 BFD_RELOC_IA64_PCREL60B
2975 BFD_RELOC_IA64_PCREL64I
2977 BFD_RELOC_IA64_PCREL32MSB
2979 BFD_RELOC_IA64_PCREL32LSB
2981 BFD_RELOC_IA64_PCREL64MSB
2983 BFD_RELOC_IA64_PCREL64LSB
2985 BFD_RELOC_IA64_LTOFF_FPTR22
2987 BFD_RELOC_IA64_LTOFF_FPTR64I
2989 BFD_RELOC_IA64_LTOFF_FPTR32MSB
2991 BFD_RELOC_IA64_LTOFF_FPTR32LSB
2993 BFD_RELOC_IA64_LTOFF_FPTR64MSB
2995 BFD_RELOC_IA64_LTOFF_FPTR64LSB
2997 BFD_RELOC_IA64_SEGREL32MSB
2999 BFD_RELOC_IA64_SEGREL32LSB
3001 BFD_RELOC_IA64_SEGREL64MSB
3003 BFD_RELOC_IA64_SEGREL64LSB
3005 BFD_RELOC_IA64_SECREL32MSB
3007 BFD_RELOC_IA64_SECREL32LSB
3009 BFD_RELOC_IA64_SECREL64MSB
3011 BFD_RELOC_IA64_SECREL64LSB
3013 BFD_RELOC_IA64_REL32MSB
3015 BFD_RELOC_IA64_REL32LSB
3017 BFD_RELOC_IA64_REL64MSB
3019 BFD_RELOC_IA64_REL64LSB
3021 BFD_RELOC_IA64_LTV32MSB
3023 BFD_RELOC_IA64_LTV32LSB
3025 BFD_RELOC_IA64_LTV64MSB
3027 BFD_RELOC_IA64_LTV64LSB
3029 BFD_RELOC_IA64_IPLTMSB
3031 BFD_RELOC_IA64_IPLTLSB
3035 BFD_RELOC_IA64_TPREL22
3037 BFD_RELOC_IA64_TPREL64MSB
3039 BFD_RELOC_IA64_TPREL64LSB
3041 BFD_RELOC_IA64_LTOFF_TP22
3043 BFD_RELOC_IA64_LTOFF22X
3045 BFD_RELOC_IA64_LDXMOV
3047 Intel IA64 Relocations.
3050 BFD_RELOC_M68HC11_HI8
3052 Motorola 68HC11 reloc.
3053 This is the 8 bits high part of an absolute address.
3055 BFD_RELOC_M68HC11_LO8
3057 Motorola 68HC11 reloc.
3058 This is the 8 bits low part of an absolute address.
3060 BFD_RELOC_M68HC11_3B
3062 Motorola 68HC11 reloc.
3063 This is the 3 bits of a value.
3066 BFD_RELOC_CRIS_BDISP8
3068 BFD_RELOC_CRIS_UNSIGNED_5
3070 BFD_RELOC_CRIS_SIGNED_6
3072 BFD_RELOC_CRIS_UNSIGNED_6
3074 BFD_RELOC_CRIS_UNSIGNED_4
3076 These relocs are only used within the CRIS assembler. They are not
3077 (at present) written to any object files.
3081 BFD_RELOC_CRIS_GLOB_DAT
3083 BFD_RELOC_CRIS_JUMP_SLOT
3085 BFD_RELOC_CRIS_RELATIVE
3087 Relocs used in ELF shared libraries for CRIS.
3089 BFD_RELOC_CRIS_32_GOT
3091 32-bit offset to symbol-entry within GOT.
3093 BFD_RELOC_CRIS_16_GOT
3095 16-bit offset to symbol-entry within GOT.
3097 BFD_RELOC_CRIS_32_GOTPLT
3099 32-bit offset to symbol-entry within GOT, with PLT handling.
3101 BFD_RELOC_CRIS_16_GOTPLT
3103 16-bit offset to symbol-entry within GOT, with PLT handling.
3105 BFD_RELOC_CRIS_32_GOTREL
3107 32-bit offset to symbol, relative to GOT.
3109 BFD_RELOC_CRIS_32_PLT_GOTREL
3111 32-bit offset to symbol with PLT entry, relative to GOT.
3113 BFD_RELOC_CRIS_32_PLT_PCREL
3115 32-bit offset to symbol with PLT entry, relative to this relocation.
3120 BFD_RELOC_860_GLOB_DAT
3122 BFD_RELOC_860_JUMP_SLOT
3124 BFD_RELOC_860_RELATIVE
3134 BFD_RELOC_860_SPLIT0
3138 BFD_RELOC_860_SPLIT1
3142 BFD_RELOC_860_SPLIT2
3146 BFD_RELOC_860_LOGOT0
3148 BFD_RELOC_860_SPGOT0
3150 BFD_RELOC_860_LOGOT1
3152 BFD_RELOC_860_SPGOT1
3154 BFD_RELOC_860_LOGOTOFF0
3156 BFD_RELOC_860_SPGOTOFF0
3158 BFD_RELOC_860_LOGOTOFF1
3160 BFD_RELOC_860_SPGOTOFF1
3162 BFD_RELOC_860_LOGOTOFF2
3164 BFD_RELOC_860_LOGOTOFF3
3168 BFD_RELOC_860_HIGHADJ
3172 BFD_RELOC_860_HAGOTOFF
3180 BFD_RELOC_860_HIGOTOFF
3182 Intel i860 Relocations.
3185 BFD_RELOC_OPENRISC_ABS_26
3187 BFD_RELOC_OPENRISC_REL_26
3189 OpenRISC Relocations.
3192 BFD_RELOC_H8_DIR16A8
3194 BFD_RELOC_H8_DIR16R8
3196 BFD_RELOC_H8_DIR24A8
3198 BFD_RELOC_H8_DIR24R8
3200 BFD_RELOC_H8_DIR32A16
3208 .typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
3213 bfd_reloc_type_lookup
3217 bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code);
3220 Return a pointer to a howto structure which, when
3221 invoked, will perform the relocation @var{code} on data from the
3227 bfd_reloc_type_lookup (abfd
, code
)
3229 bfd_reloc_code_real_type code
;
3231 return BFD_SEND (abfd
, reloc_type_lookup
, (abfd
, code
));
3234 static reloc_howto_type bfd_howto_32
=
3235 HOWTO (0, 00, 2, 32, false, 0, complain_overflow_bitfield
, 0, "VRT32", false, 0xffffffff, 0xffffffff, true);
3239 bfd_default_reloc_type_lookup
3242 reloc_howto_type *bfd_default_reloc_type_lookup
3243 (bfd *abfd, bfd_reloc_code_real_type code);
3246 Provides a default relocation lookup routine for any architecture.
3251 bfd_default_reloc_type_lookup (abfd
, code
)
3253 bfd_reloc_code_real_type code
;
3257 case BFD_RELOC_CTOR
:
3258 /* The type of reloc used in a ctor, which will be as wide as the
3259 address - so either a 64, 32, or 16 bitter. */
3260 switch (bfd_get_arch_info (abfd
)->bits_per_address
)
3265 return &bfd_howto_32
;
3274 return (reloc_howto_type
*) NULL
;
3279 bfd_get_reloc_code_name
3282 const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code);
3285 Provides a printable name for the supplied relocation code.
3286 Useful mainly for printing error messages.
3290 bfd_get_reloc_code_name (code
)
3291 bfd_reloc_code_real_type code
;
3293 if (code
> BFD_RELOC_UNUSED
)
3295 return bfd_reloc_code_real_names
[(int)code
];
3300 bfd_generic_relax_section
3303 boolean bfd_generic_relax_section
3306 struct bfd_link_info *,
3310 Provides default handling for relaxing for back ends which
3311 don't do relaxing -- i.e., does nothing.
3316 bfd_generic_relax_section (abfd
, section
, link_info
, again
)
3317 bfd
*abfd ATTRIBUTE_UNUSED
;
3318 asection
*section ATTRIBUTE_UNUSED
;
3319 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
3328 bfd_generic_gc_sections
3331 boolean bfd_generic_gc_sections
3332 (bfd *, struct bfd_link_info *);
3335 Provides default handling for relaxing for back ends which
3336 don't do section gc -- i.e., does nothing.
3341 bfd_generic_gc_sections (abfd
, link_info
)
3342 bfd
*abfd ATTRIBUTE_UNUSED
;
3343 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
3350 bfd_generic_merge_sections
3353 boolean bfd_generic_merge_sections
3354 (bfd *, struct bfd_link_info *);
3357 Provides default handling for SEC_MERGE section merging for back ends
3358 which don't have SEC_MERGE support -- i.e., does nothing.
3363 bfd_generic_merge_sections (abfd
, link_info
)
3364 bfd
*abfd ATTRIBUTE_UNUSED
;
3365 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
3372 bfd_generic_get_relocated_section_contents
3376 bfd_generic_get_relocated_section_contents (bfd *abfd,
3377 struct bfd_link_info *link_info,
3378 struct bfd_link_order *link_order,
3380 boolean relocateable,
3384 Provides default handling of relocation effort for back ends
3385 which can't be bothered to do it efficiently.
3390 bfd_generic_get_relocated_section_contents (abfd
, link_info
, link_order
, data
,
3391 relocateable
, symbols
)
3393 struct bfd_link_info
*link_info
;
3394 struct bfd_link_order
*link_order
;
3396 boolean relocateable
;
3399 /* Get enough memory to hold the stuff */
3400 bfd
*input_bfd
= link_order
->u
.indirect
.section
->owner
;
3401 asection
*input_section
= link_order
->u
.indirect
.section
;
3403 long reloc_size
= bfd_get_reloc_upper_bound (input_bfd
, input_section
);
3404 arelent
**reloc_vector
= NULL
;
3410 reloc_vector
= (arelent
**) bfd_malloc ((size_t) reloc_size
);
3411 if (reloc_vector
== NULL
&& reloc_size
!= 0)
3414 /* read in the section */
3415 if (!bfd_get_section_contents (input_bfd
,
3419 input_section
->_raw_size
))
3422 /* We're not relaxing the section, so just copy the size info */
3423 input_section
->_cooked_size
= input_section
->_raw_size
;
3424 input_section
->reloc_done
= true;
3426 reloc_count
= bfd_canonicalize_reloc (input_bfd
,
3430 if (reloc_count
< 0)
3433 if (reloc_count
> 0)
3436 for (parent
= reloc_vector
; *parent
!= (arelent
*) NULL
;
3439 char *error_message
= (char *) NULL
;
3440 bfd_reloc_status_type r
=
3441 bfd_perform_relocation (input_bfd
,
3445 relocateable
? abfd
: (bfd
*) NULL
,
3450 asection
*os
= input_section
->output_section
;
3452 /* A partial link, so keep the relocs */
3453 os
->orelocation
[os
->reloc_count
] = *parent
;
3457 if (r
!= bfd_reloc_ok
)
3461 case bfd_reloc_undefined
:
3462 if (!((*link_info
->callbacks
->undefined_symbol
)
3463 (link_info
, bfd_asymbol_name (*(*parent
)->sym_ptr_ptr
),
3464 input_bfd
, input_section
, (*parent
)->address
,
3468 case bfd_reloc_dangerous
:
3469 BFD_ASSERT (error_message
!= (char *) NULL
);
3470 if (!((*link_info
->callbacks
->reloc_dangerous
)
3471 (link_info
, error_message
, input_bfd
, input_section
,
3472 (*parent
)->address
)))
3475 case bfd_reloc_overflow
:
3476 if (!((*link_info
->callbacks
->reloc_overflow
)
3477 (link_info
, bfd_asymbol_name (*(*parent
)->sym_ptr_ptr
),
3478 (*parent
)->howto
->name
, (*parent
)->addend
,
3479 input_bfd
, input_section
, (*parent
)->address
)))
3482 case bfd_reloc_outofrange
:
3491 if (reloc_vector
!= NULL
)
3492 free (reloc_vector
);
3496 if (reloc_vector
!= NULL
)
3497 free (reloc_vector
);