1 /* BFD back-end for ALPHA Extended-Coff files.
2 Copyright (C) 1993-2020 Free Software Foundation, Inc.
3 Modified from coff-mips.c by Steve Chamberlain <sac@cygnus.com> and
4 Ian Lance Taylor <ian@cygnus.com>.
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
27 #include "coff/internal.h"
29 #include "coff/symconst.h"
30 #include "coff/ecoff.h"
31 #include "coff/alpha.h"
36 /* Prototypes for static functions. */
40 /* ECOFF has COFF sections, but the debugging information is stored in
41 a completely different format. ECOFF targets use some of the
42 swapping routines from coffswap.h, and some of the generic COFF
43 routines in coffgen.c, but, unlike the real COFF targets, do not
44 use coffcode.h itself.
46 Get the generic COFF swapping routines, except for the reloc,
47 symbol, and lineno ones. Give them ecoff names. Define some
48 accessor macros for the large sizes used for Alpha ECOFF. */
50 #define GET_FILEHDR_SYMPTR H_GET_64
51 #define PUT_FILEHDR_SYMPTR H_PUT_64
52 #define GET_AOUTHDR_TSIZE H_GET_64
53 #define PUT_AOUTHDR_TSIZE H_PUT_64
54 #define GET_AOUTHDR_DSIZE H_GET_64
55 #define PUT_AOUTHDR_DSIZE H_PUT_64
56 #define GET_AOUTHDR_BSIZE H_GET_64
57 #define PUT_AOUTHDR_BSIZE H_PUT_64
58 #define GET_AOUTHDR_ENTRY H_GET_64
59 #define PUT_AOUTHDR_ENTRY H_PUT_64
60 #define GET_AOUTHDR_TEXT_START H_GET_64
61 #define PUT_AOUTHDR_TEXT_START H_PUT_64
62 #define GET_AOUTHDR_DATA_START H_GET_64
63 #define PUT_AOUTHDR_DATA_START H_PUT_64
64 #define GET_SCNHDR_PADDR H_GET_64
65 #define PUT_SCNHDR_PADDR H_PUT_64
66 #define GET_SCNHDR_VADDR H_GET_64
67 #define PUT_SCNHDR_VADDR H_PUT_64
68 #define GET_SCNHDR_SIZE H_GET_64
69 #define PUT_SCNHDR_SIZE H_PUT_64
70 #define GET_SCNHDR_SCNPTR H_GET_64
71 #define PUT_SCNHDR_SCNPTR H_PUT_64
72 #define GET_SCNHDR_RELPTR H_GET_64
73 #define PUT_SCNHDR_RELPTR H_PUT_64
74 #define GET_SCNHDR_LNNOPTR H_GET_64
75 #define PUT_SCNHDR_LNNOPTR H_PUT_64
79 #define NO_COFF_RELOCS
80 #define NO_COFF_SYMBOLS
81 #define NO_COFF_LINENOS
82 #define coff_swap_filehdr_in alpha_ecoff_swap_filehdr_in
83 #define coff_swap_filehdr_out alpha_ecoff_swap_filehdr_out
84 #define coff_swap_aouthdr_in alpha_ecoff_swap_aouthdr_in
85 #define coff_swap_aouthdr_out alpha_ecoff_swap_aouthdr_out
86 #define coff_swap_scnhdr_in alpha_ecoff_swap_scnhdr_in
87 #define coff_swap_scnhdr_out alpha_ecoff_swap_scnhdr_out
90 /* Get the ECOFF swapping routines. */
92 #include "ecoffswap.h"
94 /* How to process the various reloc types. */
96 static bfd_reloc_status_type
97 reloc_nil (bfd
*abfd ATTRIBUTE_UNUSED
,
98 arelent
*reloc ATTRIBUTE_UNUSED
,
99 asymbol
*sym ATTRIBUTE_UNUSED
,
100 void * data ATTRIBUTE_UNUSED
,
101 asection
*sec ATTRIBUTE_UNUSED
,
102 bfd
*output_bfd ATTRIBUTE_UNUSED
,
103 char **error_message ATTRIBUTE_UNUSED
)
108 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
109 from smaller values. Start with zero, widen, *then* decrement. */
110 #define MINUS_ONE (((bfd_vma)0) - 1)
112 static reloc_howto_type alpha_howto_table
[] =
114 /* Reloc type 0 is ignored by itself. However, it appears after a
115 GPDISP reloc to identify the location where the low order 16 bits
116 of the gp register are loaded. */
117 HOWTO (ALPHA_R_IGNORE
, /* type */
119 0, /* size (0 = byte, 1 = short, 2 = long) */
121 TRUE
, /* pc_relative */
123 complain_overflow_dont
, /* complain_on_overflow */
124 reloc_nil
, /* special_function */
126 TRUE
, /* partial_inplace */
129 TRUE
), /* pcrel_offset */
131 /* A 32 bit reference to a symbol. */
132 HOWTO (ALPHA_R_REFLONG
, /* type */
134 2, /* size (0 = byte, 1 = short, 2 = long) */
136 FALSE
, /* pc_relative */
138 complain_overflow_bitfield
, /* complain_on_overflow */
139 0, /* special_function */
140 "REFLONG", /* name */
141 TRUE
, /* partial_inplace */
142 0xffffffff, /* src_mask */
143 0xffffffff, /* dst_mask */
144 FALSE
), /* pcrel_offset */
146 /* A 64 bit reference to a symbol. */
147 HOWTO (ALPHA_R_REFQUAD
, /* type */
149 4, /* size (0 = byte, 1 = short, 2 = long) */
151 FALSE
, /* pc_relative */
153 complain_overflow_bitfield
, /* complain_on_overflow */
154 0, /* special_function */
155 "REFQUAD", /* name */
156 TRUE
, /* partial_inplace */
157 MINUS_ONE
, /* src_mask */
158 MINUS_ONE
, /* dst_mask */
159 FALSE
), /* pcrel_offset */
161 /* A 32 bit GP relative offset. This is just like REFLONG except
162 that when the value is used the value of the gp register will be
164 HOWTO (ALPHA_R_GPREL32
, /* type */
166 2, /* size (0 = byte, 1 = short, 2 = long) */
168 FALSE
, /* pc_relative */
170 complain_overflow_bitfield
, /* complain_on_overflow */
171 0, /* special_function */
172 "GPREL32", /* name */
173 TRUE
, /* partial_inplace */
174 0xffffffff, /* src_mask */
175 0xffffffff, /* dst_mask */
176 FALSE
), /* pcrel_offset */
178 /* Used for an instruction that refers to memory off the GP
179 register. The offset is 16 bits of the 32 bit instruction. This
180 reloc always seems to be against the .lita section. */
181 HOWTO (ALPHA_R_LITERAL
, /* type */
183 2, /* size (0 = byte, 1 = short, 2 = long) */
185 FALSE
, /* pc_relative */
187 complain_overflow_signed
, /* complain_on_overflow */
188 0, /* special_function */
189 "LITERAL", /* name */
190 TRUE
, /* partial_inplace */
191 0xffff, /* src_mask */
192 0xffff, /* dst_mask */
193 FALSE
), /* pcrel_offset */
195 /* This reloc only appears immediately following a LITERAL reloc.
196 It identifies a use of the literal. It seems that the linker can
197 use this to eliminate a portion of the .lita section. The symbol
198 index is special: 1 means the literal address is in the base
199 register of a memory format instruction; 2 means the literal
200 address is in the byte offset register of a byte-manipulation
201 instruction; 3 means the literal address is in the target
202 register of a jsr instruction. This does not actually do any
204 HOWTO (ALPHA_R_LITUSE
, /* type */
206 2, /* size (0 = byte, 1 = short, 2 = long) */
208 FALSE
, /* pc_relative */
210 complain_overflow_dont
, /* complain_on_overflow */
211 reloc_nil
, /* special_function */
213 FALSE
, /* partial_inplace */
216 FALSE
), /* pcrel_offset */
218 /* Load the gp register. This is always used for a ldah instruction
219 which loads the upper 16 bits of the gp register. The next reloc
220 will be an IGNORE reloc which identifies the location of the lda
221 instruction which loads the lower 16 bits. The symbol index of
222 the GPDISP instruction appears to actually be the number of bytes
223 between the ldah and lda instructions. This gives two different
224 ways to determine where the lda instruction is; I don't know why
225 both are used. The value to use for the relocation is the
226 difference between the GP value and the current location; the
227 load will always be done against a register holding the current
229 HOWTO (ALPHA_R_GPDISP
, /* type */
231 2, /* size (0 = byte, 1 = short, 2 = long) */
233 TRUE
, /* pc_relative */
235 complain_overflow_dont
, /* complain_on_overflow */
236 reloc_nil
, /* special_function */
238 TRUE
, /* partial_inplace */
239 0xffff, /* src_mask */
240 0xffff, /* dst_mask */
241 TRUE
), /* pcrel_offset */
243 /* A 21 bit branch. The native assembler generates these for
244 branches within the text segment, and also fills in the PC
245 relative offset in the instruction. */
246 HOWTO (ALPHA_R_BRADDR
, /* type */
248 2, /* size (0 = byte, 1 = short, 2 = long) */
250 TRUE
, /* pc_relative */
252 complain_overflow_signed
, /* complain_on_overflow */
253 0, /* special_function */
255 TRUE
, /* partial_inplace */
256 0x1fffff, /* src_mask */
257 0x1fffff, /* dst_mask */
258 FALSE
), /* pcrel_offset */
260 /* A hint for a jump to a register. */
261 HOWTO (ALPHA_R_HINT
, /* type */
263 2, /* size (0 = byte, 1 = short, 2 = long) */
265 TRUE
, /* pc_relative */
267 complain_overflow_dont
, /* complain_on_overflow */
268 0, /* special_function */
270 TRUE
, /* partial_inplace */
271 0x3fff, /* src_mask */
272 0x3fff, /* dst_mask */
273 FALSE
), /* pcrel_offset */
275 /* 16 bit PC relative offset. */
276 HOWTO (ALPHA_R_SREL16
, /* type */
278 1, /* size (0 = byte, 1 = short, 2 = long) */
280 TRUE
, /* pc_relative */
282 complain_overflow_signed
, /* complain_on_overflow */
283 0, /* special_function */
285 TRUE
, /* partial_inplace */
286 0xffff, /* src_mask */
287 0xffff, /* dst_mask */
288 FALSE
), /* pcrel_offset */
290 /* 32 bit PC relative offset. */
291 HOWTO (ALPHA_R_SREL32
, /* type */
293 2, /* size (0 = byte, 1 = short, 2 = long) */
295 TRUE
, /* pc_relative */
297 complain_overflow_signed
, /* complain_on_overflow */
298 0, /* special_function */
300 TRUE
, /* partial_inplace */
301 0xffffffff, /* src_mask */
302 0xffffffff, /* dst_mask */
303 FALSE
), /* pcrel_offset */
305 /* A 64 bit PC relative offset. */
306 HOWTO (ALPHA_R_SREL64
, /* type */
308 4, /* size (0 = byte, 1 = short, 2 = long) */
310 TRUE
, /* pc_relative */
312 complain_overflow_signed
, /* complain_on_overflow */
313 0, /* special_function */
315 TRUE
, /* partial_inplace */
316 MINUS_ONE
, /* src_mask */
317 MINUS_ONE
, /* dst_mask */
318 FALSE
), /* pcrel_offset */
320 /* Push a value on the reloc evaluation stack. */
321 HOWTO (ALPHA_R_OP_PUSH
, /* type */
323 0, /* size (0 = byte, 1 = short, 2 = long) */
325 FALSE
, /* pc_relative */
327 complain_overflow_dont
, /* complain_on_overflow */
328 0, /* special_function */
329 "OP_PUSH", /* name */
330 FALSE
, /* partial_inplace */
333 FALSE
), /* pcrel_offset */
335 /* Store the value from the stack at the given address. Store it in
336 a bitfield of size r_size starting at bit position r_offset. */
337 HOWTO (ALPHA_R_OP_STORE
, /* type */
339 4, /* size (0 = byte, 1 = short, 2 = long) */
341 FALSE
, /* pc_relative */
343 complain_overflow_dont
, /* complain_on_overflow */
344 0, /* special_function */
345 "OP_STORE", /* name */
346 FALSE
, /* partial_inplace */
348 MINUS_ONE
, /* dst_mask */
349 FALSE
), /* pcrel_offset */
351 /* Subtract the reloc address from the value on the top of the
353 HOWTO (ALPHA_R_OP_PSUB
, /* type */
355 0, /* size (0 = byte, 1 = short, 2 = long) */
357 FALSE
, /* pc_relative */
359 complain_overflow_dont
, /* complain_on_overflow */
360 0, /* special_function */
361 "OP_PSUB", /* name */
362 FALSE
, /* partial_inplace */
365 FALSE
), /* pcrel_offset */
367 /* Shift the value on the top of the relocation stack right by the
369 HOWTO (ALPHA_R_OP_PRSHIFT
, /* type */
371 0, /* size (0 = byte, 1 = short, 2 = long) */
373 FALSE
, /* pc_relative */
375 complain_overflow_dont
, /* complain_on_overflow */
376 0, /* special_function */
377 "OP_PRSHIFT", /* name */
378 FALSE
, /* partial_inplace */
381 FALSE
), /* pcrel_offset */
383 /* Adjust the GP value for a new range in the object file. */
384 HOWTO (ALPHA_R_GPVALUE
, /* type */
386 0, /* size (0 = byte, 1 = short, 2 = long) */
388 FALSE
, /* pc_relative */
390 complain_overflow_dont
, /* complain_on_overflow */
391 0, /* special_function */
392 "GPVALUE", /* name */
393 FALSE
, /* partial_inplace */
396 FALSE
) /* pcrel_offset */
399 /* Recognize an Alpha ECOFF file. */
402 alpha_ecoff_object_p (bfd
*abfd
)
406 ret
= coff_object_p (abfd
);
412 /* Alpha ECOFF has a .pdata section. The lnnoptr field of the
413 .pdata section is the number of entries it contains. Each
414 entry takes up 8 bytes. The number of entries is required
415 since the section is aligned to a 16 byte boundary. When we
416 link .pdata sections together, we do not want to include the
417 alignment bytes. We handle this on input by faking the size
418 of the .pdata section to remove the unwanted alignment bytes.
419 On output we will set the lnnoptr field and force the
421 sec
= bfd_get_section_by_name (abfd
, _PDATA
);
422 if (sec
!= (asection
*) NULL
)
426 size
= (bfd_size_type
) sec
->line_filepos
* 8;
427 BFD_ASSERT (size
== sec
->size
428 || size
+ 8 == sec
->size
);
429 if (!bfd_set_section_size (sec
, size
))
437 /* See whether the magic number matches. */
440 alpha_ecoff_bad_format_hook (bfd
*abfd ATTRIBUTE_UNUSED
,
443 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
445 if (! ALPHA_ECOFF_BADMAG (*internal_f
))
448 if (ALPHA_ECOFF_COMPRESSEDMAG (*internal_f
))
450 (_("%pB: cannot handle compressed Alpha binaries; "
451 "use compiler flags, or objZ, to generate uncompressed binaries"),
457 /* This is a hook called by coff_real_object_p to create any backend
458 specific information. */
461 alpha_ecoff_mkobject_hook (bfd
*abfd
, void * filehdr
, void * aouthdr
)
465 ecoff
= _bfd_ecoff_mkobject_hook (abfd
, filehdr
, aouthdr
);
469 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
471 /* Set additional BFD flags according to the object type from the
472 machine specific file header flags. */
473 switch (internal_f
->f_flags
& F_ALPHA_OBJECT_TYPE_MASK
)
475 case F_ALPHA_SHARABLE
:
476 abfd
->flags
|= DYNAMIC
;
478 case F_ALPHA_CALL_SHARED
:
479 /* Always executable if using shared libraries as the run time
480 loader might resolve undefined references. */
481 abfd
->flags
|= (DYNAMIC
| EXEC_P
);
488 /* Reloc handling. */
490 /* Swap a reloc in. */
493 alpha_ecoff_swap_reloc_in (bfd
*abfd
,
495 struct internal_reloc
*intern
)
497 const RELOC
*ext
= (RELOC
*) ext_ptr
;
499 intern
->r_vaddr
= H_GET_64 (abfd
, ext
->r_vaddr
);
500 intern
->r_symndx
= H_GET_32 (abfd
, ext
->r_symndx
);
502 BFD_ASSERT (bfd_header_little_endian (abfd
));
504 intern
->r_type
= ((ext
->r_bits
[0] & RELOC_BITS0_TYPE_LITTLE
)
505 >> RELOC_BITS0_TYPE_SH_LITTLE
);
506 intern
->r_extern
= (ext
->r_bits
[1] & RELOC_BITS1_EXTERN_LITTLE
) != 0;
507 intern
->r_offset
= ((ext
->r_bits
[1] & RELOC_BITS1_OFFSET_LITTLE
)
508 >> RELOC_BITS1_OFFSET_SH_LITTLE
);
509 /* Ignored the reserved bits. */
510 intern
->r_size
= ((ext
->r_bits
[3] & RELOC_BITS3_SIZE_LITTLE
)
511 >> RELOC_BITS3_SIZE_SH_LITTLE
);
513 if (intern
->r_type
== ALPHA_R_LITUSE
514 || intern
->r_type
== ALPHA_R_GPDISP
)
516 /* Handle the LITUSE and GPDISP relocs specially. Its symndx
517 value is not actually a symbol index, but is instead a
518 special code. We put the code in the r_size field, and
519 clobber the symndx. */
520 if (intern
->r_size
!= 0)
522 intern
->r_size
= intern
->r_symndx
;
523 intern
->r_symndx
= RELOC_SECTION_NONE
;
525 else if (intern
->r_type
== ALPHA_R_IGNORE
)
527 /* The IGNORE reloc generally follows a GPDISP reloc, and is
528 against the .lita section. The section is irrelevant. */
529 if (! intern
->r_extern
&&
530 intern
->r_symndx
== RELOC_SECTION_ABS
)
532 if (! intern
->r_extern
&& intern
->r_symndx
== RELOC_SECTION_LITA
)
533 intern
->r_symndx
= RELOC_SECTION_ABS
;
537 /* Swap a reloc out. */
540 alpha_ecoff_swap_reloc_out (bfd
*abfd
,
541 const struct internal_reloc
*intern
,
544 RELOC
*ext
= (RELOC
*) dst
;
548 /* Undo the hackery done in swap_reloc_in. */
549 if (intern
->r_type
== ALPHA_R_LITUSE
550 || intern
->r_type
== ALPHA_R_GPDISP
)
552 symndx
= intern
->r_size
;
555 else if (intern
->r_type
== ALPHA_R_IGNORE
556 && ! intern
->r_extern
557 && intern
->r_symndx
== RELOC_SECTION_ABS
)
559 symndx
= RELOC_SECTION_LITA
;
560 size
= intern
->r_size
;
564 symndx
= intern
->r_symndx
;
565 size
= intern
->r_size
;
568 /* XXX FIXME: The maximum symndx value used to be 14 but this
569 fails with object files produced by DEC's C++ compiler.
570 Where does the value 14 (or 15) come from anyway ? */
571 BFD_ASSERT (intern
->r_extern
572 || (intern
->r_symndx
>= 0 && intern
->r_symndx
<= 15));
574 H_PUT_64 (abfd
, intern
->r_vaddr
, ext
->r_vaddr
);
575 H_PUT_32 (abfd
, symndx
, ext
->r_symndx
);
577 BFD_ASSERT (bfd_header_little_endian (abfd
));
579 ext
->r_bits
[0] = ((intern
->r_type
<< RELOC_BITS0_TYPE_SH_LITTLE
)
580 & RELOC_BITS0_TYPE_LITTLE
);
581 ext
->r_bits
[1] = ((intern
->r_extern
? RELOC_BITS1_EXTERN_LITTLE
: 0)
582 | ((intern
->r_offset
<< RELOC_BITS1_OFFSET_SH_LITTLE
)
583 & RELOC_BITS1_OFFSET_LITTLE
));
585 ext
->r_bits
[3] = ((size
<< RELOC_BITS3_SIZE_SH_LITTLE
)
586 & RELOC_BITS3_SIZE_LITTLE
);
589 /* Finish canonicalizing a reloc. Part of this is generic to all
590 ECOFF targets, and that part is in ecoff.c. The rest is done in
591 this backend routine. It must fill in the howto field. */
594 alpha_adjust_reloc_in (bfd
*abfd
,
595 const struct internal_reloc
*intern
,
598 if (intern
->r_type
> ALPHA_R_GPVALUE
)
600 /* xgettext:c-format */
601 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
602 abfd
, intern
->r_type
);
603 bfd_set_error (bfd_error_bad_value
);
609 switch (intern
->r_type
)
615 /* This relocs appear to be fully resolved when they are against
616 internal symbols. Against external symbols, BRADDR at least
617 appears to be resolved against the next instruction. */
618 if (! intern
->r_extern
)
621 rptr
->addend
= - (intern
->r_vaddr
+ 4);
624 case ALPHA_R_GPREL32
:
625 case ALPHA_R_LITERAL
:
626 /* Copy the gp value for this object file into the addend, to
627 ensure that we are not confused by the linker. */
628 if (! intern
->r_extern
)
629 rptr
->addend
+= ecoff_data (abfd
)->gp
;
634 /* The LITUSE and GPDISP relocs do not use a symbol, or an
635 addend, but they do use a special code. Put this code in the
637 rptr
->addend
= intern
->r_size
;
640 case ALPHA_R_OP_STORE
:
641 /* The STORE reloc needs the size and offset fields. We store
642 them in the addend. */
643 BFD_ASSERT (intern
->r_offset
<= 256);
644 rptr
->addend
= (intern
->r_offset
<< 8) + intern
->r_size
;
647 case ALPHA_R_OP_PUSH
:
648 case ALPHA_R_OP_PSUB
:
649 case ALPHA_R_OP_PRSHIFT
:
650 /* The PUSH, PSUB and PRSHIFT relocs do not actually use an
651 address. I believe that the address supplied is really an
653 rptr
->addend
= intern
->r_vaddr
;
656 case ALPHA_R_GPVALUE
:
657 /* Set the addend field to the new GP value. */
658 rptr
->addend
= intern
->r_symndx
+ ecoff_data (abfd
)->gp
;
662 /* If the type is ALPHA_R_IGNORE, make sure this is a reference
663 to the absolute section so that the reloc is ignored. For
664 some reason the address of this reloc type is not adjusted by
665 the section vma. We record the gp value for this object file
666 here, for convenience when doing the GPDISP relocation. */
667 rptr
->sym_ptr_ptr
= bfd_abs_section_ptr
->symbol_ptr_ptr
;
668 rptr
->address
= intern
->r_vaddr
;
669 rptr
->addend
= ecoff_data (abfd
)->gp
;
676 rptr
->howto
= &alpha_howto_table
[intern
->r_type
];
679 /* When writing out a reloc we need to pull some values back out of
680 the addend field into the reloc. This is roughly the reverse of
681 alpha_adjust_reloc_in, except that there are several changes we do
685 alpha_adjust_reloc_out (bfd
*abfd ATTRIBUTE_UNUSED
,
687 struct internal_reloc
*intern
)
689 switch (intern
->r_type
)
693 intern
->r_size
= rel
->addend
;
696 case ALPHA_R_OP_STORE
:
697 intern
->r_size
= rel
->addend
& 0xff;
698 intern
->r_offset
= (rel
->addend
>> 8) & 0xff;
701 case ALPHA_R_OP_PUSH
:
702 case ALPHA_R_OP_PSUB
:
703 case ALPHA_R_OP_PRSHIFT
:
704 intern
->r_vaddr
= rel
->addend
;
708 intern
->r_vaddr
= rel
->address
;
716 /* The size of the stack for the relocation evaluator. */
717 #define RELOC_STACKSIZE (10)
719 /* Alpha ECOFF relocs have a built in expression evaluator as well as
720 other interdependencies. Rather than use a bunch of special
721 functions and global variables, we use a single routine to do all
722 the relocation for a section. I haven't yet worked out how the
723 assembler is going to handle this. */
726 alpha_ecoff_get_relocated_section_contents (bfd
*abfd
,
727 struct bfd_link_info
*link_info
,
728 struct bfd_link_order
*link_order
,
730 bfd_boolean relocatable
,
733 bfd
*input_bfd
= link_order
->u
.indirect
.section
->owner
;
734 asection
*input_section
= link_order
->u
.indirect
.section
;
735 long reloc_size
= bfd_get_reloc_upper_bound (input_bfd
, input_section
);
736 arelent
**reloc_vector
= NULL
;
738 bfd
*output_bfd
= relocatable
? abfd
: (bfd
*) NULL
;
741 bfd_boolean gp_undefined
;
742 bfd_vma stack
[RELOC_STACKSIZE
];
747 reloc_vector
= (arelent
**) bfd_malloc ((bfd_size_type
) reloc_size
);
748 if (reloc_vector
== NULL
&& reloc_size
!= 0)
751 sz
= input_section
->rawsize
? input_section
->rawsize
: input_section
->size
;
752 if (! bfd_get_section_contents (input_bfd
, input_section
, data
, 0, sz
))
755 reloc_count
= bfd_canonicalize_reloc (input_bfd
, input_section
,
756 reloc_vector
, symbols
);
759 if (reloc_count
== 0)
760 goto successful_return
;
762 /* Get the GP value for the output BFD. */
763 gp_undefined
= FALSE
;
764 gp
= _bfd_get_gp_value (abfd
);
772 /* Make up a value. */
774 for (sec
= abfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
777 && (strcmp (sec
->name
, ".sbss") == 0
778 || strcmp (sec
->name
, ".sdata") == 0
779 || strcmp (sec
->name
, ".lit4") == 0
780 || strcmp (sec
->name
, ".lit8") == 0
781 || strcmp (sec
->name
, ".lita") == 0))
785 _bfd_set_gp_value (abfd
, gp
);
789 struct bfd_link_hash_entry
*h
;
791 h
= bfd_link_hash_lookup (link_info
->hash
, "_gp", FALSE
, FALSE
,
793 if (h
== (struct bfd_link_hash_entry
*) NULL
794 || h
->type
!= bfd_link_hash_defined
)
799 + h
->u
.def
.section
->output_section
->vma
800 + h
->u
.def
.section
->output_offset
);
801 _bfd_set_gp_value (abfd
, gp
);
806 for (; *reloc_vector
!= (arelent
*) NULL
; reloc_vector
++)
809 bfd_reloc_status_type r
;
814 switch (rel
->howto
->type
)
817 rel
->address
+= input_section
->output_offset
;
820 case ALPHA_R_REFLONG
:
821 case ALPHA_R_REFQUAD
:
828 && ((*rel
->sym_ptr_ptr
)->flags
& BSF_SECTION_SYM
) == 0)
830 rel
->address
+= input_section
->output_offset
;
833 r
= bfd_perform_relocation (input_bfd
, rel
, data
, input_section
,
837 case ALPHA_R_GPREL32
:
838 /* This relocation is used in a switch table. It is a 32
839 bit offset from the current GP value. We must adjust it
840 by the different between the original GP value and the
841 current GP value. The original GP value is stored in the
842 addend. We adjust the addend and let
843 bfd_perform_relocation finish the job. */
845 r
= bfd_perform_relocation (input_bfd
, rel
, data
, input_section
,
847 if (r
== bfd_reloc_ok
&& gp_undefined
)
849 r
= bfd_reloc_dangerous
;
850 err
= (char *) _("GP relative relocation used when GP not defined");
854 case ALPHA_R_LITERAL
:
855 /* This is a reference to a literal value, generally
856 (always?) in the .lita section. This is a 16 bit GP
857 relative relocation. Sometimes the subsequent reloc is a
858 LITUSE reloc, which indicates how this reloc is used.
859 This sometimes permits rewriting the two instructions
860 referred to by the LITERAL and the LITUSE into different
861 instructions which do not refer to .lita. This can save
862 a memory reference, and permits removing a value from
863 .lita thus saving GP relative space.
865 We do not these optimizations. To do them we would need
866 to arrange to link the .lita section first, so that by
867 the time we got here we would know the final values to
868 use. This would not be particularly difficult, but it is
869 not currently implemented. */
874 /* I believe that the LITERAL reloc will only apply to a
875 ldq or ldl instruction, so check my assumption. */
876 insn
= bfd_get_32 (input_bfd
, data
+ rel
->address
);
877 BFD_ASSERT (((insn
>> 26) & 0x3f) == 0x29
878 || ((insn
>> 26) & 0x3f) == 0x28);
881 r
= bfd_perform_relocation (input_bfd
, rel
, data
, input_section
,
883 if (r
== bfd_reloc_ok
&& gp_undefined
)
885 r
= bfd_reloc_dangerous
;
887 (char *) _("GP relative relocation used when GP not defined");
893 /* See ALPHA_R_LITERAL above for the uses of this reloc. It
894 does not cause anything to happen, itself. */
895 rel
->address
+= input_section
->output_offset
;
899 /* This marks the ldah of an ldah/lda pair which loads the
900 gp register with the difference of the gp value and the
901 current location. The second of the pair is r_size bytes
902 ahead; it used to be marked with an ALPHA_R_IGNORE reloc,
903 but that no longer happens in OSF/1 3.2. */
905 unsigned long insn1
, insn2
;
908 /* Get the two instructions. */
909 insn1
= bfd_get_32 (input_bfd
, data
+ rel
->address
);
910 insn2
= bfd_get_32 (input_bfd
, data
+ rel
->address
+ rel
->addend
);
912 BFD_ASSERT (((insn1
>> 26) & 0x3f) == 0x09); /* ldah */
913 BFD_ASSERT (((insn2
>> 26) & 0x3f) == 0x08); /* lda */
915 /* Get the existing addend. We must account for the sign
916 extension done by lda and ldah. */
917 addend
= ((insn1
& 0xffff) << 16) + (insn2
& 0xffff);
920 addend
-= 0x80000000;
921 addend
-= 0x80000000;
926 /* The existing addend includes the different between the
927 gp of the input BFD and the address in the input BFD.
928 Subtract this out. */
929 addend
-= (ecoff_data (input_bfd
)->gp
930 - (input_section
->vma
+ rel
->address
));
932 /* Now add in the final gp value, and subtract out the
935 - (input_section
->output_section
->vma
936 + input_section
->output_offset
939 /* Change the instructions, accounting for the sign
940 extension, and write them out. */
943 insn1
= (insn1
& 0xffff0000) | ((addend
>> 16) & 0xffff);
944 insn2
= (insn2
& 0xffff0000) | (addend
& 0xffff);
946 bfd_put_32 (input_bfd
, (bfd_vma
) insn1
, data
+ rel
->address
);
947 bfd_put_32 (input_bfd
, (bfd_vma
) insn2
,
948 data
+ rel
->address
+ rel
->addend
);
950 rel
->address
+= input_section
->output_offset
;
954 case ALPHA_R_OP_PUSH
:
955 /* Push a value on the reloc evaluation stack. */
962 rel
->address
+= input_section
->output_offset
;
966 /* Figure out the relocation of this symbol. */
967 symbol
= *rel
->sym_ptr_ptr
;
969 if (bfd_is_und_section (symbol
->section
))
970 r
= bfd_reloc_undefined
;
972 if (bfd_is_com_section (symbol
->section
))
975 relocation
= symbol
->value
;
976 relocation
+= symbol
->section
->output_section
->vma
;
977 relocation
+= symbol
->section
->output_offset
;
978 relocation
+= rel
->addend
;
980 if (tos
>= RELOC_STACKSIZE
)
983 stack
[tos
++] = relocation
;
987 case ALPHA_R_OP_STORE
:
988 /* Store a value from the reloc stack into a bitfield. */
995 rel
->address
+= input_section
->output_offset
;
1002 /* The offset and size for this reloc are encoded into the
1003 addend field by alpha_adjust_reloc_in. */
1004 offset
= (rel
->addend
>> 8) & 0xff;
1005 size
= rel
->addend
& 0xff;
1007 val
= bfd_get_64 (abfd
, data
+ rel
->address
);
1008 val
&=~ (((1 << size
) - 1) << offset
);
1009 val
|= (stack
[--tos
] & ((1 << size
) - 1)) << offset
;
1010 bfd_put_64 (abfd
, val
, data
+ rel
->address
);
1014 case ALPHA_R_OP_PSUB
:
1015 /* Subtract a value from the top of the stack. */
1022 rel
->address
+= input_section
->output_offset
;
1026 /* Figure out the relocation of this symbol. */
1027 symbol
= *rel
->sym_ptr_ptr
;
1029 if (bfd_is_und_section (symbol
->section
))
1030 r
= bfd_reloc_undefined
;
1032 if (bfd_is_com_section (symbol
->section
))
1035 relocation
= symbol
->value
;
1036 relocation
+= symbol
->section
->output_section
->vma
;
1037 relocation
+= symbol
->section
->output_offset
;
1038 relocation
+= rel
->addend
;
1043 stack
[tos
- 1] -= relocation
;
1047 case ALPHA_R_OP_PRSHIFT
:
1048 /* Shift the value on the top of the stack. */
1055 rel
->address
+= input_section
->output_offset
;
1059 /* Figure out the relocation of this symbol. */
1060 symbol
= *rel
->sym_ptr_ptr
;
1062 if (bfd_is_und_section (symbol
->section
))
1063 r
= bfd_reloc_undefined
;
1065 if (bfd_is_com_section (symbol
->section
))
1068 relocation
= symbol
->value
;
1069 relocation
+= symbol
->section
->output_section
->vma
;
1070 relocation
+= symbol
->section
->output_offset
;
1071 relocation
+= rel
->addend
;
1076 stack
[tos
- 1] >>= relocation
;
1080 case ALPHA_R_GPVALUE
:
1081 /* I really don't know if this does the right thing. */
1083 gp_undefined
= FALSE
;
1092 asection
*os
= input_section
->output_section
;
1094 /* A partial link, so keep the relocs. */
1095 os
->orelocation
[os
->reloc_count
] = rel
;
1099 if (r
!= bfd_reloc_ok
)
1103 case bfd_reloc_undefined
:
1104 (*link_info
->callbacks
->undefined_symbol
)
1105 (link_info
, bfd_asymbol_name (*rel
->sym_ptr_ptr
),
1106 input_bfd
, input_section
, rel
->address
, TRUE
);
1108 case bfd_reloc_dangerous
:
1109 (*link_info
->callbacks
->reloc_dangerous
)
1110 (link_info
, err
, input_bfd
, input_section
, rel
->address
);
1112 case bfd_reloc_overflow
:
1113 (*link_info
->callbacks
->reloc_overflow
)
1114 (link_info
, NULL
, bfd_asymbol_name (*rel
->sym_ptr_ptr
),
1115 rel
->howto
->name
, rel
->addend
, input_bfd
,
1116 input_section
, rel
->address
);
1118 case bfd_reloc_outofrange
:
1130 free (reloc_vector
);
1134 free (reloc_vector
);
1138 /* Get the howto structure for a generic reloc type. */
1140 static reloc_howto_type
*
1141 alpha_bfd_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1142 bfd_reloc_code_real_type code
)
1149 alpha_type
= ALPHA_R_REFLONG
;
1152 case BFD_RELOC_CTOR
:
1153 alpha_type
= ALPHA_R_REFQUAD
;
1155 case BFD_RELOC_GPREL32
:
1156 alpha_type
= ALPHA_R_GPREL32
;
1158 case BFD_RELOC_ALPHA_LITERAL
:
1159 alpha_type
= ALPHA_R_LITERAL
;
1161 case BFD_RELOC_ALPHA_LITUSE
:
1162 alpha_type
= ALPHA_R_LITUSE
;
1164 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1165 alpha_type
= ALPHA_R_GPDISP
;
1167 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1168 alpha_type
= ALPHA_R_IGNORE
;
1170 case BFD_RELOC_23_PCREL_S2
:
1171 alpha_type
= ALPHA_R_BRADDR
;
1173 case BFD_RELOC_ALPHA_HINT
:
1174 alpha_type
= ALPHA_R_HINT
;
1176 case BFD_RELOC_16_PCREL
:
1177 alpha_type
= ALPHA_R_SREL16
;
1179 case BFD_RELOC_32_PCREL
:
1180 alpha_type
= ALPHA_R_SREL32
;
1182 case BFD_RELOC_64_PCREL
:
1183 alpha_type
= ALPHA_R_SREL64
;
1186 return (reloc_howto_type
*) NULL
;
1189 return &alpha_howto_table
[alpha_type
];
1192 static reloc_howto_type
*
1193 alpha_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1199 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
1201 if (alpha_howto_table
[i
].name
!= NULL
1202 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
1203 return &alpha_howto_table
[i
];
1208 /* A helper routine for alpha_relocate_section which converts an
1209 external reloc when generating relocatable output. Returns the
1210 relocation amount. */
1213 alpha_convert_external_reloc (bfd
*output_bfd ATTRIBUTE_UNUSED
,
1214 struct bfd_link_info
*info
,
1216 struct external_reloc
*ext_rel
,
1217 struct ecoff_link_hash_entry
*h
)
1219 unsigned long r_symndx
;
1222 BFD_ASSERT (bfd_link_relocatable (info
));
1224 if (h
->root
.type
== bfd_link_hash_defined
1225 || h
->root
.type
== bfd_link_hash_defweak
)
1230 /* This symbol is defined in the output. Convert the reloc from
1231 being against the symbol to being against the section. */
1233 /* Clear the r_extern bit. */
1234 ext_rel
->r_bits
[1] &=~ RELOC_BITS1_EXTERN_LITTLE
;
1236 /* Compute a new r_symndx value. */
1237 hsec
= h
->root
.u
.def
.section
;
1238 name
= bfd_section_name (hsec
->output_section
);
1240 r_symndx
= (unsigned long) -1;
1244 if (strcmp (name
, "*ABS*") == 0)
1245 r_symndx
= RELOC_SECTION_ABS
;
1248 if (strcmp (name
, ".bss") == 0)
1249 r_symndx
= RELOC_SECTION_BSS
;
1252 if (strcmp (name
, ".data") == 0)
1253 r_symndx
= RELOC_SECTION_DATA
;
1256 if (strcmp (name
, ".fini") == 0)
1257 r_symndx
= RELOC_SECTION_FINI
;
1260 if (strcmp (name
, ".init") == 0)
1261 r_symndx
= RELOC_SECTION_INIT
;
1264 if (strcmp (name
, ".lita") == 0)
1265 r_symndx
= RELOC_SECTION_LITA
;
1266 else if (strcmp (name
, ".lit8") == 0)
1267 r_symndx
= RELOC_SECTION_LIT8
;
1268 else if (strcmp (name
, ".lit4") == 0)
1269 r_symndx
= RELOC_SECTION_LIT4
;
1272 if (strcmp (name
, ".pdata") == 0)
1273 r_symndx
= RELOC_SECTION_PDATA
;
1276 if (strcmp (name
, ".rdata") == 0)
1277 r_symndx
= RELOC_SECTION_RDATA
;
1278 else if (strcmp (name
, ".rconst") == 0)
1279 r_symndx
= RELOC_SECTION_RCONST
;
1282 if (strcmp (name
, ".sdata") == 0)
1283 r_symndx
= RELOC_SECTION_SDATA
;
1284 else if (strcmp (name
, ".sbss") == 0)
1285 r_symndx
= RELOC_SECTION_SBSS
;
1288 if (strcmp (name
, ".text") == 0)
1289 r_symndx
= RELOC_SECTION_TEXT
;
1292 if (strcmp (name
, ".xdata") == 0)
1293 r_symndx
= RELOC_SECTION_XDATA
;
1297 if (r_symndx
== (unsigned long) -1)
1300 /* Add the section VMA and the symbol value. */
1301 relocation
= (h
->root
.u
.def
.value
1302 + hsec
->output_section
->vma
1303 + hsec
->output_offset
);
1307 /* Change the symndx value to the right one for
1310 if (r_symndx
== (unsigned long) -1)
1312 /* Caller must give an error. */
1318 /* Write out the new r_symndx value. */
1319 H_PUT_32 (input_bfd
, r_symndx
, ext_rel
->r_symndx
);
1324 /* Relocate a section while linking an Alpha ECOFF file. This is
1325 quite similar to get_relocated_section_contents. Perhaps they
1326 could be combined somehow. */
1329 alpha_relocate_section (bfd
*output_bfd
,
1330 struct bfd_link_info
*info
,
1332 asection
*input_section
,
1334 void * external_relocs
)
1336 asection
**symndx_to_section
, *lita_sec
;
1337 struct ecoff_link_hash_entry
**sym_hashes
;
1339 bfd_boolean gp_undefined
;
1340 bfd_vma stack
[RELOC_STACKSIZE
];
1342 struct external_reloc
*ext_rel
;
1343 struct external_reloc
*ext_rel_end
;
1346 /* We keep a table mapping the symndx found in an internal reloc to
1347 the appropriate section. This is faster than looking up the
1348 section by name each time. */
1349 symndx_to_section
= ecoff_data (input_bfd
)->symndx_to_section
;
1350 if (symndx_to_section
== (asection
**) NULL
)
1352 amt
= NUM_RELOC_SECTIONS
* sizeof (asection
*);
1353 symndx_to_section
= (asection
**) bfd_alloc (input_bfd
, amt
);
1354 if (!symndx_to_section
)
1357 symndx_to_section
[RELOC_SECTION_NONE
] = NULL
;
1358 symndx_to_section
[RELOC_SECTION_TEXT
] =
1359 bfd_get_section_by_name (input_bfd
, ".text");
1360 symndx_to_section
[RELOC_SECTION_RDATA
] =
1361 bfd_get_section_by_name (input_bfd
, ".rdata");
1362 symndx_to_section
[RELOC_SECTION_DATA
] =
1363 bfd_get_section_by_name (input_bfd
, ".data");
1364 symndx_to_section
[RELOC_SECTION_SDATA
] =
1365 bfd_get_section_by_name (input_bfd
, ".sdata");
1366 symndx_to_section
[RELOC_SECTION_SBSS
] =
1367 bfd_get_section_by_name (input_bfd
, ".sbss");
1368 symndx_to_section
[RELOC_SECTION_BSS
] =
1369 bfd_get_section_by_name (input_bfd
, ".bss");
1370 symndx_to_section
[RELOC_SECTION_INIT
] =
1371 bfd_get_section_by_name (input_bfd
, ".init");
1372 symndx_to_section
[RELOC_SECTION_LIT8
] =
1373 bfd_get_section_by_name (input_bfd
, ".lit8");
1374 symndx_to_section
[RELOC_SECTION_LIT4
] =
1375 bfd_get_section_by_name (input_bfd
, ".lit4");
1376 symndx_to_section
[RELOC_SECTION_XDATA
] =
1377 bfd_get_section_by_name (input_bfd
, ".xdata");
1378 symndx_to_section
[RELOC_SECTION_PDATA
] =
1379 bfd_get_section_by_name (input_bfd
, ".pdata");
1380 symndx_to_section
[RELOC_SECTION_FINI
] =
1381 bfd_get_section_by_name (input_bfd
, ".fini");
1382 symndx_to_section
[RELOC_SECTION_LITA
] =
1383 bfd_get_section_by_name (input_bfd
, ".lita");
1384 symndx_to_section
[RELOC_SECTION_ABS
] = bfd_abs_section_ptr
;
1385 symndx_to_section
[RELOC_SECTION_RCONST
] =
1386 bfd_get_section_by_name (input_bfd
, ".rconst");
1388 ecoff_data (input_bfd
)->symndx_to_section
= symndx_to_section
;
1391 sym_hashes
= ecoff_data (input_bfd
)->sym_hashes
;
1393 /* On the Alpha, the .lita section must be addressable by the global
1394 pointer. To support large programs, we need to allow multiple
1395 global pointers. This works as long as each input .lita section
1396 is <64KB big. This implies that when producing relocatable
1397 output, the .lita section is limited to 64KB. . */
1399 lita_sec
= symndx_to_section
[RELOC_SECTION_LITA
];
1400 gp
= _bfd_get_gp_value (output_bfd
);
1401 if (! bfd_link_relocatable (info
) && lita_sec
!= NULL
)
1403 struct ecoff_section_tdata
*lita_sec_data
;
1405 /* Make sure we have a section data structure to which we can
1406 hang on to the gp value we pick for the section. */
1407 lita_sec_data
= ecoff_section_data (input_bfd
, lita_sec
);
1408 if (lita_sec_data
== NULL
)
1410 amt
= sizeof (struct ecoff_section_tdata
);
1411 lita_sec_data
= ((struct ecoff_section_tdata
*)
1412 bfd_zalloc (input_bfd
, amt
));
1413 lita_sec
->used_by_bfd
= lita_sec_data
;
1416 if (lita_sec_data
->gp
!= 0)
1418 /* If we already assigned a gp to this section, we better
1419 stick with that value. */
1420 gp
= lita_sec_data
->gp
;
1425 bfd_size_type lita_size
;
1427 lita_vma
= lita_sec
->output_offset
+ lita_sec
->output_section
->vma
;
1428 lita_size
= lita_sec
->size
;
1431 || lita_vma
< gp
- 0x8000
1432 || lita_vma
+ lita_size
>= gp
+ 0x8000)
1434 /* Either gp hasn't been set at all or the current gp
1435 cannot address this .lita section. In both cases we
1436 reset the gp to point into the "middle" of the
1437 current input .lita section. */
1438 if (gp
&& !ecoff_data (output_bfd
)->issued_multiple_gp_warning
)
1440 (*info
->callbacks
->warning
) (info
,
1441 _("using multiple gp values"),
1442 (char *) NULL
, output_bfd
,
1443 (asection
*) NULL
, (bfd_vma
) 0);
1444 ecoff_data (output_bfd
)->issued_multiple_gp_warning
= TRUE
;
1446 if (lita_vma
< gp
- 0x8000)
1447 gp
= lita_vma
+ lita_size
- 0x8000;
1449 gp
= lita_vma
+ 0x8000;
1453 lita_sec_data
->gp
= gp
;
1456 _bfd_set_gp_value (output_bfd
, gp
);
1459 gp_undefined
= (gp
== 0);
1461 BFD_ASSERT (bfd_header_little_endian (output_bfd
));
1462 BFD_ASSERT (bfd_header_little_endian (input_bfd
));
1464 ext_rel
= (struct external_reloc
*) external_relocs
;
1465 ext_rel_end
= ext_rel
+ input_section
->reloc_count
;
1466 for (; ext_rel
< ext_rel_end
; ext_rel
++)
1469 unsigned long r_symndx
;
1474 bfd_boolean relocatep
;
1475 bfd_boolean adjust_addrp
;
1476 bfd_boolean gp_usedp
;
1479 r_vaddr
= H_GET_64 (input_bfd
, ext_rel
->r_vaddr
);
1480 r_symndx
= H_GET_32 (input_bfd
, ext_rel
->r_symndx
);
1482 r_type
= ((ext_rel
->r_bits
[0] & RELOC_BITS0_TYPE_LITTLE
)
1483 >> RELOC_BITS0_TYPE_SH_LITTLE
);
1484 r_extern
= (ext_rel
->r_bits
[1] & RELOC_BITS1_EXTERN_LITTLE
) != 0;
1485 r_offset
= ((ext_rel
->r_bits
[1] & RELOC_BITS1_OFFSET_LITTLE
)
1486 >> RELOC_BITS1_OFFSET_SH_LITTLE
);
1487 /* Ignored the reserved bits. */
1488 r_size
= ((ext_rel
->r_bits
[3] & RELOC_BITS3_SIZE_LITTLE
)
1489 >> RELOC_BITS3_SIZE_SH_LITTLE
);
1492 adjust_addrp
= TRUE
;
1498 case ALPHA_R_GPRELHIGH
:
1499 _bfd_error_handler (_("%pB: %s unsupported"),
1500 input_bfd
, "ALPHA_R_GPRELHIGH");
1501 bfd_set_error (bfd_error_bad_value
);
1504 case ALPHA_R_GPRELLOW
:
1505 _bfd_error_handler (_("%pB: %s unsupported"),
1506 input_bfd
, "ALPHA_R_GPRELLOW");
1507 bfd_set_error (bfd_error_bad_value
);
1511 /* xgettext:c-format */
1512 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
1513 input_bfd
, (int) r_type
);
1514 bfd_set_error (bfd_error_bad_value
);
1517 case ALPHA_R_IGNORE
:
1518 /* This reloc appears after a GPDISP reloc. On earlier
1519 versions of OSF/1, It marked the position of the second
1520 instruction to be altered by the GPDISP reloc, but it is
1521 not otherwise used for anything. For some reason, the
1522 address of the relocation does not appear to include the
1523 section VMA, unlike the other relocation types. */
1524 if (bfd_link_relocatable (info
))
1525 H_PUT_64 (input_bfd
, input_section
->output_offset
+ r_vaddr
,
1527 adjust_addrp
= FALSE
;
1530 case ALPHA_R_REFLONG
:
1531 case ALPHA_R_REFQUAD
:
1536 case ALPHA_R_BRADDR
:
1537 case ALPHA_R_SREL16
:
1538 case ALPHA_R_SREL32
:
1539 case ALPHA_R_SREL64
:
1541 addend
+= - (r_vaddr
+ 4);
1545 case ALPHA_R_GPREL32
:
1546 /* This relocation is used in a switch table. It is a 32
1547 bit offset from the current GP value. We must adjust it
1548 by the different between the original GP value and the
1549 current GP value. */
1551 addend
= ecoff_data (input_bfd
)->gp
- gp
;
1555 case ALPHA_R_LITERAL
:
1556 /* This is a reference to a literal value, generally
1557 (always?) in the .lita section. This is a 16 bit GP
1558 relative relocation. Sometimes the subsequent reloc is a
1559 LITUSE reloc, which indicates how this reloc is used.
1560 This sometimes permits rewriting the two instructions
1561 referred to by the LITERAL and the LITUSE into different
1562 instructions which do not refer to .lita. This can save
1563 a memory reference, and permits removing a value from
1564 .lita thus saving GP relative space.
1566 We do not these optimizations. To do them we would need
1567 to arrange to link the .lita section first, so that by
1568 the time we got here we would know the final values to
1569 use. This would not be particularly difficult, but it is
1570 not currently implemented. */
1572 /* I believe that the LITERAL reloc will only apply to a ldq
1573 or ldl instruction, so check my assumption. */
1577 insn
= bfd_get_32 (input_bfd
,
1578 contents
+ r_vaddr
- input_section
->vma
);
1579 BFD_ASSERT (((insn
>> 26) & 0x3f) == 0x29
1580 || ((insn
>> 26) & 0x3f) == 0x28);
1584 addend
= ecoff_data (input_bfd
)->gp
- gp
;
1588 case ALPHA_R_LITUSE
:
1589 /* See ALPHA_R_LITERAL above for the uses of this reloc. It
1590 does not cause anything to happen, itself. */
1593 case ALPHA_R_GPDISP
:
1594 /* This marks the ldah of an ldah/lda pair which loads the
1595 gp register with the difference of the gp value and the
1596 current location. The second of the pair is r_symndx
1597 bytes ahead. It used to be marked with an ALPHA_R_IGNORE
1598 reloc, but OSF/1 3.2 no longer does that. */
1600 unsigned long insn1
, insn2
;
1602 /* Get the two instructions. */
1603 insn1
= bfd_get_32 (input_bfd
,
1604 contents
+ r_vaddr
- input_section
->vma
);
1605 insn2
= bfd_get_32 (input_bfd
,
1608 - input_section
->vma
1611 BFD_ASSERT (((insn1
>> 26) & 0x3f) == 0x09); /* ldah */
1612 BFD_ASSERT (((insn2
>> 26) & 0x3f) == 0x08); /* lda */
1614 /* Get the existing addend. We must account for the sign
1615 extension done by lda and ldah. */
1616 addend
= ((insn1
& 0xffff) << 16) + (insn2
& 0xffff);
1619 /* This is addend -= 0x100000000 without causing an
1620 integer overflow on a 32 bit host. */
1621 addend
-= 0x80000000;
1622 addend
-= 0x80000000;
1627 /* The existing addend includes the difference between the
1628 gp of the input BFD and the address in the input BFD.
1629 We want to change this to the difference between the
1630 final GP and the final address. */
1632 - ecoff_data (input_bfd
)->gp
1633 + input_section
->vma
1634 - (input_section
->output_section
->vma
1635 + input_section
->output_offset
));
1637 /* Change the instructions, accounting for the sign
1638 extension, and write them out. */
1639 if (addend
& 0x8000)
1641 insn1
= (insn1
& 0xffff0000) | ((addend
>> 16) & 0xffff);
1642 insn2
= (insn2
& 0xffff0000) | (addend
& 0xffff);
1644 bfd_put_32 (input_bfd
, (bfd_vma
) insn1
,
1645 contents
+ r_vaddr
- input_section
->vma
);
1646 bfd_put_32 (input_bfd
, (bfd_vma
) insn2
,
1647 contents
+ r_vaddr
- input_section
->vma
+ r_symndx
);
1653 case ALPHA_R_OP_PUSH
:
1654 case ALPHA_R_OP_PSUB
:
1655 case ALPHA_R_OP_PRSHIFT
:
1656 /* Manipulate values on the reloc evaluation stack. The
1657 r_vaddr field is not an address in input_section, it is
1658 the current value (including any addend) of the object
1664 s
= symndx_to_section
[r_symndx
];
1665 if (s
== (asection
*) NULL
)
1667 addend
= s
->output_section
->vma
+ s
->output_offset
- s
->vma
;
1671 struct ecoff_link_hash_entry
*h
;
1673 h
= sym_hashes
[r_symndx
];
1674 if (h
== (struct ecoff_link_hash_entry
*) NULL
)
1677 if (! bfd_link_relocatable (info
))
1679 if (h
->root
.type
== bfd_link_hash_defined
1680 || h
->root
.type
== bfd_link_hash_defweak
)
1681 addend
= (h
->root
.u
.def
.value
1682 + h
->root
.u
.def
.section
->output_section
->vma
1683 + h
->root
.u
.def
.section
->output_offset
);
1686 /* Note that we pass the address as 0, since we
1687 do not have a meaningful number for the
1688 location within the section that is being
1690 (*info
->callbacks
->undefined_symbol
)
1691 (info
, h
->root
.root
.string
, input_bfd
,
1692 input_section
, (bfd_vma
) 0, TRUE
);
1698 if (h
->root
.type
!= bfd_link_hash_defined
1699 && h
->root
.type
!= bfd_link_hash_defweak
1702 /* This symbol is not being written out. Pass
1703 the address as 0, as with undefined_symbol,
1705 (*info
->callbacks
->unattached_reloc
)
1706 (info
, h
->root
.root
.string
,
1707 input_bfd
, input_section
, (bfd_vma
) 0);
1710 addend
= alpha_convert_external_reloc (output_bfd
, info
,
1718 if (bfd_link_relocatable (info
))
1720 /* Adjust r_vaddr by the addend. */
1721 H_PUT_64 (input_bfd
, addend
, ext_rel
->r_vaddr
);
1727 case ALPHA_R_OP_PUSH
:
1728 if (tos
>= RELOC_STACKSIZE
)
1730 stack
[tos
++] = addend
;
1733 case ALPHA_R_OP_PSUB
:
1736 stack
[tos
- 1] -= addend
;
1739 case ALPHA_R_OP_PRSHIFT
:
1742 stack
[tos
- 1] >>= addend
;
1747 adjust_addrp
= FALSE
;
1750 case ALPHA_R_OP_STORE
:
1751 /* Store a value from the reloc stack into a bitfield. If
1752 we are generating relocatable output, all we do is
1753 adjust the address of the reloc. */
1754 if (! bfd_link_relocatable (info
))
1762 /* Get the relocation mask. The separate steps and the
1763 casts to bfd_vma are attempts to avoid a bug in the
1764 Alpha OSF 1.3 C compiler. See reloc.c for more
1767 mask
<<= (bfd_vma
) r_size
;
1770 /* FIXME: I don't know what kind of overflow checking,
1771 if any, should be done here. */
1772 val
= bfd_get_64 (input_bfd
,
1773 contents
+ r_vaddr
- input_section
->vma
);
1774 val
&=~ mask
<< (bfd_vma
) r_offset
;
1775 val
|= (stack
[--tos
] & mask
) << (bfd_vma
) r_offset
;
1776 bfd_put_64 (input_bfd
, val
,
1777 contents
+ r_vaddr
- input_section
->vma
);
1781 case ALPHA_R_GPVALUE
:
1782 /* I really don't know if this does the right thing. */
1783 gp
= ecoff_data (input_bfd
)->gp
+ r_symndx
;
1784 gp_undefined
= FALSE
;
1790 reloc_howto_type
*howto
;
1791 struct ecoff_link_hash_entry
*h
= NULL
;
1794 bfd_reloc_status_type r
;
1796 /* Perform a relocation. */
1798 howto
= &alpha_howto_table
[r_type
];
1802 h
= sym_hashes
[r_symndx
];
1803 /* If h is NULL, that means that there is a reloc
1804 against an external symbol which we thought was just
1805 a debugging symbol. This should not happen. */
1806 if (h
== (struct ecoff_link_hash_entry
*) NULL
)
1811 if (r_symndx
>= NUM_RELOC_SECTIONS
)
1814 s
= symndx_to_section
[r_symndx
];
1816 if (s
== (asection
*) NULL
)
1820 if (bfd_link_relocatable (info
))
1822 /* We are generating relocatable output, and must
1823 convert the existing reloc. */
1826 if (h
->root
.type
!= bfd_link_hash_defined
1827 && h
->root
.type
!= bfd_link_hash_defweak
1830 /* This symbol is not being written out. */
1831 (*info
->callbacks
->unattached_reloc
)
1832 (info
, h
->root
.root
.string
, input_bfd
,
1833 input_section
, r_vaddr
- input_section
->vma
);
1836 relocation
= alpha_convert_external_reloc (output_bfd
,
1844 /* This is a relocation against a section. Adjust
1845 the value by the amount the section moved. */
1846 relocation
= (s
->output_section
->vma
1851 /* If this is PC relative, the existing object file
1852 appears to already have the reloc worked out. We
1853 must subtract out the old value and add in the new
1855 if (howto
->pc_relative
)
1856 relocation
-= (input_section
->output_section
->vma
1857 + input_section
->output_offset
1858 - input_section
->vma
);
1860 /* Put in any addend. */
1861 relocation
+= addend
;
1863 /* Adjust the contents. */
1864 r
= _bfd_relocate_contents (howto
, input_bfd
, relocation
,
1867 - input_section
->vma
));
1871 /* We are producing a final executable. */
1874 /* This is a reloc against a symbol. */
1875 if (h
->root
.type
== bfd_link_hash_defined
1876 || h
->root
.type
== bfd_link_hash_defweak
)
1880 hsec
= h
->root
.u
.def
.section
;
1881 relocation
= (h
->root
.u
.def
.value
1882 + hsec
->output_section
->vma
1883 + hsec
->output_offset
);
1887 (*info
->callbacks
->undefined_symbol
)
1888 (info
, h
->root
.root
.string
, input_bfd
, input_section
,
1889 r_vaddr
- input_section
->vma
, TRUE
);
1895 /* This is a reloc against a section. */
1896 relocation
= (s
->output_section
->vma
1900 /* Adjust a PC relative relocation by removing the
1901 reference to the original source section. */
1902 if (howto
->pc_relative
)
1903 relocation
+= input_section
->vma
;
1906 r
= _bfd_final_link_relocate (howto
,
1910 r_vaddr
- input_section
->vma
,
1915 if (r
!= bfd_reloc_ok
)
1920 case bfd_reloc_outofrange
:
1922 case bfd_reloc_overflow
:
1927 name
= sym_hashes
[r_symndx
]->root
.root
.string
;
1929 name
= bfd_section_name (symndx_to_section
[r_symndx
]);
1930 (*info
->callbacks
->reloc_overflow
)
1931 (info
, NULL
, name
, alpha_howto_table
[r_type
].name
,
1932 (bfd_vma
) 0, input_bfd
, input_section
,
1933 r_vaddr
- input_section
->vma
);
1940 if (bfd_link_relocatable (info
) && adjust_addrp
)
1942 /* Change the address of the relocation. */
1943 H_PUT_64 (input_bfd
,
1944 (input_section
->output_section
->vma
1945 + input_section
->output_offset
1946 - input_section
->vma
1951 if (gp_usedp
&& gp_undefined
)
1953 (*info
->callbacks
->reloc_dangerous
)
1954 (info
, _("GP relative relocation used when GP not defined"),
1955 input_bfd
, input_section
, r_vaddr
- input_section
->vma
);
1956 /* Only give the error once per link. */
1958 _bfd_set_gp_value (output_bfd
, gp
);
1959 gp_undefined
= FALSE
;
1969 /* Do final adjustments to the filehdr and the aouthdr. This routine
1970 sets the dynamic bits in the file header. */
1973 alpha_adjust_headers (bfd
*abfd
,
1974 struct internal_filehdr
*fhdr
,
1975 struct internal_aouthdr
*ahdr ATTRIBUTE_UNUSED
)
1977 if ((abfd
->flags
& (DYNAMIC
| EXEC_P
)) == (DYNAMIC
| EXEC_P
))
1978 fhdr
->f_flags
|= F_ALPHA_CALL_SHARED
;
1979 else if ((abfd
->flags
& DYNAMIC
) != 0)
1980 fhdr
->f_flags
|= F_ALPHA_SHARABLE
;
1984 /* Archive handling. In OSF/1 (or Digital Unix) v3.2, Digital
1985 introduced archive packing, in which the elements in an archive are
1986 optionally compressed using a simple dictionary scheme. We know
1987 how to read such archives, but we don't write them. */
1989 #define alpha_ecoff_slurp_armap _bfd_ecoff_slurp_armap
1990 #define alpha_ecoff_slurp_extended_name_table \
1991 _bfd_ecoff_slurp_extended_name_table
1992 #define alpha_ecoff_construct_extended_name_table \
1993 _bfd_ecoff_construct_extended_name_table
1994 #define alpha_ecoff_truncate_arname _bfd_ecoff_truncate_arname
1995 #define alpha_ecoff_write_armap _bfd_ecoff_write_armap
1996 #define alpha_ecoff_write_ar_hdr _bfd_generic_write_ar_hdr
1997 #define alpha_ecoff_generic_stat_arch_elt _bfd_ecoff_generic_stat_arch_elt
1998 #define alpha_ecoff_update_armap_timestamp _bfd_ecoff_update_armap_timestamp
2000 /* A compressed file uses this instead of ARFMAG. */
2002 #define ARFZMAG "Z\012"
2004 /* Read an archive header. This is like the standard routine, but it
2005 also accepts ARFZMAG. */
2008 alpha_ecoff_read_ar_hdr (bfd
*abfd
)
2010 struct areltdata
*ret
;
2013 ret
= (struct areltdata
*) _bfd_generic_read_ar_hdr_mag (abfd
, ARFZMAG
);
2017 h
= (struct ar_hdr
*) ret
->arch_header
;
2018 if (strncmp (h
->ar_fmag
, ARFZMAG
, 2) == 0)
2022 /* This is a compressed file. We must set the size correctly.
2023 The size is the eight bytes after the dummy file header. */
2024 if (bfd_seek (abfd
, (file_ptr
) FILHSZ
, SEEK_CUR
) != 0
2025 || bfd_bread (ab
, (bfd_size_type
) 8, abfd
) != 8
2026 || bfd_seek (abfd
, (file_ptr
) (- (FILHSZ
+ 8)), SEEK_CUR
) != 0)
2032 ret
->parsed_size
= H_GET_64 (abfd
, ab
);
2038 /* Get an archive element at a specified file position. This is where
2039 we uncompress the archive element if necessary. */
2042 alpha_ecoff_get_elt_at_filepos (bfd
*archive
, file_ptr filepos
)
2045 struct areltdata
*tdata
;
2050 struct bfd_in_memory
*bim
;
2054 nbfd
= _bfd_get_elt_at_filepos (archive
, filepos
);
2058 if ((nbfd
->flags
& BFD_IN_MEMORY
) != 0)
2060 /* We have already expanded this BFD. */
2064 tdata
= (struct areltdata
*) nbfd
->arelt_data
;
2065 hdr
= (struct ar_hdr
*) tdata
->arch_header
;
2066 if (strncmp (hdr
->ar_fmag
, ARFZMAG
, 2) != 0)
2069 /* We must uncompress this element. We do this by copying it into a
2070 memory buffer, and making bfd_bread and bfd_seek use that buffer.
2071 This can use a lot of memory, but it's simpler than getting a
2072 temporary file, making that work with the file descriptor caching
2073 code, and making sure that it is deleted at all appropriate
2074 times. It can be changed if it ever becomes important. */
2076 /* The compressed file starts with a dummy ECOFF file header. */
2077 if (bfd_seek (nbfd
, (file_ptr
) FILHSZ
, SEEK_SET
) != 0)
2080 /* The next eight bytes are the real file size. */
2081 if (bfd_bread (ab
, (bfd_size_type
) 8, nbfd
) != 8)
2083 size
= H_GET_64 (nbfd
, ab
);
2085 /* The decompression algorithm will at most expand by eight times. */
2086 filesize
= bfd_get_file_size (archive
);
2087 if (filesize
!= 0 && size
/ 8 > filesize
)
2089 bfd_set_error (bfd_error_malformed_archive
);
2096 bfd_byte dict
[4096];
2100 buf
= (bfd_byte
*) bfd_malloc (size
);
2107 /* I don't know what the next eight bytes are for. */
2108 if (bfd_bread (ab
, (bfd_size_type
) 8, nbfd
) != 8)
2111 /* This is the uncompression algorithm. It's a simple
2112 dictionary based scheme in which each character is predicted
2113 by a hash of the previous three characters. A control byte
2114 indicates whether the character is predicted or whether it
2115 appears in the input stream; each control byte manages the
2116 next eight bytes in the output stream. */
2117 memset (dict
, 0, sizeof dict
);
2119 while (bfd_bread (&b
, (bfd_size_type
) 1, nbfd
) == 1)
2123 for (i
= 0; i
< 8; i
++, b
>>= 1)
2131 if (bfd_bread (&n
, 1, nbfd
) != 1)
2144 h
&= sizeof dict
- 1;
2152 /* Now the uncompressed file contents are in buf. */
2153 bim
= ((struct bfd_in_memory
*)
2154 bfd_malloc ((bfd_size_type
) sizeof (struct bfd_in_memory
)));
2160 nbfd
->mtime_set
= TRUE
;
2161 nbfd
->mtime
= strtol (hdr
->ar_date
, (char **) NULL
, 10);
2163 nbfd
->flags
|= BFD_IN_MEMORY
;
2164 nbfd
->iostream
= bim
;
2165 nbfd
->iovec
= &_bfd_memory_iovec
;
2167 BFD_ASSERT (! nbfd
->cacheable
);
2178 /* Open the next archived file. */
2181 alpha_ecoff_openr_next_archived_file (bfd
*archive
, bfd
*last_file
)
2183 ufile_ptr filestart
;
2185 if (last_file
== NULL
)
2186 filestart
= bfd_ardata (archive
)->first_file_filepos
;
2189 struct areltdata
*t
;
2193 /* We can't use arelt_size here, because that uses parsed_size,
2194 which is the uncompressed size. We need the compressed size. */
2195 t
= (struct areltdata
*) last_file
->arelt_data
;
2196 h
= (struct ar_hdr
*) t
->arch_header
;
2197 size
= strtol (h
->ar_size
, (char **) NULL
, 10);
2199 /* Pad to an even boundary...
2200 Note that last_file->origin can be odd in the case of
2201 BSD-4.4-style element with a long odd size. */
2202 filestart
= last_file
->proxy_origin
+ size
;
2203 filestart
+= filestart
% 2;
2204 if (filestart
< last_file
->proxy_origin
)
2206 /* Prevent looping. See PR19256. */
2207 bfd_set_error (bfd_error_malformed_archive
);
2212 return alpha_ecoff_get_elt_at_filepos (archive
, filestart
);
2215 /* Open the archive file given an index into the armap. */
2218 alpha_ecoff_get_elt_at_index (bfd
*abfd
, symindex sym_index
)
2222 entry
= bfd_ardata (abfd
)->symdefs
+ sym_index
;
2223 return alpha_ecoff_get_elt_at_filepos (abfd
, entry
->file_offset
);
2227 alpha_ecoff_swap_coff_aux_in (bfd
*abfd ATTRIBUTE_UNUSED
,
2228 void *ext1 ATTRIBUTE_UNUSED
,
2229 int type ATTRIBUTE_UNUSED
,
2230 int in_class ATTRIBUTE_UNUSED
,
2231 int indx ATTRIBUTE_UNUSED
,
2232 int numaux ATTRIBUTE_UNUSED
,
2233 void *in1 ATTRIBUTE_UNUSED
)
2238 alpha_ecoff_swap_coff_sym_in (bfd
*abfd ATTRIBUTE_UNUSED
,
2239 void *ext1 ATTRIBUTE_UNUSED
,
2240 void *in1 ATTRIBUTE_UNUSED
)
2245 alpha_ecoff_swap_coff_lineno_in (bfd
*abfd ATTRIBUTE_UNUSED
,
2246 void *ext1 ATTRIBUTE_UNUSED
,
2247 void *in1 ATTRIBUTE_UNUSED
)
2252 alpha_ecoff_swap_coff_aux_out (bfd
*abfd ATTRIBUTE_UNUSED
,
2253 void *inp ATTRIBUTE_UNUSED
,
2254 int type ATTRIBUTE_UNUSED
,
2255 int in_class ATTRIBUTE_UNUSED
,
2256 int indx ATTRIBUTE_UNUSED
,
2257 int numaux ATTRIBUTE_UNUSED
,
2258 void *extp ATTRIBUTE_UNUSED
)
2264 alpha_ecoff_swap_coff_sym_out (bfd
*abfd ATTRIBUTE_UNUSED
,
2265 void *inp ATTRIBUTE_UNUSED
,
2266 void *extp ATTRIBUTE_UNUSED
)
2272 alpha_ecoff_swap_coff_lineno_out (bfd
*abfd ATTRIBUTE_UNUSED
,
2273 void *inp ATTRIBUTE_UNUSED
,
2274 void *extp ATTRIBUTE_UNUSED
)
2280 alpha_ecoff_swap_coff_reloc_out (bfd
*abfd ATTRIBUTE_UNUSED
,
2281 void *inp ATTRIBUTE_UNUSED
,
2282 void *extp ATTRIBUTE_UNUSED
)
2287 /* This is the ECOFF backend structure. The backend field of the
2288 target vector points to this. */
2290 static const struct ecoff_backend_data alpha_ecoff_backend_data
=
2292 /* COFF backend structure. */
2294 alpha_ecoff_swap_coff_aux_in
, alpha_ecoff_swap_coff_sym_in
,
2295 alpha_ecoff_swap_coff_lineno_in
, alpha_ecoff_swap_coff_aux_out
,
2296 alpha_ecoff_swap_coff_sym_out
, alpha_ecoff_swap_coff_lineno_out
,
2297 alpha_ecoff_swap_coff_reloc_out
,
2298 alpha_ecoff_swap_filehdr_out
, alpha_ecoff_swap_aouthdr_out
,
2299 alpha_ecoff_swap_scnhdr_out
,
2300 FILHSZ
, AOUTSZ
, SCNHSZ
, 0, 0, 0, 0, FILNMLEN
, TRUE
,
2301 ECOFF_NO_LONG_SECTION_NAMES
, 4, FALSE
, 2, 32768,
2302 alpha_ecoff_swap_filehdr_in
, alpha_ecoff_swap_aouthdr_in
,
2303 alpha_ecoff_swap_scnhdr_in
, NULL
,
2304 alpha_ecoff_bad_format_hook
, _bfd_ecoff_set_arch_mach_hook
,
2305 alpha_ecoff_mkobject_hook
, _bfd_ecoff_styp_to_sec_flags
,
2306 _bfd_ecoff_set_alignment_hook
, _bfd_ecoff_slurp_symbol_table
,
2307 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
2308 NULL
, NULL
, NULL
, NULL
2310 /* Supported architecture. */
2312 /* Initial portion of armap string. */
2314 /* The page boundary used to align sections in a demand-paged
2315 executable file. E.g., 0x1000. */
2317 /* TRUE if the .rdata section is part of the text segment, as on the
2318 Alpha. FALSE if .rdata is part of the data segment, as on the
2321 /* Bitsize of constructor entries. */
2323 /* Reloc to use for constructor entries. */
2324 &alpha_howto_table
[ALPHA_R_REFQUAD
],
2326 /* Symbol table magic number. */
2328 /* Alignment of debugging information. E.g., 4. */
2330 /* Sizes of external symbolic information. */
2331 sizeof (struct hdr_ext
),
2332 sizeof (struct dnr_ext
),
2333 sizeof (struct pdr_ext
),
2334 sizeof (struct sym_ext
),
2335 sizeof (struct opt_ext
),
2336 sizeof (struct fdr_ext
),
2337 sizeof (struct rfd_ext
),
2338 sizeof (struct ext_ext
),
2339 /* Functions to swap in external symbolic data. */
2348 _bfd_ecoff_swap_tir_in
,
2349 _bfd_ecoff_swap_rndx_in
,
2350 /* Functions to swap out external symbolic data. */
2359 _bfd_ecoff_swap_tir_out
,
2360 _bfd_ecoff_swap_rndx_out
,
2361 /* Function to read in symbolic data. */
2362 _bfd_ecoff_slurp_symbolic_info
2364 /* External reloc size. */
2366 /* Reloc swapping functions. */
2367 alpha_ecoff_swap_reloc_in
,
2368 alpha_ecoff_swap_reloc_out
,
2369 /* Backend reloc tweaking. */
2370 alpha_adjust_reloc_in
,
2371 alpha_adjust_reloc_out
,
2372 /* Relocate section contents while linking. */
2373 alpha_relocate_section
,
2374 /* Do final adjustments to filehdr and aouthdr. */
2375 alpha_adjust_headers
,
2376 /* Read an element from an archive at a given file position. */
2377 alpha_ecoff_get_elt_at_filepos
2380 /* Looking up a reloc type is Alpha specific. */
2381 #define _bfd_ecoff_bfd_reloc_type_lookup alpha_bfd_reloc_type_lookup
2382 #define _bfd_ecoff_bfd_reloc_name_lookup \
2383 alpha_bfd_reloc_name_lookup
2385 /* So is getting relocated section contents. */
2386 #define _bfd_ecoff_bfd_get_relocated_section_contents \
2387 alpha_ecoff_get_relocated_section_contents
2389 /* Handling file windows is generic. */
2390 #define _bfd_ecoff_get_section_contents_in_window \
2391 _bfd_generic_get_section_contents_in_window
2393 /* Input section flag lookup is generic. */
2394 #define _bfd_ecoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags
2396 /* Relaxing sections is generic. */
2397 #define _bfd_ecoff_bfd_relax_section bfd_generic_relax_section
2398 #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections
2399 #define _bfd_ecoff_bfd_merge_sections bfd_generic_merge_sections
2400 #define _bfd_ecoff_bfd_is_group_section bfd_generic_is_group_section
2401 #define _bfd_ecoff_bfd_group_name bfd_generic_group_name
2402 #define _bfd_ecoff_bfd_discard_group bfd_generic_discard_group
2403 #define _bfd_ecoff_section_already_linked \
2404 _bfd_coff_section_already_linked
2405 #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
2406 #define _bfd_ecoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
2407 #define _bfd_ecoff_bfd_define_start_stop bfd_generic_define_start_stop
2408 #define _bfd_ecoff_bfd_link_check_relocs _bfd_generic_link_check_relocs
2410 /* Installing internal relocations in a section is also generic. */
2411 #define _bfd_ecoff_set_reloc _bfd_generic_set_reloc
2413 const bfd_target alpha_ecoff_le_vec
=
2415 "ecoff-littlealpha", /* name */
2416 bfd_target_ecoff_flavour
,
2417 BFD_ENDIAN_LITTLE
, /* data byte order is little */
2418 BFD_ENDIAN_LITTLE
, /* header byte order is little */
2420 (HAS_RELOC
| EXEC_P
/* object flags */
2421 | HAS_LINENO
| HAS_DEBUG
2422 | HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
| D_PAGED
),
2424 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_CODE
2425 | SEC_DATA
| SEC_SMALL_DATA
),
2426 0, /* leading underscore */
2427 ' ', /* ar_pad_char */
2428 15, /* ar_max_namelen */
2429 0, /* match priority. */
2430 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
2431 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
2432 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* data */
2433 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
2434 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
2435 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* hdrs */
2437 { /* bfd_check_format */
2439 alpha_ecoff_object_p
,
2440 bfd_generic_archive_p
,
2443 { /* bfd_set_format */
2444 _bfd_bool_bfd_false_error
,
2445 _bfd_ecoff_mkobject
,
2446 _bfd_generic_mkarchive
,
2447 _bfd_bool_bfd_false_error
2449 { /* bfd_write_contents */
2450 _bfd_bool_bfd_false_error
,
2451 _bfd_ecoff_write_object_contents
,
2452 _bfd_write_archive_contents
,
2453 _bfd_bool_bfd_false_error
2456 BFD_JUMP_TABLE_GENERIC (_bfd_ecoff
),
2457 BFD_JUMP_TABLE_COPY (_bfd_ecoff
),
2458 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
2459 BFD_JUMP_TABLE_ARCHIVE (alpha_ecoff
),
2460 BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff
),
2461 BFD_JUMP_TABLE_RELOCS (_bfd_ecoff
),
2462 BFD_JUMP_TABLE_WRITE (_bfd_ecoff
),
2463 BFD_JUMP_TABLE_LINK (_bfd_ecoff
),
2464 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic
),
2468 &alpha_ecoff_backend_data