1 /* BFD back-end for ALPHA Extended-Coff files.
2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
5 Modified from coff-mips.c by Steve Chamberlain <sac@cygnus.com> and
6 Ian Lance Taylor <ian@cygnus.com>.
8 This file is part of BFD, the Binary File Descriptor library.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
23 MA 02110-1301, USA. */
29 #include "coff/internal.h"
31 #include "coff/symconst.h"
32 #include "coff/ecoff.h"
33 #include "coff/alpha.h"
38 /* Prototypes for static functions. */
40 static const bfd_target
*alpha_ecoff_object_p
42 static bfd_boolean alpha_ecoff_bad_format_hook
43 PARAMS ((bfd
*abfd
, PTR filehdr
));
44 static PTR alpha_ecoff_mkobject_hook
45 PARAMS ((bfd
*, PTR filehdr
, PTR aouthdr
));
46 static void alpha_ecoff_swap_reloc_in
47 PARAMS ((bfd
*, PTR
, struct internal_reloc
*));
48 static void alpha_ecoff_swap_reloc_out
49 PARAMS ((bfd
*, const struct internal_reloc
*, PTR
));
50 static void alpha_adjust_reloc_in
51 PARAMS ((bfd
*, const struct internal_reloc
*, arelent
*));
52 static void alpha_adjust_reloc_out
53 PARAMS ((bfd
*, const arelent
*, struct internal_reloc
*));
54 static reloc_howto_type
*alpha_bfd_reloc_type_lookup
55 PARAMS ((bfd
*, bfd_reloc_code_real_type
));
56 static bfd_byte
*alpha_ecoff_get_relocated_section_contents
57 PARAMS ((bfd
*abfd
, struct bfd_link_info
*, struct bfd_link_order
*,
58 bfd_byte
*data
, bfd_boolean relocatable
, asymbol
**symbols
));
59 static bfd_vma alpha_convert_external_reloc
60 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, struct external_reloc
*,
61 struct ecoff_link_hash_entry
*));
62 static bfd_boolean alpha_relocate_section
63 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*, PTR
));
64 static bfd_boolean alpha_adjust_headers
65 PARAMS ((bfd
*, struct internal_filehdr
*, struct internal_aouthdr
*));
66 static PTR alpha_ecoff_read_ar_hdr
68 static bfd
*alpha_ecoff_get_elt_at_filepos
69 PARAMS ((bfd
*, file_ptr
));
70 static bfd
*alpha_ecoff_openr_next_archived_file
71 PARAMS ((bfd
*, bfd
*));
72 static bfd
*alpha_ecoff_get_elt_at_index
73 PARAMS ((bfd
*, symindex
));
75 /* ECOFF has COFF sections, but the debugging information is stored in
76 a completely different format. ECOFF targets use some of the
77 swapping routines from coffswap.h, and some of the generic COFF
78 routines in coffgen.c, but, unlike the real COFF targets, do not
79 use coffcode.h itself.
81 Get the generic COFF swapping routines, except for the reloc,
82 symbol, and lineno ones. Give them ecoff names. Define some
83 accessor macros for the large sizes used for Alpha ECOFF. */
85 #define GET_FILEHDR_SYMPTR H_GET_64
86 #define PUT_FILEHDR_SYMPTR H_PUT_64
87 #define GET_AOUTHDR_TSIZE H_GET_64
88 #define PUT_AOUTHDR_TSIZE H_PUT_64
89 #define GET_AOUTHDR_DSIZE H_GET_64
90 #define PUT_AOUTHDR_DSIZE H_PUT_64
91 #define GET_AOUTHDR_BSIZE H_GET_64
92 #define PUT_AOUTHDR_BSIZE H_PUT_64
93 #define GET_AOUTHDR_ENTRY H_GET_64
94 #define PUT_AOUTHDR_ENTRY H_PUT_64
95 #define GET_AOUTHDR_TEXT_START H_GET_64
96 #define PUT_AOUTHDR_TEXT_START H_PUT_64
97 #define GET_AOUTHDR_DATA_START H_GET_64
98 #define PUT_AOUTHDR_DATA_START H_PUT_64
99 #define GET_SCNHDR_PADDR H_GET_64
100 #define PUT_SCNHDR_PADDR H_PUT_64
101 #define GET_SCNHDR_VADDR H_GET_64
102 #define PUT_SCNHDR_VADDR H_PUT_64
103 #define GET_SCNHDR_SIZE H_GET_64
104 #define PUT_SCNHDR_SIZE H_PUT_64
105 #define GET_SCNHDR_SCNPTR H_GET_64
106 #define PUT_SCNHDR_SCNPTR H_PUT_64
107 #define GET_SCNHDR_RELPTR H_GET_64
108 #define PUT_SCNHDR_RELPTR H_PUT_64
109 #define GET_SCNHDR_LNNOPTR H_GET_64
110 #define PUT_SCNHDR_LNNOPTR H_PUT_64
114 #define NO_COFF_RELOCS
115 #define NO_COFF_SYMBOLS
116 #define NO_COFF_LINENOS
117 #define coff_swap_filehdr_in alpha_ecoff_swap_filehdr_in
118 #define coff_swap_filehdr_out alpha_ecoff_swap_filehdr_out
119 #define coff_swap_aouthdr_in alpha_ecoff_swap_aouthdr_in
120 #define coff_swap_aouthdr_out alpha_ecoff_swap_aouthdr_out
121 #define coff_swap_scnhdr_in alpha_ecoff_swap_scnhdr_in
122 #define coff_swap_scnhdr_out alpha_ecoff_swap_scnhdr_out
123 #include "coffswap.h"
125 /* Get the ECOFF swapping routines. */
127 #include "ecoffswap.h"
129 /* How to process the various reloc types. */
131 static bfd_reloc_status_type reloc_nil
132 PARAMS ((bfd
*, arelent
*, asymbol
*, PTR
, asection
*, bfd
*, char **));
134 static bfd_reloc_status_type
135 reloc_nil (abfd
, reloc
, sym
, data
, sec
, output_bfd
, error_message
)
136 bfd
*abfd ATTRIBUTE_UNUSED
;
137 arelent
*reloc ATTRIBUTE_UNUSED
;
138 asymbol
*sym ATTRIBUTE_UNUSED
;
139 PTR data ATTRIBUTE_UNUSED
;
140 asection
*sec ATTRIBUTE_UNUSED
;
141 bfd
*output_bfd ATTRIBUTE_UNUSED
;
142 char **error_message ATTRIBUTE_UNUSED
;
147 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
148 from smaller values. Start with zero, widen, *then* decrement. */
149 #define MINUS_ONE (((bfd_vma)0) - 1)
151 static reloc_howto_type alpha_howto_table
[] =
153 /* Reloc type 0 is ignored by itself. However, it appears after a
154 GPDISP reloc to identify the location where the low order 16 bits
155 of the gp register are loaded. */
156 HOWTO (ALPHA_R_IGNORE
, /* type */
158 0, /* size (0 = byte, 1 = short, 2 = long) */
160 TRUE
, /* pc_relative */
162 complain_overflow_dont
, /* complain_on_overflow */
163 reloc_nil
, /* special_function */
165 TRUE
, /* partial_inplace */
168 TRUE
), /* pcrel_offset */
170 /* A 32 bit reference to a symbol. */
171 HOWTO (ALPHA_R_REFLONG
, /* type */
173 2, /* size (0 = byte, 1 = short, 2 = long) */
175 FALSE
, /* pc_relative */
177 complain_overflow_bitfield
, /* complain_on_overflow */
178 0, /* special_function */
179 "REFLONG", /* name */
180 TRUE
, /* partial_inplace */
181 0xffffffff, /* src_mask */
182 0xffffffff, /* dst_mask */
183 FALSE
), /* pcrel_offset */
185 /* A 64 bit reference to a symbol. */
186 HOWTO (ALPHA_R_REFQUAD
, /* type */
188 4, /* size (0 = byte, 1 = short, 2 = long) */
190 FALSE
, /* pc_relative */
192 complain_overflow_bitfield
, /* complain_on_overflow */
193 0, /* special_function */
194 "REFQUAD", /* name */
195 TRUE
, /* partial_inplace */
196 MINUS_ONE
, /* src_mask */
197 MINUS_ONE
, /* dst_mask */
198 FALSE
), /* pcrel_offset */
200 /* A 32 bit GP relative offset. This is just like REFLONG except
201 that when the value is used the value of the gp register will be
203 HOWTO (ALPHA_R_GPREL32
, /* type */
205 2, /* size (0 = byte, 1 = short, 2 = long) */
207 FALSE
, /* pc_relative */
209 complain_overflow_bitfield
, /* complain_on_overflow */
210 0, /* special_function */
211 "GPREL32", /* name */
212 TRUE
, /* partial_inplace */
213 0xffffffff, /* src_mask */
214 0xffffffff, /* dst_mask */
215 FALSE
), /* pcrel_offset */
217 /* Used for an instruction that refers to memory off the GP
218 register. The offset is 16 bits of the 32 bit instruction. This
219 reloc always seems to be against the .lita section. */
220 HOWTO (ALPHA_R_LITERAL
, /* type */
222 2, /* size (0 = byte, 1 = short, 2 = long) */
224 FALSE
, /* pc_relative */
226 complain_overflow_signed
, /* complain_on_overflow */
227 0, /* special_function */
228 "LITERAL", /* name */
229 TRUE
, /* partial_inplace */
230 0xffff, /* src_mask */
231 0xffff, /* dst_mask */
232 FALSE
), /* pcrel_offset */
234 /* This reloc only appears immediately following a LITERAL reloc.
235 It identifies a use of the literal. It seems that the linker can
236 use this to eliminate a portion of the .lita section. The symbol
237 index is special: 1 means the literal address is in the base
238 register of a memory format instruction; 2 means the literal
239 address is in the byte offset register of a byte-manipulation
240 instruction; 3 means the literal address is in the target
241 register of a jsr instruction. This does not actually do any
243 HOWTO (ALPHA_R_LITUSE
, /* type */
245 2, /* size (0 = byte, 1 = short, 2 = long) */
247 FALSE
, /* pc_relative */
249 complain_overflow_dont
, /* complain_on_overflow */
250 reloc_nil
, /* special_function */
252 FALSE
, /* partial_inplace */
255 FALSE
), /* pcrel_offset */
257 /* Load the gp register. This is always used for a ldah instruction
258 which loads the upper 16 bits of the gp register. The next reloc
259 will be an IGNORE reloc which identifies the location of the lda
260 instruction which loads the lower 16 bits. The symbol index of
261 the GPDISP instruction appears to actually be the number of bytes
262 between the ldah and lda instructions. This gives two different
263 ways to determine where the lda instruction is; I don't know why
264 both are used. The value to use for the relocation is the
265 difference between the GP value and the current location; the
266 load will always be done against a register holding the current
268 HOWTO (ALPHA_R_GPDISP
, /* type */
270 2, /* size (0 = byte, 1 = short, 2 = long) */
272 TRUE
, /* pc_relative */
274 complain_overflow_dont
, /* complain_on_overflow */
275 reloc_nil
, /* special_function */
277 TRUE
, /* partial_inplace */
278 0xffff, /* src_mask */
279 0xffff, /* dst_mask */
280 TRUE
), /* pcrel_offset */
282 /* A 21 bit branch. The native assembler generates these for
283 branches within the text segment, and also fills in the PC
284 relative offset in the instruction. */
285 HOWTO (ALPHA_R_BRADDR
, /* type */
287 2, /* size (0 = byte, 1 = short, 2 = long) */
289 TRUE
, /* pc_relative */
291 complain_overflow_signed
, /* complain_on_overflow */
292 0, /* special_function */
294 TRUE
, /* partial_inplace */
295 0x1fffff, /* src_mask */
296 0x1fffff, /* dst_mask */
297 FALSE
), /* pcrel_offset */
299 /* A hint for a jump to a register. */
300 HOWTO (ALPHA_R_HINT
, /* type */
302 2, /* size (0 = byte, 1 = short, 2 = long) */
304 TRUE
, /* pc_relative */
306 complain_overflow_dont
, /* complain_on_overflow */
307 0, /* special_function */
309 TRUE
, /* partial_inplace */
310 0x3fff, /* src_mask */
311 0x3fff, /* dst_mask */
312 FALSE
), /* pcrel_offset */
314 /* 16 bit PC relative offset. */
315 HOWTO (ALPHA_R_SREL16
, /* type */
317 1, /* size (0 = byte, 1 = short, 2 = long) */
319 TRUE
, /* pc_relative */
321 complain_overflow_signed
, /* complain_on_overflow */
322 0, /* special_function */
324 TRUE
, /* partial_inplace */
325 0xffff, /* src_mask */
326 0xffff, /* dst_mask */
327 FALSE
), /* pcrel_offset */
329 /* 32 bit PC relative offset. */
330 HOWTO (ALPHA_R_SREL32
, /* type */
332 2, /* size (0 = byte, 1 = short, 2 = long) */
334 TRUE
, /* pc_relative */
336 complain_overflow_signed
, /* complain_on_overflow */
337 0, /* special_function */
339 TRUE
, /* partial_inplace */
340 0xffffffff, /* src_mask */
341 0xffffffff, /* dst_mask */
342 FALSE
), /* pcrel_offset */
344 /* A 64 bit PC relative offset. */
345 HOWTO (ALPHA_R_SREL64
, /* type */
347 4, /* size (0 = byte, 1 = short, 2 = long) */
349 TRUE
, /* pc_relative */
351 complain_overflow_signed
, /* complain_on_overflow */
352 0, /* special_function */
354 TRUE
, /* partial_inplace */
355 MINUS_ONE
, /* src_mask */
356 MINUS_ONE
, /* dst_mask */
357 FALSE
), /* pcrel_offset */
359 /* Push a value on the reloc evaluation stack. */
360 HOWTO (ALPHA_R_OP_PUSH
, /* type */
362 0, /* size (0 = byte, 1 = short, 2 = long) */
364 FALSE
, /* pc_relative */
366 complain_overflow_dont
, /* complain_on_overflow */
367 0, /* special_function */
368 "OP_PUSH", /* name */
369 FALSE
, /* partial_inplace */
372 FALSE
), /* pcrel_offset */
374 /* Store the value from the stack at the given address. Store it in
375 a bitfield of size r_size starting at bit position r_offset. */
376 HOWTO (ALPHA_R_OP_STORE
, /* type */
378 4, /* size (0 = byte, 1 = short, 2 = long) */
380 FALSE
, /* pc_relative */
382 complain_overflow_dont
, /* complain_on_overflow */
383 0, /* special_function */
384 "OP_STORE", /* name */
385 FALSE
, /* partial_inplace */
387 MINUS_ONE
, /* dst_mask */
388 FALSE
), /* pcrel_offset */
390 /* Subtract the reloc address from the value on the top of the
392 HOWTO (ALPHA_R_OP_PSUB
, /* type */
394 0, /* size (0 = byte, 1 = short, 2 = long) */
396 FALSE
, /* pc_relative */
398 complain_overflow_dont
, /* complain_on_overflow */
399 0, /* special_function */
400 "OP_PSUB", /* name */
401 FALSE
, /* partial_inplace */
404 FALSE
), /* pcrel_offset */
406 /* Shift the value on the top of the relocation stack right by the
408 HOWTO (ALPHA_R_OP_PRSHIFT
, /* type */
410 0, /* size (0 = byte, 1 = short, 2 = long) */
412 FALSE
, /* pc_relative */
414 complain_overflow_dont
, /* complain_on_overflow */
415 0, /* special_function */
416 "OP_PRSHIFT", /* name */
417 FALSE
, /* partial_inplace */
420 FALSE
), /* pcrel_offset */
422 /* Adjust the GP value for a new range in the object file. */
423 HOWTO (ALPHA_R_GPVALUE
, /* type */
425 0, /* size (0 = byte, 1 = short, 2 = long) */
427 FALSE
, /* pc_relative */
429 complain_overflow_dont
, /* complain_on_overflow */
430 0, /* special_function */
431 "GPVALUE", /* name */
432 FALSE
, /* partial_inplace */
435 FALSE
) /* pcrel_offset */
438 /* Recognize an Alpha ECOFF file. */
440 static const bfd_target
*
441 alpha_ecoff_object_p (abfd
)
444 static const bfd_target
*ret
;
446 ret
= coff_object_p (abfd
);
452 /* Alpha ECOFF has a .pdata section. The lnnoptr field of the
453 .pdata section is the number of entries it contains. Each
454 entry takes up 8 bytes. The number of entries is required
455 since the section is aligned to a 16 byte boundary. When we
456 link .pdata sections together, we do not want to include the
457 alignment bytes. We handle this on input by faking the size
458 of the .pdata section to remove the unwanted alignment bytes.
459 On output we will set the lnnoptr field and force the
461 sec
= bfd_get_section_by_name (abfd
, _PDATA
);
462 if (sec
!= (asection
*) NULL
)
466 size
= sec
->line_filepos
* 8;
467 BFD_ASSERT (size
== sec
->size
468 || size
+ 8 == sec
->size
);
469 if (! bfd_set_section_size (abfd
, sec
, size
))
477 /* See whether the magic number matches. */
480 alpha_ecoff_bad_format_hook (abfd
, filehdr
)
481 bfd
*abfd ATTRIBUTE_UNUSED
;
484 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
486 if (! ALPHA_ECOFF_BADMAG (*internal_f
))
489 if (ALPHA_ECOFF_COMPRESSEDMAG (*internal_f
))
490 (*_bfd_error_handler
)
491 (_("%B: Cannot handle compressed Alpha binaries.\n"
492 " Use compiler flags, or objZ, to generate uncompressed binaries."),
498 /* This is a hook called by coff_real_object_p to create any backend
499 specific information. */
502 alpha_ecoff_mkobject_hook (abfd
, filehdr
, aouthdr
)
509 ecoff
= _bfd_ecoff_mkobject_hook (abfd
, filehdr
, aouthdr
);
513 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
515 /* Set additional BFD flags according to the object type from the
516 machine specific file header flags. */
517 switch (internal_f
->f_flags
& F_ALPHA_OBJECT_TYPE_MASK
)
519 case F_ALPHA_SHARABLE
:
520 abfd
->flags
|= DYNAMIC
;
522 case F_ALPHA_CALL_SHARED
:
523 /* Always executable if using shared libraries as the run time
524 loader might resolve undefined references. */
525 abfd
->flags
|= (DYNAMIC
| EXEC_P
);
532 /* Reloc handling. */
534 /* Swap a reloc in. */
537 alpha_ecoff_swap_reloc_in (abfd
, ext_ptr
, intern
)
540 struct internal_reloc
*intern
;
542 const RELOC
*ext
= (RELOC
*) ext_ptr
;
544 intern
->r_vaddr
= H_GET_64 (abfd
, ext
->r_vaddr
);
545 intern
->r_symndx
= H_GET_32 (abfd
, ext
->r_symndx
);
547 BFD_ASSERT (bfd_header_little_endian (abfd
));
549 intern
->r_type
= ((ext
->r_bits
[0] & RELOC_BITS0_TYPE_LITTLE
)
550 >> RELOC_BITS0_TYPE_SH_LITTLE
);
551 intern
->r_extern
= (ext
->r_bits
[1] & RELOC_BITS1_EXTERN_LITTLE
) != 0;
552 intern
->r_offset
= ((ext
->r_bits
[1] & RELOC_BITS1_OFFSET_LITTLE
)
553 >> RELOC_BITS1_OFFSET_SH_LITTLE
);
554 /* Ignored the reserved bits. */
555 intern
->r_size
= ((ext
->r_bits
[3] & RELOC_BITS3_SIZE_LITTLE
)
556 >> RELOC_BITS3_SIZE_SH_LITTLE
);
558 if (intern
->r_type
== ALPHA_R_LITUSE
559 || intern
->r_type
== ALPHA_R_GPDISP
)
561 /* Handle the LITUSE and GPDISP relocs specially. Its symndx
562 value is not actually a symbol index, but is instead a
563 special code. We put the code in the r_size field, and
564 clobber the symndx. */
565 if (intern
->r_size
!= 0)
567 intern
->r_size
= intern
->r_symndx
;
568 intern
->r_symndx
= RELOC_SECTION_NONE
;
570 else if (intern
->r_type
== ALPHA_R_IGNORE
)
572 /* The IGNORE reloc generally follows a GPDISP reloc, and is
573 against the .lita section. The section is irrelevant. */
574 if (! intern
->r_extern
&&
575 intern
->r_symndx
== RELOC_SECTION_ABS
)
577 if (! intern
->r_extern
&& intern
->r_symndx
== RELOC_SECTION_LITA
)
578 intern
->r_symndx
= RELOC_SECTION_ABS
;
582 /* Swap a reloc out. */
585 alpha_ecoff_swap_reloc_out (abfd
, intern
, dst
)
587 const struct internal_reloc
*intern
;
590 RELOC
*ext
= (RELOC
*) dst
;
594 /* Undo the hackery done in swap_reloc_in. */
595 if (intern
->r_type
== ALPHA_R_LITUSE
596 || intern
->r_type
== ALPHA_R_GPDISP
)
598 symndx
= intern
->r_size
;
601 else if (intern
->r_type
== ALPHA_R_IGNORE
602 && ! intern
->r_extern
603 && intern
->r_symndx
== RELOC_SECTION_ABS
)
605 symndx
= RELOC_SECTION_LITA
;
606 size
= intern
->r_size
;
610 symndx
= intern
->r_symndx
;
611 size
= intern
->r_size
;
614 /* XXX FIXME: The maximum symndx value used to be 14 but this
615 fails with object files produced by DEC's C++ compiler.
616 Where does the value 14 (or 15) come from anyway ? */
617 BFD_ASSERT (intern
->r_extern
618 || (intern
->r_symndx
>= 0 && intern
->r_symndx
<= 15));
620 H_PUT_64 (abfd
, intern
->r_vaddr
, ext
->r_vaddr
);
621 H_PUT_32 (abfd
, symndx
, ext
->r_symndx
);
623 BFD_ASSERT (bfd_header_little_endian (abfd
));
625 ext
->r_bits
[0] = ((intern
->r_type
<< RELOC_BITS0_TYPE_SH_LITTLE
)
626 & RELOC_BITS0_TYPE_LITTLE
);
627 ext
->r_bits
[1] = ((intern
->r_extern
? RELOC_BITS1_EXTERN_LITTLE
: 0)
628 | ((intern
->r_offset
<< RELOC_BITS1_OFFSET_SH_LITTLE
)
629 & RELOC_BITS1_OFFSET_LITTLE
));
631 ext
->r_bits
[3] = ((size
<< RELOC_BITS3_SIZE_SH_LITTLE
)
632 & RELOC_BITS3_SIZE_LITTLE
);
635 /* Finish canonicalizing a reloc. Part of this is generic to all
636 ECOFF targets, and that part is in ecoff.c. The rest is done in
637 this backend routine. It must fill in the howto field. */
640 alpha_adjust_reloc_in (abfd
, intern
, rptr
)
642 const struct internal_reloc
*intern
;
645 if (intern
->r_type
> ALPHA_R_GPVALUE
)
647 (*_bfd_error_handler
)
648 (_("%B: unknown/unsupported relocation type %d"),
649 abfd
, intern
->r_type
);
650 bfd_set_error (bfd_error_bad_value
);
656 switch (intern
->r_type
)
662 /* This relocs appear to be fully resolved when they are against
663 internal symbols. Against external symbols, BRADDR at least
664 appears to be resolved against the next instruction. */
665 if (! intern
->r_extern
)
668 rptr
->addend
= - (intern
->r_vaddr
+ 4);
671 case ALPHA_R_GPREL32
:
672 case ALPHA_R_LITERAL
:
673 /* Copy the gp value for this object file into the addend, to
674 ensure that we are not confused by the linker. */
675 if (! intern
->r_extern
)
676 rptr
->addend
+= ecoff_data (abfd
)->gp
;
681 /* The LITUSE and GPDISP relocs do not use a symbol, or an
682 addend, but they do use a special code. Put this code in the
684 rptr
->addend
= intern
->r_size
;
687 case ALPHA_R_OP_STORE
:
688 /* The STORE reloc needs the size and offset fields. We store
689 them in the addend. */
690 BFD_ASSERT (intern
->r_offset
<= 256);
691 rptr
->addend
= (intern
->r_offset
<< 8) + intern
->r_size
;
694 case ALPHA_R_OP_PUSH
:
695 case ALPHA_R_OP_PSUB
:
696 case ALPHA_R_OP_PRSHIFT
:
697 /* The PUSH, PSUB and PRSHIFT relocs do not actually use an
698 address. I believe that the address supplied is really an
700 rptr
->addend
= intern
->r_vaddr
;
703 case ALPHA_R_GPVALUE
:
704 /* Set the addend field to the new GP value. */
705 rptr
->addend
= intern
->r_symndx
+ ecoff_data (abfd
)->gp
;
709 /* If the type is ALPHA_R_IGNORE, make sure this is a reference
710 to the absolute section so that the reloc is ignored. For
711 some reason the address of this reloc type is not adjusted by
712 the section vma. We record the gp value for this object file
713 here, for convenience when doing the GPDISP relocation. */
714 rptr
->sym_ptr_ptr
= bfd_abs_section_ptr
->symbol_ptr_ptr
;
715 rptr
->address
= intern
->r_vaddr
;
716 rptr
->addend
= ecoff_data (abfd
)->gp
;
723 rptr
->howto
= &alpha_howto_table
[intern
->r_type
];
726 /* When writing out a reloc we need to pull some values back out of
727 the addend field into the reloc. This is roughly the reverse of
728 alpha_adjust_reloc_in, except that there are several changes we do
732 alpha_adjust_reloc_out (abfd
, rel
, intern
)
733 bfd
*abfd ATTRIBUTE_UNUSED
;
735 struct internal_reloc
*intern
;
737 switch (intern
->r_type
)
741 intern
->r_size
= rel
->addend
;
744 case ALPHA_R_OP_STORE
:
745 intern
->r_size
= rel
->addend
& 0xff;
746 intern
->r_offset
= (rel
->addend
>> 8) & 0xff;
749 case ALPHA_R_OP_PUSH
:
750 case ALPHA_R_OP_PSUB
:
751 case ALPHA_R_OP_PRSHIFT
:
752 intern
->r_vaddr
= rel
->addend
;
756 intern
->r_vaddr
= rel
->address
;
764 /* The size of the stack for the relocation evaluator. */
765 #define RELOC_STACKSIZE (10)
767 /* Alpha ECOFF relocs have a built in expression evaluator as well as
768 other interdependencies. Rather than use a bunch of special
769 functions and global variables, we use a single routine to do all
770 the relocation for a section. I haven't yet worked out how the
771 assembler is going to handle this. */
774 alpha_ecoff_get_relocated_section_contents (abfd
, link_info
, link_order
,
775 data
, relocatable
, symbols
)
777 struct bfd_link_info
*link_info
;
778 struct bfd_link_order
*link_order
;
780 bfd_boolean relocatable
;
783 bfd
*input_bfd
= link_order
->u
.indirect
.section
->owner
;
784 asection
*input_section
= link_order
->u
.indirect
.section
;
785 long reloc_size
= bfd_get_reloc_upper_bound (input_bfd
, input_section
);
786 arelent
**reloc_vector
= NULL
;
788 bfd
*output_bfd
= relocatable
? abfd
: (bfd
*) NULL
;
791 bfd_boolean gp_undefined
;
792 bfd_vma stack
[RELOC_STACKSIZE
];
797 reloc_vector
= (arelent
**) bfd_malloc ((bfd_size_type
) reloc_size
);
798 if (reloc_vector
== NULL
&& reloc_size
!= 0)
801 sz
= input_section
->rawsize
? input_section
->rawsize
: input_section
->size
;
802 if (! bfd_get_section_contents (input_bfd
, input_section
, data
, 0, sz
))
805 reloc_count
= bfd_canonicalize_reloc (input_bfd
, input_section
,
806 reloc_vector
, symbols
);
809 if (reloc_count
== 0)
810 goto successful_return
;
812 /* Get the GP value for the output BFD. */
813 gp_undefined
= FALSE
;
814 gp
= _bfd_get_gp_value (abfd
);
822 /* Make up a value. */
824 for (sec
= abfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
827 && (strcmp (sec
->name
, ".sbss") == 0
828 || strcmp (sec
->name
, ".sdata") == 0
829 || strcmp (sec
->name
, ".lit4") == 0
830 || strcmp (sec
->name
, ".lit8") == 0
831 || strcmp (sec
->name
, ".lita") == 0))
835 _bfd_set_gp_value (abfd
, gp
);
839 struct bfd_link_hash_entry
*h
;
841 h
= bfd_link_hash_lookup (link_info
->hash
, "_gp", FALSE
, FALSE
,
843 if (h
== (struct bfd_link_hash_entry
*) NULL
844 || h
->type
!= bfd_link_hash_defined
)
849 + h
->u
.def
.section
->output_section
->vma
850 + h
->u
.def
.section
->output_offset
);
851 _bfd_set_gp_value (abfd
, gp
);
856 for (; *reloc_vector
!= (arelent
*) NULL
; reloc_vector
++)
859 bfd_reloc_status_type r
;
864 switch (rel
->howto
->type
)
867 rel
->address
+= input_section
->output_offset
;
870 case ALPHA_R_REFLONG
:
871 case ALPHA_R_REFQUAD
:
878 && ((*rel
->sym_ptr_ptr
)->flags
& BSF_SECTION_SYM
) == 0)
880 rel
->address
+= input_section
->output_offset
;
883 r
= bfd_perform_relocation (input_bfd
, rel
, data
, input_section
,
887 case ALPHA_R_GPREL32
:
888 /* This relocation is used in a switch table. It is a 32
889 bit offset from the current GP value. We must adjust it
890 by the different between the original GP value and the
891 current GP value. The original GP value is stored in the
892 addend. We adjust the addend and let
893 bfd_perform_relocation finish the job. */
895 r
= bfd_perform_relocation (input_bfd
, rel
, data
, input_section
,
897 if (r
== bfd_reloc_ok
&& gp_undefined
)
899 r
= bfd_reloc_dangerous
;
900 err
= (char *) _("GP relative relocation used when GP not defined");
904 case ALPHA_R_LITERAL
:
905 /* This is a reference to a literal value, generally
906 (always?) in the .lita section. This is a 16 bit GP
907 relative relocation. Sometimes the subsequent reloc is a
908 LITUSE reloc, which indicates how this reloc is used.
909 This sometimes permits rewriting the two instructions
910 referred to by the LITERAL and the LITUSE into different
911 instructions which do not refer to .lita. This can save
912 a memory reference, and permits removing a value from
913 .lita thus saving GP relative space.
915 We do not these optimizations. To do them we would need
916 to arrange to link the .lita section first, so that by
917 the time we got here we would know the final values to
918 use. This would not be particularly difficult, but it is
919 not currently implemented. */
924 /* I believe that the LITERAL reloc will only apply to a
925 ldq or ldl instruction, so check my assumption. */
926 insn
= bfd_get_32 (input_bfd
, data
+ rel
->address
);
927 BFD_ASSERT (((insn
>> 26) & 0x3f) == 0x29
928 || ((insn
>> 26) & 0x3f) == 0x28);
931 r
= bfd_perform_relocation (input_bfd
, rel
, data
, input_section
,
933 if (r
== bfd_reloc_ok
&& gp_undefined
)
935 r
= bfd_reloc_dangerous
;
937 (char *) _("GP relative relocation used when GP not defined");
943 /* See ALPHA_R_LITERAL above for the uses of this reloc. It
944 does not cause anything to happen, itself. */
945 rel
->address
+= input_section
->output_offset
;
949 /* This marks the ldah of an ldah/lda pair which loads the
950 gp register with the difference of the gp value and the
951 current location. The second of the pair is r_size bytes
952 ahead; it used to be marked with an ALPHA_R_IGNORE reloc,
953 but that no longer happens in OSF/1 3.2. */
955 unsigned long insn1
, insn2
;
958 /* Get the two instructions. */
959 insn1
= bfd_get_32 (input_bfd
, data
+ rel
->address
);
960 insn2
= bfd_get_32 (input_bfd
, data
+ rel
->address
+ rel
->addend
);
962 BFD_ASSERT (((insn1
>> 26) & 0x3f) == 0x09); /* ldah */
963 BFD_ASSERT (((insn2
>> 26) & 0x3f) == 0x08); /* lda */
965 /* Get the existing addend. We must account for the sign
966 extension done by lda and ldah. */
967 addend
= ((insn1
& 0xffff) << 16) + (insn2
& 0xffff);
970 addend
-= 0x80000000;
971 addend
-= 0x80000000;
976 /* The existing addend includes the different between the
977 gp of the input BFD and the address in the input BFD.
978 Subtract this out. */
979 addend
-= (ecoff_data (input_bfd
)->gp
980 - (input_section
->vma
+ rel
->address
));
982 /* Now add in the final gp value, and subtract out the
985 - (input_section
->output_section
->vma
986 + input_section
->output_offset
989 /* Change the instructions, accounting for the sign
990 extension, and write them out. */
993 insn1
= (insn1
& 0xffff0000) | ((addend
>> 16) & 0xffff);
994 insn2
= (insn2
& 0xffff0000) | (addend
& 0xffff);
996 bfd_put_32 (input_bfd
, (bfd_vma
) insn1
, data
+ rel
->address
);
997 bfd_put_32 (input_bfd
, (bfd_vma
) insn2
,
998 data
+ rel
->address
+ rel
->addend
);
1000 rel
->address
+= input_section
->output_offset
;
1004 case ALPHA_R_OP_PUSH
:
1005 /* Push a value on the reloc evaluation stack. */
1012 rel
->address
+= input_section
->output_offset
;
1016 /* Figure out the relocation of this symbol. */
1017 symbol
= *rel
->sym_ptr_ptr
;
1019 if (bfd_is_und_section (symbol
->section
))
1020 r
= bfd_reloc_undefined
;
1022 if (bfd_is_com_section (symbol
->section
))
1025 relocation
= symbol
->value
;
1026 relocation
+= symbol
->section
->output_section
->vma
;
1027 relocation
+= symbol
->section
->output_offset
;
1028 relocation
+= rel
->addend
;
1030 if (tos
>= RELOC_STACKSIZE
)
1033 stack
[tos
++] = relocation
;
1037 case ALPHA_R_OP_STORE
:
1038 /* Store a value from the reloc stack into a bitfield. */
1045 rel
->address
+= input_section
->output_offset
;
1052 /* The offset and size for this reloc are encoded into the
1053 addend field by alpha_adjust_reloc_in. */
1054 offset
= (rel
->addend
>> 8) & 0xff;
1055 size
= rel
->addend
& 0xff;
1057 val
= bfd_get_64 (abfd
, data
+ rel
->address
);
1058 val
&=~ (((1 << size
) - 1) << offset
);
1059 val
|= (stack
[--tos
] & ((1 << size
) - 1)) << offset
;
1060 bfd_put_64 (abfd
, val
, data
+ rel
->address
);
1064 case ALPHA_R_OP_PSUB
:
1065 /* Subtract a value from the top of the stack. */
1072 rel
->address
+= input_section
->output_offset
;
1076 /* Figure out the relocation of this symbol. */
1077 symbol
= *rel
->sym_ptr_ptr
;
1079 if (bfd_is_und_section (symbol
->section
))
1080 r
= bfd_reloc_undefined
;
1082 if (bfd_is_com_section (symbol
->section
))
1085 relocation
= symbol
->value
;
1086 relocation
+= symbol
->section
->output_section
->vma
;
1087 relocation
+= symbol
->section
->output_offset
;
1088 relocation
+= rel
->addend
;
1093 stack
[tos
- 1] -= relocation
;
1097 case ALPHA_R_OP_PRSHIFT
:
1098 /* Shift the value on the top of the stack. */
1105 rel
->address
+= input_section
->output_offset
;
1109 /* Figure out the relocation of this symbol. */
1110 symbol
= *rel
->sym_ptr_ptr
;
1112 if (bfd_is_und_section (symbol
->section
))
1113 r
= bfd_reloc_undefined
;
1115 if (bfd_is_com_section (symbol
->section
))
1118 relocation
= symbol
->value
;
1119 relocation
+= symbol
->section
->output_section
->vma
;
1120 relocation
+= symbol
->section
->output_offset
;
1121 relocation
+= rel
->addend
;
1126 stack
[tos
- 1] >>= relocation
;
1130 case ALPHA_R_GPVALUE
:
1131 /* I really don't know if this does the right thing. */
1133 gp_undefined
= FALSE
;
1142 asection
*os
= input_section
->output_section
;
1144 /* A partial link, so keep the relocs. */
1145 os
->orelocation
[os
->reloc_count
] = rel
;
1149 if (r
!= bfd_reloc_ok
)
1153 case bfd_reloc_undefined
:
1154 if (! ((*link_info
->callbacks
->undefined_symbol
)
1155 (link_info
, bfd_asymbol_name (*rel
->sym_ptr_ptr
),
1156 input_bfd
, input_section
, rel
->address
, TRUE
)))
1159 case bfd_reloc_dangerous
:
1160 if (! ((*link_info
->callbacks
->reloc_dangerous
)
1161 (link_info
, err
, input_bfd
, input_section
,
1165 case bfd_reloc_overflow
:
1166 if (! ((*link_info
->callbacks
->reloc_overflow
)
1168 bfd_asymbol_name (*rel
->sym_ptr_ptr
),
1169 rel
->howto
->name
, rel
->addend
, input_bfd
,
1170 input_section
, rel
->address
)))
1173 case bfd_reloc_outofrange
:
1185 if (reloc_vector
!= NULL
)
1186 free (reloc_vector
);
1190 if (reloc_vector
!= NULL
)
1191 free (reloc_vector
);
1195 /* Get the howto structure for a generic reloc type. */
1197 static reloc_howto_type
*
1198 alpha_bfd_reloc_type_lookup (abfd
, code
)
1199 bfd
*abfd ATTRIBUTE_UNUSED
;
1200 bfd_reloc_code_real_type code
;
1207 alpha_type
= ALPHA_R_REFLONG
;
1210 case BFD_RELOC_CTOR
:
1211 alpha_type
= ALPHA_R_REFQUAD
;
1213 case BFD_RELOC_GPREL32
:
1214 alpha_type
= ALPHA_R_GPREL32
;
1216 case BFD_RELOC_ALPHA_LITERAL
:
1217 alpha_type
= ALPHA_R_LITERAL
;
1219 case BFD_RELOC_ALPHA_LITUSE
:
1220 alpha_type
= ALPHA_R_LITUSE
;
1222 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1223 alpha_type
= ALPHA_R_GPDISP
;
1225 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1226 alpha_type
= ALPHA_R_IGNORE
;
1228 case BFD_RELOC_23_PCREL_S2
:
1229 alpha_type
= ALPHA_R_BRADDR
;
1231 case BFD_RELOC_ALPHA_HINT
:
1232 alpha_type
= ALPHA_R_HINT
;
1234 case BFD_RELOC_16_PCREL
:
1235 alpha_type
= ALPHA_R_SREL16
;
1237 case BFD_RELOC_32_PCREL
:
1238 alpha_type
= ALPHA_R_SREL32
;
1240 case BFD_RELOC_64_PCREL
:
1241 alpha_type
= ALPHA_R_SREL64
;
1244 return (reloc_howto_type
*) NULL
;
1247 return &alpha_howto_table
[alpha_type
];
1250 static reloc_howto_type
*
1251 alpha_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1257 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
1259 if (alpha_howto_table
[i
].name
!= NULL
1260 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
1261 return &alpha_howto_table
[i
];
1266 /* A helper routine for alpha_relocate_section which converts an
1267 external reloc when generating relocatable output. Returns the
1268 relocation amount. */
1271 alpha_convert_external_reloc (output_bfd
, info
, input_bfd
, ext_rel
, h
)
1272 bfd
*output_bfd ATTRIBUTE_UNUSED
;
1273 struct bfd_link_info
*info
;
1275 struct external_reloc
*ext_rel
;
1276 struct ecoff_link_hash_entry
*h
;
1278 unsigned long r_symndx
;
1281 BFD_ASSERT (info
->relocatable
);
1283 if (h
->root
.type
== bfd_link_hash_defined
1284 || h
->root
.type
== bfd_link_hash_defweak
)
1289 /* This symbol is defined in the output. Convert the reloc from
1290 being against the symbol to being against the section. */
1292 /* Clear the r_extern bit. */
1293 ext_rel
->r_bits
[1] &=~ RELOC_BITS1_EXTERN_LITTLE
;
1295 /* Compute a new r_symndx value. */
1296 hsec
= h
->root
.u
.def
.section
;
1297 name
= bfd_get_section_name (output_bfd
, hsec
->output_section
);
1299 r_symndx
= (unsigned long) -1;
1303 if (strcmp (name
, "*ABS*") == 0)
1304 r_symndx
= RELOC_SECTION_ABS
;
1307 if (strcmp (name
, ".bss") == 0)
1308 r_symndx
= RELOC_SECTION_BSS
;
1311 if (strcmp (name
, ".data") == 0)
1312 r_symndx
= RELOC_SECTION_DATA
;
1315 if (strcmp (name
, ".fini") == 0)
1316 r_symndx
= RELOC_SECTION_FINI
;
1319 if (strcmp (name
, ".init") == 0)
1320 r_symndx
= RELOC_SECTION_INIT
;
1323 if (strcmp (name
, ".lita") == 0)
1324 r_symndx
= RELOC_SECTION_LITA
;
1325 else if (strcmp (name
, ".lit8") == 0)
1326 r_symndx
= RELOC_SECTION_LIT8
;
1327 else if (strcmp (name
, ".lit4") == 0)
1328 r_symndx
= RELOC_SECTION_LIT4
;
1331 if (strcmp (name
, ".pdata") == 0)
1332 r_symndx
= RELOC_SECTION_PDATA
;
1335 if (strcmp (name
, ".rdata") == 0)
1336 r_symndx
= RELOC_SECTION_RDATA
;
1337 else if (strcmp (name
, ".rconst") == 0)
1338 r_symndx
= RELOC_SECTION_RCONST
;
1341 if (strcmp (name
, ".sdata") == 0)
1342 r_symndx
= RELOC_SECTION_SDATA
;
1343 else if (strcmp (name
, ".sbss") == 0)
1344 r_symndx
= RELOC_SECTION_SBSS
;
1347 if (strcmp (name
, ".text") == 0)
1348 r_symndx
= RELOC_SECTION_TEXT
;
1351 if (strcmp (name
, ".xdata") == 0)
1352 r_symndx
= RELOC_SECTION_XDATA
;
1356 if (r_symndx
== (unsigned long) -1)
1359 /* Add the section VMA and the symbol value. */
1360 relocation
= (h
->root
.u
.def
.value
1361 + hsec
->output_section
->vma
1362 + hsec
->output_offset
);
1366 /* Change the symndx value to the right one for
1369 if (r_symndx
== (unsigned long) -1)
1371 /* Caller must give an error. */
1377 /* Write out the new r_symndx value. */
1378 H_PUT_32 (input_bfd
, r_symndx
, ext_rel
->r_symndx
);
1383 /* Relocate a section while linking an Alpha ECOFF file. This is
1384 quite similar to get_relocated_section_contents. Perhaps they
1385 could be combined somehow. */
1388 alpha_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
1389 contents
, external_relocs
)
1391 struct bfd_link_info
*info
;
1393 asection
*input_section
;
1395 PTR external_relocs
;
1397 asection
**symndx_to_section
, *lita_sec
;
1398 struct ecoff_link_hash_entry
**sym_hashes
;
1400 bfd_boolean gp_undefined
;
1401 bfd_vma stack
[RELOC_STACKSIZE
];
1403 struct external_reloc
*ext_rel
;
1404 struct external_reloc
*ext_rel_end
;
1407 /* We keep a table mapping the symndx found in an internal reloc to
1408 the appropriate section. This is faster than looking up the
1409 section by name each time. */
1410 symndx_to_section
= ecoff_data (input_bfd
)->symndx_to_section
;
1411 if (symndx_to_section
== (asection
**) NULL
)
1413 amt
= NUM_RELOC_SECTIONS
* sizeof (asection
*);
1414 symndx_to_section
= (asection
**) bfd_alloc (input_bfd
, amt
);
1415 if (!symndx_to_section
)
1418 symndx_to_section
[RELOC_SECTION_NONE
] = NULL
;
1419 symndx_to_section
[RELOC_SECTION_TEXT
] =
1420 bfd_get_section_by_name (input_bfd
, ".text");
1421 symndx_to_section
[RELOC_SECTION_RDATA
] =
1422 bfd_get_section_by_name (input_bfd
, ".rdata");
1423 symndx_to_section
[RELOC_SECTION_DATA
] =
1424 bfd_get_section_by_name (input_bfd
, ".data");
1425 symndx_to_section
[RELOC_SECTION_SDATA
] =
1426 bfd_get_section_by_name (input_bfd
, ".sdata");
1427 symndx_to_section
[RELOC_SECTION_SBSS
] =
1428 bfd_get_section_by_name (input_bfd
, ".sbss");
1429 symndx_to_section
[RELOC_SECTION_BSS
] =
1430 bfd_get_section_by_name (input_bfd
, ".bss");
1431 symndx_to_section
[RELOC_SECTION_INIT
] =
1432 bfd_get_section_by_name (input_bfd
, ".init");
1433 symndx_to_section
[RELOC_SECTION_LIT8
] =
1434 bfd_get_section_by_name (input_bfd
, ".lit8");
1435 symndx_to_section
[RELOC_SECTION_LIT4
] =
1436 bfd_get_section_by_name (input_bfd
, ".lit4");
1437 symndx_to_section
[RELOC_SECTION_XDATA
] =
1438 bfd_get_section_by_name (input_bfd
, ".xdata");
1439 symndx_to_section
[RELOC_SECTION_PDATA
] =
1440 bfd_get_section_by_name (input_bfd
, ".pdata");
1441 symndx_to_section
[RELOC_SECTION_FINI
] =
1442 bfd_get_section_by_name (input_bfd
, ".fini");
1443 symndx_to_section
[RELOC_SECTION_LITA
] =
1444 bfd_get_section_by_name (input_bfd
, ".lita");
1445 symndx_to_section
[RELOC_SECTION_ABS
] = bfd_abs_section_ptr
;
1446 symndx_to_section
[RELOC_SECTION_RCONST
] =
1447 bfd_get_section_by_name (input_bfd
, ".rconst");
1449 ecoff_data (input_bfd
)->symndx_to_section
= symndx_to_section
;
1452 sym_hashes
= ecoff_data (input_bfd
)->sym_hashes
;
1454 /* On the Alpha, the .lita section must be addressable by the global
1455 pointer. To support large programs, we need to allow multiple
1456 global pointers. This works as long as each input .lita section
1457 is <64KB big. This implies that when producing relocatable
1458 output, the .lita section is limited to 64KB. . */
1460 lita_sec
= symndx_to_section
[RELOC_SECTION_LITA
];
1461 gp
= _bfd_get_gp_value (output_bfd
);
1462 if (! info
->relocatable
&& lita_sec
!= NULL
)
1464 struct ecoff_section_tdata
*lita_sec_data
;
1466 /* Make sure we have a section data structure to which we can
1467 hang on to the gp value we pick for the section. */
1468 lita_sec_data
= ecoff_section_data (input_bfd
, lita_sec
);
1469 if (lita_sec_data
== NULL
)
1471 amt
= sizeof (struct ecoff_section_tdata
);
1472 lita_sec_data
= ((struct ecoff_section_tdata
*)
1473 bfd_zalloc (input_bfd
, amt
));
1474 lita_sec
->used_by_bfd
= lita_sec_data
;
1477 if (lita_sec_data
->gp
!= 0)
1479 /* If we already assigned a gp to this section, we better
1480 stick with that value. */
1481 gp
= lita_sec_data
->gp
;
1486 bfd_size_type lita_size
;
1488 lita_vma
= lita_sec
->output_offset
+ lita_sec
->output_section
->vma
;
1489 lita_size
= lita_sec
->size
;
1492 || lita_vma
< gp
- 0x8000
1493 || lita_vma
+ lita_size
>= gp
+ 0x8000)
1495 /* Either gp hasn't been set at all or the current gp
1496 cannot address this .lita section. In both cases we
1497 reset the gp to point into the "middle" of the
1498 current input .lita section. */
1499 if (gp
&& !ecoff_data (output_bfd
)->issued_multiple_gp_warning
)
1501 (*info
->callbacks
->warning
) (info
,
1502 _("using multiple gp values"),
1503 (char *) NULL
, output_bfd
,
1504 (asection
*) NULL
, (bfd_vma
) 0);
1505 ecoff_data (output_bfd
)->issued_multiple_gp_warning
= TRUE
;
1507 if (lita_vma
< gp
- 0x8000)
1508 gp
= lita_vma
+ lita_size
- 0x8000;
1510 gp
= lita_vma
+ 0x8000;
1514 lita_sec_data
->gp
= gp
;
1517 _bfd_set_gp_value (output_bfd
, gp
);
1520 gp_undefined
= (gp
== 0);
1522 BFD_ASSERT (bfd_header_little_endian (output_bfd
));
1523 BFD_ASSERT (bfd_header_little_endian (input_bfd
));
1525 ext_rel
= (struct external_reloc
*) external_relocs
;
1526 ext_rel_end
= ext_rel
+ input_section
->reloc_count
;
1527 for (; ext_rel
< ext_rel_end
; ext_rel
++)
1530 unsigned long r_symndx
;
1535 bfd_boolean relocatep
;
1536 bfd_boolean adjust_addrp
;
1537 bfd_boolean gp_usedp
;
1540 r_vaddr
= H_GET_64 (input_bfd
, ext_rel
->r_vaddr
);
1541 r_symndx
= H_GET_32 (input_bfd
, ext_rel
->r_symndx
);
1543 r_type
= ((ext_rel
->r_bits
[0] & RELOC_BITS0_TYPE_LITTLE
)
1544 >> RELOC_BITS0_TYPE_SH_LITTLE
);
1545 r_extern
= (ext_rel
->r_bits
[1] & RELOC_BITS1_EXTERN_LITTLE
) != 0;
1546 r_offset
= ((ext_rel
->r_bits
[1] & RELOC_BITS1_OFFSET_LITTLE
)
1547 >> RELOC_BITS1_OFFSET_SH_LITTLE
);
1548 /* Ignored the reserved bits. */
1549 r_size
= ((ext_rel
->r_bits
[3] & RELOC_BITS3_SIZE_LITTLE
)
1550 >> RELOC_BITS3_SIZE_SH_LITTLE
);
1553 adjust_addrp
= TRUE
;
1559 case ALPHA_R_GPRELHIGH
:
1560 (*_bfd_error_handler
)
1561 (_("%B: unsupported relocation: ALPHA_R_GPRELHIGH"),
1563 bfd_set_error (bfd_error_bad_value
);
1566 case ALPHA_R_GPRELLOW
:
1567 (*_bfd_error_handler
)
1568 (_("%B: unsupported relocation: ALPHA_R_GPRELLOW"),
1570 bfd_set_error (bfd_error_bad_value
);
1574 (*_bfd_error_handler
)
1575 (_("%B: unknown relocation type %d"),
1576 input_bfd
, (int) r_type
);
1577 bfd_set_error (bfd_error_bad_value
);
1580 case ALPHA_R_IGNORE
:
1581 /* This reloc appears after a GPDISP reloc. On earlier
1582 versions of OSF/1, It marked the position of the second
1583 instruction to be altered by the GPDISP reloc, but it is
1584 not otherwise used for anything. For some reason, the
1585 address of the relocation does not appear to include the
1586 section VMA, unlike the other relocation types. */
1587 if (info
->relocatable
)
1588 H_PUT_64 (input_bfd
, input_section
->output_offset
+ r_vaddr
,
1590 adjust_addrp
= FALSE
;
1593 case ALPHA_R_REFLONG
:
1594 case ALPHA_R_REFQUAD
:
1599 case ALPHA_R_BRADDR
:
1600 case ALPHA_R_SREL16
:
1601 case ALPHA_R_SREL32
:
1602 case ALPHA_R_SREL64
:
1604 addend
+= - (r_vaddr
+ 4);
1608 case ALPHA_R_GPREL32
:
1609 /* This relocation is used in a switch table. It is a 32
1610 bit offset from the current GP value. We must adjust it
1611 by the different between the original GP value and the
1612 current GP value. */
1614 addend
= ecoff_data (input_bfd
)->gp
- gp
;
1618 case ALPHA_R_LITERAL
:
1619 /* This is a reference to a literal value, generally
1620 (always?) in the .lita section. This is a 16 bit GP
1621 relative relocation. Sometimes the subsequent reloc is a
1622 LITUSE reloc, which indicates how this reloc is used.
1623 This sometimes permits rewriting the two instructions
1624 referred to by the LITERAL and the LITUSE into different
1625 instructions which do not refer to .lita. This can save
1626 a memory reference, and permits removing a value from
1627 .lita thus saving GP relative space.
1629 We do not these optimizations. To do them we would need
1630 to arrange to link the .lita section first, so that by
1631 the time we got here we would know the final values to
1632 use. This would not be particularly difficult, but it is
1633 not currently implemented. */
1635 /* I believe that the LITERAL reloc will only apply to a ldq
1636 or ldl instruction, so check my assumption. */
1640 insn
= bfd_get_32 (input_bfd
,
1641 contents
+ r_vaddr
- input_section
->vma
);
1642 BFD_ASSERT (((insn
>> 26) & 0x3f) == 0x29
1643 || ((insn
>> 26) & 0x3f) == 0x28);
1647 addend
= ecoff_data (input_bfd
)->gp
- gp
;
1651 case ALPHA_R_LITUSE
:
1652 /* See ALPHA_R_LITERAL above for the uses of this reloc. It
1653 does not cause anything to happen, itself. */
1656 case ALPHA_R_GPDISP
:
1657 /* This marks the ldah of an ldah/lda pair which loads the
1658 gp register with the difference of the gp value and the
1659 current location. The second of the pair is r_symndx
1660 bytes ahead. It used to be marked with an ALPHA_R_IGNORE
1661 reloc, but OSF/1 3.2 no longer does that. */
1663 unsigned long insn1
, insn2
;
1665 /* Get the two instructions. */
1666 insn1
= bfd_get_32 (input_bfd
,
1667 contents
+ r_vaddr
- input_section
->vma
);
1668 insn2
= bfd_get_32 (input_bfd
,
1671 - input_section
->vma
1674 BFD_ASSERT (((insn1
>> 26) & 0x3f) == 0x09); /* ldah */
1675 BFD_ASSERT (((insn2
>> 26) & 0x3f) == 0x08); /* lda */
1677 /* Get the existing addend. We must account for the sign
1678 extension done by lda and ldah. */
1679 addend
= ((insn1
& 0xffff) << 16) + (insn2
& 0xffff);
1682 /* This is addend -= 0x100000000 without causing an
1683 integer overflow on a 32 bit host. */
1684 addend
-= 0x80000000;
1685 addend
-= 0x80000000;
1690 /* The existing addend includes the difference between the
1691 gp of the input BFD and the address in the input BFD.
1692 We want to change this to the difference between the
1693 final GP and the final address. */
1695 - ecoff_data (input_bfd
)->gp
1696 + input_section
->vma
1697 - (input_section
->output_section
->vma
1698 + input_section
->output_offset
));
1700 /* Change the instructions, accounting for the sign
1701 extension, and write them out. */
1702 if (addend
& 0x8000)
1704 insn1
= (insn1
& 0xffff0000) | ((addend
>> 16) & 0xffff);
1705 insn2
= (insn2
& 0xffff0000) | (addend
& 0xffff);
1707 bfd_put_32 (input_bfd
, (bfd_vma
) insn1
,
1708 contents
+ r_vaddr
- input_section
->vma
);
1709 bfd_put_32 (input_bfd
, (bfd_vma
) insn2
,
1710 contents
+ r_vaddr
- input_section
->vma
+ r_symndx
);
1716 case ALPHA_R_OP_PUSH
:
1717 case ALPHA_R_OP_PSUB
:
1718 case ALPHA_R_OP_PRSHIFT
:
1719 /* Manipulate values on the reloc evaluation stack. The
1720 r_vaddr field is not an address in input_section, it is
1721 the current value (including any addend) of the object
1727 s
= symndx_to_section
[r_symndx
];
1728 if (s
== (asection
*) NULL
)
1730 addend
= s
->output_section
->vma
+ s
->output_offset
- s
->vma
;
1734 struct ecoff_link_hash_entry
*h
;
1736 h
= sym_hashes
[r_symndx
];
1737 if (h
== (struct ecoff_link_hash_entry
*) NULL
)
1740 if (! info
->relocatable
)
1742 if (h
->root
.type
== bfd_link_hash_defined
1743 || h
->root
.type
== bfd_link_hash_defweak
)
1744 addend
= (h
->root
.u
.def
.value
1745 + h
->root
.u
.def
.section
->output_section
->vma
1746 + h
->root
.u
.def
.section
->output_offset
);
1749 /* Note that we pass the address as 0, since we
1750 do not have a meaningful number for the
1751 location within the section that is being
1753 if (! ((*info
->callbacks
->undefined_symbol
)
1754 (info
, h
->root
.root
.string
, input_bfd
,
1755 input_section
, (bfd_vma
) 0, TRUE
)))
1762 if (h
->root
.type
!= bfd_link_hash_defined
1763 && h
->root
.type
!= bfd_link_hash_defweak
1766 /* This symbol is not being written out. Pass
1767 the address as 0, as with undefined_symbol,
1769 if (! ((*info
->callbacks
->unattached_reloc
)
1770 (info
, h
->root
.root
.string
, input_bfd
,
1771 input_section
, (bfd_vma
) 0)))
1775 addend
= alpha_convert_external_reloc (output_bfd
, info
,
1783 if (info
->relocatable
)
1785 /* Adjust r_vaddr by the addend. */
1786 H_PUT_64 (input_bfd
, addend
, ext_rel
->r_vaddr
);
1792 case ALPHA_R_OP_PUSH
:
1793 if (tos
>= RELOC_STACKSIZE
)
1795 stack
[tos
++] = addend
;
1798 case ALPHA_R_OP_PSUB
:
1801 stack
[tos
- 1] -= addend
;
1804 case ALPHA_R_OP_PRSHIFT
:
1807 stack
[tos
- 1] >>= addend
;
1812 adjust_addrp
= FALSE
;
1815 case ALPHA_R_OP_STORE
:
1816 /* Store a value from the reloc stack into a bitfield. If
1817 we are generating relocatable output, all we do is
1818 adjust the address of the reloc. */
1819 if (! info
->relocatable
)
1827 /* Get the relocation mask. The separate steps and the
1828 casts to bfd_vma are attempts to avoid a bug in the
1829 Alpha OSF 1.3 C compiler. See reloc.c for more
1832 mask
<<= (bfd_vma
) r_size
;
1835 /* FIXME: I don't know what kind of overflow checking,
1836 if any, should be done here. */
1837 val
= bfd_get_64 (input_bfd
,
1838 contents
+ r_vaddr
- input_section
->vma
);
1839 val
&=~ mask
<< (bfd_vma
) r_offset
;
1840 val
|= (stack
[--tos
] & mask
) << (bfd_vma
) r_offset
;
1841 bfd_put_64 (input_bfd
, val
,
1842 contents
+ r_vaddr
- input_section
->vma
);
1846 case ALPHA_R_GPVALUE
:
1847 /* I really don't know if this does the right thing. */
1848 gp
= ecoff_data (input_bfd
)->gp
+ r_symndx
;
1849 gp_undefined
= FALSE
;
1855 reloc_howto_type
*howto
;
1856 struct ecoff_link_hash_entry
*h
= NULL
;
1859 bfd_reloc_status_type r
;
1861 /* Perform a relocation. */
1863 howto
= &alpha_howto_table
[r_type
];
1867 h
= sym_hashes
[r_symndx
];
1868 /* If h is NULL, that means that there is a reloc
1869 against an external symbol which we thought was just
1870 a debugging symbol. This should not happen. */
1871 if (h
== (struct ecoff_link_hash_entry
*) NULL
)
1876 if (r_symndx
>= NUM_RELOC_SECTIONS
)
1879 s
= symndx_to_section
[r_symndx
];
1881 if (s
== (asection
*) NULL
)
1885 if (info
->relocatable
)
1887 /* We are generating relocatable output, and must
1888 convert the existing reloc. */
1891 if (h
->root
.type
!= bfd_link_hash_defined
1892 && h
->root
.type
!= bfd_link_hash_defweak
1895 /* This symbol is not being written out. */
1896 if (! ((*info
->callbacks
->unattached_reloc
)
1897 (info
, h
->root
.root
.string
, input_bfd
,
1898 input_section
, r_vaddr
- input_section
->vma
)))
1902 relocation
= alpha_convert_external_reloc (output_bfd
,
1910 /* This is a relocation against a section. Adjust
1911 the value by the amount the section moved. */
1912 relocation
= (s
->output_section
->vma
1917 /* If this is PC relative, the existing object file
1918 appears to already have the reloc worked out. We
1919 must subtract out the old value and add in the new
1921 if (howto
->pc_relative
)
1922 relocation
-= (input_section
->output_section
->vma
1923 + input_section
->output_offset
1924 - input_section
->vma
);
1926 /* Put in any addend. */
1927 relocation
+= addend
;
1929 /* Adjust the contents. */
1930 r
= _bfd_relocate_contents (howto
, input_bfd
, relocation
,
1933 - input_section
->vma
));
1937 /* We are producing a final executable. */
1940 /* This is a reloc against a symbol. */
1941 if (h
->root
.type
== bfd_link_hash_defined
1942 || h
->root
.type
== bfd_link_hash_defweak
)
1946 hsec
= h
->root
.u
.def
.section
;
1947 relocation
= (h
->root
.u
.def
.value
1948 + hsec
->output_section
->vma
1949 + hsec
->output_offset
);
1953 if (! ((*info
->callbacks
->undefined_symbol
)
1954 (info
, h
->root
.root
.string
, input_bfd
,
1956 r_vaddr
- input_section
->vma
, TRUE
)))
1963 /* This is a reloc against a section. */
1964 relocation
= (s
->output_section
->vma
1968 /* Adjust a PC relative relocation by removing the
1969 reference to the original source section. */
1970 if (howto
->pc_relative
)
1971 relocation
+= input_section
->vma
;
1974 r
= _bfd_final_link_relocate (howto
,
1978 r_vaddr
- input_section
->vma
,
1983 if (r
!= bfd_reloc_ok
)
1988 case bfd_reloc_outofrange
:
1990 case bfd_reloc_overflow
:
1995 name
= sym_hashes
[r_symndx
]->root
.root
.string
;
1997 name
= bfd_section_name (input_bfd
,
1998 symndx_to_section
[r_symndx
]);
1999 if (! ((*info
->callbacks
->reloc_overflow
)
2001 alpha_howto_table
[r_type
].name
,
2002 (bfd_vma
) 0, input_bfd
, input_section
,
2003 r_vaddr
- input_section
->vma
)))
2011 if (info
->relocatable
&& adjust_addrp
)
2013 /* Change the address of the relocation. */
2014 H_PUT_64 (input_bfd
,
2015 (input_section
->output_section
->vma
2016 + input_section
->output_offset
2017 - input_section
->vma
2022 if (gp_usedp
&& gp_undefined
)
2024 if (! ((*info
->callbacks
->reloc_dangerous
)
2025 (info
, _("GP relative relocation used when GP not defined"),
2026 input_bfd
, input_section
, r_vaddr
- input_section
->vma
)))
2028 /* Only give the error once per link. */
2030 _bfd_set_gp_value (output_bfd
, gp
);
2031 gp_undefined
= FALSE
;
2041 /* Do final adjustments to the filehdr and the aouthdr. This routine
2042 sets the dynamic bits in the file header. */
2045 alpha_adjust_headers (abfd
, fhdr
, ahdr
)
2047 struct internal_filehdr
*fhdr
;
2048 struct internal_aouthdr
*ahdr ATTRIBUTE_UNUSED
;
2050 if ((abfd
->flags
& (DYNAMIC
| EXEC_P
)) == (DYNAMIC
| EXEC_P
))
2051 fhdr
->f_flags
|= F_ALPHA_CALL_SHARED
;
2052 else if ((abfd
->flags
& DYNAMIC
) != 0)
2053 fhdr
->f_flags
|= F_ALPHA_SHARABLE
;
2057 /* Archive handling. In OSF/1 (or Digital Unix) v3.2, Digital
2058 introduced archive packing, in which the elements in an archive are
2059 optionally compressed using a simple dictionary scheme. We know
2060 how to read such archives, but we don't write them. */
2062 #define alpha_ecoff_slurp_armap _bfd_ecoff_slurp_armap
2063 #define alpha_ecoff_slurp_extended_name_table \
2064 _bfd_ecoff_slurp_extended_name_table
2065 #define alpha_ecoff_construct_extended_name_table \
2066 _bfd_ecoff_construct_extended_name_table
2067 #define alpha_ecoff_truncate_arname _bfd_ecoff_truncate_arname
2068 #define alpha_ecoff_write_armap _bfd_ecoff_write_armap
2069 #define alpha_ecoff_write_ar_hdr _bfd_generic_write_ar_hdr
2070 #define alpha_ecoff_generic_stat_arch_elt _bfd_ecoff_generic_stat_arch_elt
2071 #define alpha_ecoff_update_armap_timestamp _bfd_ecoff_update_armap_timestamp
2073 /* A compressed file uses this instead of ARFMAG. */
2075 #define ARFZMAG "Z\012"
2077 /* Read an archive header. This is like the standard routine, but it
2078 also accepts ARFZMAG. */
2081 alpha_ecoff_read_ar_hdr (abfd
)
2084 struct areltdata
*ret
;
2087 ret
= (struct areltdata
*) _bfd_generic_read_ar_hdr_mag (abfd
, ARFZMAG
);
2091 h
= (struct ar_hdr
*) ret
->arch_header
;
2092 if (strncmp (h
->ar_fmag
, ARFZMAG
, 2) == 0)
2096 /* This is a compressed file. We must set the size correctly.
2097 The size is the eight bytes after the dummy file header. */
2098 if (bfd_seek (abfd
, (file_ptr
) FILHSZ
, SEEK_CUR
) != 0
2099 || bfd_bread (ab
, (bfd_size_type
) 8, abfd
) != 8
2100 || bfd_seek (abfd
, (file_ptr
) (- (FILHSZ
+ 8)), SEEK_CUR
) != 0)
2103 ret
->parsed_size
= H_GET_64 (abfd
, ab
);
2109 /* Get an archive element at a specified file position. This is where
2110 we uncompress the archive element if necessary. */
2113 alpha_ecoff_get_elt_at_filepos (archive
, filepos
)
2118 struct areltdata
*tdata
;
2123 struct bfd_in_memory
*bim
;
2126 nbfd
= _bfd_get_elt_at_filepos (archive
, filepos
);
2130 if ((nbfd
->flags
& BFD_IN_MEMORY
) != 0)
2132 /* We have already expanded this BFD. */
2136 tdata
= (struct areltdata
*) nbfd
->arelt_data
;
2137 hdr
= (struct ar_hdr
*) tdata
->arch_header
;
2138 if (strncmp (hdr
->ar_fmag
, ARFZMAG
, 2) != 0)
2141 /* We must uncompress this element. We do this by copying it into a
2142 memory buffer, and making bfd_bread and bfd_seek use that buffer.
2143 This can use a lot of memory, but it's simpler than getting a
2144 temporary file, making that work with the file descriptor caching
2145 code, and making sure that it is deleted at all appropriate
2146 times. It can be changed if it ever becomes important. */
2148 /* The compressed file starts with a dummy ECOFF file header. */
2149 if (bfd_seek (nbfd
, (file_ptr
) FILHSZ
, SEEK_SET
) != 0)
2152 /* The next eight bytes are the real file size. */
2153 if (bfd_bread (ab
, (bfd_size_type
) 8, nbfd
) != 8)
2155 size
= H_GET_64 (nbfd
, ab
);
2160 bfd_byte dict
[4096];
2164 buf
= (bfd_byte
*) bfd_malloc (size
);
2171 /* I don't know what the next eight bytes are for. */
2172 if (bfd_bread (ab
, (bfd_size_type
) 8, nbfd
) != 8)
2175 /* This is the uncompression algorithm. It's a simple
2176 dictionary based scheme in which each character is predicted
2177 by a hash of the previous three characters. A control byte
2178 indicates whether the character is predicted or whether it
2179 appears in the input stream; each control byte manages the
2180 next eight bytes in the output stream. */
2181 memset (dict
, 0, sizeof dict
);
2183 while (bfd_bread (&b
, (bfd_size_type
) 1, nbfd
) == 1)
2187 for (i
= 0; i
< 8; i
++, b
>>= 1)
2195 if (! bfd_bread (&n
, (bfd_size_type
) 1, nbfd
))
2208 h
&= sizeof dict
- 1;
2216 /* Now the uncompressed file contents are in buf. */
2217 bim
= ((struct bfd_in_memory
*)
2218 bfd_malloc ((bfd_size_type
) sizeof (struct bfd_in_memory
)));
2224 nbfd
->mtime_set
= TRUE
;
2225 nbfd
->mtime
= strtol (hdr
->ar_date
, (char **) NULL
, 10);
2227 nbfd
->flags
|= BFD_IN_MEMORY
;
2228 nbfd
->iostream
= (PTR
) bim
;
2229 nbfd
->iovec
= &_bfd_memory_iovec
;
2231 BFD_ASSERT (! nbfd
->cacheable
);
2243 /* Open the next archived file. */
2246 alpha_ecoff_openr_next_archived_file (archive
, last_file
)
2252 if (last_file
== NULL
)
2253 filestart
= bfd_ardata (archive
)->first_file_filepos
;
2256 struct areltdata
*t
;
2260 /* We can't use arelt_size here, because that uses parsed_size,
2261 which is the uncompressed size. We need the compressed size. */
2262 t
= (struct areltdata
*) last_file
->arelt_data
;
2263 h
= (struct ar_hdr
*) t
->arch_header
;
2264 size
= strtol (h
->ar_size
, (char **) NULL
, 10);
2266 /* Pad to an even boundary...
2267 Note that last_file->origin can be odd in the case of
2268 BSD-4.4-style element with a long odd size. */
2269 filestart
= last_file
->proxy_origin
+ size
;
2270 filestart
+= filestart
% 2;
2273 return alpha_ecoff_get_elt_at_filepos (archive
, filestart
);
2276 /* Open the archive file given an index into the armap. */
2279 alpha_ecoff_get_elt_at_index (bfd
*abfd
, symindex sym_index
)
2283 entry
= bfd_ardata (abfd
)->symdefs
+ sym_index
;
2284 return alpha_ecoff_get_elt_at_filepos (abfd
, entry
->file_offset
);
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 (void (*) PARAMS ((bfd
*,PTR
,int,int,int,int,PTR
))) bfd_void
, /* aux_in */
2295 (void (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* sym_in */
2296 (void (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* lineno_in */
2297 (unsigned (*) PARAMS ((bfd
*,PTR
,int,int,int,int,PTR
)))bfd_void
,/*aux_out*/
2298 (unsigned (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* sym_out */
2299 (unsigned (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* lineno_out */
2300 (unsigned (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* reloc_out */
2301 alpha_ecoff_swap_filehdr_out
, alpha_ecoff_swap_aouthdr_out
,
2302 alpha_ecoff_swap_scnhdr_out
,
2303 FILHSZ
, AOUTSZ
, SCNHSZ
, 0, 0, 0, 0, FILNMLEN
, TRUE
,
2304 ECOFF_NO_LONG_SECTION_NAMES
, 4, FALSE
, 2,
2305 alpha_ecoff_swap_filehdr_in
, alpha_ecoff_swap_aouthdr_in
,
2306 alpha_ecoff_swap_scnhdr_in
, NULL
,
2307 alpha_ecoff_bad_format_hook
, _bfd_ecoff_set_arch_mach_hook
,
2308 alpha_ecoff_mkobject_hook
, _bfd_ecoff_styp_to_sec_flags
,
2309 _bfd_ecoff_set_alignment_hook
, _bfd_ecoff_slurp_symbol_table
,
2310 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
2311 NULL
, NULL
, NULL
, NULL
2313 /* Supported architecture. */
2315 /* Initial portion of armap string. */
2317 /* The page boundary used to align sections in a demand-paged
2318 executable file. E.g., 0x1000. */
2320 /* TRUE if the .rdata section is part of the text segment, as on the
2321 Alpha. FALSE if .rdata is part of the data segment, as on the
2324 /* Bitsize of constructor entries. */
2326 /* Reloc to use for constructor entries. */
2327 &alpha_howto_table
[ALPHA_R_REFQUAD
],
2329 /* Symbol table magic number. */
2331 /* Alignment of debugging information. E.g., 4. */
2333 /* Sizes of external symbolic information. */
2334 sizeof (struct hdr_ext
),
2335 sizeof (struct dnr_ext
),
2336 sizeof (struct pdr_ext
),
2337 sizeof (struct sym_ext
),
2338 sizeof (struct opt_ext
),
2339 sizeof (struct fdr_ext
),
2340 sizeof (struct rfd_ext
),
2341 sizeof (struct ext_ext
),
2342 /* Functions to swap in external symbolic data. */
2351 _bfd_ecoff_swap_tir_in
,
2352 _bfd_ecoff_swap_rndx_in
,
2353 /* Functions to swap out external symbolic data. */
2362 _bfd_ecoff_swap_tir_out
,
2363 _bfd_ecoff_swap_rndx_out
,
2364 /* Function to read in symbolic data. */
2365 _bfd_ecoff_slurp_symbolic_info
2367 /* External reloc size. */
2369 /* Reloc swapping functions. */
2370 alpha_ecoff_swap_reloc_in
,
2371 alpha_ecoff_swap_reloc_out
,
2372 /* Backend reloc tweaking. */
2373 alpha_adjust_reloc_in
,
2374 alpha_adjust_reloc_out
,
2375 /* Relocate section contents while linking. */
2376 alpha_relocate_section
,
2377 /* Do final adjustments to filehdr and aouthdr. */
2378 alpha_adjust_headers
,
2379 /* Read an element from an archive at a given file position. */
2380 alpha_ecoff_get_elt_at_filepos
2383 /* Looking up a reloc type is Alpha specific. */
2384 #define _bfd_ecoff_bfd_reloc_type_lookup alpha_bfd_reloc_type_lookup
2385 #define _bfd_ecoff_bfd_reloc_name_lookup \
2386 alpha_bfd_reloc_name_lookup
2388 /* So is getting relocated section contents. */
2389 #define _bfd_ecoff_bfd_get_relocated_section_contents \
2390 alpha_ecoff_get_relocated_section_contents
2392 /* Handling file windows is generic. */
2393 #define _bfd_ecoff_get_section_contents_in_window \
2394 _bfd_generic_get_section_contents_in_window
2396 /* Input section flag lookup is generic. */
2397 #define _bfd_ecoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags
2399 /* Relaxing sections is generic. */
2400 #define _bfd_ecoff_bfd_relax_section bfd_generic_relax_section
2401 #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections
2402 #define _bfd_ecoff_bfd_merge_sections bfd_generic_merge_sections
2403 #define _bfd_ecoff_bfd_is_group_section bfd_generic_is_group_section
2404 #define _bfd_ecoff_bfd_discard_group bfd_generic_discard_group
2405 #define _bfd_ecoff_section_already_linked \
2406 _bfd_coff_section_already_linked
2407 #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
2409 const bfd_target ecoffalpha_little_vec
=
2411 "ecoff-littlealpha", /* name */
2412 bfd_target_ecoff_flavour
,
2413 BFD_ENDIAN_LITTLE
, /* data byte order is little */
2414 BFD_ENDIAN_LITTLE
, /* header byte order is little */
2416 (HAS_RELOC
| EXEC_P
| /* object flags */
2417 HAS_LINENO
| HAS_DEBUG
|
2418 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
| D_PAGED
),
2420 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_CODE
| SEC_DATA
),
2421 0, /* leading underscore */
2422 ' ', /* ar_pad_char */
2423 15, /* ar_max_namelen */
2424 0, /* match priority. */
2425 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
2426 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
2427 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* data */
2428 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
2429 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
2430 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* hdrs */
2432 {_bfd_dummy_target
, alpha_ecoff_object_p
, /* bfd_check_format */
2433 bfd_generic_archive_p
, _bfd_dummy_target
},
2434 {bfd_false
, _bfd_ecoff_mkobject
, /* bfd_set_format */
2435 _bfd_generic_mkarchive
, bfd_false
},
2436 {bfd_false
, _bfd_ecoff_write_object_contents
, /* bfd_write_contents */
2437 _bfd_write_archive_contents
, bfd_false
},
2439 BFD_JUMP_TABLE_GENERIC (_bfd_ecoff
),
2440 BFD_JUMP_TABLE_COPY (_bfd_ecoff
),
2441 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
2442 BFD_JUMP_TABLE_ARCHIVE (alpha_ecoff
),
2443 BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff
),
2444 BFD_JUMP_TABLE_RELOCS (_bfd_ecoff
),
2445 BFD_JUMP_TABLE_WRITE (_bfd_ecoff
),
2446 BFD_JUMP_TABLE_LINK (_bfd_ecoff
),
2447 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic
),
2451 (PTR
) &alpha_ecoff_backend_data