1 /* BFD support for handling relocation entries.
2 Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
3 Written by Cygnus Support.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 BFD maintains relocations in much the same was as it maintains
26 symbols; they are left alone until required, then read in
27 en-mass and traslated into an internal form. There is a common
28 routine <<bfd_perform_relocation>> which acts upon the
29 canonical form to do the actual fixup.
31 Note that relocations are maintained on a per section basis,
32 whilst symbols are maintained on a per BFD basis.
34 All a back end has to do to fit the BFD interface is to create
35 as many <<struct reloc_cache_entry>> as there are relocations
36 in a particular section, and fill in the right bits:
51 typedef arelent, howto manager, Relocations, Relocations
56 This is the structure of a relocation entry:
60 .typedef enum bfd_reloc_status
62 . {* No errors detected *}
65 . {* The relocation was performed, but there was an overflow. *}
68 . {* The address to relocate was not within the section supplied. *}
69 . bfd_reloc_outofrange,
71 . {* Used by special functions *}
75 . bfd_reloc_notsupported,
77 . {* Unsupported relocation size requested. *}
80 . {* The symbol to relocate against was undefined. *}
81 . bfd_reloc_undefined,
83 . {* The relocation was performed, but may not be ok - presently
84 . generated only when linking i960 coff files with i960 b.out
88 . bfd_reloc_status_type;
91 .typedef struct reloc_cache_entry
93 . {* A pointer into the canonical table of pointers *}
94 . struct symbol_cache_entry **sym_ptr_ptr;
96 . {* offset in section *}
97 . bfd_size_type address;
99 . {* addend for relocation value *}
102 . {* Pointer to how to perform the required relocation *}
103 . CONST struct reloc_howto_struct *howto;
112 Here is a description of each of the fields within a relent:
116 The symbol table pointer points to a pointer to the symbol
117 associated with the relocation request. This would naturally
118 be the pointer into the table returned by the back end's
119 get_symtab action. @xref{Symbols}. The symbol is referenced
120 through a pointer to a pointer so that tools like the linker
121 can fix up all the symbols of the same name by modifying only
122 one pointer. The relocation routine looks in the symbol and
123 uses the base of the section the symbol is attached to and the
124 value of the symbol as the initial relocation offset. If the
125 symbol pointer is zero, then the section provided is looked up.
129 The address field gives the offset in bytes from the base of
130 the section data which owns the relocation record to the first
131 byte of relocatable information. The actual data relocated
132 will be relative to this point - for example, a relocation
133 type which modifies the bottom two bytes of a four byte word
134 would not touch the first byte pointed to in a big endian
139 The addend is a value provided by the back end to be added (!)
140 to the relocation offset. Its interpretation is dependent upon
141 the howto. For example, on the 68k the code:
147 | return foo[0x12345678];
150 Could be compiled into:
153 | moveb @@#12345678,d0
159 This could create a reloc pointing to foo, but leave the
160 offset in the data (something like)
163 |RELOCATION RECORDS FOR [.text]:
167 |00000000 4e56 fffc ; linkw fp,#-4
168 |00000004 1039 1234 5678 ; moveb @@#12345678,d0
169 |0000000a 49c0 ; extbl d0
170 |0000000c 4e5e ; unlk fp
174 Using coff and an 88k, some instructions don't have enough
175 space in them to represent the full address range, and
176 pointers have to be loaded in two parts. So you'd get something like:
179 | or.u r13,r0,hi16(_foo+0x12345678)
180 | ld.b r2,r13,lo16(_foo+0x12345678)
184 This should create two relocs, both pointing to _foo, and with
185 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
198 The relocation routine digs out the value from the data, adds
199 it to the addend to get the original offset and then adds the
200 value of _foo. Note that all 32 bits have to be kept around
201 somewhere, to cope with carry from bit 15 to bit 16.
203 One further example is the sparc and the a.out format. The
204 sparc has a similar problem to the 88k, in that some
205 instructions don't have room for an entire offset, but on the
206 sparc the parts are created odd sized lumps. The designers of
207 the a.out format chose not to use the data within the section
208 for storing part of the offset; all the offset is kept within
209 the reloc. Any thing in the data should be ignored.
212 | sethi %hi(_foo+0x12345678),%g2
213 | ldsb [%g2+%lo(_foo+0x12345678)],%i0
217 Both relocs contains a pointer to foo, and the offsets would
221 |RELOCATION RECORDS FOR [.text]:
223 |00000004 HI22 _foo+0x12345678
224 |00000008 LO10 _foo+0x12345678
226 |00000000 9de3bf90 ; save %sp,-112,%sp
227 |00000004 05000000 ; sethi %hi(_foo+0),%g2
228 |00000008 f048a000 ; ldsb [%g2+%lo(_foo+0)],%i0
229 |0000000c 81c7e008 ; ret
230 |00000010 81e80000 ; restore
235 The howto field can be imagined as a
236 relocation instruction. It is a pointer to a struct which
237 contains information on what to do with all the other
238 information in the reloc record and data section. A back end
239 would normally have a relocation instruction set and turn
240 relocations into pointers to the correct structure on input -
241 but it would be possible to create each howto field on demand.
247 <<enum complain_overflow>>
249 Indicates what sort of overflow checking should be done when
250 performing a relocation.
254 .enum complain_overflow
256 . {* Do not complain on overflow. *}
257 . complain_overflow_dont,
259 . {* Complain if the bitfield overflows, whether it is considered
260 . as signed or unsigned. *}
261 . complain_overflow_bitfield,
263 . {* Complain if the value overflows when considered as signed
265 . complain_overflow_signed,
267 . {* Complain if the value overflows when considered as an
268 . unsigned number. *}
269 . complain_overflow_unsigned
278 The <<reloc_howto_type>> is a structure which contains all the
279 information that BFD needs to know to tie up a back end's data.
282 .struct symbol_cache_entry; {* Forward declaration *}
284 .typedef CONST struct reloc_howto_struct
286 . {* The type field has mainly a documetary use - the back end can
287 . to what it wants with it, though the normally the back end's
288 . external idea of what a reloc number would be would be stored
289 . in this field. For example, the a PC relative word relocation
290 . in a coff environment would have the type 023 - because that's
291 . what the outside world calls a R_PCRWORD reloc. *}
294 . {* The value the final relocation is shifted right by. This drops
295 . unwanted data from the relocation. *}
296 . unsigned int rightshift;
298 . {* The size of the item to be relocated. This is *not* a
299 . power-of-two measure.
303 . 3 : nothing done (unless special_function is nonzero)
305 . -2 : two bytes, result should be subtracted from the
306 . data instead of added
307 . There is currently no trivial way to extract a "number of
308 . bytes" from a howto pointer. *}
311 . {* The number of bits in the item to be relocated. This is used
312 . when doing overflow checking. *}
313 . unsigned int bitsize;
315 . {* Notes that the relocation is relative to the location in the
316 . data section of the addend. The relocation function will
317 . subtract from the relocation value the address of the location
318 . being relocated. *}
319 . boolean pc_relative;
321 . {* The bit position of the reloc value in the destination.
322 . The relocated value is left shifted by this amount. *}
323 . unsigned int bitpos;
325 . {* What type of overflow error should be checked for when
327 . enum complain_overflow complain_on_overflow;
329 . {* If this field is non null, then the supplied function is
330 . called rather than the normal function. This allows really
331 . strange relocation methods to be accomodated (e.g., i960 callj
333 . bfd_reloc_status_type (*special_function)
334 . PARAMS ((bfd *abfd,
335 . arelent *reloc_entry,
336 . struct symbol_cache_entry *symbol,
338 . asection *input_section,
341 . {* The textual name of the relocation type. *}
344 . {* When performing a partial link, some formats must modify the
345 . relocations rather than the data - this flag signals this.*}
346 . boolean partial_inplace;
348 . {* The src_mask is used to select what parts of the read in data
349 . are to be used in the relocation sum. E.g., if this was an 8 bit
350 . bit of data which we read and relocated, this would be
351 . 0x000000ff. When we have relocs which have an addend, such as
352 . sun4 extended relocs, the value in the offset part of a
353 . relocating field is garbage so we never use it. In this case
354 . the mask would be 0x00000000. *}
357 . {* The dst_mask is what parts of the instruction are replaced
358 . into the instruction. In most cases src_mask == dst_mask,
359 . except in the above special case, where dst_mask would be
360 . 0x000000ff, and src_mask would be 0x00000000. *}
363 . {* When some formats create PC relative instructions, they leave
364 . the value of the pc of the place being relocated in the offset
365 . slot of the instruction, so that a PC relative relocation can
366 . be made just by adding in an ordinary offset (e.g., sun3 a.out).
367 . Some formats leave the displacement part of an instruction
368 . empty (e.g., m88k bcs), this flag signals the fact.*}
369 . boolean pcrel_offset;
380 The HOWTO define is horrible and will go away.
383 .#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
384 . {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
387 And will be replaced with the totally magic way. But for the
388 moment, we are compatible, so do it this way..
391 .#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN)
394 Helper routine to turn a symbol into a relocation value.
396 .#define HOWTO_PREPARE(relocation, symbol) \
398 . if (symbol != (asymbol *)NULL) { \
399 . if (bfd_is_com_section (symbol->section)) { \
403 . relocation = symbol->value; \
416 How relocs are tied together
418 .typedef unsigned char bfd_byte;
420 .typedef struct relent_chain {
422 . struct relent_chain *next;
431 bfd_perform_relocation
434 bfd_reloc_status_type
435 bfd_perform_relocation
437 arelent *reloc_entry,
439 asection *input_section,
443 If an output_bfd is supplied to this function the generated
444 image will be relocatable, the relocations are copied to the
445 output file after they have been changed to reflect the new
446 state of the world. There are two ways of reflecting the
447 results of partial linkage in an output file; by modifying the
448 output data in place, and by modifying the relocation record.
449 Some native formats (e.g., basic a.out and basic coff) have no
450 way of specifying an addend in the relocation type, so the
451 addend has to go in the output data. This is no big deal
452 since in these formats the output data slot will always be big
453 enough for the addend. Complex reloc types with addends were
454 invented to solve just this problem.
459 bfd_reloc_status_type
460 DEFUN(bfd_perform_relocation,(abfd,
466 arelent *reloc_entry AND
468 asection *input_section AND
472 bfd_reloc_status_type flag = bfd_reloc_ok;
473 bfd_size_type addr = reloc_entry->address ;
474 bfd_vma output_base = 0;
475 reloc_howto_type *howto = reloc_entry->howto;
476 asection *reloc_target_output_section ;
480 symbol = *( reloc_entry->sym_ptr_ptr);
481 if ((symbol->section == &bfd_abs_section)
482 && output_bfd != (bfd *)NULL)
484 reloc_entry->address += input_section->output_offset;
488 /* If we are not producing relocateable output, return an error if
489 the symbol is not defined. An undefined weak symbol is
490 considered to have a value of zero (SVR4 ABI, p. 4-27). */
491 if (symbol->section == &bfd_und_section
492 && (symbol->flags & BSF_WEAK) == 0
493 && output_bfd == (bfd *) NULL)
494 flag = bfd_reloc_undefined;
496 /* If there is a function supplied to handle this relocation type,
497 call it. It'll return `bfd_reloc_continue' if further processing
499 if (howto->special_function)
501 bfd_reloc_status_type cont;
502 cont = howto->special_function (abfd, reloc_entry, symbol, data,
503 input_section, output_bfd);
504 if (cont != bfd_reloc_continue)
508 /* Is the address of the relocation really within the section? */
509 if (reloc_entry->address > input_section->_cooked_size)
510 return bfd_reloc_outofrange;
512 /* Work out which section the relocation is targetted at and the
513 initial relocation command value. */
515 /* Get symbol value. (Common symbols are special.) */
516 if (bfd_is_com_section (symbol->section))
519 relocation = symbol->value;
522 reloc_target_output_section = symbol->section->output_section;
524 /* Convert input-section-relative symbol value to absolute. */
525 if (output_bfd && howto->partial_inplace==false)
528 output_base = reloc_target_output_section->vma;
530 relocation += output_base + symbol->section->output_offset;
532 /* Add in supplied addend. */
533 relocation += reloc_entry->addend;
535 if (howto->pc_relative == true)
537 /* Anything which started out as pc relative should end up that
540 There are two ways we can see a pcrel instruction. Sometimes
541 the pcrel displacement has been partially calculated, it
542 includes the distance from the start of the section to the
543 instruction in it (e.g., sun3), and sometimes the field is
544 totally blank - e.g., m88kbcs. */
547 input_section->output_section->vma + input_section->output_offset;
549 if (howto->pcrel_offset == true)
550 relocation -= reloc_entry->address;
553 if (output_bfd!= (bfd *)NULL)
555 if ( howto->partial_inplace == false)
557 /* This is a partial relocation, and we want to apply the relocation
558 to the reloc entry rather than the raw data. Modify the reloc
559 inplace to reflect what we now know. */
560 reloc_entry->addend = relocation;
561 reloc_entry->address += input_section->output_offset;
566 /* This is a partial relocation, but inplace, so modify the
569 If we've relocated with a symbol with a section, change
570 into a ref to the section belonging to the symbol. */
572 reloc_entry->address += input_section->output_offset;
575 if (abfd->xvec->flavour == bfd_target_coff_flavour)
577 relocation -= reloc_entry->addend;
578 reloc_entry->addend = 0;
582 reloc_entry->addend = relocation;
588 reloc_entry->addend = 0;
591 /* FIXME: This overflow checking is incomplete, because the value
592 might have overflowed before we get here. For a correct check we
593 need to compute the value in a size larger than bitsize, but we
594 can't reasonably do that for a reloc the same size as a host
596 FIXME: We should also do overflow checking on the result after
597 adding in the value contained in the object file. */
598 if (howto->complain_on_overflow != complain_overflow_dont)
602 /* Get the value that will be used for the relocation, but
603 starting at bit position zero. */
604 if (howto->rightshift > howto->bitpos)
605 check = relocation >> (howto->rightshift - howto->bitpos);
607 check = relocation << (howto->bitpos - howto->rightshift);
608 switch (howto->complain_on_overflow)
610 case complain_overflow_signed:
612 /* Assumes two's complement. */
613 bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
614 bfd_signed_vma reloc_signed_min = ~ reloc_signed_max;
616 /* The above right shift is incorrect for a signed value.
617 Fix it up by forcing on the upper bits. */
618 if (howto->rightshift > howto->bitpos
619 && (bfd_signed_vma) relocation < 0)
620 check |= ((bfd_vma) -1
622 >> (howto->rightshift - howto->bitpos)));
623 if ((bfd_signed_vma) check > reloc_signed_max
624 || (bfd_signed_vma) check < reloc_signed_min)
625 flag = bfd_reloc_overflow;
628 case complain_overflow_unsigned:
630 /* Assumes two's complement. This expression avoids
631 overflow if howto->bitsize is the number of bits in
633 bfd_vma reloc_unsigned_max =
634 (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
636 if ((bfd_vma) check > reloc_unsigned_max)
637 flag = bfd_reloc_overflow;
640 case complain_overflow_bitfield:
642 /* Assumes two's complement. This expression avoids
643 overflow if howto->bitsize is the number of bits in
645 bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
647 if (((bfd_vma) check &~ reloc_bits) != 0
648 && ((bfd_vma) check &~ reloc_bits) != (-1 &~ reloc_bits))
650 /* The above right shift is incorrect for a signed
651 value. See if turning on the upper bits fixes the
653 if (howto->rightshift > howto->bitpos
654 && (bfd_signed_vma) relocation < 0)
656 check |= ((bfd_vma) -1
658 >> (howto->rightshift - howto->bitpos)));
659 if (((bfd_vma) check &~ reloc_bits) != (-1 &~ reloc_bits))
660 flag = bfd_reloc_overflow;
663 flag = bfd_reloc_overflow;
673 Either we are relocating all the way, or we don't want to apply
674 the relocation to the reloc entry (probably because there isn't
675 any room in the output format to describe addends to relocs)
677 relocation >>= howto->rightshift;
679 /* Shift everything up to where it's going to be used */
681 relocation <<= howto->bitpos;
683 /* Wait for the day when all have the mask in them */
686 i instruction to be left alone
687 o offset within instruction
688 r relocation offset to apply
697 i i i i i o o o o o from bfd_get<size>
698 and S S S S S to get the size offset we want
699 + r r r r r r r r r r to get the final value to place
700 and D D D D D to chop to right size
701 -----------------------
704 ... i i i i i o o o o o from bfd_get<size>
705 and N N N N N get instruction
706 -----------------------
712 -----------------------
713 R R R R R R R R R R put into bfd_put<size>
717 x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
723 char x = bfd_get_8(abfd, (char *)data + addr);
725 bfd_put_8(abfd,x, (unsigned char *) data + addr);
732 short x = bfd_get_16(abfd, (bfd_byte *)data + addr);
734 bfd_put_16(abfd, x, (unsigned char *)data + addr);
740 long x = bfd_get_32 (abfd, (bfd_byte *) data + addr);
742 bfd_put_32 (abfd, x, (bfd_byte *)data + addr);
747 long x = bfd_get_32(abfd, (bfd_byte *) data + addr);
748 relocation = -relocation;
750 bfd_put_32(abfd,x, (bfd_byte *)data + addr);
762 bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data + addr);
764 bfd_put_64 (abfd, x, (bfd_byte *) data + addr);
771 return bfd_reloc_other;
782 howto manager, , typedef arelent, Relocations
787 When an application wants to create a relocation, but doesn't
788 know what the target machine might call it, it can find out by
789 using this bit of code.
798 The insides of a reloc code. The idea is that, eventually, there
799 will be one enumerator for every type of relocation we ever do.
800 Pass one of these values to <<bfd_reloc_type_lookup>>, and it'll
801 return a howto pointer.
803 This does mean that the application must determine the correct
804 enumerator value; you can't get a howto pointer from a random set
809 .typedef enum bfd_reloc_code_real
811 . {* Basic absolute relocations *}
817 . {* PC-relative relocations *}
818 . BFD_RELOC_64_PCREL,
819 . BFD_RELOC_32_PCREL,
820 . BFD_RELOC_24_PCREL, {* used by i960 *}
821 . BFD_RELOC_16_PCREL,
824 . {* Linkage-table relative *}
825 . BFD_RELOC_32_BASEREL,
826 . BFD_RELOC_16_BASEREL,
827 . BFD_RELOC_8_BASEREL,
829 . {* The type of reloc used to build a contructor table - at the moment
830 . probably a 32 bit wide abs address, but the cpu can choose. *}
833 . {* 8 bits wide, but used to form an address like 0xffnn *}
836 . {* 32-bit pc-relative, shifted right 2 bits (i.e., 30-bit
837 . word displacement, e.g. for SPARC) *}
838 . BFD_RELOC_32_PCREL_S2,
840 . {* High 22 bits of 32-bit value, placed into lower 22 bits of
841 . target word; simple reloc. *}
846 . {* Reloc types used for i960/b.out. *}
847 . BFD_RELOC_I960_CALLJ,
849 . {* now for the sparc/elf codes *}
850 . BFD_RELOC_NONE, {* actually used *}
851 . BFD_RELOC_SPARC_WDISP22,
854 . BFD_RELOC_SPARC_GOT10,
855 . BFD_RELOC_SPARC_GOT13,
856 . BFD_RELOC_SPARC_GOT22,
857 . BFD_RELOC_SPARC_PC10,
858 . BFD_RELOC_SPARC_PC22,
859 . BFD_RELOC_SPARC_WPLT30,
860 . BFD_RELOC_SPARC_COPY,
861 . BFD_RELOC_SPARC_GLOB_DAT,
862 . BFD_RELOC_SPARC_JMP_SLOT,
863 . BFD_RELOC_SPARC_RELATIVE,
864 . BFD_RELOC_SPARC_UA32,
866 . {* these are a.out specific? *}
867 . BFD_RELOC_SPARC_BASE13,
868 . BFD_RELOC_SPARC_BASE22,
870 . {* start-sanitize-v9 *}
871 . BFD_RELOC_SPARC_10,
872 . BFD_RELOC_SPARC_11,
873 .#define BFD_RELOC_SPARC_64 BFD_RELOC_64
874 . BFD_RELOC_SPARC_OLO10,
875 . BFD_RELOC_SPARC_HH22,
876 . BFD_RELOC_SPARC_HM10,
877 . BFD_RELOC_SPARC_LM22,
878 . BFD_RELOC_SPARC_PC_HH22,
879 . BFD_RELOC_SPARC_PC_HM10,
880 . BFD_RELOC_SPARC_PC_LM22,
881 . BFD_RELOC_SPARC_WDISP16,
882 . BFD_RELOC_SPARC_WDISP19,
883 . BFD_RELOC_SPARC_GLOB_JMP,
884 . BFD_RELOC_SPARC_LO7,
885 . {* end-sanitize-v9 *}
887 . {* Bits 27..2 of the relocation address shifted right 2 bits;
888 . simple reloc otherwise. *}
889 . BFD_RELOC_MIPS_JMP,
891 . {* signed 16-bit pc-relative, shifted right 2 bits (e.g. for MIPS) *}
892 . BFD_RELOC_16_PCREL_S2,
894 . {* High 16 bits of 32-bit value; simple reloc. *}
896 . {* High 16 bits of 32-bit value but the low 16 bits will be sign
897 . extended and added to form the final result. If the low 16
898 . bits form a negative number, we need to add one to the high value
899 . to compensate for the borrow when the low bits are added. *}
904 . {* 16 bit relocation relative to the global pointer. *}
905 . BFD_RELOC_MIPS_GPREL,
907 . {* These are, so far, specific to HPPA processors. I'm not sure that some
908 . don't duplicate other reloc types, such as BFD_RELOC_32 and _32_PCREL.
909 . Also, many more were in the list I got that don't fit in well in the
910 . model BFD uses, so I've omitted them for now. If we do make this reloc
911 . type get used for code that really does implement the funky reloc types,
912 . they'll have to be added to this list. *}
918 . BFD_RELOC_HPPA_L21,
919 . BFD_RELOC_HPPA_R11,
920 . BFD_RELOC_HPPA_R14,
921 . BFD_RELOC_HPPA_R17,
922 . BFD_RELOC_HPPA_LS21,
923 . BFD_RELOC_HPPA_RS11,
924 . BFD_RELOC_HPPA_RS14,
925 . BFD_RELOC_HPPA_RS17,
926 . BFD_RELOC_HPPA_LD21,
927 . BFD_RELOC_HPPA_RD11,
928 . BFD_RELOC_HPPA_RD14,
929 . BFD_RELOC_HPPA_RD17,
930 . BFD_RELOC_HPPA_LR21,
931 . BFD_RELOC_HPPA_RR14,
932 . BFD_RELOC_HPPA_RR17,
934 . BFD_RELOC_HPPA_GOTOFF_11,
935 . BFD_RELOC_HPPA_GOTOFF_14,
936 . BFD_RELOC_HPPA_GOTOFF_L21,
937 . BFD_RELOC_HPPA_GOTOFF_R11,
938 . BFD_RELOC_HPPA_GOTOFF_R14,
939 . BFD_RELOC_HPPA_GOTOFF_LS21,
940 . BFD_RELOC_HPPA_GOTOFF_RS11,
941 . BFD_RELOC_HPPA_GOTOFF_RS14,
942 . BFD_RELOC_HPPA_GOTOFF_LD21,
943 . BFD_RELOC_HPPA_GOTOFF_RD11,
944 . BFD_RELOC_HPPA_GOTOFF_RD14,
945 . BFD_RELOC_HPPA_GOTOFF_LR21,
946 . BFD_RELOC_HPPA_GOTOFF_RR14,
948 . BFD_RELOC_HPPA_DLT_32,
949 . BFD_RELOC_HPPA_DLT_11,
950 . BFD_RELOC_HPPA_DLT_14,
951 . BFD_RELOC_HPPA_DLT_L21,
952 . BFD_RELOC_HPPA_DLT_R11,
953 . BFD_RELOC_HPPA_DLT_R14,
955 . BFD_RELOC_HPPA_ABS_CALL_11,
956 . BFD_RELOC_HPPA_ABS_CALL_14,
957 . BFD_RELOC_HPPA_ABS_CALL_17,
958 . BFD_RELOC_HPPA_ABS_CALL_L21,
959 . BFD_RELOC_HPPA_ABS_CALL_R11,
960 . BFD_RELOC_HPPA_ABS_CALL_R14,
961 . BFD_RELOC_HPPA_ABS_CALL_R17,
962 . BFD_RELOC_HPPA_ABS_CALL_LS21,
963 . BFD_RELOC_HPPA_ABS_CALL_RS11,
964 . BFD_RELOC_HPPA_ABS_CALL_RS14,
965 . BFD_RELOC_HPPA_ABS_CALL_RS17,
966 . BFD_RELOC_HPPA_ABS_CALL_LD21,
967 . BFD_RELOC_HPPA_ABS_CALL_RD11,
968 . BFD_RELOC_HPPA_ABS_CALL_RD14,
969 . BFD_RELOC_HPPA_ABS_CALL_RD17,
970 . BFD_RELOC_HPPA_ABS_CALL_LR21,
971 . BFD_RELOC_HPPA_ABS_CALL_RR14,
972 . BFD_RELOC_HPPA_ABS_CALL_RR17,
974 . BFD_RELOC_HPPA_PCREL_CALL_11,
975 . BFD_RELOC_HPPA_PCREL_CALL_12,
976 . BFD_RELOC_HPPA_PCREL_CALL_14,
977 . BFD_RELOC_HPPA_PCREL_CALL_17,
978 . BFD_RELOC_HPPA_PCREL_CALL_L21,
979 . BFD_RELOC_HPPA_PCREL_CALL_R11,
980 . BFD_RELOC_HPPA_PCREL_CALL_R14,
981 . BFD_RELOC_HPPA_PCREL_CALL_R17,
982 . BFD_RELOC_HPPA_PCREL_CALL_LS21,
983 . BFD_RELOC_HPPA_PCREL_CALL_RS11,
984 . BFD_RELOC_HPPA_PCREL_CALL_RS14,
985 . BFD_RELOC_HPPA_PCREL_CALL_RS17,
986 . BFD_RELOC_HPPA_PCREL_CALL_LD21,
987 . BFD_RELOC_HPPA_PCREL_CALL_RD11,
988 . BFD_RELOC_HPPA_PCREL_CALL_RD14,
989 . BFD_RELOC_HPPA_PCREL_CALL_RD17,
990 . BFD_RELOC_HPPA_PCREL_CALL_LR21,
991 . BFD_RELOC_HPPA_PCREL_CALL_RR14,
992 . BFD_RELOC_HPPA_PCREL_CALL_RR17,
994 . BFD_RELOC_HPPA_PLABEL_32,
995 . BFD_RELOC_HPPA_PLABEL_11,
996 . BFD_RELOC_HPPA_PLABEL_14,
997 . BFD_RELOC_HPPA_PLABEL_L21,
998 . BFD_RELOC_HPPA_PLABEL_R11,
999 . BFD_RELOC_HPPA_PLABEL_R14,
1001 . BFD_RELOC_HPPA_UNWIND_ENTRY,
1002 . BFD_RELOC_HPPA_UNWIND_ENTRIES,
1004 . {* i386/elf relocations *}
1005 . BFD_RELOC_386_GOT32,
1006 . BFD_RELOC_386_PLT32,
1007 . BFD_RELOC_386_COPY,
1008 . BFD_RELOC_386_GLOB_DAT,
1009 . BFD_RELOC_386_JUMP_SLOT,
1010 . BFD_RELOC_386_RELATIVE,
1011 . BFD_RELOC_386_GOTOFF,
1012 . BFD_RELOC_386_GOTPC,
1014 . {* this must be the highest numeric value *}
1016 . } bfd_reloc_code_real_type;
1022 bfd_reloc_type_lookup
1025 CONST struct reloc_howto_struct *
1026 bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code);
1029 This routine returns a pointer to a howto struct which when
1030 invoked, will perform the supplied relocation on data from the
1036 CONST struct reloc_howto_struct *
1037 DEFUN(bfd_reloc_type_lookup,(abfd, code),
1039 bfd_reloc_code_real_type code)
1041 return BFD_SEND (abfd, reloc_type_lookup, (abfd, code));
1044 static reloc_howto_type bfd_howto_32 =
1045 HOWTO(0, 00,2,32,false,0,complain_overflow_bitfield,0,"VRT32", false,0xffffffff,0xffffffff,true);
1050 bfd_default_reloc_type_lookup
1053 CONST struct reloc_howto_struct *bfd_default_reloc_type_lookup
1055 bfd_reloc_code_real_type code);
1058 Provides a default relocation lookup routine for any architecture.
1063 CONST struct reloc_howto_struct *
1064 DEFUN(bfd_default_reloc_type_lookup, (abfd, code),
1066 bfd_reloc_code_real_type code)
1070 case BFD_RELOC_CTOR:
1071 /* The type of reloc used in a ctor, which will be as wide as the
1072 address - so either a 64, 32, or 16 bitter. */
1073 switch (bfd_get_arch_info (abfd)->bits_per_address) {
1077 return &bfd_howto_32;
1086 return (CONST struct reloc_howto_struct *)NULL;
1092 bfd_generic_relax_section
1095 boolean bfd_generic_relax_section
1101 Provides default handling for relaxing for back ends which
1102 don't do relaxing -- i.e., does nothing.
1106 DEFUN(bfd_generic_relax_section,(abfd, section, symbols),
1108 asection *section AND
1119 bfd_generic_get_relocated_section_contents
1123 bfd_generic_get_relocated_section_contents (bfd *abfd,
1124 struct bfd_seclet *seclet,
1126 boolean relocateable);
1129 Provides default handling of relocation effort for back ends
1130 which can't be bothered to do it efficiently.
1135 DEFUN(bfd_generic_get_relocated_section_contents,(abfd,
1140 struct bfd_seclet *seclet AND
1142 boolean relocateable)
1144 extern bfd_error_vector_type bfd_error_vector;
1146 /* Get enough memory to hold the stuff */
1147 bfd *input_bfd = seclet->u.indirect.section->owner;
1148 asection *input_section = seclet->u.indirect.section;
1152 size_t reloc_size = bfd_get_reloc_upper_bound(input_bfd, input_section);
1153 arelent **reloc_vector = (arelent **) alloca(reloc_size);
1155 /* read in the section */
1156 bfd_get_section_contents(input_bfd,
1160 input_section->_raw_size);
1162 /* We're not relaxing the section, so just copy the size info */
1163 input_section->_cooked_size = input_section->_raw_size;
1164 input_section->reloc_done = true;
1167 if (bfd_canonicalize_reloc(input_bfd,
1170 seclet->u.indirect.symbols) )
1173 for (parent = reloc_vector; * parent != (arelent *)NULL;
1176 bfd_reloc_status_type r=
1177 bfd_perform_relocation(input_bfd,
1181 relocateable ? abfd : (bfd *) NULL);
1185 asection *os = input_section->output_section;
1187 /* A partial link, so keep the relocs */
1188 os->orelocation[os->reloc_count] = *parent;
1192 if (r != bfd_reloc_ok)
1196 case bfd_reloc_undefined:
1197 bfd_error_vector.undefined_symbol(*parent, seclet);
1199 case bfd_reloc_dangerous:
1200 bfd_error_vector.reloc_dangerous(*parent, seclet);
1202 case bfd_reloc_outofrange:
1203 case bfd_reloc_overflow:
1204 bfd_error_vector.reloc_value_truncated(*parent, seclet);