1 /* MMIX-specific support for 64-bit ELF.
2 Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011,
4 Free Software Foundation, Inc.
5 Contributed by Hans-Peter Nilsson <hp@bitrange.com>
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
25 /* No specific ABI or "processor-specific supplement" defined. */
28 - "Traditional" linker relaxation (shrinking whole sections).
29 - Merge reloc stubs jumping to same location.
30 - GETA stub relaxation (call a stub for out of range new
31 R_MMIX_GETA_STUBBABLE). */
38 #include "opcode/mmix.h"
40 #define MINUS_ONE (((bfd_vma) 0) - 1)
42 #define MAX_PUSHJ_STUB_SIZE (5 * 4)
44 /* Put these everywhere in new code. */
46 _bfd_abort (__FILE__, __LINE__, \
47 "Internal: Non-debugged code (test-case missing)")
50 _bfd_abort (__FILE__, __LINE__, \
53 struct _mmix_elf_section_data
55 struct bfd_elf_section_data elf;
58 struct bpo_reloc_section_info *reloc;
59 struct bpo_greg_section_info *greg;
62 struct pushj_stub_info
64 /* Maximum number of stubs needed for this section. */
65 bfd_size_type n_pushj_relocs;
67 /* Size of stubs after a mmix_elf_relax_section round. */
68 bfd_size_type stubs_size_sum;
70 /* Per-reloc stubs_size_sum information. The stubs_size_sum member is the sum
71 of these. Allocated in mmix_elf_check_common_relocs. */
72 bfd_size_type *stub_size;
74 /* Offset of next stub during relocation. Somewhat redundant with the
75 above: error coverage is easier and we don't have to reset the
76 stubs_size_sum for relocation. */
77 bfd_size_type stub_offset;
80 /* Whether there has been a warning that this section could not be
81 linked due to a specific cause. FIXME: a way to access the
82 linker info or output section, then stuff the limiter guard
84 bfd_boolean has_warned_bpo;
85 bfd_boolean has_warned_pushj;
88 #define mmix_elf_section_data(sec) \
89 ((struct _mmix_elf_section_data *) elf_section_data (sec))
91 /* For each section containing a base-plus-offset (BPO) reloc, we attach
92 this struct as mmix_elf_section_data (section)->bpo, which is otherwise
94 struct bpo_reloc_section_info
96 /* The base is 1; this is the first number in this section. */
97 size_t first_base_plus_offset_reloc;
99 /* Number of BPO-relocs in this section. */
100 size_t n_bpo_relocs_this_section;
102 /* Running index, used at relocation time. */
105 /* We don't have access to the bfd_link_info struct in
106 mmix_final_link_relocate. What we really want to get at is the
107 global single struct greg_relocation, so we stash it here. */
108 asection *bpo_greg_section;
111 /* Helper struct (in global context) for the one below.
112 There's one of these created for every BPO reloc. */
113 struct bpo_reloc_request
117 /* Valid after relaxation. The base is 0; the first register number
118 must be added. The offset is in range 0..255. */
122 /* The order number for this BPO reloc, corresponding to the order in
123 which BPO relocs were found. Used to create an index after reloc
124 requests are sorted. */
127 /* Set when the value is computed. Better than coding "guard values"
128 into the other members. Is FALSE only for BPO relocs in a GC:ed
133 /* We attach this as mmix_elf_section_data (sec)->bpo in the linker-allocated
134 greg contents section (MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME),
135 which is linked into the register contents section
136 (MMIX_REG_CONTENTS_SECTION_NAME). This section is created by the
137 linker; using the same hook as for usual with BPO relocs does not
139 struct bpo_greg_section_info
141 /* After GC, this reflects the number of remaining, non-excluded
145 /* This is the number of allocated bpo_reloc_requests; the size of
146 sorted_indexes. Valid after the check.*relocs functions are called
147 for all incoming sections. It includes the number of BPO relocs in
148 sections that were GC:ed. */
149 size_t n_max_bpo_relocs;
151 /* A counter used to find out when to fold the BPO gregs, since we
152 don't have a single "after-relaxation" hook. */
153 size_t n_remaining_bpo_relocs_this_relaxation_round;
155 /* The number of linker-allocated GREGs resulting from BPO relocs.
156 This is an approximation after _bfd_mmix_before_linker_allocation
157 and supposedly accurate after mmix_elf_relax_section is called for
158 all incoming non-collected sections. */
159 size_t n_allocated_bpo_gregs;
161 /* Index into reloc_request[], sorted on increasing "value", secondary
162 by increasing index for strict sorting order. */
163 size_t *bpo_reloc_indexes;
165 /* An array of all relocations, with the "value" member filled in by
166 the relaxation function. */
167 struct bpo_reloc_request *reloc_request;
171 extern bfd_boolean mmix_elf_final_link (bfd *, struct bfd_link_info *);
173 extern void mmix_elf_symbol_processing (bfd *, asymbol *);
175 /* Only intended to be called from a debugger. */
176 extern void mmix_dump_bpo_gregs
177 (struct bfd_link_info *, bfd_error_handler_type);
180 mmix_set_relaxable_size (bfd *, asection *, void *);
181 static bfd_reloc_status_type
182 mmix_elf_reloc (bfd *, arelent *, asymbol *, void *,
183 asection *, bfd *, char **);
184 static bfd_reloc_status_type
185 mmix_final_link_relocate (reloc_howto_type *, asection *, bfd_byte *, bfd_vma,
186 bfd_signed_vma, bfd_vma, const char *, asection *,
190 /* Watch out: this currently needs to have elements with the same index as
191 their R_MMIX_ number. */
192 static reloc_howto_type elf_mmix_howto_table[] =
194 /* This reloc does nothing. */
195 HOWTO (R_MMIX_NONE, /* type */
197 2, /* size (0 = byte, 1 = short, 2 = long) */
199 FALSE, /* pc_relative */
201 complain_overflow_bitfield, /* complain_on_overflow */
202 bfd_elf_generic_reloc, /* special_function */
203 "R_MMIX_NONE", /* name */
204 FALSE, /* partial_inplace */
207 FALSE), /* pcrel_offset */
209 /* An 8 bit absolute relocation. */
210 HOWTO (R_MMIX_8, /* type */
212 0, /* size (0 = byte, 1 = short, 2 = long) */
214 FALSE, /* pc_relative */
216 complain_overflow_bitfield, /* complain_on_overflow */
217 bfd_elf_generic_reloc, /* special_function */
218 "R_MMIX_8", /* name */
219 FALSE, /* partial_inplace */
222 FALSE), /* pcrel_offset */
224 /* An 16 bit absolute relocation. */
225 HOWTO (R_MMIX_16, /* type */
227 1, /* size (0 = byte, 1 = short, 2 = long) */
229 FALSE, /* pc_relative */
231 complain_overflow_bitfield, /* complain_on_overflow */
232 bfd_elf_generic_reloc, /* special_function */
233 "R_MMIX_16", /* name */
234 FALSE, /* partial_inplace */
236 0xffff, /* dst_mask */
237 FALSE), /* pcrel_offset */
239 /* An 24 bit absolute relocation. */
240 HOWTO (R_MMIX_24, /* type */
242 2, /* size (0 = byte, 1 = short, 2 = long) */
244 FALSE, /* pc_relative */
246 complain_overflow_bitfield, /* complain_on_overflow */
247 bfd_elf_generic_reloc, /* special_function */
248 "R_MMIX_24", /* name */
249 FALSE, /* partial_inplace */
250 ~0xffffff, /* src_mask */
251 0xffffff, /* dst_mask */
252 FALSE), /* pcrel_offset */
254 /* A 32 bit absolute relocation. */
255 HOWTO (R_MMIX_32, /* type */
257 2, /* size (0 = byte, 1 = short, 2 = long) */
259 FALSE, /* pc_relative */
261 complain_overflow_bitfield, /* complain_on_overflow */
262 bfd_elf_generic_reloc, /* special_function */
263 "R_MMIX_32", /* name */
264 FALSE, /* partial_inplace */
266 0xffffffff, /* dst_mask */
267 FALSE), /* pcrel_offset */
269 /* 64 bit relocation. */
270 HOWTO (R_MMIX_64, /* type */
272 4, /* size (0 = byte, 1 = short, 2 = long) */
274 FALSE, /* pc_relative */
276 complain_overflow_bitfield, /* complain_on_overflow */
277 bfd_elf_generic_reloc, /* special_function */
278 "R_MMIX_64", /* name */
279 FALSE, /* partial_inplace */
281 MINUS_ONE, /* dst_mask */
282 FALSE), /* pcrel_offset */
284 /* An 8 bit PC-relative relocation. */
285 HOWTO (R_MMIX_PC_8, /* type */
287 0, /* size (0 = byte, 1 = short, 2 = long) */
289 TRUE, /* pc_relative */
291 complain_overflow_bitfield, /* complain_on_overflow */
292 bfd_elf_generic_reloc, /* special_function */
293 "R_MMIX_PC_8", /* name */
294 FALSE, /* partial_inplace */
297 TRUE), /* pcrel_offset */
299 /* An 16 bit PC-relative relocation. */
300 HOWTO (R_MMIX_PC_16, /* type */
302 1, /* size (0 = byte, 1 = short, 2 = long) */
304 TRUE, /* pc_relative */
306 complain_overflow_bitfield, /* complain_on_overflow */
307 bfd_elf_generic_reloc, /* special_function */
308 "R_MMIX_PC_16", /* name */
309 FALSE, /* partial_inplace */
311 0xffff, /* dst_mask */
312 TRUE), /* pcrel_offset */
314 /* An 24 bit PC-relative relocation. */
315 HOWTO (R_MMIX_PC_24, /* type */
317 2, /* size (0 = byte, 1 = short, 2 = long) */
319 TRUE, /* pc_relative */
321 complain_overflow_bitfield, /* complain_on_overflow */
322 bfd_elf_generic_reloc, /* special_function */
323 "R_MMIX_PC_24", /* name */
324 FALSE, /* partial_inplace */
325 ~0xffffff, /* src_mask */
326 0xffffff, /* dst_mask */
327 TRUE), /* pcrel_offset */
329 /* A 32 bit absolute PC-relative relocation. */
330 HOWTO (R_MMIX_PC_32, /* type */
332 2, /* size (0 = byte, 1 = short, 2 = long) */
334 TRUE, /* pc_relative */
336 complain_overflow_bitfield, /* complain_on_overflow */
337 bfd_elf_generic_reloc, /* special_function */
338 "R_MMIX_PC_32", /* name */
339 FALSE, /* partial_inplace */
341 0xffffffff, /* dst_mask */
342 TRUE), /* pcrel_offset */
344 /* 64 bit PC-relative relocation. */
345 HOWTO (R_MMIX_PC_64, /* type */
347 4, /* size (0 = byte, 1 = short, 2 = long) */
349 TRUE, /* pc_relative */
351 complain_overflow_bitfield, /* complain_on_overflow */
352 bfd_elf_generic_reloc, /* special_function */
353 "R_MMIX_PC_64", /* name */
354 FALSE, /* partial_inplace */
356 MINUS_ONE, /* dst_mask */
357 TRUE), /* pcrel_offset */
359 /* GNU extension to record C++ vtable hierarchy. */
360 HOWTO (R_MMIX_GNU_VTINHERIT, /* type */
362 0, /* size (0 = byte, 1 = short, 2 = long) */
364 FALSE, /* pc_relative */
366 complain_overflow_dont, /* complain_on_overflow */
367 NULL, /* special_function */
368 "R_MMIX_GNU_VTINHERIT", /* name */
369 FALSE, /* partial_inplace */
372 TRUE), /* pcrel_offset */
374 /* GNU extension to record C++ vtable member usage. */
375 HOWTO (R_MMIX_GNU_VTENTRY, /* type */
377 0, /* size (0 = byte, 1 = short, 2 = long) */
379 FALSE, /* pc_relative */
381 complain_overflow_dont, /* complain_on_overflow */
382 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
383 "R_MMIX_GNU_VTENTRY", /* name */
384 FALSE, /* partial_inplace */
387 FALSE), /* pcrel_offset */
389 /* The GETA relocation is supposed to get any address that could
390 possibly be reached by the GETA instruction. It can silently expand
391 to get a 64-bit operand, but will complain if any of the two least
392 significant bits are set. The howto members reflect a simple GETA. */
393 HOWTO (R_MMIX_GETA, /* type */
395 2, /* size (0 = byte, 1 = short, 2 = long) */
397 TRUE, /* pc_relative */
399 complain_overflow_signed, /* complain_on_overflow */
400 mmix_elf_reloc, /* special_function */
401 "R_MMIX_GETA", /* name */
402 FALSE, /* partial_inplace */
403 ~0x0100ffff, /* src_mask */
404 0x0100ffff, /* dst_mask */
405 TRUE), /* pcrel_offset */
407 HOWTO (R_MMIX_GETA_1, /* type */
409 2, /* size (0 = byte, 1 = short, 2 = long) */
411 TRUE, /* pc_relative */
413 complain_overflow_signed, /* complain_on_overflow */
414 mmix_elf_reloc, /* special_function */
415 "R_MMIX_GETA_1", /* name */
416 FALSE, /* partial_inplace */
417 ~0x0100ffff, /* src_mask */
418 0x0100ffff, /* dst_mask */
419 TRUE), /* pcrel_offset */
421 HOWTO (R_MMIX_GETA_2, /* type */
423 2, /* size (0 = byte, 1 = short, 2 = long) */
425 TRUE, /* pc_relative */
427 complain_overflow_signed, /* complain_on_overflow */
428 mmix_elf_reloc, /* special_function */
429 "R_MMIX_GETA_2", /* name */
430 FALSE, /* partial_inplace */
431 ~0x0100ffff, /* src_mask */
432 0x0100ffff, /* dst_mask */
433 TRUE), /* pcrel_offset */
435 HOWTO (R_MMIX_GETA_3, /* type */
437 2, /* size (0 = byte, 1 = short, 2 = long) */
439 TRUE, /* pc_relative */
441 complain_overflow_signed, /* complain_on_overflow */
442 mmix_elf_reloc, /* special_function */
443 "R_MMIX_GETA_3", /* name */
444 FALSE, /* partial_inplace */
445 ~0x0100ffff, /* src_mask */
446 0x0100ffff, /* dst_mask */
447 TRUE), /* pcrel_offset */
449 /* The conditional branches are supposed to reach any (code) address.
450 It can silently expand to a 64-bit operand, but will emit an error if
451 any of the two least significant bits are set. The howto members
452 reflect a simple branch. */
453 HOWTO (R_MMIX_CBRANCH, /* type */
455 2, /* size (0 = byte, 1 = short, 2 = long) */
457 TRUE, /* pc_relative */
459 complain_overflow_signed, /* complain_on_overflow */
460 mmix_elf_reloc, /* special_function */
461 "R_MMIX_CBRANCH", /* name */
462 FALSE, /* partial_inplace */
463 ~0x0100ffff, /* src_mask */
464 0x0100ffff, /* dst_mask */
465 TRUE), /* pcrel_offset */
467 HOWTO (R_MMIX_CBRANCH_J, /* type */
469 2, /* size (0 = byte, 1 = short, 2 = long) */
471 TRUE, /* pc_relative */
473 complain_overflow_signed, /* complain_on_overflow */
474 mmix_elf_reloc, /* special_function */
475 "R_MMIX_CBRANCH_J", /* name */
476 FALSE, /* partial_inplace */
477 ~0x0100ffff, /* src_mask */
478 0x0100ffff, /* dst_mask */
479 TRUE), /* pcrel_offset */
481 HOWTO (R_MMIX_CBRANCH_1, /* type */
483 2, /* size (0 = byte, 1 = short, 2 = long) */
485 TRUE, /* pc_relative */
487 complain_overflow_signed, /* complain_on_overflow */
488 mmix_elf_reloc, /* special_function */
489 "R_MMIX_CBRANCH_1", /* name */
490 FALSE, /* partial_inplace */
491 ~0x0100ffff, /* src_mask */
492 0x0100ffff, /* dst_mask */
493 TRUE), /* pcrel_offset */
495 HOWTO (R_MMIX_CBRANCH_2, /* type */
497 2, /* size (0 = byte, 1 = short, 2 = long) */
499 TRUE, /* pc_relative */
501 complain_overflow_signed, /* complain_on_overflow */
502 mmix_elf_reloc, /* special_function */
503 "R_MMIX_CBRANCH_2", /* name */
504 FALSE, /* partial_inplace */
505 ~0x0100ffff, /* src_mask */
506 0x0100ffff, /* dst_mask */
507 TRUE), /* pcrel_offset */
509 HOWTO (R_MMIX_CBRANCH_3, /* type */
511 2, /* size (0 = byte, 1 = short, 2 = long) */
513 TRUE, /* pc_relative */
515 complain_overflow_signed, /* complain_on_overflow */
516 mmix_elf_reloc, /* special_function */
517 "R_MMIX_CBRANCH_3", /* name */
518 FALSE, /* partial_inplace */
519 ~0x0100ffff, /* src_mask */
520 0x0100ffff, /* dst_mask */
521 TRUE), /* pcrel_offset */
523 /* The PUSHJ instruction can reach any (code) address, as long as it's
524 the beginning of a function (no usable restriction). It can silently
525 expand to a 64-bit operand, but will emit an error if any of the two
526 least significant bits are set. It can also expand into a call to a
527 stub; see R_MMIX_PUSHJ_STUBBABLE. The howto members reflect a simple
529 HOWTO (R_MMIX_PUSHJ, /* type */
531 2, /* size (0 = byte, 1 = short, 2 = long) */
533 TRUE, /* pc_relative */
535 complain_overflow_signed, /* complain_on_overflow */
536 mmix_elf_reloc, /* special_function */
537 "R_MMIX_PUSHJ", /* name */
538 FALSE, /* partial_inplace */
539 ~0x0100ffff, /* src_mask */
540 0x0100ffff, /* dst_mask */
541 TRUE), /* pcrel_offset */
543 HOWTO (R_MMIX_PUSHJ_1, /* type */
545 2, /* size (0 = byte, 1 = short, 2 = long) */
547 TRUE, /* pc_relative */
549 complain_overflow_signed, /* complain_on_overflow */
550 mmix_elf_reloc, /* special_function */
551 "R_MMIX_PUSHJ_1", /* name */
552 FALSE, /* partial_inplace */
553 ~0x0100ffff, /* src_mask */
554 0x0100ffff, /* dst_mask */
555 TRUE), /* pcrel_offset */
557 HOWTO (R_MMIX_PUSHJ_2, /* type */
559 2, /* size (0 = byte, 1 = short, 2 = long) */
561 TRUE, /* pc_relative */
563 complain_overflow_signed, /* complain_on_overflow */
564 mmix_elf_reloc, /* special_function */
565 "R_MMIX_PUSHJ_2", /* name */
566 FALSE, /* partial_inplace */
567 ~0x0100ffff, /* src_mask */
568 0x0100ffff, /* dst_mask */
569 TRUE), /* pcrel_offset */
571 HOWTO (R_MMIX_PUSHJ_3, /* type */
573 2, /* size (0 = byte, 1 = short, 2 = long) */
575 TRUE, /* pc_relative */
577 complain_overflow_signed, /* complain_on_overflow */
578 mmix_elf_reloc, /* special_function */
579 "R_MMIX_PUSHJ_3", /* name */
580 FALSE, /* partial_inplace */
581 ~0x0100ffff, /* src_mask */
582 0x0100ffff, /* dst_mask */
583 TRUE), /* pcrel_offset */
585 /* A JMP is supposed to reach any (code) address. By itself, it can
586 reach +-64M; the expansion can reach all 64 bits. Note that the 64M
587 limit is soon reached if you link the program in wildly different
588 memory segments. The howto members reflect a trivial JMP. */
589 HOWTO (R_MMIX_JMP, /* type */
591 2, /* size (0 = byte, 1 = short, 2 = long) */
593 TRUE, /* pc_relative */
595 complain_overflow_signed, /* complain_on_overflow */
596 mmix_elf_reloc, /* special_function */
597 "R_MMIX_JMP", /* name */
598 FALSE, /* partial_inplace */
599 ~0x1ffffff, /* src_mask */
600 0x1ffffff, /* dst_mask */
601 TRUE), /* pcrel_offset */
603 HOWTO (R_MMIX_JMP_1, /* type */
605 2, /* size (0 = byte, 1 = short, 2 = long) */
607 TRUE, /* pc_relative */
609 complain_overflow_signed, /* complain_on_overflow */
610 mmix_elf_reloc, /* special_function */
611 "R_MMIX_JMP_1", /* name */
612 FALSE, /* partial_inplace */
613 ~0x1ffffff, /* src_mask */
614 0x1ffffff, /* dst_mask */
615 TRUE), /* pcrel_offset */
617 HOWTO (R_MMIX_JMP_2, /* type */
619 2, /* size (0 = byte, 1 = short, 2 = long) */
621 TRUE, /* pc_relative */
623 complain_overflow_signed, /* complain_on_overflow */
624 mmix_elf_reloc, /* special_function */
625 "R_MMIX_JMP_2", /* name */
626 FALSE, /* partial_inplace */
627 ~0x1ffffff, /* src_mask */
628 0x1ffffff, /* dst_mask */
629 TRUE), /* pcrel_offset */
631 HOWTO (R_MMIX_JMP_3, /* type */
633 2, /* size (0 = byte, 1 = short, 2 = long) */
635 TRUE, /* pc_relative */
637 complain_overflow_signed, /* complain_on_overflow */
638 mmix_elf_reloc, /* special_function */
639 "R_MMIX_JMP_3", /* name */
640 FALSE, /* partial_inplace */
641 ~0x1ffffff, /* src_mask */
642 0x1ffffff, /* dst_mask */
643 TRUE), /* pcrel_offset */
645 /* When we don't emit link-time-relaxable code from the assembler, or
646 when relaxation has done all it can do, these relocs are used. For
647 GETA/PUSHJ/branches. */
648 HOWTO (R_MMIX_ADDR19, /* type */
650 2, /* size (0 = byte, 1 = short, 2 = long) */
652 TRUE, /* pc_relative */
654 complain_overflow_signed, /* complain_on_overflow */
655 mmix_elf_reloc, /* special_function */
656 "R_MMIX_ADDR19", /* name */
657 FALSE, /* partial_inplace */
658 ~0x0100ffff, /* src_mask */
659 0x0100ffff, /* dst_mask */
660 TRUE), /* pcrel_offset */
663 HOWTO (R_MMIX_ADDR27, /* type */
665 2, /* size (0 = byte, 1 = short, 2 = long) */
667 TRUE, /* pc_relative */
669 complain_overflow_signed, /* complain_on_overflow */
670 mmix_elf_reloc, /* special_function */
671 "R_MMIX_ADDR27", /* name */
672 FALSE, /* partial_inplace */
673 ~0x1ffffff, /* src_mask */
674 0x1ffffff, /* dst_mask */
675 TRUE), /* pcrel_offset */
677 /* A general register or the value 0..255. If a value, then the
678 instruction (offset -3) needs adjusting. */
679 HOWTO (R_MMIX_REG_OR_BYTE, /* type */
681 1, /* size (0 = byte, 1 = short, 2 = long) */
683 FALSE, /* pc_relative */
685 complain_overflow_bitfield, /* complain_on_overflow */
686 mmix_elf_reloc, /* special_function */
687 "R_MMIX_REG_OR_BYTE", /* name */
688 FALSE, /* partial_inplace */
691 FALSE), /* pcrel_offset */
693 /* A general register. */
694 HOWTO (R_MMIX_REG, /* type */
696 1, /* size (0 = byte, 1 = short, 2 = long) */
698 FALSE, /* pc_relative */
700 complain_overflow_bitfield, /* complain_on_overflow */
701 mmix_elf_reloc, /* special_function */
702 "R_MMIX_REG", /* name */
703 FALSE, /* partial_inplace */
706 FALSE), /* pcrel_offset */
708 /* A register plus an index, corresponding to the relocation expression.
709 The sizes must correspond to the valid range of the expression, while
710 the bitmasks correspond to what we store in the image. */
711 HOWTO (R_MMIX_BASE_PLUS_OFFSET, /* type */
713 4, /* size (0 = byte, 1 = short, 2 = long) */
715 FALSE, /* pc_relative */
717 complain_overflow_bitfield, /* complain_on_overflow */
718 mmix_elf_reloc, /* special_function */
719 "R_MMIX_BASE_PLUS_OFFSET", /* name */
720 FALSE, /* partial_inplace */
722 0xffff, /* dst_mask */
723 FALSE), /* pcrel_offset */
725 /* A "magic" relocation for a LOCAL expression, asserting that the
726 expression is less than the number of global registers. No actual
727 modification of the contents is done. Implementing this as a
728 relocation was less intrusive than e.g. putting such expressions in a
729 section to discard *after* relocation. */
730 HOWTO (R_MMIX_LOCAL, /* type */
732 0, /* size (0 = byte, 1 = short, 2 = long) */
734 FALSE, /* pc_relative */
736 complain_overflow_dont, /* complain_on_overflow */
737 mmix_elf_reloc, /* special_function */
738 "R_MMIX_LOCAL", /* name */
739 FALSE, /* partial_inplace */
742 FALSE), /* pcrel_offset */
744 HOWTO (R_MMIX_PUSHJ_STUBBABLE, /* type */
746 2, /* size (0 = byte, 1 = short, 2 = long) */
748 TRUE, /* pc_relative */
750 complain_overflow_signed, /* complain_on_overflow */
751 mmix_elf_reloc, /* special_function */
752 "R_MMIX_PUSHJ_STUBBABLE", /* name */
753 FALSE, /* partial_inplace */
754 ~0x0100ffff, /* src_mask */
755 0x0100ffff, /* dst_mask */
756 TRUE) /* pcrel_offset */
760 /* Map BFD reloc types to MMIX ELF reloc types. */
762 struct mmix_reloc_map
764 bfd_reloc_code_real_type bfd_reloc_val;
765 enum elf_mmix_reloc_type elf_reloc_val;
769 static const struct mmix_reloc_map mmix_reloc_map[] =
771 {BFD_RELOC_NONE, R_MMIX_NONE},
772 {BFD_RELOC_8, R_MMIX_8},
773 {BFD_RELOC_16, R_MMIX_16},
774 {BFD_RELOC_24, R_MMIX_24},
775 {BFD_RELOC_32, R_MMIX_32},
776 {BFD_RELOC_64, R_MMIX_64},
777 {BFD_RELOC_8_PCREL, R_MMIX_PC_8},
778 {BFD_RELOC_16_PCREL, R_MMIX_PC_16},
779 {BFD_RELOC_24_PCREL, R_MMIX_PC_24},
780 {BFD_RELOC_32_PCREL, R_MMIX_PC_32},
781 {BFD_RELOC_64_PCREL, R_MMIX_PC_64},
782 {BFD_RELOC_VTABLE_INHERIT, R_MMIX_GNU_VTINHERIT},
783 {BFD_RELOC_VTABLE_ENTRY, R_MMIX_GNU_VTENTRY},
784 {BFD_RELOC_MMIX_GETA, R_MMIX_GETA},
785 {BFD_RELOC_MMIX_CBRANCH, R_MMIX_CBRANCH},
786 {BFD_RELOC_MMIX_PUSHJ, R_MMIX_PUSHJ},
787 {BFD_RELOC_MMIX_JMP, R_MMIX_JMP},
788 {BFD_RELOC_MMIX_ADDR19, R_MMIX_ADDR19},
789 {BFD_RELOC_MMIX_ADDR27, R_MMIX_ADDR27},
790 {BFD_RELOC_MMIX_REG_OR_BYTE, R_MMIX_REG_OR_BYTE},
791 {BFD_RELOC_MMIX_REG, R_MMIX_REG},
792 {BFD_RELOC_MMIX_BASE_PLUS_OFFSET, R_MMIX_BASE_PLUS_OFFSET},
793 {BFD_RELOC_MMIX_LOCAL, R_MMIX_LOCAL},
794 {BFD_RELOC_MMIX_PUSHJ_STUBBABLE, R_MMIX_PUSHJ_STUBBABLE}
797 static reloc_howto_type *
798 bfd_elf64_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
799 bfd_reloc_code_real_type code)
804 i < sizeof (mmix_reloc_map) / sizeof (mmix_reloc_map[0]);
807 if (mmix_reloc_map[i].bfd_reloc_val == code)
808 return &elf_mmix_howto_table[mmix_reloc_map[i].elf_reloc_val];
814 static reloc_howto_type *
815 bfd_elf64_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
821 i < sizeof (elf_mmix_howto_table) / sizeof (elf_mmix_howto_table[0]);
823 if (elf_mmix_howto_table[i].name != NULL
824 && strcasecmp (elf_mmix_howto_table[i].name, r_name) == 0)
825 return &elf_mmix_howto_table[i];
831 mmix_elf_new_section_hook (bfd *abfd, asection *sec)
833 if (!sec->used_by_bfd)
835 struct _mmix_elf_section_data *sdata;
836 bfd_size_type amt = sizeof (*sdata);
838 sdata = bfd_zalloc (abfd, amt);
841 sec->used_by_bfd = sdata;
844 return _bfd_elf_new_section_hook (abfd, sec);
848 /* This function performs the actual bitfiddling and sanity check for a
849 final relocation. Each relocation gets its *worst*-case expansion
850 in size when it arrives here; any reduction in size should have been
851 caught in linker relaxation earlier. When we get here, the relocation
852 looks like the smallest instruction with SWYM:s (nop:s) appended to the
853 max size. We fill in those nop:s.
855 R_MMIX_GETA: (FIXME: Relaxation should break this up in 1, 2, 3 tetra)
859 INCML $N,(foo >> 16) & 0xffff
860 INCMH $N,(foo >> 32) & 0xffff
861 INCH $N,(foo >> 48) & 0xffff
863 R_MMIX_CBRANCH: (FIXME: Relaxation should break this up, but
864 condbranches needing relaxation might be rare enough to not be
875 R_MMIX_PUSHJ: (FIXME: Relaxation...)
884 R_MMIX_JMP: (FIXME: Relaxation...)
893 R_MMIX_ADDR19 and R_MMIX_ADDR27 are just filled in. */
895 static bfd_reloc_status_type
896 mmix_elf_perform_relocation (asection *isec, reloc_howto_type *howto,
897 void *datap, bfd_vma addr, bfd_vma value,
898 char **error_message)
900 bfd *abfd = isec->owner;
901 bfd_reloc_status_type flag = bfd_reloc_ok;
902 bfd_reloc_status_type r;
906 /* The worst case bits are all similar SETL/INCML/INCMH/INCH sequences.
907 We handle the differences here and the common sequence later. */
912 reg = bfd_get_8 (abfd, (bfd_byte *) datap + 1);
914 /* We change to an absolute value. */
920 int in1 = bfd_get_16 (abfd, (bfd_byte *) datap) << 16;
922 /* Invert the condition and prediction bit, and set the offset
923 to five instructions ahead.
925 We *can* do better if we want to. If the branch is found to be
926 within limits, we could leave the branch as is; there'll just
927 be a bunch of NOP:s after it. But we shouldn't see this
928 sequence often enough that it's worth doing it. */
931 (((in1 ^ ((PRED_INV_BIT | COND_INV_BIT) << 24)) & ~0xffff)
935 /* Put a "GO $255,$255,0" after the common sequence. */
937 ((GO_INSN_BYTE | IMM_OFFSET_BIT) << 24) | 0xffff00,
938 (bfd_byte *) datap + 20);
940 /* Common sequence starts at offset 4. */
943 /* We change to an absolute value. */
948 case R_MMIX_PUSHJ_STUBBABLE:
949 /* If the address fits, we're fine. */
951 /* Note rightshift 0; see R_MMIX_JMP case below. */
952 && (r = bfd_check_overflow (complain_overflow_signed,
955 bfd_arch_bits_per_address (abfd),
956 value)) == bfd_reloc_ok)
957 goto pcrel_mmix_reloc_fits;
960 bfd_size_type size = isec->rawsize ? isec->rawsize : isec->size;
962 /* We have the bytes at the PUSHJ insn and need to get the
963 position for the stub. There's supposed to be room allocated
965 bfd_byte *stubcontents
966 = ((bfd_byte *) datap
967 - (addr - (isec->output_section->vma + isec->output_offset))
969 + mmix_elf_section_data (isec)->pjs.stub_offset);
972 if (mmix_elf_section_data (isec)->pjs.n_pushj_relocs == 0)
974 /* This shouldn't happen when linking to ELF or mmo, so
975 this is an attempt to link to "binary", right? We
976 can't access the output bfd, so we can't verify that
977 assumption. We only know that the critical
978 mmix_elf_check_common_relocs has not been called,
979 which happens when the output format is different
980 from the input format (and is not mmo). */
981 if (! mmix_elf_section_data (isec)->has_warned_pushj)
983 /* For the first such error per input section, produce
984 a verbose message. */
986 = _("invalid input relocation when producing"
987 " non-ELF, non-mmo format output."
988 "\n Please use the objcopy program to convert from"
990 "\n or assemble using"
991 " \"-no-expand\" (for gcc, \"-Wa,-no-expand\"");
992 mmix_elf_section_data (isec)->has_warned_pushj = TRUE;
993 return bfd_reloc_dangerous;
996 /* For subsequent errors, return this one, which is
997 rate-limited but looks a little bit different,
998 hopefully without affecting user-friendliness. */
999 return bfd_reloc_overflow;
1002 /* The address doesn't fit, so redirect the PUSHJ to the
1003 location of the stub. */
1004 r = mmix_elf_perform_relocation (isec,
1005 &elf_mmix_howto_table
1009 isec->output_section->vma
1010 + isec->output_offset
1012 + (mmix_elf_section_data (isec)
1016 if (r != bfd_reloc_ok)
1020 = (isec->output_section->vma
1021 + isec->output_offset
1023 + mmix_elf_section_data (isec)->pjs.stub_offset);
1025 /* We generate a simple JMP if that suffices, else the whole 5
1027 if (bfd_check_overflow (complain_overflow_signed,
1028 elf_mmix_howto_table[R_MMIX_ADDR27].bitsize,
1030 bfd_arch_bits_per_address (abfd),
1031 addr + value - stubaddr) == bfd_reloc_ok)
1033 bfd_put_32 (abfd, JMP_INSN_BYTE << 24, stubcontents);
1034 r = mmix_elf_perform_relocation (isec,
1035 &elf_mmix_howto_table
1039 value + addr - stubaddr,
1041 mmix_elf_section_data (isec)->pjs.stub_offset += 4;
1043 if (size + mmix_elf_section_data (isec)->pjs.stub_offset
1051 /* Put a "GO $255,0" after the common sequence. */
1053 ((GO_INSN_BYTE | IMM_OFFSET_BIT) << 24)
1054 | 0xff00, (bfd_byte *) stubcontents + 16);
1056 /* Prepare for the general code to set the first part of the
1059 datap = stubcontents;
1060 mmix_elf_section_data (isec)->pjs.stub_offset
1061 += MAX_PUSHJ_STUB_SIZE;
1068 int inreg = bfd_get_8 (abfd, (bfd_byte *) datap + 1);
1070 /* Put a "PUSHGO $N,$255,0" after the common sequence. */
1072 ((PUSHGO_INSN_BYTE | IMM_OFFSET_BIT) << 24)
1075 (bfd_byte *) datap + 16);
1077 /* We change to an absolute value. */
1083 /* This one is a little special. If we get here on a non-relaxing
1084 link, and the destination is actually in range, we don't need to
1086 If so, we fall through to the bit-fiddling relocs.
1088 FIXME: bfd_check_overflow seems broken; the relocation is
1089 rightshifted before testing, so supply a zero rightshift. */
1091 if (! ((value & 3) == 0
1092 && (r = bfd_check_overflow (complain_overflow_signed,
1095 bfd_arch_bits_per_address (abfd),
1096 value)) == bfd_reloc_ok))
1098 /* If the relocation doesn't fit in a JMP, we let the NOP:s be
1099 modified below, and put a "GO $255,$255,0" after the
1100 address-loading sequence. */
1102 ((GO_INSN_BYTE | IMM_OFFSET_BIT) << 24)
1104 (bfd_byte *) datap + 16);
1106 /* We change to an absolute value. */
1113 pcrel_mmix_reloc_fits:
1114 /* These must be in range, or else we emit an error. */
1115 if ((value & 3) == 0
1116 /* Note rightshift 0; see above. */
1117 && (r = bfd_check_overflow (complain_overflow_signed,
1120 bfd_arch_bits_per_address (abfd),
1121 value)) == bfd_reloc_ok)
1124 = bfd_get_32 (abfd, (bfd_byte *) datap);
1127 if ((bfd_signed_vma) value < 0)
1130 value += (1 << (howto->bitsize - 1));
1138 (in1 & howto->src_mask)
1140 | (value & howto->dst_mask),
1141 (bfd_byte *) datap);
1143 return bfd_reloc_ok;
1146 return bfd_reloc_overflow;
1148 case R_MMIX_BASE_PLUS_OFFSET:
1150 struct bpo_reloc_section_info *bpodata
1151 = mmix_elf_section_data (isec)->bpo.reloc;
1152 asection *bpo_greg_section;
1153 struct bpo_greg_section_info *gregdata;
1156 if (bpodata == NULL)
1158 /* This shouldn't happen when linking to ELF or mmo, so
1159 this is an attempt to link to "binary", right? We
1160 can't access the output bfd, so we can't verify that
1161 assumption. We only know that the critical
1162 mmix_elf_check_common_relocs has not been called, which
1163 happens when the output format is different from the
1164 input format (and is not mmo). */
1165 if (! mmix_elf_section_data (isec)->has_warned_bpo)
1167 /* For the first such error per input section, produce
1168 a verbose message. */
1170 = _("invalid input relocation when producing"
1171 " non-ELF, non-mmo format output."
1172 "\n Please use the objcopy program to convert from"
1174 "\n or compile using the gcc-option"
1175 " \"-mno-base-addresses\".");
1176 mmix_elf_section_data (isec)->has_warned_bpo = TRUE;
1177 return bfd_reloc_dangerous;
1180 /* For subsequent errors, return this one, which is
1181 rate-limited but looks a little bit different,
1182 hopefully without affecting user-friendliness. */
1183 return bfd_reloc_overflow;
1186 bpo_greg_section = bpodata->bpo_greg_section;
1187 gregdata = mmix_elf_section_data (bpo_greg_section)->bpo.greg;
1188 bpo_index = gregdata->bpo_reloc_indexes[bpodata->bpo_index++];
1190 /* A consistency check: The value we now have in "relocation" must
1191 be the same as the value we stored for that relocation. It
1192 doesn't cost much, so can be left in at all times. */
1193 if (value != gregdata->reloc_request[bpo_index].value)
1195 (*_bfd_error_handler)
1196 (_("%s: Internal inconsistency error for value for\n\
1197 linker-allocated global register: linked: 0x%lx%08lx != relaxed: 0x%lx%08lx\n"),
1198 bfd_get_filename (isec->owner),
1199 (unsigned long) (value >> 32), (unsigned long) value,
1200 (unsigned long) (gregdata->reloc_request[bpo_index].value
1202 (unsigned long) gregdata->reloc_request[bpo_index].value);
1203 bfd_set_error (bfd_error_bad_value);
1204 return bfd_reloc_overflow;
1207 /* Then store the register number and offset for that register
1208 into datap and datap + 1 respectively. */
1210 gregdata->reloc_request[bpo_index].regindex
1211 + bpo_greg_section->output_section->vma / 8,
1214 gregdata->reloc_request[bpo_index].offset,
1215 ((unsigned char *) datap) + 1);
1216 return bfd_reloc_ok;
1219 case R_MMIX_REG_OR_BYTE:
1222 return bfd_reloc_overflow;
1223 bfd_put_8 (abfd, value, datap);
1224 return bfd_reloc_ok;
1227 BAD_CASE (howto->type);
1230 /* This code adds the common SETL/INCML/INCMH/INCH worst-case
1233 /* Lowest two bits must be 0. We return bfd_reloc_overflow for
1234 everything that looks strange. */
1236 flag = bfd_reloc_overflow;
1239 (SETL_INSN_BYTE << 24) | (value & 0xffff) | (reg << 16),
1240 (bfd_byte *) datap + offs);
1242 (INCML_INSN_BYTE << 24) | ((value >> 16) & 0xffff) | (reg << 16),
1243 (bfd_byte *) datap + offs + 4);
1245 (INCMH_INSN_BYTE << 24) | ((value >> 32) & 0xffff) | (reg << 16),
1246 (bfd_byte *) datap + offs + 8);
1248 (INCH_INSN_BYTE << 24) | ((value >> 48) & 0xffff) | (reg << 16),
1249 (bfd_byte *) datap + offs + 12);
1254 /* Set the howto pointer for an MMIX ELF reloc (type RELA). */
1257 mmix_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
1259 Elf_Internal_Rela *dst)
1261 unsigned int r_type;
1263 r_type = ELF64_R_TYPE (dst->r_info);
1264 BFD_ASSERT (r_type < (unsigned int) R_MMIX_max);
1265 cache_ptr->howto = &elf_mmix_howto_table[r_type];
1268 /* Any MMIX-specific relocation gets here at assembly time or when linking
1269 to other formats (such as mmo); this is the relocation function from
1270 the reloc_table. We don't get here for final pure ELF linking. */
1272 static bfd_reloc_status_type
1273 mmix_elf_reloc (bfd *abfd,
1274 arelent *reloc_entry,
1277 asection *input_section,
1279 char **error_message)
1282 bfd_reloc_status_type r;
1283 asection *reloc_target_output_section;
1284 bfd_reloc_status_type flag = bfd_reloc_ok;
1285 bfd_vma output_base = 0;
1287 r = bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
1288 input_section, output_bfd, error_message);
1290 /* If that was all that was needed (i.e. this isn't a final link, only
1291 some segment adjustments), we're done. */
1292 if (r != bfd_reloc_continue)
1295 if (bfd_is_und_section (symbol->section)
1296 && (symbol->flags & BSF_WEAK) == 0
1297 && output_bfd == (bfd *) NULL)
1298 return bfd_reloc_undefined;
1300 /* Is the address of the relocation really within the section? */
1301 if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
1302 return bfd_reloc_outofrange;
1304 /* Work out which section the relocation is targeted at and the
1305 initial relocation command value. */
1307 /* Get symbol value. (Common symbols are special.) */
1308 if (bfd_is_com_section (symbol->section))
1311 relocation = symbol->value;
1313 reloc_target_output_section = bfd_get_output_section (symbol);
1315 /* Here the variable relocation holds the final address of the symbol we
1316 are relocating against, plus any addend. */
1320 output_base = reloc_target_output_section->vma;
1322 relocation += output_base + symbol->section->output_offset;
1324 if (output_bfd != (bfd *) NULL)
1326 /* Add in supplied addend. */
1327 relocation += reloc_entry->addend;
1329 /* This is a partial relocation, and we want to apply the
1330 relocation to the reloc entry rather than the raw data.
1331 Modify the reloc inplace to reflect what we now know. */
1332 reloc_entry->addend = relocation;
1333 reloc_entry->address += input_section->output_offset;
1337 return mmix_final_link_relocate (reloc_entry->howto, input_section,
1338 data, reloc_entry->address,
1339 reloc_entry->addend, relocation,
1340 bfd_asymbol_name (symbol),
1341 reloc_target_output_section,
1345 /* Relocate an MMIX ELF section. Modified from elf32-fr30.c; look to it
1346 for guidance if you're thinking of copying this. */
1349 mmix_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
1350 struct bfd_link_info *info,
1352 asection *input_section,
1354 Elf_Internal_Rela *relocs,
1355 Elf_Internal_Sym *local_syms,
1356 asection **local_sections)
1358 Elf_Internal_Shdr *symtab_hdr;
1359 struct elf_link_hash_entry **sym_hashes;
1360 Elf_Internal_Rela *rel;
1361 Elf_Internal_Rela *relend;
1365 size = input_section->rawsize ? input_section->rawsize : input_section->size;
1366 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
1367 sym_hashes = elf_sym_hashes (input_bfd);
1368 relend = relocs + input_section->reloc_count;
1370 /* Zero the stub area before we start. */
1371 if (input_section->rawsize != 0
1372 && input_section->size > input_section->rawsize)
1373 memset (contents + input_section->rawsize, 0,
1374 input_section->size - input_section->rawsize);
1376 for (rel = relocs; rel < relend; rel ++)
1378 reloc_howto_type *howto;
1379 unsigned long r_symndx;
1380 Elf_Internal_Sym *sym;
1382 struct elf_link_hash_entry *h;
1384 bfd_reloc_status_type r;
1385 const char *name = NULL;
1387 bfd_boolean undefined_signalled = FALSE;
1389 r_type = ELF64_R_TYPE (rel->r_info);
1391 if (r_type == R_MMIX_GNU_VTINHERIT
1392 || r_type == R_MMIX_GNU_VTENTRY)
1395 r_symndx = ELF64_R_SYM (rel->r_info);
1397 howto = elf_mmix_howto_table + ELF64_R_TYPE (rel->r_info);
1402 if (r_symndx < symtab_hdr->sh_info)
1404 sym = local_syms + r_symndx;
1405 sec = local_sections [r_symndx];
1406 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
1408 name = bfd_elf_string_from_elf_section (input_bfd,
1409 symtab_hdr->sh_link,
1412 name = bfd_section_name (input_bfd, sec);
1416 bfd_boolean unresolved_reloc;
1418 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
1419 r_symndx, symtab_hdr, sym_hashes,
1421 unresolved_reloc, undefined_signalled);
1422 name = h->root.root.string;
1425 if (sec != NULL && discarded_section (sec))
1426 RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
1427 rel, 1, relend, howto, 0, contents);
1429 if (info->relocatable)
1431 /* This is a relocatable link. For most relocs we don't have to
1432 change anything, unless the reloc is against a section
1433 symbol, in which case we have to adjust according to where
1434 the section symbol winds up in the output section. */
1435 if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
1436 rel->r_addend += sec->output_offset;
1438 /* For PUSHJ stub relocs however, we may need to change the
1439 reloc and the section contents, if the reloc doesn't reach
1440 beyond the end of the output section and previous stubs.
1441 Then we change the section contents to be a PUSHJ to the end
1442 of the input section plus stubs (we can do that without using
1443 a reloc), and then we change the reloc to be a R_MMIX_PUSHJ
1444 at the stub location. */
1445 if (r_type == R_MMIX_PUSHJ_STUBBABLE)
1447 /* We've already checked whether we need a stub; use that
1449 if (mmix_elf_section_data (input_section)->pjs.stub_size[pjsno]
1452 Elf_Internal_Rela relcpy;
1454 if (mmix_elf_section_data (input_section)
1455 ->pjs.stub_size[pjsno] != MAX_PUSHJ_STUB_SIZE)
1458 /* There's already a PUSHJ insn there, so just fill in
1459 the offset bits to the stub. */
1460 if (mmix_final_link_relocate (elf_mmix_howto_table
1467 ->output_section->vma
1468 + input_section->output_offset
1470 + mmix_elf_section_data (input_section)
1472 NULL, NULL, NULL) != bfd_reloc_ok)
1475 /* Put a JMP insn at the stub; it goes with the
1476 R_MMIX_JMP reloc. */
1477 bfd_put_32 (output_bfd, JMP_INSN_BYTE << 24,
1480 + mmix_elf_section_data (input_section)
1483 /* Change the reloc to be at the stub, and to a full
1484 R_MMIX_JMP reloc. */
1485 rel->r_info = ELF64_R_INFO (r_symndx, R_MMIX_JMP);
1488 + mmix_elf_section_data (input_section)
1491 mmix_elf_section_data (input_section)->pjs.stub_offset
1492 += MAX_PUSHJ_STUB_SIZE;
1494 /* Shift this reloc to the end of the relocs to maintain
1495 the r_offset sorted reloc order. */
1497 memmove (rel, rel + 1, (char *) relend - (char *) rel);
1498 relend[-1] = relcpy;
1500 /* Back up one reloc, or else we'd skip the next reloc
1510 r = mmix_final_link_relocate (howto, input_section,
1511 contents, rel->r_offset,
1512 rel->r_addend, relocation, name, sec, NULL);
1514 if (r != bfd_reloc_ok)
1516 bfd_boolean check_ok = TRUE;
1517 const char * msg = (const char *) NULL;
1521 case bfd_reloc_overflow:
1522 check_ok = info->callbacks->reloc_overflow
1523 (info, (h ? &h->root : NULL), name, howto->name,
1524 (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
1527 case bfd_reloc_undefined:
1528 /* We may have sent this message above. */
1529 if (! undefined_signalled)
1530 check_ok = info->callbacks->undefined_symbol
1531 (info, name, input_bfd, input_section, rel->r_offset,
1533 undefined_signalled = TRUE;
1536 case bfd_reloc_outofrange:
1537 msg = _("internal error: out of range error");
1540 case bfd_reloc_notsupported:
1541 msg = _("internal error: unsupported relocation error");
1544 case bfd_reloc_dangerous:
1545 msg = _("internal error: dangerous relocation");
1549 msg = _("internal error: unknown error");
1554 check_ok = info->callbacks->warning
1555 (info, msg, name, input_bfd, input_section, rel->r_offset);
1565 /* Perform a single relocation. By default we use the standard BFD
1566 routines. A few relocs we have to do ourselves. */
1568 static bfd_reloc_status_type
1569 mmix_final_link_relocate (reloc_howto_type *howto, asection *input_section,
1570 bfd_byte *contents, bfd_vma r_offset,
1571 bfd_signed_vma r_addend, bfd_vma relocation,
1572 const char *symname, asection *symsec,
1573 char **error_message)
1575 bfd_reloc_status_type r = bfd_reloc_ok;
1577 = (input_section->output_section->vma
1578 + input_section->output_offset
1581 = (bfd_signed_vma) relocation + r_addend;
1583 switch (howto->type)
1585 /* All these are PC-relative. */
1586 case R_MMIX_PUSHJ_STUBBABLE:
1588 case R_MMIX_CBRANCH:
1593 contents += r_offset;
1595 srel -= (input_section->output_section->vma
1596 + input_section->output_offset
1599 r = mmix_elf_perform_relocation (input_section, howto, contents,
1600 addr, srel, error_message);
1603 case R_MMIX_BASE_PLUS_OFFSET:
1605 return bfd_reloc_undefined;
1607 /* Check that we're not relocating against a register symbol. */
1608 if (strcmp (bfd_get_section_name (symsec->owner, symsec),
1609 MMIX_REG_CONTENTS_SECTION_NAME) == 0
1610 || strcmp (bfd_get_section_name (symsec->owner, symsec),
1611 MMIX_REG_SECTION_NAME) == 0)
1613 /* Note: This is separated out into two messages in order
1614 to ease the translation into other languages. */
1615 if (symname == NULL || *symname == 0)
1616 (*_bfd_error_handler)
1617 (_("%s: base-plus-offset relocation against register symbol: (unknown) in %s"),
1618 bfd_get_filename (input_section->owner),
1619 bfd_get_section_name (symsec->owner, symsec));
1621 (*_bfd_error_handler)
1622 (_("%s: base-plus-offset relocation against register symbol: %s in %s"),
1623 bfd_get_filename (input_section->owner), symname,
1624 bfd_get_section_name (symsec->owner, symsec));
1625 return bfd_reloc_overflow;
1629 case R_MMIX_REG_OR_BYTE:
1631 /* For now, we handle these alike. They must refer to an register
1632 symbol, which is either relative to the register section and in
1633 the range 0..255, or is in the register contents section with vma
1636 /* FIXME: A better way to check for reg contents section?
1637 FIXME: Postpone section->scaling to mmix_elf_perform_relocation? */
1639 return bfd_reloc_undefined;
1641 if (strcmp (bfd_get_section_name (symsec->owner, symsec),
1642 MMIX_REG_CONTENTS_SECTION_NAME) == 0)
1644 if ((srel & 7) != 0 || srel < 32*8 || srel > 255*8)
1646 /* The bfd_reloc_outofrange return value, though intuitively
1647 a better value, will not get us an error. */
1648 return bfd_reloc_overflow;
1652 else if (strcmp (bfd_get_section_name (symsec->owner, symsec),
1653 MMIX_REG_SECTION_NAME) == 0)
1655 if (srel < 0 || srel > 255)
1656 /* The bfd_reloc_outofrange return value, though intuitively a
1657 better value, will not get us an error. */
1658 return bfd_reloc_overflow;
1662 /* Note: This is separated out into two messages in order
1663 to ease the translation into other languages. */
1664 if (symname == NULL || *symname == 0)
1665 (*_bfd_error_handler)
1666 (_("%s: register relocation against non-register symbol: (unknown) in %s"),
1667 bfd_get_filename (input_section->owner),
1668 bfd_get_section_name (symsec->owner, symsec));
1670 (*_bfd_error_handler)
1671 (_("%s: register relocation against non-register symbol: %s in %s"),
1672 bfd_get_filename (input_section->owner), symname,
1673 bfd_get_section_name (symsec->owner, symsec));
1675 /* The bfd_reloc_outofrange return value, though intuitively a
1676 better value, will not get us an error. */
1677 return bfd_reloc_overflow;
1680 contents += r_offset;
1681 r = mmix_elf_perform_relocation (input_section, howto, contents,
1682 addr, srel, error_message);
1686 /* This isn't a real relocation, it's just an assertion that the
1687 final relocation value corresponds to a local register. We
1688 ignore the actual relocation; nothing is changed. */
1691 = bfd_get_section_by_name (input_section->output_section->owner,
1692 MMIX_REG_CONTENTS_SECTION_NAME);
1693 bfd_vma first_global;
1695 /* Check that this is an absolute value, or a reference to the
1696 register contents section or the register (symbol) section.
1697 Absolute numbers can get here as undefined section. Undefined
1698 symbols are signalled elsewhere, so there's no conflict in us
1699 accidentally handling it. */
1700 if (!bfd_is_abs_section (symsec)
1701 && !bfd_is_und_section (symsec)
1702 && strcmp (bfd_get_section_name (symsec->owner, symsec),
1703 MMIX_REG_CONTENTS_SECTION_NAME) != 0
1704 && strcmp (bfd_get_section_name (symsec->owner, symsec),
1705 MMIX_REG_SECTION_NAME) != 0)
1707 (*_bfd_error_handler)
1708 (_("%s: directive LOCAL valid only with a register or absolute value"),
1709 bfd_get_filename (input_section->owner));
1711 return bfd_reloc_overflow;
1714 /* If we don't have a register contents section, then $255 is the
1715 first global register. */
1721 = bfd_get_section_vma (input_section->output_section->owner,
1723 if (strcmp (bfd_get_section_name (symsec->owner, symsec),
1724 MMIX_REG_CONTENTS_SECTION_NAME) == 0)
1726 if ((srel & 7) != 0 || srel < 32*8 || srel > 255*8)
1727 /* The bfd_reloc_outofrange return value, though
1728 intuitively a better value, will not get us an error. */
1729 return bfd_reloc_overflow;
1734 if ((bfd_vma) srel >= first_global)
1736 /* FIXME: Better error message. */
1737 (*_bfd_error_handler)
1738 (_("%s: LOCAL directive: Register $%ld is not a local register. First global register is $%ld."),
1739 bfd_get_filename (input_section->owner), (long) srel, (long) first_global);
1741 return bfd_reloc_overflow;
1748 r = _bfd_final_link_relocate (howto, input_section->owner, input_section,
1750 relocation, r_addend);
1756 /* Return the section that should be marked against GC for a given
1760 mmix_elf_gc_mark_hook (asection *sec,
1761 struct bfd_link_info *info,
1762 Elf_Internal_Rela *rel,
1763 struct elf_link_hash_entry *h,
1764 Elf_Internal_Sym *sym)
1767 switch (ELF64_R_TYPE (rel->r_info))
1769 case R_MMIX_GNU_VTINHERIT:
1770 case R_MMIX_GNU_VTENTRY:
1774 return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
1777 /* Update relocation info for a GC-excluded section. We could supposedly
1778 perform the allocation after GC, but there's no suitable hook between
1779 GC (or section merge) and the point when all input sections must be
1780 present. Better to waste some memory and (perhaps) a little time. */
1783 mmix_elf_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
1784 struct bfd_link_info *info ATTRIBUTE_UNUSED,
1786 const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
1788 struct bpo_reloc_section_info *bpodata
1789 = mmix_elf_section_data (sec)->bpo.reloc;
1790 asection *allocated_gregs_section;
1792 /* If no bpodata here, we have nothing to do. */
1793 if (bpodata == NULL)
1796 allocated_gregs_section = bpodata->bpo_greg_section;
1798 mmix_elf_section_data (allocated_gregs_section)->bpo.greg->n_bpo_relocs
1799 -= bpodata->n_bpo_relocs_this_section;
1804 /* Sort register relocs to come before expanding relocs. */
1807 mmix_elf_sort_relocs (const void * p1, const void * p2)
1809 const Elf_Internal_Rela *r1 = (const Elf_Internal_Rela *) p1;
1810 const Elf_Internal_Rela *r2 = (const Elf_Internal_Rela *) p2;
1811 int r1_is_reg, r2_is_reg;
1813 /* Sort primarily on r_offset & ~3, so relocs are done to consecutive
1815 if ((r1->r_offset & ~(bfd_vma) 3) > (r2->r_offset & ~(bfd_vma) 3))
1817 else if ((r1->r_offset & ~(bfd_vma) 3) < (r2->r_offset & ~(bfd_vma) 3))
1821 = (ELF64_R_TYPE (r1->r_info) == R_MMIX_REG_OR_BYTE
1822 || ELF64_R_TYPE (r1->r_info) == R_MMIX_REG);
1824 = (ELF64_R_TYPE (r2->r_info) == R_MMIX_REG_OR_BYTE
1825 || ELF64_R_TYPE (r2->r_info) == R_MMIX_REG);
1826 if (r1_is_reg != r2_is_reg)
1827 return r2_is_reg - r1_is_reg;
1829 /* Neither or both are register relocs. Then sort on full offset. */
1830 if (r1->r_offset > r2->r_offset)
1832 else if (r1->r_offset < r2->r_offset)
1837 /* Subset of mmix_elf_check_relocs, common to ELF and mmo linking. */
1840 mmix_elf_check_common_relocs (bfd *abfd,
1841 struct bfd_link_info *info,
1843 const Elf_Internal_Rela *relocs)
1845 bfd *bpo_greg_owner = NULL;
1846 asection *allocated_gregs_section = NULL;
1847 struct bpo_greg_section_info *gregdata = NULL;
1848 struct bpo_reloc_section_info *bpodata = NULL;
1849 const Elf_Internal_Rela *rel;
1850 const Elf_Internal_Rela *rel_end;
1852 /* We currently have to abuse this COFF-specific member, since there's
1853 no target-machine-dedicated member. There's no alternative outside
1854 the bfd_link_info struct; we can't specialize a hash-table since
1855 they're different between ELF and mmo. */
1856 bpo_greg_owner = (bfd *) info->base_file;
1858 rel_end = relocs + sec->reloc_count;
1859 for (rel = relocs; rel < rel_end; rel++)
1861 switch (ELF64_R_TYPE (rel->r_info))
1863 /* This relocation causes a GREG allocation. We need to count
1864 them, and we need to create a section for them, so we need an
1865 object to fake as the owner of that section. We can't use
1866 the ELF dynobj for this, since the ELF bits assume lots of
1867 DSO-related stuff if that member is non-NULL. */
1868 case R_MMIX_BASE_PLUS_OFFSET:
1869 /* We don't do anything with this reloc for a relocatable link. */
1870 if (info->relocatable)
1873 if (bpo_greg_owner == NULL)
1875 bpo_greg_owner = abfd;
1876 info->base_file = bpo_greg_owner;
1879 if (allocated_gregs_section == NULL)
1880 allocated_gregs_section
1881 = bfd_get_section_by_name (bpo_greg_owner,
1882 MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME);
1884 if (allocated_gregs_section == NULL)
1886 allocated_gregs_section
1887 = bfd_make_section_with_flags (bpo_greg_owner,
1888 MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME,
1891 | SEC_LINKER_CREATED));
1892 /* Setting both SEC_ALLOC and SEC_LOAD means the section is
1893 treated like any other section, and we'd get errors for
1894 address overlap with the text section. Let's set none of
1895 those flags, as that is what currently happens for usual
1896 GREG allocations, and that works. */
1897 if (allocated_gregs_section == NULL
1898 || !bfd_set_section_alignment (bpo_greg_owner,
1899 allocated_gregs_section,
1903 gregdata = (struct bpo_greg_section_info *)
1904 bfd_zalloc (bpo_greg_owner, sizeof (struct bpo_greg_section_info));
1905 if (gregdata == NULL)
1907 mmix_elf_section_data (allocated_gregs_section)->bpo.greg
1910 else if (gregdata == NULL)
1912 = mmix_elf_section_data (allocated_gregs_section)->bpo.greg;
1914 /* Get ourselves some auxiliary info for the BPO-relocs. */
1915 if (bpodata == NULL)
1917 /* No use doing a separate iteration pass to find the upper
1918 limit - just use the number of relocs. */
1919 bpodata = (struct bpo_reloc_section_info *)
1920 bfd_alloc (bpo_greg_owner,
1921 sizeof (struct bpo_reloc_section_info)
1922 * (sec->reloc_count + 1));
1923 if (bpodata == NULL)
1925 mmix_elf_section_data (sec)->bpo.reloc = bpodata;
1926 bpodata->first_base_plus_offset_reloc
1927 = bpodata->bpo_index
1928 = gregdata->n_max_bpo_relocs;
1929 bpodata->bpo_greg_section
1930 = allocated_gregs_section;
1931 bpodata->n_bpo_relocs_this_section = 0;
1934 bpodata->n_bpo_relocs_this_section++;
1935 gregdata->n_max_bpo_relocs++;
1937 /* We don't get another chance to set this before GC; we've not
1938 set up any hook that runs before GC. */
1939 gregdata->n_bpo_relocs
1940 = gregdata->n_max_bpo_relocs;
1943 case R_MMIX_PUSHJ_STUBBABLE:
1944 mmix_elf_section_data (sec)->pjs.n_pushj_relocs++;
1949 /* Allocate per-reloc stub storage and initialize it to the max stub
1951 if (mmix_elf_section_data (sec)->pjs.n_pushj_relocs != 0)
1955 mmix_elf_section_data (sec)->pjs.stub_size
1956 = bfd_alloc (abfd, mmix_elf_section_data (sec)->pjs.n_pushj_relocs
1957 * sizeof (mmix_elf_section_data (sec)
1958 ->pjs.stub_size[0]));
1959 if (mmix_elf_section_data (sec)->pjs.stub_size == NULL)
1962 for (i = 0; i < mmix_elf_section_data (sec)->pjs.n_pushj_relocs; i++)
1963 mmix_elf_section_data (sec)->pjs.stub_size[i] = MAX_PUSHJ_STUB_SIZE;
1969 /* Look through the relocs for a section during the first phase. */
1972 mmix_elf_check_relocs (bfd *abfd,
1973 struct bfd_link_info *info,
1975 const Elf_Internal_Rela *relocs)
1977 Elf_Internal_Shdr *symtab_hdr;
1978 struct elf_link_hash_entry **sym_hashes;
1979 const Elf_Internal_Rela *rel;
1980 const Elf_Internal_Rela *rel_end;
1982 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
1983 sym_hashes = elf_sym_hashes (abfd);
1985 /* First we sort the relocs so that any register relocs come before
1986 expansion-relocs to the same insn. FIXME: Not done for mmo. */
1987 qsort ((void *) relocs, sec->reloc_count, sizeof (Elf_Internal_Rela),
1988 mmix_elf_sort_relocs);
1990 /* Do the common part. */
1991 if (!mmix_elf_check_common_relocs (abfd, info, sec, relocs))
1994 if (info->relocatable)
1997 rel_end = relocs + sec->reloc_count;
1998 for (rel = relocs; rel < rel_end; rel++)
2000 struct elf_link_hash_entry *h;
2001 unsigned long r_symndx;
2003 r_symndx = ELF64_R_SYM (rel->r_info);
2004 if (r_symndx < symtab_hdr->sh_info)
2008 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
2009 while (h->root.type == bfd_link_hash_indirect
2010 || h->root.type == bfd_link_hash_warning)
2011 h = (struct elf_link_hash_entry *) h->root.u.i.link;
2014 switch (ELF64_R_TYPE (rel->r_info))
2016 /* This relocation describes the C++ object vtable hierarchy.
2017 Reconstruct it for later use during GC. */
2018 case R_MMIX_GNU_VTINHERIT:
2019 if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
2023 /* This relocation describes which C++ vtable entries are actually
2024 used. Record for later use during GC. */
2025 case R_MMIX_GNU_VTENTRY:
2026 BFD_ASSERT (h != NULL);
2028 && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
2037 /* Wrapper for mmix_elf_check_common_relocs, called when linking to mmo.
2038 Copied from elf_link_add_object_symbols. */
2041 _bfd_mmix_check_all_relocs (bfd *abfd, struct bfd_link_info *info)
2045 for (o = abfd->sections; o != NULL; o = o->next)
2047 Elf_Internal_Rela *internal_relocs;
2050 if ((o->flags & SEC_RELOC) == 0
2051 || o->reloc_count == 0
2052 || ((info->strip == strip_all || info->strip == strip_debugger)
2053 && (o->flags & SEC_DEBUGGING) != 0)
2054 || bfd_is_abs_section (o->output_section))
2058 = _bfd_elf_link_read_relocs (abfd, o, NULL,
2059 (Elf_Internal_Rela *) NULL,
2061 if (internal_relocs == NULL)
2064 ok = mmix_elf_check_common_relocs (abfd, info, o, internal_relocs);
2066 if (! info->keep_memory)
2067 free (internal_relocs);
2076 /* Change symbols relative to the reg contents section to instead be to
2077 the register section, and scale them down to correspond to the register
2081 mmix_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
2082 const char *name ATTRIBUTE_UNUSED,
2083 Elf_Internal_Sym *sym,
2084 asection *input_sec,
2085 struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
2087 if (input_sec != NULL
2088 && input_sec->name != NULL
2089 && ELF_ST_TYPE (sym->st_info) != STT_SECTION
2090 && strcmp (input_sec->name, MMIX_REG_CONTENTS_SECTION_NAME) == 0)
2093 sym->st_shndx = SHN_REGISTER;
2099 /* We fake a register section that holds values that are register numbers.
2100 Having a SHN_REGISTER and register section translates better to other
2101 formats (e.g. mmo) than for example a STT_REGISTER attribute.
2102 This section faking is based on a construct in elf32-mips.c. */
2103 static asection mmix_elf_reg_section;
2104 static asymbol mmix_elf_reg_section_symbol;
2105 static asymbol *mmix_elf_reg_section_symbol_ptr;
2107 /* Handle the special section numbers that a symbol may use. */
2110 mmix_elf_symbol_processing (abfd, asym)
2111 bfd *abfd ATTRIBUTE_UNUSED;
2114 elf_symbol_type *elfsym;
2116 elfsym = (elf_symbol_type *) asym;
2117 switch (elfsym->internal_elf_sym.st_shndx)
2120 if (mmix_elf_reg_section.name == NULL)
2122 /* Initialize the register section. */
2123 mmix_elf_reg_section.name = MMIX_REG_SECTION_NAME;
2124 mmix_elf_reg_section.flags = SEC_NO_FLAGS;
2125 mmix_elf_reg_section.output_section = &mmix_elf_reg_section;
2126 mmix_elf_reg_section.symbol = &mmix_elf_reg_section_symbol;
2127 mmix_elf_reg_section.symbol_ptr_ptr = &mmix_elf_reg_section_symbol_ptr;
2128 mmix_elf_reg_section_symbol.name = MMIX_REG_SECTION_NAME;
2129 mmix_elf_reg_section_symbol.flags = BSF_SECTION_SYM;
2130 mmix_elf_reg_section_symbol.section = &mmix_elf_reg_section;
2131 mmix_elf_reg_section_symbol_ptr = &mmix_elf_reg_section_symbol;
2133 asym->section = &mmix_elf_reg_section;
2141 /* Given a BFD section, try to locate the corresponding ELF section
2145 mmix_elf_section_from_bfd_section (bfd * abfd ATTRIBUTE_UNUSED,
2149 if (strcmp (bfd_get_section_name (abfd, sec), MMIX_REG_SECTION_NAME) == 0)
2150 *retval = SHN_REGISTER;
2157 /* Hook called by the linker routine which adds symbols from an object
2158 file. We must handle the special SHN_REGISTER section number here.
2160 We also check that we only have *one* each of the section-start
2161 symbols, since otherwise having two with the same value would cause
2162 them to be "merged", but with the contents serialized. */
2165 mmix_elf_add_symbol_hook (bfd *abfd,
2166 struct bfd_link_info *info ATTRIBUTE_UNUSED,
2167 Elf_Internal_Sym *sym,
2168 const char **namep ATTRIBUTE_UNUSED,
2169 flagword *flagsp ATTRIBUTE_UNUSED,
2171 bfd_vma *valp ATTRIBUTE_UNUSED)
2173 if (sym->st_shndx == SHN_REGISTER)
2175 *secp = bfd_make_section_old_way (abfd, MMIX_REG_SECTION_NAME);
2176 (*secp)->flags |= SEC_LINKER_CREATED;
2178 else if ((*namep)[0] == '_' && (*namep)[1] == '_' && (*namep)[2] == '.'
2179 && CONST_STRNEQ (*namep, MMIX_LOC_SECTION_START_SYMBOL_PREFIX))
2181 /* See if we have another one. */
2182 struct bfd_link_hash_entry *h = bfd_link_hash_lookup (info->hash,
2188 if (h != NULL && h->type != bfd_link_hash_undefined)
2190 /* How do we get the asymbol (or really: the filename) from h?
2191 h->u.def.section->owner is NULL. */
2192 ((*_bfd_error_handler)
2193 (_("%s: Error: multiple definition of `%s'; start of %s is set in a earlier linked file\n"),
2194 bfd_get_filename (abfd), *namep,
2195 *namep + strlen (MMIX_LOC_SECTION_START_SYMBOL_PREFIX)));
2196 bfd_set_error (bfd_error_bad_value);
2204 /* We consider symbols matching "L.*:[0-9]+" to be local symbols. */
2207 mmix_elf_is_local_label_name (bfd *abfd, const char *name)
2212 /* Also include the default local-label definition. */
2213 if (_bfd_elf_is_local_label_name (abfd, name))
2219 /* If there's no ":", or more than one, it's not a local symbol. */
2220 colpos = strchr (name, ':');
2221 if (colpos == NULL || strchr (colpos + 1, ':') != NULL)
2224 /* Check that there are remaining characters and that they are digits. */
2228 digits = strspn (colpos + 1, "0123456789");
2229 return digits != 0 && colpos[1 + digits] == 0;
2232 /* We get rid of the register section here. */
2235 mmix_elf_final_link (bfd *abfd, struct bfd_link_info *info)
2237 /* We never output a register section, though we create one for
2238 temporary measures. Check that nobody entered contents into it. */
2239 asection *reg_section;
2241 reg_section = bfd_get_section_by_name (abfd, MMIX_REG_SECTION_NAME);
2243 if (reg_section != NULL)
2245 /* FIXME: Pass error state gracefully. */
2246 if (bfd_get_section_flags (abfd, reg_section) & SEC_HAS_CONTENTS)
2247 _bfd_abort (__FILE__, __LINE__, _("Register section has contents\n"));
2249 /* Really remove the section, if it hasn't already been done. */
2250 if (!bfd_section_removed_from_list (abfd, reg_section))
2252 bfd_section_list_remove (abfd, reg_section);
2253 --abfd->section_count;
2257 if (! bfd_elf_final_link (abfd, info))
2260 /* Since this section is marked SEC_LINKER_CREATED, it isn't output by
2261 the regular linker machinery. We do it here, like other targets with
2262 special sections. */
2263 if (info->base_file != NULL)
2265 asection *greg_section
2266 = bfd_get_section_by_name ((bfd *) info->base_file,
2267 MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME);
2268 if (!bfd_set_section_contents (abfd,
2269 greg_section->output_section,
2270 greg_section->contents,
2271 (file_ptr) greg_section->output_offset,
2272 greg_section->size))
2278 /* We need to include the maximum size of PUSHJ-stubs in the initial
2279 section size. This is expected to shrink during linker relaxation. */
2282 mmix_set_relaxable_size (bfd *abfd ATTRIBUTE_UNUSED,
2286 struct bfd_link_info *info = ptr;
2288 /* Make sure we only do this for section where we know we want this,
2289 otherwise we might end up resetting the size of COMMONs. */
2290 if (mmix_elf_section_data (sec)->pjs.n_pushj_relocs == 0)
2293 sec->rawsize = sec->size;
2294 sec->size += (mmix_elf_section_data (sec)->pjs.n_pushj_relocs
2295 * MAX_PUSHJ_STUB_SIZE);
2297 /* For use in relocatable link, we start with a max stubs size. See
2298 mmix_elf_relax_section. */
2299 if (info->relocatable && sec->output_section)
2300 mmix_elf_section_data (sec->output_section)->pjs.stubs_size_sum
2301 += (mmix_elf_section_data (sec)->pjs.n_pushj_relocs
2302 * MAX_PUSHJ_STUB_SIZE);
2305 /* Initialize stuff for the linker-generated GREGs to match
2306 R_MMIX_BASE_PLUS_OFFSET relocs seen by the linker. */
2309 _bfd_mmix_before_linker_allocation (bfd *abfd ATTRIBUTE_UNUSED,
2310 struct bfd_link_info *info)
2312 asection *bpo_gregs_section;
2313 bfd *bpo_greg_owner;
2314 struct bpo_greg_section_info *gregdata;
2318 size_t *bpo_reloc_indexes;
2321 /* Set the initial size of sections. */
2322 for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
2323 bfd_map_over_sections (ibfd, mmix_set_relaxable_size, info);
2325 /* The bpo_greg_owner bfd is supposed to have been set by
2326 mmix_elf_check_relocs when the first R_MMIX_BASE_PLUS_OFFSET is seen.
2327 If there is no such object, there was no R_MMIX_BASE_PLUS_OFFSET. */
2328 bpo_greg_owner = (bfd *) info->base_file;
2329 if (bpo_greg_owner == NULL)
2333 = bfd_get_section_by_name (bpo_greg_owner,
2334 MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME);
2336 if (bpo_gregs_section == NULL)
2339 /* We use the target-data handle in the ELF section data. */
2340 gregdata = mmix_elf_section_data (bpo_gregs_section)->bpo.greg;
2341 if (gregdata == NULL)
2344 n_gregs = gregdata->n_bpo_relocs;
2345 gregdata->n_allocated_bpo_gregs = n_gregs;
2347 /* When this reaches zero during relaxation, all entries have been
2348 filled in and the size of the linker gregs can be calculated. */
2349 gregdata->n_remaining_bpo_relocs_this_relaxation_round = n_gregs;
2351 /* Set the zeroth-order estimate for the GREGs size. */
2352 gregs_size = n_gregs * 8;
2354 if (!bfd_set_section_size (bpo_greg_owner, bpo_gregs_section, gregs_size))
2357 /* Allocate and set up the GREG arrays. They're filled in at relaxation
2358 time. Note that we must use the max number ever noted for the array,
2359 since the index numbers were created before GC. */
2360 gregdata->reloc_request
2361 = bfd_zalloc (bpo_greg_owner,
2362 sizeof (struct bpo_reloc_request)
2363 * gregdata->n_max_bpo_relocs);
2365 gregdata->bpo_reloc_indexes
2367 = bfd_alloc (bpo_greg_owner,
2368 gregdata->n_max_bpo_relocs
2370 if (bpo_reloc_indexes == NULL)
2373 /* The default order is an identity mapping. */
2374 for (i = 0; i < gregdata->n_max_bpo_relocs; i++)
2376 bpo_reloc_indexes[i] = i;
2377 gregdata->reloc_request[i].bpo_reloc_no = i;
2383 /* Fill in contents in the linker allocated gregs. Everything is
2384 calculated at this point; we just move the contents into place here. */
2387 _bfd_mmix_after_linker_allocation (bfd *abfd ATTRIBUTE_UNUSED,
2388 struct bfd_link_info *link_info)
2390 asection *bpo_gregs_section;
2391 bfd *bpo_greg_owner;
2392 struct bpo_greg_section_info *gregdata;
2398 /* The bpo_greg_owner bfd is supposed to have been set by mmix_elf_check_relocs
2399 when the first R_MMIX_BASE_PLUS_OFFSET is seen. If there is no such
2400 object, there was no R_MMIX_BASE_PLUS_OFFSET. */
2401 bpo_greg_owner = (bfd *) link_info->base_file;
2402 if (bpo_greg_owner == NULL)
2406 = bfd_get_section_by_name (bpo_greg_owner,
2407 MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME);
2409 /* This can't happen without DSO handling. When DSOs are handled
2410 without any R_MMIX_BASE_PLUS_OFFSET seen, there will be no such
2412 if (bpo_gregs_section == NULL)
2415 /* We use the target-data handle in the ELF section data. */
2417 gregdata = mmix_elf_section_data (bpo_gregs_section)->bpo.greg;
2418 if (gregdata == NULL)
2421 n_gregs = gregdata->n_allocated_bpo_gregs;
2423 bpo_gregs_section->contents
2424 = contents = bfd_alloc (bpo_greg_owner, bpo_gregs_section->size);
2425 if (contents == NULL)
2428 /* Sanity check: If these numbers mismatch, some relocation has not been
2429 accounted for and the rest of gregdata is probably inconsistent.
2430 It's a bug, but it's more helpful to identify it than segfaulting
2432 if (gregdata->n_remaining_bpo_relocs_this_relaxation_round
2433 != gregdata->n_bpo_relocs)
2435 (*_bfd_error_handler)
2436 (_("Internal inconsistency: remaining %u != max %u.\n\
2437 Please report this bug."),
2438 gregdata->n_remaining_bpo_relocs_this_relaxation_round,
2439 gregdata->n_bpo_relocs);
2443 for (lastreg = 255, i = 0, j = 0; j < n_gregs; i++)
2444 if (gregdata->reloc_request[i].regindex != lastreg)
2446 bfd_put_64 (bpo_greg_owner, gregdata->reloc_request[i].value,
2448 lastreg = gregdata->reloc_request[i].regindex;
2455 /* Sort valid relocs to come before non-valid relocs, then on increasing
2459 bpo_reloc_request_sort_fn (const void * p1, const void * p2)
2461 const struct bpo_reloc_request *r1 = (const struct bpo_reloc_request *) p1;
2462 const struct bpo_reloc_request *r2 = (const struct bpo_reloc_request *) p2;
2464 /* Primary function is validity; non-valid relocs sorted after valid
2466 if (r1->valid != r2->valid)
2467 return r2->valid - r1->valid;
2469 /* Then sort on value. Don't simplify and return just the difference of
2470 the values: the upper bits of the 64-bit value would be truncated on
2471 a host with 32-bit ints. */
2472 if (r1->value != r2->value)
2473 return r1->value > r2->value ? 1 : -1;
2475 /* As a last re-sort, use the relocation number, so we get a stable
2476 sort. The *addresses* aren't stable since items are swapped during
2477 sorting. It depends on the qsort implementation if this actually
2479 return r1->bpo_reloc_no > r2->bpo_reloc_no
2480 ? 1 : (r1->bpo_reloc_no < r2->bpo_reloc_no ? -1 : 0);
2483 /* For debug use only. Dumps the global register allocations resulting
2484 from base-plus-offset relocs. */
2487 mmix_dump_bpo_gregs (link_info, pf)
2488 struct bfd_link_info *link_info;
2489 bfd_error_handler_type pf;
2491 bfd *bpo_greg_owner;
2492 asection *bpo_gregs_section;
2493 struct bpo_greg_section_info *gregdata;
2496 if (link_info == NULL || link_info->base_file == NULL)
2499 bpo_greg_owner = (bfd *) link_info->base_file;
2502 = bfd_get_section_by_name (bpo_greg_owner,
2503 MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME);
2505 if (bpo_gregs_section == NULL)
2508 gregdata = mmix_elf_section_data (bpo_gregs_section)->bpo.greg;
2509 if (gregdata == NULL)
2513 pf = _bfd_error_handler;
2515 /* These format strings are not translated. They are for debug purposes
2516 only and never displayed to an end user. Should they escape, we
2517 surely want them in original. */
2518 (*pf) (" n_bpo_relocs: %u\n n_max_bpo_relocs: %u\n n_remain...round: %u\n\
2519 n_allocated_bpo_gregs: %u\n", gregdata->n_bpo_relocs,
2520 gregdata->n_max_bpo_relocs,
2521 gregdata->n_remaining_bpo_relocs_this_relaxation_round,
2522 gregdata->n_allocated_bpo_gregs);
2524 if (gregdata->reloc_request)
2525 for (i = 0; i < gregdata->n_max_bpo_relocs; i++)
2526 (*pf) ("%4u (%4u)/%4u#%u: 0x%08lx%08lx r: %3u o: %3u\n",
2528 (gregdata->bpo_reloc_indexes != NULL
2529 ? gregdata->bpo_reloc_indexes[i] : (size_t) -1),
2530 gregdata->reloc_request[i].bpo_reloc_no,
2531 gregdata->reloc_request[i].valid,
2533 (unsigned long) (gregdata->reloc_request[i].value >> 32),
2534 (unsigned long) gregdata->reloc_request[i].value,
2535 gregdata->reloc_request[i].regindex,
2536 gregdata->reloc_request[i].offset);
2539 /* This links all R_MMIX_BASE_PLUS_OFFSET relocs into a special array, and
2540 when the last such reloc is done, an index-array is sorted according to
2541 the values and iterated over to produce register numbers (indexed by 0
2542 from the first allocated register number) and offsets for use in real
2543 relocation. (N.B.: Relocatable runs are handled, not just punted.)
2545 PUSHJ stub accounting is also done here.
2547 Symbol- and reloc-reading infrastructure copied from elf-m10200.c. */
2550 mmix_elf_relax_section (bfd *abfd,
2552 struct bfd_link_info *link_info,
2555 Elf_Internal_Shdr *symtab_hdr;
2556 Elf_Internal_Rela *internal_relocs;
2557 Elf_Internal_Rela *irel, *irelend;
2558 asection *bpo_gregs_section = NULL;
2559 struct bpo_greg_section_info *gregdata;
2560 struct bpo_reloc_section_info *bpodata
2561 = mmix_elf_section_data (sec)->bpo.reloc;
2562 /* The initialization is to quiet compiler warnings. The value is to
2563 spot a missing actual initialization. */
2564 size_t bpono = (size_t) -1;
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 if (bpodata != NULL)
2590 bpo_gregs_section = bpodata->bpo_greg_section;
2591 gregdata = mmix_elf_section_data (bpo_gregs_section)->bpo.greg;
2592 bpono = bpodata->first_base_plus_offset_reloc;
2597 /* Get a copy of the native relocations. */
2599 = _bfd_elf_link_read_relocs (abfd, sec, NULL,
2600 (Elf_Internal_Rela *) NULL,
2601 link_info->keep_memory);
2602 if (internal_relocs == NULL)
2605 /* Walk through them looking for relaxing opportunities. */
2606 irelend = internal_relocs + sec->reloc_count;
2607 for (irel = internal_relocs; irel < irelend; irel++)
2610 struct elf_link_hash_entry *h = NULL;
2612 /* We only process two relocs. */
2613 if (ELF64_R_TYPE (irel->r_info) != (int) R_MMIX_BASE_PLUS_OFFSET
2614 && ELF64_R_TYPE (irel->r_info) != (int) R_MMIX_PUSHJ_STUBBABLE)
2617 /* We process relocs in a distinctly different way when this is a
2618 relocatable link (for one, we don't look at symbols), so we avoid
2619 mixing its code with that for the "normal" relaxation. */
2620 if (link_info->relocatable)
2622 /* The only transformation in a relocatable link is to generate
2623 a full stub at the location of the stub calculated for the
2624 input section, if the relocated stub location, the end of the
2625 output section plus earlier stubs, cannot be reached. Thus
2626 relocatable linking can only lead to worse code, but it still
2628 if (ELF64_R_TYPE (irel->r_info) == R_MMIX_PUSHJ_STUBBABLE)
2630 /* If we can reach the end of the output-section and beyond
2631 any current stubs, then we don't need a stub for this
2632 reloc. The relaxed order of output stub allocation may
2633 not exactly match the straightforward order, so we always
2634 assume presence of output stubs, which will allow
2635 relaxation only on relocations indifferent to the
2636 presence of output stub allocations for other relocations
2637 and thus the order of output stub allocation. */
2638 if (bfd_check_overflow (complain_overflow_signed,
2641 bfd_arch_bits_per_address (abfd),
2642 /* Output-stub location. */
2643 sec->output_section->rawsize
2644 + (mmix_elf_section_data (sec
2646 ->pjs.stubs_size_sum)
2647 /* Location of this PUSHJ reloc. */
2648 - (sec->output_offset + irel->r_offset)
2649 /* Don't count *this* stub twice. */
2650 - (mmix_elf_section_data (sec)
2651 ->pjs.stub_size[pjsno]
2652 + MAX_PUSHJ_STUB_SIZE))
2654 mmix_elf_section_data (sec)->pjs.stub_size[pjsno] = 0;
2656 mmix_elf_section_data (sec)->pjs.stubs_size_sum
2657 += mmix_elf_section_data (sec)->pjs.stub_size[pjsno];
2665 /* Get the value of the symbol referred to by the reloc. */
2666 if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
2668 /* A local symbol. */
2669 Elf_Internal_Sym *isym;
2672 /* Read this BFD's local symbols if we haven't already. */
2673 if (isymbuf == NULL)
2675 isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
2676 if (isymbuf == NULL)
2677 isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
2678 symtab_hdr->sh_info, 0,
2684 isym = isymbuf + ELF64_R_SYM (irel->r_info);
2685 if (isym->st_shndx == SHN_UNDEF)
2686 sym_sec = bfd_und_section_ptr;
2687 else if (isym->st_shndx == SHN_ABS)
2688 sym_sec = bfd_abs_section_ptr;
2689 else if (isym->st_shndx == SHN_COMMON)
2690 sym_sec = bfd_com_section_ptr;
2692 sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
2693 symval = (isym->st_value
2694 + sym_sec->output_section->vma
2695 + sym_sec->output_offset);
2701 /* An external symbol. */
2702 indx = ELF64_R_SYM (irel->r_info) - symtab_hdr->sh_info;
2703 h = elf_sym_hashes (abfd)[indx];
2704 BFD_ASSERT (h != NULL);
2705 if (h->root.type != bfd_link_hash_defined
2706 && h->root.type != bfd_link_hash_defweak)
2708 /* This appears to be a reference to an undefined symbol. Just
2709 ignore it--it will be caught by the regular reloc processing.
2710 We need to keep BPO reloc accounting consistent, though
2711 else we'll abort instead of emitting an error message. */
2712 if (ELF64_R_TYPE (irel->r_info) == R_MMIX_BASE_PLUS_OFFSET
2713 && gregdata != NULL)
2715 gregdata->n_remaining_bpo_relocs_this_relaxation_round--;
2721 symval = (h->root.u.def.value
2722 + h->root.u.def.section->output_section->vma
2723 + h->root.u.def.section->output_offset);
2726 if (ELF64_R_TYPE (irel->r_info) == (int) R_MMIX_PUSHJ_STUBBABLE)
2728 bfd_vma value = symval + irel->r_addend;
2730 = (sec->output_section->vma
2731 + sec->output_offset
2734 = (sec->output_section->vma
2735 + sec->output_offset
2737 + mmix_elf_section_data (sec)->pjs.stubs_size_sum);
2739 if ((value & 3) == 0
2740 && bfd_check_overflow (complain_overflow_signed,
2743 bfd_arch_bits_per_address (abfd),
2746 ? mmix_elf_section_data (sec)
2747 ->pjs.stub_size[pjsno]
2750 /* If the reloc fits, no stub is needed. */
2751 mmix_elf_section_data (sec)->pjs.stub_size[pjsno] = 0;
2753 /* Maybe we can get away with just a JMP insn? */
2754 if ((value & 3) == 0
2755 && bfd_check_overflow (complain_overflow_signed,
2758 bfd_arch_bits_per_address (abfd),
2761 ? mmix_elf_section_data (sec)
2762 ->pjs.stub_size[pjsno] - 4
2765 /* Yep, account for a stub consisting of a single JMP insn. */
2766 mmix_elf_section_data (sec)->pjs.stub_size[pjsno] = 4;
2768 /* Nope, go for the full insn stub. It doesn't seem useful to
2769 emit the intermediate sizes; those will only be useful for
2770 a >64M program assuming contiguous code. */
2771 mmix_elf_section_data (sec)->pjs.stub_size[pjsno]
2772 = MAX_PUSHJ_STUB_SIZE;
2774 mmix_elf_section_data (sec)->pjs.stubs_size_sum
2775 += mmix_elf_section_data (sec)->pjs.stub_size[pjsno];
2780 /* We're looking at a R_MMIX_BASE_PLUS_OFFSET reloc. */
2782 gregdata->reloc_request[gregdata->bpo_reloc_indexes[bpono]].value
2783 = symval + irel->r_addend;
2784 gregdata->reloc_request[gregdata->bpo_reloc_indexes[bpono++]].valid = TRUE;
2785 gregdata->n_remaining_bpo_relocs_this_relaxation_round--;
2788 /* Check if that was the last BPO-reloc. If so, sort the values and
2789 calculate how many registers we need to cover them. Set the size of
2790 the linker gregs, and if the number of registers changed, indicate
2791 that we need to relax some more because we have more work to do. */
2792 if (gregdata != NULL
2793 && gregdata->n_remaining_bpo_relocs_this_relaxation_round == 0)
2799 /* First, reset the remaining relocs for the next round. */
2800 gregdata->n_remaining_bpo_relocs_this_relaxation_round
2801 = gregdata->n_bpo_relocs;
2803 qsort (gregdata->reloc_request,
2804 gregdata->n_max_bpo_relocs,
2805 sizeof (struct bpo_reloc_request),
2806 bpo_reloc_request_sort_fn);
2808 /* Recalculate indexes. When we find a change (however unlikely
2809 after the initial iteration), we know we need to relax again,
2810 since items in the GREG-array are sorted by increasing value and
2811 stored in the relaxation phase. */
2812 for (i = 0; i < gregdata->n_max_bpo_relocs; i++)
2813 if (gregdata->bpo_reloc_indexes[gregdata->reloc_request[i].bpo_reloc_no]
2816 gregdata->bpo_reloc_indexes[gregdata->reloc_request[i].bpo_reloc_no]
2821 /* Allocate register numbers (indexing from 0). Stop at the first
2823 for (i = 0, regindex = 0, prev_base = gregdata->reloc_request[0].value;
2824 i < gregdata->n_bpo_relocs;
2827 if (gregdata->reloc_request[i].value > prev_base + 255)
2830 prev_base = gregdata->reloc_request[i].value;
2832 gregdata->reloc_request[i].regindex = regindex;
2833 gregdata->reloc_request[i].offset
2834 = gregdata->reloc_request[i].value - prev_base;
2837 /* If it's not the same as the last time, we need to relax again,
2838 because the size of the section has changed. I'm not sure we
2839 actually need to do any adjustments since the shrinking happens
2840 at the start of this section, but better safe than sorry. */
2841 if (gregdata->n_allocated_bpo_gregs != regindex + 1)
2843 gregdata->n_allocated_bpo_gregs = regindex + 1;
2847 bpo_gregs_section->size = (regindex + 1) * 8;
2850 if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents)
2852 if (! link_info->keep_memory)
2856 /* Cache the symbols for elf_link_input_bfd. */
2857 symtab_hdr->contents = (unsigned char *) isymbuf;
2861 if (internal_relocs != NULL
2862 && elf_section_data (sec)->relocs != internal_relocs)
2863 free (internal_relocs);
2865 if (sec->size < size + mmix_elf_section_data (sec)->pjs.stubs_size_sum)
2868 if (sec->size > size + mmix_elf_section_data (sec)->pjs.stubs_size_sum)
2870 sec->size = size + mmix_elf_section_data (sec)->pjs.stubs_size_sum;
2877 if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents)
2879 if (internal_relocs != NULL
2880 && elf_section_data (sec)->relocs != internal_relocs)
2881 free (internal_relocs);
2885 #define ELF_ARCH bfd_arch_mmix
2886 #define ELF_MACHINE_CODE EM_MMIX
2888 /* According to mmix-doc page 36 (paragraph 45), this should be (1LL << 48LL).
2889 However, that's too much for something somewhere in the linker part of
2890 BFD; perhaps the start-address has to be a non-zero multiple of this
2891 number, or larger than this number. The symptom is that the linker
2892 complains: "warning: allocated section `.text' not in segment". We
2893 settle for 64k; the page-size used in examples is 8k.
2894 #define ELF_MAXPAGESIZE 0x10000
2896 Unfortunately, this causes excessive padding in the supposedly small
2897 for-education programs that are the expected usage (where people would
2898 inspect output). We stick to 256 bytes just to have *some* default
2900 #define ELF_MAXPAGESIZE 0x100
2902 #define TARGET_BIG_SYM bfd_elf64_mmix_vec
2903 #define TARGET_BIG_NAME "elf64-mmix"
2905 #define elf_info_to_howto_rel NULL
2906 #define elf_info_to_howto mmix_info_to_howto_rela
2907 #define elf_backend_relocate_section mmix_elf_relocate_section
2908 #define elf_backend_gc_mark_hook mmix_elf_gc_mark_hook
2909 #define elf_backend_gc_sweep_hook mmix_elf_gc_sweep_hook
2911 #define elf_backend_link_output_symbol_hook \
2912 mmix_elf_link_output_symbol_hook
2913 #define elf_backend_add_symbol_hook mmix_elf_add_symbol_hook
2915 #define elf_backend_check_relocs mmix_elf_check_relocs
2916 #define elf_backend_symbol_processing mmix_elf_symbol_processing
2917 #define elf_backend_omit_section_dynsym \
2918 ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
2920 #define bfd_elf64_bfd_is_local_label_name \
2921 mmix_elf_is_local_label_name
2923 #define elf_backend_may_use_rel_p 0
2924 #define elf_backend_may_use_rela_p 1
2925 #define elf_backend_default_use_rela_p 1
2927 #define elf_backend_can_gc_sections 1
2928 #define elf_backend_section_from_bfd_section \
2929 mmix_elf_section_from_bfd_section
2931 #define bfd_elf64_new_section_hook mmix_elf_new_section_hook
2932 #define bfd_elf64_bfd_final_link mmix_elf_final_link
2933 #define bfd_elf64_bfd_relax_section mmix_elf_relax_section
2935 #include "elf64-target.h"