1 /* MMIX-specific support for 64-bit ELF.
2 Copyright 2001, 2002, 2003, 2004, 2005, 2006
3 Free Software Foundation, Inc.
4 Contributed by Hans-Peter Nilsson <hp@bitrange.com>
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
22 /* No specific ABI or "processor-specific supplement" defined. */
25 - "Traditional" linker relaxation (shrinking whole sections).
26 - Merge reloc stubs jumping to same location.
27 - GETA stub relaxation (call a stub for out of range new
28 R_MMIX_GETA_STUBBABLE). */
35 #include "opcode/mmix.h"
37 #define MINUS_ONE (((bfd_vma) 0) - 1)
39 #define MAX_PUSHJ_STUB_SIZE (5 * 4)
41 /* Put these everywhere in new code. */
43 _bfd_abort (__FILE__, __LINE__, \
44 "Internal: Non-debugged code (test-case missing)")
47 _bfd_abort (__FILE__, __LINE__, \
50 struct _mmix_elf_section_data
52 struct bfd_elf_section_data elf;
55 struct bpo_reloc_section_info *reloc;
56 struct bpo_greg_section_info *greg;
59 struct pushj_stub_info
61 /* Maximum number of stubs needed for this section. */
62 bfd_size_type n_pushj_relocs;
64 /* Size of stubs after a mmix_elf_relax_section round. */
65 bfd_size_type stubs_size_sum;
67 /* Per-reloc stubs_size_sum information. The stubs_size_sum member is the sum
68 of these. Allocated in mmix_elf_check_common_relocs. */
69 bfd_size_type *stub_size;
71 /* Offset of next stub during relocation. Somewhat redundant with the
72 above: error coverage is easier and we don't have to reset the
73 stubs_size_sum for relocation. */
74 bfd_size_type stub_offset;
78 #define mmix_elf_section_data(sec) \
79 ((struct _mmix_elf_section_data *) elf_section_data (sec))
81 /* For each section containing a base-plus-offset (BPO) reloc, we attach
82 this struct as mmix_elf_section_data (section)->bpo, which is otherwise
84 struct bpo_reloc_section_info
86 /* The base is 1; this is the first number in this section. */
87 size_t first_base_plus_offset_reloc;
89 /* Number of BPO-relocs in this section. */
90 size_t n_bpo_relocs_this_section;
92 /* Running index, used at relocation time. */
95 /* We don't have access to the bfd_link_info struct in
96 mmix_final_link_relocate. What we really want to get at is the
97 global single struct greg_relocation, so we stash it here. */
98 asection *bpo_greg_section;
101 /* Helper struct (in global context) for the one below.
102 There's one of these created for every BPO reloc. */
103 struct bpo_reloc_request
107 /* Valid after relaxation. The base is 0; the first register number
108 must be added. The offset is in range 0..255. */
112 /* The order number for this BPO reloc, corresponding to the order in
113 which BPO relocs were found. Used to create an index after reloc
114 requests are sorted. */
117 /* Set when the value is computed. Better than coding "guard values"
118 into the other members. Is FALSE only for BPO relocs in a GC:ed
123 /* We attach this as mmix_elf_section_data (sec)->bpo in the linker-allocated
124 greg contents section (MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME),
125 which is linked into the register contents section
126 (MMIX_REG_CONTENTS_SECTION_NAME). This section is created by the
127 linker; using the same hook as for usual with BPO relocs does not
129 struct bpo_greg_section_info
131 /* After GC, this reflects the number of remaining, non-excluded
135 /* This is the number of allocated bpo_reloc_requests; the size of
136 sorted_indexes. Valid after the check.*relocs functions are called
137 for all incoming sections. It includes the number of BPO relocs in
138 sections that were GC:ed. */
139 size_t n_max_bpo_relocs;
141 /* A counter used to find out when to fold the BPO gregs, since we
142 don't have a single "after-relaxation" hook. */
143 size_t n_remaining_bpo_relocs_this_relaxation_round;
145 /* The number of linker-allocated GREGs resulting from BPO relocs.
146 This is an approximation after _bfd_mmix_before_linker_allocation
147 and supposedly accurate after mmix_elf_relax_section is called for
148 all incoming non-collected sections. */
149 size_t n_allocated_bpo_gregs;
151 /* Index into reloc_request[], sorted on increasing "value", secondary
152 by increasing index for strict sorting order. */
153 size_t *bpo_reloc_indexes;
155 /* An array of all relocations, with the "value" member filled in by
156 the relaxation function. */
157 struct bpo_reloc_request *reloc_request;
160 static bfd_boolean mmix_elf_link_output_symbol_hook
161 PARAMS ((struct bfd_link_info *, const char *, Elf_Internal_Sym *,
162 asection *, struct elf_link_hash_entry *));
164 static bfd_reloc_status_type mmix_elf_reloc
165 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
167 static reloc_howto_type *bfd_elf64_bfd_reloc_type_lookup
168 PARAMS ((bfd *, bfd_reloc_code_real_type));
170 static void mmix_info_to_howto_rela
171 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
173 static int mmix_elf_sort_relocs PARAMS ((const PTR, const PTR));
175 static bfd_boolean mmix_elf_new_section_hook
176 PARAMS ((bfd *, asection *));
178 static bfd_boolean mmix_elf_check_relocs
179 PARAMS ((bfd *, struct bfd_link_info *, asection *,
180 const Elf_Internal_Rela *));
182 static bfd_boolean mmix_elf_check_common_relocs
183 PARAMS ((bfd *, struct bfd_link_info *, asection *,
184 const Elf_Internal_Rela *));
186 static bfd_boolean mmix_elf_relocate_section
187 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
188 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
190 static bfd_reloc_status_type mmix_final_link_relocate
191 PARAMS ((reloc_howto_type *, asection *, bfd_byte *,
192 bfd_vma, bfd_signed_vma, bfd_vma, const char *, asection *));
194 static bfd_reloc_status_type mmix_elf_perform_relocation
195 PARAMS ((asection *, reloc_howto_type *, PTR, bfd_vma, bfd_vma));
197 static bfd_boolean mmix_elf_section_from_bfd_section
198 PARAMS ((bfd *, asection *, int *));
200 static bfd_boolean mmix_elf_add_symbol_hook
201 PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Sym *,
202 const char **, flagword *, asection **, bfd_vma *));
204 static bfd_boolean mmix_elf_is_local_label_name
205 PARAMS ((bfd *, const char *));
207 static int bpo_reloc_request_sort_fn PARAMS ((const PTR, const PTR));
209 static bfd_boolean mmix_elf_relax_section
210 PARAMS ((bfd *abfd, asection *sec, struct bfd_link_info *link_info,
211 bfd_boolean *again));
213 extern bfd_boolean mmix_elf_final_link PARAMS ((bfd *, struct bfd_link_info *));
215 extern void mmix_elf_symbol_processing PARAMS ((bfd *, asymbol *));
217 /* Only intended to be called from a debugger. */
218 extern void mmix_dump_bpo_gregs
219 PARAMS ((struct bfd_link_info *, bfd_error_handler_type));
222 mmix_set_relaxable_size
223 PARAMS ((bfd *, asection *, void *));
226 /* Watch out: this currently needs to have elements with the same index as
227 their R_MMIX_ number. */
228 static reloc_howto_type elf_mmix_howto_table[] =
230 /* This reloc does nothing. */
231 HOWTO (R_MMIX_NONE, /* type */
233 2, /* size (0 = byte, 1 = short, 2 = long) */
235 FALSE, /* pc_relative */
237 complain_overflow_bitfield, /* complain_on_overflow */
238 bfd_elf_generic_reloc, /* special_function */
239 "R_MMIX_NONE", /* name */
240 FALSE, /* partial_inplace */
243 FALSE), /* pcrel_offset */
245 /* An 8 bit absolute relocation. */
246 HOWTO (R_MMIX_8, /* type */
248 0, /* size (0 = byte, 1 = short, 2 = long) */
250 FALSE, /* pc_relative */
252 complain_overflow_bitfield, /* complain_on_overflow */
253 bfd_elf_generic_reloc, /* special_function */
254 "R_MMIX_8", /* name */
255 FALSE, /* partial_inplace */
258 FALSE), /* pcrel_offset */
260 /* An 16 bit absolute relocation. */
261 HOWTO (R_MMIX_16, /* type */
263 1, /* size (0 = byte, 1 = short, 2 = long) */
265 FALSE, /* pc_relative */
267 complain_overflow_bitfield, /* complain_on_overflow */
268 bfd_elf_generic_reloc, /* special_function */
269 "R_MMIX_16", /* name */
270 FALSE, /* partial_inplace */
272 0xffff, /* dst_mask */
273 FALSE), /* pcrel_offset */
275 /* An 24 bit absolute relocation. */
276 HOWTO (R_MMIX_24, /* type */
278 2, /* size (0 = byte, 1 = short, 2 = long) */
280 FALSE, /* pc_relative */
282 complain_overflow_bitfield, /* complain_on_overflow */
283 bfd_elf_generic_reloc, /* special_function */
284 "R_MMIX_24", /* name */
285 FALSE, /* partial_inplace */
286 ~0xffffff, /* src_mask */
287 0xffffff, /* dst_mask */
288 FALSE), /* pcrel_offset */
290 /* A 32 bit absolute relocation. */
291 HOWTO (R_MMIX_32, /* type */
293 2, /* size (0 = byte, 1 = short, 2 = long) */
295 FALSE, /* pc_relative */
297 complain_overflow_bitfield, /* complain_on_overflow */
298 bfd_elf_generic_reloc, /* special_function */
299 "R_MMIX_32", /* name */
300 FALSE, /* partial_inplace */
302 0xffffffff, /* dst_mask */
303 FALSE), /* pcrel_offset */
305 /* 64 bit relocation. */
306 HOWTO (R_MMIX_64, /* type */
308 4, /* size (0 = byte, 1 = short, 2 = long) */
310 FALSE, /* pc_relative */
312 complain_overflow_bitfield, /* complain_on_overflow */
313 bfd_elf_generic_reloc, /* special_function */
314 "R_MMIX_64", /* name */
315 FALSE, /* partial_inplace */
317 MINUS_ONE, /* dst_mask */
318 FALSE), /* pcrel_offset */
320 /* An 8 bit PC-relative relocation. */
321 HOWTO (R_MMIX_PC_8, /* type */
323 0, /* size (0 = byte, 1 = short, 2 = long) */
325 TRUE, /* pc_relative */
327 complain_overflow_bitfield, /* complain_on_overflow */
328 bfd_elf_generic_reloc, /* special_function */
329 "R_MMIX_PC_8", /* name */
330 FALSE, /* partial_inplace */
333 TRUE), /* pcrel_offset */
335 /* An 16 bit PC-relative relocation. */
336 HOWTO (R_MMIX_PC_16, /* type */
338 1, /* size (0 = byte, 1 = short, 2 = long) */
340 TRUE, /* pc_relative */
342 complain_overflow_bitfield, /* complain_on_overflow */
343 bfd_elf_generic_reloc, /* special_function */
344 "R_MMIX_PC_16", /* name */
345 FALSE, /* partial_inplace */
347 0xffff, /* dst_mask */
348 TRUE), /* pcrel_offset */
350 /* An 24 bit PC-relative relocation. */
351 HOWTO (R_MMIX_PC_24, /* type */
353 2, /* size (0 = byte, 1 = short, 2 = long) */
355 TRUE, /* pc_relative */
357 complain_overflow_bitfield, /* complain_on_overflow */
358 bfd_elf_generic_reloc, /* special_function */
359 "R_MMIX_PC_24", /* name */
360 FALSE, /* partial_inplace */
361 ~0xffffff, /* src_mask */
362 0xffffff, /* dst_mask */
363 TRUE), /* pcrel_offset */
365 /* A 32 bit absolute PC-relative relocation. */
366 HOWTO (R_MMIX_PC_32, /* type */
368 2, /* size (0 = byte, 1 = short, 2 = long) */
370 TRUE, /* pc_relative */
372 complain_overflow_bitfield, /* complain_on_overflow */
373 bfd_elf_generic_reloc, /* special_function */
374 "R_MMIX_PC_32", /* name */
375 FALSE, /* partial_inplace */
377 0xffffffff, /* dst_mask */
378 TRUE), /* pcrel_offset */
380 /* 64 bit PC-relative relocation. */
381 HOWTO (R_MMIX_PC_64, /* type */
383 4, /* size (0 = byte, 1 = short, 2 = long) */
385 TRUE, /* pc_relative */
387 complain_overflow_bitfield, /* complain_on_overflow */
388 bfd_elf_generic_reloc, /* special_function */
389 "R_MMIX_PC_64", /* name */
390 FALSE, /* partial_inplace */
392 MINUS_ONE, /* dst_mask */
393 TRUE), /* pcrel_offset */
395 /* GNU extension to record C++ vtable hierarchy. */
396 HOWTO (R_MMIX_GNU_VTINHERIT, /* type */
398 0, /* size (0 = byte, 1 = short, 2 = long) */
400 FALSE, /* pc_relative */
402 complain_overflow_dont, /* complain_on_overflow */
403 NULL, /* special_function */
404 "R_MMIX_GNU_VTINHERIT", /* name */
405 FALSE, /* partial_inplace */
408 TRUE), /* pcrel_offset */
410 /* GNU extension to record C++ vtable member usage. */
411 HOWTO (R_MMIX_GNU_VTENTRY, /* type */
413 0, /* size (0 = byte, 1 = short, 2 = long) */
415 FALSE, /* pc_relative */
417 complain_overflow_dont, /* complain_on_overflow */
418 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
419 "R_MMIX_GNU_VTENTRY", /* name */
420 FALSE, /* partial_inplace */
423 FALSE), /* pcrel_offset */
425 /* The GETA relocation is supposed to get any address that could
426 possibly be reached by the GETA instruction. It can silently expand
427 to get a 64-bit operand, but will complain if any of the two least
428 significant bits are set. The howto members reflect a simple GETA. */
429 HOWTO (R_MMIX_GETA, /* type */
431 2, /* size (0 = byte, 1 = short, 2 = long) */
433 TRUE, /* pc_relative */
435 complain_overflow_signed, /* complain_on_overflow */
436 mmix_elf_reloc, /* special_function */
437 "R_MMIX_GETA", /* name */
438 FALSE, /* partial_inplace */
439 ~0x0100ffff, /* src_mask */
440 0x0100ffff, /* dst_mask */
441 TRUE), /* pcrel_offset */
443 HOWTO (R_MMIX_GETA_1, /* type */
445 2, /* size (0 = byte, 1 = short, 2 = long) */
447 TRUE, /* pc_relative */
449 complain_overflow_signed, /* complain_on_overflow */
450 mmix_elf_reloc, /* special_function */
451 "R_MMIX_GETA_1", /* name */
452 FALSE, /* partial_inplace */
453 ~0x0100ffff, /* src_mask */
454 0x0100ffff, /* dst_mask */
455 TRUE), /* pcrel_offset */
457 HOWTO (R_MMIX_GETA_2, /* type */
459 2, /* size (0 = byte, 1 = short, 2 = long) */
461 TRUE, /* pc_relative */
463 complain_overflow_signed, /* complain_on_overflow */
464 mmix_elf_reloc, /* special_function */
465 "R_MMIX_GETA_2", /* name */
466 FALSE, /* partial_inplace */
467 ~0x0100ffff, /* src_mask */
468 0x0100ffff, /* dst_mask */
469 TRUE), /* pcrel_offset */
471 HOWTO (R_MMIX_GETA_3, /* type */
473 2, /* size (0 = byte, 1 = short, 2 = long) */
475 TRUE, /* pc_relative */
477 complain_overflow_signed, /* complain_on_overflow */
478 mmix_elf_reloc, /* special_function */
479 "R_MMIX_GETA_3", /* name */
480 FALSE, /* partial_inplace */
481 ~0x0100ffff, /* src_mask */
482 0x0100ffff, /* dst_mask */
483 TRUE), /* pcrel_offset */
485 /* The conditional branches are supposed to reach any (code) address.
486 It can silently expand to a 64-bit operand, but will emit an error if
487 any of the two least significant bits are set. The howto members
488 reflect a simple branch. */
489 HOWTO (R_MMIX_CBRANCH, /* type */
491 2, /* size (0 = byte, 1 = short, 2 = long) */
493 TRUE, /* pc_relative */
495 complain_overflow_signed, /* complain_on_overflow */
496 mmix_elf_reloc, /* special_function */
497 "R_MMIX_CBRANCH", /* name */
498 FALSE, /* partial_inplace */
499 ~0x0100ffff, /* src_mask */
500 0x0100ffff, /* dst_mask */
501 TRUE), /* pcrel_offset */
503 HOWTO (R_MMIX_CBRANCH_J, /* type */
505 2, /* size (0 = byte, 1 = short, 2 = long) */
507 TRUE, /* pc_relative */
509 complain_overflow_signed, /* complain_on_overflow */
510 mmix_elf_reloc, /* special_function */
511 "R_MMIX_CBRANCH_J", /* name */
512 FALSE, /* partial_inplace */
513 ~0x0100ffff, /* src_mask */
514 0x0100ffff, /* dst_mask */
515 TRUE), /* pcrel_offset */
517 HOWTO (R_MMIX_CBRANCH_1, /* type */
519 2, /* size (0 = byte, 1 = short, 2 = long) */
521 TRUE, /* pc_relative */
523 complain_overflow_signed, /* complain_on_overflow */
524 mmix_elf_reloc, /* special_function */
525 "R_MMIX_CBRANCH_1", /* name */
526 FALSE, /* partial_inplace */
527 ~0x0100ffff, /* src_mask */
528 0x0100ffff, /* dst_mask */
529 TRUE), /* pcrel_offset */
531 HOWTO (R_MMIX_CBRANCH_2, /* type */
533 2, /* size (0 = byte, 1 = short, 2 = long) */
535 TRUE, /* pc_relative */
537 complain_overflow_signed, /* complain_on_overflow */
538 mmix_elf_reloc, /* special_function */
539 "R_MMIX_CBRANCH_2", /* name */
540 FALSE, /* partial_inplace */
541 ~0x0100ffff, /* src_mask */
542 0x0100ffff, /* dst_mask */
543 TRUE), /* pcrel_offset */
545 HOWTO (R_MMIX_CBRANCH_3, /* type */
547 2, /* size (0 = byte, 1 = short, 2 = long) */
549 TRUE, /* pc_relative */
551 complain_overflow_signed, /* complain_on_overflow */
552 mmix_elf_reloc, /* special_function */
553 "R_MMIX_CBRANCH_3", /* name */
554 FALSE, /* partial_inplace */
555 ~0x0100ffff, /* src_mask */
556 0x0100ffff, /* dst_mask */
557 TRUE), /* pcrel_offset */
559 /* The PUSHJ instruction can reach any (code) address, as long as it's
560 the beginning of a function (no usable restriction). It can silently
561 expand to a 64-bit operand, but will emit an error if any of the two
562 least significant bits are set. It can also expand into a call to a
563 stub; see R_MMIX_PUSHJ_STUBBABLE. The howto members reflect a simple
565 HOWTO (R_MMIX_PUSHJ, /* type */
567 2, /* size (0 = byte, 1 = short, 2 = long) */
569 TRUE, /* pc_relative */
571 complain_overflow_signed, /* complain_on_overflow */
572 mmix_elf_reloc, /* special_function */
573 "R_MMIX_PUSHJ", /* name */
574 FALSE, /* partial_inplace */
575 ~0x0100ffff, /* src_mask */
576 0x0100ffff, /* dst_mask */
577 TRUE), /* pcrel_offset */
579 HOWTO (R_MMIX_PUSHJ_1, /* type */
581 2, /* size (0 = byte, 1 = short, 2 = long) */
583 TRUE, /* pc_relative */
585 complain_overflow_signed, /* complain_on_overflow */
586 mmix_elf_reloc, /* special_function */
587 "R_MMIX_PUSHJ_1", /* name */
588 FALSE, /* partial_inplace */
589 ~0x0100ffff, /* src_mask */
590 0x0100ffff, /* dst_mask */
591 TRUE), /* pcrel_offset */
593 HOWTO (R_MMIX_PUSHJ_2, /* type */
595 2, /* size (0 = byte, 1 = short, 2 = long) */
597 TRUE, /* pc_relative */
599 complain_overflow_signed, /* complain_on_overflow */
600 mmix_elf_reloc, /* special_function */
601 "R_MMIX_PUSHJ_2", /* name */
602 FALSE, /* partial_inplace */
603 ~0x0100ffff, /* src_mask */
604 0x0100ffff, /* dst_mask */
605 TRUE), /* pcrel_offset */
607 HOWTO (R_MMIX_PUSHJ_3, /* type */
609 2, /* size (0 = byte, 1 = short, 2 = long) */
611 TRUE, /* pc_relative */
613 complain_overflow_signed, /* complain_on_overflow */
614 mmix_elf_reloc, /* special_function */
615 "R_MMIX_PUSHJ_3", /* name */
616 FALSE, /* partial_inplace */
617 ~0x0100ffff, /* src_mask */
618 0x0100ffff, /* dst_mask */
619 TRUE), /* pcrel_offset */
621 /* A JMP is supposed to reach any (code) address. By itself, it can
622 reach +-64M; the expansion can reach all 64 bits. Note that the 64M
623 limit is soon reached if you link the program in wildly different
624 memory segments. The howto members reflect a trivial JMP. */
625 HOWTO (R_MMIX_JMP, /* type */
627 2, /* size (0 = byte, 1 = short, 2 = long) */
629 TRUE, /* pc_relative */
631 complain_overflow_signed, /* complain_on_overflow */
632 mmix_elf_reloc, /* special_function */
633 "R_MMIX_JMP", /* name */
634 FALSE, /* partial_inplace */
635 ~0x1ffffff, /* src_mask */
636 0x1ffffff, /* dst_mask */
637 TRUE), /* pcrel_offset */
639 HOWTO (R_MMIX_JMP_1, /* type */
641 2, /* size (0 = byte, 1 = short, 2 = long) */
643 TRUE, /* pc_relative */
645 complain_overflow_signed, /* complain_on_overflow */
646 mmix_elf_reloc, /* special_function */
647 "R_MMIX_JMP_1", /* name */
648 FALSE, /* partial_inplace */
649 ~0x1ffffff, /* src_mask */
650 0x1ffffff, /* dst_mask */
651 TRUE), /* pcrel_offset */
653 HOWTO (R_MMIX_JMP_2, /* type */
655 2, /* size (0 = byte, 1 = short, 2 = long) */
657 TRUE, /* pc_relative */
659 complain_overflow_signed, /* complain_on_overflow */
660 mmix_elf_reloc, /* special_function */
661 "R_MMIX_JMP_2", /* name */
662 FALSE, /* partial_inplace */
663 ~0x1ffffff, /* src_mask */
664 0x1ffffff, /* dst_mask */
665 TRUE), /* pcrel_offset */
667 HOWTO (R_MMIX_JMP_3, /* type */
669 2, /* size (0 = byte, 1 = short, 2 = long) */
671 TRUE, /* pc_relative */
673 complain_overflow_signed, /* complain_on_overflow */
674 mmix_elf_reloc, /* special_function */
675 "R_MMIX_JMP_3", /* name */
676 FALSE, /* partial_inplace */
677 ~0x1ffffff, /* src_mask */
678 0x1ffffff, /* dst_mask */
679 TRUE), /* pcrel_offset */
681 /* When we don't emit link-time-relaxable code from the assembler, or
682 when relaxation has done all it can do, these relocs are used. For
683 GETA/PUSHJ/branches. */
684 HOWTO (R_MMIX_ADDR19, /* type */
686 2, /* size (0 = byte, 1 = short, 2 = long) */
688 TRUE, /* pc_relative */
690 complain_overflow_signed, /* complain_on_overflow */
691 mmix_elf_reloc, /* special_function */
692 "R_MMIX_ADDR19", /* name */
693 FALSE, /* partial_inplace */
694 ~0x0100ffff, /* src_mask */
695 0x0100ffff, /* dst_mask */
696 TRUE), /* pcrel_offset */
699 HOWTO (R_MMIX_ADDR27, /* type */
701 2, /* size (0 = byte, 1 = short, 2 = long) */
703 TRUE, /* pc_relative */
705 complain_overflow_signed, /* complain_on_overflow */
706 mmix_elf_reloc, /* special_function */
707 "R_MMIX_ADDR27", /* name */
708 FALSE, /* partial_inplace */
709 ~0x1ffffff, /* src_mask */
710 0x1ffffff, /* dst_mask */
711 TRUE), /* pcrel_offset */
713 /* A general register or the value 0..255. If a value, then the
714 instruction (offset -3) needs adjusting. */
715 HOWTO (R_MMIX_REG_OR_BYTE, /* type */
717 1, /* size (0 = byte, 1 = short, 2 = long) */
719 FALSE, /* pc_relative */
721 complain_overflow_bitfield, /* complain_on_overflow */
722 mmix_elf_reloc, /* special_function */
723 "R_MMIX_REG_OR_BYTE", /* name */
724 FALSE, /* partial_inplace */
727 FALSE), /* pcrel_offset */
729 /* A general register. */
730 HOWTO (R_MMIX_REG, /* type */
732 1, /* size (0 = byte, 1 = short, 2 = long) */
734 FALSE, /* pc_relative */
736 complain_overflow_bitfield, /* complain_on_overflow */
737 mmix_elf_reloc, /* special_function */
738 "R_MMIX_REG", /* name */
739 FALSE, /* partial_inplace */
742 FALSE), /* pcrel_offset */
744 /* A register plus an index, corresponding to the relocation expression.
745 The sizes must correspond to the valid range of the expression, while
746 the bitmasks correspond to what we store in the image. */
747 HOWTO (R_MMIX_BASE_PLUS_OFFSET, /* type */
749 4, /* size (0 = byte, 1 = short, 2 = long) */
751 FALSE, /* pc_relative */
753 complain_overflow_bitfield, /* complain_on_overflow */
754 mmix_elf_reloc, /* special_function */
755 "R_MMIX_BASE_PLUS_OFFSET", /* name */
756 FALSE, /* partial_inplace */
758 0xffff, /* dst_mask */
759 FALSE), /* pcrel_offset */
761 /* A "magic" relocation for a LOCAL expression, asserting that the
762 expression is less than the number of global registers. No actual
763 modification of the contents is done. Implementing this as a
764 relocation was less intrusive than e.g. putting such expressions in a
765 section to discard *after* relocation. */
766 HOWTO (R_MMIX_LOCAL, /* type */
768 0, /* size (0 = byte, 1 = short, 2 = long) */
770 FALSE, /* pc_relative */
772 complain_overflow_dont, /* complain_on_overflow */
773 mmix_elf_reloc, /* special_function */
774 "R_MMIX_LOCAL", /* name */
775 FALSE, /* partial_inplace */
778 FALSE), /* pcrel_offset */
780 HOWTO (R_MMIX_PUSHJ_STUBBABLE, /* type */
782 2, /* size (0 = byte, 1 = short, 2 = long) */
784 TRUE, /* pc_relative */
786 complain_overflow_signed, /* complain_on_overflow */
787 mmix_elf_reloc, /* special_function */
788 "R_MMIX_PUSHJ_STUBBABLE", /* name */
789 FALSE, /* partial_inplace */
790 ~0x0100ffff, /* src_mask */
791 0x0100ffff, /* dst_mask */
792 TRUE) /* pcrel_offset */
796 /* Map BFD reloc types to MMIX ELF reloc types. */
798 struct mmix_reloc_map
800 bfd_reloc_code_real_type bfd_reloc_val;
801 enum elf_mmix_reloc_type elf_reloc_val;
805 static const struct mmix_reloc_map mmix_reloc_map[] =
807 {BFD_RELOC_NONE, R_MMIX_NONE},
808 {BFD_RELOC_8, R_MMIX_8},
809 {BFD_RELOC_16, R_MMIX_16},
810 {BFD_RELOC_24, R_MMIX_24},
811 {BFD_RELOC_32, R_MMIX_32},
812 {BFD_RELOC_64, R_MMIX_64},
813 {BFD_RELOC_8_PCREL, R_MMIX_PC_8},
814 {BFD_RELOC_16_PCREL, R_MMIX_PC_16},
815 {BFD_RELOC_24_PCREL, R_MMIX_PC_24},
816 {BFD_RELOC_32_PCREL, R_MMIX_PC_32},
817 {BFD_RELOC_64_PCREL, R_MMIX_PC_64},
818 {BFD_RELOC_VTABLE_INHERIT, R_MMIX_GNU_VTINHERIT},
819 {BFD_RELOC_VTABLE_ENTRY, R_MMIX_GNU_VTENTRY},
820 {BFD_RELOC_MMIX_GETA, R_MMIX_GETA},
821 {BFD_RELOC_MMIX_CBRANCH, R_MMIX_CBRANCH},
822 {BFD_RELOC_MMIX_PUSHJ, R_MMIX_PUSHJ},
823 {BFD_RELOC_MMIX_JMP, R_MMIX_JMP},
824 {BFD_RELOC_MMIX_ADDR19, R_MMIX_ADDR19},
825 {BFD_RELOC_MMIX_ADDR27, R_MMIX_ADDR27},
826 {BFD_RELOC_MMIX_REG_OR_BYTE, R_MMIX_REG_OR_BYTE},
827 {BFD_RELOC_MMIX_REG, R_MMIX_REG},
828 {BFD_RELOC_MMIX_BASE_PLUS_OFFSET, R_MMIX_BASE_PLUS_OFFSET},
829 {BFD_RELOC_MMIX_LOCAL, R_MMIX_LOCAL},
830 {BFD_RELOC_MMIX_PUSHJ_STUBBABLE, R_MMIX_PUSHJ_STUBBABLE}
833 static reloc_howto_type *
834 bfd_elf64_bfd_reloc_type_lookup (abfd, code)
835 bfd *abfd ATTRIBUTE_UNUSED;
836 bfd_reloc_code_real_type code;
841 i < sizeof (mmix_reloc_map) / sizeof (mmix_reloc_map[0]);
844 if (mmix_reloc_map[i].bfd_reloc_val == code)
845 return &elf_mmix_howto_table[mmix_reloc_map[i].elf_reloc_val];
852 mmix_elf_new_section_hook (abfd, sec)
856 if (!sec->used_by_bfd)
858 struct _mmix_elf_section_data *sdata;
859 bfd_size_type amt = sizeof (*sdata);
861 sdata = bfd_zalloc (abfd, amt);
864 sec->used_by_bfd = sdata;
867 return _bfd_elf_new_section_hook (abfd, sec);
871 /* This function performs the actual bitfiddling and sanity check for a
872 final relocation. Each relocation gets its *worst*-case expansion
873 in size when it arrives here; any reduction in size should have been
874 caught in linker relaxation earlier. When we get here, the relocation
875 looks like the smallest instruction with SWYM:s (nop:s) appended to the
876 max size. We fill in those nop:s.
878 R_MMIX_GETA: (FIXME: Relaxation should break this up in 1, 2, 3 tetra)
882 INCML $N,(foo >> 16) & 0xffff
883 INCMH $N,(foo >> 32) & 0xffff
884 INCH $N,(foo >> 48) & 0xffff
886 R_MMIX_CBRANCH: (FIXME: Relaxation should break this up, but
887 condbranches needing relaxation might be rare enough to not be
898 R_MMIX_PUSHJ: (FIXME: Relaxation...)
907 R_MMIX_JMP: (FIXME: Relaxation...)
916 R_MMIX_ADDR19 and R_MMIX_ADDR27 are just filled in. */
918 static bfd_reloc_status_type
919 mmix_elf_perform_relocation (isec, howto, datap, addr, value)
921 reloc_howto_type *howto;
926 bfd *abfd = isec->owner;
927 bfd_reloc_status_type flag = bfd_reloc_ok;
928 bfd_reloc_status_type r;
932 /* The worst case bits are all similar SETL/INCML/INCMH/INCH sequences.
933 We handle the differences here and the common sequence later. */
938 reg = bfd_get_8 (abfd, (bfd_byte *) datap + 1);
940 /* We change to an absolute value. */
946 int in1 = bfd_get_16 (abfd, (bfd_byte *) datap) << 16;
948 /* Invert the condition and prediction bit, and set the offset
949 to five instructions ahead.
951 We *can* do better if we want to. If the branch is found to be
952 within limits, we could leave the branch as is; there'll just
953 be a bunch of NOP:s after it. But we shouldn't see this
954 sequence often enough that it's worth doing it. */
957 (((in1 ^ ((PRED_INV_BIT | COND_INV_BIT) << 24)) & ~0xffff)
961 /* Put a "GO $255,$255,0" after the common sequence. */
963 ((GO_INSN_BYTE | IMM_OFFSET_BIT) << 24) | 0xffff00,
964 (bfd_byte *) datap + 20);
966 /* Common sequence starts at offset 4. */
969 /* We change to an absolute value. */
974 case R_MMIX_PUSHJ_STUBBABLE:
975 /* If the address fits, we're fine. */
977 /* Note rightshift 0; see R_MMIX_JMP case below. */
978 && (r = bfd_check_overflow (complain_overflow_signed,
981 bfd_arch_bits_per_address (abfd),
982 value)) == bfd_reloc_ok)
983 goto pcrel_mmix_reloc_fits;
986 bfd_size_type size = isec->rawsize ? isec->rawsize : isec->size;
988 /* We have the bytes at the PUSHJ insn and need to get the
989 position for the stub. There's supposed to be room allocated
991 bfd_byte *stubcontents
992 = ((bfd_byte *) datap
993 - (addr - (isec->output_section->vma + isec->output_offset))
995 + mmix_elf_section_data (isec)->pjs.stub_offset);
998 /* The address doesn't fit, so redirect the PUSHJ to the
999 location of the stub. */
1000 r = mmix_elf_perform_relocation (isec,
1001 &elf_mmix_howto_table
1005 isec->output_section->vma
1006 + isec->output_offset
1008 + (mmix_elf_section_data (isec)
1011 if (r != bfd_reloc_ok)
1015 = (isec->output_section->vma
1016 + isec->output_offset
1018 + mmix_elf_section_data (isec)->pjs.stub_offset);
1020 /* We generate a simple JMP if that suffices, else the whole 5
1022 if (bfd_check_overflow (complain_overflow_signed,
1023 elf_mmix_howto_table[R_MMIX_ADDR27].bitsize,
1025 bfd_arch_bits_per_address (abfd),
1026 addr + value - stubaddr) == bfd_reloc_ok)
1028 bfd_put_32 (abfd, JMP_INSN_BYTE << 24, stubcontents);
1029 r = mmix_elf_perform_relocation (isec,
1030 &elf_mmix_howto_table
1034 value + addr - stubaddr);
1035 mmix_elf_section_data (isec)->pjs.stub_offset += 4;
1037 if (size + mmix_elf_section_data (isec)->pjs.stub_offset
1045 /* Put a "GO $255,0" after the common sequence. */
1047 ((GO_INSN_BYTE | IMM_OFFSET_BIT) << 24)
1048 | 0xff00, (bfd_byte *) stubcontents + 16);
1050 /* Prepare for the general code to set the first part of the
1053 datap = stubcontents;
1054 mmix_elf_section_data (isec)->pjs.stub_offset
1055 += MAX_PUSHJ_STUB_SIZE;
1062 int inreg = bfd_get_8 (abfd, (bfd_byte *) datap + 1);
1064 /* Put a "PUSHGO $N,$255,0" after the common sequence. */
1066 ((PUSHGO_INSN_BYTE | IMM_OFFSET_BIT) << 24)
1069 (bfd_byte *) datap + 16);
1071 /* We change to an absolute value. */
1077 /* This one is a little special. If we get here on a non-relaxing
1078 link, and the destination is actually in range, we don't need to
1080 If so, we fall through to the bit-fiddling relocs.
1082 FIXME: bfd_check_overflow seems broken; the relocation is
1083 rightshifted before testing, so supply a zero rightshift. */
1085 if (! ((value & 3) == 0
1086 && (r = bfd_check_overflow (complain_overflow_signed,
1089 bfd_arch_bits_per_address (abfd),
1090 value)) == bfd_reloc_ok))
1092 /* If the relocation doesn't fit in a JMP, we let the NOP:s be
1093 modified below, and put a "GO $255,$255,0" after the
1094 address-loading sequence. */
1096 ((GO_INSN_BYTE | IMM_OFFSET_BIT) << 24)
1098 (bfd_byte *) datap + 16);
1100 /* We change to an absolute value. */
1107 pcrel_mmix_reloc_fits:
1108 /* These must be in range, or else we emit an error. */
1109 if ((value & 3) == 0
1110 /* Note rightshift 0; see above. */
1111 && (r = bfd_check_overflow (complain_overflow_signed,
1114 bfd_arch_bits_per_address (abfd),
1115 value)) == bfd_reloc_ok)
1118 = bfd_get_32 (abfd, (bfd_byte *) datap);
1121 if ((bfd_signed_vma) value < 0)
1124 value += (1 << (howto->bitsize - 1));
1132 (in1 & howto->src_mask)
1134 | (value & howto->dst_mask),
1135 (bfd_byte *) datap);
1137 return bfd_reloc_ok;
1140 return bfd_reloc_overflow;
1142 case R_MMIX_BASE_PLUS_OFFSET:
1144 struct bpo_reloc_section_info *bpodata
1145 = mmix_elf_section_data (isec)->bpo.reloc;
1146 asection *bpo_greg_section
1147 = bpodata->bpo_greg_section;
1148 struct bpo_greg_section_info *gregdata
1149 = mmix_elf_section_data (bpo_greg_section)->bpo.greg;
1151 = gregdata->bpo_reloc_indexes[bpodata->bpo_index++];
1153 /* A consistency check: The value we now have in "relocation" must
1154 be the same as the value we stored for that relocation. It
1155 doesn't cost much, so can be left in at all times. */
1156 if (value != gregdata->reloc_request[bpo_index].value)
1158 (*_bfd_error_handler)
1159 (_("%s: Internal inconsistency error for value for\n\
1160 linker-allocated global register: linked: 0x%lx%08lx != relaxed: 0x%lx%08lx\n"),
1161 bfd_get_filename (isec->owner),
1162 (unsigned long) (value >> 32), (unsigned long) value,
1163 (unsigned long) (gregdata->reloc_request[bpo_index].value
1165 (unsigned long) gregdata->reloc_request[bpo_index].value);
1166 bfd_set_error (bfd_error_bad_value);
1167 return bfd_reloc_overflow;
1170 /* Then store the register number and offset for that register
1171 into datap and datap + 1 respectively. */
1173 gregdata->reloc_request[bpo_index].regindex
1174 + bpo_greg_section->output_section->vma / 8,
1177 gregdata->reloc_request[bpo_index].offset,
1178 ((unsigned char *) datap) + 1);
1179 return bfd_reloc_ok;
1182 case R_MMIX_REG_OR_BYTE:
1185 return bfd_reloc_overflow;
1186 bfd_put_8 (abfd, value, datap);
1187 return bfd_reloc_ok;
1190 BAD_CASE (howto->type);
1193 /* This code adds the common SETL/INCML/INCMH/INCH worst-case
1196 /* Lowest two bits must be 0. We return bfd_reloc_overflow for
1197 everything that looks strange. */
1199 flag = bfd_reloc_overflow;
1202 (SETL_INSN_BYTE << 24) | (value & 0xffff) | (reg << 16),
1203 (bfd_byte *) datap + offs);
1205 (INCML_INSN_BYTE << 24) | ((value >> 16) & 0xffff) | (reg << 16),
1206 (bfd_byte *) datap + offs + 4);
1208 (INCMH_INSN_BYTE << 24) | ((value >> 32) & 0xffff) | (reg << 16),
1209 (bfd_byte *) datap + offs + 8);
1211 (INCH_INSN_BYTE << 24) | ((value >> 48) & 0xffff) | (reg << 16),
1212 (bfd_byte *) datap + offs + 12);
1217 /* Set the howto pointer for an MMIX ELF reloc (type RELA). */
1220 mmix_info_to_howto_rela (abfd, cache_ptr, dst)
1221 bfd *abfd ATTRIBUTE_UNUSED;
1223 Elf_Internal_Rela *dst;
1225 unsigned int r_type;
1227 r_type = ELF64_R_TYPE (dst->r_info);
1228 BFD_ASSERT (r_type < (unsigned int) R_MMIX_max);
1229 cache_ptr->howto = &elf_mmix_howto_table[r_type];
1232 /* Any MMIX-specific relocation gets here at assembly time or when linking
1233 to other formats (such as mmo); this is the relocation function from
1234 the reloc_table. We don't get here for final pure ELF linking. */
1236 static bfd_reloc_status_type
1237 mmix_elf_reloc (abfd, reloc_entry, symbol, data, input_section,
1238 output_bfd, error_message)
1240 arelent *reloc_entry;
1243 asection *input_section;
1245 char **error_message ATTRIBUTE_UNUSED;
1248 bfd_reloc_status_type r;
1249 asection *reloc_target_output_section;
1250 bfd_reloc_status_type flag = bfd_reloc_ok;
1251 bfd_vma output_base = 0;
1254 r = bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
1255 input_section, output_bfd, error_message);
1257 /* If that was all that was needed (i.e. this isn't a final link, only
1258 some segment adjustments), we're done. */
1259 if (r != bfd_reloc_continue)
1262 if (bfd_is_und_section (symbol->section)
1263 && (symbol->flags & BSF_WEAK) == 0
1264 && output_bfd == (bfd *) NULL)
1265 return bfd_reloc_undefined;
1267 /* Is the address of the relocation really within the section? */
1268 if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
1269 return bfd_reloc_outofrange;
1271 /* Work out which section the relocation is targeted at and the
1272 initial relocation command value. */
1274 /* Get symbol value. (Common symbols are special.) */
1275 if (bfd_is_com_section (symbol->section))
1278 relocation = symbol->value;
1280 reloc_target_output_section = bfd_get_output_section (symbol);
1282 /* Here the variable relocation holds the final address of the symbol we
1283 are relocating against, plus any addend. */
1287 output_base = reloc_target_output_section->vma;
1289 relocation += output_base + symbol->section->output_offset;
1291 /* Get position of relocation. */
1292 addr = (reloc_entry->address + input_section->output_section->vma
1293 + input_section->output_offset);
1294 if (output_bfd != (bfd *) NULL)
1296 /* Add in supplied addend. */
1297 relocation += reloc_entry->addend;
1299 /* This is a partial relocation, and we want to apply the
1300 relocation to the reloc entry rather than the raw data.
1301 Modify the reloc inplace to reflect what we now know. */
1302 reloc_entry->addend = relocation;
1303 reloc_entry->address += input_section->output_offset;
1307 return mmix_final_link_relocate (reloc_entry->howto, input_section,
1308 data, reloc_entry->address,
1309 reloc_entry->addend, relocation,
1310 bfd_asymbol_name (symbol),
1311 reloc_target_output_section);
1314 /* Relocate an MMIX ELF section. Modified from elf32-fr30.c; look to it
1315 for guidance if you're thinking of copying this. */
1318 mmix_elf_relocate_section (output_bfd, info, input_bfd, input_section,
1319 contents, relocs, local_syms, local_sections)
1320 bfd *output_bfd ATTRIBUTE_UNUSED;
1321 struct bfd_link_info *info;
1323 asection *input_section;
1325 Elf_Internal_Rela *relocs;
1326 Elf_Internal_Sym *local_syms;
1327 asection **local_sections;
1329 Elf_Internal_Shdr *symtab_hdr;
1330 struct elf_link_hash_entry **sym_hashes;
1331 Elf_Internal_Rela *rel;
1332 Elf_Internal_Rela *relend;
1336 size = input_section->rawsize ? input_section->rawsize : input_section->size;
1337 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
1338 sym_hashes = elf_sym_hashes (input_bfd);
1339 relend = relocs + input_section->reloc_count;
1341 /* Zero the stub area before we start. */
1342 if (input_section->rawsize != 0
1343 && input_section->size > input_section->rawsize)
1344 memset (contents + input_section->rawsize, 0,
1345 input_section->size - input_section->rawsize);
1347 for (rel = relocs; rel < relend; rel ++)
1349 reloc_howto_type *howto;
1350 unsigned long r_symndx;
1351 Elf_Internal_Sym *sym;
1353 struct elf_link_hash_entry *h;
1355 bfd_reloc_status_type r;
1356 const char *name = NULL;
1358 bfd_boolean undefined_signalled = FALSE;
1360 r_type = ELF64_R_TYPE (rel->r_info);
1362 if (r_type == R_MMIX_GNU_VTINHERIT
1363 || r_type == R_MMIX_GNU_VTENTRY)
1366 r_symndx = ELF64_R_SYM (rel->r_info);
1368 if (info->relocatable)
1370 /* This is a relocatable link. For most relocs we don't have to
1371 change anything, unless the reloc is against a section
1372 symbol, in which case we have to adjust according to where
1373 the section symbol winds up in the output section. */
1374 if (r_symndx < symtab_hdr->sh_info)
1376 sym = local_syms + r_symndx;
1378 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
1380 sec = local_sections [r_symndx];
1381 rel->r_addend += sec->output_offset + sym->st_value;
1385 /* For PUSHJ stub relocs however, we may need to change the
1386 reloc and the section contents, if the reloc doesn't reach
1387 beyond the end of the output section and previous stubs.
1388 Then we change the section contents to be a PUSHJ to the end
1389 of the input section plus stubs (we can do that without using
1390 a reloc), and then we change the reloc to be a R_MMIX_PUSHJ
1391 at the stub location. */
1392 if (r_type == R_MMIX_PUSHJ_STUBBABLE)
1394 /* We've already checked whether we need a stub; use that
1396 if (mmix_elf_section_data (input_section)->pjs.stub_size[pjsno]
1399 Elf_Internal_Rela relcpy;
1401 if (mmix_elf_section_data (input_section)
1402 ->pjs.stub_size[pjsno] != MAX_PUSHJ_STUB_SIZE)
1405 /* There's already a PUSHJ insn there, so just fill in
1406 the offset bits to the stub. */
1407 if (mmix_final_link_relocate (elf_mmix_howto_table
1414 ->output_section->vma
1415 + input_section->output_offset
1417 + mmix_elf_section_data (input_section)
1419 NULL, NULL) != bfd_reloc_ok)
1422 /* Put a JMP insn at the stub; it goes with the
1423 R_MMIX_JMP reloc. */
1424 bfd_put_32 (output_bfd, JMP_INSN_BYTE << 24,
1427 + mmix_elf_section_data (input_section)
1430 /* Change the reloc to be at the stub, and to a full
1431 R_MMIX_JMP reloc. */
1432 rel->r_info = ELF64_R_INFO (r_symndx, R_MMIX_JMP);
1435 + mmix_elf_section_data (input_section)
1438 mmix_elf_section_data (input_section)->pjs.stub_offset
1439 += MAX_PUSHJ_STUB_SIZE;
1441 /* Shift this reloc to the end of the relocs to maintain
1442 the r_offset sorted reloc order. */
1444 memmove (rel, rel + 1, (char *) relend - (char *) rel);
1445 relend[-1] = relcpy;
1447 /* Back up one reloc, or else we'd skip the next reloc
1457 /* This is a final link. */
1458 howto = elf_mmix_howto_table + ELF64_R_TYPE (rel->r_info);
1463 if (r_symndx < symtab_hdr->sh_info)
1465 sym = local_syms + r_symndx;
1466 sec = local_sections [r_symndx];
1467 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
1469 name = bfd_elf_string_from_elf_section (input_bfd,
1470 symtab_hdr->sh_link,
1473 name = bfd_section_name (input_bfd, sec);
1477 bfd_boolean unresolved_reloc;
1479 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
1480 r_symndx, symtab_hdr, sym_hashes,
1482 unresolved_reloc, undefined_signalled);
1483 name = h->root.root.string;
1486 r = mmix_final_link_relocate (howto, input_section,
1487 contents, rel->r_offset,
1488 rel->r_addend, relocation, name, sec);
1490 if (r != bfd_reloc_ok)
1492 bfd_boolean check_ok = TRUE;
1493 const char * msg = (const char *) NULL;
1497 case bfd_reloc_overflow:
1498 check_ok = info->callbacks->reloc_overflow
1499 (info, (h ? &h->root : NULL), name, howto->name,
1500 (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
1503 case bfd_reloc_undefined:
1504 /* We may have sent this message above. */
1505 if (! undefined_signalled)
1506 check_ok = info->callbacks->undefined_symbol
1507 (info, name, input_bfd, input_section, rel->r_offset,
1509 undefined_signalled = TRUE;
1512 case bfd_reloc_outofrange:
1513 msg = _("internal error: out of range error");
1516 case bfd_reloc_notsupported:
1517 msg = _("internal error: unsupported relocation error");
1520 case bfd_reloc_dangerous:
1521 msg = _("internal error: dangerous relocation");
1525 msg = _("internal error: unknown error");
1530 check_ok = info->callbacks->warning
1531 (info, msg, name, input_bfd, input_section, rel->r_offset);
1541 /* Perform a single relocation. By default we use the standard BFD
1542 routines. A few relocs we have to do ourselves. */
1544 static bfd_reloc_status_type
1545 mmix_final_link_relocate (howto, input_section, contents,
1546 r_offset, r_addend, relocation, symname, symsec)
1547 reloc_howto_type *howto;
1548 asection *input_section;
1551 bfd_signed_vma r_addend;
1553 const char *symname;
1556 bfd_reloc_status_type r = bfd_reloc_ok;
1558 = (input_section->output_section->vma
1559 + input_section->output_offset
1562 = (bfd_signed_vma) relocation + r_addend;
1564 switch (howto->type)
1566 /* All these are PC-relative. */
1567 case R_MMIX_PUSHJ_STUBBABLE:
1569 case R_MMIX_CBRANCH:
1574 contents += r_offset;
1576 srel -= (input_section->output_section->vma
1577 + input_section->output_offset
1580 r = mmix_elf_perform_relocation (input_section, howto, contents,
1584 case R_MMIX_BASE_PLUS_OFFSET:
1586 return bfd_reloc_undefined;
1588 /* Check that we're not relocating against a register symbol. */
1589 if (strcmp (bfd_get_section_name (symsec->owner, symsec),
1590 MMIX_REG_CONTENTS_SECTION_NAME) == 0
1591 || strcmp (bfd_get_section_name (symsec->owner, symsec),
1592 MMIX_REG_SECTION_NAME) == 0)
1594 /* Note: This is separated out into two messages in order
1595 to ease the translation into other languages. */
1596 if (symname == NULL || *symname == 0)
1597 (*_bfd_error_handler)
1598 (_("%s: base-plus-offset relocation against register symbol: (unknown) in %s"),
1599 bfd_get_filename (input_section->owner),
1600 bfd_get_section_name (symsec->owner, symsec));
1602 (*_bfd_error_handler)
1603 (_("%s: base-plus-offset relocation against register symbol: %s in %s"),
1604 bfd_get_filename (input_section->owner), symname,
1605 bfd_get_section_name (symsec->owner, symsec));
1606 return bfd_reloc_overflow;
1610 case R_MMIX_REG_OR_BYTE:
1612 /* For now, we handle these alike. They must refer to an register
1613 symbol, which is either relative to the register section and in
1614 the range 0..255, or is in the register contents section with vma
1617 /* FIXME: A better way to check for reg contents section?
1618 FIXME: Postpone section->scaling to mmix_elf_perform_relocation? */
1620 return bfd_reloc_undefined;
1622 if (strcmp (bfd_get_section_name (symsec->owner, symsec),
1623 MMIX_REG_CONTENTS_SECTION_NAME) == 0)
1625 if ((srel & 7) != 0 || srel < 32*8 || srel > 255*8)
1627 /* The bfd_reloc_outofrange return value, though intuitively
1628 a better value, will not get us an error. */
1629 return bfd_reloc_overflow;
1633 else if (strcmp (bfd_get_section_name (symsec->owner, symsec),
1634 MMIX_REG_SECTION_NAME) == 0)
1636 if (srel < 0 || srel > 255)
1637 /* The bfd_reloc_outofrange return value, though intuitively a
1638 better value, will not get us an error. */
1639 return bfd_reloc_overflow;
1643 /* Note: This is separated out into two messages in order
1644 to ease the translation into other languages. */
1645 if (symname == NULL || *symname == 0)
1646 (*_bfd_error_handler)
1647 (_("%s: register relocation against non-register symbol: (unknown) in %s"),
1648 bfd_get_filename (input_section->owner),
1649 bfd_get_section_name (symsec->owner, symsec));
1651 (*_bfd_error_handler)
1652 (_("%s: register relocation against non-register symbol: %s in %s"),
1653 bfd_get_filename (input_section->owner), symname,
1654 bfd_get_section_name (symsec->owner, symsec));
1656 /* The bfd_reloc_outofrange return value, though intuitively a
1657 better value, will not get us an error. */
1658 return bfd_reloc_overflow;
1661 contents += r_offset;
1662 r = mmix_elf_perform_relocation (input_section, howto, contents,
1667 /* This isn't a real relocation, it's just an assertion that the
1668 final relocation value corresponds to a local register. We
1669 ignore the actual relocation; nothing is changed. */
1672 = bfd_get_section_by_name (input_section->output_section->owner,
1673 MMIX_REG_CONTENTS_SECTION_NAME);
1674 bfd_vma first_global;
1676 /* Check that this is an absolute value, or a reference to the
1677 register contents section or the register (symbol) section.
1678 Absolute numbers can get here as undefined section. Undefined
1679 symbols are signalled elsewhere, so there's no conflict in us
1680 accidentally handling it. */
1681 if (!bfd_is_abs_section (symsec)
1682 && !bfd_is_und_section (symsec)
1683 && strcmp (bfd_get_section_name (symsec->owner, symsec),
1684 MMIX_REG_CONTENTS_SECTION_NAME) != 0
1685 && strcmp (bfd_get_section_name (symsec->owner, symsec),
1686 MMIX_REG_SECTION_NAME) != 0)
1688 (*_bfd_error_handler)
1689 (_("%s: directive LOCAL valid only with a register or absolute value"),
1690 bfd_get_filename (input_section->owner));
1692 return bfd_reloc_overflow;
1695 /* If we don't have a register contents section, then $255 is the
1696 first global register. */
1701 first_global = bfd_get_section_vma (abfd, regsec) / 8;
1702 if (strcmp (bfd_get_section_name (symsec->owner, symsec),
1703 MMIX_REG_CONTENTS_SECTION_NAME) == 0)
1705 if ((srel & 7) != 0 || srel < 32*8 || srel > 255*8)
1706 /* The bfd_reloc_outofrange return value, though
1707 intuitively a better value, will not get us an error. */
1708 return bfd_reloc_overflow;
1713 if ((bfd_vma) srel >= first_global)
1715 /* FIXME: Better error message. */
1716 (*_bfd_error_handler)
1717 (_("%s: LOCAL directive: Register $%ld is not a local register. First global register is $%ld."),
1718 bfd_get_filename (input_section->owner), (long) srel, (long) first_global);
1720 return bfd_reloc_overflow;
1727 r = _bfd_final_link_relocate (howto, input_section->owner, input_section,
1729 relocation, r_addend);
1735 /* Return the section that should be marked against GC for a given
1739 mmix_elf_gc_mark_hook (asection *sec,
1740 struct bfd_link_info *info,
1741 Elf_Internal_Rela *rel,
1742 struct elf_link_hash_entry *h,
1743 Elf_Internal_Sym *sym)
1746 switch (ELF64_R_TYPE (rel->r_info))
1748 case R_MMIX_GNU_VTINHERIT:
1749 case R_MMIX_GNU_VTENTRY:
1753 return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
1756 /* Update relocation info for a GC-excluded section. We could supposedly
1757 perform the allocation after GC, but there's no suitable hook between
1758 GC (or section merge) and the point when all input sections must be
1759 present. Better to waste some memory and (perhaps) a little time. */
1762 mmix_elf_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
1763 struct bfd_link_info *info ATTRIBUTE_UNUSED,
1765 const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
1767 struct bpo_reloc_section_info *bpodata
1768 = mmix_elf_section_data (sec)->bpo.reloc;
1769 asection *allocated_gregs_section;
1771 /* If no bpodata here, we have nothing to do. */
1772 if (bpodata == NULL)
1775 allocated_gregs_section = bpodata->bpo_greg_section;
1777 mmix_elf_section_data (allocated_gregs_section)->bpo.greg->n_bpo_relocs
1778 -= bpodata->n_bpo_relocs_this_section;
1783 /* Sort register relocs to come before expanding relocs. */
1786 mmix_elf_sort_relocs (p1, p2)
1790 const Elf_Internal_Rela *r1 = (const Elf_Internal_Rela *) p1;
1791 const Elf_Internal_Rela *r2 = (const Elf_Internal_Rela *) p2;
1792 int r1_is_reg, r2_is_reg;
1794 /* Sort primarily on r_offset & ~3, so relocs are done to consecutive
1796 if ((r1->r_offset & ~(bfd_vma) 3) > (r2->r_offset & ~(bfd_vma) 3))
1798 else if ((r1->r_offset & ~(bfd_vma) 3) < (r2->r_offset & ~(bfd_vma) 3))
1802 = (ELF64_R_TYPE (r1->r_info) == R_MMIX_REG_OR_BYTE
1803 || ELF64_R_TYPE (r1->r_info) == R_MMIX_REG);
1805 = (ELF64_R_TYPE (r2->r_info) == R_MMIX_REG_OR_BYTE
1806 || ELF64_R_TYPE (r2->r_info) == R_MMIX_REG);
1807 if (r1_is_reg != r2_is_reg)
1808 return r2_is_reg - r1_is_reg;
1810 /* Neither or both are register relocs. Then sort on full offset. */
1811 if (r1->r_offset > r2->r_offset)
1813 else if (r1->r_offset < r2->r_offset)
1818 /* Subset of mmix_elf_check_relocs, common to ELF and mmo linking. */
1821 mmix_elf_check_common_relocs (abfd, info, sec, relocs)
1823 struct bfd_link_info *info;
1825 const Elf_Internal_Rela *relocs;
1827 bfd *bpo_greg_owner = NULL;
1828 asection *allocated_gregs_section = NULL;
1829 struct bpo_greg_section_info *gregdata = NULL;
1830 struct bpo_reloc_section_info *bpodata = NULL;
1831 const Elf_Internal_Rela *rel;
1832 const Elf_Internal_Rela *rel_end;
1834 /* We currently have to abuse this COFF-specific member, since there's
1835 no target-machine-dedicated member. There's no alternative outside
1836 the bfd_link_info struct; we can't specialize a hash-table since
1837 they're different between ELF and mmo. */
1838 bpo_greg_owner = (bfd *) info->base_file;
1840 rel_end = relocs + sec->reloc_count;
1841 for (rel = relocs; rel < rel_end; rel++)
1843 switch (ELF64_R_TYPE (rel->r_info))
1845 /* This relocation causes a GREG allocation. We need to count
1846 them, and we need to create a section for them, so we need an
1847 object to fake as the owner of that section. We can't use
1848 the ELF dynobj for this, since the ELF bits assume lots of
1849 DSO-related stuff if that member is non-NULL. */
1850 case R_MMIX_BASE_PLUS_OFFSET:
1851 /* We don't do anything with this reloc for a relocatable link. */
1852 if (info->relocatable)
1855 if (bpo_greg_owner == NULL)
1857 bpo_greg_owner = abfd;
1858 info->base_file = (PTR) bpo_greg_owner;
1861 if (allocated_gregs_section == NULL)
1862 allocated_gregs_section
1863 = bfd_get_section_by_name (bpo_greg_owner,
1864 MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME);
1866 if (allocated_gregs_section == NULL)
1868 allocated_gregs_section
1869 = bfd_make_section_with_flags (bpo_greg_owner,
1870 MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME,
1873 | SEC_LINKER_CREATED));
1874 /* Setting both SEC_ALLOC and SEC_LOAD means the section is
1875 treated like any other section, and we'd get errors for
1876 address overlap with the text section. Let's set none of
1877 those flags, as that is what currently happens for usual
1878 GREG allocations, and that works. */
1879 if (allocated_gregs_section == NULL
1880 || !bfd_set_section_alignment (bpo_greg_owner,
1881 allocated_gregs_section,
1885 gregdata = (struct bpo_greg_section_info *)
1886 bfd_zalloc (bpo_greg_owner, sizeof (struct bpo_greg_section_info));
1887 if (gregdata == NULL)
1889 mmix_elf_section_data (allocated_gregs_section)->bpo.greg
1892 else if (gregdata == NULL)
1894 = mmix_elf_section_data (allocated_gregs_section)->bpo.greg;
1896 /* Get ourselves some auxiliary info for the BPO-relocs. */
1897 if (bpodata == NULL)
1899 /* No use doing a separate iteration pass to find the upper
1900 limit - just use the number of relocs. */
1901 bpodata = (struct bpo_reloc_section_info *)
1902 bfd_alloc (bpo_greg_owner,
1903 sizeof (struct bpo_reloc_section_info)
1904 * (sec->reloc_count + 1));
1905 if (bpodata == NULL)
1907 mmix_elf_section_data (sec)->bpo.reloc = bpodata;
1908 bpodata->first_base_plus_offset_reloc
1909 = bpodata->bpo_index
1910 = gregdata->n_max_bpo_relocs;
1911 bpodata->bpo_greg_section
1912 = allocated_gregs_section;
1913 bpodata->n_bpo_relocs_this_section = 0;
1916 bpodata->n_bpo_relocs_this_section++;
1917 gregdata->n_max_bpo_relocs++;
1919 /* We don't get another chance to set this before GC; we've not
1920 set up any hook that runs before GC. */
1921 gregdata->n_bpo_relocs
1922 = gregdata->n_max_bpo_relocs;
1925 case R_MMIX_PUSHJ_STUBBABLE:
1926 mmix_elf_section_data (sec)->pjs.n_pushj_relocs++;
1931 /* Allocate per-reloc stub storage and initialize it to the max stub
1933 if (mmix_elf_section_data (sec)->pjs.n_pushj_relocs != 0)
1937 mmix_elf_section_data (sec)->pjs.stub_size
1938 = bfd_alloc (abfd, mmix_elf_section_data (sec)->pjs.n_pushj_relocs
1939 * sizeof (mmix_elf_section_data (sec)
1940 ->pjs.stub_size[0]));
1941 if (mmix_elf_section_data (sec)->pjs.stub_size == NULL)
1944 for (i = 0; i < mmix_elf_section_data (sec)->pjs.n_pushj_relocs; i++)
1945 mmix_elf_section_data (sec)->pjs.stub_size[i] = MAX_PUSHJ_STUB_SIZE;
1951 /* Look through the relocs for a section during the first phase. */
1954 mmix_elf_check_relocs (abfd, info, sec, relocs)
1956 struct bfd_link_info *info;
1958 const Elf_Internal_Rela *relocs;
1960 Elf_Internal_Shdr *symtab_hdr;
1961 struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
1962 const Elf_Internal_Rela *rel;
1963 const Elf_Internal_Rela *rel_end;
1965 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
1966 sym_hashes = elf_sym_hashes (abfd);
1967 sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof(Elf64_External_Sym);
1968 if (!elf_bad_symtab (abfd))
1969 sym_hashes_end -= symtab_hdr->sh_info;
1971 /* First we sort the relocs so that any register relocs come before
1972 expansion-relocs to the same insn. FIXME: Not done for mmo. */
1973 qsort ((PTR) relocs, sec->reloc_count, sizeof (Elf_Internal_Rela),
1974 mmix_elf_sort_relocs);
1976 /* Do the common part. */
1977 if (!mmix_elf_check_common_relocs (abfd, info, sec, relocs))
1980 if (info->relocatable)
1983 rel_end = relocs + sec->reloc_count;
1984 for (rel = relocs; rel < rel_end; rel++)
1986 struct elf_link_hash_entry *h;
1987 unsigned long r_symndx;
1989 r_symndx = ELF64_R_SYM (rel->r_info);
1990 if (r_symndx < symtab_hdr->sh_info)
1994 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
1995 while (h->root.type == bfd_link_hash_indirect
1996 || h->root.type == bfd_link_hash_warning)
1997 h = (struct elf_link_hash_entry *) h->root.u.i.link;
2000 switch (ELF64_R_TYPE (rel->r_info))
2002 /* This relocation describes the C++ object vtable hierarchy.
2003 Reconstruct it for later use during GC. */
2004 case R_MMIX_GNU_VTINHERIT:
2005 if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
2009 /* This relocation describes which C++ vtable entries are actually
2010 used. Record for later use during GC. */
2011 case R_MMIX_GNU_VTENTRY:
2012 if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
2021 /* Wrapper for mmix_elf_check_common_relocs, called when linking to mmo.
2022 Copied from elf_link_add_object_symbols. */
2025 _bfd_mmix_check_all_relocs (abfd, info)
2027 struct bfd_link_info *info;
2031 for (o = abfd->sections; o != NULL; o = o->next)
2033 Elf_Internal_Rela *internal_relocs;
2036 if ((o->flags & SEC_RELOC) == 0
2037 || o->reloc_count == 0
2038 || ((info->strip == strip_all || info->strip == strip_debugger)
2039 && (o->flags & SEC_DEBUGGING) != 0)
2040 || bfd_is_abs_section (o->output_section))
2044 = _bfd_elf_link_read_relocs (abfd, o, (PTR) NULL,
2045 (Elf_Internal_Rela *) NULL,
2047 if (internal_relocs == NULL)
2050 ok = mmix_elf_check_common_relocs (abfd, info, o, internal_relocs);
2052 if (! info->keep_memory)
2053 free (internal_relocs);
2062 /* Change symbols relative to the reg contents section to instead be to
2063 the register section, and scale them down to correspond to the register
2067 mmix_elf_link_output_symbol_hook (info, name, sym, input_sec, h)
2068 struct bfd_link_info *info ATTRIBUTE_UNUSED;
2069 const char *name ATTRIBUTE_UNUSED;
2070 Elf_Internal_Sym *sym;
2071 asection *input_sec;
2072 struct elf_link_hash_entry *h ATTRIBUTE_UNUSED;
2074 if (input_sec != NULL
2075 && input_sec->name != NULL
2076 && ELF_ST_TYPE (sym->st_info) != STT_SECTION
2077 && strcmp (input_sec->name, MMIX_REG_CONTENTS_SECTION_NAME) == 0)
2080 sym->st_shndx = SHN_REGISTER;
2086 /* We fake a register section that holds values that are register numbers.
2087 Having a SHN_REGISTER and register section translates better to other
2088 formats (e.g. mmo) than for example a STT_REGISTER attribute.
2089 This section faking is based on a construct in elf32-mips.c. */
2090 static asection mmix_elf_reg_section;
2091 static asymbol mmix_elf_reg_section_symbol;
2092 static asymbol *mmix_elf_reg_section_symbol_ptr;
2094 /* Handle the special section numbers that a symbol may use. */
2097 mmix_elf_symbol_processing (abfd, asym)
2098 bfd *abfd ATTRIBUTE_UNUSED;
2101 elf_symbol_type *elfsym;
2103 elfsym = (elf_symbol_type *) asym;
2104 switch (elfsym->internal_elf_sym.st_shndx)
2107 if (mmix_elf_reg_section.name == NULL)
2109 /* Initialize the register section. */
2110 mmix_elf_reg_section.name = MMIX_REG_SECTION_NAME;
2111 mmix_elf_reg_section.flags = SEC_NO_FLAGS;
2112 mmix_elf_reg_section.output_section = &mmix_elf_reg_section;
2113 mmix_elf_reg_section.symbol = &mmix_elf_reg_section_symbol;
2114 mmix_elf_reg_section.symbol_ptr_ptr = &mmix_elf_reg_section_symbol_ptr;
2115 mmix_elf_reg_section_symbol.name = MMIX_REG_SECTION_NAME;
2116 mmix_elf_reg_section_symbol.flags = BSF_SECTION_SYM;
2117 mmix_elf_reg_section_symbol.section = &mmix_elf_reg_section;
2118 mmix_elf_reg_section_symbol_ptr = &mmix_elf_reg_section_symbol;
2120 asym->section = &mmix_elf_reg_section;
2128 /* Given a BFD section, try to locate the corresponding ELF section
2132 mmix_elf_section_from_bfd_section (abfd, sec, retval)
2133 bfd * abfd ATTRIBUTE_UNUSED;
2137 if (strcmp (bfd_get_section_name (abfd, sec), MMIX_REG_SECTION_NAME) == 0)
2138 *retval = SHN_REGISTER;
2145 /* Hook called by the linker routine which adds symbols from an object
2146 file. We must handle the special SHN_REGISTER section number here.
2148 We also check that we only have *one* each of the section-start
2149 symbols, since otherwise having two with the same value would cause
2150 them to be "merged", but with the contents serialized. */
2153 mmix_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
2155 struct bfd_link_info *info ATTRIBUTE_UNUSED;
2156 Elf_Internal_Sym *sym;
2157 const char **namep ATTRIBUTE_UNUSED;
2158 flagword *flagsp ATTRIBUTE_UNUSED;
2160 bfd_vma *valp ATTRIBUTE_UNUSED;
2162 if (sym->st_shndx == SHN_REGISTER)
2164 *secp = bfd_make_section_old_way (abfd, MMIX_REG_SECTION_NAME);
2165 (*secp)->flags |= SEC_LINKER_CREATED;
2167 else if ((*namep)[0] == '_' && (*namep)[1] == '_' && (*namep)[2] == '.'
2168 && CONST_STRNEQ (*namep, MMIX_LOC_SECTION_START_SYMBOL_PREFIX))
2170 /* See if we have another one. */
2171 struct bfd_link_hash_entry *h = bfd_link_hash_lookup (info->hash,
2177 if (h != NULL && h->type != bfd_link_hash_undefined)
2179 /* How do we get the asymbol (or really: the filename) from h?
2180 h->u.def.section->owner is NULL. */
2181 ((*_bfd_error_handler)
2182 (_("%s: Error: multiple definition of `%s'; start of %s is set in a earlier linked file\n"),
2183 bfd_get_filename (abfd), *namep,
2184 *namep + strlen (MMIX_LOC_SECTION_START_SYMBOL_PREFIX)));
2185 bfd_set_error (bfd_error_bad_value);
2193 /* We consider symbols matching "L.*:[0-9]+" to be local symbols. */
2196 mmix_elf_is_local_label_name (abfd, name)
2203 /* Also include the default local-label definition. */
2204 if (_bfd_elf_is_local_label_name (abfd, name))
2210 /* If there's no ":", or more than one, it's not a local symbol. */
2211 colpos = strchr (name, ':');
2212 if (colpos == NULL || strchr (colpos + 1, ':') != NULL)
2215 /* Check that there are remaining characters and that they are digits. */
2219 digits = strspn (colpos + 1, "0123456789");
2220 return digits != 0 && colpos[1 + digits] == 0;
2223 /* We get rid of the register section here. */
2226 mmix_elf_final_link (abfd, info)
2228 struct bfd_link_info *info;
2230 /* We never output a register section, though we create one for
2231 temporary measures. Check that nobody entered contents into it. */
2232 asection *reg_section;
2234 reg_section = bfd_get_section_by_name (abfd, MMIX_REG_SECTION_NAME);
2236 if (reg_section != NULL)
2238 /* FIXME: Pass error state gracefully. */
2239 if (bfd_get_section_flags (abfd, reg_section) & SEC_HAS_CONTENTS)
2240 _bfd_abort (__FILE__, __LINE__, _("Register section has contents\n"));
2242 /* Really remove the section, if it hasn't already been done. */
2243 if (!bfd_section_removed_from_list (abfd, reg_section))
2245 bfd_section_list_remove (abfd, reg_section);
2246 --abfd->section_count;
2250 if (! bfd_elf_final_link (abfd, info))
2253 /* Since this section is marked SEC_LINKER_CREATED, it isn't output by
2254 the regular linker machinery. We do it here, like other targets with
2255 special sections. */
2256 if (info->base_file != NULL)
2258 asection *greg_section
2259 = bfd_get_section_by_name ((bfd *) info->base_file,
2260 MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME);
2261 if (!bfd_set_section_contents (abfd,
2262 greg_section->output_section,
2263 greg_section->contents,
2264 (file_ptr) greg_section->output_offset,
2265 greg_section->size))
2271 /* We need to include the maximum size of PUSHJ-stubs in the initial
2272 section size. This is expected to shrink during linker relaxation. */
2275 mmix_set_relaxable_size (abfd, sec, ptr)
2276 bfd *abfd ATTRIBUTE_UNUSED;
2280 struct bfd_link_info *info = ptr;
2282 /* Make sure we only do this for section where we know we want this,
2283 otherwise we might end up resetting the size of COMMONs. */
2284 if (mmix_elf_section_data (sec)->pjs.n_pushj_relocs == 0)
2287 sec->rawsize = sec->size;
2288 sec->size += (mmix_elf_section_data (sec)->pjs.n_pushj_relocs
2289 * MAX_PUSHJ_STUB_SIZE);
2291 /* For use in relocatable link, we start with a max stubs size. See
2292 mmix_elf_relax_section. */
2293 if (info->relocatable && sec->output_section)
2294 mmix_elf_section_data (sec->output_section)->pjs.stubs_size_sum
2295 += (mmix_elf_section_data (sec)->pjs.n_pushj_relocs
2296 * MAX_PUSHJ_STUB_SIZE);
2299 /* Initialize stuff for the linker-generated GREGs to match
2300 R_MMIX_BASE_PLUS_OFFSET relocs seen by the linker. */
2303 _bfd_mmix_before_linker_allocation (abfd, info)
2304 bfd *abfd ATTRIBUTE_UNUSED;
2305 struct bfd_link_info *info;
2307 asection *bpo_gregs_section;
2308 bfd *bpo_greg_owner;
2309 struct bpo_greg_section_info *gregdata;
2313 size_t *bpo_reloc_indexes;
2316 /* Set the initial size of sections. */
2317 for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
2318 bfd_map_over_sections (ibfd, mmix_set_relaxable_size, info);
2320 /* The bpo_greg_owner bfd is supposed to have been set by
2321 mmix_elf_check_relocs when the first R_MMIX_BASE_PLUS_OFFSET is seen.
2322 If there is no such object, there was no R_MMIX_BASE_PLUS_OFFSET. */
2323 bpo_greg_owner = (bfd *) info->base_file;
2324 if (bpo_greg_owner == NULL)
2328 = bfd_get_section_by_name (bpo_greg_owner,
2329 MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME);
2331 if (bpo_gregs_section == NULL)
2334 /* We use the target-data handle in the ELF section data. */
2335 gregdata = mmix_elf_section_data (bpo_gregs_section)->bpo.greg;
2336 if (gregdata == NULL)
2339 n_gregs = gregdata->n_bpo_relocs;
2340 gregdata->n_allocated_bpo_gregs = n_gregs;
2342 /* When this reaches zero during relaxation, all entries have been
2343 filled in and the size of the linker gregs can be calculated. */
2344 gregdata->n_remaining_bpo_relocs_this_relaxation_round = n_gregs;
2346 /* Set the zeroth-order estimate for the GREGs size. */
2347 gregs_size = n_gregs * 8;
2349 if (!bfd_set_section_size (bpo_greg_owner, bpo_gregs_section, gregs_size))
2352 /* Allocate and set up the GREG arrays. They're filled in at relaxation
2353 time. Note that we must use the max number ever noted for the array,
2354 since the index numbers were created before GC. */
2355 gregdata->reloc_request
2356 = bfd_zalloc (bpo_greg_owner,
2357 sizeof (struct bpo_reloc_request)
2358 * gregdata->n_max_bpo_relocs);
2360 gregdata->bpo_reloc_indexes
2362 = bfd_alloc (bpo_greg_owner,
2363 gregdata->n_max_bpo_relocs
2365 if (bpo_reloc_indexes == NULL)
2368 /* The default order is an identity mapping. */
2369 for (i = 0; i < gregdata->n_max_bpo_relocs; i++)
2371 bpo_reloc_indexes[i] = i;
2372 gregdata->reloc_request[i].bpo_reloc_no = i;
2378 /* Fill in contents in the linker allocated gregs. Everything is
2379 calculated at this point; we just move the contents into place here. */
2382 _bfd_mmix_after_linker_allocation (abfd, link_info)
2383 bfd *abfd ATTRIBUTE_UNUSED;
2384 struct bfd_link_info *link_info;
2386 asection *bpo_gregs_section;
2387 bfd *bpo_greg_owner;
2388 struct bpo_greg_section_info *gregdata;
2394 /* The bpo_greg_owner bfd is supposed to have been set by mmix_elf_check_relocs
2395 when the first R_MMIX_BASE_PLUS_OFFSET is seen. If there is no such
2396 object, there was no R_MMIX_BASE_PLUS_OFFSET. */
2397 bpo_greg_owner = (bfd *) link_info->base_file;
2398 if (bpo_greg_owner == NULL)
2402 = bfd_get_section_by_name (bpo_greg_owner,
2403 MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME);
2405 /* This can't happen without DSO handling. When DSOs are handled
2406 without any R_MMIX_BASE_PLUS_OFFSET seen, there will be no such
2408 if (bpo_gregs_section == NULL)
2411 /* We use the target-data handle in the ELF section data. */
2413 gregdata = mmix_elf_section_data (bpo_gregs_section)->bpo.greg;
2414 if (gregdata == NULL)
2417 n_gregs = gregdata->n_allocated_bpo_gregs;
2419 bpo_gregs_section->contents
2420 = contents = bfd_alloc (bpo_greg_owner, bpo_gregs_section->size);
2421 if (contents == NULL)
2424 /* Sanity check: If these numbers mismatch, some relocation has not been
2425 accounted for and the rest of gregdata is probably inconsistent.
2426 It's a bug, but it's more helpful to identify it than segfaulting
2428 if (gregdata->n_remaining_bpo_relocs_this_relaxation_round
2429 != gregdata->n_bpo_relocs)
2431 (*_bfd_error_handler)
2432 (_("Internal inconsistency: remaining %u != max %u.\n\
2433 Please report this bug."),
2434 gregdata->n_remaining_bpo_relocs_this_relaxation_round,
2435 gregdata->n_bpo_relocs);
2439 for (lastreg = 255, i = 0, j = 0; j < n_gregs; i++)
2440 if (gregdata->reloc_request[i].regindex != lastreg)
2442 bfd_put_64 (bpo_greg_owner, gregdata->reloc_request[i].value,
2444 lastreg = gregdata->reloc_request[i].regindex;
2451 /* Sort valid relocs to come before non-valid relocs, then on increasing
2455 bpo_reloc_request_sort_fn (p1, p2)
2459 const struct bpo_reloc_request *r1 = (const struct bpo_reloc_request *) p1;
2460 const struct bpo_reloc_request *r2 = (const struct bpo_reloc_request *) p2;
2462 /* Primary function is validity; non-valid relocs sorted after valid
2464 if (r1->valid != r2->valid)
2465 return r2->valid - r1->valid;
2467 /* Then sort on value. Don't simplify and return just the difference of
2468 the values: the upper bits of the 64-bit value would be truncated on
2469 a host with 32-bit ints. */
2470 if (r1->value != r2->value)
2471 return r1->value > r2->value ? 1 : -1;
2473 /* As a last re-sort, use the relocation number, so we get a stable
2474 sort. The *addresses* aren't stable since items are swapped during
2475 sorting. It depends on the qsort implementation if this actually
2477 return r1->bpo_reloc_no > r2->bpo_reloc_no
2478 ? 1 : (r1->bpo_reloc_no < r2->bpo_reloc_no ? -1 : 0);
2481 /* For debug use only. Dumps the global register allocations resulting
2482 from base-plus-offset relocs. */
2485 mmix_dump_bpo_gregs (link_info, pf)
2486 struct bfd_link_info *link_info;
2487 bfd_error_handler_type pf;
2489 bfd *bpo_greg_owner;
2490 asection *bpo_gregs_section;
2491 struct bpo_greg_section_info *gregdata;
2494 if (link_info == NULL || link_info->base_file == NULL)
2497 bpo_greg_owner = (bfd *) link_info->base_file;
2500 = bfd_get_section_by_name (bpo_greg_owner,
2501 MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME);
2503 if (bpo_gregs_section == NULL)
2506 gregdata = mmix_elf_section_data (bpo_gregs_section)->bpo.greg;
2507 if (gregdata == NULL)
2511 pf = _bfd_error_handler;
2513 /* These format strings are not translated. They are for debug purposes
2514 only and never displayed to an end user. Should they escape, we
2515 surely want them in original. */
2516 (*pf) (" n_bpo_relocs: %u\n n_max_bpo_relocs: %u\n n_remain...round: %u\n\
2517 n_allocated_bpo_gregs: %u\n", gregdata->n_bpo_relocs,
2518 gregdata->n_max_bpo_relocs,
2519 gregdata->n_remaining_bpo_relocs_this_relaxation_round,
2520 gregdata->n_allocated_bpo_gregs);
2522 if (gregdata->reloc_request)
2523 for (i = 0; i < gregdata->n_max_bpo_relocs; i++)
2524 (*pf) ("%4u (%4u)/%4u#%u: 0x%08lx%08lx r: %3u o: %3u\n",
2526 (gregdata->bpo_reloc_indexes != NULL
2527 ? gregdata->bpo_reloc_indexes[i] : (size_t) -1),
2528 gregdata->reloc_request[i].bpo_reloc_no,
2529 gregdata->reloc_request[i].valid,
2531 (unsigned long) (gregdata->reloc_request[i].value >> 32),
2532 (unsigned long) gregdata->reloc_request[i].value,
2533 gregdata->reloc_request[i].regindex,
2534 gregdata->reloc_request[i].offset);
2537 /* This links all R_MMIX_BASE_PLUS_OFFSET relocs into a special array, and
2538 when the last such reloc is done, an index-array is sorted according to
2539 the values and iterated over to produce register numbers (indexed by 0
2540 from the first allocated register number) and offsets for use in real
2543 PUSHJ stub accounting is also done here.
2545 Symbol- and reloc-reading infrastructure copied from elf-m10200.c. */
2548 mmix_elf_relax_section (abfd, sec, link_info, again)
2551 struct bfd_link_info *link_info;
2554 Elf_Internal_Shdr *symtab_hdr;
2555 Elf_Internal_Rela *internal_relocs;
2556 Elf_Internal_Rela *irel, *irelend;
2557 asection *bpo_gregs_section = NULL;
2558 struct bpo_greg_section_info *gregdata;
2559 struct bpo_reloc_section_info *bpodata
2560 = mmix_elf_section_data (sec)->bpo.reloc;
2561 /* The initialization is to quiet compiler warnings. The value is to
2562 spot a missing actual initialization. */
2563 size_t bpono = (size_t) -1;
2565 bfd *bpo_greg_owner;
2566 Elf_Internal_Sym *isymbuf = NULL;
2567 bfd_size_type size = sec->rawsize ? sec->rawsize : sec->size;
2569 mmix_elf_section_data (sec)->pjs.stubs_size_sum = 0;
2571 /* Assume nothing changes. */
2574 /* We don't have to do anything if this section does not have relocs, or
2575 if this is not a code section. */
2576 if ((sec->flags & SEC_RELOC) == 0
2577 || sec->reloc_count == 0
2578 || (sec->flags & SEC_CODE) == 0
2579 || (sec->flags & SEC_LINKER_CREATED) != 0
2580 /* If no R_MMIX_BASE_PLUS_OFFSET relocs and no PUSHJ-stub relocs,
2581 then nothing to do. */
2583 && mmix_elf_section_data (sec)->pjs.n_pushj_relocs == 0))
2586 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
2588 bpo_greg_owner = (bfd *) link_info->base_file;
2590 if (bpodata != NULL)
2592 bpo_gregs_section = bpodata->bpo_greg_section;
2593 gregdata = mmix_elf_section_data (bpo_gregs_section)->bpo.greg;
2594 bpono = bpodata->first_base_plus_offset_reloc;
2599 /* Get a copy of the native relocations. */
2601 = _bfd_elf_link_read_relocs (abfd, sec, (PTR) NULL,
2602 (Elf_Internal_Rela *) NULL,
2603 link_info->keep_memory);
2604 if (internal_relocs == NULL)
2607 /* Walk through them looking for relaxing opportunities. */
2608 irelend = internal_relocs + sec->reloc_count;
2609 for (irel = internal_relocs; irel < irelend; irel++)
2612 struct elf_link_hash_entry *h = NULL;
2614 /* We only process two relocs. */
2615 if (ELF64_R_TYPE (irel->r_info) != (int) R_MMIX_BASE_PLUS_OFFSET
2616 && ELF64_R_TYPE (irel->r_info) != (int) R_MMIX_PUSHJ_STUBBABLE)
2619 /* We process relocs in a distinctly different way when this is a
2620 relocatable link (for one, we don't look at symbols), so we avoid
2621 mixing its code with that for the "normal" relaxation. */
2622 if (link_info->relocatable)
2624 /* The only transformation in a relocatable link is to generate
2625 a full stub at the location of the stub calculated for the
2626 input section, if the relocated stub location, the end of the
2627 output section plus earlier stubs, cannot be reached. Thus
2628 relocatable linking can only lead to worse code, but it still
2630 if (ELF64_R_TYPE (irel->r_info) == R_MMIX_PUSHJ_STUBBABLE)
2632 /* If we can reach the end of the output-section and beyond
2633 any current stubs, then we don't need a stub for this
2634 reloc. The relaxed order of output stub allocation may
2635 not exactly match the straightforward order, so we always
2636 assume presence of output stubs, which will allow
2637 relaxation only on relocations indifferent to the
2638 presence of output stub allocations for other relocations
2639 and thus the order of output stub allocation. */
2640 if (bfd_check_overflow (complain_overflow_signed,
2643 bfd_arch_bits_per_address (abfd),
2644 /* Output-stub location. */
2645 sec->output_section->rawsize
2646 + (mmix_elf_section_data (sec
2648 ->pjs.stubs_size_sum)
2649 /* Location of this PUSHJ reloc. */
2650 - (sec->output_offset + irel->r_offset)
2651 /* Don't count *this* stub twice. */
2652 - (mmix_elf_section_data (sec)
2653 ->pjs.stub_size[pjsno]
2654 + MAX_PUSHJ_STUB_SIZE))
2656 mmix_elf_section_data (sec)->pjs.stub_size[pjsno] = 0;
2658 mmix_elf_section_data (sec)->pjs.stubs_size_sum
2659 += mmix_elf_section_data (sec)->pjs.stub_size[pjsno];
2667 /* Get the value of the symbol referred to by the reloc. */
2668 if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
2670 /* A local symbol. */
2671 Elf_Internal_Sym *isym;
2674 /* Read this BFD's local symbols if we haven't already. */
2675 if (isymbuf == NULL)
2677 isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
2678 if (isymbuf == NULL)
2679 isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
2680 symtab_hdr->sh_info, 0,
2686 isym = isymbuf + ELF64_R_SYM (irel->r_info);
2687 if (isym->st_shndx == SHN_UNDEF)
2688 sym_sec = bfd_und_section_ptr;
2689 else if (isym->st_shndx == SHN_ABS)
2690 sym_sec = bfd_abs_section_ptr;
2691 else if (isym->st_shndx == SHN_COMMON)
2692 sym_sec = bfd_com_section_ptr;
2694 sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
2695 symval = (isym->st_value
2696 + sym_sec->output_section->vma
2697 + sym_sec->output_offset);
2703 /* An external symbol. */
2704 indx = ELF64_R_SYM (irel->r_info) - symtab_hdr->sh_info;
2705 h = elf_sym_hashes (abfd)[indx];
2706 BFD_ASSERT (h != NULL);
2707 if (h->root.type != bfd_link_hash_defined
2708 && h->root.type != bfd_link_hash_defweak)
2710 /* This appears to be a reference to an undefined symbol. Just
2711 ignore it--it will be caught by the regular reloc processing.
2712 We need to keep BPO reloc accounting consistent, though
2713 else we'll abort instead of emitting an error message. */
2714 if (ELF64_R_TYPE (irel->r_info) == R_MMIX_BASE_PLUS_OFFSET
2715 && gregdata != NULL)
2717 gregdata->n_remaining_bpo_relocs_this_relaxation_round--;
2723 symval = (h->root.u.def.value
2724 + h->root.u.def.section->output_section->vma
2725 + h->root.u.def.section->output_offset);
2728 if (ELF64_R_TYPE (irel->r_info) == (int) R_MMIX_PUSHJ_STUBBABLE)
2730 bfd_vma value = symval + irel->r_addend;
2732 = (sec->output_section->vma
2733 + sec->output_offset
2736 = (sec->output_section->vma
2737 + sec->output_offset
2739 + mmix_elf_section_data (sec)->pjs.stubs_size_sum);
2741 if ((value & 3) == 0
2742 && bfd_check_overflow (complain_overflow_signed,
2745 bfd_arch_bits_per_address (abfd),
2748 ? mmix_elf_section_data (sec)
2749 ->pjs.stub_size[pjsno]
2752 /* If the reloc fits, no stub is needed. */
2753 mmix_elf_section_data (sec)->pjs.stub_size[pjsno] = 0;
2755 /* Maybe we can get away with just a JMP insn? */
2756 if ((value & 3) == 0
2757 && bfd_check_overflow (complain_overflow_signed,
2760 bfd_arch_bits_per_address (abfd),
2763 ? mmix_elf_section_data (sec)
2764 ->pjs.stub_size[pjsno] - 4
2767 /* Yep, account for a stub consisting of a single JMP insn. */
2768 mmix_elf_section_data (sec)->pjs.stub_size[pjsno] = 4;
2770 /* Nope, go for the full insn stub. It doesn't seem useful to
2771 emit the intermediate sizes; those will only be useful for
2772 a >64M program assuming contiguous code. */
2773 mmix_elf_section_data (sec)->pjs.stub_size[pjsno]
2774 = MAX_PUSHJ_STUB_SIZE;
2776 mmix_elf_section_data (sec)->pjs.stubs_size_sum
2777 += mmix_elf_section_data (sec)->pjs.stub_size[pjsno];
2782 /* We're looking at a R_MMIX_BASE_PLUS_OFFSET reloc. */
2784 gregdata->reloc_request[gregdata->bpo_reloc_indexes[bpono]].value
2785 = symval + irel->r_addend;
2786 gregdata->reloc_request[gregdata->bpo_reloc_indexes[bpono++]].valid = TRUE;
2787 gregdata->n_remaining_bpo_relocs_this_relaxation_round--;
2790 /* Check if that was the last BPO-reloc. If so, sort the values and
2791 calculate how many registers we need to cover them. Set the size of
2792 the linker gregs, and if the number of registers changed, indicate
2793 that we need to relax some more because we have more work to do. */
2794 if (gregdata != NULL
2795 && gregdata->n_remaining_bpo_relocs_this_relaxation_round == 0)
2801 /* First, reset the remaining relocs for the next round. */
2802 gregdata->n_remaining_bpo_relocs_this_relaxation_round
2803 = gregdata->n_bpo_relocs;
2805 qsort ((PTR) gregdata->reloc_request,
2806 gregdata->n_max_bpo_relocs,
2807 sizeof (struct bpo_reloc_request),
2808 bpo_reloc_request_sort_fn);
2810 /* Recalculate indexes. When we find a change (however unlikely
2811 after the initial iteration), we know we need to relax again,
2812 since items in the GREG-array are sorted by increasing value and
2813 stored in the relaxation phase. */
2814 for (i = 0; i < gregdata->n_max_bpo_relocs; i++)
2815 if (gregdata->bpo_reloc_indexes[gregdata->reloc_request[i].bpo_reloc_no]
2818 gregdata->bpo_reloc_indexes[gregdata->reloc_request[i].bpo_reloc_no]
2823 /* Allocate register numbers (indexing from 0). Stop at the first
2825 for (i = 0, regindex = 0, prev_base = gregdata->reloc_request[0].value;
2826 i < gregdata->n_bpo_relocs;
2829 if (gregdata->reloc_request[i].value > prev_base + 255)
2832 prev_base = gregdata->reloc_request[i].value;
2834 gregdata->reloc_request[i].regindex = regindex;
2835 gregdata->reloc_request[i].offset
2836 = gregdata->reloc_request[i].value - prev_base;
2839 /* If it's not the same as the last time, we need to relax again,
2840 because the size of the section has changed. I'm not sure we
2841 actually need to do any adjustments since the shrinking happens
2842 at the start of this section, but better safe than sorry. */
2843 if (gregdata->n_allocated_bpo_gregs != regindex + 1)
2845 gregdata->n_allocated_bpo_gregs = regindex + 1;
2849 bpo_gregs_section->size = (regindex + 1) * 8;
2852 if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents)
2854 if (! link_info->keep_memory)
2858 /* Cache the symbols for elf_link_input_bfd. */
2859 symtab_hdr->contents = (unsigned char *) isymbuf;
2863 if (internal_relocs != NULL
2864 && elf_section_data (sec)->relocs != internal_relocs)
2865 free (internal_relocs);
2867 if (sec->size < size + mmix_elf_section_data (sec)->pjs.stubs_size_sum)
2870 if (sec->size > size + mmix_elf_section_data (sec)->pjs.stubs_size_sum)
2872 sec->size = size + mmix_elf_section_data (sec)->pjs.stubs_size_sum;
2879 if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents)
2881 if (internal_relocs != NULL
2882 && elf_section_data (sec)->relocs != internal_relocs)
2883 free (internal_relocs);
2887 #define ELF_ARCH bfd_arch_mmix
2888 #define ELF_MACHINE_CODE EM_MMIX
2890 /* According to mmix-doc page 36 (paragraph 45), this should be (1LL << 48LL).
2891 However, that's too much for something somewhere in the linker part of
2892 BFD; perhaps the start-address has to be a non-zero multiple of this
2893 number, or larger than this number. The symptom is that the linker
2894 complains: "warning: allocated section `.text' not in segment". We
2895 settle for 64k; the page-size used in examples is 8k.
2896 #define ELF_MAXPAGESIZE 0x10000
2898 Unfortunately, this causes excessive padding in the supposedly small
2899 for-education programs that are the expected usage (where people would
2900 inspect output). We stick to 256 bytes just to have *some* default
2902 #define ELF_MAXPAGESIZE 0x100
2904 #define TARGET_BIG_SYM bfd_elf64_mmix_vec
2905 #define TARGET_BIG_NAME "elf64-mmix"
2907 #define elf_info_to_howto_rel NULL
2908 #define elf_info_to_howto mmix_info_to_howto_rela
2909 #define elf_backend_relocate_section mmix_elf_relocate_section
2910 #define elf_backend_gc_mark_hook mmix_elf_gc_mark_hook
2911 #define elf_backend_gc_sweep_hook mmix_elf_gc_sweep_hook
2913 #define elf_backend_link_output_symbol_hook \
2914 mmix_elf_link_output_symbol_hook
2915 #define elf_backend_add_symbol_hook mmix_elf_add_symbol_hook
2917 #define elf_backend_check_relocs mmix_elf_check_relocs
2918 #define elf_backend_symbol_processing mmix_elf_symbol_processing
2919 #define elf_backend_omit_section_dynsym \
2920 ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
2922 #define bfd_elf64_bfd_is_local_label_name \
2923 mmix_elf_is_local_label_name
2925 #define elf_backend_may_use_rel_p 0
2926 #define elf_backend_may_use_rela_p 1
2927 #define elf_backend_default_use_rela_p 1
2929 #define elf_backend_can_gc_sections 1
2930 #define elf_backend_section_from_bfd_section \
2931 mmix_elf_section_from_bfd_section
2933 #define bfd_elf64_new_section_hook mmix_elf_new_section_hook
2934 #define bfd_elf64_bfd_final_link mmix_elf_final_link
2935 #define bfd_elf64_bfd_relax_section mmix_elf_relax_section
2937 #include "elf64-target.h"