Second part of ms1 to mt renaming.
[external/binutils.git] / bfd / reloc.c
1 /* BFD support for handling relocation entries.
2    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3    2000, 2001, 2002, 2003, 2004, 2005
4    Free Software Foundation, Inc.
5    Written by Cygnus Support.
6
7    This file is part of BFD, the Binary File Descriptor library.
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
22
23 /*
24 SECTION
25         Relocations
26
27         BFD maintains relocations in much the same way it maintains
28         symbols: they are left alone until required, then read in
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.
32
33         Relocations are maintained on a per section basis,
34         while symbols are maintained on a per BFD basis.
35
36         All that a back end has to do to fit the BFD interface is to create
37         a <<struct reloc_cache_entry>> for each relocation
38         in a particular section, and fill in the right bits of the structures.
39
40 @menu
41 @* typedef arelent::
42 @* howto manager::
43 @end menu
44
45 */
46
47 /* DO compile in the reloc_code name table from libbfd.h.  */
48 #define _BFD_MAKE_TABLE_bfd_reloc_code_real
49
50 #include "bfd.h"
51 #include "sysdep.h"
52 #include "bfdlink.h"
53 #include "libbfd.h"
54 /*
55 DOCDD
56 INODE
57         typedef arelent, howto manager, Relocations, Relocations
58
59 SUBSECTION
60         typedef arelent
61
62         This is the structure of a relocation entry:
63
64 CODE_FRAGMENT
65 .
66 .typedef enum bfd_reloc_status
67 .{
68 .  {* No errors detected.  *}
69 .  bfd_reloc_ok,
70 .
71 .  {* The relocation was performed, but there was an overflow.  *}
72 .  bfd_reloc_overflow,
73 .
74 .  {* The address to relocate was not within the section supplied.  *}
75 .  bfd_reloc_outofrange,
76 .
77 .  {* Used by special functions.  *}
78 .  bfd_reloc_continue,
79 .
80 .  {* Unsupported relocation size requested.  *}
81 .  bfd_reloc_notsupported,
82 .
83 .  {* Unused.  *}
84 .  bfd_reloc_other,
85 .
86 .  {* The symbol to relocate against was undefined.  *}
87 .  bfd_reloc_undefined,
88 .
89 .  {* The relocation was performed, but may not be ok - presently
90 .     generated only when linking i960 coff files with i960 b.out
91 .     symbols.  If this type is returned, the error_message argument
92 .     to bfd_perform_relocation will be set.  *}
93 .  bfd_reloc_dangerous
94 . }
95 . bfd_reloc_status_type;
96 .
97 .
98 .typedef struct reloc_cache_entry
99 .{
100 .  {* A pointer into the canonical table of pointers.  *}
101 .  struct bfd_symbol **sym_ptr_ptr;
102 .
103 .  {* offset in section.  *}
104 .  bfd_size_type address;
105 .
106 .  {* addend for relocation value.  *}
107 .  bfd_vma addend;
108 .
109 .  {* Pointer to how to perform the required relocation.  *}
110 .  reloc_howto_type *howto;
111 .
112 .}
113 .arelent;
114 .
115 */
116
117 /*
118 DESCRIPTION
119
120         Here is a description of each of the fields within an <<arelent>>:
121
122         o <<sym_ptr_ptr>>
123
124         The symbol table pointer points to a pointer to the symbol
125         associated with the relocation request.  It is the pointer
126         into the table returned by the back end's
127         <<canonicalize_symtab>> action. @xref{Symbols}. The symbol is
128         referenced through a pointer to a pointer so that tools like
129         the linker can fix up all the symbols of the same name by
130         modifying only one pointer. The relocation routine looks in
131         the symbol and uses the base of the section the symbol is
132         attached to and the value of the symbol as the initial
133         relocation offset. If the symbol pointer is zero, then the
134         section provided is looked up.
135
136         o <<address>>
137
138         The <<address>> field gives the offset in bytes from the base of
139         the section data which owns the relocation record to the first
140         byte of relocatable information. The actual data relocated
141         will be relative to this point; for example, a relocation
142         type which modifies the bottom two bytes of a four byte word
143         would not touch the first byte pointed to in a big endian
144         world.
145
146         o <<addend>>
147
148         The <<addend>> is a value provided by the back end to be added (!)
149         to the relocation offset. Its interpretation is dependent upon
150         the howto. For example, on the 68k the code:
151
152 |        char foo[];
153 |        main()
154 |                {
155 |                return foo[0x12345678];
156 |                }
157
158         Could be compiled into:
159
160 |        linkw fp,#-4
161 |        moveb @@#12345678,d0
162 |        extbl d0
163 |        unlk fp
164 |        rts
165
166         This could create a reloc pointing to <<foo>>, but leave the
167         offset in the data, something like:
168
169 |RELOCATION RECORDS FOR [.text]:
170 |offset   type      value
171 |00000006 32        _foo
172 |
173 |00000000 4e56 fffc          ; linkw fp,#-4
174 |00000004 1039 1234 5678     ; moveb @@#12345678,d0
175 |0000000a 49c0               ; extbl d0
176 |0000000c 4e5e               ; unlk fp
177 |0000000e 4e75               ; rts
178
179         Using coff and an 88k, some instructions don't have enough
180         space in them to represent the full address range, and
181         pointers have to be loaded in two parts. So you'd get something like:
182
183 |        or.u     r13,r0,hi16(_foo+0x12345678)
184 |        ld.b     r2,r13,lo16(_foo+0x12345678)
185 |        jmp      r1
186
187         This should create two relocs, both pointing to <<_foo>>, and with
188         0x12340000 in their addend field. The data would consist of:
189
190 |RELOCATION RECORDS FOR [.text]:
191 |offset   type      value
192 |00000002 HVRT16    _foo+0x12340000
193 |00000006 LVRT16    _foo+0x12340000
194 |
195 |00000000 5da05678           ; or.u r13,r0,0x5678
196 |00000004 1c4d5678           ; ld.b r2,r13,0x5678
197 |00000008 f400c001           ; jmp r1
198
199         The relocation routine digs out the value from the data, adds
200         it to the addend to get the original offset, and then adds the
201         value of <<_foo>>. Note that all 32 bits have to be kept around
202         somewhere, to cope with carry from bit 15 to bit 16.
203
204         One further example is the sparc and the a.out format. The
205         sparc has a similar problem to the 88k, in that some
206         instructions don't have room for an entire offset, but on the
207         sparc the parts are created in odd sized lumps. The designers of
208         the a.out format chose to not use the data within the section
209         for storing part of the offset; all the offset is kept within
210         the reloc. Anything in the data should be ignored.
211
212 |        save %sp,-112,%sp
213 |        sethi %hi(_foo+0x12345678),%g2
214 |        ldsb [%g2+%lo(_foo+0x12345678)],%i0
215 |        ret
216 |        restore
217
218         Both relocs contain a pointer to <<foo>>, and the offsets
219         contain junk.
220
221 |RELOCATION RECORDS FOR [.text]:
222 |offset   type      value
223 |00000004 HI22      _foo+0x12345678
224 |00000008 LO10      _foo+0x12345678
225 |
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
231
232         o <<howto>>
233
234         The <<howto>> field can be imagined as a
235         relocation instruction. It is a pointer to a structure which
236         contains information on what to do with all of the other
237         information in the reloc record and data section. A back end
238         would normally have a relocation instruction set and turn
239         relocations into pointers to the correct structure on input -
240         but it would be possible to create each howto field on demand.
241
242 */
243
244 /*
245 SUBSUBSECTION
246         <<enum complain_overflow>>
247
248         Indicates what sort of overflow checking should be done when
249         performing a relocation.
250
251 CODE_FRAGMENT
252 .
253 .enum complain_overflow
254 .{
255 .  {* Do not complain on overflow.  *}
256 .  complain_overflow_dont,
257 .
258 .  {* Complain if the value overflows when considered as a signed
259 .     number one bit larger than the field.  ie. A bitfield of N bits
260 .     is allowed to represent -2**n to 2**n-1.  *}
261 .  complain_overflow_bitfield,
262 .
263 .  {* Complain if the value overflows when considered as a signed
264 .     number.  *}
265 .  complain_overflow_signed,
266 .
267 .  {* Complain if the value overflows when considered as an
268 .     unsigned number.  *}
269 .  complain_overflow_unsigned
270 .};
271
272 */
273
274 /*
275 SUBSUBSECTION
276         <<reloc_howto_type>>
277
278         The <<reloc_howto_type>> is a structure which contains all the
279         information that libbfd needs to know to tie up a back end's data.
280
281 CODE_FRAGMENT
282 .struct bfd_symbol;             {* Forward declaration.  *}
283 .
284 .struct reloc_howto_struct
285 .{
286 .  {*  The type field has mainly a documentary use - the back end can
287 .      do what it wants with it, though normally the back end's
288 .      external idea of what a reloc number is stored
289 .      in this field.  For example, a PC relative word relocation
290 .      in a coff environment has the type 023 - because that's
291 .      what the outside world calls a R_PCRWORD reloc.  *}
292 .  unsigned int type;
293 .
294 .  {*  The value the final relocation is shifted right by.  This drops
295 .      unwanted data from the relocation.  *}
296 .  unsigned int rightshift;
297 .
298 .  {*  The size of the item to be relocated.  This is *not* a
299 .      power-of-two measure.  To get the number of bytes operated
300 .      on by a type of relocation, use bfd_get_reloc_size.  *}
301 .  int size;
302 .
303 .  {*  The number of bits in the item to be relocated.  This is used
304 .      when doing overflow checking.  *}
305 .  unsigned int bitsize;
306 .
307 .  {*  Notes that the relocation is relative to the location in the
308 .      data section of the addend.  The relocation function will
309 .      subtract from the relocation value the address of the location
310 .      being relocated.  *}
311 .  bfd_boolean pc_relative;
312 .
313 .  {*  The bit position of the reloc value in the destination.
314 .      The relocated value is left shifted by this amount.  *}
315 .  unsigned int bitpos;
316 .
317 .  {* What type of overflow error should be checked for when
318 .     relocating.  *}
319 .  enum complain_overflow complain_on_overflow;
320 .
321 .  {* If this field is non null, then the supplied function is
322 .     called rather than the normal function.  This allows really
323 .     strange relocation methods to be accommodated (e.g., i960 callj
324 .     instructions).  *}
325 .  bfd_reloc_status_type (*special_function)
326 .    (bfd *, arelent *, struct bfd_symbol *, void *, asection *,
327 .     bfd *, char **);
328 .
329 .  {* The textual name of the relocation type.  *}
330 .  char *name;
331 .
332 .  {* Some formats record a relocation addend in the section contents
333 .     rather than with the relocation.  For ELF formats this is the
334 .     distinction between USE_REL and USE_RELA (though the code checks
335 .     for USE_REL == 1/0).  The value of this field is TRUE if the
336 .     addend is recorded with the section contents; when performing a
337 .     partial link (ld -r) the section contents (the data) will be
338 .     modified.  The value of this field is FALSE if addends are
339 .     recorded with the relocation (in arelent.addend); when performing
340 .     a partial link the relocation will be modified.
341 .     All relocations for all ELF USE_RELA targets should set this field
342 .     to FALSE (values of TRUE should be looked on with suspicion).
343 .     However, the converse is not true: not all relocations of all ELF
344 .     USE_REL targets set this field to TRUE.  Why this is so is peculiar
345 .     to each particular target.  For relocs that aren't used in partial
346 .     links (e.g. GOT stuff) it doesn't matter what this is set to.  *}
347 .  bfd_boolean partial_inplace;
348 .
349 .  {* src_mask selects the part of the instruction (or data) to be used
350 .     in the relocation sum.  If the target relocations don't have an
351 .     addend in the reloc, eg. ELF USE_REL, src_mask will normally equal
352 .     dst_mask to extract the addend from the section contents.  If
353 .     relocations do have an addend in the reloc, eg. ELF USE_RELA, this
354 .     field should be zero.  Non-zero values for ELF USE_RELA targets are
355 .     bogus as in those cases the value in the dst_mask part of the
356 .     section contents should be treated as garbage.  *}
357 .  bfd_vma src_mask;
358 .
359 .  {* dst_mask selects which parts of the instruction (or data) are
360 .     replaced with a relocated value.  *}
361 .  bfd_vma dst_mask;
362 .
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 .  bfd_boolean pcrel_offset;
370 .};
371 .
372 */
373
374 /*
375 FUNCTION
376         The HOWTO Macro
377
378 DESCRIPTION
379         The HOWTO define is horrible and will go away.
380
381 .#define HOWTO(C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
382 .  { (unsigned) C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC }
383
384 DESCRIPTION
385         And will be replaced with the totally magic way. But for the
386         moment, we are compatible, so do it this way.
387
388 .#define NEWHOWTO(FUNCTION, NAME, SIZE, REL, IN) \
389 .  HOWTO (0, 0, SIZE, 0, REL, 0, complain_overflow_dont, FUNCTION, \
390 .         NAME, FALSE, 0, 0, IN)
391 .
392
393 DESCRIPTION
394         This is used to fill in an empty howto entry in an array.
395
396 .#define EMPTY_HOWTO(C) \
397 .  HOWTO ((C), 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL, \
398 .         NULL, FALSE, 0, 0, FALSE)
399 .
400
401 DESCRIPTION
402         Helper routine to turn a symbol into a relocation value.
403
404 .#define HOWTO_PREPARE(relocation, symbol)               \
405 .  {                                                     \
406 .    if (symbol != NULL)                                 \
407 .      {                                                 \
408 .        if (bfd_is_com_section (symbol->section))       \
409 .          {                                             \
410 .            relocation = 0;                             \
411 .          }                                             \
412 .        else                                            \
413 .          {                                             \
414 .            relocation = symbol->value;                 \
415 .          }                                             \
416 .      }                                                 \
417 .  }
418 .
419 */
420
421 /*
422 FUNCTION
423         bfd_get_reloc_size
424
425 SYNOPSIS
426         unsigned int bfd_get_reloc_size (reloc_howto_type *);
427
428 DESCRIPTION
429         For a reloc_howto_type that operates on a fixed number of bytes,
430         this returns the number of bytes operated on.
431  */
432
433 unsigned int
434 bfd_get_reloc_size (reloc_howto_type *howto)
435 {
436   switch (howto->size)
437     {
438     case 0: return 1;
439     case 1: return 2;
440     case 2: return 4;
441     case 3: return 0;
442     case 4: return 8;
443     case 8: return 16;
444     case -2: return 4;
445     default: abort ();
446     }
447 }
448
449 /*
450 TYPEDEF
451         arelent_chain
452
453 DESCRIPTION
454
455         How relocs are tied together in an <<asection>>:
456
457 .typedef struct relent_chain
458 .{
459 .  arelent relent;
460 .  struct relent_chain *next;
461 .}
462 .arelent_chain;
463 .
464 */
465
466 /* N_ONES produces N one bits, without overflowing machine arithmetic.  */
467 #define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1)
468
469 /*
470 FUNCTION
471         bfd_check_overflow
472
473 SYNOPSIS
474         bfd_reloc_status_type bfd_check_overflow
475           (enum complain_overflow how,
476            unsigned int bitsize,
477            unsigned int rightshift,
478            unsigned int addrsize,
479            bfd_vma relocation);
480
481 DESCRIPTION
482         Perform overflow checking on @var{relocation} which has
483         @var{bitsize} significant bits and will be shifted right by
484         @var{rightshift} bits, on a machine with addresses containing
485         @var{addrsize} significant bits.  The result is either of
486         @code{bfd_reloc_ok} or @code{bfd_reloc_overflow}.
487
488 */
489
490 bfd_reloc_status_type
491 bfd_check_overflow (enum complain_overflow how,
492                     unsigned int bitsize,
493                     unsigned int rightshift,
494                     unsigned int addrsize,
495                     bfd_vma relocation)
496 {
497   bfd_vma fieldmask, addrmask, signmask, ss, a;
498   bfd_reloc_status_type flag = bfd_reloc_ok;
499
500   /* Note: BITSIZE should always be <= ADDRSIZE, but in case it's not,
501      we'll be permissive: extra bits in the field mask will
502      automatically extend the address mask for purposes of the
503      overflow check.  */
504   fieldmask = N_ONES (bitsize);
505   signmask = ~fieldmask;
506   addrmask = N_ONES (addrsize) | fieldmask;
507   a = (relocation & addrmask) >> rightshift;;
508
509   switch (how)
510     {
511     case complain_overflow_dont:
512       break;
513
514     case complain_overflow_signed:
515       /* If any sign bits are set, all sign bits must be set.  That
516          is, A must be a valid negative address after shifting.  */
517       signmask = ~ (fieldmask >> 1);
518       /* Fall thru */
519
520     case complain_overflow_bitfield:
521       /* Bitfields are sometimes signed, sometimes unsigned.  We
522          explicitly allow an address wrap too, which means a bitfield
523          of n bits is allowed to store -2**n to 2**n-1.  Thus overflow
524          if the value has some, but not all, bits set outside the
525          field.  */
526       ss = a & signmask;
527       if (ss != 0 && ss != ((addrmask >> rightshift) & signmask))
528         flag = bfd_reloc_overflow;
529       break;
530
531     case complain_overflow_unsigned:
532       /* We have an overflow if the address does not fit in the field.  */
533       if ((a & signmask) != 0)
534         flag = bfd_reloc_overflow;
535       break;
536
537     default:
538       abort ();
539     }
540
541   return flag;
542 }
543
544 /*
545 FUNCTION
546         bfd_perform_relocation
547
548 SYNOPSIS
549         bfd_reloc_status_type bfd_perform_relocation
550           (bfd *abfd,
551            arelent *reloc_entry,
552            void *data,
553            asection *input_section,
554            bfd *output_bfd,
555            char **error_message);
556
557 DESCRIPTION
558         If @var{output_bfd} is supplied to this function, the
559         generated image will be relocatable; the relocations are
560         copied to the output file after they have been changed to
561         reflect the new state of the world. There are two ways of
562         reflecting the results of partial linkage in an output file:
563         by modifying the output data in place, and by modifying the
564         relocation record.  Some native formats (e.g., basic a.out and
565         basic coff) have no way of specifying an addend in the
566         relocation type, so the addend has to go in the output data.
567         This is no big deal since in these formats the output data
568         slot will always be big enough for the addend. Complex reloc
569         types with addends were invented to solve just this problem.
570         The @var{error_message} argument is set to an error message if
571         this return @code{bfd_reloc_dangerous}.
572
573 */
574
575 bfd_reloc_status_type
576 bfd_perform_relocation (bfd *abfd,
577                         arelent *reloc_entry,
578                         void *data,
579                         asection *input_section,
580                         bfd *output_bfd,
581                         char **error_message)
582 {
583   bfd_vma relocation;
584   bfd_reloc_status_type flag = bfd_reloc_ok;
585   bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd);
586   bfd_vma output_base = 0;
587   reloc_howto_type *howto = reloc_entry->howto;
588   asection *reloc_target_output_section;
589   asymbol *symbol;
590
591   symbol = *(reloc_entry->sym_ptr_ptr);
592   if (bfd_is_abs_section (symbol->section)
593       && output_bfd != NULL)
594     {
595       reloc_entry->address += input_section->output_offset;
596       return bfd_reloc_ok;
597     }
598
599   /* If we are not producing relocatable output, return an error if
600      the symbol is not defined.  An undefined weak symbol is
601      considered to have a value of zero (SVR4 ABI, p. 4-27).  */
602   if (bfd_is_und_section (symbol->section)
603       && (symbol->flags & BSF_WEAK) == 0
604       && output_bfd == NULL)
605     flag = bfd_reloc_undefined;
606
607   /* If there is a function supplied to handle this relocation type,
608      call it.  It'll return `bfd_reloc_continue' if further processing
609      can be done.  */
610   if (howto->special_function)
611     {
612       bfd_reloc_status_type cont;
613       cont = howto->special_function (abfd, reloc_entry, symbol, data,
614                                       input_section, output_bfd,
615                                       error_message);
616       if (cont != bfd_reloc_continue)
617         return cont;
618     }
619
620   /* Is the address of the relocation really within the section?  */
621   if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
622     return bfd_reloc_outofrange;
623
624   /* Work out which section the relocation is targeted at and the
625      initial relocation command value.  */
626
627   /* Get symbol value.  (Common symbols are special.)  */
628   if (bfd_is_com_section (symbol->section))
629     relocation = 0;
630   else
631     relocation = symbol->value;
632
633   reloc_target_output_section = symbol->section->output_section;
634
635   /* Convert input-section-relative symbol value to absolute.  */
636   if ((output_bfd && ! howto->partial_inplace)
637       || reloc_target_output_section == NULL)
638     output_base = 0;
639   else
640     output_base = reloc_target_output_section->vma;
641
642   relocation += output_base + symbol->section->output_offset;
643
644   /* Add in supplied addend.  */
645   relocation += reloc_entry->addend;
646
647   /* Here the variable relocation holds the final address of the
648      symbol we are relocating against, plus any addend.  */
649
650   if (howto->pc_relative)
651     {
652       /* This is a PC relative relocation.  We want to set RELOCATION
653          to the distance between the address of the symbol and the
654          location.  RELOCATION is already the address of the symbol.
655
656          We start by subtracting the address of the section containing
657          the location.
658
659          If pcrel_offset is set, we must further subtract the position
660          of the location within the section.  Some targets arrange for
661          the addend to be the negative of the position of the location
662          within the section; for example, i386-aout does this.  For
663          i386-aout, pcrel_offset is FALSE.  Some other targets do not
664          include the position of the location; for example, m88kbcs,
665          or ELF.  For those targets, pcrel_offset is TRUE.
666
667          If we are producing relocatable output, then we must ensure
668          that this reloc will be correctly computed when the final
669          relocation is done.  If pcrel_offset is FALSE we want to wind
670          up with the negative of the location within the section,
671          which means we must adjust the existing addend by the change
672          in the location within the section.  If pcrel_offset is TRUE
673          we do not want to adjust the existing addend at all.
674
675          FIXME: This seems logical to me, but for the case of
676          producing relocatable output it is not what the code
677          actually does.  I don't want to change it, because it seems
678          far too likely that something will break.  */
679
680       relocation -=
681         input_section->output_section->vma + input_section->output_offset;
682
683       if (howto->pcrel_offset)
684         relocation -= reloc_entry->address;
685     }
686
687   if (output_bfd != NULL)
688     {
689       if (! howto->partial_inplace)
690         {
691           /* This is a partial relocation, and we want to apply the relocation
692              to the reloc entry rather than the raw data. Modify the reloc
693              inplace to reflect what we now know.  */
694           reloc_entry->addend = relocation;
695           reloc_entry->address += input_section->output_offset;
696           return flag;
697         }
698       else
699         {
700           /* This is a partial relocation, but inplace, so modify the
701              reloc record a bit.
702
703              If we've relocated with a symbol with a section, change
704              into a ref to the section belonging to the symbol.  */
705
706           reloc_entry->address += input_section->output_offset;
707
708           /* WTF?? */
709           if (abfd->xvec->flavour == bfd_target_coff_flavour
710               && strcmp (abfd->xvec->name, "coff-Intel-little") != 0
711               && strcmp (abfd->xvec->name, "coff-Intel-big") != 0)
712             {
713               /* For m68k-coff, the addend was being subtracted twice during
714                  relocation with -r.  Removing the line below this comment
715                  fixes that problem; see PR 2953.
716
717 However, Ian wrote the following, regarding removing the line below,
718 which explains why it is still enabled:  --djm
719
720 If you put a patch like that into BFD you need to check all the COFF
721 linkers.  I am fairly certain that patch will break coff-i386 (e.g.,
722 SCO); see coff_i386_reloc in coff-i386.c where I worked around the
723 problem in a different way.  There may very well be a reason that the
724 code works as it does.
725
726 Hmmm.  The first obvious point is that bfd_perform_relocation should
727 not have any tests that depend upon the flavour.  It's seem like
728 entirely the wrong place for such a thing.  The second obvious point
729 is that the current code ignores the reloc addend when producing
730 relocatable output for COFF.  That's peculiar.  In fact, I really
731 have no idea what the point of the line you want to remove is.
732
733 A typical COFF reloc subtracts the old value of the symbol and adds in
734 the new value to the location in the object file (if it's a pc
735 relative reloc it adds the difference between the symbol value and the
736 location).  When relocating we need to preserve that property.
737
738 BFD handles this by setting the addend to the negative of the old
739 value of the symbol.  Unfortunately it handles common symbols in a
740 non-standard way (it doesn't subtract the old value) but that's a
741 different story (we can't change it without losing backward
742 compatibility with old object files) (coff-i386 does subtract the old
743 value, to be compatible with existing coff-i386 targets, like SCO).
744
745 So everything works fine when not producing relocatable output.  When
746 we are producing relocatable output, logically we should do exactly
747 what we do when not producing relocatable output.  Therefore, your
748 patch is correct.  In fact, it should probably always just set
749 reloc_entry->addend to 0 for all cases, since it is, in fact, going to
750 add the value into the object file.  This won't hurt the COFF code,
751 which doesn't use the addend; I'm not sure what it will do to other
752 formats (the thing to check for would be whether any formats both use
753 the addend and set partial_inplace).
754
755 When I wanted to make coff-i386 produce relocatable output, I ran
756 into the problem that you are running into: I wanted to remove that
757 line.  Rather than risk it, I made the coff-i386 relocs use a special
758 function; it's coff_i386_reloc in coff-i386.c.  The function
759 specifically adds the addend field into the object file, knowing that
760 bfd_perform_relocation is not going to.  If you remove that line, then
761 coff-i386.c will wind up adding the addend field in twice.  It's
762 trivial to fix; it just needs to be done.
763
764 The problem with removing the line is just that it may break some
765 working code.  With BFD it's hard to be sure of anything.  The right
766 way to deal with this is simply to build and test at least all the
767 supported COFF targets.  It should be straightforward if time and disk
768 space consuming.  For each target:
769     1) build the linker
770     2) generate some executable, and link it using -r (I would
771        probably use paranoia.o and link against newlib/libc.a, which
772        for all the supported targets would be available in
773        /usr/cygnus/progressive/H-host/target/lib/libc.a).
774     3) make the change to reloc.c
775     4) rebuild the linker
776     5) repeat step 2
777     6) if the resulting object files are the same, you have at least
778        made it no worse
779     7) if they are different you have to figure out which version is
780        right
781 */
782               relocation -= reloc_entry->addend;
783               reloc_entry->addend = 0;
784             }
785           else
786             {
787               reloc_entry->addend = relocation;
788             }
789         }
790     }
791   else
792     {
793       reloc_entry->addend = 0;
794     }
795
796   /* FIXME: This overflow checking is incomplete, because the value
797      might have overflowed before we get here.  For a correct check we
798      need to compute the value in a size larger than bitsize, but we
799      can't reasonably do that for a reloc the same size as a host
800      machine word.
801      FIXME: We should also do overflow checking on the result after
802      adding in the value contained in the object file.  */
803   if (howto->complain_on_overflow != complain_overflow_dont
804       && flag == bfd_reloc_ok)
805     flag = bfd_check_overflow (howto->complain_on_overflow,
806                                howto->bitsize,
807                                howto->rightshift,
808                                bfd_arch_bits_per_address (abfd),
809                                relocation);
810
811   /* Either we are relocating all the way, or we don't want to apply
812      the relocation to the reloc entry (probably because there isn't
813      any room in the output format to describe addends to relocs).  */
814
815   /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler
816      (OSF version 1.3, compiler version 3.11).  It miscompiles the
817      following program:
818
819      struct str
820      {
821        unsigned int i0;
822      } s = { 0 };
823
824      int
825      main ()
826      {
827        unsigned long x;
828
829        x = 0x100000000;
830        x <<= (unsigned long) s.i0;
831        if (x == 0)
832          printf ("failed\n");
833        else
834          printf ("succeeded (%lx)\n", x);
835      }
836      */
837
838   relocation >>= (bfd_vma) howto->rightshift;
839
840   /* Shift everything up to where it's going to be used.  */
841   relocation <<= (bfd_vma) howto->bitpos;
842
843   /* Wait for the day when all have the mask in them.  */
844
845   /* What we do:
846      i instruction to be left alone
847      o offset within instruction
848      r relocation offset to apply
849      S src mask
850      D dst mask
851      N ~dst mask
852      A part 1
853      B part 2
854      R result
855
856      Do this:
857      ((  i i i i i o o o o o  from bfd_get<size>
858      and           S S S S S) to get the size offset we want
859      +   r r r r r r r r r r) to get the final value to place
860      and           D D D D D  to chop to right size
861      -----------------------
862      =             A A A A A
863      And this:
864      (   i i i i i o o o o o  from bfd_get<size>
865      and N N N N N          ) get instruction
866      -----------------------
867      =   B B B B B
868
869      And then:
870      (   B B B B B
871      or            A A A A A)
872      -----------------------
873      =   R R R R R R R R R R  put into bfd_put<size>
874      */
875
876 #define DOIT(x) \
877   x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) +  relocation) & howto->dst_mask))
878
879   switch (howto->size)
880     {
881     case 0:
882       {
883         char x = bfd_get_8 (abfd, (char *) data + octets);
884         DOIT (x);
885         bfd_put_8 (abfd, x, (unsigned char *) data + octets);
886       }
887       break;
888
889     case 1:
890       {
891         short x = bfd_get_16 (abfd, (bfd_byte *) data + octets);
892         DOIT (x);
893         bfd_put_16 (abfd, (bfd_vma) x, (unsigned char *) data + octets);
894       }
895       break;
896     case 2:
897       {
898         long x = bfd_get_32 (abfd, (bfd_byte *) data + octets);
899         DOIT (x);
900         bfd_put_32 (abfd, (bfd_vma) x, (bfd_byte *) data + octets);
901       }
902       break;
903     case -2:
904       {
905         long x = bfd_get_32 (abfd, (bfd_byte *) data + octets);
906         relocation = -relocation;
907         DOIT (x);
908         bfd_put_32 (abfd, (bfd_vma) x, (bfd_byte *) data + octets);
909       }
910       break;
911
912     case -1:
913       {
914         long x = bfd_get_16 (abfd, (bfd_byte *) data + octets);
915         relocation = -relocation;
916         DOIT (x);
917         bfd_put_16 (abfd, (bfd_vma) x, (bfd_byte *) data + octets);
918       }
919       break;
920
921     case 3:
922       /* Do nothing */
923       break;
924
925     case 4:
926 #ifdef BFD64
927       {
928         bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data + octets);
929         DOIT (x);
930         bfd_put_64 (abfd, x, (bfd_byte *) data + octets);
931       }
932 #else
933       abort ();
934 #endif
935       break;
936     default:
937       return bfd_reloc_other;
938     }
939
940   return flag;
941 }
942
943 /*
944 FUNCTION
945         bfd_install_relocation
946
947 SYNOPSIS
948         bfd_reloc_status_type bfd_install_relocation
949           (bfd *abfd,
950            arelent *reloc_entry,
951            void *data, bfd_vma data_start,
952            asection *input_section,
953            char **error_message);
954
955 DESCRIPTION
956         This looks remarkably like <<bfd_perform_relocation>>, except it
957         does not expect that the section contents have been filled in.
958         I.e., it's suitable for use when creating, rather than applying
959         a relocation.
960
961         For now, this function should be considered reserved for the
962         assembler.
963 */
964
965 bfd_reloc_status_type
966 bfd_install_relocation (bfd *abfd,
967                         arelent *reloc_entry,
968                         void *data_start,
969                         bfd_vma data_start_offset,
970                         asection *input_section,
971                         char **error_message)
972 {
973   bfd_vma relocation;
974   bfd_reloc_status_type flag = bfd_reloc_ok;
975   bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd);
976   bfd_vma output_base = 0;
977   reloc_howto_type *howto = reloc_entry->howto;
978   asection *reloc_target_output_section;
979   asymbol *symbol;
980   bfd_byte *data;
981
982   symbol = *(reloc_entry->sym_ptr_ptr);
983   if (bfd_is_abs_section (symbol->section))
984     {
985       reloc_entry->address += input_section->output_offset;
986       return bfd_reloc_ok;
987     }
988
989   /* If there is a function supplied to handle this relocation type,
990      call it.  It'll return `bfd_reloc_continue' if further processing
991      can be done.  */
992   if (howto->special_function)
993     {
994       bfd_reloc_status_type cont;
995
996       /* XXX - The special_function calls haven't been fixed up to deal
997          with creating new relocations and section contents.  */
998       cont = howto->special_function (abfd, reloc_entry, symbol,
999                                       /* XXX - Non-portable! */
1000                                       ((bfd_byte *) data_start
1001                                        - data_start_offset),
1002                                       input_section, abfd, error_message);
1003       if (cont != bfd_reloc_continue)
1004         return cont;
1005     }
1006
1007   /* Is the address of the relocation really within the section?  */
1008   if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
1009     return bfd_reloc_outofrange;
1010
1011   /* Work out which section the relocation is targeted at and the
1012      initial relocation command value.  */
1013
1014   /* Get symbol value.  (Common symbols are special.)  */
1015   if (bfd_is_com_section (symbol->section))
1016     relocation = 0;
1017   else
1018     relocation = symbol->value;
1019
1020   reloc_target_output_section = symbol->section->output_section;
1021
1022   /* Convert input-section-relative symbol value to absolute.  */
1023   if (! howto->partial_inplace)
1024     output_base = 0;
1025   else
1026     output_base = reloc_target_output_section->vma;
1027
1028   relocation += output_base + symbol->section->output_offset;
1029
1030   /* Add in supplied addend.  */
1031   relocation += reloc_entry->addend;
1032
1033   /* Here the variable relocation holds the final address of the
1034      symbol we are relocating against, plus any addend.  */
1035
1036   if (howto->pc_relative)
1037     {
1038       /* This is a PC relative relocation.  We want to set RELOCATION
1039          to the distance between the address of the symbol and the
1040          location.  RELOCATION is already the address of the symbol.
1041
1042          We start by subtracting the address of the section containing
1043          the location.
1044
1045          If pcrel_offset is set, we must further subtract the position
1046          of the location within the section.  Some targets arrange for
1047          the addend to be the negative of the position of the location
1048          within the section; for example, i386-aout does this.  For
1049          i386-aout, pcrel_offset is FALSE.  Some other targets do not
1050          include the position of the location; for example, m88kbcs,
1051          or ELF.  For those targets, pcrel_offset is TRUE.
1052
1053          If we are producing relocatable output, then we must ensure
1054          that this reloc will be correctly computed when the final
1055          relocation is done.  If pcrel_offset is FALSE we want to wind
1056          up with the negative of the location within the section,
1057          which means we must adjust the existing addend by the change
1058          in the location within the section.  If pcrel_offset is TRUE
1059          we do not want to adjust the existing addend at all.
1060
1061          FIXME: This seems logical to me, but for the case of
1062          producing relocatable output it is not what the code
1063          actually does.  I don't want to change it, because it seems
1064          far too likely that something will break.  */
1065
1066       relocation -=
1067         input_section->output_section->vma + input_section->output_offset;
1068
1069       if (howto->pcrel_offset && howto->partial_inplace)
1070         relocation -= reloc_entry->address;
1071     }
1072
1073   if (! howto->partial_inplace)
1074     {
1075       /* This is a partial relocation, and we want to apply the relocation
1076          to the reloc entry rather than the raw data. Modify the reloc
1077          inplace to reflect what we now know.  */
1078       reloc_entry->addend = relocation;
1079       reloc_entry->address += input_section->output_offset;
1080       return flag;
1081     }
1082   else
1083     {
1084       /* This is a partial relocation, but inplace, so modify the
1085          reloc record a bit.
1086
1087          If we've relocated with a symbol with a section, change
1088          into a ref to the section belonging to the symbol.  */
1089       reloc_entry->address += input_section->output_offset;
1090
1091       /* WTF?? */
1092       if (abfd->xvec->flavour == bfd_target_coff_flavour
1093           && strcmp (abfd->xvec->name, "coff-Intel-little") != 0
1094           && strcmp (abfd->xvec->name, "coff-Intel-big") != 0)
1095         {
1096
1097           /* For m68k-coff, the addend was being subtracted twice during
1098              relocation with -r.  Removing the line below this comment
1099              fixes that problem; see PR 2953.
1100
1101 However, Ian wrote the following, regarding removing the line below,
1102 which explains why it is still enabled:  --djm
1103
1104 If you put a patch like that into BFD you need to check all the COFF
1105 linkers.  I am fairly certain that patch will break coff-i386 (e.g.,
1106 SCO); see coff_i386_reloc in coff-i386.c where I worked around the
1107 problem in a different way.  There may very well be a reason that the
1108 code works as it does.
1109
1110 Hmmm.  The first obvious point is that bfd_install_relocation should
1111 not have any tests that depend upon the flavour.  It's seem like
1112 entirely the wrong place for such a thing.  The second obvious point
1113 is that the current code ignores the reloc addend when producing
1114 relocatable output for COFF.  That's peculiar.  In fact, I really
1115 have no idea what the point of the line you want to remove is.
1116
1117 A typical COFF reloc subtracts the old value of the symbol and adds in
1118 the new value to the location in the object file (if it's a pc
1119 relative reloc it adds the difference between the symbol value and the
1120 location).  When relocating we need to preserve that property.
1121
1122 BFD handles this by setting the addend to the negative of the old
1123 value of the symbol.  Unfortunately it handles common symbols in a
1124 non-standard way (it doesn't subtract the old value) but that's a
1125 different story (we can't change it without losing backward
1126 compatibility with old object files) (coff-i386 does subtract the old
1127 value, to be compatible with existing coff-i386 targets, like SCO).
1128
1129 So everything works fine when not producing relocatable output.  When
1130 we are producing relocatable output, logically we should do exactly
1131 what we do when not producing relocatable output.  Therefore, your
1132 patch is correct.  In fact, it should probably always just set
1133 reloc_entry->addend to 0 for all cases, since it is, in fact, going to
1134 add the value into the object file.  This won't hurt the COFF code,
1135 which doesn't use the addend; I'm not sure what it will do to other
1136 formats (the thing to check for would be whether any formats both use
1137 the addend and set partial_inplace).
1138
1139 When I wanted to make coff-i386 produce relocatable output, I ran
1140 into the problem that you are running into: I wanted to remove that
1141 line.  Rather than risk it, I made the coff-i386 relocs use a special
1142 function; it's coff_i386_reloc in coff-i386.c.  The function
1143 specifically adds the addend field into the object file, knowing that
1144 bfd_install_relocation is not going to.  If you remove that line, then
1145 coff-i386.c will wind up adding the addend field in twice.  It's
1146 trivial to fix; it just needs to be done.
1147
1148 The problem with removing the line is just that it may break some
1149 working code.  With BFD it's hard to be sure of anything.  The right
1150 way to deal with this is simply to build and test at least all the
1151 supported COFF targets.  It should be straightforward if time and disk
1152 space consuming.  For each target:
1153     1) build the linker
1154     2) generate some executable, and link it using -r (I would
1155        probably use paranoia.o and link against newlib/libc.a, which
1156        for all the supported targets would be available in
1157        /usr/cygnus/progressive/H-host/target/lib/libc.a).
1158     3) make the change to reloc.c
1159     4) rebuild the linker
1160     5) repeat step 2
1161     6) if the resulting object files are the same, you have at least
1162        made it no worse
1163     7) if they are different you have to figure out which version is
1164        right.  */
1165           relocation -= reloc_entry->addend;
1166           /* FIXME: There should be no target specific code here...  */
1167           if (strcmp (abfd->xvec->name, "coff-z8k") != 0)
1168             reloc_entry->addend = 0;
1169         }
1170       else
1171         {
1172           reloc_entry->addend = relocation;
1173         }
1174     }
1175
1176   /* FIXME: This overflow checking is incomplete, because the value
1177      might have overflowed before we get here.  For a correct check we
1178      need to compute the value in a size larger than bitsize, but we
1179      can't reasonably do that for a reloc the same size as a host
1180      machine word.
1181      FIXME: We should also do overflow checking on the result after
1182      adding in the value contained in the object file.  */
1183   if (howto->complain_on_overflow != complain_overflow_dont)
1184     flag = bfd_check_overflow (howto->complain_on_overflow,
1185                                howto->bitsize,
1186                                howto->rightshift,
1187                                bfd_arch_bits_per_address (abfd),
1188                                relocation);
1189
1190   /* Either we are relocating all the way, or we don't want to apply
1191      the relocation to the reloc entry (probably because there isn't
1192      any room in the output format to describe addends to relocs).  */
1193
1194   /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler
1195      (OSF version 1.3, compiler version 3.11).  It miscompiles the
1196      following program:
1197
1198      struct str
1199      {
1200        unsigned int i0;
1201      } s = { 0 };
1202
1203      int
1204      main ()
1205      {
1206        unsigned long x;
1207
1208        x = 0x100000000;
1209        x <<= (unsigned long) s.i0;
1210        if (x == 0)
1211          printf ("failed\n");
1212        else
1213          printf ("succeeded (%lx)\n", x);
1214      }
1215      */
1216
1217   relocation >>= (bfd_vma) howto->rightshift;
1218
1219   /* Shift everything up to where it's going to be used.  */
1220   relocation <<= (bfd_vma) howto->bitpos;
1221
1222   /* Wait for the day when all have the mask in them.  */
1223
1224   /* What we do:
1225      i instruction to be left alone
1226      o offset within instruction
1227      r relocation offset to apply
1228      S src mask
1229      D dst mask
1230      N ~dst mask
1231      A part 1
1232      B part 2
1233      R result
1234
1235      Do this:
1236      ((  i i i i i o o o o o  from bfd_get<size>
1237      and           S S S S S) to get the size offset we want
1238      +   r r r r r r r r r r) to get the final value to place
1239      and           D D D D D  to chop to right size
1240      -----------------------
1241      =             A A A A A
1242      And this:
1243      (   i i i i i o o o o o  from bfd_get<size>
1244      and N N N N N          ) get instruction
1245      -----------------------
1246      =   B B B B B
1247
1248      And then:
1249      (   B B B B B
1250      or            A A A A A)
1251      -----------------------
1252      =   R R R R R R R R R R  put into bfd_put<size>
1253      */
1254
1255 #define DOIT(x) \
1256   x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) +  relocation) & howto->dst_mask))
1257
1258   data = (bfd_byte *) data_start + (octets - data_start_offset);
1259
1260   switch (howto->size)
1261     {
1262     case 0:
1263       {
1264         char x = bfd_get_8 (abfd, data);
1265         DOIT (x);
1266         bfd_put_8 (abfd, x, data);
1267       }
1268       break;
1269
1270     case 1:
1271       {
1272         short x = bfd_get_16 (abfd, data);
1273         DOIT (x);
1274         bfd_put_16 (abfd, (bfd_vma) x, data);
1275       }
1276       break;
1277     case 2:
1278       {
1279         long x = bfd_get_32 (abfd, data);
1280         DOIT (x);
1281         bfd_put_32 (abfd, (bfd_vma) x, data);
1282       }
1283       break;
1284     case -2:
1285       {
1286         long x = bfd_get_32 (abfd, data);
1287         relocation = -relocation;
1288         DOIT (x);
1289         bfd_put_32 (abfd, (bfd_vma) x, data);
1290       }
1291       break;
1292
1293     case 3:
1294       /* Do nothing */
1295       break;
1296
1297     case 4:
1298       {
1299         bfd_vma x = bfd_get_64 (abfd, data);
1300         DOIT (x);
1301         bfd_put_64 (abfd, x, data);
1302       }
1303       break;
1304     default:
1305       return bfd_reloc_other;
1306     }
1307
1308   return flag;
1309 }
1310
1311 /* This relocation routine is used by some of the backend linkers.
1312    They do not construct asymbol or arelent structures, so there is no
1313    reason for them to use bfd_perform_relocation.  Also,
1314    bfd_perform_relocation is so hacked up it is easier to write a new
1315    function than to try to deal with it.
1316
1317    This routine does a final relocation.  Whether it is useful for a
1318    relocatable link depends upon how the object format defines
1319    relocations.
1320
1321    FIXME: This routine ignores any special_function in the HOWTO,
1322    since the existing special_function values have been written for
1323    bfd_perform_relocation.
1324
1325    HOWTO is the reloc howto information.
1326    INPUT_BFD is the BFD which the reloc applies to.
1327    INPUT_SECTION is the section which the reloc applies to.
1328    CONTENTS is the contents of the section.
1329    ADDRESS is the address of the reloc within INPUT_SECTION.
1330    VALUE is the value of the symbol the reloc refers to.
1331    ADDEND is the addend of the reloc.  */
1332
1333 bfd_reloc_status_type
1334 _bfd_final_link_relocate (reloc_howto_type *howto,
1335                           bfd *input_bfd,
1336                           asection *input_section,
1337                           bfd_byte *contents,
1338                           bfd_vma address,
1339                           bfd_vma value,
1340                           bfd_vma addend)
1341 {
1342   bfd_vma relocation;
1343
1344   /* Sanity check the address.  */
1345   if (address > bfd_get_section_limit (input_bfd, input_section))
1346     return bfd_reloc_outofrange;
1347
1348   /* This function assumes that we are dealing with a basic relocation
1349      against a symbol.  We want to compute the value of the symbol to
1350      relocate to.  This is just VALUE, the value of the symbol, plus
1351      ADDEND, any addend associated with the reloc.  */
1352   relocation = value + addend;
1353
1354   /* If the relocation is PC relative, we want to set RELOCATION to
1355      the distance between the symbol (currently in RELOCATION) and the
1356      location we are relocating.  Some targets (e.g., i386-aout)
1357      arrange for the contents of the section to be the negative of the
1358      offset of the location within the section; for such targets
1359      pcrel_offset is FALSE.  Other targets (e.g., m88kbcs or ELF)
1360      simply leave the contents of the section as zero; for such
1361      targets pcrel_offset is TRUE.  If pcrel_offset is FALSE we do not
1362      need to subtract out the offset of the location within the
1363      section (which is just ADDRESS).  */
1364   if (howto->pc_relative)
1365     {
1366       relocation -= (input_section->output_section->vma
1367                      + input_section->output_offset);
1368       if (howto->pcrel_offset)
1369         relocation -= address;
1370     }
1371
1372   return _bfd_relocate_contents (howto, input_bfd, relocation,
1373                                  contents + address);
1374 }
1375
1376 /* Relocate a given location using a given value and howto.  */
1377
1378 bfd_reloc_status_type
1379 _bfd_relocate_contents (reloc_howto_type *howto,
1380                         bfd *input_bfd,
1381                         bfd_vma relocation,
1382                         bfd_byte *location)
1383 {
1384   int size;
1385   bfd_vma x = 0;
1386   bfd_reloc_status_type flag;
1387   unsigned int rightshift = howto->rightshift;
1388   unsigned int bitpos = howto->bitpos;
1389
1390   /* If the size is negative, negate RELOCATION.  This isn't very
1391      general.  */
1392   if (howto->size < 0)
1393     relocation = -relocation;
1394
1395   /* Get the value we are going to relocate.  */
1396   size = bfd_get_reloc_size (howto);
1397   switch (size)
1398     {
1399     default:
1400     case 0:
1401       abort ();
1402     case 1:
1403       x = bfd_get_8 (input_bfd, location);
1404       break;
1405     case 2:
1406       x = bfd_get_16 (input_bfd, location);
1407       break;
1408     case 4:
1409       x = bfd_get_32 (input_bfd, location);
1410       break;
1411     case 8:
1412 #ifdef BFD64
1413       x = bfd_get_64 (input_bfd, location);
1414 #else
1415       abort ();
1416 #endif
1417       break;
1418     }
1419
1420   /* Check for overflow.  FIXME: We may drop bits during the addition
1421      which we don't check for.  We must either check at every single
1422      operation, which would be tedious, or we must do the computations
1423      in a type larger than bfd_vma, which would be inefficient.  */
1424   flag = bfd_reloc_ok;
1425   if (howto->complain_on_overflow != complain_overflow_dont)
1426     {
1427       bfd_vma addrmask, fieldmask, signmask, ss;
1428       bfd_vma a, b, sum;
1429
1430       /* Get the values to be added together.  For signed and unsigned
1431          relocations, we assume that all values should be truncated to
1432          the size of an address.  For bitfields, all the bits matter.
1433          See also bfd_check_overflow.  */
1434       fieldmask = N_ONES (howto->bitsize);
1435       signmask = ~fieldmask;
1436       addrmask = N_ONES (bfd_arch_bits_per_address (input_bfd)) | fieldmask;
1437       a = (relocation & addrmask) >> rightshift;
1438       b = (x & howto->src_mask & addrmask) >> bitpos;
1439
1440       switch (howto->complain_on_overflow)
1441         {
1442         case complain_overflow_signed:
1443           /* If any sign bits are set, all sign bits must be set.
1444              That is, A must be a valid negative address after
1445              shifting.  */
1446           signmask = ~(fieldmask >> 1);
1447           /* Fall thru */
1448
1449         case complain_overflow_bitfield:
1450           /* Much like the signed check, but for a field one bit
1451              wider.  We allow a bitfield to represent numbers in the
1452              range -2**n to 2**n-1, where n is the number of bits in the
1453              field.  Note that when bfd_vma is 32 bits, a 32-bit reloc
1454              can't overflow, which is exactly what we want.  */
1455           ss = a & signmask;
1456           if (ss != 0 && ss != ((addrmask >> rightshift) & signmask))
1457             flag = bfd_reloc_overflow;
1458
1459           /* We only need this next bit of code if the sign bit of B
1460              is below the sign bit of A.  This would only happen if
1461              SRC_MASK had fewer bits than BITSIZE.  Note that if
1462              SRC_MASK has more bits than BITSIZE, we can get into
1463              trouble; we would need to verify that B is in range, as
1464              we do for A above.  */
1465           ss = ((~howto->src_mask) >> 1) & howto->src_mask;
1466           ss >>= bitpos;
1467
1468           /* Set all the bits above the sign bit.  */
1469           b = (b ^ ss) - ss;
1470
1471           /* Now we can do the addition.  */
1472           sum = a + b;
1473
1474           /* See if the result has the correct sign.  Bits above the
1475              sign bit are junk now; ignore them.  If the sum is
1476              positive, make sure we did not have all negative inputs;
1477              if the sum is negative, make sure we did not have all
1478              positive inputs.  The test below looks only at the sign
1479              bits, and it really just
1480                  SIGN (A) == SIGN (B) && SIGN (A) != SIGN (SUM)
1481
1482              We mask with addrmask here to explicitly allow an address
1483              wrap-around.  The Linux kernel relies on it, and it is
1484              the only way to write assembler code which can run when
1485              loaded at a location 0x80000000 away from the location at
1486              which it is linked.  */
1487           if (((~(a ^ b)) & (a ^ sum)) & signmask & addrmask)
1488             flag = bfd_reloc_overflow;
1489           break;
1490
1491         case complain_overflow_unsigned:
1492           /* Checking for an unsigned overflow is relatively easy:
1493              trim the addresses and add, and trim the result as well.
1494              Overflow is normally indicated when the result does not
1495              fit in the field.  However, we also need to consider the
1496              case when, e.g., fieldmask is 0x7fffffff or smaller, an
1497              input is 0x80000000, and bfd_vma is only 32 bits; then we
1498              will get sum == 0, but there is an overflow, since the
1499              inputs did not fit in the field.  Instead of doing a
1500              separate test, we can check for this by or-ing in the
1501              operands when testing for the sum overflowing its final
1502              field.  */
1503           sum = (a + b) & addrmask;
1504           if ((a | b | sum) & signmask)
1505             flag = bfd_reloc_overflow;
1506           break;
1507
1508         default:
1509           abort ();
1510         }
1511     }
1512
1513   /* Put RELOCATION in the right bits.  */
1514   relocation >>= (bfd_vma) rightshift;
1515   relocation <<= (bfd_vma) bitpos;
1516
1517   /* Add RELOCATION to the right bits of X.  */
1518   x = ((x & ~howto->dst_mask)
1519        | (((x & howto->src_mask) + relocation) & howto->dst_mask));
1520
1521   /* Put the relocated value back in the object file.  */
1522   switch (size)
1523     {
1524     default:
1525     case 0:
1526       abort ();
1527     case 1:
1528       bfd_put_8 (input_bfd, x, location);
1529       break;
1530     case 2:
1531       bfd_put_16 (input_bfd, x, location);
1532       break;
1533     case 4:
1534       bfd_put_32 (input_bfd, x, location);
1535       break;
1536     case 8:
1537 #ifdef BFD64
1538       bfd_put_64 (input_bfd, x, location);
1539 #else
1540       abort ();
1541 #endif
1542       break;
1543     }
1544
1545   return flag;
1546 }
1547
1548 /*
1549 DOCDD
1550 INODE
1551         howto manager,  , typedef arelent, Relocations
1552
1553 SUBSECTION
1554         The howto manager
1555
1556         When an application wants to create a relocation, but doesn't
1557         know what the target machine might call it, it can find out by
1558         using this bit of code.
1559
1560 */
1561
1562 /*
1563 TYPEDEF
1564         bfd_reloc_code_type
1565
1566 DESCRIPTION
1567         The insides of a reloc code.  The idea is that, eventually, there
1568         will be one enumerator for every type of relocation we ever do.
1569         Pass one of these values to <<bfd_reloc_type_lookup>>, and it'll
1570         return a howto pointer.
1571
1572         This does mean that the application must determine the correct
1573         enumerator value; you can't get a howto pointer from a random set
1574         of attributes.
1575
1576 SENUM
1577    bfd_reloc_code_real
1578
1579 ENUM
1580   BFD_RELOC_64
1581 ENUMX
1582   BFD_RELOC_32
1583 ENUMX
1584   BFD_RELOC_26
1585 ENUMX
1586   BFD_RELOC_24
1587 ENUMX
1588   BFD_RELOC_16
1589 ENUMX
1590   BFD_RELOC_14
1591 ENUMX
1592   BFD_RELOC_8
1593 ENUMDOC
1594   Basic absolute relocations of N bits.
1595
1596 ENUM
1597   BFD_RELOC_64_PCREL
1598 ENUMX
1599   BFD_RELOC_32_PCREL
1600 ENUMX
1601   BFD_RELOC_24_PCREL
1602 ENUMX
1603   BFD_RELOC_16_PCREL
1604 ENUMX
1605   BFD_RELOC_12_PCREL
1606 ENUMX
1607   BFD_RELOC_8_PCREL
1608 ENUMDOC
1609   PC-relative relocations.  Sometimes these are relative to the address
1610 of the relocation itself; sometimes they are relative to the start of
1611 the section containing the relocation.  It depends on the specific target.
1612
1613 The 24-bit relocation is used in some Intel 960 configurations.
1614
1615 ENUM
1616   BFD_RELOC_32_SECREL
1617 ENUMDOC
1618   Section relative relocations.  Some targets need this for DWARF2.
1619
1620 ENUM
1621   BFD_RELOC_32_GOT_PCREL
1622 ENUMX
1623   BFD_RELOC_16_GOT_PCREL
1624 ENUMX
1625   BFD_RELOC_8_GOT_PCREL
1626 ENUMX
1627   BFD_RELOC_32_GOTOFF
1628 ENUMX
1629   BFD_RELOC_16_GOTOFF
1630 ENUMX
1631   BFD_RELOC_LO16_GOTOFF
1632 ENUMX
1633   BFD_RELOC_HI16_GOTOFF
1634 ENUMX
1635   BFD_RELOC_HI16_S_GOTOFF
1636 ENUMX
1637   BFD_RELOC_8_GOTOFF
1638 ENUMX
1639   BFD_RELOC_64_PLT_PCREL
1640 ENUMX
1641   BFD_RELOC_32_PLT_PCREL
1642 ENUMX
1643   BFD_RELOC_24_PLT_PCREL
1644 ENUMX
1645   BFD_RELOC_16_PLT_PCREL
1646 ENUMX
1647   BFD_RELOC_8_PLT_PCREL
1648 ENUMX
1649   BFD_RELOC_64_PLTOFF
1650 ENUMX
1651   BFD_RELOC_32_PLTOFF
1652 ENUMX
1653   BFD_RELOC_16_PLTOFF
1654 ENUMX
1655   BFD_RELOC_LO16_PLTOFF
1656 ENUMX
1657   BFD_RELOC_HI16_PLTOFF
1658 ENUMX
1659   BFD_RELOC_HI16_S_PLTOFF
1660 ENUMX
1661   BFD_RELOC_8_PLTOFF
1662 ENUMDOC
1663   For ELF.
1664
1665 ENUM
1666   BFD_RELOC_68K_GLOB_DAT
1667 ENUMX
1668   BFD_RELOC_68K_JMP_SLOT
1669 ENUMX
1670   BFD_RELOC_68K_RELATIVE
1671 ENUMDOC
1672   Relocations used by 68K ELF.
1673
1674 ENUM
1675   BFD_RELOC_32_BASEREL
1676 ENUMX
1677   BFD_RELOC_16_BASEREL
1678 ENUMX
1679   BFD_RELOC_LO16_BASEREL
1680 ENUMX
1681   BFD_RELOC_HI16_BASEREL
1682 ENUMX
1683   BFD_RELOC_HI16_S_BASEREL
1684 ENUMX
1685   BFD_RELOC_8_BASEREL
1686 ENUMX
1687   BFD_RELOC_RVA
1688 ENUMDOC
1689   Linkage-table relative.
1690
1691 ENUM
1692   BFD_RELOC_8_FFnn
1693 ENUMDOC
1694   Absolute 8-bit relocation, but used to form an address like 0xFFnn.
1695
1696 ENUM
1697   BFD_RELOC_32_PCREL_S2
1698 ENUMX
1699   BFD_RELOC_16_PCREL_S2
1700 ENUMX
1701   BFD_RELOC_23_PCREL_S2
1702 ENUMDOC
1703   These PC-relative relocations are stored as word displacements --
1704 i.e., byte displacements shifted right two bits.  The 30-bit word
1705 displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the
1706 SPARC.  (SPARC tools generally refer to this as <<WDISP30>>.)  The
1707 signed 16-bit displacement is used on the MIPS, and the 23-bit
1708 displacement is used on the Alpha.
1709
1710 ENUM
1711   BFD_RELOC_HI22
1712 ENUMX
1713   BFD_RELOC_LO10
1714 ENUMDOC
1715   High 22 bits and low 10 bits of 32-bit value, placed into lower bits of
1716 the target word.  These are used on the SPARC.
1717
1718 ENUM
1719   BFD_RELOC_GPREL16
1720 ENUMX
1721   BFD_RELOC_GPREL32
1722 ENUMDOC
1723   For systems that allocate a Global Pointer register, these are
1724 displacements off that register.  These relocation types are
1725 handled specially, because the value the register will have is
1726 decided relatively late.
1727
1728 ENUM
1729   BFD_RELOC_I960_CALLJ
1730 ENUMDOC
1731   Reloc types used for i960/b.out.
1732
1733 ENUM
1734   BFD_RELOC_NONE
1735 ENUMX
1736   BFD_RELOC_SPARC_WDISP22
1737 ENUMX
1738   BFD_RELOC_SPARC22
1739 ENUMX
1740   BFD_RELOC_SPARC13
1741 ENUMX
1742   BFD_RELOC_SPARC_GOT10
1743 ENUMX
1744   BFD_RELOC_SPARC_GOT13
1745 ENUMX
1746   BFD_RELOC_SPARC_GOT22
1747 ENUMX
1748   BFD_RELOC_SPARC_PC10
1749 ENUMX
1750   BFD_RELOC_SPARC_PC22
1751 ENUMX
1752   BFD_RELOC_SPARC_WPLT30
1753 ENUMX
1754   BFD_RELOC_SPARC_COPY
1755 ENUMX
1756   BFD_RELOC_SPARC_GLOB_DAT
1757 ENUMX
1758   BFD_RELOC_SPARC_JMP_SLOT
1759 ENUMX
1760   BFD_RELOC_SPARC_RELATIVE
1761 ENUMX
1762   BFD_RELOC_SPARC_UA16
1763 ENUMX
1764   BFD_RELOC_SPARC_UA32
1765 ENUMX
1766   BFD_RELOC_SPARC_UA64
1767 ENUMDOC
1768   SPARC ELF relocations.  There is probably some overlap with other
1769   relocation types already defined.
1770
1771 ENUM
1772   BFD_RELOC_SPARC_BASE13
1773 ENUMX
1774   BFD_RELOC_SPARC_BASE22
1775 ENUMDOC
1776   I think these are specific to SPARC a.out (e.g., Sun 4).
1777
1778 ENUMEQ
1779   BFD_RELOC_SPARC_64
1780   BFD_RELOC_64
1781 ENUMX
1782   BFD_RELOC_SPARC_10
1783 ENUMX
1784   BFD_RELOC_SPARC_11
1785 ENUMX
1786   BFD_RELOC_SPARC_OLO10
1787 ENUMX
1788   BFD_RELOC_SPARC_HH22
1789 ENUMX
1790   BFD_RELOC_SPARC_HM10
1791 ENUMX
1792   BFD_RELOC_SPARC_LM22
1793 ENUMX
1794   BFD_RELOC_SPARC_PC_HH22
1795 ENUMX
1796   BFD_RELOC_SPARC_PC_HM10
1797 ENUMX
1798   BFD_RELOC_SPARC_PC_LM22
1799 ENUMX
1800   BFD_RELOC_SPARC_WDISP16
1801 ENUMX
1802   BFD_RELOC_SPARC_WDISP19
1803 ENUMX
1804   BFD_RELOC_SPARC_7
1805 ENUMX
1806   BFD_RELOC_SPARC_6
1807 ENUMX
1808   BFD_RELOC_SPARC_5
1809 ENUMEQX
1810   BFD_RELOC_SPARC_DISP64
1811   BFD_RELOC_64_PCREL
1812 ENUMX
1813   BFD_RELOC_SPARC_PLT32
1814 ENUMX
1815   BFD_RELOC_SPARC_PLT64
1816 ENUMX
1817   BFD_RELOC_SPARC_HIX22
1818 ENUMX
1819   BFD_RELOC_SPARC_LOX10
1820 ENUMX
1821   BFD_RELOC_SPARC_H44
1822 ENUMX
1823   BFD_RELOC_SPARC_M44
1824 ENUMX
1825   BFD_RELOC_SPARC_L44
1826 ENUMX
1827   BFD_RELOC_SPARC_REGISTER
1828 ENUMDOC
1829   SPARC64 relocations
1830
1831 ENUM
1832   BFD_RELOC_SPARC_REV32
1833 ENUMDOC
1834   SPARC little endian relocation
1835 ENUM
1836   BFD_RELOC_SPARC_TLS_GD_HI22
1837 ENUMX
1838   BFD_RELOC_SPARC_TLS_GD_LO10
1839 ENUMX
1840   BFD_RELOC_SPARC_TLS_GD_ADD
1841 ENUMX
1842   BFD_RELOC_SPARC_TLS_GD_CALL
1843 ENUMX
1844   BFD_RELOC_SPARC_TLS_LDM_HI22
1845 ENUMX
1846   BFD_RELOC_SPARC_TLS_LDM_LO10
1847 ENUMX
1848   BFD_RELOC_SPARC_TLS_LDM_ADD
1849 ENUMX
1850   BFD_RELOC_SPARC_TLS_LDM_CALL
1851 ENUMX
1852   BFD_RELOC_SPARC_TLS_LDO_HIX22
1853 ENUMX
1854   BFD_RELOC_SPARC_TLS_LDO_LOX10
1855 ENUMX
1856   BFD_RELOC_SPARC_TLS_LDO_ADD
1857 ENUMX
1858   BFD_RELOC_SPARC_TLS_IE_HI22
1859 ENUMX
1860   BFD_RELOC_SPARC_TLS_IE_LO10
1861 ENUMX
1862   BFD_RELOC_SPARC_TLS_IE_LD
1863 ENUMX
1864   BFD_RELOC_SPARC_TLS_IE_LDX
1865 ENUMX
1866   BFD_RELOC_SPARC_TLS_IE_ADD
1867 ENUMX
1868   BFD_RELOC_SPARC_TLS_LE_HIX22
1869 ENUMX
1870   BFD_RELOC_SPARC_TLS_LE_LOX10
1871 ENUMX
1872   BFD_RELOC_SPARC_TLS_DTPMOD32
1873 ENUMX
1874   BFD_RELOC_SPARC_TLS_DTPMOD64
1875 ENUMX
1876   BFD_RELOC_SPARC_TLS_DTPOFF32
1877 ENUMX
1878   BFD_RELOC_SPARC_TLS_DTPOFF64
1879 ENUMX
1880   BFD_RELOC_SPARC_TLS_TPOFF32
1881 ENUMX
1882   BFD_RELOC_SPARC_TLS_TPOFF64
1883 ENUMDOC
1884   SPARC TLS relocations
1885
1886 ENUM
1887   BFD_RELOC_ALPHA_GPDISP_HI16
1888 ENUMDOC
1889   Alpha ECOFF and ELF relocations.  Some of these treat the symbol or
1890      "addend" in some special way.
1891   For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when
1892      writing; when reading, it will be the absolute section symbol.  The
1893      addend is the displacement in bytes of the "lda" instruction from
1894      the "ldah" instruction (which is at the address of this reloc).
1895 ENUM
1896   BFD_RELOC_ALPHA_GPDISP_LO16
1897 ENUMDOC
1898   For GPDISP_LO16 ("ignore") relocations, the symbol is handled as
1899      with GPDISP_HI16 relocs.  The addend is ignored when writing the
1900      relocations out, and is filled in with the file's GP value on
1901      reading, for convenience.
1902
1903 ENUM
1904   BFD_RELOC_ALPHA_GPDISP
1905 ENUMDOC
1906   The ELF GPDISP relocation is exactly the same as the GPDISP_HI16
1907      relocation except that there is no accompanying GPDISP_LO16
1908      relocation.
1909
1910 ENUM
1911   BFD_RELOC_ALPHA_LITERAL
1912 ENUMX
1913   BFD_RELOC_ALPHA_ELF_LITERAL
1914 ENUMX
1915   BFD_RELOC_ALPHA_LITUSE
1916 ENUMDOC
1917   The Alpha LITERAL/LITUSE relocs are produced by a symbol reference;
1918      the assembler turns it into a LDQ instruction to load the address of
1919      the symbol, and then fills in a register in the real instruction.
1920
1921      The LITERAL reloc, at the LDQ instruction, refers to the .lita
1922      section symbol.  The addend is ignored when writing, but is filled
1923      in with the file's GP value on reading, for convenience, as with the
1924      GPDISP_LO16 reloc.
1925
1926      The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16.
1927      It should refer to the symbol to be referenced, as with 16_GOTOFF,
1928      but it generates output not based on the position within the .got
1929      section, but relative to the GP value chosen for the file during the
1930      final link stage.
1931
1932      The LITUSE reloc, on the instruction using the loaded address, gives
1933      information to the linker that it might be able to use to optimize
1934      away some literal section references.  The symbol is ignored (read
1935      as the absolute section symbol), and the "addend" indicates the type
1936      of instruction using the register:
1937               1 - "memory" fmt insn
1938               2 - byte-manipulation (byte offset reg)
1939               3 - jsr (target of branch)
1940
1941 ENUM
1942   BFD_RELOC_ALPHA_HINT
1943 ENUMDOC
1944   The HINT relocation indicates a value that should be filled into the
1945      "hint" field of a jmp/jsr/ret instruction, for possible branch-
1946      prediction logic which may be provided on some processors.
1947
1948 ENUM
1949   BFD_RELOC_ALPHA_LINKAGE
1950 ENUMDOC
1951   The LINKAGE relocation outputs a linkage pair in the object file,
1952      which is filled by the linker.
1953
1954 ENUM
1955   BFD_RELOC_ALPHA_CODEADDR
1956 ENUMDOC
1957   The CODEADDR relocation outputs a STO_CA in the object file,
1958      which is filled by the linker.
1959
1960 ENUM
1961   BFD_RELOC_ALPHA_GPREL_HI16
1962 ENUMX
1963   BFD_RELOC_ALPHA_GPREL_LO16
1964 ENUMDOC
1965   The GPREL_HI/LO relocations together form a 32-bit offset from the
1966      GP register.
1967
1968 ENUM
1969   BFD_RELOC_ALPHA_BRSGP
1970 ENUMDOC
1971   Like BFD_RELOC_23_PCREL_S2, except that the source and target must
1972   share a common GP, and the target address is adjusted for
1973   STO_ALPHA_STD_GPLOAD.
1974
1975 ENUM
1976   BFD_RELOC_ALPHA_TLSGD
1977 ENUMX
1978   BFD_RELOC_ALPHA_TLSLDM
1979 ENUMX
1980   BFD_RELOC_ALPHA_DTPMOD64
1981 ENUMX
1982   BFD_RELOC_ALPHA_GOTDTPREL16
1983 ENUMX
1984   BFD_RELOC_ALPHA_DTPREL64
1985 ENUMX
1986   BFD_RELOC_ALPHA_DTPREL_HI16
1987 ENUMX
1988   BFD_RELOC_ALPHA_DTPREL_LO16
1989 ENUMX
1990   BFD_RELOC_ALPHA_DTPREL16
1991 ENUMX
1992   BFD_RELOC_ALPHA_GOTTPREL16
1993 ENUMX
1994   BFD_RELOC_ALPHA_TPREL64
1995 ENUMX
1996   BFD_RELOC_ALPHA_TPREL_HI16
1997 ENUMX
1998   BFD_RELOC_ALPHA_TPREL_LO16
1999 ENUMX
2000   BFD_RELOC_ALPHA_TPREL16
2001 ENUMDOC
2002   Alpha thread-local storage relocations.
2003
2004 ENUM
2005   BFD_RELOC_MIPS_JMP
2006 ENUMDOC
2007   Bits 27..2 of the relocation address shifted right 2 bits;
2008      simple reloc otherwise.
2009
2010 ENUM
2011   BFD_RELOC_MIPS16_JMP
2012 ENUMDOC
2013   The MIPS16 jump instruction.
2014
2015 ENUM
2016   BFD_RELOC_MIPS16_GPREL
2017 ENUMDOC
2018   MIPS16 GP relative reloc.
2019
2020 ENUM
2021   BFD_RELOC_HI16
2022 ENUMDOC
2023   High 16 bits of 32-bit value; simple reloc.
2024 ENUM
2025   BFD_RELOC_HI16_S
2026 ENUMDOC
2027   High 16 bits of 32-bit value but the low 16 bits will be sign
2028      extended and added to form the final result.  If the low 16
2029      bits form a negative number, we need to add one to the high value
2030      to compensate for the borrow when the low bits are added.
2031 ENUM
2032   BFD_RELOC_LO16
2033 ENUMDOC
2034   Low 16 bits.
2035
2036 ENUM
2037   BFD_RELOC_HI16_PCREL
2038 ENUMDOC
2039   High 16 bits of 32-bit pc-relative value
2040 ENUM
2041   BFD_RELOC_HI16_S_PCREL
2042 ENUMDOC
2043   High 16 bits of 32-bit pc-relative value, adjusted
2044 ENUM
2045   BFD_RELOC_LO16_PCREL
2046 ENUMDOC
2047   Low 16 bits of pc-relative value
2048
2049 ENUM
2050   BFD_RELOC_MIPS16_HI16
2051 ENUMDOC
2052   MIPS16 high 16 bits of 32-bit value.
2053 ENUM
2054   BFD_RELOC_MIPS16_HI16_S
2055 ENUMDOC
2056   MIPS16 high 16 bits of 32-bit value but the low 16 bits will be sign
2057      extended and added to form the final result.  If the low 16
2058      bits form a negative number, we need to add one to the high value
2059      to compensate for the borrow when the low bits are added.
2060 ENUM
2061   BFD_RELOC_MIPS16_LO16
2062 ENUMDOC
2063   MIPS16 low 16 bits.
2064
2065 ENUM
2066   BFD_RELOC_MIPS_LITERAL
2067 ENUMDOC
2068   Relocation against a MIPS literal section.
2069
2070 ENUM
2071   BFD_RELOC_MIPS_GOT16
2072 ENUMX
2073   BFD_RELOC_MIPS_CALL16
2074 ENUMX
2075   BFD_RELOC_MIPS_GOT_HI16
2076 ENUMX
2077   BFD_RELOC_MIPS_GOT_LO16
2078 ENUMX
2079   BFD_RELOC_MIPS_CALL_HI16
2080 ENUMX
2081   BFD_RELOC_MIPS_CALL_LO16
2082 ENUMX
2083   BFD_RELOC_MIPS_SUB
2084 ENUMX
2085   BFD_RELOC_MIPS_GOT_PAGE
2086 ENUMX
2087   BFD_RELOC_MIPS_GOT_OFST
2088 ENUMX
2089   BFD_RELOC_MIPS_GOT_DISP
2090 ENUMX
2091   BFD_RELOC_MIPS_SHIFT5
2092 ENUMX
2093   BFD_RELOC_MIPS_SHIFT6
2094 ENUMX
2095   BFD_RELOC_MIPS_INSERT_A
2096 ENUMX
2097   BFD_RELOC_MIPS_INSERT_B
2098 ENUMX
2099   BFD_RELOC_MIPS_DELETE
2100 ENUMX
2101   BFD_RELOC_MIPS_HIGHEST
2102 ENUMX
2103   BFD_RELOC_MIPS_HIGHER
2104 ENUMX
2105   BFD_RELOC_MIPS_SCN_DISP
2106 ENUMX
2107   BFD_RELOC_MIPS_REL16
2108 ENUMX
2109   BFD_RELOC_MIPS_RELGOT
2110 ENUMX
2111   BFD_RELOC_MIPS_JALR
2112 ENUMX
2113   BFD_RELOC_MIPS_TLS_DTPMOD32
2114 ENUMX
2115   BFD_RELOC_MIPS_TLS_DTPREL32
2116 ENUMX
2117   BFD_RELOC_MIPS_TLS_DTPMOD64
2118 ENUMX
2119   BFD_RELOC_MIPS_TLS_DTPREL64
2120 ENUMX
2121   BFD_RELOC_MIPS_TLS_GD
2122 ENUMX
2123   BFD_RELOC_MIPS_TLS_LDM
2124 ENUMX
2125   BFD_RELOC_MIPS_TLS_DTPREL_HI16
2126 ENUMX
2127   BFD_RELOC_MIPS_TLS_DTPREL_LO16
2128 ENUMX
2129   BFD_RELOC_MIPS_TLS_GOTTPREL
2130 ENUMX
2131   BFD_RELOC_MIPS_TLS_TPREL32
2132 ENUMX
2133   BFD_RELOC_MIPS_TLS_TPREL64
2134 ENUMX
2135   BFD_RELOC_MIPS_TLS_TPREL_HI16
2136 ENUMX
2137   BFD_RELOC_MIPS_TLS_TPREL_LO16
2138 ENUMDOC
2139   MIPS ELF relocations.
2140 COMMENT
2141
2142 ENUM
2143   BFD_RELOC_FRV_LABEL16
2144 ENUMX
2145   BFD_RELOC_FRV_LABEL24
2146 ENUMX
2147   BFD_RELOC_FRV_LO16
2148 ENUMX
2149   BFD_RELOC_FRV_HI16
2150 ENUMX
2151   BFD_RELOC_FRV_GPREL12
2152 ENUMX
2153   BFD_RELOC_FRV_GPRELU12
2154 ENUMX
2155   BFD_RELOC_FRV_GPREL32
2156 ENUMX
2157   BFD_RELOC_FRV_GPRELHI
2158 ENUMX
2159   BFD_RELOC_FRV_GPRELLO
2160 ENUMX
2161   BFD_RELOC_FRV_GOT12
2162 ENUMX
2163   BFD_RELOC_FRV_GOTHI
2164 ENUMX
2165   BFD_RELOC_FRV_GOTLO
2166 ENUMX
2167   BFD_RELOC_FRV_FUNCDESC
2168 ENUMX
2169   BFD_RELOC_FRV_FUNCDESC_GOT12
2170 ENUMX
2171   BFD_RELOC_FRV_FUNCDESC_GOTHI
2172 ENUMX
2173   BFD_RELOC_FRV_FUNCDESC_GOTLO
2174 ENUMX
2175   BFD_RELOC_FRV_FUNCDESC_VALUE
2176 ENUMX
2177   BFD_RELOC_FRV_FUNCDESC_GOTOFF12
2178 ENUMX
2179   BFD_RELOC_FRV_FUNCDESC_GOTOFFHI
2180 ENUMX
2181   BFD_RELOC_FRV_FUNCDESC_GOTOFFLO
2182 ENUMX
2183   BFD_RELOC_FRV_GOTOFF12
2184 ENUMX
2185   BFD_RELOC_FRV_GOTOFFHI
2186 ENUMX
2187   BFD_RELOC_FRV_GOTOFFLO
2188 ENUMX
2189   BFD_RELOC_FRV_GETTLSOFF
2190 ENUMX
2191   BFD_RELOC_FRV_TLSDESC_VALUE
2192 ENUMX
2193   BFD_RELOC_FRV_GOTTLSDESC12
2194 ENUMX
2195   BFD_RELOC_FRV_GOTTLSDESCHI
2196 ENUMX
2197   BFD_RELOC_FRV_GOTTLSDESCLO
2198 ENUMX
2199   BFD_RELOC_FRV_TLSMOFF12
2200 ENUMX
2201   BFD_RELOC_FRV_TLSMOFFHI
2202 ENUMX
2203   BFD_RELOC_FRV_TLSMOFFLO
2204 ENUMX
2205   BFD_RELOC_FRV_GOTTLSOFF12
2206 ENUMX
2207   BFD_RELOC_FRV_GOTTLSOFFHI
2208 ENUMX
2209   BFD_RELOC_FRV_GOTTLSOFFLO
2210 ENUMX
2211   BFD_RELOC_FRV_TLSOFF
2212 ENUMX
2213   BFD_RELOC_FRV_TLSDESC_RELAX
2214 ENUMX
2215   BFD_RELOC_FRV_GETTLSOFF_RELAX
2216 ENUMX
2217   BFD_RELOC_FRV_TLSOFF_RELAX
2218 ENUMX
2219   BFD_RELOC_FRV_TLSMOFF
2220 ENUMDOC
2221   Fujitsu Frv Relocations.
2222 COMMENT
2223
2224 ENUM
2225   BFD_RELOC_MN10300_GOTOFF24
2226 ENUMDOC
2227   This is a 24bit GOT-relative reloc for the mn10300.
2228 ENUM
2229   BFD_RELOC_MN10300_GOT32
2230 ENUMDOC
2231   This is a 32bit GOT-relative reloc for the mn10300, offset by two bytes
2232   in the instruction.
2233 ENUM
2234   BFD_RELOC_MN10300_GOT24
2235 ENUMDOC
2236   This is a 24bit GOT-relative reloc for the mn10300, offset by two bytes
2237   in the instruction.
2238 ENUM
2239   BFD_RELOC_MN10300_GOT16
2240 ENUMDOC
2241   This is a 16bit GOT-relative reloc for the mn10300, offset by two bytes
2242   in the instruction.
2243 ENUM
2244   BFD_RELOC_MN10300_COPY
2245 ENUMDOC
2246   Copy symbol at runtime.
2247 ENUM
2248   BFD_RELOC_MN10300_GLOB_DAT
2249 ENUMDOC
2250   Create GOT entry.
2251 ENUM
2252   BFD_RELOC_MN10300_JMP_SLOT
2253 ENUMDOC
2254   Create PLT entry.
2255 ENUM
2256   BFD_RELOC_MN10300_RELATIVE
2257 ENUMDOC
2258   Adjust by program base.
2259 COMMENT
2260
2261 ENUM
2262   BFD_RELOC_386_GOT32
2263 ENUMX
2264   BFD_RELOC_386_PLT32
2265 ENUMX
2266   BFD_RELOC_386_COPY
2267 ENUMX
2268   BFD_RELOC_386_GLOB_DAT
2269 ENUMX
2270   BFD_RELOC_386_JUMP_SLOT
2271 ENUMX
2272   BFD_RELOC_386_RELATIVE
2273 ENUMX
2274   BFD_RELOC_386_GOTOFF
2275 ENUMX
2276   BFD_RELOC_386_GOTPC
2277 ENUMX
2278   BFD_RELOC_386_TLS_TPOFF
2279 ENUMX
2280   BFD_RELOC_386_TLS_IE
2281 ENUMX
2282   BFD_RELOC_386_TLS_GOTIE
2283 ENUMX
2284   BFD_RELOC_386_TLS_LE
2285 ENUMX
2286   BFD_RELOC_386_TLS_GD
2287 ENUMX
2288   BFD_RELOC_386_TLS_LDM
2289 ENUMX
2290   BFD_RELOC_386_TLS_LDO_32
2291 ENUMX
2292   BFD_RELOC_386_TLS_IE_32
2293 ENUMX
2294   BFD_RELOC_386_TLS_LE_32
2295 ENUMX
2296   BFD_RELOC_386_TLS_DTPMOD32
2297 ENUMX
2298   BFD_RELOC_386_TLS_DTPOFF32
2299 ENUMX
2300   BFD_RELOC_386_TLS_TPOFF32
2301 ENUMDOC
2302   i386/elf relocations
2303
2304 ENUM
2305   BFD_RELOC_X86_64_GOT32
2306 ENUMX
2307   BFD_RELOC_X86_64_PLT32
2308 ENUMX
2309   BFD_RELOC_X86_64_COPY
2310 ENUMX
2311   BFD_RELOC_X86_64_GLOB_DAT
2312 ENUMX
2313   BFD_RELOC_X86_64_JUMP_SLOT
2314 ENUMX
2315   BFD_RELOC_X86_64_RELATIVE
2316 ENUMX
2317   BFD_RELOC_X86_64_GOTPCREL
2318 ENUMX
2319   BFD_RELOC_X86_64_32S
2320 ENUMX
2321   BFD_RELOC_X86_64_DTPMOD64
2322 ENUMX
2323   BFD_RELOC_X86_64_DTPOFF64
2324 ENUMX
2325   BFD_RELOC_X86_64_TPOFF64
2326 ENUMX
2327   BFD_RELOC_X86_64_TLSGD
2328 ENUMX
2329   BFD_RELOC_X86_64_TLSLD
2330 ENUMX
2331   BFD_RELOC_X86_64_DTPOFF32
2332 ENUMX
2333   BFD_RELOC_X86_64_GOTTPOFF
2334 ENUMX
2335   BFD_RELOC_X86_64_TPOFF32
2336 ENUMX
2337   BFD_RELOC_X86_64_GOTOFF64
2338 ENUMX
2339   BFD_RELOC_X86_64_GOTPC32
2340 ENUMDOC
2341   x86-64/elf relocations
2342
2343 ENUM
2344   BFD_RELOC_NS32K_IMM_8
2345 ENUMX
2346   BFD_RELOC_NS32K_IMM_16
2347 ENUMX
2348   BFD_RELOC_NS32K_IMM_32
2349 ENUMX
2350   BFD_RELOC_NS32K_IMM_8_PCREL
2351 ENUMX
2352   BFD_RELOC_NS32K_IMM_16_PCREL
2353 ENUMX
2354   BFD_RELOC_NS32K_IMM_32_PCREL
2355 ENUMX
2356   BFD_RELOC_NS32K_DISP_8
2357 ENUMX
2358   BFD_RELOC_NS32K_DISP_16
2359 ENUMX
2360   BFD_RELOC_NS32K_DISP_32
2361 ENUMX
2362   BFD_RELOC_NS32K_DISP_8_PCREL
2363 ENUMX
2364   BFD_RELOC_NS32K_DISP_16_PCREL
2365 ENUMX
2366   BFD_RELOC_NS32K_DISP_32_PCREL
2367 ENUMDOC
2368   ns32k relocations
2369
2370 ENUM
2371   BFD_RELOC_PDP11_DISP_8_PCREL
2372 ENUMX
2373   BFD_RELOC_PDP11_DISP_6_PCREL
2374 ENUMDOC
2375   PDP11 relocations
2376
2377 ENUM
2378   BFD_RELOC_PJ_CODE_HI16
2379 ENUMX
2380   BFD_RELOC_PJ_CODE_LO16
2381 ENUMX
2382   BFD_RELOC_PJ_CODE_DIR16
2383 ENUMX
2384   BFD_RELOC_PJ_CODE_DIR32
2385 ENUMX
2386   BFD_RELOC_PJ_CODE_REL16
2387 ENUMX
2388   BFD_RELOC_PJ_CODE_REL32
2389 ENUMDOC
2390   Picojava relocs.  Not all of these appear in object files.
2391
2392 ENUM
2393   BFD_RELOC_PPC_B26
2394 ENUMX
2395   BFD_RELOC_PPC_BA26
2396 ENUMX
2397   BFD_RELOC_PPC_TOC16
2398 ENUMX
2399   BFD_RELOC_PPC_B16
2400 ENUMX
2401   BFD_RELOC_PPC_B16_BRTAKEN
2402 ENUMX
2403   BFD_RELOC_PPC_B16_BRNTAKEN
2404 ENUMX
2405   BFD_RELOC_PPC_BA16
2406 ENUMX
2407   BFD_RELOC_PPC_BA16_BRTAKEN
2408 ENUMX
2409   BFD_RELOC_PPC_BA16_BRNTAKEN
2410 ENUMX
2411   BFD_RELOC_PPC_COPY
2412 ENUMX
2413   BFD_RELOC_PPC_GLOB_DAT
2414 ENUMX
2415   BFD_RELOC_PPC_JMP_SLOT
2416 ENUMX
2417   BFD_RELOC_PPC_RELATIVE
2418 ENUMX
2419   BFD_RELOC_PPC_LOCAL24PC
2420 ENUMX
2421   BFD_RELOC_PPC_EMB_NADDR32
2422 ENUMX
2423   BFD_RELOC_PPC_EMB_NADDR16
2424 ENUMX
2425   BFD_RELOC_PPC_EMB_NADDR16_LO
2426 ENUMX
2427   BFD_RELOC_PPC_EMB_NADDR16_HI
2428 ENUMX
2429   BFD_RELOC_PPC_EMB_NADDR16_HA
2430 ENUMX
2431   BFD_RELOC_PPC_EMB_SDAI16
2432 ENUMX
2433   BFD_RELOC_PPC_EMB_SDA2I16
2434 ENUMX
2435   BFD_RELOC_PPC_EMB_SDA2REL
2436 ENUMX
2437   BFD_RELOC_PPC_EMB_SDA21
2438 ENUMX
2439   BFD_RELOC_PPC_EMB_MRKREF
2440 ENUMX
2441   BFD_RELOC_PPC_EMB_RELSEC16
2442 ENUMX
2443   BFD_RELOC_PPC_EMB_RELST_LO
2444 ENUMX
2445   BFD_RELOC_PPC_EMB_RELST_HI
2446 ENUMX
2447   BFD_RELOC_PPC_EMB_RELST_HA
2448 ENUMX
2449   BFD_RELOC_PPC_EMB_BIT_FLD
2450 ENUMX
2451   BFD_RELOC_PPC_EMB_RELSDA
2452 ENUMX
2453   BFD_RELOC_PPC64_HIGHER
2454 ENUMX
2455   BFD_RELOC_PPC64_HIGHER_S
2456 ENUMX
2457   BFD_RELOC_PPC64_HIGHEST
2458 ENUMX
2459   BFD_RELOC_PPC64_HIGHEST_S
2460 ENUMX
2461   BFD_RELOC_PPC64_TOC16_LO
2462 ENUMX
2463   BFD_RELOC_PPC64_TOC16_HI
2464 ENUMX
2465   BFD_RELOC_PPC64_TOC16_HA
2466 ENUMX
2467   BFD_RELOC_PPC64_TOC
2468 ENUMX
2469   BFD_RELOC_PPC64_PLTGOT16
2470 ENUMX
2471   BFD_RELOC_PPC64_PLTGOT16_LO
2472 ENUMX
2473   BFD_RELOC_PPC64_PLTGOT16_HI
2474 ENUMX
2475   BFD_RELOC_PPC64_PLTGOT16_HA
2476 ENUMX
2477   BFD_RELOC_PPC64_ADDR16_DS
2478 ENUMX
2479   BFD_RELOC_PPC64_ADDR16_LO_DS
2480 ENUMX
2481   BFD_RELOC_PPC64_GOT16_DS
2482 ENUMX
2483   BFD_RELOC_PPC64_GOT16_LO_DS
2484 ENUMX
2485   BFD_RELOC_PPC64_PLT16_LO_DS
2486 ENUMX
2487   BFD_RELOC_PPC64_SECTOFF_DS
2488 ENUMX
2489   BFD_RELOC_PPC64_SECTOFF_LO_DS
2490 ENUMX
2491   BFD_RELOC_PPC64_TOC16_DS
2492 ENUMX
2493   BFD_RELOC_PPC64_TOC16_LO_DS
2494 ENUMX
2495   BFD_RELOC_PPC64_PLTGOT16_DS
2496 ENUMX
2497   BFD_RELOC_PPC64_PLTGOT16_LO_DS
2498 ENUMDOC
2499   Power(rs6000) and PowerPC relocations.
2500
2501 ENUM
2502   BFD_RELOC_PPC_TLS
2503 ENUMX
2504   BFD_RELOC_PPC_DTPMOD
2505 ENUMX
2506   BFD_RELOC_PPC_TPREL16
2507 ENUMX
2508   BFD_RELOC_PPC_TPREL16_LO
2509 ENUMX
2510   BFD_RELOC_PPC_TPREL16_HI
2511 ENUMX
2512   BFD_RELOC_PPC_TPREL16_HA
2513 ENUMX
2514   BFD_RELOC_PPC_TPREL
2515 ENUMX
2516   BFD_RELOC_PPC_DTPREL16
2517 ENUMX
2518   BFD_RELOC_PPC_DTPREL16_LO
2519 ENUMX
2520   BFD_RELOC_PPC_DTPREL16_HI
2521 ENUMX
2522   BFD_RELOC_PPC_DTPREL16_HA
2523 ENUMX
2524   BFD_RELOC_PPC_DTPREL
2525 ENUMX
2526   BFD_RELOC_PPC_GOT_TLSGD16
2527 ENUMX
2528   BFD_RELOC_PPC_GOT_TLSGD16_LO
2529 ENUMX
2530   BFD_RELOC_PPC_GOT_TLSGD16_HI
2531 ENUMX
2532   BFD_RELOC_PPC_GOT_TLSGD16_HA
2533 ENUMX
2534   BFD_RELOC_PPC_GOT_TLSLD16
2535 ENUMX
2536   BFD_RELOC_PPC_GOT_TLSLD16_LO
2537 ENUMX
2538   BFD_RELOC_PPC_GOT_TLSLD16_HI
2539 ENUMX
2540   BFD_RELOC_PPC_GOT_TLSLD16_HA
2541 ENUMX
2542   BFD_RELOC_PPC_GOT_TPREL16
2543 ENUMX
2544   BFD_RELOC_PPC_GOT_TPREL16_LO
2545 ENUMX
2546   BFD_RELOC_PPC_GOT_TPREL16_HI
2547 ENUMX
2548   BFD_RELOC_PPC_GOT_TPREL16_HA
2549 ENUMX
2550   BFD_RELOC_PPC_GOT_DTPREL16
2551 ENUMX
2552   BFD_RELOC_PPC_GOT_DTPREL16_LO
2553 ENUMX
2554   BFD_RELOC_PPC_GOT_DTPREL16_HI
2555 ENUMX
2556   BFD_RELOC_PPC_GOT_DTPREL16_HA
2557 ENUMX
2558   BFD_RELOC_PPC64_TPREL16_DS
2559 ENUMX
2560   BFD_RELOC_PPC64_TPREL16_LO_DS
2561 ENUMX
2562   BFD_RELOC_PPC64_TPREL16_HIGHER
2563 ENUMX
2564   BFD_RELOC_PPC64_TPREL16_HIGHERA
2565 ENUMX
2566   BFD_RELOC_PPC64_TPREL16_HIGHEST
2567 ENUMX
2568   BFD_RELOC_PPC64_TPREL16_HIGHESTA
2569 ENUMX
2570   BFD_RELOC_PPC64_DTPREL16_DS
2571 ENUMX
2572   BFD_RELOC_PPC64_DTPREL16_LO_DS
2573 ENUMX
2574   BFD_RELOC_PPC64_DTPREL16_HIGHER
2575 ENUMX
2576   BFD_RELOC_PPC64_DTPREL16_HIGHERA
2577 ENUMX
2578   BFD_RELOC_PPC64_DTPREL16_HIGHEST
2579 ENUMX
2580   BFD_RELOC_PPC64_DTPREL16_HIGHESTA
2581 ENUMDOC
2582   PowerPC and PowerPC64 thread-local storage relocations.
2583
2584 ENUM
2585   BFD_RELOC_I370_D12
2586 ENUMDOC
2587   IBM 370/390 relocations
2588
2589 ENUM
2590   BFD_RELOC_CTOR
2591 ENUMDOC
2592   The type of reloc used to build a constructor table - at the moment
2593   probably a 32 bit wide absolute relocation, but the target can choose.
2594   It generally does map to one of the other relocation types.
2595
2596 ENUM
2597   BFD_RELOC_ARM_PCREL_BRANCH
2598 ENUMDOC
2599   ARM 26 bit pc-relative branch.  The lowest two bits must be zero and are
2600   not stored in the instruction.
2601 ENUM
2602   BFD_RELOC_ARM_PCREL_BLX
2603 ENUMDOC
2604   ARM 26 bit pc-relative branch.  The lowest bit must be zero and is
2605   not stored in the instruction.  The 2nd lowest bit comes from a 1 bit
2606   field in the instruction.
2607 ENUM
2608   BFD_RELOC_THUMB_PCREL_BLX
2609 ENUMDOC
2610   Thumb 22 bit pc-relative branch.  The lowest bit must be zero and is
2611   not stored in the instruction.  The 2nd lowest bit comes from a 1 bit
2612   field in the instruction.
2613 ENUM 
2614   BFD_RELOC_ARM_PCREL_CALL
2615 ENUMDOC
2616   ARM 26-bit pc-relative branch for an unconditional BL or BLX instruction.
2617 ENUM 
2618   BFD_RELOC_ARM_PCREL_JUMP
2619 ENUMDOC
2620   ARM 26-bit pc-relative branch for B or conditional BL instruction.
2621
2622 ENUM
2623   BFD_RELOC_THUMB_PCREL_BRANCH7
2624 ENUMX
2625   BFD_RELOC_THUMB_PCREL_BRANCH9
2626 ENUMX
2627   BFD_RELOC_THUMB_PCREL_BRANCH12
2628 ENUMX
2629   BFD_RELOC_THUMB_PCREL_BRANCH20
2630 ENUMX
2631   BFD_RELOC_THUMB_PCREL_BRANCH23
2632 ENUMX
2633   BFD_RELOC_THUMB_PCREL_BRANCH25
2634 ENUMDOC
2635   Thumb 7-, 9-, 12-, 20-, 23-, and 25-bit pc-relative branches.
2636   The lowest bit must be zero and is not stored in the instruction.
2637   Note that the corresponding ELF R_ARM_THM_JUMPnn constant has an
2638   "nn" one smaller in all cases.  Note further that BRANCH23
2639   corresponds to R_ARM_THM_CALL.
2640
2641 ENUM
2642   BFD_RELOC_ARM_OFFSET_IMM
2643 ENUMDOC
2644   12-bit immediate offset, used in ARM-format ldr and str instructions.
2645
2646 ENUM
2647   BFD_RELOC_ARM_THUMB_OFFSET
2648 ENUMDOC
2649   5-bit immediate offset, used in Thumb-format ldr and str instructions.
2650
2651 ENUM
2652   BFD_RELOC_ARM_TARGET1
2653 ENUMDOC
2654   Pc-relative or absolute relocation depending on target.  Used for
2655   entries in .init_array sections.
2656 ENUM
2657   BFD_RELOC_ARM_ROSEGREL32
2658 ENUMDOC
2659   Read-only segment base relative address.
2660 ENUM
2661   BFD_RELOC_ARM_SBREL32
2662 ENUMDOC
2663   Data segment base relative address.
2664 ENUM
2665   BFD_RELOC_ARM_TARGET2
2666 ENUMDOC
2667   This reloc is used for references to RTTI data from exception handling
2668   tables.  The actual definition depends on the target.  It may be a
2669   pc-relative or some form of GOT-indirect relocation.
2670 ENUM
2671   BFD_RELOC_ARM_PREL31
2672 ENUMDOC
2673   31-bit PC relative address.
2674
2675 ENUM
2676   BFD_RELOC_ARM_JUMP_SLOT
2677 ENUMX
2678   BFD_RELOC_ARM_GLOB_DAT
2679 ENUMX
2680   BFD_RELOC_ARM_GOT32
2681 ENUMX
2682   BFD_RELOC_ARM_PLT32
2683 ENUMX
2684   BFD_RELOC_ARM_RELATIVE
2685 ENUMX
2686   BFD_RELOC_ARM_GOTOFF
2687 ENUMX
2688   BFD_RELOC_ARM_GOTPC
2689 ENUMDOC
2690   Relocations for setting up GOTs and PLTs for shared libraries.
2691
2692 ENUM
2693   BFD_RELOC_ARM_TLS_GD32
2694 ENUMX
2695   BFD_RELOC_ARM_TLS_LDO32
2696 ENUMX
2697   BFD_RELOC_ARM_TLS_LDM32
2698 ENUMX
2699   BFD_RELOC_ARM_TLS_DTPOFF32
2700 ENUMX
2701   BFD_RELOC_ARM_TLS_DTPMOD32
2702 ENUMX
2703   BFD_RELOC_ARM_TLS_TPOFF32
2704 ENUMX
2705   BFD_RELOC_ARM_TLS_IE32
2706 ENUMX
2707   BFD_RELOC_ARM_TLS_LE32
2708 ENUMDOC
2709   ARM thread-local storage relocations.
2710
2711 ENUM
2712   BFD_RELOC_ARM_IMMEDIATE
2713 ENUMX
2714   BFD_RELOC_ARM_ADRL_IMMEDIATE
2715 ENUMX
2716   BFD_RELOC_ARM_T32_IMMEDIATE
2717 ENUMX
2718   BFD_RELOC_ARM_T32_IMM12
2719 ENUMX
2720   BFD_RELOC_ARM_T32_ADD_PC12
2721 ENUMX
2722   BFD_RELOC_ARM_SHIFT_IMM
2723 ENUMX
2724   BFD_RELOC_ARM_SMC
2725 ENUMX
2726   BFD_RELOC_ARM_SWI
2727 ENUMX
2728   BFD_RELOC_ARM_MULTI
2729 ENUMX
2730   BFD_RELOC_ARM_CP_OFF_IMM
2731 ENUMX
2732   BFD_RELOC_ARM_CP_OFF_IMM_S2
2733 ENUMX
2734   BFD_RELOC_ARM_T32_CP_OFF_IMM
2735 ENUMX
2736   BFD_RELOC_ARM_T32_CP_OFF_IMM_S2
2737 ENUMX
2738   BFD_RELOC_ARM_ADR_IMM
2739 ENUMX
2740   BFD_RELOC_ARM_LDR_IMM
2741 ENUMX
2742   BFD_RELOC_ARM_LITERAL
2743 ENUMX
2744   BFD_RELOC_ARM_IN_POOL
2745 ENUMX
2746   BFD_RELOC_ARM_OFFSET_IMM8
2747 ENUMX
2748   BFD_RELOC_ARM_T32_OFFSET_U8
2749 ENUMX
2750   BFD_RELOC_ARM_T32_OFFSET_IMM
2751 ENUMX
2752   BFD_RELOC_ARM_HWLITERAL
2753 ENUMX
2754   BFD_RELOC_ARM_THUMB_ADD
2755 ENUMX
2756   BFD_RELOC_ARM_THUMB_IMM
2757 ENUMX
2758   BFD_RELOC_ARM_THUMB_SHIFT
2759 ENUMDOC
2760   These relocs are only used within the ARM assembler.  They are not
2761   (at present) written to any object files.
2762
2763 ENUM
2764   BFD_RELOC_SH_PCDISP8BY2
2765 ENUMX
2766   BFD_RELOC_SH_PCDISP12BY2
2767 ENUMX
2768   BFD_RELOC_SH_IMM3
2769 ENUMX
2770   BFD_RELOC_SH_IMM3U
2771 ENUMX
2772   BFD_RELOC_SH_DISP12
2773 ENUMX
2774   BFD_RELOC_SH_DISP12BY2
2775 ENUMX
2776   BFD_RELOC_SH_DISP12BY4
2777 ENUMX
2778   BFD_RELOC_SH_DISP12BY8
2779 ENUMX
2780   BFD_RELOC_SH_DISP20
2781 ENUMX
2782   BFD_RELOC_SH_DISP20BY8
2783 ENUMX
2784   BFD_RELOC_SH_IMM4
2785 ENUMX
2786   BFD_RELOC_SH_IMM4BY2
2787 ENUMX
2788   BFD_RELOC_SH_IMM4BY4
2789 ENUMX
2790   BFD_RELOC_SH_IMM8
2791 ENUMX
2792   BFD_RELOC_SH_IMM8BY2
2793 ENUMX
2794   BFD_RELOC_SH_IMM8BY4
2795 ENUMX
2796   BFD_RELOC_SH_PCRELIMM8BY2
2797 ENUMX
2798   BFD_RELOC_SH_PCRELIMM8BY4
2799 ENUMX
2800   BFD_RELOC_SH_SWITCH16
2801 ENUMX
2802   BFD_RELOC_SH_SWITCH32
2803 ENUMX
2804   BFD_RELOC_SH_USES
2805 ENUMX
2806   BFD_RELOC_SH_COUNT
2807 ENUMX
2808   BFD_RELOC_SH_ALIGN
2809 ENUMX
2810   BFD_RELOC_SH_CODE
2811 ENUMX
2812   BFD_RELOC_SH_DATA
2813 ENUMX
2814   BFD_RELOC_SH_LABEL
2815 ENUMX
2816   BFD_RELOC_SH_LOOP_START
2817 ENUMX
2818   BFD_RELOC_SH_LOOP_END
2819 ENUMX
2820   BFD_RELOC_SH_COPY
2821 ENUMX
2822   BFD_RELOC_SH_GLOB_DAT
2823 ENUMX
2824   BFD_RELOC_SH_JMP_SLOT
2825 ENUMX
2826   BFD_RELOC_SH_RELATIVE
2827 ENUMX
2828   BFD_RELOC_SH_GOTPC
2829 ENUMX
2830   BFD_RELOC_SH_GOT_LOW16
2831 ENUMX
2832   BFD_RELOC_SH_GOT_MEDLOW16
2833 ENUMX
2834   BFD_RELOC_SH_GOT_MEDHI16
2835 ENUMX
2836   BFD_RELOC_SH_GOT_HI16
2837 ENUMX
2838   BFD_RELOC_SH_GOTPLT_LOW16
2839 ENUMX
2840   BFD_RELOC_SH_GOTPLT_MEDLOW16
2841 ENUMX
2842   BFD_RELOC_SH_GOTPLT_MEDHI16
2843 ENUMX
2844   BFD_RELOC_SH_GOTPLT_HI16
2845 ENUMX
2846   BFD_RELOC_SH_PLT_LOW16
2847 ENUMX
2848   BFD_RELOC_SH_PLT_MEDLOW16
2849 ENUMX
2850   BFD_RELOC_SH_PLT_MEDHI16
2851 ENUMX
2852   BFD_RELOC_SH_PLT_HI16
2853 ENUMX
2854   BFD_RELOC_SH_GOTOFF_LOW16
2855 ENUMX
2856   BFD_RELOC_SH_GOTOFF_MEDLOW16
2857 ENUMX
2858   BFD_RELOC_SH_GOTOFF_MEDHI16
2859 ENUMX
2860   BFD_RELOC_SH_GOTOFF_HI16
2861 ENUMX
2862   BFD_RELOC_SH_GOTPC_LOW16
2863 ENUMX
2864   BFD_RELOC_SH_GOTPC_MEDLOW16
2865 ENUMX
2866   BFD_RELOC_SH_GOTPC_MEDHI16
2867 ENUMX
2868   BFD_RELOC_SH_GOTPC_HI16
2869 ENUMX
2870   BFD_RELOC_SH_COPY64
2871 ENUMX
2872   BFD_RELOC_SH_GLOB_DAT64
2873 ENUMX
2874   BFD_RELOC_SH_JMP_SLOT64
2875 ENUMX
2876   BFD_RELOC_SH_RELATIVE64
2877 ENUMX
2878   BFD_RELOC_SH_GOT10BY4
2879 ENUMX
2880   BFD_RELOC_SH_GOT10BY8
2881 ENUMX
2882   BFD_RELOC_SH_GOTPLT10BY4
2883 ENUMX
2884   BFD_RELOC_SH_GOTPLT10BY8
2885 ENUMX
2886   BFD_RELOC_SH_GOTPLT32
2887 ENUMX
2888   BFD_RELOC_SH_SHMEDIA_CODE
2889 ENUMX
2890   BFD_RELOC_SH_IMMU5
2891 ENUMX
2892   BFD_RELOC_SH_IMMS6
2893 ENUMX
2894   BFD_RELOC_SH_IMMS6BY32
2895 ENUMX
2896   BFD_RELOC_SH_IMMU6
2897 ENUMX
2898   BFD_RELOC_SH_IMMS10
2899 ENUMX
2900   BFD_RELOC_SH_IMMS10BY2
2901 ENUMX
2902   BFD_RELOC_SH_IMMS10BY4
2903 ENUMX
2904   BFD_RELOC_SH_IMMS10BY8
2905 ENUMX
2906   BFD_RELOC_SH_IMMS16
2907 ENUMX
2908   BFD_RELOC_SH_IMMU16
2909 ENUMX
2910   BFD_RELOC_SH_IMM_LOW16
2911 ENUMX
2912   BFD_RELOC_SH_IMM_LOW16_PCREL
2913 ENUMX
2914   BFD_RELOC_SH_IMM_MEDLOW16
2915 ENUMX
2916   BFD_RELOC_SH_IMM_MEDLOW16_PCREL
2917 ENUMX
2918   BFD_RELOC_SH_IMM_MEDHI16
2919 ENUMX
2920   BFD_RELOC_SH_IMM_MEDHI16_PCREL
2921 ENUMX
2922   BFD_RELOC_SH_IMM_HI16
2923 ENUMX
2924   BFD_RELOC_SH_IMM_HI16_PCREL
2925 ENUMX
2926   BFD_RELOC_SH_PT_16
2927 ENUMX
2928   BFD_RELOC_SH_TLS_GD_32
2929 ENUMX
2930   BFD_RELOC_SH_TLS_LD_32
2931 ENUMX
2932   BFD_RELOC_SH_TLS_LDO_32
2933 ENUMX
2934   BFD_RELOC_SH_TLS_IE_32
2935 ENUMX
2936   BFD_RELOC_SH_TLS_LE_32
2937 ENUMX
2938   BFD_RELOC_SH_TLS_DTPMOD32
2939 ENUMX
2940   BFD_RELOC_SH_TLS_DTPOFF32
2941 ENUMX
2942   BFD_RELOC_SH_TLS_TPOFF32
2943 ENUMDOC
2944   Renesas / SuperH SH relocs.  Not all of these appear in object files.
2945
2946 ENUM
2947   BFD_RELOC_ARC_B22_PCREL
2948 ENUMDOC
2949   ARC Cores relocs.
2950   ARC 22 bit pc-relative branch.  The lowest two bits must be zero and are
2951   not stored in the instruction.  The high 20 bits are installed in bits 26
2952   through 7 of the instruction.
2953 ENUM
2954   BFD_RELOC_ARC_B26
2955 ENUMDOC
2956   ARC 26 bit absolute branch.  The lowest two bits must be zero and are not
2957   stored in the instruction.  The high 24 bits are installed in bits 23
2958   through 0.
2959
2960 ENUM
2961   BFD_RELOC_BFIN_16_IMM
2962 ENUMDOC
2963   ADI Blackfin 16 bit immediate absolute reloc.
2964 ENUM
2965   BFD_RELOC_BFIN_16_HIGH
2966 ENUMDOC
2967   ADI Blackfin 16 bit immediate absolute reloc higher 16 bits.
2968 ENUM
2969   BFD_RELOC_BFIN_4_PCREL
2970 ENUMDOC
2971   ADI Blackfin 'a' part of LSETUP.
2972 ENUM
2973   BFD_RELOC_BFIN_5_PCREL
2974 ENUMDOC
2975   ADI Blackfin.
2976 ENUM
2977   BFD_RELOC_BFIN_16_LOW
2978 ENUMDOC
2979   ADI Blackfin 16 bit immediate absolute reloc lower 16 bits.
2980 ENUM
2981   BFD_RELOC_BFIN_10_PCREL
2982 ENUMDOC
2983   ADI Blackfin.
2984 ENUM
2985   BFD_RELOC_BFIN_11_PCREL
2986 ENUMDOC
2987   ADI Blackfin 'b' part of LSETUP.
2988 ENUM
2989   BFD_RELOC_BFIN_12_PCREL_JUMP
2990 ENUMDOC
2991   ADI Blackfin.
2992 ENUM
2993   BFD_RELOC_BFIN_12_PCREL_JUMP_S
2994 ENUMDOC
2995   ADI Blackfin Short jump, pcrel.
2996 ENUM
2997   BFD_RELOC_BFIN_24_PCREL_CALL_X
2998 ENUMDOC
2999   ADI Blackfin Call.x not implemented.
3000 ENUM
3001   BFD_RELOC_BFIN_24_PCREL_JUMP_L
3002 ENUMDOC
3003   ADI Blackfin Long Jump pcrel.
3004 ENUM
3005   BFD_RELOC_BFIN_GOT
3006 ENUMDOC
3007   ADI Blackfin GOT relocation.
3008 ENUM
3009   BFD_RELOC_BFIN_PLTPC
3010 ENUMDOC
3011   ADI Blackfin PLTPC relocation.
3012 ENUM
3013   BFD_ARELOC_BFIN_PUSH
3014 ENUMDOC
3015   ADI Blackfin arithmetic relocation.
3016 ENUM
3017   BFD_ARELOC_BFIN_CONST
3018 ENUMDOC
3019   ADI Blackfin arithmetic relocation.
3020 ENUM
3021   BFD_ARELOC_BFIN_ADD
3022 ENUMDOC
3023   ADI Blackfin arithmetic relocation.
3024 ENUM
3025   BFD_ARELOC_BFIN_SUB
3026 ENUMDOC
3027   ADI Blackfin arithmetic relocation.
3028 ENUM
3029   BFD_ARELOC_BFIN_MULT
3030 ENUMDOC
3031   ADI Blackfin arithmetic relocation.
3032 ENUM
3033   BFD_ARELOC_BFIN_DIV
3034 ENUMDOC
3035   ADI Blackfin arithmetic relocation.
3036 ENUM
3037   BFD_ARELOC_BFIN_MOD
3038 ENUMDOC
3039   ADI Blackfin arithmetic relocation.
3040 ENUM
3041   BFD_ARELOC_BFIN_LSHIFT
3042 ENUMDOC
3043   ADI Blackfin arithmetic relocation.
3044 ENUM
3045   BFD_ARELOC_BFIN_RSHIFT
3046 ENUMDOC
3047   ADI Blackfin arithmetic relocation.
3048 ENUM
3049   BFD_ARELOC_BFIN_AND
3050 ENUMDOC
3051   ADI Blackfin arithmetic relocation.
3052 ENUM
3053   BFD_ARELOC_BFIN_OR
3054 ENUMDOC
3055   ADI Blackfin arithmetic relocation.
3056 ENUM
3057   BFD_ARELOC_BFIN_XOR
3058 ENUMDOC
3059   ADI Blackfin arithmetic relocation.
3060 ENUM
3061   BFD_ARELOC_BFIN_LAND
3062 ENUMDOC
3063   ADI Blackfin arithmetic relocation.
3064 ENUM
3065   BFD_ARELOC_BFIN_LOR
3066 ENUMDOC
3067   ADI Blackfin arithmetic relocation.
3068 ENUM
3069   BFD_ARELOC_BFIN_LEN
3070 ENUMDOC
3071   ADI Blackfin arithmetic relocation.
3072 ENUM
3073   BFD_ARELOC_BFIN_NEG
3074 ENUMDOC
3075   ADI Blackfin arithmetic relocation.
3076 ENUM
3077   BFD_ARELOC_BFIN_COMP
3078 ENUMDOC
3079   ADI Blackfin arithmetic relocation.
3080 ENUM
3081   BFD_ARELOC_BFIN_PAGE
3082 ENUMDOC
3083   ADI Blackfin arithmetic relocation.
3084 ENUM
3085   BFD_ARELOC_BFIN_HWPAGE
3086 ENUMDOC
3087   ADI Blackfin arithmetic relocation.
3088 ENUM
3089   BFD_ARELOC_BFIN_ADDR
3090 ENUMDOC
3091   ADI Blackfin arithmetic relocation.
3092
3093 ENUM
3094   BFD_RELOC_D10V_10_PCREL_R
3095 ENUMDOC
3096   Mitsubishi D10V relocs.
3097   This is a 10-bit reloc with the right 2 bits
3098   assumed to be 0.
3099 ENUM
3100   BFD_RELOC_D10V_10_PCREL_L
3101 ENUMDOC
3102   Mitsubishi D10V relocs.
3103   This is a 10-bit reloc with the right 2 bits
3104   assumed to be 0.  This is the same as the previous reloc
3105   except it is in the left container, i.e.,
3106   shifted left 15 bits.
3107 ENUM
3108   BFD_RELOC_D10V_18
3109 ENUMDOC
3110   This is an 18-bit reloc with the right 2 bits
3111   assumed to be 0.
3112 ENUM
3113   BFD_RELOC_D10V_18_PCREL
3114 ENUMDOC
3115   This is an 18-bit reloc with the right 2 bits
3116   assumed to be 0.
3117
3118 ENUM
3119   BFD_RELOC_D30V_6
3120 ENUMDOC
3121   Mitsubishi D30V relocs.
3122   This is a 6-bit absolute reloc.
3123 ENUM
3124   BFD_RELOC_D30V_9_PCREL
3125 ENUMDOC
3126   This is a 6-bit pc-relative reloc with
3127   the right 3 bits assumed to be 0.
3128 ENUM
3129   BFD_RELOC_D30V_9_PCREL_R
3130 ENUMDOC
3131   This is a 6-bit pc-relative reloc with
3132   the right 3 bits assumed to be 0. Same
3133   as the previous reloc but on the right side
3134   of the container.
3135 ENUM
3136   BFD_RELOC_D30V_15
3137 ENUMDOC
3138   This is a 12-bit absolute reloc with the
3139   right 3 bitsassumed to be 0.
3140 ENUM
3141   BFD_RELOC_D30V_15_PCREL
3142 ENUMDOC
3143   This is a 12-bit pc-relative reloc with
3144   the right 3 bits assumed to be 0.
3145 ENUM
3146   BFD_RELOC_D30V_15_PCREL_R
3147 ENUMDOC
3148   This is a 12-bit pc-relative reloc with
3149   the right 3 bits assumed to be 0. Same
3150   as the previous reloc but on the right side
3151   of the container.
3152 ENUM
3153   BFD_RELOC_D30V_21
3154 ENUMDOC
3155   This is an 18-bit absolute reloc with
3156   the right 3 bits assumed to be 0.
3157 ENUM
3158   BFD_RELOC_D30V_21_PCREL
3159 ENUMDOC
3160   This is an 18-bit pc-relative reloc with
3161   the right 3 bits assumed to be 0.
3162 ENUM
3163   BFD_RELOC_D30V_21_PCREL_R
3164 ENUMDOC
3165   This is an 18-bit pc-relative reloc with
3166   the right 3 bits assumed to be 0. Same
3167   as the previous reloc but on the right side
3168   of the container.
3169 ENUM
3170   BFD_RELOC_D30V_32
3171 ENUMDOC
3172   This is a 32-bit absolute reloc.
3173 ENUM
3174   BFD_RELOC_D30V_32_PCREL
3175 ENUMDOC
3176   This is a 32-bit pc-relative reloc.
3177
3178 ENUM
3179   BFD_RELOC_DLX_HI16_S
3180 ENUMDOC
3181   DLX relocs
3182 ENUM
3183   BFD_RELOC_DLX_LO16
3184 ENUMDOC
3185   DLX relocs
3186 ENUM
3187   BFD_RELOC_DLX_JMP26
3188 ENUMDOC
3189   DLX relocs
3190
3191 ENUM
3192   BFD_RELOC_M32C_HI8
3193 ENUMDOC
3194   Renesas M16C/M32C Relocations.
3195
3196 ENUM
3197   BFD_RELOC_M32R_24
3198 ENUMDOC
3199   Renesas M32R (formerly Mitsubishi M32R) relocs.
3200   This is a 24 bit absolute address.
3201 ENUM
3202   BFD_RELOC_M32R_10_PCREL
3203 ENUMDOC
3204   This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0.
3205 ENUM
3206   BFD_RELOC_M32R_18_PCREL
3207 ENUMDOC
3208   This is an 18-bit reloc with the right 2 bits assumed to be 0.
3209 ENUM
3210   BFD_RELOC_M32R_26_PCREL
3211 ENUMDOC
3212   This is a 26-bit reloc with the right 2 bits assumed to be 0.
3213 ENUM
3214   BFD_RELOC_M32R_HI16_ULO
3215 ENUMDOC
3216   This is a 16-bit reloc containing the high 16 bits of an address
3217   used when the lower 16 bits are treated as unsigned.
3218 ENUM
3219   BFD_RELOC_M32R_HI16_SLO
3220 ENUMDOC
3221   This is a 16-bit reloc containing the high 16 bits of an address
3222   used when the lower 16 bits are treated as signed.
3223 ENUM
3224   BFD_RELOC_M32R_LO16
3225 ENUMDOC
3226   This is a 16-bit reloc containing the lower 16 bits of an address.
3227 ENUM
3228   BFD_RELOC_M32R_SDA16
3229 ENUMDOC
3230   This is a 16-bit reloc containing the small data area offset for use in
3231   add3, load, and store instructions.
3232 ENUM
3233   BFD_RELOC_M32R_GOT24
3234 ENUMX
3235   BFD_RELOC_M32R_26_PLTREL
3236 ENUMX
3237   BFD_RELOC_M32R_COPY
3238 ENUMX
3239   BFD_RELOC_M32R_GLOB_DAT
3240 ENUMX
3241   BFD_RELOC_M32R_JMP_SLOT
3242 ENUMX
3243   BFD_RELOC_M32R_RELATIVE
3244 ENUMX
3245   BFD_RELOC_M32R_GOTOFF
3246 ENUMX
3247   BFD_RELOC_M32R_GOTOFF_HI_ULO
3248 ENUMX
3249   BFD_RELOC_M32R_GOTOFF_HI_SLO
3250 ENUMX
3251   BFD_RELOC_M32R_GOTOFF_LO
3252 ENUMX
3253   BFD_RELOC_M32R_GOTPC24
3254 ENUMX
3255   BFD_RELOC_M32R_GOT16_HI_ULO
3256 ENUMX
3257   BFD_RELOC_M32R_GOT16_HI_SLO
3258 ENUMX
3259   BFD_RELOC_M32R_GOT16_LO
3260 ENUMX
3261   BFD_RELOC_M32R_GOTPC_HI_ULO
3262 ENUMX
3263   BFD_RELOC_M32R_GOTPC_HI_SLO
3264 ENUMX
3265   BFD_RELOC_M32R_GOTPC_LO
3266 ENUMDOC
3267   For PIC.
3268
3269
3270 ENUM
3271   BFD_RELOC_V850_9_PCREL
3272 ENUMDOC
3273   This is a 9-bit reloc
3274 ENUM
3275   BFD_RELOC_V850_22_PCREL
3276 ENUMDOC
3277   This is a 22-bit reloc
3278
3279 ENUM
3280   BFD_RELOC_V850_SDA_16_16_OFFSET
3281 ENUMDOC
3282   This is a 16 bit offset from the short data area pointer.
3283 ENUM
3284   BFD_RELOC_V850_SDA_15_16_OFFSET
3285 ENUMDOC
3286   This is a 16 bit offset (of which only 15 bits are used) from the
3287   short data area pointer.
3288 ENUM
3289   BFD_RELOC_V850_ZDA_16_16_OFFSET
3290 ENUMDOC
3291   This is a 16 bit offset from the zero data area pointer.
3292 ENUM
3293   BFD_RELOC_V850_ZDA_15_16_OFFSET
3294 ENUMDOC
3295   This is a 16 bit offset (of which only 15 bits are used) from the
3296   zero data area pointer.
3297 ENUM
3298   BFD_RELOC_V850_TDA_6_8_OFFSET
3299 ENUMDOC
3300   This is an 8 bit offset (of which only 6 bits are used) from the
3301   tiny data area pointer.
3302 ENUM
3303   BFD_RELOC_V850_TDA_7_8_OFFSET
3304 ENUMDOC
3305   This is an 8bit offset (of which only 7 bits are used) from the tiny
3306   data area pointer.
3307 ENUM
3308   BFD_RELOC_V850_TDA_7_7_OFFSET
3309 ENUMDOC
3310   This is a 7 bit offset from the tiny data area pointer.
3311 ENUM
3312   BFD_RELOC_V850_TDA_16_16_OFFSET
3313 ENUMDOC
3314   This is a 16 bit offset from the tiny data area pointer.
3315 COMMENT
3316 ENUM
3317   BFD_RELOC_V850_TDA_4_5_OFFSET
3318 ENUMDOC
3319   This is a 5 bit offset (of which only 4 bits are used) from the tiny
3320   data area pointer.
3321 ENUM
3322   BFD_RELOC_V850_TDA_4_4_OFFSET
3323 ENUMDOC
3324   This is a 4 bit offset from the tiny data area pointer.
3325 ENUM
3326   BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET
3327 ENUMDOC
3328   This is a 16 bit offset from the short data area pointer, with the
3329   bits placed non-contiguously in the instruction.
3330 ENUM
3331   BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET
3332 ENUMDOC
3333   This is a 16 bit offset from the zero data area pointer, with the
3334   bits placed non-contiguously in the instruction.
3335 ENUM
3336   BFD_RELOC_V850_CALLT_6_7_OFFSET
3337 ENUMDOC
3338   This is a 6 bit offset from the call table base pointer.
3339 ENUM
3340   BFD_RELOC_V850_CALLT_16_16_OFFSET
3341 ENUMDOC
3342   This is a 16 bit offset from the call table base pointer.
3343 ENUM
3344   BFD_RELOC_V850_LONGCALL
3345 ENUMDOC
3346   Used for relaxing indirect function calls.
3347 ENUM
3348   BFD_RELOC_V850_LONGJUMP
3349 ENUMDOC
3350   Used for relaxing indirect jumps.
3351 ENUM
3352   BFD_RELOC_V850_ALIGN
3353 ENUMDOC
3354   Used to maintain alignment whilst relaxing.
3355 ENUM
3356   BFD_RELOC_V850_LO16_SPLIT_OFFSET
3357 ENUMDOC
3358   This is a variation of BFD_RELOC_LO16 that can be used in v850e ld.bu
3359   instructions.
3360 ENUM
3361   BFD_RELOC_MN10300_32_PCREL
3362 ENUMDOC
3363   This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
3364   instruction.
3365 ENUM
3366   BFD_RELOC_MN10300_16_PCREL
3367 ENUMDOC
3368   This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
3369   instruction.
3370
3371 ENUM
3372   BFD_RELOC_TIC30_LDP
3373 ENUMDOC
3374   This is a 8bit DP reloc for the tms320c30, where the most
3375   significant 8 bits of a 24 bit word are placed into the least
3376   significant 8 bits of the opcode.
3377
3378 ENUM
3379   BFD_RELOC_TIC54X_PARTLS7
3380 ENUMDOC
3381   This is a 7bit reloc for the tms320c54x, where the least
3382   significant 7 bits of a 16 bit word are placed into the least
3383   significant 7 bits of the opcode.
3384
3385 ENUM
3386   BFD_RELOC_TIC54X_PARTMS9
3387 ENUMDOC
3388   This is a 9bit DP reloc for the tms320c54x, where the most
3389   significant 9 bits of a 16 bit word are placed into the least
3390   significant 9 bits of the opcode.
3391
3392 ENUM
3393   BFD_RELOC_TIC54X_23
3394 ENUMDOC
3395   This is an extended address 23-bit reloc for the tms320c54x.
3396
3397 ENUM
3398   BFD_RELOC_TIC54X_16_OF_23
3399 ENUMDOC
3400   This is a 16-bit reloc for the tms320c54x, where the least
3401   significant 16 bits of a 23-bit extended address are placed into
3402   the opcode.
3403
3404 ENUM
3405   BFD_RELOC_TIC54X_MS7_OF_23
3406 ENUMDOC
3407   This is a reloc for the tms320c54x, where the most
3408   significant 7 bits of a 23-bit extended address are placed into
3409   the opcode.
3410
3411 ENUM
3412   BFD_RELOC_FR30_48
3413 ENUMDOC
3414   This is a 48 bit reloc for the FR30 that stores 32 bits.
3415 ENUM
3416   BFD_RELOC_FR30_20
3417 ENUMDOC
3418   This is a 32 bit reloc for the FR30 that stores 20 bits split up into
3419   two sections.
3420 ENUM
3421   BFD_RELOC_FR30_6_IN_4
3422 ENUMDOC
3423   This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in
3424   4 bits.
3425 ENUM
3426   BFD_RELOC_FR30_8_IN_8
3427 ENUMDOC
3428   This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset
3429   into 8 bits.
3430 ENUM
3431   BFD_RELOC_FR30_9_IN_8
3432 ENUMDOC
3433   This is a 16 bit reloc for the FR30 that stores a 9 bit short offset
3434   into 8 bits.
3435 ENUM
3436   BFD_RELOC_FR30_10_IN_8
3437 ENUMDOC
3438   This is a 16 bit reloc for the FR30 that stores a 10 bit word offset
3439   into 8 bits.
3440 ENUM
3441   BFD_RELOC_FR30_9_PCREL
3442 ENUMDOC
3443   This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative
3444   short offset into 8 bits.
3445 ENUM
3446   BFD_RELOC_FR30_12_PCREL
3447 ENUMDOC
3448   This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative
3449   short offset into 11 bits.
3450
3451 ENUM
3452   BFD_RELOC_MCORE_PCREL_IMM8BY4
3453 ENUMX
3454   BFD_RELOC_MCORE_PCREL_IMM11BY2
3455 ENUMX
3456   BFD_RELOC_MCORE_PCREL_IMM4BY2
3457 ENUMX
3458   BFD_RELOC_MCORE_PCREL_32
3459 ENUMX
3460   BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2
3461 ENUMX
3462   BFD_RELOC_MCORE_RVA
3463 ENUMDOC
3464   Motorola Mcore relocations.
3465
3466 ENUM
3467   BFD_RELOC_MMIX_GETA
3468 ENUMX
3469   BFD_RELOC_MMIX_GETA_1
3470 ENUMX
3471   BFD_RELOC_MMIX_GETA_2
3472 ENUMX
3473   BFD_RELOC_MMIX_GETA_3
3474 ENUMDOC
3475   These are relocations for the GETA instruction.
3476 ENUM
3477   BFD_RELOC_MMIX_CBRANCH
3478 ENUMX
3479   BFD_RELOC_MMIX_CBRANCH_J
3480 ENUMX
3481   BFD_RELOC_MMIX_CBRANCH_1
3482 ENUMX
3483   BFD_RELOC_MMIX_CBRANCH_2
3484 ENUMX
3485   BFD_RELOC_MMIX_CBRANCH_3
3486 ENUMDOC
3487   These are relocations for a conditional branch instruction.
3488 ENUM
3489   BFD_RELOC_MMIX_PUSHJ
3490 ENUMX
3491   BFD_RELOC_MMIX_PUSHJ_1
3492 ENUMX
3493   BFD_RELOC_MMIX_PUSHJ_2
3494 ENUMX
3495   BFD_RELOC_MMIX_PUSHJ_3
3496 ENUMX
3497   BFD_RELOC_MMIX_PUSHJ_STUBBABLE
3498 ENUMDOC
3499   These are relocations for the PUSHJ instruction.
3500 ENUM
3501   BFD_RELOC_MMIX_JMP
3502 ENUMX
3503   BFD_RELOC_MMIX_JMP_1
3504 ENUMX
3505   BFD_RELOC_MMIX_JMP_2
3506 ENUMX
3507   BFD_RELOC_MMIX_JMP_3
3508 ENUMDOC
3509   These are relocations for the JMP instruction.
3510 ENUM
3511   BFD_RELOC_MMIX_ADDR19
3512 ENUMDOC
3513   This is a relocation for a relative address as in a GETA instruction or
3514   a branch.
3515 ENUM
3516   BFD_RELOC_MMIX_ADDR27
3517 ENUMDOC
3518   This is a relocation for a relative address as in a JMP instruction.
3519 ENUM
3520   BFD_RELOC_MMIX_REG_OR_BYTE
3521 ENUMDOC
3522   This is a relocation for an instruction field that may be a general
3523   register or a value 0..255.
3524 ENUM
3525   BFD_RELOC_MMIX_REG
3526 ENUMDOC
3527   This is a relocation for an instruction field that may be a general
3528   register.
3529 ENUM
3530   BFD_RELOC_MMIX_BASE_PLUS_OFFSET
3531 ENUMDOC
3532   This is a relocation for two instruction fields holding a register and
3533   an offset, the equivalent of the relocation.
3534 ENUM
3535   BFD_RELOC_MMIX_LOCAL
3536 ENUMDOC
3537   This relocation is an assertion that the expression is not allocated as
3538   a global register.  It does not modify contents.
3539
3540 ENUM
3541   BFD_RELOC_AVR_7_PCREL
3542 ENUMDOC
3543   This is a 16 bit reloc for the AVR that stores 8 bit pc relative
3544   short offset into 7 bits.
3545 ENUM
3546   BFD_RELOC_AVR_13_PCREL
3547 ENUMDOC
3548   This is a 16 bit reloc for the AVR that stores 13 bit pc relative
3549   short offset into 12 bits.
3550 ENUM
3551   BFD_RELOC_AVR_16_PM
3552 ENUMDOC
3553   This is a 16 bit reloc for the AVR that stores 17 bit value (usually
3554   program memory address) into 16 bits.
3555 ENUM
3556   BFD_RELOC_AVR_LO8_LDI
3557 ENUMDOC
3558   This is a 16 bit reloc for the AVR that stores 8 bit value (usually
3559   data memory address) into 8 bit immediate value of LDI insn.
3560 ENUM
3561   BFD_RELOC_AVR_HI8_LDI
3562 ENUMDOC
3563   This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit
3564   of data memory address) into 8 bit immediate value of LDI insn.
3565 ENUM
3566   BFD_RELOC_AVR_HH8_LDI
3567 ENUMDOC
3568   This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit
3569   of program memory address) into 8 bit immediate value of LDI insn.
3570 ENUM
3571   BFD_RELOC_AVR_LO8_LDI_NEG
3572 ENUMDOC
3573   This is a 16 bit reloc for the AVR that stores negated 8 bit value
3574   (usually data memory address) into 8 bit immediate value of SUBI insn.
3575 ENUM
3576   BFD_RELOC_AVR_HI8_LDI_NEG
3577 ENUMDOC
3578   This is a 16 bit reloc for the AVR that stores negated 8 bit value
3579   (high 8 bit of data memory address) into 8 bit immediate value of
3580   SUBI insn.
3581 ENUM
3582   BFD_RELOC_AVR_HH8_LDI_NEG
3583 ENUMDOC
3584   This is a 16 bit reloc for the AVR that stores negated 8 bit value
3585   (most high 8 bit of program memory address) into 8 bit immediate value
3586   of LDI or SUBI insn.
3587 ENUM
3588   BFD_RELOC_AVR_LO8_LDI_PM
3589 ENUMDOC
3590   This is a 16 bit reloc for the AVR that stores 8 bit value (usually
3591   command address) into 8 bit immediate value of LDI insn.
3592 ENUM
3593   BFD_RELOC_AVR_HI8_LDI_PM
3594 ENUMDOC
3595   This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit
3596   of command address) into 8 bit immediate value of LDI insn.
3597 ENUM
3598   BFD_RELOC_AVR_HH8_LDI_PM
3599 ENUMDOC
3600   This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit
3601   of command address) into 8 bit immediate value of LDI insn.
3602 ENUM
3603   BFD_RELOC_AVR_LO8_LDI_PM_NEG
3604 ENUMDOC
3605   This is a 16 bit reloc for the AVR that stores negated 8 bit value
3606   (usually command address) into 8 bit immediate value of SUBI insn.
3607 ENUM
3608   BFD_RELOC_AVR_HI8_LDI_PM_NEG
3609 ENUMDOC
3610   This is a 16 bit reloc for the AVR that stores negated 8 bit value
3611   (high 8 bit of 16 bit command address) into 8 bit immediate value
3612   of SUBI insn.
3613 ENUM
3614   BFD_RELOC_AVR_HH8_LDI_PM_NEG
3615 ENUMDOC
3616   This is a 16 bit reloc for the AVR that stores negated 8 bit value
3617   (high 6 bit of 22 bit command address) into 8 bit immediate
3618   value of SUBI insn.
3619 ENUM
3620   BFD_RELOC_AVR_CALL
3621 ENUMDOC
3622   This is a 32 bit reloc for the AVR that stores 23 bit value
3623   into 22 bits.
3624 ENUM
3625   BFD_RELOC_AVR_LDI
3626 ENUMDOC
3627   This is a 16 bit reloc for the AVR that stores all needed bits
3628   for absolute addressing with ldi with overflow check to linktime
3629 ENUM
3630   BFD_RELOC_AVR_6
3631 ENUMDOC
3632   This is a 6 bit reloc for the AVR that stores offset for ldd/std
3633   instructions
3634 ENUM
3635   BFD_RELOC_AVR_6_ADIW
3636 ENUMDOC
3637   This is a 6 bit reloc for the AVR that stores offset for adiw/sbiw
3638   instructions
3639
3640 ENUM
3641   BFD_RELOC_390_12
3642 ENUMDOC
3643    Direct 12 bit.
3644 ENUM
3645   BFD_RELOC_390_GOT12
3646 ENUMDOC
3647   12 bit GOT offset.
3648 ENUM
3649   BFD_RELOC_390_PLT32
3650 ENUMDOC
3651   32 bit PC relative PLT address.
3652 ENUM
3653   BFD_RELOC_390_COPY
3654 ENUMDOC
3655   Copy symbol at runtime.
3656 ENUM
3657   BFD_RELOC_390_GLOB_DAT
3658 ENUMDOC
3659   Create GOT entry.
3660 ENUM
3661   BFD_RELOC_390_JMP_SLOT
3662 ENUMDOC
3663   Create PLT entry.
3664 ENUM
3665   BFD_RELOC_390_RELATIVE
3666 ENUMDOC
3667   Adjust by program base.
3668 ENUM
3669   BFD_RELOC_390_GOTPC
3670 ENUMDOC
3671   32 bit PC relative offset to GOT.
3672 ENUM
3673   BFD_RELOC_390_GOT16
3674 ENUMDOC
3675   16 bit GOT offset.
3676 ENUM
3677   BFD_RELOC_390_PC16DBL
3678 ENUMDOC
3679   PC relative 16 bit shifted by 1.
3680 ENUM
3681   BFD_RELOC_390_PLT16DBL
3682 ENUMDOC
3683   16 bit PC rel. PLT shifted by 1.
3684 ENUM
3685   BFD_RELOC_390_PC32DBL
3686 ENUMDOC
3687   PC relative 32 bit shifted by 1.
3688 ENUM
3689   BFD_RELOC_390_PLT32DBL
3690 ENUMDOC
3691   32 bit PC rel. PLT shifted by 1.
3692 ENUM
3693   BFD_RELOC_390_GOTPCDBL
3694 ENUMDOC
3695   32 bit PC rel. GOT shifted by 1.
3696 ENUM
3697   BFD_RELOC_390_GOT64
3698 ENUMDOC
3699   64 bit GOT offset.
3700 ENUM
3701   BFD_RELOC_390_PLT64
3702 ENUMDOC
3703   64 bit PC relative PLT address.
3704 ENUM
3705   BFD_RELOC_390_GOTENT
3706 ENUMDOC
3707   32 bit rel. offset to GOT entry.
3708 ENUM
3709   BFD_RELOC_390_GOTOFF64
3710 ENUMDOC
3711   64 bit offset to GOT.
3712 ENUM
3713   BFD_RELOC_390_GOTPLT12
3714 ENUMDOC
3715   12-bit offset to symbol-entry within GOT, with PLT handling.
3716 ENUM
3717   BFD_RELOC_390_GOTPLT16
3718 ENUMDOC
3719   16-bit offset to symbol-entry within GOT, with PLT handling.
3720 ENUM
3721   BFD_RELOC_390_GOTPLT32
3722 ENUMDOC
3723   32-bit offset to symbol-entry within GOT, with PLT handling.
3724 ENUM
3725   BFD_RELOC_390_GOTPLT64
3726 ENUMDOC
3727   64-bit offset to symbol-entry within GOT, with PLT handling.
3728 ENUM
3729   BFD_RELOC_390_GOTPLTENT
3730 ENUMDOC
3731   32-bit rel. offset to symbol-entry within GOT, with PLT handling.
3732 ENUM
3733   BFD_RELOC_390_PLTOFF16
3734 ENUMDOC
3735   16-bit rel. offset from the GOT to a PLT entry.
3736 ENUM
3737   BFD_RELOC_390_PLTOFF32
3738 ENUMDOC
3739   32-bit rel. offset from the GOT to a PLT entry.
3740 ENUM
3741   BFD_RELOC_390_PLTOFF64
3742 ENUMDOC
3743   64-bit rel. offset from the GOT to a PLT entry.
3744
3745 ENUM
3746   BFD_RELOC_390_TLS_LOAD
3747 ENUMX
3748   BFD_RELOC_390_TLS_GDCALL
3749 ENUMX
3750   BFD_RELOC_390_TLS_LDCALL
3751 ENUMX
3752   BFD_RELOC_390_TLS_GD32
3753 ENUMX
3754   BFD_RELOC_390_TLS_GD64
3755 ENUMX
3756   BFD_RELOC_390_TLS_GOTIE12
3757 ENUMX
3758   BFD_RELOC_390_TLS_GOTIE32
3759 ENUMX
3760   BFD_RELOC_390_TLS_GOTIE64
3761 ENUMX
3762   BFD_RELOC_390_TLS_LDM32
3763 ENUMX
3764   BFD_RELOC_390_TLS_LDM64
3765 ENUMX
3766   BFD_RELOC_390_TLS_IE32
3767 ENUMX
3768   BFD_RELOC_390_TLS_IE64
3769 ENUMX
3770   BFD_RELOC_390_TLS_IEENT
3771 ENUMX
3772   BFD_RELOC_390_TLS_LE32
3773 ENUMX
3774   BFD_RELOC_390_TLS_LE64
3775 ENUMX
3776   BFD_RELOC_390_TLS_LDO32
3777 ENUMX
3778   BFD_RELOC_390_TLS_LDO64
3779 ENUMX
3780   BFD_RELOC_390_TLS_DTPMOD
3781 ENUMX
3782   BFD_RELOC_390_TLS_DTPOFF
3783 ENUMX
3784   BFD_RELOC_390_TLS_TPOFF
3785 ENUMDOC
3786   s390 tls relocations.
3787
3788 ENUM
3789   BFD_RELOC_390_20
3790 ENUMX
3791   BFD_RELOC_390_GOT20
3792 ENUMX
3793   BFD_RELOC_390_GOTPLT20
3794 ENUMX
3795   BFD_RELOC_390_TLS_GOTIE20
3796 ENUMDOC
3797   Long displacement extension.
3798
3799 ENUM
3800   BFD_RELOC_IP2K_FR9
3801 ENUMDOC
3802   Scenix IP2K - 9-bit register number / data address
3803 ENUM
3804   BFD_RELOC_IP2K_BANK
3805 ENUMDOC
3806   Scenix IP2K - 4-bit register/data bank number
3807 ENUM
3808   BFD_RELOC_IP2K_ADDR16CJP
3809 ENUMDOC
3810   Scenix IP2K - low 13 bits of instruction word address
3811 ENUM
3812   BFD_RELOC_IP2K_PAGE3
3813 ENUMDOC
3814   Scenix IP2K - high 3 bits of instruction word address
3815 ENUM
3816   BFD_RELOC_IP2K_LO8DATA
3817 ENUMX
3818   BFD_RELOC_IP2K_HI8DATA
3819 ENUMX
3820   BFD_RELOC_IP2K_EX8DATA
3821 ENUMDOC
3822   Scenix IP2K - ext/low/high 8 bits of data address
3823 ENUM
3824   BFD_RELOC_IP2K_LO8INSN
3825 ENUMX
3826   BFD_RELOC_IP2K_HI8INSN
3827 ENUMDOC
3828   Scenix IP2K - low/high 8 bits of instruction word address
3829 ENUM
3830   BFD_RELOC_IP2K_PC_SKIP
3831 ENUMDOC
3832   Scenix IP2K - even/odd PC modifier to modify snb pcl.0
3833 ENUM
3834   BFD_RELOC_IP2K_TEXT
3835 ENUMDOC
3836   Scenix IP2K - 16 bit word address in text section.
3837 ENUM
3838   BFD_RELOC_IP2K_FR_OFFSET
3839 ENUMDOC
3840   Scenix IP2K - 7-bit sp or dp offset
3841 ENUM
3842   BFD_RELOC_VPE4KMATH_DATA
3843 ENUMX
3844   BFD_RELOC_VPE4KMATH_INSN
3845 ENUMDOC
3846   Scenix VPE4K coprocessor - data/insn-space addressing
3847
3848 ENUM
3849   BFD_RELOC_VTABLE_INHERIT
3850 ENUMX
3851   BFD_RELOC_VTABLE_ENTRY
3852 ENUMDOC
3853   These two relocations are used by the linker to determine which of
3854   the entries in a C++ virtual function table are actually used.  When
3855   the --gc-sections option is given, the linker will zero out the entries
3856   that are not used, so that the code for those functions need not be
3857   included in the output.
3858
3859   VTABLE_INHERIT is a zero-space relocation used to describe to the
3860   linker the inheritance tree of a C++ virtual function table.  The
3861   relocation's symbol should be the parent class' vtable, and the
3862   relocation should be located at the child vtable.
3863
3864   VTABLE_ENTRY is a zero-space relocation that describes the use of a
3865   virtual function table entry.  The reloc's symbol should refer to the
3866   table of the class mentioned in the code.  Off of that base, an offset
3867   describes the entry that is being used.  For Rela hosts, this offset
3868   is stored in the reloc's addend.  For Rel hosts, we are forced to put
3869   this offset in the reloc's section offset.
3870
3871 ENUM
3872   BFD_RELOC_IA64_IMM14
3873 ENUMX
3874   BFD_RELOC_IA64_IMM22
3875 ENUMX
3876   BFD_RELOC_IA64_IMM64
3877 ENUMX
3878   BFD_RELOC_IA64_DIR32MSB
3879 ENUMX
3880   BFD_RELOC_IA64_DIR32LSB
3881 ENUMX
3882   BFD_RELOC_IA64_DIR64MSB
3883 ENUMX
3884   BFD_RELOC_IA64_DIR64LSB
3885 ENUMX
3886   BFD_RELOC_IA64_GPREL22
3887 ENUMX
3888   BFD_RELOC_IA64_GPREL64I
3889 ENUMX
3890   BFD_RELOC_IA64_GPREL32MSB
3891 ENUMX
3892   BFD_RELOC_IA64_GPREL32LSB
3893 ENUMX
3894   BFD_RELOC_IA64_GPREL64MSB
3895 ENUMX
3896   BFD_RELOC_IA64_GPREL64LSB
3897 ENUMX
3898   BFD_RELOC_IA64_LTOFF22
3899 ENUMX
3900   BFD_RELOC_IA64_LTOFF64I
3901 ENUMX
3902   BFD_RELOC_IA64_PLTOFF22
3903 ENUMX
3904   BFD_RELOC_IA64_PLTOFF64I
3905 ENUMX
3906   BFD_RELOC_IA64_PLTOFF64MSB
3907 ENUMX
3908   BFD_RELOC_IA64_PLTOFF64LSB
3909 ENUMX
3910   BFD_RELOC_IA64_FPTR64I
3911 ENUMX
3912   BFD_RELOC_IA64_FPTR32MSB
3913 ENUMX
3914   BFD_RELOC_IA64_FPTR32LSB
3915 ENUMX
3916   BFD_RELOC_IA64_FPTR64MSB
3917 ENUMX
3918   BFD_RELOC_IA64_FPTR64LSB
3919 ENUMX
3920   BFD_RELOC_IA64_PCREL21B
3921 ENUMX
3922   BFD_RELOC_IA64_PCREL21BI
3923 ENUMX
3924   BFD_RELOC_IA64_PCREL21M
3925 ENUMX
3926   BFD_RELOC_IA64_PCREL21F
3927 ENUMX
3928   BFD_RELOC_IA64_PCREL22
3929 ENUMX
3930   BFD_RELOC_IA64_PCREL60B
3931 ENUMX
3932   BFD_RELOC_IA64_PCREL64I
3933 ENUMX
3934   BFD_RELOC_IA64_PCREL32MSB
3935 ENUMX
3936   BFD_RELOC_IA64_PCREL32LSB
3937 ENUMX
3938   BFD_RELOC_IA64_PCREL64MSB
3939 ENUMX
3940   BFD_RELOC_IA64_PCREL64LSB
3941 ENUMX
3942   BFD_RELOC_IA64_LTOFF_FPTR22
3943 ENUMX
3944   BFD_RELOC_IA64_LTOFF_FPTR64I
3945 ENUMX
3946   BFD_RELOC_IA64_LTOFF_FPTR32MSB
3947 ENUMX
3948   BFD_RELOC_IA64_LTOFF_FPTR32LSB
3949 ENUMX
3950   BFD_RELOC_IA64_LTOFF_FPTR64MSB
3951 ENUMX
3952   BFD_RELOC_IA64_LTOFF_FPTR64LSB
3953 ENUMX
3954   BFD_RELOC_IA64_SEGREL32MSB
3955 ENUMX
3956   BFD_RELOC_IA64_SEGREL32LSB
3957 ENUMX
3958   BFD_RELOC_IA64_SEGREL64MSB
3959 ENUMX
3960   BFD_RELOC_IA64_SEGREL64LSB
3961 ENUMX
3962   BFD_RELOC_IA64_SECREL32MSB
3963 ENUMX
3964   BFD_RELOC_IA64_SECREL32LSB
3965 ENUMX
3966   BFD_RELOC_IA64_SECREL64MSB
3967 ENUMX
3968   BFD_RELOC_IA64_SECREL64LSB
3969 ENUMX
3970   BFD_RELOC_IA64_REL32MSB
3971 ENUMX
3972   BFD_RELOC_IA64_REL32LSB
3973 ENUMX
3974   BFD_RELOC_IA64_REL64MSB
3975 ENUMX
3976   BFD_RELOC_IA64_REL64LSB
3977 ENUMX
3978   BFD_RELOC_IA64_LTV32MSB
3979 ENUMX
3980   BFD_RELOC_IA64_LTV32LSB
3981 ENUMX
3982   BFD_RELOC_IA64_LTV64MSB
3983 ENUMX
3984   BFD_RELOC_IA64_LTV64LSB
3985 ENUMX
3986   BFD_RELOC_IA64_IPLTMSB
3987 ENUMX
3988   BFD_RELOC_IA64_IPLTLSB
3989 ENUMX
3990   BFD_RELOC_IA64_COPY
3991 ENUMX
3992   BFD_RELOC_IA64_LTOFF22X
3993 ENUMX
3994   BFD_RELOC_IA64_LDXMOV
3995 ENUMX
3996   BFD_RELOC_IA64_TPREL14
3997 ENUMX
3998   BFD_RELOC_IA64_TPREL22
3999 ENUMX
4000   BFD_RELOC_IA64_TPREL64I
4001 ENUMX
4002   BFD_RELOC_IA64_TPREL64MSB
4003 ENUMX
4004   BFD_RELOC_IA64_TPREL64LSB
4005 ENUMX
4006   BFD_RELOC_IA64_LTOFF_TPREL22
4007 ENUMX
4008   BFD_RELOC_IA64_DTPMOD64MSB
4009 ENUMX
4010   BFD_RELOC_IA64_DTPMOD64LSB
4011 ENUMX
4012   BFD_RELOC_IA64_LTOFF_DTPMOD22
4013 ENUMX
4014   BFD_RELOC_IA64_DTPREL14
4015 ENUMX
4016   BFD_RELOC_IA64_DTPREL22
4017 ENUMX
4018   BFD_RELOC_IA64_DTPREL64I
4019 ENUMX
4020   BFD_RELOC_IA64_DTPREL32MSB
4021 ENUMX
4022   BFD_RELOC_IA64_DTPREL32LSB
4023 ENUMX
4024   BFD_RELOC_IA64_DTPREL64MSB
4025 ENUMX
4026   BFD_RELOC_IA64_DTPREL64LSB
4027 ENUMX
4028   BFD_RELOC_IA64_LTOFF_DTPREL22
4029 ENUMDOC
4030   Intel IA64 Relocations.
4031
4032 ENUM
4033   BFD_RELOC_M68HC11_HI8
4034 ENUMDOC
4035   Motorola 68HC11 reloc.
4036   This is the 8 bit high part of an absolute address.
4037 ENUM
4038   BFD_RELOC_M68HC11_LO8
4039 ENUMDOC
4040   Motorola 68HC11 reloc.
4041   This is the 8 bit low part of an absolute address.
4042 ENUM
4043   BFD_RELOC_M68HC11_3B
4044 ENUMDOC
4045   Motorola 68HC11 reloc.
4046   This is the 3 bit of a value.
4047 ENUM
4048   BFD_RELOC_M68HC11_RL_JUMP
4049 ENUMDOC
4050   Motorola 68HC11 reloc.
4051   This reloc marks the beginning of a jump/call instruction.
4052   It is used for linker relaxation to correctly identify beginning
4053   of instruction and change some branches to use PC-relative
4054   addressing mode.
4055 ENUM
4056   BFD_RELOC_M68HC11_RL_GROUP
4057 ENUMDOC
4058   Motorola 68HC11 reloc.
4059   This reloc marks a group of several instructions that gcc generates
4060   and for which the linker relaxation pass can modify and/or remove
4061   some of them.
4062 ENUM
4063   BFD_RELOC_M68HC11_LO16
4064 ENUMDOC
4065   Motorola 68HC11 reloc.
4066   This is the 16-bit lower part of an address.  It is used for 'call'
4067   instruction to specify the symbol address without any special
4068   transformation (due to memory bank window).
4069 ENUM
4070   BFD_RELOC_M68HC11_PAGE
4071 ENUMDOC
4072   Motorola 68HC11 reloc.
4073   This is a 8-bit reloc that specifies the page number of an address.
4074   It is used by 'call' instruction to specify the page number of
4075   the symbol.
4076 ENUM
4077   BFD_RELOC_M68HC11_24
4078 ENUMDOC
4079   Motorola 68HC11 reloc.
4080   This is a 24-bit reloc that represents the address with a 16-bit
4081   value and a 8-bit page number.  The symbol address is transformed
4082   to follow the 16K memory bank of 68HC12 (seen as mapped in the window).
4083 ENUM
4084   BFD_RELOC_M68HC12_5B
4085 ENUMDOC
4086   Motorola 68HC12 reloc.
4087   This is the 5 bits of a value.
4088
4089 ENUM
4090   BFD_RELOC_16C_NUM08
4091 ENUMX
4092   BFD_RELOC_16C_NUM08_C
4093 ENUMX
4094   BFD_RELOC_16C_NUM16
4095 ENUMX
4096   BFD_RELOC_16C_NUM16_C
4097 ENUMX
4098   BFD_RELOC_16C_NUM32
4099 ENUMX
4100   BFD_RELOC_16C_NUM32_C
4101 ENUMX
4102   BFD_RELOC_16C_DISP04
4103 ENUMX
4104   BFD_RELOC_16C_DISP04_C
4105 ENUMX
4106   BFD_RELOC_16C_DISP08
4107 ENUMX
4108   BFD_RELOC_16C_DISP08_C
4109 ENUMX
4110   BFD_RELOC_16C_DISP16
4111 ENUMX
4112   BFD_RELOC_16C_DISP16_C
4113 ENUMX
4114   BFD_RELOC_16C_DISP24
4115 ENUMX
4116   BFD_RELOC_16C_DISP24_C
4117 ENUMX
4118   BFD_RELOC_16C_DISP24a
4119 ENUMX
4120   BFD_RELOC_16C_DISP24a_C
4121 ENUMX
4122   BFD_RELOC_16C_REG04
4123 ENUMX
4124   BFD_RELOC_16C_REG04_C
4125 ENUMX
4126   BFD_RELOC_16C_REG04a
4127 ENUMX
4128   BFD_RELOC_16C_REG04a_C
4129 ENUMX
4130   BFD_RELOC_16C_REG14
4131 ENUMX
4132   BFD_RELOC_16C_REG14_C
4133 ENUMX
4134   BFD_RELOC_16C_REG16
4135 ENUMX
4136   BFD_RELOC_16C_REG16_C
4137 ENUMX
4138   BFD_RELOC_16C_REG20
4139 ENUMX
4140   BFD_RELOC_16C_REG20_C
4141 ENUMX
4142   BFD_RELOC_16C_ABS20
4143 ENUMX
4144   BFD_RELOC_16C_ABS20_C
4145 ENUMX
4146   BFD_RELOC_16C_ABS24
4147 ENUMX
4148   BFD_RELOC_16C_ABS24_C
4149 ENUMX
4150   BFD_RELOC_16C_IMM04
4151 ENUMX
4152   BFD_RELOC_16C_IMM04_C
4153 ENUMX
4154   BFD_RELOC_16C_IMM16
4155 ENUMX
4156   BFD_RELOC_16C_IMM16_C
4157 ENUMX
4158   BFD_RELOC_16C_IMM20
4159 ENUMX
4160   BFD_RELOC_16C_IMM20_C
4161 ENUMX
4162   BFD_RELOC_16C_IMM24
4163 ENUMX
4164   BFD_RELOC_16C_IMM24_C
4165 ENUMX
4166   BFD_RELOC_16C_IMM32
4167 ENUMX
4168   BFD_RELOC_16C_IMM32_C
4169 ENUMDOC
4170   NS CR16C Relocations.
4171
4172 ENUM
4173   BFD_RELOC_CRX_REL4
4174 ENUMX
4175   BFD_RELOC_CRX_REL8
4176 ENUMX
4177   BFD_RELOC_CRX_REL8_CMP
4178 ENUMX
4179   BFD_RELOC_CRX_REL16
4180 ENUMX
4181   BFD_RELOC_CRX_REL24
4182 ENUMX
4183   BFD_RELOC_CRX_REL32
4184 ENUMX
4185   BFD_RELOC_CRX_REGREL12
4186 ENUMX
4187   BFD_RELOC_CRX_REGREL22
4188 ENUMX
4189   BFD_RELOC_CRX_REGREL28
4190 ENUMX
4191   BFD_RELOC_CRX_REGREL32
4192 ENUMX
4193   BFD_RELOC_CRX_ABS16
4194 ENUMX
4195   BFD_RELOC_CRX_ABS32
4196 ENUMX
4197   BFD_RELOC_CRX_NUM8
4198 ENUMX
4199   BFD_RELOC_CRX_NUM16
4200 ENUMX
4201   BFD_RELOC_CRX_NUM32
4202 ENUMX
4203   BFD_RELOC_CRX_IMM16
4204 ENUMX
4205   BFD_RELOC_CRX_IMM32
4206 ENUMX
4207   BFD_RELOC_CRX_SWITCH8
4208 ENUMX
4209   BFD_RELOC_CRX_SWITCH16
4210 ENUMX
4211   BFD_RELOC_CRX_SWITCH32
4212 ENUMDOC 
4213   NS CRX Relocations.
4214
4215 ENUM
4216   BFD_RELOC_CRIS_BDISP8
4217 ENUMX
4218   BFD_RELOC_CRIS_UNSIGNED_5
4219 ENUMX
4220   BFD_RELOC_CRIS_SIGNED_6
4221 ENUMX
4222   BFD_RELOC_CRIS_UNSIGNED_6
4223 ENUMX
4224   BFD_RELOC_CRIS_SIGNED_8
4225 ENUMX
4226   BFD_RELOC_CRIS_UNSIGNED_8
4227 ENUMX
4228   BFD_RELOC_CRIS_SIGNED_16
4229 ENUMX
4230   BFD_RELOC_CRIS_UNSIGNED_16
4231 ENUMX
4232   BFD_RELOC_CRIS_LAPCQ_OFFSET
4233 ENUMX
4234   BFD_RELOC_CRIS_UNSIGNED_4
4235 ENUMDOC
4236   These relocs are only used within the CRIS assembler.  They are not
4237   (at present) written to any object files.
4238 ENUM
4239   BFD_RELOC_CRIS_COPY
4240 ENUMX
4241   BFD_RELOC_CRIS_GLOB_DAT
4242 ENUMX
4243   BFD_RELOC_CRIS_JUMP_SLOT
4244 ENUMX
4245   BFD_RELOC_CRIS_RELATIVE
4246 ENUMDOC
4247   Relocs used in ELF shared libraries for CRIS.
4248 ENUM
4249   BFD_RELOC_CRIS_32_GOT
4250 ENUMDOC
4251   32-bit offset to symbol-entry within GOT.
4252 ENUM
4253   BFD_RELOC_CRIS_16_GOT
4254 ENUMDOC
4255   16-bit offset to symbol-entry within GOT.
4256 ENUM
4257   BFD_RELOC_CRIS_32_GOTPLT
4258 ENUMDOC
4259   32-bit offset to symbol-entry within GOT, with PLT handling.
4260 ENUM
4261   BFD_RELOC_CRIS_16_GOTPLT
4262 ENUMDOC
4263   16-bit offset to symbol-entry within GOT, with PLT handling.
4264 ENUM
4265   BFD_RELOC_CRIS_32_GOTREL
4266 ENUMDOC
4267   32-bit offset to symbol, relative to GOT.
4268 ENUM
4269   BFD_RELOC_CRIS_32_PLT_GOTREL
4270 ENUMDOC
4271   32-bit offset to symbol with PLT entry, relative to GOT.
4272 ENUM
4273   BFD_RELOC_CRIS_32_PLT_PCREL
4274 ENUMDOC
4275   32-bit offset to symbol with PLT entry, relative to this relocation.
4276
4277 ENUM
4278   BFD_RELOC_860_COPY
4279 ENUMX
4280   BFD_RELOC_860_GLOB_DAT
4281 ENUMX
4282   BFD_RELOC_860_JUMP_SLOT
4283 ENUMX
4284   BFD_RELOC_860_RELATIVE
4285 ENUMX
4286   BFD_RELOC_860_PC26
4287 ENUMX
4288   BFD_RELOC_860_PLT26
4289 ENUMX
4290   BFD_RELOC_860_PC16
4291 ENUMX
4292   BFD_RELOC_860_LOW0
4293 ENUMX
4294   BFD_RELOC_860_SPLIT0
4295 ENUMX
4296   BFD_RELOC_860_LOW1
4297 ENUMX
4298   BFD_RELOC_860_SPLIT1
4299 ENUMX
4300   BFD_RELOC_860_LOW2
4301 ENUMX
4302   BFD_RELOC_860_SPLIT2
4303 ENUMX
4304   BFD_RELOC_860_LOW3
4305 ENUMX
4306   BFD_RELOC_860_LOGOT0
4307 ENUMX
4308   BFD_RELOC_860_SPGOT0
4309 ENUMX
4310   BFD_RELOC_860_LOGOT1
4311 ENUMX
4312   BFD_RELOC_860_SPGOT1
4313 ENUMX
4314   BFD_RELOC_860_LOGOTOFF0
4315 ENUMX
4316   BFD_RELOC_860_SPGOTOFF0
4317 ENUMX
4318   BFD_RELOC_860_LOGOTOFF1
4319 ENUMX
4320   BFD_RELOC_860_SPGOTOFF1
4321 ENUMX
4322   BFD_RELOC_860_LOGOTOFF2
4323 ENUMX
4324   BFD_RELOC_860_LOGOTOFF3
4325 ENUMX
4326   BFD_RELOC_860_LOPC
4327 ENUMX
4328   BFD_RELOC_860_HIGHADJ
4329 ENUMX
4330   BFD_RELOC_860_HAGOT
4331 ENUMX
4332   BFD_RELOC_860_HAGOTOFF
4333 ENUMX
4334   BFD_RELOC_860_HAPC
4335 ENUMX
4336   BFD_RELOC_860_HIGH
4337 ENUMX
4338   BFD_RELOC_860_HIGOT
4339 ENUMX
4340   BFD_RELOC_860_HIGOTOFF
4341 ENUMDOC
4342   Intel i860 Relocations.
4343
4344 ENUM
4345   BFD_RELOC_OPENRISC_ABS_26
4346 ENUMX
4347   BFD_RELOC_OPENRISC_REL_26
4348 ENUMDOC
4349   OpenRISC Relocations.
4350
4351 ENUM
4352   BFD_RELOC_H8_DIR16A8
4353 ENUMX
4354   BFD_RELOC_H8_DIR16R8
4355 ENUMX
4356   BFD_RELOC_H8_DIR24A8
4357 ENUMX
4358   BFD_RELOC_H8_DIR24R8
4359 ENUMX
4360   BFD_RELOC_H8_DIR32A16
4361 ENUMDOC
4362   H8 elf Relocations.
4363
4364 ENUM
4365   BFD_RELOC_XSTORMY16_REL_12
4366 ENUMX
4367   BFD_RELOC_XSTORMY16_12
4368 ENUMX
4369   BFD_RELOC_XSTORMY16_24
4370 ENUMX
4371   BFD_RELOC_XSTORMY16_FPTR16
4372 ENUMDOC
4373   Sony Xstormy16 Relocations.
4374
4375 ENUM
4376   BFD_RELOC_VAX_GLOB_DAT
4377 ENUMX
4378   BFD_RELOC_VAX_JMP_SLOT
4379 ENUMX
4380   BFD_RELOC_VAX_RELATIVE
4381 ENUMDOC
4382   Relocations used by VAX ELF.
4383   
4384 ENUM
4385   BFD_RELOC_MT_PC16
4386 ENUMDOC
4387   Morpho MT - 16 bit immediate relocation. 
4388 ENUM
4389   BFD_RELOC_MT_HI16
4390 ENUMDOC
4391   Morpho MT - Hi 16 bits of an address. 
4392 ENUM
4393   BFD_RELOC_MT_LO16
4394 ENUMDOC
4395   Morpho MT - Low 16 bits of an address. 
4396 ENUM
4397   BFD_RELOC_MT_GNU_VTINHERIT
4398 ENUMDOC
4399   Morpho MT - Used to tell the linker which vtable entries are used.
4400 ENUM
4401   BFD_RELOC_MT_GNU_VTENTRY
4402 ENUMDOC
4403   Morpho MT - Used to tell the linker which vtable entries are used.
4404 ENUM
4405   BFD_RELOC_MT_PCINSN8
4406 ENUMDOC
4407   Morpho MT - 8 bit immediate relocation. 
4408
4409 ENUM
4410   BFD_RELOC_MSP430_10_PCREL
4411 ENUMX
4412   BFD_RELOC_MSP430_16_PCREL
4413 ENUMX
4414   BFD_RELOC_MSP430_16
4415 ENUMX
4416   BFD_RELOC_MSP430_16_PCREL_BYTE
4417 ENUMX
4418   BFD_RELOC_MSP430_16_BYTE
4419 ENUMX
4420   BFD_RELOC_MSP430_2X_PCREL
4421 ENUMX
4422   BFD_RELOC_MSP430_RL_PCREL
4423 ENUMDOC
4424   msp430 specific relocation codes
4425
4426 ENUM
4427   BFD_RELOC_IQ2000_OFFSET_16
4428 ENUMX
4429   BFD_RELOC_IQ2000_OFFSET_21
4430 ENUMX
4431   BFD_RELOC_IQ2000_UHI16
4432 ENUMDOC
4433   IQ2000 Relocations.
4434
4435 ENUM
4436   BFD_RELOC_XTENSA_RTLD
4437 ENUMDOC
4438   Special Xtensa relocation used only by PLT entries in ELF shared
4439   objects to indicate that the runtime linker should set the value
4440   to one of its own internal functions or data structures.
4441 ENUM
4442   BFD_RELOC_XTENSA_GLOB_DAT
4443 ENUMX
4444   BFD_RELOC_XTENSA_JMP_SLOT
4445 ENUMX
4446   BFD_RELOC_XTENSA_RELATIVE
4447 ENUMDOC
4448   Xtensa relocations for ELF shared objects.
4449 ENUM
4450   BFD_RELOC_XTENSA_PLT
4451 ENUMDOC
4452   Xtensa relocation used in ELF object files for symbols that may require
4453   PLT entries.  Otherwise, this is just a generic 32-bit relocation.
4454 ENUM
4455   BFD_RELOC_XTENSA_DIFF8
4456 ENUMX
4457   BFD_RELOC_XTENSA_DIFF16
4458 ENUMX
4459   BFD_RELOC_XTENSA_DIFF32
4460 ENUMDOC
4461   Xtensa relocations to mark the difference of two local symbols.
4462   These are only needed to support linker relaxation and can be ignored
4463   when not relaxing.  The field is set to the value of the difference
4464   assuming no relaxation.  The relocation encodes the position of the
4465   first symbol so the linker can determine whether to adjust the field
4466   value.
4467 ENUM
4468   BFD_RELOC_XTENSA_SLOT0_OP
4469 ENUMX
4470   BFD_RELOC_XTENSA_SLOT1_OP
4471 ENUMX
4472   BFD_RELOC_XTENSA_SLOT2_OP
4473 ENUMX
4474   BFD_RELOC_XTENSA_SLOT3_OP
4475 ENUMX
4476   BFD_RELOC_XTENSA_SLOT4_OP
4477 ENUMX
4478   BFD_RELOC_XTENSA_SLOT5_OP
4479 ENUMX
4480   BFD_RELOC_XTENSA_SLOT6_OP
4481 ENUMX
4482   BFD_RELOC_XTENSA_SLOT7_OP
4483 ENUMX
4484   BFD_RELOC_XTENSA_SLOT8_OP
4485 ENUMX
4486   BFD_RELOC_XTENSA_SLOT9_OP
4487 ENUMX
4488   BFD_RELOC_XTENSA_SLOT10_OP
4489 ENUMX
4490   BFD_RELOC_XTENSA_SLOT11_OP
4491 ENUMX
4492   BFD_RELOC_XTENSA_SLOT12_OP
4493 ENUMX
4494   BFD_RELOC_XTENSA_SLOT13_OP
4495 ENUMX
4496   BFD_RELOC_XTENSA_SLOT14_OP
4497 ENUMDOC
4498   Generic Xtensa relocations for instruction operands.  Only the slot
4499   number is encoded in the relocation.  The relocation applies to the
4500   last PC-relative immediate operand, or if there are no PC-relative
4501   immediates, to the last immediate operand.
4502 ENUM
4503   BFD_RELOC_XTENSA_SLOT0_ALT
4504 ENUMX
4505   BFD_RELOC_XTENSA_SLOT1_ALT
4506 ENUMX
4507   BFD_RELOC_XTENSA_SLOT2_ALT
4508 ENUMX
4509   BFD_RELOC_XTENSA_SLOT3_ALT
4510 ENUMX
4511   BFD_RELOC_XTENSA_SLOT4_ALT
4512 ENUMX
4513   BFD_RELOC_XTENSA_SLOT5_ALT
4514 ENUMX
4515   BFD_RELOC_XTENSA_SLOT6_ALT
4516 ENUMX
4517   BFD_RELOC_XTENSA_SLOT7_ALT
4518 ENUMX
4519   BFD_RELOC_XTENSA_SLOT8_ALT
4520 ENUMX
4521   BFD_RELOC_XTENSA_SLOT9_ALT
4522 ENUMX
4523   BFD_RELOC_XTENSA_SLOT10_ALT
4524 ENUMX
4525   BFD_RELOC_XTENSA_SLOT11_ALT
4526 ENUMX
4527   BFD_RELOC_XTENSA_SLOT12_ALT
4528 ENUMX
4529   BFD_RELOC_XTENSA_SLOT13_ALT
4530 ENUMX
4531   BFD_RELOC_XTENSA_SLOT14_ALT
4532 ENUMDOC
4533   Alternate Xtensa relocations.  Only the slot is encoded in the
4534   relocation.  The meaning of these relocations is opcode-specific.
4535 ENUM
4536   BFD_RELOC_XTENSA_OP0
4537 ENUMX
4538   BFD_RELOC_XTENSA_OP1
4539 ENUMX
4540   BFD_RELOC_XTENSA_OP2
4541 ENUMDOC
4542   Xtensa relocations for backward compatibility.  These have all been
4543   replaced by BFD_RELOC_XTENSA_SLOT0_OP.
4544 ENUM
4545   BFD_RELOC_XTENSA_ASM_EXPAND
4546 ENUMDOC
4547   Xtensa relocation to mark that the assembler expanded the 
4548   instructions from an original target.  The expansion size is
4549   encoded in the reloc size.
4550 ENUM
4551   BFD_RELOC_XTENSA_ASM_SIMPLIFY
4552 ENUMDOC
4553   Xtensa relocation to mark that the linker should simplify 
4554   assembler-expanded instructions.  This is commonly used 
4555   internally by the linker after analysis of a 
4556   BFD_RELOC_XTENSA_ASM_EXPAND.
4557
4558 ENUM
4559   BFD_RELOC_Z80_DISP8
4560 ENUMDOC
4561   8 bit signed offset in (ix+d) or (iy+d).
4562
4563 ENUM
4564   BFD_RELOC_Z8K_DISP7
4565 ENUMDOC
4566   DJNZ offset.
4567 ENUM
4568   BFD_RELOC_Z8K_CALLR
4569 ENUMDOC
4570   CALR offset.
4571 ENUM
4572   BFD_RELOC_Z8K_IMM4L
4573 ENUMDOC
4574   4 bit value.
4575
4576 ENDSENUM
4577   BFD_RELOC_UNUSED
4578 CODE_FRAGMENT
4579 .
4580 .typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
4581 */
4582
4583 /*
4584 FUNCTION
4585         bfd_reloc_type_lookup
4586
4587 SYNOPSIS
4588         reloc_howto_type *bfd_reloc_type_lookup
4589           (bfd *abfd, bfd_reloc_code_real_type code);
4590
4591 DESCRIPTION
4592         Return a pointer to a howto structure which, when
4593         invoked, will perform the relocation @var{code} on data from the
4594         architecture noted.
4595
4596 */
4597
4598 reloc_howto_type *
4599 bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code)
4600 {
4601   return BFD_SEND (abfd, reloc_type_lookup, (abfd, code));
4602 }
4603
4604 static reloc_howto_type bfd_howto_32 =
4605 HOWTO (0, 00, 2, 32, FALSE, 0, complain_overflow_dont, 0, "VRT32", FALSE, 0xffffffff, 0xffffffff, TRUE);
4606
4607 /*
4608 INTERNAL_FUNCTION
4609         bfd_default_reloc_type_lookup
4610
4611 SYNOPSIS
4612         reloc_howto_type *bfd_default_reloc_type_lookup
4613           (bfd *abfd, bfd_reloc_code_real_type  code);
4614
4615 DESCRIPTION
4616         Provides a default relocation lookup routine for any architecture.
4617
4618 */
4619
4620 reloc_howto_type *
4621 bfd_default_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code)
4622 {
4623   switch (code)
4624     {
4625     case BFD_RELOC_CTOR:
4626       /* The type of reloc used in a ctor, which will be as wide as the
4627          address - so either a 64, 32, or 16 bitter.  */
4628       switch (bfd_get_arch_info (abfd)->bits_per_address)
4629         {
4630         case 64:
4631           BFD_FAIL ();
4632         case 32:
4633           return &bfd_howto_32;
4634         case 16:
4635           BFD_FAIL ();
4636         default:
4637           BFD_FAIL ();
4638         }
4639     default:
4640       BFD_FAIL ();
4641     }
4642   return NULL;
4643 }
4644
4645 /*
4646 FUNCTION
4647         bfd_get_reloc_code_name
4648
4649 SYNOPSIS
4650         const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code);
4651
4652 DESCRIPTION
4653         Provides a printable name for the supplied relocation code.
4654         Useful mainly for printing error messages.
4655 */
4656
4657 const char *
4658 bfd_get_reloc_code_name (bfd_reloc_code_real_type code)
4659 {
4660   if (code > BFD_RELOC_UNUSED)
4661     return 0;
4662   return bfd_reloc_code_real_names[code];
4663 }
4664
4665 /*
4666 INTERNAL_FUNCTION
4667         bfd_generic_relax_section
4668
4669 SYNOPSIS
4670         bfd_boolean bfd_generic_relax_section
4671           (bfd *abfd,
4672            asection *section,
4673            struct bfd_link_info *,
4674            bfd_boolean *);
4675
4676 DESCRIPTION
4677         Provides default handling for relaxing for back ends which
4678         don't do relaxing.
4679 */
4680
4681 bfd_boolean
4682 bfd_generic_relax_section (bfd *abfd ATTRIBUTE_UNUSED,
4683                            asection *section ATTRIBUTE_UNUSED,
4684                            struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
4685                            bfd_boolean *again)
4686 {
4687   *again = FALSE;
4688   return TRUE;
4689 }
4690
4691 /*
4692 INTERNAL_FUNCTION
4693         bfd_generic_gc_sections
4694
4695 SYNOPSIS
4696         bfd_boolean bfd_generic_gc_sections
4697           (bfd *, struct bfd_link_info *);
4698
4699 DESCRIPTION
4700         Provides default handling for relaxing for back ends which
4701         don't do section gc -- i.e., does nothing.
4702 */
4703
4704 bfd_boolean
4705 bfd_generic_gc_sections (bfd *abfd ATTRIBUTE_UNUSED,
4706                          struct bfd_link_info *info ATTRIBUTE_UNUSED)
4707 {
4708   return TRUE;
4709 }
4710
4711 /*
4712 INTERNAL_FUNCTION
4713         bfd_generic_merge_sections
4714
4715 SYNOPSIS
4716         bfd_boolean bfd_generic_merge_sections
4717           (bfd *, struct bfd_link_info *);
4718
4719 DESCRIPTION
4720         Provides default handling for SEC_MERGE section merging for back ends
4721         which don't have SEC_MERGE support -- i.e., does nothing.
4722 */
4723
4724 bfd_boolean
4725 bfd_generic_merge_sections (bfd *abfd ATTRIBUTE_UNUSED,
4726                             struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
4727 {
4728   return TRUE;
4729 }
4730
4731 /*
4732 INTERNAL_FUNCTION
4733         bfd_generic_get_relocated_section_contents
4734
4735 SYNOPSIS
4736         bfd_byte *bfd_generic_get_relocated_section_contents
4737           (bfd *abfd,
4738            struct bfd_link_info *link_info,
4739            struct bfd_link_order *link_order,
4740            bfd_byte *data,
4741            bfd_boolean relocatable,
4742            asymbol **symbols);
4743
4744 DESCRIPTION
4745         Provides default handling of relocation effort for back ends
4746         which can't be bothered to do it efficiently.
4747
4748 */
4749
4750 bfd_byte *
4751 bfd_generic_get_relocated_section_contents (bfd *abfd,
4752                                             struct bfd_link_info *link_info,
4753                                             struct bfd_link_order *link_order,
4754                                             bfd_byte *data,
4755                                             bfd_boolean relocatable,
4756                                             asymbol **symbols)
4757 {
4758   /* Get enough memory to hold the stuff.  */
4759   bfd *input_bfd = link_order->u.indirect.section->owner;
4760   asection *input_section = link_order->u.indirect.section;
4761
4762   long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
4763   arelent **reloc_vector = NULL;
4764   long reloc_count;
4765   bfd_size_type sz;
4766
4767   if (reloc_size < 0)
4768     goto error_return;
4769
4770   reloc_vector = bfd_malloc (reloc_size);
4771   if (reloc_vector == NULL && reloc_size != 0)
4772     goto error_return;
4773
4774   /* Read in the section.  */
4775   sz = input_section->rawsize ? input_section->rawsize : input_section->size;
4776   if (!bfd_get_section_contents (input_bfd, input_section, data, 0, sz))
4777     goto error_return;
4778
4779   reloc_count = bfd_canonicalize_reloc (input_bfd,
4780                                         input_section,
4781                                         reloc_vector,
4782                                         symbols);
4783   if (reloc_count < 0)
4784     goto error_return;
4785
4786   if (reloc_count > 0)
4787     {
4788       arelent **parent;
4789       for (parent = reloc_vector; *parent != NULL; parent++)
4790         {
4791           char *error_message = NULL;
4792           bfd_reloc_status_type r =
4793             bfd_perform_relocation (input_bfd,
4794                                     *parent,
4795                                     data,
4796                                     input_section,
4797                                     relocatable ? abfd : NULL,
4798                                     &error_message);
4799
4800           if (relocatable)
4801             {
4802               asection *os = input_section->output_section;
4803
4804               /* A partial link, so keep the relocs.  */
4805               os->orelocation[os->reloc_count] = *parent;
4806               os->reloc_count++;
4807             }
4808
4809           if (r != bfd_reloc_ok)
4810             {
4811               switch (r)
4812                 {
4813                 case bfd_reloc_undefined:
4814                   if (!((*link_info->callbacks->undefined_symbol)
4815                         (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
4816                          input_bfd, input_section, (*parent)->address,
4817                          TRUE)))
4818                     goto error_return;
4819                   break;
4820                 case bfd_reloc_dangerous:
4821                   BFD_ASSERT (error_message != NULL);
4822                   if (!((*link_info->callbacks->reloc_dangerous)
4823                         (link_info, error_message, input_bfd, input_section,
4824                          (*parent)->address)))
4825                     goto error_return;
4826                   break;
4827                 case bfd_reloc_overflow:
4828                   if (!((*link_info->callbacks->reloc_overflow)
4829                         (link_info, NULL,
4830                          bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
4831                          (*parent)->howto->name, (*parent)->addend,
4832                          input_bfd, input_section, (*parent)->address)))
4833                     goto error_return;
4834                   break;
4835                 case bfd_reloc_outofrange:
4836                 default:
4837                   abort ();
4838                   break;
4839                 }
4840
4841             }
4842         }
4843     }
4844   if (reloc_vector != NULL)
4845     free (reloc_vector);
4846   return data;
4847
4848 error_return:
4849   if (reloc_vector != NULL)
4850     free (reloc_vector);
4851   return NULL;
4852 }