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 Free Software Foundation, Inc.
4 Modified from coff-mips.c by Steve Chamberlain <sac@cygnus.com> and
5 Ian Lance Taylor <ian@cygnus.com>.
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
28 #include "coff/internal.h"
30 #include "coff/symconst.h"
31 #include "coff/ecoff.h"
32 #include "coff/alpha.h"
37 /* Prototypes for static functions. */
39 static const bfd_target
*alpha_ecoff_object_p
41 static bfd_boolean alpha_ecoff_bad_format_hook
42 PARAMS ((bfd
*abfd
, PTR filehdr
));
43 static PTR alpha_ecoff_mkobject_hook
44 PARAMS ((bfd
*, PTR filehdr
, PTR aouthdr
));
45 static void alpha_ecoff_swap_reloc_in
46 PARAMS ((bfd
*, PTR
, struct internal_reloc
*));
47 static void alpha_ecoff_swap_reloc_out
48 PARAMS ((bfd
*, const struct internal_reloc
*, PTR
));
49 static void alpha_adjust_reloc_in
50 PARAMS ((bfd
*, const struct internal_reloc
*, arelent
*));
51 static void alpha_adjust_reloc_out
52 PARAMS ((bfd
*, const arelent
*, struct internal_reloc
*));
53 static reloc_howto_type
*alpha_bfd_reloc_type_lookup
54 PARAMS ((bfd
*, bfd_reloc_code_real_type
));
55 static bfd_byte
*alpha_ecoff_get_relocated_section_contents
56 PARAMS ((bfd
*abfd
, struct bfd_link_info
*, struct bfd_link_order
*,
57 bfd_byte
*data
, bfd_boolean relocatable
, asymbol
**symbols
));
58 static bfd_vma alpha_convert_external_reloc
59 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, struct external_reloc
*,
60 struct ecoff_link_hash_entry
*));
61 static bfd_boolean alpha_relocate_section
62 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*, PTR
));
63 static bfd_boolean alpha_adjust_headers
64 PARAMS ((bfd
*, struct internal_filehdr
*, struct internal_aouthdr
*));
65 static PTR alpha_ecoff_read_ar_hdr
67 static bfd
*alpha_ecoff_get_elt_at_filepos
68 PARAMS ((bfd
*, file_ptr
));
69 static bfd
*alpha_ecoff_openr_next_archived_file
70 PARAMS ((bfd
*, bfd
*));
71 static bfd
*alpha_ecoff_get_elt_at_index
72 PARAMS ((bfd
*, symindex
));
74 /* ECOFF has COFF sections, but the debugging information is stored in
75 a completely different format. ECOFF targets use some of the
76 swapping routines from coffswap.h, and some of the generic COFF
77 routines in coffgen.c, but, unlike the real COFF targets, do not
78 use coffcode.h itself.
80 Get the generic COFF swapping routines, except for the reloc,
81 symbol, and lineno ones. Give them ecoff names. Define some
82 accessor macros for the large sizes used for Alpha ECOFF. */
84 #define GET_FILEHDR_SYMPTR H_GET_64
85 #define PUT_FILEHDR_SYMPTR H_PUT_64
86 #define GET_AOUTHDR_TSIZE H_GET_64
87 #define PUT_AOUTHDR_TSIZE H_PUT_64
88 #define GET_AOUTHDR_DSIZE H_GET_64
89 #define PUT_AOUTHDR_DSIZE H_PUT_64
90 #define GET_AOUTHDR_BSIZE H_GET_64
91 #define PUT_AOUTHDR_BSIZE H_PUT_64
92 #define GET_AOUTHDR_ENTRY H_GET_64
93 #define PUT_AOUTHDR_ENTRY H_PUT_64
94 #define GET_AOUTHDR_TEXT_START H_GET_64
95 #define PUT_AOUTHDR_TEXT_START H_PUT_64
96 #define GET_AOUTHDR_DATA_START H_GET_64
97 #define PUT_AOUTHDR_DATA_START H_PUT_64
98 #define GET_SCNHDR_PADDR H_GET_64
99 #define PUT_SCNHDR_PADDR H_PUT_64
100 #define GET_SCNHDR_VADDR H_GET_64
101 #define PUT_SCNHDR_VADDR H_PUT_64
102 #define GET_SCNHDR_SIZE H_GET_64
103 #define PUT_SCNHDR_SIZE H_PUT_64
104 #define GET_SCNHDR_SCNPTR H_GET_64
105 #define PUT_SCNHDR_SCNPTR H_PUT_64
106 #define GET_SCNHDR_RELPTR H_GET_64
107 #define PUT_SCNHDR_RELPTR H_PUT_64
108 #define GET_SCNHDR_LNNOPTR H_GET_64
109 #define PUT_SCNHDR_LNNOPTR H_PUT_64
113 #define NO_COFF_RELOCS
114 #define NO_COFF_SYMBOLS
115 #define NO_COFF_LINENOS
116 #define coff_swap_filehdr_in alpha_ecoff_swap_filehdr_in
117 #define coff_swap_filehdr_out alpha_ecoff_swap_filehdr_out
118 #define coff_swap_aouthdr_in alpha_ecoff_swap_aouthdr_in
119 #define coff_swap_aouthdr_out alpha_ecoff_swap_aouthdr_out
120 #define coff_swap_scnhdr_in alpha_ecoff_swap_scnhdr_in
121 #define coff_swap_scnhdr_out alpha_ecoff_swap_scnhdr_out
122 #include "coffswap.h"
124 /* Get the ECOFF swapping routines. */
126 #include "ecoffswap.h"
128 /* How to process the various reloc types. */
130 static bfd_reloc_status_type reloc_nil
131 PARAMS ((bfd
*, arelent
*, asymbol
*, PTR
, asection
*, bfd
*, char **));
133 static bfd_reloc_status_type
134 reloc_nil (abfd
, reloc
, sym
, data
, sec
, output_bfd
, error_message
)
135 bfd
*abfd ATTRIBUTE_UNUSED
;
136 arelent
*reloc ATTRIBUTE_UNUSED
;
137 asymbol
*sym ATTRIBUTE_UNUSED
;
138 PTR data ATTRIBUTE_UNUSED
;
139 asection
*sec ATTRIBUTE_UNUSED
;
140 bfd
*output_bfd ATTRIBUTE_UNUSED
;
141 char **error_message ATTRIBUTE_UNUSED
;
146 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
147 from smaller values. Start with zero, widen, *then* decrement. */
148 #define MINUS_ONE (((bfd_vma)0) - 1)
150 static reloc_howto_type alpha_howto_table
[] =
152 /* Reloc type 0 is ignored by itself. However, it appears after a
153 GPDISP reloc to identify the location where the low order 16 bits
154 of the gp register are loaded. */
155 HOWTO (ALPHA_R_IGNORE
, /* type */
157 0, /* size (0 = byte, 1 = short, 2 = long) */
159 TRUE
, /* pc_relative */
161 complain_overflow_dont
, /* complain_on_overflow */
162 reloc_nil
, /* special_function */
164 TRUE
, /* partial_inplace */
167 TRUE
), /* pcrel_offset */
169 /* A 32 bit reference to a symbol. */
170 HOWTO (ALPHA_R_REFLONG
, /* type */
172 2, /* size (0 = byte, 1 = short, 2 = long) */
174 FALSE
, /* pc_relative */
176 complain_overflow_bitfield
, /* complain_on_overflow */
177 0, /* special_function */
178 "REFLONG", /* name */
179 TRUE
, /* partial_inplace */
180 0xffffffff, /* src_mask */
181 0xffffffff, /* dst_mask */
182 FALSE
), /* pcrel_offset */
184 /* A 64 bit reference to a symbol. */
185 HOWTO (ALPHA_R_REFQUAD
, /* type */
187 4, /* size (0 = byte, 1 = short, 2 = long) */
189 FALSE
, /* pc_relative */
191 complain_overflow_bitfield
, /* complain_on_overflow */
192 0, /* special_function */
193 "REFQUAD", /* name */
194 TRUE
, /* partial_inplace */
195 MINUS_ONE
, /* src_mask */
196 MINUS_ONE
, /* dst_mask */
197 FALSE
), /* pcrel_offset */
199 /* A 32 bit GP relative offset. This is just like REFLONG except
200 that when the value is used the value of the gp register will be
202 HOWTO (ALPHA_R_GPREL32
, /* type */
204 2, /* size (0 = byte, 1 = short, 2 = long) */
206 FALSE
, /* pc_relative */
208 complain_overflow_bitfield
, /* complain_on_overflow */
209 0, /* special_function */
210 "GPREL32", /* name */
211 TRUE
, /* partial_inplace */
212 0xffffffff, /* src_mask */
213 0xffffffff, /* dst_mask */
214 FALSE
), /* pcrel_offset */
216 /* Used for an instruction that refers to memory off the GP
217 register. The offset is 16 bits of the 32 bit instruction. This
218 reloc always seems to be against the .lita section. */
219 HOWTO (ALPHA_R_LITERAL
, /* type */
221 2, /* size (0 = byte, 1 = short, 2 = long) */
223 FALSE
, /* pc_relative */
225 complain_overflow_signed
, /* complain_on_overflow */
226 0, /* special_function */
227 "LITERAL", /* name */
228 TRUE
, /* partial_inplace */
229 0xffff, /* src_mask */
230 0xffff, /* dst_mask */
231 FALSE
), /* pcrel_offset */
233 /* This reloc only appears immediately following a LITERAL reloc.
234 It identifies a use of the literal. It seems that the linker can
235 use this to eliminate a portion of the .lita section. The symbol
236 index is special: 1 means the literal address is in the base
237 register of a memory format instruction; 2 means the literal
238 address is in the byte offset register of a byte-manipulation
239 instruction; 3 means the literal address is in the target
240 register of a jsr instruction. This does not actually do any
242 HOWTO (ALPHA_R_LITUSE
, /* type */
244 2, /* size (0 = byte, 1 = short, 2 = long) */
246 FALSE
, /* pc_relative */
248 complain_overflow_dont
, /* complain_on_overflow */
249 reloc_nil
, /* special_function */
251 FALSE
, /* partial_inplace */
254 FALSE
), /* pcrel_offset */
256 /* Load the gp register. This is always used for a ldah instruction
257 which loads the upper 16 bits of the gp register. The next reloc
258 will be an IGNORE reloc which identifies the location of the lda
259 instruction which loads the lower 16 bits. The symbol index of
260 the GPDISP instruction appears to actually be the number of bytes
261 between the ldah and lda instructions. This gives two different
262 ways to determine where the lda instruction is; I don't know why
263 both are used. The value to use for the relocation is the
264 difference between the GP value and the current location; the
265 load will always be done against a register holding the current
267 HOWTO (ALPHA_R_GPDISP
, /* type */
269 2, /* size (0 = byte, 1 = short, 2 = long) */
271 TRUE
, /* pc_relative */
273 complain_overflow_dont
, /* complain_on_overflow */
274 reloc_nil
, /* special_function */
276 TRUE
, /* partial_inplace */
277 0xffff, /* src_mask */
278 0xffff, /* dst_mask */
279 TRUE
), /* pcrel_offset */
281 /* A 21 bit branch. The native assembler generates these for
282 branches within the text segment, and also fills in the PC
283 relative offset in the instruction. */
284 HOWTO (ALPHA_R_BRADDR
, /* type */
286 2, /* size (0 = byte, 1 = short, 2 = long) */
288 TRUE
, /* pc_relative */
290 complain_overflow_signed
, /* complain_on_overflow */
291 0, /* special_function */
293 TRUE
, /* partial_inplace */
294 0x1fffff, /* src_mask */
295 0x1fffff, /* dst_mask */
296 FALSE
), /* pcrel_offset */
298 /* A hint for a jump to a register. */
299 HOWTO (ALPHA_R_HINT
, /* type */
301 2, /* size (0 = byte, 1 = short, 2 = long) */
303 TRUE
, /* pc_relative */
305 complain_overflow_dont
, /* complain_on_overflow */
306 0, /* special_function */
308 TRUE
, /* partial_inplace */
309 0x3fff, /* src_mask */
310 0x3fff, /* dst_mask */
311 FALSE
), /* pcrel_offset */
313 /* 16 bit PC relative offset. */
314 HOWTO (ALPHA_R_SREL16
, /* type */
316 1, /* size (0 = byte, 1 = short, 2 = long) */
318 TRUE
, /* pc_relative */
320 complain_overflow_signed
, /* complain_on_overflow */
321 0, /* special_function */
323 TRUE
, /* partial_inplace */
324 0xffff, /* src_mask */
325 0xffff, /* dst_mask */
326 FALSE
), /* pcrel_offset */
328 /* 32 bit PC relative offset. */
329 HOWTO (ALPHA_R_SREL32
, /* type */
331 2, /* size (0 = byte, 1 = short, 2 = long) */
333 TRUE
, /* pc_relative */
335 complain_overflow_signed
, /* complain_on_overflow */
336 0, /* special_function */
338 TRUE
, /* partial_inplace */
339 0xffffffff, /* src_mask */
340 0xffffffff, /* dst_mask */
341 FALSE
), /* pcrel_offset */
343 /* A 64 bit PC relative offset. */
344 HOWTO (ALPHA_R_SREL64
, /* type */
346 4, /* size (0 = byte, 1 = short, 2 = long) */
348 TRUE
, /* pc_relative */
350 complain_overflow_signed
, /* complain_on_overflow */
351 0, /* special_function */
353 TRUE
, /* partial_inplace */
354 MINUS_ONE
, /* src_mask */
355 MINUS_ONE
, /* dst_mask */
356 FALSE
), /* pcrel_offset */
358 /* Push a value on the reloc evaluation stack. */
359 HOWTO (ALPHA_R_OP_PUSH
, /* type */
361 0, /* size (0 = byte, 1 = short, 2 = long) */
363 FALSE
, /* pc_relative */
365 complain_overflow_dont
, /* complain_on_overflow */
366 0, /* special_function */
367 "OP_PUSH", /* name */
368 FALSE
, /* partial_inplace */
371 FALSE
), /* pcrel_offset */
373 /* Store the value from the stack at the given address. Store it in
374 a bitfield of size r_size starting at bit position r_offset. */
375 HOWTO (ALPHA_R_OP_STORE
, /* type */
377 4, /* size (0 = byte, 1 = short, 2 = long) */
379 FALSE
, /* pc_relative */
381 complain_overflow_dont
, /* complain_on_overflow */
382 0, /* special_function */
383 "OP_STORE", /* name */
384 FALSE
, /* partial_inplace */
386 MINUS_ONE
, /* dst_mask */
387 FALSE
), /* pcrel_offset */
389 /* Subtract the reloc address from the value on the top of the
391 HOWTO (ALPHA_R_OP_PSUB
, /* type */
393 0, /* size (0 = byte, 1 = short, 2 = long) */
395 FALSE
, /* pc_relative */
397 complain_overflow_dont
, /* complain_on_overflow */
398 0, /* special_function */
399 "OP_PSUB", /* name */
400 FALSE
, /* partial_inplace */
403 FALSE
), /* pcrel_offset */
405 /* Shift the value on the top of the relocation stack right by the
407 HOWTO (ALPHA_R_OP_PRSHIFT
, /* type */
409 0, /* size (0 = byte, 1 = short, 2 = long) */
411 FALSE
, /* pc_relative */
413 complain_overflow_dont
, /* complain_on_overflow */
414 0, /* special_function */
415 "OP_PRSHIFT", /* name */
416 FALSE
, /* partial_inplace */
419 FALSE
), /* pcrel_offset */
421 /* Adjust the GP value for a new range in the object file. */
422 HOWTO (ALPHA_R_GPVALUE
, /* type */
424 0, /* size (0 = byte, 1 = short, 2 = long) */
426 FALSE
, /* pc_relative */
428 complain_overflow_dont
, /* complain_on_overflow */
429 0, /* special_function */
430 "GPVALUE", /* name */
431 FALSE
, /* partial_inplace */
434 FALSE
) /* pcrel_offset */
437 /* Recognize an Alpha ECOFF file. */
439 static const bfd_target
*
440 alpha_ecoff_object_p (abfd
)
443 static const bfd_target
*ret
;
445 ret
= coff_object_p (abfd
);
451 /* Alpha ECOFF has a .pdata section. The lnnoptr field of the
452 .pdata section is the number of entries it contains. Each
453 entry takes up 8 bytes. The number of entries is required
454 since the section is aligned to a 16 byte boundary. When we
455 link .pdata sections together, we do not want to include the
456 alignment bytes. We handle this on input by faking the size
457 of the .pdata section to remove the unwanted alignment bytes.
458 On output we will set the lnnoptr field and force the
460 sec
= bfd_get_section_by_name (abfd
, _PDATA
);
461 if (sec
!= (asection
*) NULL
)
465 size
= sec
->line_filepos
* 8;
466 BFD_ASSERT (size
== sec
->size
467 || size
+ 8 == sec
->size
);
468 if (! bfd_set_section_size (abfd
, sec
, size
))
476 /* See whether the magic number matches. */
479 alpha_ecoff_bad_format_hook (abfd
, filehdr
)
480 bfd
*abfd ATTRIBUTE_UNUSED
;
483 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
485 if (! ALPHA_ECOFF_BADMAG (*internal_f
))
488 if (ALPHA_ECOFF_COMPRESSEDMAG (*internal_f
))
489 (*_bfd_error_handler
)
490 (_("%B: Cannot handle compressed Alpha binaries.\n"
491 " Use compiler flags, or objZ, to generate uncompressed binaries."),
497 /* This is a hook called by coff_real_object_p to create any backend
498 specific information. */
501 alpha_ecoff_mkobject_hook (abfd
, filehdr
, aouthdr
)
508 ecoff
= _bfd_ecoff_mkobject_hook (abfd
, filehdr
, aouthdr
);
512 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
514 /* Set additional BFD flags according to the object type from the
515 machine specific file header flags. */
516 switch (internal_f
->f_flags
& F_ALPHA_OBJECT_TYPE_MASK
)
518 case F_ALPHA_SHARABLE
:
519 abfd
->flags
|= DYNAMIC
;
521 case F_ALPHA_CALL_SHARED
:
522 /* Always executable if using shared libraries as the run time
523 loader might resolve undefined references. */
524 abfd
->flags
|= (DYNAMIC
| EXEC_P
);
531 /* Reloc handling. */
533 /* Swap a reloc in. */
536 alpha_ecoff_swap_reloc_in (abfd
, ext_ptr
, intern
)
539 struct internal_reloc
*intern
;
541 const RELOC
*ext
= (RELOC
*) ext_ptr
;
543 intern
->r_vaddr
= H_GET_64 (abfd
, ext
->r_vaddr
);
544 intern
->r_symndx
= H_GET_32 (abfd
, ext
->r_symndx
);
546 BFD_ASSERT (bfd_header_little_endian (abfd
));
548 intern
->r_type
= ((ext
->r_bits
[0] & RELOC_BITS0_TYPE_LITTLE
)
549 >> RELOC_BITS0_TYPE_SH_LITTLE
);
550 intern
->r_extern
= (ext
->r_bits
[1] & RELOC_BITS1_EXTERN_LITTLE
) != 0;
551 intern
->r_offset
= ((ext
->r_bits
[1] & RELOC_BITS1_OFFSET_LITTLE
)
552 >> RELOC_BITS1_OFFSET_SH_LITTLE
);
553 /* Ignored the reserved bits. */
554 intern
->r_size
= ((ext
->r_bits
[3] & RELOC_BITS3_SIZE_LITTLE
)
555 >> RELOC_BITS3_SIZE_SH_LITTLE
);
557 if (intern
->r_type
== ALPHA_R_LITUSE
558 || intern
->r_type
== ALPHA_R_GPDISP
)
560 /* Handle the LITUSE and GPDISP relocs specially. Its symndx
561 value is not actually a symbol index, but is instead a
562 special code. We put the code in the r_size field, and
563 clobber the symndx. */
564 if (intern
->r_size
!= 0)
566 intern
->r_size
= intern
->r_symndx
;
567 intern
->r_symndx
= RELOC_SECTION_NONE
;
569 else if (intern
->r_type
== ALPHA_R_IGNORE
)
571 /* The IGNORE reloc generally follows a GPDISP reloc, and is
572 against the .lita section. The section is irrelevant. */
573 if (! intern
->r_extern
&&
574 intern
->r_symndx
== RELOC_SECTION_ABS
)
576 if (! intern
->r_extern
&& intern
->r_symndx
== RELOC_SECTION_LITA
)
577 intern
->r_symndx
= RELOC_SECTION_ABS
;
581 /* Swap a reloc out. */
584 alpha_ecoff_swap_reloc_out (abfd
, intern
, dst
)
586 const struct internal_reloc
*intern
;
589 RELOC
*ext
= (RELOC
*) dst
;
593 /* Undo the hackery done in swap_reloc_in. */
594 if (intern
->r_type
== ALPHA_R_LITUSE
595 || intern
->r_type
== ALPHA_R_GPDISP
)
597 symndx
= intern
->r_size
;
600 else if (intern
->r_type
== ALPHA_R_IGNORE
601 && ! intern
->r_extern
602 && intern
->r_symndx
== RELOC_SECTION_ABS
)
604 symndx
= RELOC_SECTION_LITA
;
605 size
= intern
->r_size
;
609 symndx
= intern
->r_symndx
;
610 size
= intern
->r_size
;
613 /* XXX FIXME: The maximum symndx value used to be 14 but this
614 fails with object files produced by DEC's C++ compiler.
615 Where does the value 14 (or 15) come from anyway ? */
616 BFD_ASSERT (intern
->r_extern
617 || (intern
->r_symndx
>= 0 && intern
->r_symndx
<= 15));
619 H_PUT_64 (abfd
, intern
->r_vaddr
, ext
->r_vaddr
);
620 H_PUT_32 (abfd
, symndx
, ext
->r_symndx
);
622 BFD_ASSERT (bfd_header_little_endian (abfd
));
624 ext
->r_bits
[0] = ((intern
->r_type
<< RELOC_BITS0_TYPE_SH_LITTLE
)
625 & RELOC_BITS0_TYPE_LITTLE
);
626 ext
->r_bits
[1] = ((intern
->r_extern
? RELOC_BITS1_EXTERN_LITTLE
: 0)
627 | ((intern
->r_offset
<< RELOC_BITS1_OFFSET_SH_LITTLE
)
628 & RELOC_BITS1_OFFSET_LITTLE
));
630 ext
->r_bits
[3] = ((size
<< RELOC_BITS3_SIZE_SH_LITTLE
)
631 & RELOC_BITS3_SIZE_LITTLE
);
634 /* Finish canonicalizing a reloc. Part of this is generic to all
635 ECOFF targets, and that part is in ecoff.c. The rest is done in
636 this backend routine. It must fill in the howto field. */
639 alpha_adjust_reloc_in (abfd
, intern
, rptr
)
641 const struct internal_reloc
*intern
;
644 if (intern
->r_type
> ALPHA_R_GPVALUE
)
646 (*_bfd_error_handler
)
647 (_("%B: unknown/unsupported relocation type %d"),
648 abfd
, intern
->r_type
);
649 bfd_set_error (bfd_error_bad_value
);
655 switch (intern
->r_type
)
661 /* This relocs appear to be fully resolved when they are against
662 internal symbols. Against external symbols, BRADDR at least
663 appears to be resolved against the next instruction. */
664 if (! intern
->r_extern
)
667 rptr
->addend
= - (intern
->r_vaddr
+ 4);
670 case ALPHA_R_GPREL32
:
671 case ALPHA_R_LITERAL
:
672 /* Copy the gp value for this object file into the addend, to
673 ensure that we are not confused by the linker. */
674 if (! intern
->r_extern
)
675 rptr
->addend
+= ecoff_data (abfd
)->gp
;
680 /* The LITUSE and GPDISP relocs do not use a symbol, or an
681 addend, but they do use a special code. Put this code in the
683 rptr
->addend
= intern
->r_size
;
686 case ALPHA_R_OP_STORE
:
687 /* The STORE reloc needs the size and offset fields. We store
688 them in the addend. */
689 BFD_ASSERT (intern
->r_offset
<= 256);
690 rptr
->addend
= (intern
->r_offset
<< 8) + intern
->r_size
;
693 case ALPHA_R_OP_PUSH
:
694 case ALPHA_R_OP_PSUB
:
695 case ALPHA_R_OP_PRSHIFT
:
696 /* The PUSH, PSUB and PRSHIFT relocs do not actually use an
697 address. I believe that the address supplied is really an
699 rptr
->addend
= intern
->r_vaddr
;
702 case ALPHA_R_GPVALUE
:
703 /* Set the addend field to the new GP value. */
704 rptr
->addend
= intern
->r_symndx
+ ecoff_data (abfd
)->gp
;
708 /* If the type is ALPHA_R_IGNORE, make sure this is a reference
709 to the absolute section so that the reloc is ignored. For
710 some reason the address of this reloc type is not adjusted by
711 the section vma. We record the gp value for this object file
712 here, for convenience when doing the GPDISP relocation. */
713 rptr
->sym_ptr_ptr
= bfd_abs_section_ptr
->symbol_ptr_ptr
;
714 rptr
->address
= intern
->r_vaddr
;
715 rptr
->addend
= ecoff_data (abfd
)->gp
;
722 rptr
->howto
= &alpha_howto_table
[intern
->r_type
];
725 /* When writing out a reloc we need to pull some values back out of
726 the addend field into the reloc. This is roughly the reverse of
727 alpha_adjust_reloc_in, except that there are several changes we do
731 alpha_adjust_reloc_out (abfd
, rel
, intern
)
732 bfd
*abfd ATTRIBUTE_UNUSED
;
734 struct internal_reloc
*intern
;
736 switch (intern
->r_type
)
740 intern
->r_size
= rel
->addend
;
743 case ALPHA_R_OP_STORE
:
744 intern
->r_size
= rel
->addend
& 0xff;
745 intern
->r_offset
= (rel
->addend
>> 8) & 0xff;
748 case ALPHA_R_OP_PUSH
:
749 case ALPHA_R_OP_PSUB
:
750 case ALPHA_R_OP_PRSHIFT
:
751 intern
->r_vaddr
= rel
->addend
;
755 intern
->r_vaddr
= rel
->address
;
763 /* The size of the stack for the relocation evaluator. */
764 #define RELOC_STACKSIZE (10)
766 /* Alpha ECOFF relocs have a built in expression evaluator as well as
767 other interdependencies. Rather than use a bunch of special
768 functions and global variables, we use a single routine to do all
769 the relocation for a section. I haven't yet worked out how the
770 assembler is going to handle this. */
773 alpha_ecoff_get_relocated_section_contents (abfd
, link_info
, link_order
,
774 data
, relocatable
, symbols
)
776 struct bfd_link_info
*link_info
;
777 struct bfd_link_order
*link_order
;
779 bfd_boolean relocatable
;
782 bfd
*input_bfd
= link_order
->u
.indirect
.section
->owner
;
783 asection
*input_section
= link_order
->u
.indirect
.section
;
784 long reloc_size
= bfd_get_reloc_upper_bound (input_bfd
, input_section
);
785 arelent
**reloc_vector
= NULL
;
787 bfd
*output_bfd
= relocatable
? abfd
: (bfd
*) NULL
;
790 bfd_boolean gp_undefined
;
791 bfd_vma stack
[RELOC_STACKSIZE
];
796 reloc_vector
= (arelent
**) bfd_malloc ((bfd_size_type
) reloc_size
);
797 if (reloc_vector
== NULL
&& reloc_size
!= 0)
800 sz
= input_section
->rawsize
? input_section
->rawsize
: input_section
->size
;
801 if (! bfd_get_section_contents (input_bfd
, input_section
, data
, 0, sz
))
804 reloc_count
= bfd_canonicalize_reloc (input_bfd
, input_section
,
805 reloc_vector
, symbols
);
808 if (reloc_count
== 0)
809 goto successful_return
;
811 /* Get the GP value for the output BFD. */
812 gp_undefined
= FALSE
;
813 gp
= _bfd_get_gp_value (abfd
);
821 /* Make up a value. */
823 for (sec
= abfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
826 && (strcmp (sec
->name
, ".sbss") == 0
827 || strcmp (sec
->name
, ".sdata") == 0
828 || strcmp (sec
->name
, ".lit4") == 0
829 || strcmp (sec
->name
, ".lit8") == 0
830 || strcmp (sec
->name
, ".lita") == 0))
834 _bfd_set_gp_value (abfd
, gp
);
838 struct bfd_link_hash_entry
*h
;
840 h
= bfd_link_hash_lookup (link_info
->hash
, "_gp", FALSE
, FALSE
,
842 if (h
== (struct bfd_link_hash_entry
*) NULL
843 || h
->type
!= bfd_link_hash_defined
)
848 + h
->u
.def
.section
->output_section
->vma
849 + h
->u
.def
.section
->output_offset
);
850 _bfd_set_gp_value (abfd
, gp
);
855 for (; *reloc_vector
!= (arelent
*) NULL
; reloc_vector
++)
858 bfd_reloc_status_type r
;
863 switch (rel
->howto
->type
)
866 rel
->address
+= input_section
->output_offset
;
869 case ALPHA_R_REFLONG
:
870 case ALPHA_R_REFQUAD
:
877 && ((*rel
->sym_ptr_ptr
)->flags
& BSF_SECTION_SYM
) == 0)
879 rel
->address
+= input_section
->output_offset
;
882 r
= bfd_perform_relocation (input_bfd
, rel
, data
, input_section
,
886 case ALPHA_R_GPREL32
:
887 /* This relocation is used in a switch table. It is a 32
888 bit offset from the current GP value. We must adjust it
889 by the different between the original GP value and the
890 current GP value. The original GP value is stored in the
891 addend. We adjust the addend and let
892 bfd_perform_relocation finish the job. */
894 r
= bfd_perform_relocation (input_bfd
, rel
, data
, input_section
,
896 if (r
== bfd_reloc_ok
&& gp_undefined
)
898 r
= bfd_reloc_dangerous
;
899 err
= (char *) _("GP relative relocation used when GP not defined");
903 case ALPHA_R_LITERAL
:
904 /* This is a reference to a literal value, generally
905 (always?) in the .lita section. This is a 16 bit GP
906 relative relocation. Sometimes the subsequent reloc is a
907 LITUSE reloc, which indicates how this reloc is used.
908 This sometimes permits rewriting the two instructions
909 referred to by the LITERAL and the LITUSE into different
910 instructions which do not refer to .lita. This can save
911 a memory reference, and permits removing a value from
912 .lita thus saving GP relative space.
914 We do not these optimizations. To do them we would need
915 to arrange to link the .lita section first, so that by
916 the time we got here we would know the final values to
917 use. This would not be particularly difficult, but it is
918 not currently implemented. */
923 /* I believe that the LITERAL reloc will only apply to a
924 ldq or ldl instruction, so check my assumption. */
925 insn
= bfd_get_32 (input_bfd
, data
+ rel
->address
);
926 BFD_ASSERT (((insn
>> 26) & 0x3f) == 0x29
927 || ((insn
>> 26) & 0x3f) == 0x28);
930 r
= bfd_perform_relocation (input_bfd
, rel
, data
, input_section
,
932 if (r
== bfd_reloc_ok
&& gp_undefined
)
934 r
= bfd_reloc_dangerous
;
936 (char *) _("GP relative relocation used when GP not defined");
942 /* See ALPHA_R_LITERAL above for the uses of this reloc. It
943 does not cause anything to happen, itself. */
944 rel
->address
+= input_section
->output_offset
;
948 /* This marks the ldah of an ldah/lda pair which loads the
949 gp register with the difference of the gp value and the
950 current location. The second of the pair is r_size bytes
951 ahead; it used to be marked with an ALPHA_R_IGNORE reloc,
952 but that no longer happens in OSF/1 3.2. */
954 unsigned long insn1
, insn2
;
957 /* Get the two instructions. */
958 insn1
= bfd_get_32 (input_bfd
, data
+ rel
->address
);
959 insn2
= bfd_get_32 (input_bfd
, data
+ rel
->address
+ rel
->addend
);
961 BFD_ASSERT (((insn1
>> 26) & 0x3f) == 0x09); /* ldah */
962 BFD_ASSERT (((insn2
>> 26) & 0x3f) == 0x08); /* lda */
964 /* Get the existing addend. We must account for the sign
965 extension done by lda and ldah. */
966 addend
= ((insn1
& 0xffff) << 16) + (insn2
& 0xffff);
969 addend
-= 0x80000000;
970 addend
-= 0x80000000;
975 /* The existing addend includes the different between the
976 gp of the input BFD and the address in the input BFD.
977 Subtract this out. */
978 addend
-= (ecoff_data (input_bfd
)->gp
979 - (input_section
->vma
+ rel
->address
));
981 /* Now add in the final gp value, and subtract out the
984 - (input_section
->output_section
->vma
985 + input_section
->output_offset
988 /* Change the instructions, accounting for the sign
989 extension, and write them out. */
992 insn1
= (insn1
& 0xffff0000) | ((addend
>> 16) & 0xffff);
993 insn2
= (insn2
& 0xffff0000) | (addend
& 0xffff);
995 bfd_put_32 (input_bfd
, (bfd_vma
) insn1
, data
+ rel
->address
);
996 bfd_put_32 (input_bfd
, (bfd_vma
) insn2
,
997 data
+ rel
->address
+ rel
->addend
);
999 rel
->address
+= input_section
->output_offset
;
1003 case ALPHA_R_OP_PUSH
:
1004 /* Push a value on the reloc evaluation stack. */
1011 rel
->address
+= input_section
->output_offset
;
1015 /* Figure out the relocation of this symbol. */
1016 symbol
= *rel
->sym_ptr_ptr
;
1018 if (bfd_is_und_section (symbol
->section
))
1019 r
= bfd_reloc_undefined
;
1021 if (bfd_is_com_section (symbol
->section
))
1024 relocation
= symbol
->value
;
1025 relocation
+= symbol
->section
->output_section
->vma
;
1026 relocation
+= symbol
->section
->output_offset
;
1027 relocation
+= rel
->addend
;
1029 if (tos
>= RELOC_STACKSIZE
)
1032 stack
[tos
++] = relocation
;
1036 case ALPHA_R_OP_STORE
:
1037 /* Store a value from the reloc stack into a bitfield. */
1044 rel
->address
+= input_section
->output_offset
;
1051 /* The offset and size for this reloc are encoded into the
1052 addend field by alpha_adjust_reloc_in. */
1053 offset
= (rel
->addend
>> 8) & 0xff;
1054 size
= rel
->addend
& 0xff;
1056 val
= bfd_get_64 (abfd
, data
+ rel
->address
);
1057 val
&=~ (((1 << size
) - 1) << offset
);
1058 val
|= (stack
[--tos
] & ((1 << size
) - 1)) << offset
;
1059 bfd_put_64 (abfd
, val
, data
+ rel
->address
);
1063 case ALPHA_R_OP_PSUB
:
1064 /* Subtract a value from the top of the stack. */
1071 rel
->address
+= input_section
->output_offset
;
1075 /* Figure out the relocation of this symbol. */
1076 symbol
= *rel
->sym_ptr_ptr
;
1078 if (bfd_is_und_section (symbol
->section
))
1079 r
= bfd_reloc_undefined
;
1081 if (bfd_is_com_section (symbol
->section
))
1084 relocation
= symbol
->value
;
1085 relocation
+= symbol
->section
->output_section
->vma
;
1086 relocation
+= symbol
->section
->output_offset
;
1087 relocation
+= rel
->addend
;
1092 stack
[tos
- 1] -= relocation
;
1096 case ALPHA_R_OP_PRSHIFT
:
1097 /* Shift the value on the top of the stack. */
1104 rel
->address
+= input_section
->output_offset
;
1108 /* Figure out the relocation of this symbol. */
1109 symbol
= *rel
->sym_ptr_ptr
;
1111 if (bfd_is_und_section (symbol
->section
))
1112 r
= bfd_reloc_undefined
;
1114 if (bfd_is_com_section (symbol
->section
))
1117 relocation
= symbol
->value
;
1118 relocation
+= symbol
->section
->output_section
->vma
;
1119 relocation
+= symbol
->section
->output_offset
;
1120 relocation
+= rel
->addend
;
1125 stack
[tos
- 1] >>= relocation
;
1129 case ALPHA_R_GPVALUE
:
1130 /* I really don't know if this does the right thing. */
1132 gp_undefined
= FALSE
;
1141 asection
*os
= input_section
->output_section
;
1143 /* A partial link, so keep the relocs. */
1144 os
->orelocation
[os
->reloc_count
] = rel
;
1148 if (r
!= bfd_reloc_ok
)
1152 case bfd_reloc_undefined
:
1153 if (! ((*link_info
->callbacks
->undefined_symbol
)
1154 (link_info
, bfd_asymbol_name (*rel
->sym_ptr_ptr
),
1155 input_bfd
, input_section
, rel
->address
, TRUE
)))
1158 case bfd_reloc_dangerous
:
1159 if (! ((*link_info
->callbacks
->reloc_dangerous
)
1160 (link_info
, err
, input_bfd
, input_section
,
1164 case bfd_reloc_overflow
:
1165 if (! ((*link_info
->callbacks
->reloc_overflow
)
1167 bfd_asymbol_name (*rel
->sym_ptr_ptr
),
1168 rel
->howto
->name
, rel
->addend
, input_bfd
,
1169 input_section
, rel
->address
)))
1172 case bfd_reloc_outofrange
:
1184 if (reloc_vector
!= NULL
)
1185 free (reloc_vector
);
1189 if (reloc_vector
!= NULL
)
1190 free (reloc_vector
);
1194 /* Get the howto structure for a generic reloc type. */
1196 static reloc_howto_type
*
1197 alpha_bfd_reloc_type_lookup (abfd
, code
)
1198 bfd
*abfd ATTRIBUTE_UNUSED
;
1199 bfd_reloc_code_real_type code
;
1206 alpha_type
= ALPHA_R_REFLONG
;
1209 case BFD_RELOC_CTOR
:
1210 alpha_type
= ALPHA_R_REFQUAD
;
1212 case BFD_RELOC_GPREL32
:
1213 alpha_type
= ALPHA_R_GPREL32
;
1215 case BFD_RELOC_ALPHA_LITERAL
:
1216 alpha_type
= ALPHA_R_LITERAL
;
1218 case BFD_RELOC_ALPHA_LITUSE
:
1219 alpha_type
= ALPHA_R_LITUSE
;
1221 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1222 alpha_type
= ALPHA_R_GPDISP
;
1224 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1225 alpha_type
= ALPHA_R_IGNORE
;
1227 case BFD_RELOC_23_PCREL_S2
:
1228 alpha_type
= ALPHA_R_BRADDR
;
1230 case BFD_RELOC_ALPHA_HINT
:
1231 alpha_type
= ALPHA_R_HINT
;
1233 case BFD_RELOC_16_PCREL
:
1234 alpha_type
= ALPHA_R_SREL16
;
1236 case BFD_RELOC_32_PCREL
:
1237 alpha_type
= ALPHA_R_SREL32
;
1239 case BFD_RELOC_64_PCREL
:
1240 alpha_type
= ALPHA_R_SREL64
;
1243 return (reloc_howto_type
*) NULL
;
1246 return &alpha_howto_table
[alpha_type
];
1249 static reloc_howto_type
*
1250 alpha_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1256 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
1258 if (alpha_howto_table
[i
].name
!= NULL
1259 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
1260 return &alpha_howto_table
[i
];
1265 /* A helper routine for alpha_relocate_section which converts an
1266 external reloc when generating relocatable output. Returns the
1267 relocation amount. */
1270 alpha_convert_external_reloc (output_bfd
, info
, input_bfd
, ext_rel
, h
)
1271 bfd
*output_bfd ATTRIBUTE_UNUSED
;
1272 struct bfd_link_info
*info
;
1274 struct external_reloc
*ext_rel
;
1275 struct ecoff_link_hash_entry
*h
;
1277 unsigned long r_symndx
;
1280 BFD_ASSERT (info
->relocatable
);
1282 if (h
->root
.type
== bfd_link_hash_defined
1283 || h
->root
.type
== bfd_link_hash_defweak
)
1288 /* This symbol is defined in the output. Convert the reloc from
1289 being against the symbol to being against the section. */
1291 /* Clear the r_extern bit. */
1292 ext_rel
->r_bits
[1] &=~ RELOC_BITS1_EXTERN_LITTLE
;
1294 /* Compute a new r_symndx value. */
1295 hsec
= h
->root
.u
.def
.section
;
1296 name
= bfd_get_section_name (output_bfd
, hsec
->output_section
);
1298 r_symndx
= (unsigned long) -1;
1302 if (strcmp (name
, "*ABS*") == 0)
1303 r_symndx
= RELOC_SECTION_ABS
;
1306 if (strcmp (name
, ".bss") == 0)
1307 r_symndx
= RELOC_SECTION_BSS
;
1310 if (strcmp (name
, ".data") == 0)
1311 r_symndx
= RELOC_SECTION_DATA
;
1314 if (strcmp (name
, ".fini") == 0)
1315 r_symndx
= RELOC_SECTION_FINI
;
1318 if (strcmp (name
, ".init") == 0)
1319 r_symndx
= RELOC_SECTION_INIT
;
1322 if (strcmp (name
, ".lita") == 0)
1323 r_symndx
= RELOC_SECTION_LITA
;
1324 else if (strcmp (name
, ".lit8") == 0)
1325 r_symndx
= RELOC_SECTION_LIT8
;
1326 else if (strcmp (name
, ".lit4") == 0)
1327 r_symndx
= RELOC_SECTION_LIT4
;
1330 if (strcmp (name
, ".pdata") == 0)
1331 r_symndx
= RELOC_SECTION_PDATA
;
1334 if (strcmp (name
, ".rdata") == 0)
1335 r_symndx
= RELOC_SECTION_RDATA
;
1336 else if (strcmp (name
, ".rconst") == 0)
1337 r_symndx
= RELOC_SECTION_RCONST
;
1340 if (strcmp (name
, ".sdata") == 0)
1341 r_symndx
= RELOC_SECTION_SDATA
;
1342 else if (strcmp (name
, ".sbss") == 0)
1343 r_symndx
= RELOC_SECTION_SBSS
;
1346 if (strcmp (name
, ".text") == 0)
1347 r_symndx
= RELOC_SECTION_TEXT
;
1350 if (strcmp (name
, ".xdata") == 0)
1351 r_symndx
= RELOC_SECTION_XDATA
;
1355 if (r_symndx
== (unsigned long) -1)
1358 /* Add the section VMA and the symbol value. */
1359 relocation
= (h
->root
.u
.def
.value
1360 + hsec
->output_section
->vma
1361 + hsec
->output_offset
);
1365 /* Change the symndx value to the right one for
1368 if (r_symndx
== (unsigned long) -1)
1370 /* Caller must give an error. */
1376 /* Write out the new r_symndx value. */
1377 H_PUT_32 (input_bfd
, r_symndx
, ext_rel
->r_symndx
);
1382 /* Relocate a section while linking an Alpha ECOFF file. This is
1383 quite similar to get_relocated_section_contents. Perhaps they
1384 could be combined somehow. */
1387 alpha_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
1388 contents
, external_relocs
)
1390 struct bfd_link_info
*info
;
1392 asection
*input_section
;
1394 PTR external_relocs
;
1396 asection
**symndx_to_section
, *lita_sec
;
1397 struct ecoff_link_hash_entry
**sym_hashes
;
1399 bfd_boolean gp_undefined
;
1400 bfd_vma stack
[RELOC_STACKSIZE
];
1402 struct external_reloc
*ext_rel
;
1403 struct external_reloc
*ext_rel_end
;
1406 /* We keep a table mapping the symndx found in an internal reloc to
1407 the appropriate section. This is faster than looking up the
1408 section by name each time. */
1409 symndx_to_section
= ecoff_data (input_bfd
)->symndx_to_section
;
1410 if (symndx_to_section
== (asection
**) NULL
)
1412 amt
= NUM_RELOC_SECTIONS
* sizeof (asection
*);
1413 symndx_to_section
= (asection
**) bfd_alloc (input_bfd
, amt
);
1414 if (!symndx_to_section
)
1417 symndx_to_section
[RELOC_SECTION_NONE
] = NULL
;
1418 symndx_to_section
[RELOC_SECTION_TEXT
] =
1419 bfd_get_section_by_name (input_bfd
, ".text");
1420 symndx_to_section
[RELOC_SECTION_RDATA
] =
1421 bfd_get_section_by_name (input_bfd
, ".rdata");
1422 symndx_to_section
[RELOC_SECTION_DATA
] =
1423 bfd_get_section_by_name (input_bfd
, ".data");
1424 symndx_to_section
[RELOC_SECTION_SDATA
] =
1425 bfd_get_section_by_name (input_bfd
, ".sdata");
1426 symndx_to_section
[RELOC_SECTION_SBSS
] =
1427 bfd_get_section_by_name (input_bfd
, ".sbss");
1428 symndx_to_section
[RELOC_SECTION_BSS
] =
1429 bfd_get_section_by_name (input_bfd
, ".bss");
1430 symndx_to_section
[RELOC_SECTION_INIT
] =
1431 bfd_get_section_by_name (input_bfd
, ".init");
1432 symndx_to_section
[RELOC_SECTION_LIT8
] =
1433 bfd_get_section_by_name (input_bfd
, ".lit8");
1434 symndx_to_section
[RELOC_SECTION_LIT4
] =
1435 bfd_get_section_by_name (input_bfd
, ".lit4");
1436 symndx_to_section
[RELOC_SECTION_XDATA
] =
1437 bfd_get_section_by_name (input_bfd
, ".xdata");
1438 symndx_to_section
[RELOC_SECTION_PDATA
] =
1439 bfd_get_section_by_name (input_bfd
, ".pdata");
1440 symndx_to_section
[RELOC_SECTION_FINI
] =
1441 bfd_get_section_by_name (input_bfd
, ".fini");
1442 symndx_to_section
[RELOC_SECTION_LITA
] =
1443 bfd_get_section_by_name (input_bfd
, ".lita");
1444 symndx_to_section
[RELOC_SECTION_ABS
] = bfd_abs_section_ptr
;
1445 symndx_to_section
[RELOC_SECTION_RCONST
] =
1446 bfd_get_section_by_name (input_bfd
, ".rconst");
1448 ecoff_data (input_bfd
)->symndx_to_section
= symndx_to_section
;
1451 sym_hashes
= ecoff_data (input_bfd
)->sym_hashes
;
1453 /* On the Alpha, the .lita section must be addressable by the global
1454 pointer. To support large programs, we need to allow multiple
1455 global pointers. This works as long as each input .lita section
1456 is <64KB big. This implies that when producing relocatable
1457 output, the .lita section is limited to 64KB. . */
1459 lita_sec
= symndx_to_section
[RELOC_SECTION_LITA
];
1460 gp
= _bfd_get_gp_value (output_bfd
);
1461 if (! info
->relocatable
&& lita_sec
!= NULL
)
1463 struct ecoff_section_tdata
*lita_sec_data
;
1465 /* Make sure we have a section data structure to which we can
1466 hang on to the gp value we pick for the section. */
1467 lita_sec_data
= ecoff_section_data (input_bfd
, lita_sec
);
1468 if (lita_sec_data
== NULL
)
1470 amt
= sizeof (struct ecoff_section_tdata
);
1471 lita_sec_data
= ((struct ecoff_section_tdata
*)
1472 bfd_zalloc (input_bfd
, amt
));
1473 lita_sec
->used_by_bfd
= lita_sec_data
;
1476 if (lita_sec_data
->gp
!= 0)
1478 /* If we already assigned a gp to this section, we better
1479 stick with that value. */
1480 gp
= lita_sec_data
->gp
;
1485 bfd_size_type lita_size
;
1487 lita_vma
= lita_sec
->output_offset
+ lita_sec
->output_section
->vma
;
1488 lita_size
= lita_sec
->size
;
1491 || lita_vma
< gp
- 0x8000
1492 || lita_vma
+ lita_size
>= gp
+ 0x8000)
1494 /* Either gp hasn't been set at all or the current gp
1495 cannot address this .lita section. In both cases we
1496 reset the gp to point into the "middle" of the
1497 current input .lita section. */
1498 if (gp
&& !ecoff_data (output_bfd
)->issued_multiple_gp_warning
)
1500 (*info
->callbacks
->warning
) (info
,
1501 _("using multiple gp values"),
1502 (char *) NULL
, output_bfd
,
1503 (asection
*) NULL
, (bfd_vma
) 0);
1504 ecoff_data (output_bfd
)->issued_multiple_gp_warning
= TRUE
;
1506 if (lita_vma
< gp
- 0x8000)
1507 gp
= lita_vma
+ lita_size
- 0x8000;
1509 gp
= lita_vma
+ 0x8000;
1513 lita_sec_data
->gp
= gp
;
1516 _bfd_set_gp_value (output_bfd
, gp
);
1519 gp_undefined
= (gp
== 0);
1521 BFD_ASSERT (bfd_header_little_endian (output_bfd
));
1522 BFD_ASSERT (bfd_header_little_endian (input_bfd
));
1524 ext_rel
= (struct external_reloc
*) external_relocs
;
1525 ext_rel_end
= ext_rel
+ input_section
->reloc_count
;
1526 for (; ext_rel
< ext_rel_end
; ext_rel
++)
1529 unsigned long r_symndx
;
1534 bfd_boolean relocatep
;
1535 bfd_boolean adjust_addrp
;
1536 bfd_boolean gp_usedp
;
1539 r_vaddr
= H_GET_64 (input_bfd
, ext_rel
->r_vaddr
);
1540 r_symndx
= H_GET_32 (input_bfd
, ext_rel
->r_symndx
);
1542 r_type
= ((ext_rel
->r_bits
[0] & RELOC_BITS0_TYPE_LITTLE
)
1543 >> RELOC_BITS0_TYPE_SH_LITTLE
);
1544 r_extern
= (ext_rel
->r_bits
[1] & RELOC_BITS1_EXTERN_LITTLE
) != 0;
1545 r_offset
= ((ext_rel
->r_bits
[1] & RELOC_BITS1_OFFSET_LITTLE
)
1546 >> RELOC_BITS1_OFFSET_SH_LITTLE
);
1547 /* Ignored the reserved bits. */
1548 r_size
= ((ext_rel
->r_bits
[3] & RELOC_BITS3_SIZE_LITTLE
)
1549 >> RELOC_BITS3_SIZE_SH_LITTLE
);
1552 adjust_addrp
= TRUE
;
1558 case ALPHA_R_GPRELHIGH
:
1559 (*_bfd_error_handler
)
1560 (_("%B: unsupported relocation: ALPHA_R_GPRELHIGH"),
1562 bfd_set_error (bfd_error_bad_value
);
1565 case ALPHA_R_GPRELLOW
:
1566 (*_bfd_error_handler
)
1567 (_("%B: unsupported relocation: ALPHA_R_GPRELLOW"),
1569 bfd_set_error (bfd_error_bad_value
);
1573 (*_bfd_error_handler
)
1574 (_("%B: unknown relocation type %d"),
1575 input_bfd
, (int) r_type
);
1576 bfd_set_error (bfd_error_bad_value
);
1579 case ALPHA_R_IGNORE
:
1580 /* This reloc appears after a GPDISP reloc. On earlier
1581 versions of OSF/1, It marked the position of the second
1582 instruction to be altered by the GPDISP reloc, but it is
1583 not otherwise used for anything. For some reason, the
1584 address of the relocation does not appear to include the
1585 section VMA, unlike the other relocation types. */
1586 if (info
->relocatable
)
1587 H_PUT_64 (input_bfd
, input_section
->output_offset
+ r_vaddr
,
1589 adjust_addrp
= FALSE
;
1592 case ALPHA_R_REFLONG
:
1593 case ALPHA_R_REFQUAD
:
1598 case ALPHA_R_BRADDR
:
1599 case ALPHA_R_SREL16
:
1600 case ALPHA_R_SREL32
:
1601 case ALPHA_R_SREL64
:
1603 addend
+= - (r_vaddr
+ 4);
1607 case ALPHA_R_GPREL32
:
1608 /* This relocation is used in a switch table. It is a 32
1609 bit offset from the current GP value. We must adjust it
1610 by the different between the original GP value and the
1611 current GP value. */
1613 addend
= ecoff_data (input_bfd
)->gp
- gp
;
1617 case ALPHA_R_LITERAL
:
1618 /* This is a reference to a literal value, generally
1619 (always?) in the .lita section. This is a 16 bit GP
1620 relative relocation. Sometimes the subsequent reloc is a
1621 LITUSE reloc, which indicates how this reloc is used.
1622 This sometimes permits rewriting the two instructions
1623 referred to by the LITERAL and the LITUSE into different
1624 instructions which do not refer to .lita. This can save
1625 a memory reference, and permits removing a value from
1626 .lita thus saving GP relative space.
1628 We do not these optimizations. To do them we would need
1629 to arrange to link the .lita section first, so that by
1630 the time we got here we would know the final values to
1631 use. This would not be particularly difficult, but it is
1632 not currently implemented. */
1634 /* I believe that the LITERAL reloc will only apply to a ldq
1635 or ldl instruction, so check my assumption. */
1639 insn
= bfd_get_32 (input_bfd
,
1640 contents
+ r_vaddr
- input_section
->vma
);
1641 BFD_ASSERT (((insn
>> 26) & 0x3f) == 0x29
1642 || ((insn
>> 26) & 0x3f) == 0x28);
1646 addend
= ecoff_data (input_bfd
)->gp
- gp
;
1650 case ALPHA_R_LITUSE
:
1651 /* See ALPHA_R_LITERAL above for the uses of this reloc. It
1652 does not cause anything to happen, itself. */
1655 case ALPHA_R_GPDISP
:
1656 /* This marks the ldah of an ldah/lda pair which loads the
1657 gp register with the difference of the gp value and the
1658 current location. The second of the pair is r_symndx
1659 bytes ahead. It used to be marked with an ALPHA_R_IGNORE
1660 reloc, but OSF/1 3.2 no longer does that. */
1662 unsigned long insn1
, insn2
;
1664 /* Get the two instructions. */
1665 insn1
= bfd_get_32 (input_bfd
,
1666 contents
+ r_vaddr
- input_section
->vma
);
1667 insn2
= bfd_get_32 (input_bfd
,
1670 - input_section
->vma
1673 BFD_ASSERT (((insn1
>> 26) & 0x3f) == 0x09); /* ldah */
1674 BFD_ASSERT (((insn2
>> 26) & 0x3f) == 0x08); /* lda */
1676 /* Get the existing addend. We must account for the sign
1677 extension done by lda and ldah. */
1678 addend
= ((insn1
& 0xffff) << 16) + (insn2
& 0xffff);
1681 /* This is addend -= 0x100000000 without causing an
1682 integer overflow on a 32 bit host. */
1683 addend
-= 0x80000000;
1684 addend
-= 0x80000000;
1689 /* The existing addend includes the difference between the
1690 gp of the input BFD and the address in the input BFD.
1691 We want to change this to the difference between the
1692 final GP and the final address. */
1694 - ecoff_data (input_bfd
)->gp
1695 + input_section
->vma
1696 - (input_section
->output_section
->vma
1697 + input_section
->output_offset
));
1699 /* Change the instructions, accounting for the sign
1700 extension, and write them out. */
1701 if (addend
& 0x8000)
1703 insn1
= (insn1
& 0xffff0000) | ((addend
>> 16) & 0xffff);
1704 insn2
= (insn2
& 0xffff0000) | (addend
& 0xffff);
1706 bfd_put_32 (input_bfd
, (bfd_vma
) insn1
,
1707 contents
+ r_vaddr
- input_section
->vma
);
1708 bfd_put_32 (input_bfd
, (bfd_vma
) insn2
,
1709 contents
+ r_vaddr
- input_section
->vma
+ r_symndx
);
1715 case ALPHA_R_OP_PUSH
:
1716 case ALPHA_R_OP_PSUB
:
1717 case ALPHA_R_OP_PRSHIFT
:
1718 /* Manipulate values on the reloc evaluation stack. The
1719 r_vaddr field is not an address in input_section, it is
1720 the current value (including any addend) of the object
1726 s
= symndx_to_section
[r_symndx
];
1727 if (s
== (asection
*) NULL
)
1729 addend
= s
->output_section
->vma
+ s
->output_offset
- s
->vma
;
1733 struct ecoff_link_hash_entry
*h
;
1735 h
= sym_hashes
[r_symndx
];
1736 if (h
== (struct ecoff_link_hash_entry
*) NULL
)
1739 if (! info
->relocatable
)
1741 if (h
->root
.type
== bfd_link_hash_defined
1742 || h
->root
.type
== bfd_link_hash_defweak
)
1743 addend
= (h
->root
.u
.def
.value
1744 + h
->root
.u
.def
.section
->output_section
->vma
1745 + h
->root
.u
.def
.section
->output_offset
);
1748 /* Note that we pass the address as 0, since we
1749 do not have a meaningful number for the
1750 location within the section that is being
1752 if (! ((*info
->callbacks
->undefined_symbol
)
1753 (info
, h
->root
.root
.string
, input_bfd
,
1754 input_section
, (bfd_vma
) 0, TRUE
)))
1761 if (h
->root
.type
!= bfd_link_hash_defined
1762 && h
->root
.type
!= bfd_link_hash_defweak
1765 /* This symbol is not being written out. Pass
1766 the address as 0, as with undefined_symbol,
1768 if (! ((*info
->callbacks
->unattached_reloc
)
1769 (info
, h
->root
.root
.string
, input_bfd
,
1770 input_section
, (bfd_vma
) 0)))
1774 addend
= alpha_convert_external_reloc (output_bfd
, info
,
1782 if (info
->relocatable
)
1784 /* Adjust r_vaddr by the addend. */
1785 H_PUT_64 (input_bfd
, addend
, ext_rel
->r_vaddr
);
1791 case ALPHA_R_OP_PUSH
:
1792 if (tos
>= RELOC_STACKSIZE
)
1794 stack
[tos
++] = addend
;
1797 case ALPHA_R_OP_PSUB
:
1800 stack
[tos
- 1] -= addend
;
1803 case ALPHA_R_OP_PRSHIFT
:
1806 stack
[tos
- 1] >>= addend
;
1811 adjust_addrp
= FALSE
;
1814 case ALPHA_R_OP_STORE
:
1815 /* Store a value from the reloc stack into a bitfield. If
1816 we are generating relocatable output, all we do is
1817 adjust the address of the reloc. */
1818 if (! info
->relocatable
)
1826 /* Get the relocation mask. The separate steps and the
1827 casts to bfd_vma are attempts to avoid a bug in the
1828 Alpha OSF 1.3 C compiler. See reloc.c for more
1831 mask
<<= (bfd_vma
) r_size
;
1834 /* FIXME: I don't know what kind of overflow checking,
1835 if any, should be done here. */
1836 val
= bfd_get_64 (input_bfd
,
1837 contents
+ r_vaddr
- input_section
->vma
);
1838 val
&=~ mask
<< (bfd_vma
) r_offset
;
1839 val
|= (stack
[--tos
] & mask
) << (bfd_vma
) r_offset
;
1840 bfd_put_64 (input_bfd
, val
,
1841 contents
+ r_vaddr
- input_section
->vma
);
1845 case ALPHA_R_GPVALUE
:
1846 /* I really don't know if this does the right thing. */
1847 gp
= ecoff_data (input_bfd
)->gp
+ r_symndx
;
1848 gp_undefined
= FALSE
;
1854 reloc_howto_type
*howto
;
1855 struct ecoff_link_hash_entry
*h
= NULL
;
1858 bfd_reloc_status_type r
;
1860 /* Perform a relocation. */
1862 howto
= &alpha_howto_table
[r_type
];
1866 h
= sym_hashes
[r_symndx
];
1867 /* If h is NULL, that means that there is a reloc
1868 against an external symbol which we thought was just
1869 a debugging symbol. This should not happen. */
1870 if (h
== (struct ecoff_link_hash_entry
*) NULL
)
1875 if (r_symndx
>= NUM_RELOC_SECTIONS
)
1878 s
= symndx_to_section
[r_symndx
];
1880 if (s
== (asection
*) NULL
)
1884 if (info
->relocatable
)
1886 /* We are generating relocatable output, and must
1887 convert the existing reloc. */
1890 if (h
->root
.type
!= bfd_link_hash_defined
1891 && h
->root
.type
!= bfd_link_hash_defweak
1894 /* This symbol is not being written out. */
1895 if (! ((*info
->callbacks
->unattached_reloc
)
1896 (info
, h
->root
.root
.string
, input_bfd
,
1897 input_section
, r_vaddr
- input_section
->vma
)))
1901 relocation
= alpha_convert_external_reloc (output_bfd
,
1909 /* This is a relocation against a section. Adjust
1910 the value by the amount the section moved. */
1911 relocation
= (s
->output_section
->vma
1916 /* If this is PC relative, the existing object file
1917 appears to already have the reloc worked out. We
1918 must subtract out the old value and add in the new
1920 if (howto
->pc_relative
)
1921 relocation
-= (input_section
->output_section
->vma
1922 + input_section
->output_offset
1923 - input_section
->vma
);
1925 /* Put in any addend. */
1926 relocation
+= addend
;
1928 /* Adjust the contents. */
1929 r
= _bfd_relocate_contents (howto
, input_bfd
, relocation
,
1932 - input_section
->vma
));
1936 /* We are producing a final executable. */
1939 /* This is a reloc against a symbol. */
1940 if (h
->root
.type
== bfd_link_hash_defined
1941 || h
->root
.type
== bfd_link_hash_defweak
)
1945 hsec
= h
->root
.u
.def
.section
;
1946 relocation
= (h
->root
.u
.def
.value
1947 + hsec
->output_section
->vma
1948 + hsec
->output_offset
);
1952 if (! ((*info
->callbacks
->undefined_symbol
)
1953 (info
, h
->root
.root
.string
, input_bfd
,
1955 r_vaddr
- input_section
->vma
, TRUE
)))
1962 /* This is a reloc against a section. */
1963 relocation
= (s
->output_section
->vma
1967 /* Adjust a PC relative relocation by removing the
1968 reference to the original source section. */
1969 if (howto
->pc_relative
)
1970 relocation
+= input_section
->vma
;
1973 r
= _bfd_final_link_relocate (howto
,
1977 r_vaddr
- input_section
->vma
,
1982 if (r
!= bfd_reloc_ok
)
1987 case bfd_reloc_outofrange
:
1989 case bfd_reloc_overflow
:
1994 name
= sym_hashes
[r_symndx
]->root
.root
.string
;
1996 name
= bfd_section_name (input_bfd
,
1997 symndx_to_section
[r_symndx
]);
1998 if (! ((*info
->callbacks
->reloc_overflow
)
2000 alpha_howto_table
[r_type
].name
,
2001 (bfd_vma
) 0, input_bfd
, input_section
,
2002 r_vaddr
- input_section
->vma
)))
2010 if (info
->relocatable
&& adjust_addrp
)
2012 /* Change the address of the relocation. */
2013 H_PUT_64 (input_bfd
,
2014 (input_section
->output_section
->vma
2015 + input_section
->output_offset
2016 - input_section
->vma
2021 if (gp_usedp
&& gp_undefined
)
2023 if (! ((*info
->callbacks
->reloc_dangerous
)
2024 (info
, _("GP relative relocation used when GP not defined"),
2025 input_bfd
, input_section
, r_vaddr
- input_section
->vma
)))
2027 /* Only give the error once per link. */
2029 _bfd_set_gp_value (output_bfd
, gp
);
2030 gp_undefined
= FALSE
;
2040 /* Do final adjustments to the filehdr and the aouthdr. This routine
2041 sets the dynamic bits in the file header. */
2044 alpha_adjust_headers (abfd
, fhdr
, ahdr
)
2046 struct internal_filehdr
*fhdr
;
2047 struct internal_aouthdr
*ahdr ATTRIBUTE_UNUSED
;
2049 if ((abfd
->flags
& (DYNAMIC
| EXEC_P
)) == (DYNAMIC
| EXEC_P
))
2050 fhdr
->f_flags
|= F_ALPHA_CALL_SHARED
;
2051 else if ((abfd
->flags
& DYNAMIC
) != 0)
2052 fhdr
->f_flags
|= F_ALPHA_SHARABLE
;
2056 /* Archive handling. In OSF/1 (or Digital Unix) v3.2, Digital
2057 introduced archive packing, in which the elements in an archive are
2058 optionally compressed using a simple dictionary scheme. We know
2059 how to read such archives, but we don't write them. */
2061 #define alpha_ecoff_slurp_armap _bfd_ecoff_slurp_armap
2062 #define alpha_ecoff_slurp_extended_name_table \
2063 _bfd_ecoff_slurp_extended_name_table
2064 #define alpha_ecoff_construct_extended_name_table \
2065 _bfd_ecoff_construct_extended_name_table
2066 #define alpha_ecoff_truncate_arname _bfd_ecoff_truncate_arname
2067 #define alpha_ecoff_write_armap _bfd_ecoff_write_armap
2068 #define alpha_ecoff_generic_stat_arch_elt _bfd_ecoff_generic_stat_arch_elt
2069 #define alpha_ecoff_update_armap_timestamp _bfd_ecoff_update_armap_timestamp
2071 /* A compressed file uses this instead of ARFMAG. */
2073 #define ARFZMAG "Z\012"
2075 /* Read an archive header. This is like the standard routine, but it
2076 also accepts ARFZMAG. */
2079 alpha_ecoff_read_ar_hdr (abfd
)
2082 struct areltdata
*ret
;
2085 ret
= (struct areltdata
*) _bfd_generic_read_ar_hdr_mag (abfd
, ARFZMAG
);
2089 h
= (struct ar_hdr
*) ret
->arch_header
;
2090 if (strncmp (h
->ar_fmag
, ARFZMAG
, 2) == 0)
2094 /* This is a compressed file. We must set the size correctly.
2095 The size is the eight bytes after the dummy file header. */
2096 if (bfd_seek (abfd
, (file_ptr
) FILHSZ
, SEEK_CUR
) != 0
2097 || bfd_bread (ab
, (bfd_size_type
) 8, abfd
) != 8
2098 || bfd_seek (abfd
, (file_ptr
) (- (FILHSZ
+ 8)), SEEK_CUR
) != 0)
2101 ret
->parsed_size
= H_GET_64 (abfd
, ab
);
2107 /* Get an archive element at a specified file position. This is where
2108 we uncompress the archive element if necessary. */
2111 alpha_ecoff_get_elt_at_filepos (archive
, filepos
)
2116 struct areltdata
*tdata
;
2121 struct bfd_in_memory
*bim
;
2123 nbfd
= _bfd_get_elt_at_filepos (archive
, filepos
);
2127 if ((nbfd
->flags
& BFD_IN_MEMORY
) != 0)
2129 /* We have already expanded this BFD. */
2133 tdata
= (struct areltdata
*) nbfd
->arelt_data
;
2134 hdr
= (struct ar_hdr
*) tdata
->arch_header
;
2135 if (strncmp (hdr
->ar_fmag
, ARFZMAG
, 2) != 0)
2138 /* We must uncompress this element. We do this by copying it into a
2139 memory buffer, and making bfd_bread and bfd_seek use that buffer.
2140 This can use a lot of memory, but it's simpler than getting a
2141 temporary file, making that work with the file descriptor caching
2142 code, and making sure that it is deleted at all appropriate
2143 times. It can be changed if it ever becomes important. */
2145 /* The compressed file starts with a dummy ECOFF file header. */
2146 if (bfd_seek (nbfd
, (file_ptr
) FILHSZ
, SEEK_SET
) != 0)
2149 /* The next eight bytes are the real file size. */
2150 if (bfd_bread (ab
, (bfd_size_type
) 8, nbfd
) != 8)
2152 size
= H_GET_64 (nbfd
, ab
);
2159 bfd_byte dict
[4096];
2163 buf
= (bfd_byte
*) bfd_alloc (nbfd
, size
);
2170 /* I don't know what the next eight bytes are for. */
2171 if (bfd_bread (ab
, (bfd_size_type
) 8, nbfd
) != 8)
2174 /* This is the uncompression algorithm. It's a simple
2175 dictionary based scheme in which each character is predicted
2176 by a hash of the previous three characters. A control byte
2177 indicates whether the character is predicted or whether it
2178 appears in the input stream; each control byte manages the
2179 next eight bytes in the output stream. */
2180 memset (dict
, 0, sizeof dict
);
2182 while (bfd_bread (&b
, (bfd_size_type
) 1, nbfd
) == 1)
2186 for (i
= 0; i
< 8; i
++, b
>>= 1)
2194 if (! bfd_bread (&n
, (bfd_size_type
) 1, nbfd
))
2207 h
&= sizeof dict
- 1;
2215 /* Now the uncompressed file contents are in buf. */
2216 bim
= ((struct bfd_in_memory
*)
2217 bfd_alloc (nbfd
, (bfd_size_type
) sizeof (struct bfd_in_memory
)));
2223 nbfd
->mtime_set
= TRUE
;
2224 nbfd
->mtime
= strtol (hdr
->ar_date
, (char **) NULL
, 10);
2226 nbfd
->flags
|= BFD_IN_MEMORY
;
2227 nbfd
->iostream
= (PTR
) bim
;
2228 BFD_ASSERT (! nbfd
->cacheable
);
2238 /* Open the next archived file. */
2241 alpha_ecoff_openr_next_archived_file (archive
, last_file
)
2247 if (last_file
== NULL
)
2248 filestart
= bfd_ardata (archive
)->first_file_filepos
;
2251 struct areltdata
*t
;
2255 /* We can't use arelt_size here, because that uses parsed_size,
2256 which is the uncompressed size. We need the compressed size. */
2257 t
= (struct areltdata
*) last_file
->arelt_data
;
2258 h
= (struct ar_hdr
*) t
->arch_header
;
2259 size
= strtol (h
->ar_size
, (char **) NULL
, 10);
2261 /* Pad to an even boundary...
2262 Note that last_file->origin can be odd in the case of
2263 BSD-4.4-style element with a long odd size. */
2264 filestart
= last_file
->origin
+ size
;
2265 filestart
+= filestart
% 2;
2268 return alpha_ecoff_get_elt_at_filepos (archive
, filestart
);
2271 /* Open the archive file given an index into the armap. */
2274 alpha_ecoff_get_elt_at_index (abfd
, index
)
2280 entry
= bfd_ardata (abfd
)->symdefs
+ index
;
2281 return alpha_ecoff_get_elt_at_filepos (abfd
, entry
->file_offset
);
2284 /* This is the ECOFF backend structure. The backend field of the
2285 target vector points to this. */
2287 static const struct ecoff_backend_data alpha_ecoff_backend_data
=
2289 /* COFF backend structure. */
2291 (void (*) PARAMS ((bfd
*,PTR
,int,int,int,int,PTR
))) bfd_void
, /* aux_in */
2292 (void (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* sym_in */
2293 (void (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* lineno_in */
2294 (unsigned (*) PARAMS ((bfd
*,PTR
,int,int,int,int,PTR
)))bfd_void
,/*aux_out*/
2295 (unsigned (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* sym_out */
2296 (unsigned (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* lineno_out */
2297 (unsigned (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* 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,
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 /* Relaxing sections is generic. */
2394 #define _bfd_ecoff_bfd_relax_section bfd_generic_relax_section
2395 #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections
2396 #define _bfd_ecoff_bfd_merge_sections bfd_generic_merge_sections
2397 #define _bfd_ecoff_bfd_is_group_section bfd_generic_is_group_section
2398 #define _bfd_ecoff_bfd_discard_group bfd_generic_discard_group
2399 #define _bfd_ecoff_section_already_linked \
2400 _bfd_generic_section_already_linked
2401 #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
2403 const bfd_target ecoffalpha_little_vec
=
2405 "ecoff-littlealpha", /* name */
2406 bfd_target_ecoff_flavour
,
2407 BFD_ENDIAN_LITTLE
, /* data byte order is little */
2408 BFD_ENDIAN_LITTLE
, /* header byte order is little */
2410 (HAS_RELOC
| EXEC_P
| /* object flags */
2411 HAS_LINENO
| HAS_DEBUG
|
2412 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
| D_PAGED
),
2414 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_CODE
| SEC_DATA
),
2415 0, /* leading underscore */
2416 ' ', /* ar_pad_char */
2417 15, /* ar_max_namelen */
2418 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
2419 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
2420 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* data */
2421 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
2422 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
2423 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* hdrs */
2425 {_bfd_dummy_target
, alpha_ecoff_object_p
, /* bfd_check_format */
2426 bfd_generic_archive_p
, _bfd_dummy_target
},
2427 {bfd_false
, _bfd_ecoff_mkobject
, /* bfd_set_format */
2428 _bfd_generic_mkarchive
, bfd_false
},
2429 {bfd_false
, _bfd_ecoff_write_object_contents
, /* bfd_write_contents */
2430 _bfd_write_archive_contents
, bfd_false
},
2432 BFD_JUMP_TABLE_GENERIC (_bfd_ecoff
),
2433 BFD_JUMP_TABLE_COPY (_bfd_ecoff
),
2434 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
2435 BFD_JUMP_TABLE_ARCHIVE (alpha_ecoff
),
2436 BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff
),
2437 BFD_JUMP_TABLE_RELOCS (_bfd_ecoff
),
2438 BFD_JUMP_TABLE_WRITE (_bfd_ecoff
),
2439 BFD_JUMP_TABLE_LINK (_bfd_ecoff
),
2440 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic
),
2444 (PTR
) &alpha_ecoff_backend_data