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