1 /* BFD back-end for ALPHA Extended-Coff files.
2 Copyright (C) 1993-2024 Free Software Foundation, Inc.
3 Modified from coff-mips.c by Steve Chamberlain <sac@cygnus.com> and
4 Ian Lance Taylor <ian@cygnus.com>.
5
6 This file is part of BFD, the Binary File Descriptor library.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
22
23 #include "sysdep.h"
24 #include "bfd.h"
25 #include "bfdlink.h"
26 #include "libbfd.h"
27 #include "coff/internal.h"
28 #include "coff/sym.h"
29 #include "coff/symconst.h"
30 #include "coff/ecoff.h"
31 #include "coff/alpha.h"
32 #include "aout/ar.h"
33 #include "libcoff.h"
34 #include "libecoff.h"
35
36 /* Prototypes for static functions. */
37
38
39
40 /* ECOFF has COFF sections, but the debugging information is stored in
41 a completely different format. ECOFF targets use some of the
42 swapping routines from coffswap.h, and some of the generic COFF
43 routines in coffgen.c, but, unlike the real COFF targets, do not
44 use coffcode.h itself.
45
46 Get the generic COFF swapping routines, except for the reloc,
47 symbol, and lineno ones. Give them ecoff names. Define some
48 accessor macros for the large sizes used for Alpha ECOFF. */
49
50 #define GET_FILEHDR_SYMPTR H_GET_64
51 #define PUT_FILEHDR_SYMPTR H_PUT_64
52 #define GET_AOUTHDR_TSIZE H_GET_64
53 #define PUT_AOUTHDR_TSIZE H_PUT_64
54 #define GET_AOUTHDR_DSIZE H_GET_64
55 #define PUT_AOUTHDR_DSIZE H_PUT_64
56 #define GET_AOUTHDR_BSIZE H_GET_64
57 #define PUT_AOUTHDR_BSIZE H_PUT_64
58 #define GET_AOUTHDR_ENTRY H_GET_64
59 #define PUT_AOUTHDR_ENTRY H_PUT_64
60 #define GET_AOUTHDR_TEXT_START H_GET_64
61 #define PUT_AOUTHDR_TEXT_START H_PUT_64
62 #define GET_AOUTHDR_DATA_START H_GET_64
63 #define PUT_AOUTHDR_DATA_START H_PUT_64
64 #define GET_SCNHDR_PADDR H_GET_64
65 #define PUT_SCNHDR_PADDR H_PUT_64
66 #define GET_SCNHDR_VADDR H_GET_64
67 #define PUT_SCNHDR_VADDR H_PUT_64
68 #define GET_SCNHDR_SIZE H_GET_64
69 #define PUT_SCNHDR_SIZE H_PUT_64
70 #define GET_SCNHDR_SCNPTR H_GET_64
71 #define PUT_SCNHDR_SCNPTR H_PUT_64
72 #define GET_SCNHDR_RELPTR H_GET_64
73 #define PUT_SCNHDR_RELPTR H_PUT_64
74 #define GET_SCNHDR_LNNOPTR H_GET_64
75 #define PUT_SCNHDR_LNNOPTR H_PUT_64
76
77 #define ALPHAECOFF
78
79 #define NO_COFF_RELOCS
80 #define NO_COFF_SYMBOLS
81 #define NO_COFF_LINENOS
82 #define coff_swap_filehdr_in alpha_ecoff_swap_filehdr_in
83 #define coff_swap_filehdr_out alpha_ecoff_swap_filehdr_out
84 #define coff_swap_aouthdr_in alpha_ecoff_swap_aouthdr_in
85 #define coff_swap_aouthdr_out alpha_ecoff_swap_aouthdr_out
86 #define coff_swap_scnhdr_in alpha_ecoff_swap_scnhdr_in
87 #define coff_swap_scnhdr_out alpha_ecoff_swap_scnhdr_out
88 #include "coffswap.h"
89
90 /* Get the ECOFF swapping routines. */
91 #define ECOFF_64
92 #include "ecoffswap.h"
93
94 /* How to process the various reloc types. */
95
96 static bfd_reloc_status_type
reloc_nil(bfd * abfd ATTRIBUTE_UNUSED,arelent * reloc ATTRIBUTE_UNUSED,asymbol * sym ATTRIBUTE_UNUSED,void * data ATTRIBUTE_UNUSED,asection * sec ATTRIBUTE_UNUSED,bfd * output_bfd ATTRIBUTE_UNUSED,char ** error_message ATTRIBUTE_UNUSED)97 reloc_nil (bfd *abfd ATTRIBUTE_UNUSED,
98 arelent *reloc ATTRIBUTE_UNUSED,
99 asymbol *sym ATTRIBUTE_UNUSED,
100 void * data ATTRIBUTE_UNUSED,
101 asection *sec ATTRIBUTE_UNUSED,
102 bfd *output_bfd ATTRIBUTE_UNUSED,
103 char **error_message ATTRIBUTE_UNUSED)
104 {
105 return bfd_reloc_ok;
106 }
107
108 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
109 from smaller values. Start with zero, widen, *then* decrement. */
110 #define MINUS_ONE (((bfd_vma)0) - 1)
111
112 static reloc_howto_type alpha_howto_table[] =
113 {
114 /* Reloc type 0 is ignored by itself. However, it appears after a
115 GPDISP reloc to identify the location where the low order 16 bits
116 of the gp register are loaded. */
117 HOWTO (ALPHA_R_IGNORE, /* type */
118 0, /* rightshift */
119 1, /* size */
120 8, /* bitsize */
121 true, /* pc_relative */
122 0, /* bitpos */
123 complain_overflow_dont, /* complain_on_overflow */
124 reloc_nil, /* special_function */
125 "IGNORE", /* name */
126 true, /* partial_inplace */
127 0, /* src_mask */
128 0, /* dst_mask */
129 true), /* pcrel_offset */
130
131 /* A 32 bit reference to a symbol. */
132 HOWTO (ALPHA_R_REFLONG, /* type */
133 0, /* rightshift */
134 4, /* size */
135 32, /* bitsize */
136 false, /* pc_relative */
137 0, /* bitpos */
138 complain_overflow_bitfield, /* complain_on_overflow */
139 0, /* special_function */
140 "REFLONG", /* name */
141 true, /* partial_inplace */
142 0xffffffff, /* src_mask */
143 0xffffffff, /* dst_mask */
144 false), /* pcrel_offset */
145
146 /* A 64 bit reference to a symbol. */
147 HOWTO (ALPHA_R_REFQUAD, /* type */
148 0, /* rightshift */
149 8, /* size */
150 64, /* bitsize */
151 false, /* pc_relative */
152 0, /* bitpos */
153 complain_overflow_bitfield, /* complain_on_overflow */
154 0, /* special_function */
155 "REFQUAD", /* name */
156 true, /* partial_inplace */
157 MINUS_ONE, /* src_mask */
158 MINUS_ONE, /* dst_mask */
159 false), /* pcrel_offset */
160
161 /* A 32 bit GP relative offset. This is just like REFLONG except
162 that when the value is used the value of the gp register will be
163 added in. */
164 HOWTO (ALPHA_R_GPREL32, /* type */
165 0, /* rightshift */
166 4, /* size */
167 32, /* bitsize */
168 false, /* pc_relative */
169 0, /* bitpos */
170 complain_overflow_bitfield, /* complain_on_overflow */
171 0, /* special_function */
172 "GPREL32", /* name */
173 true, /* partial_inplace */
174 0xffffffff, /* src_mask */
175 0xffffffff, /* dst_mask */
176 false), /* pcrel_offset */
177
178 /* Used for an instruction that refers to memory off the GP
179 register. The offset is 16 bits of the 32 bit instruction. This
180 reloc always seems to be against the .lita section. */
181 HOWTO (ALPHA_R_LITERAL, /* type */
182 0, /* rightshift */
183 4, /* size */
184 16, /* bitsize */
185 false, /* pc_relative */
186 0, /* bitpos */
187 complain_overflow_signed, /* complain_on_overflow */
188 0, /* special_function */
189 "LITERAL", /* name */
190 true, /* partial_inplace */
191 0xffff, /* src_mask */
192 0xffff, /* dst_mask */
193 false), /* pcrel_offset */
194
195 /* This reloc only appears immediately following a LITERAL reloc.
196 It identifies a use of the literal. It seems that the linker can
197 use this to eliminate a portion of the .lita section. The symbol
198 index is special: 1 means the literal address is in the base
199 register of a memory format instruction; 2 means the literal
200 address is in the byte offset register of a byte-manipulation
201 instruction; 3 means the literal address is in the target
202 register of a jsr instruction. This does not actually do any
203 relocation. */
204 HOWTO (ALPHA_R_LITUSE, /* type */
205 0, /* rightshift */
206 4, /* size */
207 32, /* bitsize */
208 false, /* pc_relative */
209 0, /* bitpos */
210 complain_overflow_dont, /* complain_on_overflow */
211 reloc_nil, /* special_function */
212 "LITUSE", /* name */
213 false, /* partial_inplace */
214 0, /* src_mask */
215 0, /* dst_mask */
216 false), /* pcrel_offset */
217
218 /* Load the gp register. This is always used for a ldah instruction
219 which loads the upper 16 bits of the gp register. The next reloc
220 will be an IGNORE reloc which identifies the location of the lda
221 instruction which loads the lower 16 bits. The symbol index of
222 the GPDISP instruction appears to actually be the number of bytes
223 between the ldah and lda instructions. This gives two different
224 ways to determine where the lda instruction is; I don't know why
225 both are used. The value to use for the relocation is the
226 difference between the GP value and the current location; the
227 load will always be done against a register holding the current
228 address. */
229 HOWTO (ALPHA_R_GPDISP, /* type */
230 16, /* rightshift */
231 4, /* size */
232 16, /* bitsize */
233 true, /* pc_relative */
234 0, /* bitpos */
235 complain_overflow_dont, /* complain_on_overflow */
236 reloc_nil, /* special_function */
237 "GPDISP", /* name */
238 true, /* partial_inplace */
239 0xffff, /* src_mask */
240 0xffff, /* dst_mask */
241 true), /* pcrel_offset */
242
243 /* A 21 bit branch. The native assembler generates these for
244 branches within the text segment, and also fills in the PC
245 relative offset in the instruction. */
246 HOWTO (ALPHA_R_BRADDR, /* type */
247 2, /* rightshift */
248 4, /* size */
249 21, /* bitsize */
250 true, /* pc_relative */
251 0, /* bitpos */
252 complain_overflow_signed, /* complain_on_overflow */
253 0, /* special_function */
254 "BRADDR", /* name */
255 true, /* partial_inplace */
256 0x1fffff, /* src_mask */
257 0x1fffff, /* dst_mask */
258 false), /* pcrel_offset */
259
260 /* A hint for a jump to a register. */
261 HOWTO (ALPHA_R_HINT, /* type */
262 2, /* rightshift */
263 4, /* size */
264 14, /* bitsize */
265 true, /* pc_relative */
266 0, /* bitpos */
267 complain_overflow_dont, /* complain_on_overflow */
268 0, /* special_function */
269 "HINT", /* name */
270 true, /* partial_inplace */
271 0x3fff, /* src_mask */
272 0x3fff, /* dst_mask */
273 false), /* pcrel_offset */
274
275 /* 16 bit PC relative offset. */
276 HOWTO (ALPHA_R_SREL16, /* type */
277 0, /* rightshift */
278 2, /* size */
279 16, /* bitsize */
280 true, /* pc_relative */
281 0, /* bitpos */
282 complain_overflow_signed, /* complain_on_overflow */
283 0, /* special_function */
284 "SREL16", /* name */
285 true, /* partial_inplace */
286 0xffff, /* src_mask */
287 0xffff, /* dst_mask */
288 false), /* pcrel_offset */
289
290 /* 32 bit PC relative offset. */
291 HOWTO (ALPHA_R_SREL32, /* type */
292 0, /* rightshift */
293 4, /* size */
294 32, /* bitsize */
295 true, /* pc_relative */
296 0, /* bitpos */
297 complain_overflow_signed, /* complain_on_overflow */
298 0, /* special_function */
299 "SREL32", /* name */
300 true, /* partial_inplace */
301 0xffffffff, /* src_mask */
302 0xffffffff, /* dst_mask */
303 false), /* pcrel_offset */
304
305 /* A 64 bit PC relative offset. */
306 HOWTO (ALPHA_R_SREL64, /* type */
307 0, /* rightshift */
308 8, /* size */
309 64, /* bitsize */
310 true, /* pc_relative */
311 0, /* bitpos */
312 complain_overflow_signed, /* complain_on_overflow */
313 0, /* special_function */
314 "SREL64", /* name */
315 true, /* partial_inplace */
316 MINUS_ONE, /* src_mask */
317 MINUS_ONE, /* dst_mask */
318 false), /* pcrel_offset */
319
320 /* Push a value on the reloc evaluation stack. */
321 HOWTO (ALPHA_R_OP_PUSH, /* type */
322 0, /* rightshift */
323 0, /* size */
324 0, /* bitsize */
325 false, /* pc_relative */
326 0, /* bitpos */
327 complain_overflow_dont, /* complain_on_overflow */
328 0, /* special_function */
329 "OP_PUSH", /* name */
330 false, /* partial_inplace */
331 0, /* src_mask */
332 0, /* dst_mask */
333 false), /* pcrel_offset */
334
335 /* Store the value from the stack at the given address. Store it in
336 a bitfield of size r_size starting at bit position r_offset. */
337 HOWTO (ALPHA_R_OP_STORE, /* type */
338 0, /* rightshift */
339 8, /* size */
340 64, /* bitsize */
341 false, /* pc_relative */
342 0, /* bitpos */
343 complain_overflow_dont, /* complain_on_overflow */
344 0, /* special_function */
345 "OP_STORE", /* name */
346 false, /* partial_inplace */
347 0, /* src_mask */
348 MINUS_ONE, /* dst_mask */
349 false), /* pcrel_offset */
350
351 /* Subtract the reloc address from the value on the top of the
352 relocation stack. */
353 HOWTO (ALPHA_R_OP_PSUB, /* type */
354 0, /* rightshift */
355 0, /* size */
356 0, /* bitsize */
357 false, /* pc_relative */
358 0, /* bitpos */
359 complain_overflow_dont, /* complain_on_overflow */
360 0, /* special_function */
361 "OP_PSUB", /* name */
362 false, /* partial_inplace */
363 0, /* src_mask */
364 0, /* dst_mask */
365 false), /* pcrel_offset */
366
367 /* Shift the value on the top of the relocation stack right by the
368 given value. */
369 HOWTO (ALPHA_R_OP_PRSHIFT, /* type */
370 0, /* rightshift */
371 0, /* size */
372 0, /* bitsize */
373 false, /* pc_relative */
374 0, /* bitpos */
375 complain_overflow_dont, /* complain_on_overflow */
376 0, /* special_function */
377 "OP_PRSHIFT", /* name */
378 false, /* partial_inplace */
379 0, /* src_mask */
380 0, /* dst_mask */
381 false), /* pcrel_offset */
382
383 /* Adjust the GP value for a new range in the object file. */
384 HOWTO (ALPHA_R_GPVALUE, /* type */
385 0, /* rightshift */
386 0, /* size */
387 0, /* bitsize */
388 false, /* pc_relative */
389 0, /* bitpos */
390 complain_overflow_dont, /* complain_on_overflow */
391 0, /* special_function */
392 "GPVALUE", /* name */
393 false, /* partial_inplace */
394 0, /* src_mask */
395 0, /* dst_mask */
396 false) /* pcrel_offset */
397 };
398
399 /* Recognize an Alpha ECOFF file. */
400
401 static bfd_cleanup
alpha_ecoff_object_p(bfd * abfd)402 alpha_ecoff_object_p (bfd *abfd)
403 {
404 bfd_cleanup ret;
405
406 ret = coff_object_p (abfd);
407
408 if (ret != NULL)
409 {
410 asection *sec;
411
412 /* Alpha ECOFF has a .pdata section. The lnnoptr field of the
413 .pdata section is the number of entries it contains. Each
414 entry takes up 8 bytes. The number of entries is required
415 since the section is aligned to a 16 byte boundary. When we
416 link .pdata sections together, we do not want to include the
417 alignment bytes. We handle this on input by faking the size
418 of the .pdata section to remove the unwanted alignment bytes.
419 On output we will set the lnnoptr field and force the
420 alignment. */
421 sec = bfd_get_section_by_name (abfd, _PDATA);
422 if (sec != (asection *) NULL)
423 {
424 bfd_size_type size;
425
426 size = (bfd_size_type) sec->line_filepos * 8;
427 BFD_ASSERT (size == sec->size
428 || size + 8 == sec->size);
429 if (!bfd_set_section_size (sec, size))
430 return NULL;
431 }
432 }
433
434 return ret;
435 }
436
437 /* See whether the magic number matches. */
438
439 static bool
alpha_ecoff_bad_format_hook(bfd * abfd ATTRIBUTE_UNUSED,void * filehdr)440 alpha_ecoff_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED,
441 void * filehdr)
442 {
443 struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
444
445 if (! ALPHA_ECOFF_BADMAG (*internal_f))
446 return true;
447
448 if (ALPHA_ECOFF_COMPRESSEDMAG (*internal_f))
449 _bfd_error_handler
450 (_("%pB: cannot handle compressed Alpha binaries; "
451 "use compiler flags, or objZ, to generate uncompressed binaries"),
452 abfd);
453
454 return false;
455 }
456
457 /* This is a hook called by coff_real_object_p to create any backend
458 specific information. */
459
460 static void *
alpha_ecoff_mkobject_hook(bfd * abfd,void * filehdr,void * aouthdr)461 alpha_ecoff_mkobject_hook (bfd *abfd, void * filehdr, void * aouthdr)
462 {
463 void * ecoff;
464
465 ecoff = _bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr);
466
467 if (ecoff != NULL)
468 {
469 struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
470
471 /* Set additional BFD flags according to the object type from the
472 machine specific file header flags. */
473 switch (internal_f->f_flags & F_ALPHA_OBJECT_TYPE_MASK)
474 {
475 case F_ALPHA_SHARABLE:
476 abfd->flags |= DYNAMIC;
477 break;
478 case F_ALPHA_CALL_SHARED:
479 /* Always executable if using shared libraries as the run time
480 loader might resolve undefined references. */
481 abfd->flags |= (DYNAMIC | EXEC_P);
482 break;
483 }
484 }
485 return ecoff;
486 }
487
488 /* Reloc handling. */
489
490 /* Swap a reloc in. */
491
492 static void
alpha_ecoff_swap_reloc_in(bfd * abfd,void * ext_ptr,struct internal_reloc * intern)493 alpha_ecoff_swap_reloc_in (bfd *abfd,
494 void * ext_ptr,
495 struct internal_reloc *intern)
496 {
497 const RELOC *ext = (RELOC *) ext_ptr;
498
499 intern->r_vaddr = H_GET_64 (abfd, ext->r_vaddr);
500 intern->r_symndx = H_GET_32 (abfd, ext->r_symndx);
501
502 BFD_ASSERT (bfd_header_little_endian (abfd));
503
504 intern->r_type = ((ext->r_bits[0] & RELOC_BITS0_TYPE_LITTLE)
505 >> RELOC_BITS0_TYPE_SH_LITTLE);
506 intern->r_extern = (ext->r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0;
507 intern->r_offset = ((ext->r_bits[1] & RELOC_BITS1_OFFSET_LITTLE)
508 >> RELOC_BITS1_OFFSET_SH_LITTLE);
509 /* Ignored the reserved bits. */
510 intern->r_size = ((ext->r_bits[3] & RELOC_BITS3_SIZE_LITTLE)
511 >> RELOC_BITS3_SIZE_SH_LITTLE);
512
513 if (intern->r_type == ALPHA_R_LITUSE
514 || intern->r_type == ALPHA_R_GPDISP)
515 {
516 /* Handle the LITUSE and GPDISP relocs specially. Its symndx
517 value is not actually a symbol index, but is instead a
518 special code. We put the code in the r_size field, and
519 clobber the symndx. */
520 if (intern->r_size != 0)
521 abort ();
522 intern->r_size = intern->r_symndx;
523 intern->r_symndx = RELOC_SECTION_NONE;
524 }
525 else if (intern->r_type == ALPHA_R_IGNORE)
526 {
527 /* The IGNORE reloc generally follows a GPDISP reloc, and is
528 against the .lita section. The section is irrelevant. */
529 if (! intern->r_extern &&
530 intern->r_symndx == RELOC_SECTION_ABS)
531 abort ();
532 if (! intern->r_extern && intern->r_symndx == RELOC_SECTION_LITA)
533 intern->r_symndx = RELOC_SECTION_ABS;
534 }
535 }
536
537 /* Swap a reloc out. */
538
539 static void
alpha_ecoff_swap_reloc_out(bfd * abfd,const struct internal_reloc * intern,void * dst)540 alpha_ecoff_swap_reloc_out (bfd *abfd,
541 const struct internal_reloc *intern,
542 void * dst)
543 {
544 RELOC *ext = (RELOC *) dst;
545 long symndx;
546 unsigned char size;
547
548 /* Undo the hackery done in swap_reloc_in. */
549 if (intern->r_type == ALPHA_R_LITUSE
550 || intern->r_type == ALPHA_R_GPDISP)
551 {
552 symndx = intern->r_size;
553 size = 0;
554 }
555 else if (intern->r_type == ALPHA_R_IGNORE
556 && ! intern->r_extern
557 && intern->r_symndx == RELOC_SECTION_ABS)
558 {
559 symndx = RELOC_SECTION_LITA;
560 size = intern->r_size;
561 }
562 else
563 {
564 symndx = intern->r_symndx;
565 size = intern->r_size;
566 }
567
568 /* XXX FIXME: The maximum symndx value used to be 14 but this
569 fails with object files produced by DEC's C++ compiler.
570 Where does the value 14 (or 15) come from anyway ? */
571 BFD_ASSERT (intern->r_extern
572 || (intern->r_symndx >= 0 && intern->r_symndx <= 15));
573
574 H_PUT_64 (abfd, intern->r_vaddr, ext->r_vaddr);
575 H_PUT_32 (abfd, symndx, ext->r_symndx);
576
577 BFD_ASSERT (bfd_header_little_endian (abfd));
578
579 ext->r_bits[0] = ((intern->r_type << RELOC_BITS0_TYPE_SH_LITTLE)
580 & RELOC_BITS0_TYPE_LITTLE);
581 ext->r_bits[1] = ((intern->r_extern ? RELOC_BITS1_EXTERN_LITTLE : 0)
582 | ((intern->r_offset << RELOC_BITS1_OFFSET_SH_LITTLE)
583 & RELOC_BITS1_OFFSET_LITTLE));
584 ext->r_bits[2] = 0;
585 ext->r_bits[3] = ((size << RELOC_BITS3_SIZE_SH_LITTLE)
586 & RELOC_BITS3_SIZE_LITTLE);
587 }
588
589 /* Finish canonicalizing a reloc. Part of this is generic to all
590 ECOFF targets, and that part is in ecoff.c. The rest is done in
591 this backend routine. It must fill in the howto field. */
592
593 static void
alpha_adjust_reloc_in(bfd * abfd,const struct internal_reloc * intern,arelent * rptr)594 alpha_adjust_reloc_in (bfd *abfd,
595 const struct internal_reloc *intern,
596 arelent *rptr)
597 {
598 if (intern->r_type > ALPHA_R_GPVALUE)
599 {
600 /* xgettext:c-format */
601 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
602 abfd, intern->r_type);
603 bfd_set_error (bfd_error_bad_value);
604 rptr->addend = 0;
605 rptr->howto = NULL;
606 return;
607 }
608
609 switch (intern->r_type)
610 {
611 case ALPHA_R_BRADDR:
612 case ALPHA_R_SREL16:
613 case ALPHA_R_SREL32:
614 case ALPHA_R_SREL64:
615 /* This relocs appear to be fully resolved when they are against
616 internal symbols. Against external symbols, BRADDR at least
617 appears to be resolved against the next instruction. */
618 if (! intern->r_extern)
619 rptr->addend = 0;
620 else
621 rptr->addend = - (intern->r_vaddr + 4);
622 break;
623
624 case ALPHA_R_GPREL32:
625 case ALPHA_R_LITERAL:
626 /* Copy the gp value for this object file into the addend, to
627 ensure that we are not confused by the linker. */
628 if (! intern->r_extern)
629 rptr->addend += ecoff_data (abfd)->gp;
630 break;
631
632 case ALPHA_R_LITUSE:
633 case ALPHA_R_GPDISP:
634 /* The LITUSE and GPDISP relocs do not use a symbol, or an
635 addend, but they do use a special code. Put this code in the
636 addend field. */
637 rptr->addend = intern->r_size;
638 break;
639
640 case ALPHA_R_OP_STORE:
641 /* The STORE reloc needs the size and offset fields. We store
642 them in the addend. */
643 #if 0
644 BFD_ASSERT (intern->r_offset <= 256);
645 #endif
646 rptr->addend = (intern->r_offset << 8) + intern->r_size;
647 break;
648
649 case ALPHA_R_OP_PUSH:
650 case ALPHA_R_OP_PSUB:
651 case ALPHA_R_OP_PRSHIFT:
652 /* The PUSH, PSUB and PRSHIFT relocs do not actually use an
653 address. I believe that the address supplied is really an
654 addend. */
655 rptr->addend = intern->r_vaddr;
656 break;
657
658 case ALPHA_R_GPVALUE:
659 /* Set the addend field to the new GP value. */
660 rptr->addend = intern->r_symndx + ecoff_data (abfd)->gp;
661 break;
662
663 case ALPHA_R_IGNORE:
664 /* If the type is ALPHA_R_IGNORE, make sure this is a reference
665 to the absolute section so that the reloc is ignored. For
666 some reason the address of this reloc type is not adjusted by
667 the section vma. We record the gp value for this object file
668 here, for convenience when doing the GPDISP relocation. */
669 rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
670 rptr->address = intern->r_vaddr;
671 rptr->addend = ecoff_data (abfd)->gp;
672 break;
673
674 default:
675 break;
676 }
677
678 rptr->howto = &alpha_howto_table[intern->r_type];
679 }
680
681 /* When writing out a reloc we need to pull some values back out of
682 the addend field into the reloc. This is roughly the reverse of
683 alpha_adjust_reloc_in, except that there are several changes we do
684 not need to undo. */
685
686 static void
alpha_adjust_reloc_out(bfd * abfd ATTRIBUTE_UNUSED,const arelent * rel,struct internal_reloc * intern)687 alpha_adjust_reloc_out (bfd *abfd ATTRIBUTE_UNUSED,
688 const arelent *rel,
689 struct internal_reloc *intern)
690 {
691 switch (intern->r_type)
692 {
693 case ALPHA_R_LITUSE:
694 case ALPHA_R_GPDISP:
695 intern->r_size = rel->addend;
696 break;
697
698 case ALPHA_R_OP_STORE:
699 intern->r_size = rel->addend & 0xff;
700 intern->r_offset = (rel->addend >> 8) & 0xff;
701 break;
702
703 case ALPHA_R_OP_PUSH:
704 case ALPHA_R_OP_PSUB:
705 case ALPHA_R_OP_PRSHIFT:
706 intern->r_vaddr = rel->addend;
707 break;
708
709 case ALPHA_R_IGNORE:
710 intern->r_vaddr = rel->address;
711 break;
712
713 default:
714 break;
715 }
716 }
717
718 /* The size of the stack for the relocation evaluator. */
719 #define RELOC_STACKSIZE (10)
720
721 /* Alpha ECOFF relocs have a built in expression evaluator as well as
722 other interdependencies. Rather than use a bunch of special
723 functions and global variables, we use a single routine to do all
724 the relocation for a section. I haven't yet worked out how the
725 assembler is going to handle this. */
726
727 static bfd_byte *
alpha_ecoff_get_relocated_section_contents(bfd * abfd,struct bfd_link_info * link_info,struct bfd_link_order * link_order,bfd_byte * data,bool relocatable,asymbol ** symbols)728 alpha_ecoff_get_relocated_section_contents (bfd *abfd,
729 struct bfd_link_info *link_info,
730 struct bfd_link_order *link_order,
731 bfd_byte *data,
732 bool relocatable,
733 asymbol **symbols)
734 {
735 bfd *input_bfd = link_order->u.indirect.section->owner;
736 asection *input_section = link_order->u.indirect.section;
737 long reloc_size;
738 arelent **reloc_vector;
739 long reloc_count;
740 bfd *output_bfd = relocatable ? abfd : (bfd *) NULL;
741 bfd_vma gp;
742 bool gp_undefined;
743 bfd_vma stack[RELOC_STACKSIZE];
744 int tos = 0;
745
746 reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
747 if (reloc_size < 0)
748 return NULL;
749
750 bfd_byte *orig_data = data;
751 if (!bfd_get_full_section_contents (input_bfd, input_section, &data))
752 return NULL;
753
754 if (data == NULL)
755 return NULL;
756
757 if (reloc_size == 0)
758 return data;
759
760 reloc_vector = (arelent **) bfd_malloc (reloc_size);
761 if (reloc_vector == NULL)
762 goto error_return;
763
764 reloc_count = bfd_canonicalize_reloc (input_bfd, input_section,
765 reloc_vector, symbols);
766 if (reloc_count < 0)
767 goto error_return;
768 if (reloc_count == 0)
769 goto successful_return;
770
771 /* Get the GP value for the output BFD. */
772 gp_undefined = false;
773 gp = _bfd_get_gp_value (abfd);
774 if (gp == 0)
775 {
776 if (relocatable)
777 {
778 asection *sec;
779 bfd_vma lo;
780
781 /* Make up a value. */
782 lo = (bfd_vma) -1;
783 for (sec = abfd->sections; sec != NULL; sec = sec->next)
784 {
785 if (sec->vma < lo
786 && (strcmp (sec->name, ".sbss") == 0
787 || strcmp (sec->name, ".sdata") == 0
788 || strcmp (sec->name, ".lit4") == 0
789 || strcmp (sec->name, ".lit8") == 0
790 || strcmp (sec->name, ".lita") == 0))
791 lo = sec->vma;
792 }
793 gp = lo + 0x8000;
794 _bfd_set_gp_value (abfd, gp);
795 }
796 else
797 {
798 struct bfd_link_hash_entry *h;
799
800 h = bfd_link_hash_lookup (link_info->hash, "_gp", false, false,
801 true);
802 if (h == (struct bfd_link_hash_entry *) NULL
803 || h->type != bfd_link_hash_defined)
804 gp_undefined = true;
805 else
806 {
807 gp = (h->u.def.value
808 + h->u.def.section->output_section->vma
809 + h->u.def.section->output_offset);
810 _bfd_set_gp_value (abfd, gp);
811 }
812 }
813 }
814
815 for (arelent **relp = reloc_vector; *relp != NULL; relp++)
816 {
817 arelent *rel;
818 bfd_reloc_status_type r;
819 char *err;
820 unsigned int r_type;
821
822 rel = *relp;
823 if (rel->howto == NULL)
824 {
825 r = bfd_reloc_notsupported;
826 r_type = ALPHA_R_IGNORE;
827 }
828 else
829 {
830 r = bfd_reloc_ok;
831 r_type = rel->howto->type;
832 }
833 switch (r_type)
834 {
835 case ALPHA_R_IGNORE:
836 rel->address += input_section->output_offset;
837 break;
838
839 case ALPHA_R_REFLONG:
840 case ALPHA_R_REFQUAD:
841 case ALPHA_R_BRADDR:
842 case ALPHA_R_HINT:
843 case ALPHA_R_SREL16:
844 case ALPHA_R_SREL32:
845 case ALPHA_R_SREL64:
846 if (relocatable
847 && ((*rel->sym_ptr_ptr)->flags & BSF_SECTION_SYM) == 0)
848 {
849 rel->address += input_section->output_offset;
850 break;
851 }
852 r = bfd_perform_relocation (input_bfd, rel, data, input_section,
853 output_bfd, &err);
854 break;
855
856 case ALPHA_R_GPREL32:
857 /* This relocation is used in a switch table. It is a 32
858 bit offset from the current GP value. We must adjust it
859 by the different between the original GP value and the
860 current GP value. The original GP value is stored in the
861 addend. We adjust the addend and let
862 bfd_perform_relocation finish the job. */
863 rel->addend -= gp;
864 r = bfd_perform_relocation (input_bfd, rel, data, input_section,
865 output_bfd, &err);
866 if (r == bfd_reloc_ok && gp_undefined)
867 {
868 r = bfd_reloc_dangerous;
869 err = (char *) _("GP relative relocation used when GP not defined");
870 }
871 break;
872
873 case ALPHA_R_LITERAL:
874 /* This is a reference to a literal value, generally
875 (always?) in the .lita section. This is a 16 bit GP
876 relative relocation. Sometimes the subsequent reloc is a
877 LITUSE reloc, which indicates how this reloc is used.
878 This sometimes permits rewriting the two instructions
879 referred to by the LITERAL and the LITUSE into different
880 instructions which do not refer to .lita. This can save
881 a memory reference, and permits removing a value from
882 .lita thus saving GP relative space.
883
884 We do not these optimizations. To do them we would need
885 to arrange to link the .lita section first, so that by
886 the time we got here we would know the final values to
887 use. This would not be particularly difficult, but it is
888 not currently implemented. */
889
890 rel->addend -= gp;
891 r = bfd_perform_relocation (input_bfd, rel, data, input_section,
892 output_bfd, &err);
893 if (r == bfd_reloc_ok && gp_undefined)
894 {
895 r = bfd_reloc_dangerous;
896 err = (char *) _("GP relative relocation used"
897 " when GP not defined");
898 }
899 break;
900
901 case ALPHA_R_LITUSE:
902 /* See ALPHA_R_LITERAL above for the uses of this reloc. It
903 does not cause anything to happen, itself. */
904 rel->address += input_section->output_offset;
905 break;
906
907 case ALPHA_R_GPDISP:
908 /* This marks the ldah of an ldah/lda pair which loads the
909 gp register with the difference of the gp value and the
910 current location. The second of the pair is r_size bytes
911 ahead; it used to be marked with an ALPHA_R_IGNORE reloc,
912 but that no longer happens in OSF/1 3.2. */
913 if (bfd_reloc_offset_in_range (rel->howto, input_bfd, input_section,
914 rel->address)
915 && bfd_reloc_offset_in_range (rel->howto, input_bfd, input_section,
916 rel->address + rel->addend))
917 {
918 /* Get the two instructions. */
919 bfd_byte *p = data + rel->address;
920 bfd_vma insn1 = bfd_get_32 (input_bfd, p);
921 bfd_vma insn2 = bfd_get_32 (input_bfd, p + rel->addend);
922
923 BFD_ASSERT (((insn1 >> 26) & 0x3f) == 0x09); /* ldah */
924 BFD_ASSERT (((insn2 >> 26) & 0x3f) == 0x08); /* lda */
925
926 /* Get the existing addend. We must account for the sign
927 extension done by lda and ldah. */
928 bfd_vma addend = (((((insn1 & 0xffff) ^ 0x8000) - 0x8000) << 16)
929 + ((((insn2 & 0xffff) ^ 0x8000) - 0x8000)));
930
931 /* The existing addend includes the different between the
932 gp of the input BFD and the address in the input BFD.
933 Subtract this out. */
934 addend -= ecoff_data (input_bfd)->gp - input_section->vma;
935
936 /* Now add in the final gp value, and subtract out the
937 final address. */
938 addend += gp - (input_section->output_section->vma
939 + input_section->output_offset);
940
941 /* Change the instructions, accounting for the sign
942 extension, and write them out. */
943 insn1 = (insn1 & ~0xffff) | (((addend + 0x8000) >> 16) & 0xffff);
944 insn2 = (insn2 & ~0xffff) | (addend & 0xffff);
945
946 bfd_put_32 (input_bfd, insn1, p);
947 bfd_put_32 (input_bfd, insn2, p + rel->addend);
948 }
949 else
950 r = bfd_reloc_outofrange;
951
952 rel->address += input_section->output_offset;
953 break;
954
955 case ALPHA_R_OP_PUSH:
956 /* Push a value on the reloc evaluation stack. */
957 {
958 asymbol *symbol;
959 bfd_vma relocation;
960
961 if (relocatable)
962 {
963 rel->address += input_section->output_offset;
964 break;
965 }
966
967 /* Figure out the relocation of this symbol. */
968 symbol = *rel->sym_ptr_ptr;
969
970 if (bfd_is_und_section (symbol->section))
971 r = bfd_reloc_undefined;
972
973 if (bfd_is_com_section (symbol->section))
974 relocation = 0;
975 else
976 relocation = symbol->value;
977 relocation += symbol->section->output_section->vma;
978 relocation += symbol->section->output_offset;
979 relocation += rel->addend;
980
981 if (tos >= RELOC_STACKSIZE)
982 {
983 r = bfd_reloc_notsupported;
984 break;
985 }
986
987 stack[tos++] = relocation;
988 }
989 break;
990
991 case ALPHA_R_OP_STORE:
992 /* Store a value from the reloc stack into a bitfield. */
993 {
994 if (relocatable)
995 {
996 rel->address += input_section->output_offset;
997 break;
998 }
999
1000 if (tos == 0)
1001 {
1002 r = bfd_reloc_notsupported;
1003 break;
1004 }
1005
1006 /* The offset and size in bits for this reloc are encoded
1007 into the addend field by alpha_adjust_reloc_in. */
1008 unsigned int offset = (rel->addend >> 8) & 0xff;
1009 unsigned int size = rel->addend & 0xff;
1010 unsigned int startbyte = offset >> 3;
1011 unsigned int endbyte = (offset + size + 7) >> 3;
1012 unsigned int bytes = endbyte + 1 - startbyte;
1013
1014 if (bytes <= 8
1015 && rel->address + startbyte + bytes >= rel->address
1016 && (rel->address + startbyte + bytes
1017 <= bfd_get_section_limit_octets (input_bfd, input_section)))
1018 {
1019 uint64_t val = 0;
1020 for (int off = bytes - 1; off >= 0; --off)
1021 val = (val << 8) | data[rel->address + startbyte + off];
1022
1023 offset -= startbyte << 3;
1024 size -= startbyte << 3;
1025 uint64_t mask = (((uint64_t) 1 << size) - 1) << offset;
1026 val = (val & ~mask) | ((stack[--tos] << offset) & mask);
1027
1028 for (unsigned int off = 0; off < bytes; ++off)
1029 {
1030 data[rel->address + startbyte + off] = val & 0xff;
1031 val >>= 8;
1032 }
1033 }
1034 else
1035 r = bfd_reloc_outofrange;
1036 }
1037 break;
1038
1039 case ALPHA_R_OP_PSUB:
1040 /* Subtract a value from the top of the stack. */
1041 {
1042 asymbol *symbol;
1043 bfd_vma relocation;
1044
1045 if (relocatable)
1046 {
1047 rel->address += input_section->output_offset;
1048 break;
1049 }
1050
1051 /* Figure out the relocation of this symbol. */
1052 symbol = *rel->sym_ptr_ptr;
1053
1054 if (bfd_is_und_section (symbol->section))
1055 r = bfd_reloc_undefined;
1056
1057 if (bfd_is_com_section (symbol->section))
1058 relocation = 0;
1059 else
1060 relocation = symbol->value;
1061 relocation += symbol->section->output_section->vma;
1062 relocation += symbol->section->output_offset;
1063 relocation += rel->addend;
1064
1065 if (tos == 0)
1066 {
1067 r = bfd_reloc_notsupported;
1068 break;
1069 }
1070
1071 stack[tos - 1] -= relocation;
1072 }
1073 break;
1074
1075 case ALPHA_R_OP_PRSHIFT:
1076 /* Shift the value on the top of the stack. */
1077 {
1078 asymbol *symbol;
1079 bfd_vma relocation;
1080
1081 if (relocatable)
1082 {
1083 rel->address += input_section->output_offset;
1084 break;
1085 }
1086
1087 /* Figure out the relocation of this symbol. */
1088 symbol = *rel->sym_ptr_ptr;
1089
1090 if (bfd_is_und_section (symbol->section))
1091 r = bfd_reloc_undefined;
1092
1093 if (bfd_is_com_section (symbol->section))
1094 relocation = 0;
1095 else
1096 relocation = symbol->value;
1097 relocation += symbol->section->output_section->vma;
1098 relocation += symbol->section->output_offset;
1099 relocation += rel->addend;
1100
1101 if (tos == 0)
1102 {
1103 r = bfd_reloc_notsupported;
1104 break;
1105 }
1106
1107 stack[tos - 1] >>= relocation;
1108 }
1109 break;
1110
1111 case ALPHA_R_GPVALUE:
1112 /* I really don't know if this does the right thing. */
1113 gp = rel->addend;
1114 gp_undefined = false;
1115 break;
1116
1117 default:
1118 r = bfd_reloc_notsupported;
1119 break;
1120 }
1121
1122 if (relocatable)
1123 {
1124 asection *os = input_section->output_section;
1125
1126 /* A partial link, so keep the relocs. */
1127 os->orelocation[os->reloc_count] = rel;
1128 os->reloc_count++;
1129 }
1130
1131 if (r != bfd_reloc_ok)
1132 {
1133 switch (r)
1134 {
1135 case bfd_reloc_undefined:
1136 (*link_info->callbacks->undefined_symbol)
1137 (link_info, bfd_asymbol_name (*rel->sym_ptr_ptr),
1138 input_bfd, input_section, rel->address, true);
1139 break;
1140 case bfd_reloc_dangerous:
1141 (*link_info->callbacks->reloc_dangerous)
1142 (link_info, err, input_bfd, input_section, rel->address);
1143 break;
1144 case bfd_reloc_overflow:
1145 (*link_info->callbacks->reloc_overflow)
1146 (link_info, NULL, bfd_asymbol_name (*rel->sym_ptr_ptr),
1147 rel->howto->name, rel->addend, input_bfd,
1148 input_section, rel->address);
1149 break;
1150 case bfd_reloc_outofrange:
1151 (*link_info->callbacks->einfo)
1152 /* xgettext:c-format */
1153 (_("%X%P: %pB(%pA): relocation \"%pR\" goes out of range\n"),
1154 input_bfd, input_section, rel);
1155 goto error_return;
1156 case bfd_reloc_notsupported:
1157 (*link_info->callbacks->einfo)
1158 /* xgettext:c-format */
1159 (_("%X%P: %pB(%pA): relocation \"%pR\" is not supported\n"),
1160 input_bfd, input_section, rel);
1161 goto error_return;
1162 default:
1163 (*link_info->callbacks->einfo)
1164 /* xgettext:c-format */
1165 (_("%X%P: %pB(%pA): relocation \"%pR\""
1166 " returns an unrecognized value %x\n"),
1167 input_bfd, input_section, rel, r);
1168 break;
1169 }
1170 }
1171 }
1172
1173 if (tos != 0)
1174 goto error_return;
1175
1176 successful_return:
1177 free (reloc_vector);
1178 return data;
1179
1180 error_return:
1181 free (reloc_vector);
1182 if (orig_data == NULL)
1183 free (data);
1184 return NULL;
1185 }
1186
1187 /* Get the howto structure for a generic reloc type. */
1188
1189 static reloc_howto_type *
alpha_bfd_reloc_type_lookup(bfd * abfd ATTRIBUTE_UNUSED,bfd_reloc_code_real_type code)1190 alpha_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
1191 bfd_reloc_code_real_type code)
1192 {
1193 int alpha_type;
1194
1195 switch (code)
1196 {
1197 case BFD_RELOC_32:
1198 alpha_type = ALPHA_R_REFLONG;
1199 break;
1200 case BFD_RELOC_64:
1201 case BFD_RELOC_CTOR:
1202 alpha_type = ALPHA_R_REFQUAD;
1203 break;
1204 case BFD_RELOC_GPREL32:
1205 alpha_type = ALPHA_R_GPREL32;
1206 break;
1207 case BFD_RELOC_ALPHA_LITERAL:
1208 alpha_type = ALPHA_R_LITERAL;
1209 break;
1210 case BFD_RELOC_ALPHA_LITUSE:
1211 alpha_type = ALPHA_R_LITUSE;
1212 break;
1213 case BFD_RELOC_ALPHA_GPDISP_HI16:
1214 alpha_type = ALPHA_R_GPDISP;
1215 break;
1216 case BFD_RELOC_ALPHA_GPDISP_LO16:
1217 alpha_type = ALPHA_R_IGNORE;
1218 break;
1219 case BFD_RELOC_23_PCREL_S2:
1220 alpha_type = ALPHA_R_BRADDR;
1221 break;
1222 case BFD_RELOC_ALPHA_HINT:
1223 alpha_type = ALPHA_R_HINT;
1224 break;
1225 case BFD_RELOC_16_PCREL:
1226 alpha_type = ALPHA_R_SREL16;
1227 break;
1228 case BFD_RELOC_32_PCREL:
1229 alpha_type = ALPHA_R_SREL32;
1230 break;
1231 case BFD_RELOC_64_PCREL:
1232 alpha_type = ALPHA_R_SREL64;
1233 break;
1234 default:
1235 return (reloc_howto_type *) NULL;
1236 }
1237
1238 return &alpha_howto_table[alpha_type];
1239 }
1240
1241 static reloc_howto_type *
alpha_bfd_reloc_name_lookup(bfd * abfd ATTRIBUTE_UNUSED,const char * r_name)1242 alpha_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
1243 const char *r_name)
1244 {
1245 unsigned int i;
1246
1247 for (i = 0;
1248 i < sizeof (alpha_howto_table) / sizeof (alpha_howto_table[0]);
1249 i++)
1250 if (alpha_howto_table[i].name != NULL
1251 && strcasecmp (alpha_howto_table[i].name, r_name) == 0)
1252 return &alpha_howto_table[i];
1253
1254 return NULL;
1255 }
1256
1257 /* A helper routine for alpha_relocate_section which converts an
1258 external reloc when generating relocatable output. Returns the
1259 relocation amount. */
1260
1261 static bfd_vma
alpha_convert_external_reloc(bfd * output_bfd ATTRIBUTE_UNUSED,struct bfd_link_info * info,bfd * input_bfd,struct external_reloc * ext_rel,struct ecoff_link_hash_entry * h)1262 alpha_convert_external_reloc (bfd *output_bfd ATTRIBUTE_UNUSED,
1263 struct bfd_link_info *info,
1264 bfd *input_bfd,
1265 struct external_reloc *ext_rel,
1266 struct ecoff_link_hash_entry *h)
1267 {
1268 unsigned long r_symndx;
1269 bfd_vma relocation;
1270
1271 BFD_ASSERT (bfd_link_relocatable (info));
1272
1273 if (h->root.type == bfd_link_hash_defined
1274 || h->root.type == bfd_link_hash_defweak)
1275 {
1276 asection *hsec;
1277 const char *name;
1278
1279 /* This symbol is defined in the output. Convert the reloc from
1280 being against the symbol to being against the section. */
1281
1282 /* Clear the r_extern bit. */
1283 ext_rel->r_bits[1] &=~ RELOC_BITS1_EXTERN_LITTLE;
1284
1285 /* Compute a new r_symndx value. */
1286 hsec = h->root.u.def.section;
1287 name = bfd_section_name (hsec->output_section);
1288
1289 r_symndx = (unsigned long) -1;
1290 switch (name[1])
1291 {
1292 case 'A':
1293 if (strcmp (name, "*ABS*") == 0)
1294 r_symndx = RELOC_SECTION_ABS;
1295 break;
1296 case 'b':
1297 if (strcmp (name, ".bss") == 0)
1298 r_symndx = RELOC_SECTION_BSS;
1299 break;
1300 case 'd':
1301 if (strcmp (name, ".data") == 0)
1302 r_symndx = RELOC_SECTION_DATA;
1303 break;
1304 case 'f':
1305 if (strcmp (name, ".fini") == 0)
1306 r_symndx = RELOC_SECTION_FINI;
1307 break;
1308 case 'i':
1309 if (strcmp (name, ".init") == 0)
1310 r_symndx = RELOC_SECTION_INIT;
1311 break;
1312 case 'l':
1313 if (strcmp (name, ".lita") == 0)
1314 r_symndx = RELOC_SECTION_LITA;
1315 else if (strcmp (name, ".lit8") == 0)
1316 r_symndx = RELOC_SECTION_LIT8;
1317 else if (strcmp (name, ".lit4") == 0)
1318 r_symndx = RELOC_SECTION_LIT4;
1319 break;
1320 case 'p':
1321 if (strcmp (name, ".pdata") == 0)
1322 r_symndx = RELOC_SECTION_PDATA;
1323 break;
1324 case 'r':
1325 if (strcmp (name, ".rdata") == 0)
1326 r_symndx = RELOC_SECTION_RDATA;
1327 else if (strcmp (name, ".rconst") == 0)
1328 r_symndx = RELOC_SECTION_RCONST;
1329 break;
1330 case 's':
1331 if (strcmp (name, ".sdata") == 0)
1332 r_symndx = RELOC_SECTION_SDATA;
1333 else if (strcmp (name, ".sbss") == 0)
1334 r_symndx = RELOC_SECTION_SBSS;
1335 break;
1336 case 't':
1337 if (strcmp (name, ".text") == 0)
1338 r_symndx = RELOC_SECTION_TEXT;
1339 break;
1340 case 'x':
1341 if (strcmp (name, ".xdata") == 0)
1342 r_symndx = RELOC_SECTION_XDATA;
1343 break;
1344 }
1345
1346 if (r_symndx == (unsigned long) -1)
1347 abort ();
1348
1349 /* Add the section VMA and the symbol value. */
1350 relocation = (h->root.u.def.value
1351 + hsec->output_section->vma
1352 + hsec->output_offset);
1353 }
1354 else
1355 {
1356 /* Change the symndx value to the right one for
1357 the output BFD. */
1358 r_symndx = h->indx;
1359 if (r_symndx == (unsigned long) -1)
1360 {
1361 /* Caller must give an error. */
1362 r_symndx = 0;
1363 }
1364 relocation = 0;
1365 }
1366
1367 /* Write out the new r_symndx value. */
1368 H_PUT_32 (input_bfd, r_symndx, ext_rel->r_symndx);
1369
1370 return relocation;
1371 }
1372
1373 /* Relocate a section while linking an Alpha ECOFF file. This is
1374 quite similar to get_relocated_section_contents. Perhaps they
1375 could be combined somehow. */
1376
1377 static bool
alpha_relocate_section(bfd * output_bfd,struct bfd_link_info * info,bfd * input_bfd,asection * input_section,bfd_byte * contents,void * external_relocs)1378 alpha_relocate_section (bfd *output_bfd,
1379 struct bfd_link_info *info,
1380 bfd *input_bfd,
1381 asection *input_section,
1382 bfd_byte *contents,
1383 void * external_relocs)
1384 {
1385 asection **symndx_to_section, *lita_sec;
1386 struct ecoff_link_hash_entry **sym_hashes;
1387 bfd_vma gp;
1388 bool gp_undefined;
1389 bfd_vma stack[RELOC_STACKSIZE];
1390 int tos = 0;
1391 struct external_reloc *ext_rel;
1392 struct external_reloc *ext_rel_end;
1393 bfd_size_type amt;
1394 bool ret = true;
1395
1396 /* We keep a table mapping the symndx found in an internal reloc to
1397 the appropriate section. This is faster than looking up the
1398 section by name each time. */
1399 symndx_to_section = ecoff_data (input_bfd)->symndx_to_section;
1400 if (symndx_to_section == (asection **) NULL)
1401 {
1402 amt = NUM_RELOC_SECTIONS * sizeof (asection *);
1403 symndx_to_section = (asection **) bfd_alloc (input_bfd, amt);
1404 if (!symndx_to_section)
1405 return false;
1406
1407 symndx_to_section[RELOC_SECTION_NONE] = NULL;
1408 symndx_to_section[RELOC_SECTION_TEXT] =
1409 bfd_get_section_by_name (input_bfd, ".text");
1410 symndx_to_section[RELOC_SECTION_RDATA] =
1411 bfd_get_section_by_name (input_bfd, ".rdata");
1412 symndx_to_section[RELOC_SECTION_DATA] =
1413 bfd_get_section_by_name (input_bfd, ".data");
1414 symndx_to_section[RELOC_SECTION_SDATA] =
1415 bfd_get_section_by_name (input_bfd, ".sdata");
1416 symndx_to_section[RELOC_SECTION_SBSS] =
1417 bfd_get_section_by_name (input_bfd, ".sbss");
1418 symndx_to_section[RELOC_SECTION_BSS] =
1419 bfd_get_section_by_name (input_bfd, ".bss");
1420 symndx_to_section[RELOC_SECTION_INIT] =
1421 bfd_get_section_by_name (input_bfd, ".init");
1422 symndx_to_section[RELOC_SECTION_LIT8] =
1423 bfd_get_section_by_name (input_bfd, ".lit8");
1424 symndx_to_section[RELOC_SECTION_LIT4] =
1425 bfd_get_section_by_name (input_bfd, ".lit4");
1426 symndx_to_section[RELOC_SECTION_XDATA] =
1427 bfd_get_section_by_name (input_bfd, ".xdata");
1428 symndx_to_section[RELOC_SECTION_PDATA] =
1429 bfd_get_section_by_name (input_bfd, ".pdata");
1430 symndx_to_section[RELOC_SECTION_FINI] =
1431 bfd_get_section_by_name (input_bfd, ".fini");
1432 symndx_to_section[RELOC_SECTION_LITA] =
1433 bfd_get_section_by_name (input_bfd, ".lita");
1434 symndx_to_section[RELOC_SECTION_ABS] = bfd_abs_section_ptr;
1435 symndx_to_section[RELOC_SECTION_RCONST] =
1436 bfd_get_section_by_name (input_bfd, ".rconst");
1437
1438 ecoff_data (input_bfd)->symndx_to_section = symndx_to_section;
1439 }
1440
1441 sym_hashes = ecoff_data (input_bfd)->sym_hashes;
1442
1443 /* On the Alpha, the .lita section must be addressable by the global
1444 pointer. To support large programs, we need to allow multiple
1445 global pointers. This works as long as each input .lita section
1446 is <64KB big. This implies that when producing relocatable
1447 output, the .lita section is limited to 64KB. . */
1448
1449 lita_sec = symndx_to_section[RELOC_SECTION_LITA];
1450 gp = _bfd_get_gp_value (output_bfd);
1451 if (! bfd_link_relocatable (info) && lita_sec != NULL)
1452 {
1453 struct ecoff_section_tdata *lita_sec_data;
1454
1455 /* Make sure we have a section data structure to which we can
1456 hang on to the gp value we pick for the section. */
1457 lita_sec_data = ecoff_section_data (input_bfd, lita_sec);
1458 if (lita_sec_data == NULL)
1459 {
1460 amt = sizeof (struct ecoff_section_tdata);
1461 lita_sec_data = ((struct ecoff_section_tdata *)
1462 bfd_zalloc (input_bfd, amt));
1463 lita_sec->used_by_bfd = lita_sec_data;
1464 }
1465
1466 if (lita_sec_data->gp != 0)
1467 {
1468 /* If we already assigned a gp to this section, we better
1469 stick with that value. */
1470 gp = lita_sec_data->gp;
1471 }
1472 else
1473 {
1474 bfd_vma lita_vma;
1475 bfd_size_type lita_size;
1476
1477 lita_vma = lita_sec->output_offset + lita_sec->output_section->vma;
1478 lita_size = lita_sec->size;
1479
1480 if (gp == 0
1481 || lita_vma < gp - 0x8000
1482 || lita_vma + lita_size >= gp + 0x8000)
1483 {
1484 /* Either gp hasn't been set at all or the current gp
1485 cannot address this .lita section. In both cases we
1486 reset the gp to point into the "middle" of the
1487 current input .lita section. */
1488 if (gp && !ecoff_data (output_bfd)->issued_multiple_gp_warning)
1489 {
1490 (*info->callbacks->warning) (info,
1491 _("using multiple gp values"),
1492 (char *) NULL, output_bfd,
1493 (asection *) NULL, (bfd_vma) 0);
1494 ecoff_data (output_bfd)->issued_multiple_gp_warning = true;
1495 }
1496 if (lita_vma < gp - 0x8000)
1497 gp = lita_vma + lita_size - 0x8000;
1498 else
1499 gp = lita_vma + 0x8000;
1500
1501 }
1502
1503 lita_sec_data->gp = gp;
1504 }
1505
1506 _bfd_set_gp_value (output_bfd, gp);
1507 }
1508
1509 gp_undefined = (gp == 0);
1510
1511 BFD_ASSERT (bfd_header_little_endian (output_bfd));
1512 BFD_ASSERT (bfd_header_little_endian (input_bfd));
1513
1514 ext_rel = (struct external_reloc *) external_relocs;
1515 ext_rel_end = ext_rel + input_section->reloc_count;
1516 for (; ext_rel < ext_rel_end; ext_rel++)
1517 {
1518 bfd_vma r_vaddr;
1519 unsigned long r_symndx;
1520 int r_type;
1521 int r_extern;
1522 int r_offset;
1523 int r_size;
1524 bool relocatep;
1525 bool adjust_addrp;
1526 bool gp_usedp;
1527 bfd_vma addend;
1528 bfd_reloc_status_type r;
1529
1530 r_vaddr = H_GET_64 (input_bfd, ext_rel->r_vaddr);
1531 r_symndx = H_GET_32 (input_bfd, ext_rel->r_symndx);
1532
1533 r_type = ((ext_rel->r_bits[0] & RELOC_BITS0_TYPE_LITTLE)
1534 >> RELOC_BITS0_TYPE_SH_LITTLE);
1535 r_extern = (ext_rel->r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0;
1536 r_offset = ((ext_rel->r_bits[1] & RELOC_BITS1_OFFSET_LITTLE)
1537 >> RELOC_BITS1_OFFSET_SH_LITTLE);
1538 /* Ignored the reserved bits. */
1539 r_size = ((ext_rel->r_bits[3] & RELOC_BITS3_SIZE_LITTLE)
1540 >> RELOC_BITS3_SIZE_SH_LITTLE);
1541
1542 relocatep = false;
1543 adjust_addrp = true;
1544 gp_usedp = false;
1545 addend = 0;
1546 r = bfd_reloc_ok;
1547
1548 switch (r_type)
1549 {
1550 default:
1551 r = bfd_reloc_notsupported;
1552 break;
1553
1554 case ALPHA_R_IGNORE:
1555 /* This reloc appears after a GPDISP reloc. On earlier
1556 versions of OSF/1, It marked the position of the second
1557 instruction to be altered by the GPDISP reloc, but it is
1558 not otherwise used for anything. For some reason, the
1559 address of the relocation does not appear to include the
1560 section VMA, unlike the other relocation types. */
1561 if (bfd_link_relocatable (info))
1562 H_PUT_64 (input_bfd, input_section->output_offset + r_vaddr,
1563 ext_rel->r_vaddr);
1564 adjust_addrp = false;
1565 break;
1566
1567 case ALPHA_R_REFLONG:
1568 case ALPHA_R_REFQUAD:
1569 case ALPHA_R_HINT:
1570 relocatep = true;
1571 break;
1572
1573 case ALPHA_R_BRADDR:
1574 case ALPHA_R_SREL16:
1575 case ALPHA_R_SREL32:
1576 case ALPHA_R_SREL64:
1577 if (r_extern)
1578 addend += - (r_vaddr + 4);
1579 relocatep = true;
1580 break;
1581
1582 case ALPHA_R_GPREL32:
1583 /* This relocation is used in a switch table. It is a 32
1584 bit offset from the current GP value. We must adjust it
1585 by the different between the original GP value and the
1586 current GP value. */
1587 relocatep = true;
1588 addend = ecoff_data (input_bfd)->gp - gp;
1589 gp_usedp = true;
1590 break;
1591
1592 case ALPHA_R_LITERAL:
1593 /* This is a reference to a literal value, generally
1594 (always?) in the .lita section. This is a 16 bit GP
1595 relative relocation. Sometimes the subsequent reloc is a
1596 LITUSE reloc, which indicates how this reloc is used.
1597 This sometimes permits rewriting the two instructions
1598 referred to by the LITERAL and the LITUSE into different
1599 instructions which do not refer to .lita. This can save
1600 a memory reference, and permits removing a value from
1601 .lita thus saving GP relative space.
1602
1603 We do not these optimizations. To do them we would need
1604 to arrange to link the .lita section first, so that by
1605 the time we got here we would know the final values to
1606 use. This would not be particularly difficult, but it is
1607 not currently implemented. */
1608
1609 relocatep = true;
1610 addend = ecoff_data (input_bfd)->gp - gp;
1611 gp_usedp = true;
1612 break;
1613
1614 case ALPHA_R_LITUSE:
1615 /* See ALPHA_R_LITERAL above for the uses of this reloc. It
1616 does not cause anything to happen, itself. */
1617 break;
1618
1619 case ALPHA_R_GPDISP:
1620 /* This marks the ldah of an ldah/lda pair which loads the
1621 gp register with the difference of the gp value and the
1622 current location. The second of the pair is r_symndx
1623 bytes ahead. It used to be marked with an ALPHA_R_IGNORE
1624 reloc, but OSF/1 3.2 no longer does that. */
1625 if (r_vaddr >= input_section->vma
1626 && r_vaddr - input_section->vma < input_section->size
1627 && input_section->size - (r_vaddr - input_section->vma) > r_symndx
1628 && (input_section->size - (r_vaddr - input_section->vma)
1629 - r_symndx >= 4))
1630 {
1631 /* Get the two instructions. */
1632 bfd_byte *p = contents + r_vaddr - input_section->vma;
1633 bfd_vma insn1 = bfd_get_32 (input_bfd, p);
1634 bfd_vma insn2 = bfd_get_32 (input_bfd, p + r_symndx);
1635
1636 BFD_ASSERT (((insn1 >> 26) & 0x3f) == 0x09); /* ldah */
1637 BFD_ASSERT (((insn2 >> 26) & 0x3f) == 0x08); /* lda */
1638
1639 /* Get the existing addend. We must account for the sign
1640 extension done by lda and ldah. */
1641 addend = (((((insn1 & 0xffff) ^ 0x8000) - 0x8000) << 16)
1642 + (((insn2 & 0xffff) ^ 0x8000) - 0x8000));
1643
1644 /* The existing addend includes the difference between the
1645 gp of the input BFD and the address in the input BFD.
1646 We want to change this to the difference between the
1647 final GP and the final address. */
1648 addend -= ecoff_data (input_bfd)->gp - input_section->vma;
1649 addend += gp - (input_section->output_section->vma
1650 + input_section->output_offset);
1651
1652 /* Change the instructions, accounting for the sign
1653 extension, and write them out. */
1654 insn1 = (insn1 & ~0xffff) | (((addend + 0x8000) >> 16) & 0xffff);
1655 insn2 = (insn2 & ~0xffff) | (addend & 0xffff);
1656
1657 bfd_put_32 (input_bfd, insn1, p);
1658 bfd_put_32 (input_bfd, insn2, p + r_symndx);
1659
1660 gp_usedp = true;
1661 }
1662 else
1663 r = bfd_reloc_outofrange;
1664 break;
1665
1666 case ALPHA_R_OP_PUSH:
1667 case ALPHA_R_OP_PSUB:
1668 case ALPHA_R_OP_PRSHIFT:
1669 /* Manipulate values on the reloc evaluation stack. The
1670 r_vaddr field is not an address in input_section, it is
1671 the current value (including any addend) of the object
1672 being used. */
1673 if (! r_extern)
1674 {
1675 asection *s;
1676
1677 s = symndx_to_section[r_symndx];
1678 if (s == NULL)
1679 {
1680 r = bfd_reloc_notsupported;
1681 break;
1682 }
1683 addend = s->output_section->vma + s->output_offset - s->vma;
1684 }
1685 else
1686 {
1687 struct ecoff_link_hash_entry *h;
1688
1689 h = sym_hashes[r_symndx];
1690 if (h == NULL)
1691 {
1692 r = bfd_reloc_notsupported;
1693 break;
1694 }
1695
1696 if (! bfd_link_relocatable (info))
1697 {
1698 if (h->root.type == bfd_link_hash_defined
1699 || h->root.type == bfd_link_hash_defweak)
1700 addend = (h->root.u.def.value
1701 + h->root.u.def.section->output_section->vma
1702 + h->root.u.def.section->output_offset);
1703 else
1704 {
1705 /* Note that we pass the address as 0, since we
1706 do not have a meaningful number for the
1707 location within the section that is being
1708 relocated. */
1709 (*info->callbacks->undefined_symbol)
1710 (info, h->root.root.string, input_bfd,
1711 input_section, (bfd_vma) 0, true);
1712 addend = 0;
1713 }
1714 }
1715 else
1716 {
1717 if (h->root.type != bfd_link_hash_defined
1718 && h->root.type != bfd_link_hash_defweak
1719 && h->indx == -1)
1720 {
1721 /* This symbol is not being written out. Pass
1722 the address as 0, as with undefined_symbol,
1723 above. */
1724 (*info->callbacks->unattached_reloc)
1725 (info, h->root.root.string,
1726 input_bfd, input_section, (bfd_vma) 0);
1727 }
1728
1729 addend = alpha_convert_external_reloc (output_bfd, info,
1730 input_bfd,
1731 ext_rel, h);
1732 }
1733 }
1734
1735 addend += r_vaddr;
1736
1737 if (bfd_link_relocatable (info))
1738 {
1739 /* Adjust r_vaddr by the addend. */
1740 H_PUT_64 (input_bfd, addend, ext_rel->r_vaddr);
1741 }
1742 else
1743 {
1744 switch (r_type)
1745 {
1746 case ALPHA_R_OP_PUSH:
1747 if (tos >= RELOC_STACKSIZE)
1748 {
1749 r = bfd_reloc_notsupported;
1750 break;
1751 }
1752 stack[tos++] = addend;
1753 break;
1754
1755 case ALPHA_R_OP_PSUB:
1756 if (tos == 0)
1757 {
1758 r = bfd_reloc_notsupported;
1759 break;
1760 }
1761 stack[tos - 1] -= addend;
1762 break;
1763
1764 case ALPHA_R_OP_PRSHIFT:
1765 if (tos == 0)
1766 {
1767 r = bfd_reloc_notsupported;
1768 break;
1769 }
1770 stack[tos - 1] >>= addend;
1771 break;
1772 }
1773 }
1774
1775 adjust_addrp = false;
1776 break;
1777
1778 case ALPHA_R_OP_STORE:
1779 /* Store a value from the reloc stack into a bitfield. If
1780 we are generating relocatable output, all we do is
1781 adjust the address of the reloc. */
1782 if (! bfd_link_relocatable (info))
1783 {
1784 unsigned int startbyte = r_offset >> 3;
1785 unsigned int endbyte = (r_offset + r_size + 7) >> 3;
1786 unsigned int bytes = endbyte + 1 - startbyte;
1787
1788 if (bytes <= 8
1789 && r_vaddr >= input_section->vma
1790 && r_vaddr - input_section->vma < input_section->size
1791 && (input_section->size - (r_vaddr - input_section->vma)
1792 >= startbyte + bytes))
1793 {
1794 bfd_byte *p = contents + (r_vaddr - input_section->vma);
1795 uint64_t val = 0;
1796 for (int off = bytes - 1; off >= 0; --off)
1797 val = (val << 8) | p[startbyte + off];
1798
1799 r_offset -= startbyte << 3;
1800 r_size -= startbyte << 3;
1801 uint64_t mask = (((uint64_t) 1 << r_size) - 1) << r_offset;
1802 val = (val & ~mask) | ((stack[--tos] << r_offset) & mask);
1803
1804 for (unsigned int off = 0; off < bytes; ++off)
1805 {
1806 p[startbyte + off] = val & 0xff;
1807 val >>= 8;
1808 }
1809 }
1810 else
1811 r = bfd_reloc_outofrange;
1812 }
1813 break;
1814
1815 case ALPHA_R_GPVALUE:
1816 /* I really don't know if this does the right thing. */
1817 gp = ecoff_data (input_bfd)->gp + r_symndx;
1818 gp_undefined = false;
1819 break;
1820 }
1821
1822 if (relocatep && r == bfd_reloc_ok)
1823 {
1824 reloc_howto_type *howto;
1825 struct ecoff_link_hash_entry *h = NULL;
1826 asection *s = NULL;
1827 bfd_vma relocation;
1828
1829 /* Perform a relocation. */
1830
1831 howto = &alpha_howto_table[r_type];
1832
1833 if (r_extern)
1834 {
1835 h = sym_hashes[r_symndx];
1836 /* If h is NULL, that means that there is a reloc
1837 against an external symbol which we thought was just
1838 a debugging symbol. This should not happen. */
1839 if (h == NULL)
1840 r = bfd_reloc_notsupported;
1841 }
1842 else
1843 {
1844 if (r_symndx >= NUM_RELOC_SECTIONS)
1845 s = NULL;
1846 else
1847 s = symndx_to_section[r_symndx];
1848
1849 if (s == NULL)
1850 r = bfd_reloc_notsupported;
1851
1852 }
1853
1854 if (r != bfd_reloc_ok)
1855 ;
1856 else if (bfd_link_relocatable (info))
1857 {
1858 /* We are generating relocatable output, and must
1859 convert the existing reloc. */
1860 if (r_extern)
1861 {
1862 if (h->root.type != bfd_link_hash_defined
1863 && h->root.type != bfd_link_hash_defweak
1864 && h->indx == -1)
1865 {
1866 /* This symbol is not being written out. */
1867 (*info->callbacks->unattached_reloc)
1868 (info, h->root.root.string, input_bfd,
1869 input_section, r_vaddr - input_section->vma);
1870 }
1871
1872 relocation = alpha_convert_external_reloc (output_bfd,
1873 info,
1874 input_bfd,
1875 ext_rel,
1876 h);
1877 }
1878 else
1879 {
1880 /* This is a relocation against a section. Adjust
1881 the value by the amount the section moved. */
1882 relocation = (s->output_section->vma
1883 + s->output_offset
1884 - s->vma);
1885 }
1886
1887 /* If this is PC relative, the existing object file
1888 appears to already have the reloc worked out. We
1889 must subtract out the old value and add in the new
1890 one. */
1891 if (howto->pc_relative)
1892 relocation -= (input_section->output_section->vma
1893 + input_section->output_offset
1894 - input_section->vma);
1895
1896 /* Put in any addend. */
1897 relocation += addend;
1898
1899 /* Adjust the contents. */
1900 r = _bfd_relocate_contents (howto, input_bfd, relocation,
1901 (contents
1902 + r_vaddr
1903 - input_section->vma));
1904 }
1905 else
1906 {
1907 /* We are producing a final executable. */
1908 if (r_extern)
1909 {
1910 /* This is a reloc against a symbol. */
1911 if (h->root.type == bfd_link_hash_defined
1912 || h->root.type == bfd_link_hash_defweak)
1913 {
1914 asection *hsec;
1915
1916 hsec = h->root.u.def.section;
1917 relocation = (h->root.u.def.value
1918 + hsec->output_section->vma
1919 + hsec->output_offset);
1920 }
1921 else
1922 r = bfd_reloc_undefined;
1923 }
1924 else
1925 {
1926 /* This is a reloc against a section. */
1927 relocation = (s->output_section->vma
1928 + s->output_offset
1929 - s->vma);
1930
1931 /* Adjust a PC relative relocation by removing the
1932 reference to the original source section. */
1933 if (howto->pc_relative)
1934 relocation += input_section->vma;
1935 }
1936
1937 if (r == bfd_reloc_ok)
1938 r = _bfd_final_link_relocate (howto,
1939 input_bfd,
1940 input_section,
1941 contents,
1942 r_vaddr - input_section->vma,
1943 relocation,
1944 addend);
1945 }
1946 }
1947
1948 if (bfd_link_relocatable (info) && adjust_addrp)
1949 {
1950 /* Change the address of the relocation. */
1951 H_PUT_64 (input_bfd,
1952 (input_section->output_section->vma
1953 + input_section->output_offset
1954 - input_section->vma
1955 + r_vaddr),
1956 ext_rel->r_vaddr);
1957 }
1958
1959 if (gp_usedp && gp_undefined)
1960 {
1961 r = bfd_reloc_dangerous;
1962 /* Only give the error once per link. */
1963 gp = 4;
1964 _bfd_set_gp_value (output_bfd, gp);
1965 gp_undefined = false;
1966 }
1967
1968 if (r != bfd_reloc_ok)
1969 {
1970 switch (r)
1971 {
1972 case bfd_reloc_overflow:
1973 {
1974 const char *name;
1975
1976 if (r_extern)
1977 name = sym_hashes[r_symndx]->root.root.string;
1978 else
1979 name = bfd_section_name (symndx_to_section[r_symndx]);
1980 (*info->callbacks->reloc_overflow)
1981 (info, NULL, name, alpha_howto_table[r_type].name,
1982 (bfd_vma) 0, input_bfd, input_section,
1983 r_vaddr - input_section->vma);
1984 }
1985 break;
1986 case bfd_reloc_outofrange:
1987 (*info->callbacks->einfo)
1988 /* xgettext:c-format */
1989 (_("%X%P: %pB(%pA): relocation out of range\n"),
1990 input_bfd, input_section);
1991 break;
1992 case bfd_reloc_undefined:
1993 (*info->callbacks->undefined_symbol)
1994 (info, sym_hashes[r_symndx]->root.root.string,
1995 input_bfd, input_section,
1996 r_vaddr - input_section->vma, true);
1997 break;
1998 case bfd_reloc_notsupported:
1999 (*info->callbacks->einfo)
2000 /* xgettext:c-format */
2001 (_("%X%P: %pB(%pA): relocation is not supported\n"),
2002 input_bfd, input_section);
2003 break;
2004 case bfd_reloc_dangerous:
2005 (*info->callbacks->reloc_dangerous)
2006 (info, _("GP relative relocation used when GP not defined"),
2007 input_bfd, input_section, r_vaddr - input_section->vma);
2008 break;
2009 default:
2010 abort ();
2011 }
2012 ret = false;
2013 }
2014 }
2015
2016 if (tos != 0)
2017 ret = false;
2018
2019 return ret;
2020 }
2021
2022 /* Do final adjustments to the filehdr and the aouthdr. This routine
2023 sets the dynamic bits in the file header. */
2024
2025 static bool
alpha_adjust_headers(bfd * abfd,struct internal_filehdr * fhdr,struct internal_aouthdr * ahdr ATTRIBUTE_UNUSED)2026 alpha_adjust_headers (bfd *abfd,
2027 struct internal_filehdr *fhdr,
2028 struct internal_aouthdr *ahdr ATTRIBUTE_UNUSED)
2029 {
2030 if ((abfd->flags & (DYNAMIC | EXEC_P)) == (DYNAMIC | EXEC_P))
2031 fhdr->f_flags |= F_ALPHA_CALL_SHARED;
2032 else if ((abfd->flags & DYNAMIC) != 0)
2033 fhdr->f_flags |= F_ALPHA_SHARABLE;
2034 return true;
2035 }
2036
2037 /* Archive handling. In OSF/1 (or Digital Unix) v3.2, Digital
2038 introduced archive packing, in which the elements in an archive are
2039 optionally compressed using a simple dictionary scheme. We know
2040 how to read such archives, but we don't write them. */
2041
2042 #define alpha_ecoff_slurp_armap _bfd_ecoff_slurp_armap
2043 #define alpha_ecoff_slurp_extended_name_table \
2044 _bfd_ecoff_slurp_extended_name_table
2045 #define alpha_ecoff_construct_extended_name_table \
2046 _bfd_ecoff_construct_extended_name_table
2047 #define alpha_ecoff_truncate_arname _bfd_ecoff_truncate_arname
2048 #define alpha_ecoff_write_armap _bfd_ecoff_write_armap
2049 #define alpha_ecoff_write_ar_hdr _bfd_generic_write_ar_hdr
2050 #define alpha_ecoff_generic_stat_arch_elt _bfd_ecoff_generic_stat_arch_elt
2051 #define alpha_ecoff_update_armap_timestamp _bfd_ecoff_update_armap_timestamp
2052
2053 /* A compressed file uses this instead of ARFMAG. */
2054
2055 #define ARFZMAG "Z\012"
2056
2057 /* Read an archive header. This is like the standard routine, but it
2058 also accepts ARFZMAG. */
2059
2060 static void *
alpha_ecoff_read_ar_hdr(bfd * abfd)2061 alpha_ecoff_read_ar_hdr (bfd *abfd)
2062 {
2063 struct areltdata *ret;
2064 struct ar_hdr *h;
2065
2066 ret = (struct areltdata *) _bfd_generic_read_ar_hdr_mag (abfd, ARFZMAG);
2067 if (ret == NULL)
2068 return NULL;
2069
2070 h = (struct ar_hdr *) ret->arch_header;
2071 if (strncmp (h->ar_fmag, ARFZMAG, 2) == 0)
2072 {
2073 bfd_byte ab[8];
2074
2075 /* This is a compressed file. We must set the size correctly.
2076 The size is the eight bytes after the dummy file header. */
2077 if (bfd_seek (abfd, FILHSZ, SEEK_CUR) != 0
2078 || bfd_read (ab, 8, abfd) != 8
2079 || bfd_seek (abfd, -(FILHSZ + 8), SEEK_CUR) != 0)
2080 {
2081 free (ret);
2082 return NULL;
2083 }
2084
2085 ret->parsed_size = H_GET_64 (abfd, ab);
2086 }
2087
2088 return ret;
2089 }
2090
2091 /* Get an archive element at a specified file position. This is where
2092 we uncompress the archive element if necessary. */
2093
2094 static bfd *
alpha_ecoff_get_elt_at_filepos(bfd * archive,file_ptr filepos,struct bfd_link_info * info)2095 alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos,
2096 struct bfd_link_info *info)
2097 {
2098 bfd *nbfd = NULL;
2099 struct areltdata *tdata;
2100 struct ar_hdr *hdr;
2101 bfd_byte ab[8];
2102 bfd_size_type size;
2103 bfd_byte *buf, *p;
2104 struct bfd_in_memory *bim;
2105 ufile_ptr filesize;
2106
2107 buf = NULL;
2108 nbfd = _bfd_get_elt_at_filepos (archive, filepos, info);
2109 if (nbfd == NULL)
2110 goto error_return;
2111
2112 if ((nbfd->flags & BFD_IN_MEMORY) != 0)
2113 {
2114 /* We have already expanded this BFD. */
2115 return nbfd;
2116 }
2117
2118 tdata = (struct areltdata *) nbfd->arelt_data;
2119 hdr = (struct ar_hdr *) tdata->arch_header;
2120 if (strncmp (hdr->ar_fmag, ARFZMAG, 2) != 0)
2121 return nbfd;
2122
2123 /* We must uncompress this element. We do this by copying it into a
2124 memory buffer, and making bfd_read and bfd_seek use that buffer.
2125 This can use a lot of memory, but it's simpler than getting a
2126 temporary file, making that work with the file descriptor caching
2127 code, and making sure that it is deleted at all appropriate
2128 times. It can be changed if it ever becomes important. */
2129
2130 /* The compressed file starts with a dummy ECOFF file header. */
2131 if (bfd_seek (nbfd, FILHSZ, SEEK_SET) != 0)
2132 goto error_return;
2133
2134 /* The next eight bytes are the real file size. */
2135 if (bfd_read (ab, 8, nbfd) != 8)
2136 goto error_return;
2137 size = H_GET_64 (nbfd, ab);
2138
2139 /* The decompression algorithm will at most expand by eight times. */
2140 filesize = bfd_get_file_size (archive);
2141 if (filesize != 0 && size / 8 > filesize)
2142 {
2143 bfd_set_error (bfd_error_malformed_archive);
2144 goto error_return;
2145 }
2146
2147 if (size != 0)
2148 {
2149 bfd_size_type left;
2150 bfd_byte dict[4096];
2151 unsigned int h;
2152 bfd_byte b;
2153
2154 buf = (bfd_byte *) bfd_malloc (size);
2155 if (buf == NULL)
2156 goto error_return;
2157 p = buf;
2158
2159 left = size;
2160
2161 /* I don't know what the next eight bytes are for. */
2162 if (bfd_read (ab, 8, nbfd) != 8)
2163 goto error_return;
2164
2165 /* This is the uncompression algorithm. It's a simple
2166 dictionary based scheme in which each character is predicted
2167 by a hash of the previous three characters. A control byte
2168 indicates whether the character is predicted or whether it
2169 appears in the input stream; each control byte manages the
2170 next eight bytes in the output stream. */
2171 memset (dict, 0, sizeof dict);
2172 h = 0;
2173 while (bfd_read (&b, 1, nbfd) == 1)
2174 {
2175 unsigned int i;
2176
2177 for (i = 0; i < 8; i++, b >>= 1)
2178 {
2179 bfd_byte n;
2180
2181 if ((b & 1) == 0)
2182 n = dict[h];
2183 else
2184 {
2185 if (bfd_read (&n, 1, nbfd) != 1)
2186 goto error_return;
2187 dict[h] = n;
2188 }
2189
2190 *p++ = n;
2191
2192 --left;
2193 if (left == 0)
2194 break;
2195
2196 h <<= 4;
2197 h ^= n;
2198 h &= sizeof dict - 1;
2199 }
2200
2201 if (left == 0)
2202 break;
2203 }
2204 }
2205
2206 /* Now the uncompressed file contents are in buf. */
2207 bim = ((struct bfd_in_memory *)
2208 bfd_malloc ((bfd_size_type) sizeof (struct bfd_in_memory)));
2209 if (bim == NULL)
2210 goto error_return;
2211 bim->size = size;
2212 bim->buffer = buf;
2213
2214 nbfd->mtime_set = true;
2215 nbfd->mtime = strtol (hdr->ar_date, (char **) NULL, 10);
2216
2217 nbfd->flags |= BFD_IN_MEMORY;
2218 nbfd->iostream = bim;
2219 nbfd->iovec = &_bfd_memory_iovec;
2220 nbfd->origin = 0;
2221 nbfd->size = 0;
2222 BFD_ASSERT (! nbfd->cacheable);
2223
2224 return nbfd;
2225
2226 error_return:
2227 free (buf);
2228 if (nbfd != NULL)
2229 bfd_close (nbfd);
2230 return NULL;
2231 }
2232
2233 /* Open the next archived file. */
2234
2235 static bfd *
alpha_ecoff_openr_next_archived_file(bfd * archive,bfd * last_file)2236 alpha_ecoff_openr_next_archived_file (bfd *archive, bfd *last_file)
2237 {
2238 ufile_ptr filestart;
2239
2240 if (last_file == NULL)
2241 filestart = bfd_ardata (archive)->first_file_filepos;
2242 else
2243 {
2244 struct areltdata *t;
2245 struct ar_hdr *h;
2246 bfd_size_type size;
2247
2248 /* We can't use arelt_size here, because that uses parsed_size,
2249 which is the uncompressed size. We need the compressed size. */
2250 t = (struct areltdata *) last_file->arelt_data;
2251 h = (struct ar_hdr *) t->arch_header;
2252 size = strtol (h->ar_size, (char **) NULL, 10);
2253
2254 /* Pad to an even boundary...
2255 Note that last_file->origin can be odd in the case of
2256 BSD-4.4-style element with a long odd size. */
2257 filestart = last_file->proxy_origin + size;
2258 filestart += filestart % 2;
2259 if (filestart < last_file->proxy_origin)
2260 {
2261 /* Prevent looping. See PR19256. */
2262 bfd_set_error (bfd_error_malformed_archive);
2263 return NULL;
2264 }
2265 }
2266
2267 return alpha_ecoff_get_elt_at_filepos (archive, filestart, NULL);
2268 }
2269
2270 /* Open the archive file given an index into the armap. */
2271
2272 static bfd *
alpha_ecoff_get_elt_at_index(bfd * abfd,symindex sym_index)2273 alpha_ecoff_get_elt_at_index (bfd *abfd, symindex sym_index)
2274 {
2275 carsym *entry;
2276
2277 entry = bfd_ardata (abfd)->symdefs + sym_index;
2278 return alpha_ecoff_get_elt_at_filepos (abfd, entry->file_offset,
2279 NULL);
2280 }
2281
2282 static void
alpha_ecoff_swap_coff_aux_in(bfd * abfd ATTRIBUTE_UNUSED,void * ext1 ATTRIBUTE_UNUSED,int type ATTRIBUTE_UNUSED,int in_class ATTRIBUTE_UNUSED,int indx ATTRIBUTE_UNUSED,int numaux ATTRIBUTE_UNUSED,void * in1 ATTRIBUTE_UNUSED)2283 alpha_ecoff_swap_coff_aux_in (bfd *abfd ATTRIBUTE_UNUSED,
2284 void *ext1 ATTRIBUTE_UNUSED,
2285 int type ATTRIBUTE_UNUSED,
2286 int in_class ATTRIBUTE_UNUSED,
2287 int indx ATTRIBUTE_UNUSED,
2288 int numaux ATTRIBUTE_UNUSED,
2289 void *in1 ATTRIBUTE_UNUSED)
2290 {
2291 }
2292
2293 static void
alpha_ecoff_swap_coff_sym_in(bfd * abfd ATTRIBUTE_UNUSED,void * ext1 ATTRIBUTE_UNUSED,void * in1 ATTRIBUTE_UNUSED)2294 alpha_ecoff_swap_coff_sym_in (bfd *abfd ATTRIBUTE_UNUSED,
2295 void *ext1 ATTRIBUTE_UNUSED,
2296 void *in1 ATTRIBUTE_UNUSED)
2297 {
2298 }
2299
2300 static void
alpha_ecoff_swap_coff_lineno_in(bfd * abfd ATTRIBUTE_UNUSED,void * ext1 ATTRIBUTE_UNUSED,void * in1 ATTRIBUTE_UNUSED)2301 alpha_ecoff_swap_coff_lineno_in (bfd *abfd ATTRIBUTE_UNUSED,
2302 void *ext1 ATTRIBUTE_UNUSED,
2303 void *in1 ATTRIBUTE_UNUSED)
2304 {
2305 }
2306
2307 static unsigned int
alpha_ecoff_swap_coff_aux_out(bfd * abfd ATTRIBUTE_UNUSED,void * inp ATTRIBUTE_UNUSED,int type ATTRIBUTE_UNUSED,int in_class ATTRIBUTE_UNUSED,int indx ATTRIBUTE_UNUSED,int numaux ATTRIBUTE_UNUSED,void * extp ATTRIBUTE_UNUSED)2308 alpha_ecoff_swap_coff_aux_out (bfd *abfd ATTRIBUTE_UNUSED,
2309 void *inp ATTRIBUTE_UNUSED,
2310 int type ATTRIBUTE_UNUSED,
2311 int in_class ATTRIBUTE_UNUSED,
2312 int indx ATTRIBUTE_UNUSED,
2313 int numaux ATTRIBUTE_UNUSED,
2314 void *extp ATTRIBUTE_UNUSED)
2315 {
2316 return 0;
2317 }
2318
2319 static unsigned int
alpha_ecoff_swap_coff_sym_out(bfd * abfd ATTRIBUTE_UNUSED,void * inp ATTRIBUTE_UNUSED,void * extp ATTRIBUTE_UNUSED)2320 alpha_ecoff_swap_coff_sym_out (bfd *abfd ATTRIBUTE_UNUSED,
2321 void *inp ATTRIBUTE_UNUSED,
2322 void *extp ATTRIBUTE_UNUSED)
2323 {
2324 return 0;
2325 }
2326
2327 static unsigned int
alpha_ecoff_swap_coff_lineno_out(bfd * abfd ATTRIBUTE_UNUSED,void * inp ATTRIBUTE_UNUSED,void * extp ATTRIBUTE_UNUSED)2328 alpha_ecoff_swap_coff_lineno_out (bfd *abfd ATTRIBUTE_UNUSED,
2329 void *inp ATTRIBUTE_UNUSED,
2330 void *extp ATTRIBUTE_UNUSED)
2331 {
2332 return 0;
2333 }
2334
2335 static unsigned int
alpha_ecoff_swap_coff_reloc_out(bfd * abfd ATTRIBUTE_UNUSED,void * inp ATTRIBUTE_UNUSED,void * extp ATTRIBUTE_UNUSED)2336 alpha_ecoff_swap_coff_reloc_out (bfd *abfd ATTRIBUTE_UNUSED,
2337 void *inp ATTRIBUTE_UNUSED,
2338 void *extp ATTRIBUTE_UNUSED)
2339 {
2340 return 0;
2341 }
2342
2343 /* This is the ECOFF backend structure. The backend field of the
2344 target vector points to this. */
2345
2346 static const struct ecoff_backend_data alpha_ecoff_backend_data =
2347 {
2348 /* COFF backend structure. */
2349 {
2350 alpha_ecoff_swap_coff_aux_in, alpha_ecoff_swap_coff_sym_in,
2351 alpha_ecoff_swap_coff_lineno_in, alpha_ecoff_swap_coff_aux_out,
2352 alpha_ecoff_swap_coff_sym_out, alpha_ecoff_swap_coff_lineno_out,
2353 alpha_ecoff_swap_coff_reloc_out,
2354 alpha_ecoff_swap_filehdr_out, alpha_ecoff_swap_aouthdr_out,
2355 alpha_ecoff_swap_scnhdr_out,
2356 FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, true,
2357 ECOFF_NO_LONG_SECTION_NAMES, 4, false, 2, 32768,
2358 alpha_ecoff_swap_filehdr_in, alpha_ecoff_swap_aouthdr_in,
2359 alpha_ecoff_swap_scnhdr_in, NULL,
2360 alpha_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook,
2361 alpha_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
2362 _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table,
2363 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2364 NULL, NULL, NULL, NULL
2365 },
2366 /* Supported architecture. */
2367 bfd_arch_alpha,
2368 /* Initial portion of armap string. */
2369 "________64",
2370 /* The page boundary used to align sections in a demand-paged
2371 executable file. E.g., 0x1000. */
2372 0x2000,
2373 /* TRUE if the .rdata section is part of the text segment, as on the
2374 Alpha. FALSE if .rdata is part of the data segment, as on the
2375 MIPS. */
2376 true,
2377 /* Bitsize of constructor entries. */
2378 64,
2379 /* Reloc to use for constructor entries. */
2380 &alpha_howto_table[ALPHA_R_REFQUAD],
2381 {
2382 /* Symbol table magic number. */
2383 magicSym2,
2384 /* Alignment of debugging information. E.g., 4. */
2385 8,
2386 /* Sizes of external symbolic information. */
2387 sizeof (struct hdr_ext),
2388 sizeof (struct dnr_ext),
2389 sizeof (struct pdr_ext),
2390 sizeof (struct sym_ext),
2391 sizeof (struct opt_ext),
2392 sizeof (struct fdr_ext),
2393 sizeof (struct rfd_ext),
2394 sizeof (struct ext_ext),
2395 /* Functions to swap in external symbolic data. */
2396 ecoff_swap_hdr_in,
2397 ecoff_swap_dnr_in,
2398 ecoff_swap_pdr_in,
2399 ecoff_swap_sym_in,
2400 ecoff_swap_opt_in,
2401 ecoff_swap_fdr_in,
2402 ecoff_swap_rfd_in,
2403 ecoff_swap_ext_in,
2404 _bfd_ecoff_swap_tir_in,
2405 _bfd_ecoff_swap_rndx_in,
2406 /* Functions to swap out external symbolic data. */
2407 ecoff_swap_hdr_out,
2408 ecoff_swap_dnr_out,
2409 ecoff_swap_pdr_out,
2410 ecoff_swap_sym_out,
2411 ecoff_swap_opt_out,
2412 ecoff_swap_fdr_out,
2413 ecoff_swap_rfd_out,
2414 ecoff_swap_ext_out,
2415 _bfd_ecoff_swap_tir_out,
2416 _bfd_ecoff_swap_rndx_out,
2417 /* Function to read in symbolic data. */
2418 _bfd_ecoff_slurp_symbolic_info
2419 },
2420 /* External reloc size. */
2421 RELSZ,
2422 /* Reloc swapping functions. */
2423 alpha_ecoff_swap_reloc_in,
2424 alpha_ecoff_swap_reloc_out,
2425 /* Backend reloc tweaking. */
2426 alpha_adjust_reloc_in,
2427 alpha_adjust_reloc_out,
2428 /* Relocate section contents while linking. */
2429 alpha_relocate_section,
2430 /* Do final adjustments to filehdr and aouthdr. */
2431 alpha_adjust_headers,
2432 /* Read an element from an archive at a given file position. */
2433 alpha_ecoff_get_elt_at_filepos
2434 };
2435
2436 /* Looking up a reloc type is Alpha specific. */
2437 #define _bfd_ecoff_bfd_reloc_type_lookup alpha_bfd_reloc_type_lookup
2438 #define _bfd_ecoff_bfd_reloc_name_lookup \
2439 alpha_bfd_reloc_name_lookup
2440
2441 /* So is getting relocated section contents. */
2442 #define _bfd_ecoff_bfd_get_relocated_section_contents \
2443 alpha_ecoff_get_relocated_section_contents
2444
2445 /* Handling file windows is generic. */
2446 #define _bfd_ecoff_get_section_contents_in_window \
2447 _bfd_generic_get_section_contents_in_window
2448
2449 /* Input section flag lookup is generic. */
2450 #define _bfd_ecoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags
2451
2452 /* Relaxing sections is generic. */
2453 #define _bfd_ecoff_bfd_relax_section bfd_generic_relax_section
2454 #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections
2455 #define _bfd_ecoff_bfd_merge_sections bfd_generic_merge_sections
2456 #define _bfd_ecoff_bfd_is_group_section bfd_generic_is_group_section
2457 #define _bfd_ecoff_bfd_group_name bfd_generic_group_name
2458 #define _bfd_ecoff_bfd_discard_group bfd_generic_discard_group
2459 #define _bfd_ecoff_section_already_linked \
2460 _bfd_coff_section_already_linked
2461 #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
2462 #define _bfd_ecoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
2463 #define _bfd_ecoff_bfd_define_start_stop bfd_generic_define_start_stop
2464 #define _bfd_ecoff_bfd_link_check_relocs _bfd_generic_link_check_relocs
2465
2466 /* Installing internal relocations in a section is also generic. */
2467 #define _bfd_ecoff_set_reloc _bfd_generic_set_reloc
2468
2469 const bfd_target alpha_ecoff_le_vec =
2470 {
2471 "ecoff-littlealpha", /* name */
2472 bfd_target_ecoff_flavour,
2473 BFD_ENDIAN_LITTLE, /* data byte order is little */
2474 BFD_ENDIAN_LITTLE, /* header byte order is little */
2475
2476 (HAS_RELOC | EXEC_P /* object flags */
2477 | HAS_LINENO | HAS_DEBUG
2478 | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
2479
2480 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE
2481 | SEC_DATA | SEC_SMALL_DATA),
2482 0, /* leading underscore */
2483 ' ', /* ar_pad_char */
2484 15, /* ar_max_namelen */
2485 0, /* match priority. */
2486 TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols. */
2487 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
2488 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
2489 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
2490 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
2491 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
2492 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
2493
2494 { /* bfd_check_format */
2495 _bfd_dummy_target,
2496 alpha_ecoff_object_p,
2497 bfd_generic_archive_p,
2498 _bfd_dummy_target
2499 },
2500 { /* bfd_set_format */
2501 _bfd_bool_bfd_false_error,
2502 _bfd_ecoff_mkobject,
2503 _bfd_generic_mkarchive,
2504 _bfd_bool_bfd_false_error
2505 },
2506 { /* bfd_write_contents */
2507 _bfd_bool_bfd_false_error,
2508 _bfd_ecoff_write_object_contents,
2509 _bfd_write_archive_contents,
2510 _bfd_bool_bfd_false_error
2511 },
2512
2513 BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
2514 BFD_JUMP_TABLE_COPY (_bfd_ecoff),
2515 BFD_JUMP_TABLE_CORE (_bfd_nocore),
2516 BFD_JUMP_TABLE_ARCHIVE (alpha_ecoff),
2517 BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
2518 BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
2519 BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
2520 BFD_JUMP_TABLE_LINK (_bfd_ecoff),
2521 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
2522
2523 NULL,
2524
2525 &alpha_ecoff_backend_data
2526 };
2527