1 /* MIPS-specific support for 32-bit ELF
2 Copyright 1993, 1994 Free Software Foundation, Inc.
4 Most of the information added by Ian Lance Taylor, Cygnus Support,
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 2 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
31 /* Get the ECOFF swapping routines. */
33 #include "coff/symconst.h"
34 #include "coff/internal.h"
35 #include "coff/ecoff.h"
36 #include "coff/mips.h"
38 #include "ecoffswap.h"
40 static bfd_reloc_status_type mips_elf_hi16_reloc PARAMS ((bfd *abfd,
47 static bfd_reloc_status_type mips_elf_got16_reloc PARAMS ((bfd *abfd,
54 static bfd_reloc_status_type mips_elf_lo16_reloc PARAMS ((bfd *abfd,
61 static bfd_reloc_status_type mips_elf_gprel16_reloc PARAMS ((bfd *abfd,
69 #define USE_REL 1 /* MIPS uses REL relocations instead of RELA */
75 R_MIPS_REL32, R_MIPS_26,
76 R_MIPS_HI16, R_MIPS_LO16,
77 R_MIPS_GPREL16, R_MIPS_LITERAL,
78 R_MIPS_GOT16, R_MIPS_PC16,
79 R_MIPS_CALL16, R_MIPS_GPREL32,
83 static reloc_howto_type elf_mips_howto_table[] =
86 HOWTO (R_MIPS_NONE, /* type */
88 0, /* size (0 = byte, 1 = short, 2 = long) */
90 false, /* pc_relative */
92 complain_overflow_dont, /* complain_on_overflow */
93 bfd_elf_generic_reloc, /* special_function */
94 "R_MIPS_NONE", /* name */
95 false, /* partial_inplace */
98 false), /* pcrel_offset */
100 /* 16 bit relocation. */
101 HOWTO (R_MIPS_16, /* type */
103 1, /* size (0 = byte, 1 = short, 2 = long) */
105 false, /* pc_relative */
107 complain_overflow_bitfield, /* complain_on_overflow */
108 bfd_elf_generic_reloc, /* special_function */
109 "R_MIPS_16", /* name */
110 true, /* partial_inplace */
111 0xffff, /* src_mask */
112 0xffff, /* dst_mask */
113 false), /* pcrel_offset */
115 /* 32 bit relocation. */
116 HOWTO (R_MIPS_32, /* type */
118 2, /* size (0 = byte, 1 = short, 2 = long) */
120 false, /* pc_relative */
122 complain_overflow_bitfield, /* complain_on_overflow */
123 bfd_elf_generic_reloc, /* special_function */
124 "R_MIPS_32", /* name */
125 true, /* partial_inplace */
126 0xffffffff, /* src_mask */
127 0xffffffff, /* dst_mask */
128 false), /* pcrel_offset */
130 /* 32 bit symbol relative relocation. */
131 HOWTO (R_MIPS_REL32, /* type */
133 2, /* size (0 = byte, 1 = short, 2 = long) */
135 false, /* pc_relative */
137 complain_overflow_bitfield, /* complain_on_overflow */
138 bfd_elf_generic_reloc, /* special_function */
139 "R_MIPS_REL32", /* name */
140 true, /* partial_inplace */
141 0xffffffff, /* src_mask */
142 0xffffffff, /* dst_mask */
143 false), /* pcrel_offset */
145 /* 26 bit branch address. */
146 HOWTO (R_MIPS_26, /* type */
148 2, /* size (0 = byte, 1 = short, 2 = long) */
150 false, /* pc_relative */
152 complain_overflow_dont, /* complain_on_overflow */
153 /* This needs complex overflow
154 detection, because the upper four
155 bits must match the PC. */
156 bfd_elf_generic_reloc, /* special_function */
157 "R_MIPS_26", /* name */
158 true, /* partial_inplace */
159 0x3ffffff, /* src_mask */
160 0x3ffffff, /* dst_mask */
161 false), /* pcrel_offset */
163 /* High 16 bits of symbol value. */
164 HOWTO (R_MIPS_HI16, /* type */
166 2, /* size (0 = byte, 1 = short, 2 = long) */
168 false, /* pc_relative */
170 complain_overflow_dont, /* complain_on_overflow */
171 mips_elf_hi16_reloc, /* special_function */
172 "R_MIPS_HI16", /* name */
173 true, /* partial_inplace */
174 0xffff, /* src_mask */
175 0xffff, /* dst_mask */
176 false), /* pcrel_offset */
178 /* Low 16 bits of symbol value. */
179 HOWTO (R_MIPS_LO16, /* type */
181 2, /* size (0 = byte, 1 = short, 2 = long) */
183 false, /* pc_relative */
185 complain_overflow_dont, /* complain_on_overflow */
186 mips_elf_lo16_reloc, /* special_function */
187 "R_MIPS_LO16", /* name */
188 true, /* partial_inplace */
189 0xffff, /* src_mask */
190 0xffff, /* dst_mask */
191 false), /* pcrel_offset */
193 /* GP relative reference. */
194 HOWTO (R_MIPS_GPREL16, /* type */
196 2, /* size (0 = byte, 1 = short, 2 = long) */
198 false, /* pc_relative */
200 complain_overflow_signed, /* complain_on_overflow */
201 mips_elf_gprel16_reloc, /* special_function */
202 "R_MIPS_GPREL16", /* name */
203 true, /* partial_inplace */
204 0xffff, /* src_mask */
205 0xffff, /* dst_mask */
206 false), /* pcrel_offset */
208 /* Reference to literal section. */
209 HOWTO (R_MIPS_LITERAL, /* type */
211 2, /* size (0 = byte, 1 = short, 2 = long) */
213 false, /* pc_relative */
215 complain_overflow_signed, /* complain_on_overflow */
216 mips_elf_gprel16_reloc, /* special_function */
217 "R_MIPS_LITERAL", /* name */
218 true, /* partial_inplace */
219 0xffff, /* src_mask */
220 0xffff, /* dst_mask */
221 false), /* pcrel_offset */
223 /* Reference to global offset table. */
224 /* FIXME: This is not handled correctly. */
225 HOWTO (R_MIPS_GOT16, /* type */
227 2, /* size (0 = byte, 1 = short, 2 = long) */
229 false, /* pc_relative */
231 complain_overflow_signed, /* complain_on_overflow */
232 mips_elf_got16_reloc, /* special_function */
233 "R_MIPS_GOT16", /* name */
234 false, /* partial_inplace */
236 0xffff, /* dst_mask */
237 false), /* pcrel_offset */
239 /* 16 bit PC relative reference. */
240 HOWTO (R_MIPS_PC16, /* type */
242 2, /* size (0 = byte, 1 = short, 2 = long) */
244 true, /* pc_relative */
246 complain_overflow_signed, /* complain_on_overflow */
247 bfd_elf_generic_reloc, /* special_function */
248 "R_MIPS_PC16", /* name */
249 true, /* partial_inplace */
250 0xffff, /* src_mask */
251 0xffff, /* dst_mask */
252 false), /* pcrel_offset */
254 /* 16 bit call through global offset table. */
255 /* FIXME: This is not handled correctly. */
256 HOWTO (R_MIPS_CALL16, /* type */
258 2, /* size (0 = byte, 1 = short, 2 = long) */
260 false, /* pc_relative */
262 complain_overflow_signed, /* complain_on_overflow */
263 bfd_elf_generic_reloc, /* special_function */
264 "R_MIPS_CALL16", /* name */
265 false, /* partial_inplace */
267 0xffff, /* dst_mask */
268 false), /* pcrel_offset */
270 /* 32 bit GP relative reference. */
271 /* FIXME: This is not handled correctly. */
272 HOWTO (R_MIPS_GPREL32, /* type */
274 2, /* size (0 = byte, 1 = short, 2 = long) */
276 false, /* pc_relative */
278 complain_overflow_bitfield, /* complain_on_overflow */
279 bfd_elf_generic_reloc, /* special_function */
280 "R_MIPS_GPREL32", /* name */
281 true, /* partial_inplace */
282 0xffffffff, /* src_mask */
283 0xffffffff, /* dst_mask */
284 false) /* pcrel_offset */
287 /* Do a R_MIPS_HI16 relocation. This has to be done in combination
288 with a R_MIPS_LO16 reloc, because there is a carry from the LO16 to
289 the HI16. Here we just save the information we need; we do the
290 actual relocation when we see the LO16. MIPS ELF requires that the
291 LO16 immediately follow the HI16, so this ought to work. */
293 static bfd_byte *mips_hi16_addr;
294 static bfd_vma mips_hi16_addend;
296 static bfd_reloc_status_type
297 mips_elf_hi16_reloc (abfd,
305 arelent *reloc_entry;
308 asection *input_section;
310 char **error_message;
312 bfd_reloc_status_type ret;
315 /* If we're relocating, and this an external symbol, we don't want
316 to change anything. */
317 if (output_bfd != (bfd *) NULL
318 && (symbol->flags & BSF_SECTION_SYM) == 0
319 && reloc_entry->addend == 0)
321 reloc_entry->address += input_section->output_offset;
325 /* FIXME: The symbol _gp_disp requires special handling, which we do
327 if (strcmp (bfd_asymbol_name (symbol), "_gp_disp") == 0)
331 if (symbol->section == &bfd_und_section
332 && output_bfd == (bfd *) NULL)
333 ret = bfd_reloc_undefined;
335 if (bfd_is_com_section (symbol->section))
338 relocation = symbol->value;
340 relocation += symbol->section->output_section->vma;
341 relocation += symbol->section->output_offset;
342 relocation += reloc_entry->addend;
344 if (reloc_entry->address > input_section->_cooked_size)
345 return bfd_reloc_outofrange;
347 /* Save the information, and let LO16 do the actual relocation. */
348 mips_hi16_addr = (bfd_byte *) data + reloc_entry->address;
349 mips_hi16_addend = relocation;
351 if (output_bfd != (bfd *) NULL)
352 reloc_entry->address += input_section->output_offset;
357 /* Do a R_MIPS_LO16 relocation. This is a straightforward 16 bit
358 inplace relocation; this function exists in order to do the
359 R_MIPS_HI16 relocation described above. */
361 static bfd_reloc_status_type
362 mips_elf_lo16_reloc (abfd,
370 arelent *reloc_entry;
373 asection *input_section;
375 char **error_message;
377 /* FIXME: The symbol _gp_disp requires special handling, which we do
379 if (output_bfd == (bfd *) NULL
380 && strcmp (bfd_asymbol_name (symbol), "_gp_disp") == 0)
383 if (mips_hi16_addr != (bfd_byte *) NULL)
389 /* Do the HI16 relocation. Note that we actually don't need to
390 know anything about the LO16 itself, except where to find the
391 low 16 bits of the addend needed by the LO16. */
392 insn = bfd_get_32 (abfd, mips_hi16_addr);
393 vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address)
395 val = ((insn & 0xffff) << 16) + vallo;
396 val += mips_hi16_addend;
398 /* The low order 16 bits are always treated as a signed value.
399 Therefore, a negative value in the low order bits requires an
400 adjustment in the high order bits. We need to make this
401 adjustment in two ways: once for the bits we took from the
402 data, and once for the bits we are putting back in to the
404 if ((vallo & 0x8000) != 0)
406 if ((val & 0x8000) != 0)
409 insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
410 bfd_put_32 (abfd, insn, mips_hi16_addr);
412 mips_hi16_addr = (bfd_byte *) NULL;
415 /* Now do the LO16 reloc in the usual way. */
416 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
417 input_section, output_bfd, error_message);
420 /* Do a R_MIPS_GOT16 reloc. This is a reloc against the global offset
421 table used for PIC code. If the symbol is an external symbol, the
422 instruction is modified to contain the offset of the appropriate
423 entry in the global offset table. If the symbol is a section
424 symbol, the next reloc is a R_MIPS_LO16 reloc. The two 16 bit
425 addends are combined to form the real addend against the section
426 symbol; the GOT16 is modified to contain the offset of an entry in
427 the global offset table, and the LO16 is modified to offset it
428 appropriately. Thus an offset larger than 16 bits requires a
429 modified value in the global offset table.
431 This implementation suffices for the assembler, but the linker does
432 not yet know how to create global offset tables. */
434 static bfd_reloc_status_type
435 mips_elf_got16_reloc (abfd,
443 arelent *reloc_entry;
446 asection *input_section;
448 char **error_message;
450 /* If we're relocating, and this an external symbol, we don't want
451 to change anything. */
452 if (output_bfd != (bfd *) NULL
453 && (symbol->flags & BSF_SECTION_SYM) == 0
454 && reloc_entry->addend == 0)
456 reloc_entry->address += input_section->output_offset;
460 /* If we're relocating, and this is a local symbol, we can handle it
462 if (output_bfd != (bfd *) NULL
463 && (symbol->flags & BSF_SECTION_SYM) != 0)
464 return mips_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
465 input_section, output_bfd, error_message);
470 /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
471 become the offset from the gp register. This function also handles
472 R_MIPS_LITERAL relocations, although those can be handled more
473 cleverly because the entries in the .lit8 and .lit4 sections can be
476 static bfd_reloc_status_type
477 mips_elf_gprel16_reloc (abfd,
485 arelent *reloc_entry;
488 asection *input_section;
490 char **error_message;
492 boolean relocateable;
497 /* If we're relocating, and this is an external symbol with no
498 addend, we don't want to change anything. We will only have an
499 addend if this is a newly created reloc, not read from an ELF
501 if (output_bfd != (bfd *) NULL
502 && (symbol->flags & BSF_SECTION_SYM) == 0
503 && reloc_entry->addend == 0)
505 reloc_entry->address += input_section->output_offset;
509 if (output_bfd != (bfd *) NULL)
513 relocateable = false;
514 output_bfd = symbol->section->output_section->owner;
517 if (symbol->section == &bfd_und_section
518 && relocateable == false)
519 return bfd_reloc_undefined;
521 /* We have to figure out the gp value, so that we can adjust the
522 symbol value correctly. We look up the symbol _gp in the output
523 BFD. If we can't find it, we're stuck. We cache it in the ELF
524 target data. We don't need to adjust the symbol value for an
525 external symbol if we are producing relocateable output. */
526 if (elf_gp (output_bfd) == 0
527 && (relocateable == false
528 || (symbol->flags & BSF_SECTION_SYM) != 0))
530 if (relocateable != false)
532 /* Make up a value. */
533 elf_gp (output_bfd) =
534 symbol->section->output_section->vma + 0x4000;
542 count = bfd_get_symcount (output_bfd);
543 sym = bfd_get_outsymbols (output_bfd);
545 if (sym == (asymbol **) NULL)
549 for (i = 0; i < count; i++, sym++)
551 register CONST char *name;
553 name = bfd_asymbol_name (*sym);
554 if (*name == '_' && strcmp (name, "_gp") == 0)
556 elf_gp (output_bfd) = bfd_asymbol_value (*sym);
564 /* Only get the error once. */
565 elf_gp (output_bfd) = 4;
567 (char *) "GP relative relocation when _gp not defined";
568 return bfd_reloc_dangerous;
573 if (bfd_is_com_section (symbol->section))
576 relocation = symbol->value;
578 relocation += symbol->section->output_section->vma;
579 relocation += symbol->section->output_offset;
581 if (reloc_entry->address > input_section->_cooked_size)
582 return bfd_reloc_outofrange;
584 insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
586 /* Set val to the offset into the section or symbol. */
587 val = ((insn & 0xffff) + reloc_entry->addend) & 0xffff;
591 /* Adjust val for the final section location and GP value. If we
592 are producing relocateable output, we don't want to do this for
593 an external symbol. */
594 if (relocateable == false
595 || (symbol->flags & BSF_SECTION_SYM) != 0)
596 val += relocation - elf_gp (output_bfd);
598 insn = (insn &~ 0xffff) | (val & 0xffff);
599 bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
601 if (relocateable != false)
602 reloc_entry->address += input_section->output_offset;
604 /* Make sure it fit in 16 bits. */
605 if (val >= 0x8000 && val < 0xffff8000)
606 return bfd_reloc_overflow;
611 /* A mapping from BFD reloc types to MIPS ELF reloc types. */
613 struct elf_reloc_map {
614 bfd_reloc_code_real_type bfd_reloc_val;
615 enum reloc_type elf_reloc_val;
618 static CONST struct elf_reloc_map mips_reloc_map[] =
620 { BFD_RELOC_NONE, R_MIPS_NONE, },
621 { BFD_RELOC_16, R_MIPS_16 },
622 { BFD_RELOC_32, R_MIPS_32 },
623 { BFD_RELOC_CTOR, R_MIPS_32 },
624 { BFD_RELOC_32_PCREL, R_MIPS_REL32 },
625 { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
626 { BFD_RELOC_HI16_S, R_MIPS_HI16 },
627 { BFD_RELOC_LO16, R_MIPS_LO16 },
628 { BFD_RELOC_MIPS_GPREL, R_MIPS_GPREL16 },
629 { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
630 { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
631 { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
632 { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
633 { BFD_RELOC_MIPS_GPREL32, R_MIPS_GPREL32 }
636 /* Given a BFD reloc type, return a howto structure. */
638 static CONST struct reloc_howto_struct *
639 bfd_elf32_bfd_reloc_type_lookup (abfd, code)
641 bfd_reloc_code_real_type code;
645 for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map); i++)
647 if (mips_reloc_map[i].bfd_reloc_val == code)
648 return &elf_mips_howto_table[(int) mips_reloc_map[i].elf_reloc_val];
653 /* Given a MIPS reloc type, fill in an arelent structure. */
656 mips_info_to_howto_rel (abfd, cache_ptr, dst)
659 Elf32_Internal_Rel *dst;
663 r_type = ELF32_R_TYPE (dst->r_info);
664 BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
665 cache_ptr->howto = &elf_mips_howto_table[r_type];
667 /* The addend for a GPREL16 or LITERAL relocation comes from the GP
668 value for the object file. We get the addend now, rather than
669 when we do the relocation, because the symbol manipulations done
670 by the linker may cause us to lose track of the input BFD. */
671 if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
672 && (r_type == (unsigned int) R_MIPS_GPREL16
673 || r_type == (unsigned int) R_MIPS_LITERAL))
674 cache_ptr->addend = elf_gp (abfd);
677 /* A .reginfo section holds a single Elf32_RegInfo structure. These
678 routines swap this structure in and out. They are used outside of
679 BFD, so they are globally visible. */
682 bfd_mips_elf32_swap_reginfo_in (abfd, ex, in)
684 const Elf32_External_RegInfo *ex;
687 in->ri_gprmask = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_gprmask);
688 in->ri_cprmask[0] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[0]);
689 in->ri_cprmask[1] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[1]);
690 in->ri_cprmask[2] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[2]);
691 in->ri_cprmask[3] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[3]);
692 in->ri_gp_value = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_gp_value);
696 bfd_mips_elf32_swap_reginfo_out (abfd, in, ex)
698 const Elf32_RegInfo *in;
699 Elf32_External_RegInfo *ex;
701 bfd_h_put_32 (abfd, (bfd_vma) in->ri_gprmask,
702 (bfd_byte *) ex->ri_gprmask);
703 bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[0],
704 (bfd_byte *) ex->ri_cprmask[0]);
705 bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[1],
706 (bfd_byte *) ex->ri_cprmask[1]);
707 bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[2],
708 (bfd_byte *) ex->ri_cprmask[2]);
709 bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[3],
710 (bfd_byte *) ex->ri_cprmask[3]);
711 bfd_h_put_32 (abfd, (bfd_vma) in->ri_gp_value,
712 (bfd_byte *) ex->ri_gp_value);
715 /* Determine whether a symbol is global for the purposes of splitting
716 the symbol table into global symbols and local symbols. At least
717 on Irix 5, this split must be between section symbols and all other
718 symbols. On most ELF targets the split is between static symbols
719 and externally visible symbols. */
723 mips_elf_sym_is_global (abfd, sym)
727 return (sym->flags & BSF_SECTION_SYM) == 0 ? true : false;
730 /* Set the right machine number for a MIPS ELF file. */
733 mips_elf_object_p (abfd)
736 switch (elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH)
740 /* Just use the default, which was set in elfcode.h. */
744 (void) bfd_default_set_arch_mach (abfd, bfd_arch_mips, 6000);
748 (void) bfd_default_set_arch_mach (abfd, bfd_arch_mips, 4000);
755 /* The final processing done just before writing out a MIPS ELF object
756 file. This gets the MIPS architecture right based on the machine
760 mips_elf_final_write_processing (abfd)
765 switch (bfd_get_mach (abfd))
783 elf_elfheader (abfd)->e_flags &=~ EF_MIPS_ARCH;
784 elf_elfheader (abfd)->e_flags |= val;
787 /* Handle a MIPS specific section when reading an object file. This
788 is called when elfcode.h finds a section with an unknown type.
789 FIXME: We need to handle the SHF_MIPS_GPREL flag, but I'm not sure
793 mips_elf_section_from_shdr (abfd, hdr, name)
795 Elf32_Internal_Shdr *hdr;
798 /* There ought to be a place to keep ELF backend specific flags, but
799 at the moment there isn't one. We just keep track of the
800 sections by their name, instead. Fortunately, the ABI gives
801 suggested names for all the MIPS specific sections, so we will
802 probably get away with this. */
803 switch (hdr->sh_type)
805 case SHT_MIPS_LIBLIST:
806 if (strcmp (name, ".liblist") != 0)
809 case SHT_MIPS_CONFLICT:
810 if (strcmp (name, ".conflict") != 0)
814 if (strncmp (name, ".gptab.", sizeof ".gptab." - 1) != 0)
818 if (strcmp (name, ".ucode") != 0)
822 if (strcmp (name, ".mdebug") != 0)
825 case SHT_MIPS_REGINFO:
826 if (strcmp (name, ".reginfo") != 0
827 || hdr->sh_size != sizeof (Elf32_External_RegInfo))
830 case SHT_MIPS_OPTIONS:
831 if (strcmp (name, ".options") != 0)
838 if (hdr->rawdata == NULL)
842 newsect = bfd_make_section (abfd, name);
845 newsect->filepos = hdr->sh_offset;
846 newsect->flags |= SEC_HAS_CONTENTS;
847 newsect->vma = hdr->sh_addr;
848 newsect->_raw_size = hdr->sh_size;
849 newsect->alignment_power = bfd_log2 (hdr->sh_addralign);
851 if (hdr->sh_flags & SHF_ALLOC)
853 newsect->flags |= SEC_ALLOC;
854 newsect->flags |= SEC_LOAD;
857 if (!(hdr->sh_flags & SHF_WRITE))
858 newsect->flags |= SEC_READONLY;
860 if (hdr->sh_flags & SHF_EXECINSTR)
861 newsect->flags |= SEC_CODE;
862 else if (newsect->flags & SEC_ALLOC)
863 newsect->flags |= SEC_DATA;
865 if (hdr->sh_type == SHT_MIPS_DEBUG)
866 newsect->flags |= SEC_DEBUGGING;
868 hdr->rawdata = (void *) newsect;
870 /* FIXME: We should record the sh_info field for a .gptab
873 /* For a .reginfo section, set the gp value in the tdata
874 information from the contents of this section. We need
875 the gp value while processing relocs, so we just get it
877 if (hdr->sh_type == SHT_MIPS_REGINFO)
879 Elf32_External_RegInfo ext;
882 if (bfd_get_section_contents (abfd, newsect, (PTR) &ext,
884 sizeof ext) == false)
886 bfd_mips_elf32_swap_reginfo_in (abfd, &ext, &s);
887 elf_gp (abfd) = s.ri_gp_value;
891 hdr->rawdata = (void *) bfd_get_section_by_name (abfd, name);
897 /* Set the correct type for a MIPS ELF section. We do this by the
898 section name, which is a hack, but ought to work. */
901 mips_elf_fake_sections (abfd, hdr, sec)
903 Elf32_Internal_Shdr *hdr;
906 register const char *name;
908 name = bfd_get_section_name (abfd, sec);
910 if (strcmp (name, ".liblist") == 0)
912 hdr->sh_type = SHT_MIPS_LIBLIST;
913 hdr->sh_info = sec->_raw_size / sizeof (Elf32_Lib);
914 /* FIXME: Set the sh_link field. */
916 else if (strcmp (name, ".conflict") == 0)
917 hdr->sh_type = SHT_MIPS_CONFLICT;
918 else if (strncmp (name, ".gptab.", sizeof ".gptab." - 1) == 0)
920 hdr->sh_type = SHT_MIPS_GPTAB;
921 /* FIXME: Set the sh_info field. */
923 else if (strcmp (name, ".ucode") == 0)
924 hdr->sh_type = SHT_MIPS_UCODE;
925 else if (strcmp (name, ".mdebug") == 0)
927 hdr->sh_type = SHT_MIPS_DEBUG;
930 else if (strcmp (name, ".reginfo") == 0)
932 hdr->sh_type = SHT_MIPS_REGINFO;
935 /* Force the section size to the correct value, even if the
936 linker thinks it is larger. The link routine below will only
937 write out this much data for .reginfo. */
938 hdr->sh_size = sec->_raw_size = sizeof (Elf32_External_RegInfo);
940 else if (strcmp (name, ".options") == 0)
942 hdr->sh_type = SHT_MIPS_OPTIONS;
949 /* Given a BFD section, try to locate the corresponding ELF section
953 mips_elf_section_from_bfd_section (abfd, hdr, sec, retval)
955 Elf32_Internal_Shdr *hdr;
959 if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
961 *retval = SHN_MIPS_SCOMMON;
964 if ((asection *) hdr->rawdata == sec)
969 /* Work over a section just before writing it out. We update the GP
970 value in the .reginfo section based on the value we are using.
971 FIXME: We recognize sections that need the SHF_MIPS_GPREL flag by
972 name; there has to be a better way. */
975 mips_elf_section_processing (abfd, hdr)
977 Elf32_Internal_Shdr *hdr;
979 if (hdr->sh_type == SHT_MIPS_REGINFO)
983 BFD_ASSERT (hdr->sh_size == sizeof (Elf32_External_RegInfo));
984 BFD_ASSERT (hdr->contents == NULL);
987 hdr->sh_offset + sizeof (Elf32_External_RegInfo) - 4,
990 bfd_h_put_32 (abfd, (bfd_vma) elf_gp (abfd), buf);
991 if (bfd_write (buf, (bfd_size_type) 1, (bfd_size_type) 4, abfd) != 4)
995 if (hdr->rawdata != NULL)
997 const char *name = ((asection *) hdr->rawdata)->name;
999 if (strcmp (name, ".sdata") == 0)
1001 hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
1002 hdr->sh_type = SHT_PROGBITS;
1004 else if (strcmp (name, ".sbss") == 0)
1006 hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
1007 hdr->sh_type = SHT_NOBITS;
1009 else if (strcmp (name, ".lit8") == 0
1010 || strcmp (name, ".lit4") == 0)
1012 hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
1013 hdr->sh_type = SHT_PROGBITS;
1020 /* Read ECOFF debugging information from a .mdebug section into a
1021 ecoff_debug_info structure. */
1024 mips_elf_read_ecoff_info (abfd, section, debug)
1027 struct ecoff_debug_info *debug;
1030 const struct ecoff_debug_swap *swap;
1031 char *ext_hdr = NULL;
1033 swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
1035 ext_hdr = (char *) malloc (swap->external_hdr_size);
1036 if (ext_hdr == NULL && swap->external_hdr_size != 0)
1038 bfd_set_error (bfd_error_no_memory);
1042 if (bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0,
1043 swap->external_hdr_size)
1047 symhdr = &debug->symbolic_header;
1048 (*swap->swap_hdr_in) (abfd, ext_hdr, symhdr);
1050 /* The symbolic header contains absolute file offsets and sizes to
1052 #define READ(ptr, offset, count, size, type) \
1053 if (symhdr->count == 0) \
1054 debug->ptr = NULL; \
1057 debug->ptr = (type) malloc (size * symhdr->count); \
1058 if (debug->ptr == NULL) \
1060 bfd_set_error (bfd_error_no_memory); \
1061 goto error_return; \
1063 if (bfd_seek (abfd, (file_ptr) symhdr->offset, SEEK_SET) != 0 \
1064 || (bfd_read (debug->ptr, size, symhdr->count, \
1065 abfd) != size * symhdr->count)) \
1066 goto error_return; \
1069 READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, PTR);
1070 READ (line, cbLineOffset, cbLine, sizeof (unsigned char), unsigned char *);
1071 READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, PTR);
1072 READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, PTR);
1073 READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, PTR);
1074 READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, PTR);
1075 READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext),
1077 READ (ss, cbSsOffset, issMax, sizeof (char), char *);
1078 READ (ssext, cbSsExtOffset, issExtMax, sizeof (char), char *);
1079 READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, PTR);
1080 READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, PTR);
1083 debug->adjust = NULL;
1088 if (ext_hdr != NULL)
1090 if (debug->external_ext != NULL)
1091 free (debug->external_ext);
1092 if (debug->line != NULL)
1094 if (debug->external_dnr != NULL)
1095 free (debug->external_dnr);
1096 if (debug->external_pdr != NULL)
1097 free (debug->external_pdr);
1098 if (debug->external_sym != NULL)
1099 free (debug->external_sym);
1100 if (debug->external_opt != NULL)
1101 free (debug->external_opt);
1102 if (debug->external_aux != NULL)
1103 free (debug->external_aux);
1104 if (debug->ss != NULL)
1106 if (debug->ssext != NULL)
1107 free (debug->ssext);
1108 if (debug->external_fdr != NULL)
1109 free (debug->external_fdr);
1110 if (debug->external_rfd != NULL)
1111 free (debug->external_rfd);
1115 /* Get EXTR information for a symbol. */
1118 mips_elf_get_extr (sym, esym)
1122 const struct ecoff_debug_swap *swap;
1124 if (sym->flags & BSF_SECTION_SYM)
1127 if (bfd_asymbol_flavour (sym) != bfd_target_elf_flavour
1128 || ((elf_symbol_type *) sym)->tc_data.mips_extr == NULL)
1131 esym->cobol_main = 0;
1135 /* FIXME: we can do better than this for st and sc. */
1136 esym->asym.st = stGlobal;
1137 esym->asym.sc = scAbs;
1138 esym->asym.reserved = 0;
1139 esym->asym.index = indexNil;
1143 swap = (get_elf_backend_data (bfd_asymbol_bfd (sym))
1144 ->elf_backend_ecoff_debug_swap);
1145 (*swap->swap_ext_in) (bfd_asymbol_bfd (sym),
1146 ((elf_symbol_type *) sym)->tc_data.mips_extr,
1152 /* Set the symbol index for an external symbol. This is actually not
1157 mips_elf_set_index (sym, indx)
1163 /* We need to use a special link routine to handle the .reginfo and
1164 the .mdebug sections. We need to merge all instances of these
1165 sections together, not write them all out sequentially. */
1168 mips_elf_final_link (abfd, info)
1170 struct bfd_link_info *info;
1174 struct generic_write_global_symbol_info wginfo;
1177 struct bfd_link_order *p;
1178 asection *reginfo_sec, *mdebug_sec;
1179 Elf32_RegInfo reginfo;
1180 struct ecoff_debug_info debug;
1181 const struct ecoff_debug_swap *swap
1182 = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
1183 HDRR *symhdr = &debug.symbolic_header;
1184 PTR mdebug_handle = NULL;
1186 abfd->outsymbols = (asymbol **) NULL;
1190 /* Build the output symbol table. This also reads in the symbols
1191 for all the input BFDs, keeping them in the outsymbols field. */
1192 for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next)
1193 if (! _bfd_generic_link_output_symbols (abfd, sub, info, &outsymalloc))
1196 /* Accumulate the global symbols. */
1198 wginfo.output_bfd = abfd;
1199 wginfo.psymalloc = &outsymalloc;
1200 _bfd_generic_link_hash_traverse (_bfd_generic_hash_table (info),
1201 _bfd_generic_link_write_global_symbol,
1204 /* Remove empty sections. Also drop the .options section, since it
1205 has special semantics which I haven't bothered to figure out.
1206 Also drop the .gptab sections, which also require special
1207 handling which is not currently done. Removing the .gptab
1208 sections is required for Irix 5 compatibility; I don't know about
1209 the other sections. */
1210 secpp = &abfd->sections;
1211 while (*secpp != NULL)
1213 if (((*secpp)->_raw_size == 0
1214 && strcmp ((*secpp)->name, ".data") != 0
1215 && strcmp ((*secpp)->name, ".text") != 0
1216 && strcmp ((*secpp)->name, ".bss") != 0)
1217 || strcmp ((*secpp)->name, ".options") == 0
1218 || strncmp ((*secpp)->name, ".gptab", 6) == 0)
1220 *secpp = (*secpp)->next;
1221 --abfd->section_count;
1224 secpp = &(*secpp)->next;
1227 /* Go through the sections and collect the .reginfo and .mdebug
1228 information. We don't write out the information until we have
1229 set the section sizes, because the ELF backend only assigns space
1230 in the file once. */
1233 for (o = abfd->sections; o != (asection *) NULL; o = o->next)
1235 if (strcmp (o->name, ".reginfo") == 0)
1237 memset (®info, 0, sizeof reginfo);
1239 /* We have found the .reginfo section in the output file.
1240 Look through all the link_orders comprising it and merge
1241 the information together. */
1242 for (p = o->link_order_head;
1243 p != (struct bfd_link_order *) NULL;
1246 asection *input_section;
1248 Elf32_External_RegInfo ext;
1251 if (p->type != bfd_indirect_link_order)
1254 input_section = p->u.indirect.section;
1255 input_bfd = input_section->owner;
1256 BFD_ASSERT (input_section->_raw_size
1257 == sizeof (Elf32_External_RegInfo));
1258 if (! bfd_get_section_contents (input_bfd, input_section,
1264 bfd_mips_elf32_swap_reginfo_in (input_bfd, &ext, &sub);
1266 reginfo.ri_gprmask |= sub.ri_gprmask;
1267 reginfo.ri_cprmask[0] |= sub.ri_cprmask[0];
1268 reginfo.ri_cprmask[1] |= sub.ri_cprmask[1];
1269 reginfo.ri_cprmask[2] |= sub.ri_cprmask[2];
1270 reginfo.ri_cprmask[3] |= sub.ri_cprmask[3];
1272 /* ri_gp_value is set by the function
1273 mips_elf_section_processing when the section is
1274 finally written out. */
1277 /* Force the section size to the value we want. */
1278 o->_raw_size = sizeof (Elf32_External_RegInfo);
1280 /* Skip this section later on. */
1281 o->link_order_head = (struct bfd_link_order *) NULL;
1286 if (strcmp (o->name, ".mdebug") == 0)
1288 /* We have found the .mdebug section in the output file.
1289 Look through all the link_orders comprising it and merge
1290 the information together. */
1291 symhdr->magic = swap->sym_magic;
1292 /* FIXME: What should the version stamp be? */
1294 symhdr->ilineMax = 0;
1298 symhdr->isymMax = 0;
1299 symhdr->ioptMax = 0;
1300 symhdr->iauxMax = 0;
1302 symhdr->issExtMax = 0;
1305 symhdr->iextMax = 0;
1307 /* We accumulate the debugging information itself in the
1308 debug_info structure. */
1310 debug.external_dnr = NULL;
1311 debug.external_pdr = NULL;
1312 debug.external_sym = NULL;
1313 debug.external_opt = NULL;
1314 debug.external_aux = NULL;
1316 debug.ssext = debug.ssext_end = NULL;
1317 debug.external_fdr = NULL;
1318 debug.external_rfd = NULL;
1319 debug.external_ext = debug.external_ext_end = NULL;
1321 mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info);
1322 if (mdebug_handle == (PTR) NULL)
1325 for (p = o->link_order_head;
1326 p != (struct bfd_link_order *) NULL;
1329 asection *input_section;
1331 const struct ecoff_debug_swap *input_swap;
1332 struct ecoff_debug_info input_debug;
1334 if (p->type != bfd_indirect_link_order)
1337 input_section = p->u.indirect.section;
1338 input_bfd = input_section->owner;
1340 if (bfd_get_flavour (input_bfd) != bfd_target_elf_flavour
1341 || (get_elf_backend_data (input_bfd)
1342 ->elf_backend_ecoff_debug_swap) == NULL)
1344 /* I don't know what a non MIPS ELF bfd would be
1345 doing with a .mdebug section, but I don't really
1346 want to deal with it. */
1350 input_swap = (get_elf_backend_data (input_bfd)
1351 ->elf_backend_ecoff_debug_swap);
1353 BFD_ASSERT (p->size == input_section->_raw_size);
1355 /* The ECOFF linking code expects that we have already
1356 read in the debugging information and set up an
1357 ecoff_debug_info structure, so we do that now. */
1358 if (! mips_elf_read_ecoff_info (input_bfd, input_section,
1362 if (! (bfd_ecoff_debug_accumulate
1363 (mdebug_handle, abfd, &debug, swap, input_bfd,
1364 &input_debug, input_swap, info)))
1367 /* Loop through the external symbols. For each one with
1368 interesting information, try to find the symbol on
1369 the symbol table of abfd and save the information in
1370 order to put it into the final external symbols. */
1371 if (info->hash->creator == input_bfd->xvec)
1376 eraw_src = input_debug.external_ext;
1377 eraw_end = (eraw_src
1378 + (input_debug.symbolic_header.iextMax
1379 * input_swap->external_ext_size));
1381 eraw_src < eraw_end;
1382 eraw_src += input_swap->external_ext_size)
1386 struct generic_link_hash_entry *h;
1387 elf_symbol_type *elf_sym;
1389 (*input_swap->swap_ext_in) (input_bfd, (PTR) eraw_src,
1391 if (ext.asym.sc == scNil
1392 || ext.asym.sc == scUndefined
1393 || ext.asym.sc == scSUndefined)
1396 name = input_debug.ssext + ext.asym.iss;
1397 h = ((struct generic_link_hash_entry *)
1398 bfd_link_hash_lookup (info->hash, name, false,
1400 if (h == (struct generic_link_hash_entry *) NULL
1401 || h->sym == (asymbol *) NULL)
1404 elf_sym = (elf_symbol_type *) (h->sym);
1406 if (elf_sym->tc_data.mips_extr != NULL)
1412 < input_debug.symbolic_header.ifdMax);
1413 ext.ifd = input_debug.ifdmap[ext.ifd];
1416 (*input_swap->swap_ext_out) (input_bfd, &ext,
1418 elf_sym->tc_data.mips_extr = (PTR) eraw_src;
1422 /* Free up the information we just read, except for the
1423 external symbols which we may have pointers to. */
1424 free (input_debug.line);
1425 free (input_debug.external_dnr);
1426 free (input_debug.external_pdr);
1427 free (input_debug.external_sym);
1428 free (input_debug.external_opt);
1429 free (input_debug.external_aux);
1430 free (input_debug.ss);
1431 free (input_debug.ssext);
1432 free (input_debug.external_fdr);
1433 free (input_debug.external_rfd);
1436 /* Build the external symbol information. */
1437 if (! bfd_ecoff_debug_externals (abfd, &debug, swap,
1440 mips_elf_set_index))
1443 /* Set the size of the section. */
1444 o->_raw_size = bfd_ecoff_debug_size (abfd, &debug, swap);
1446 /* Skip this section later on. */
1447 o->link_order_head = (struct bfd_link_order *) NULL;
1453 if (info->relocateable)
1455 /* Allocate space for the output relocs for each section. */
1456 for (o = abfd->sections;
1457 o != (asection *) NULL;
1461 for (p = o->link_order_head;
1462 p != (struct bfd_link_order *) NULL;
1465 if (p->type == bfd_section_reloc_link_order
1466 || p->type == bfd_symbol_reloc_link_order)
1468 else if (p->type == bfd_indirect_link_order)
1470 asection *input_section;
1476 input_section = p->u.indirect.section;
1477 input_bfd = input_section->owner;
1478 relsize = bfd_get_reloc_upper_bound (input_bfd,
1482 relocs = (arelent **) malloc (relsize);
1483 if (!relocs && relsize != 0)
1485 bfd_set_error (bfd_error_no_memory);
1489 bfd_canonicalize_reloc (input_bfd, input_section,
1491 bfd_get_outsymbols (input_bfd));
1492 if (reloc_count < 0)
1494 BFD_ASSERT (reloc_count == input_section->reloc_count);
1495 o->reloc_count += reloc_count;
1499 if (o->reloc_count > 0)
1501 o->orelocation = ((arelent **)
1504 * sizeof (arelent *))));
1505 if (!o->orelocation)
1507 bfd_set_error (bfd_error_no_memory);
1510 o->flags |= SEC_RELOC;
1511 /* Reset the count so that it can be used as an index
1512 when putting in the output relocs. */
1518 /* Write out the information we have accumulated. */
1519 if (reginfo_sec != (asection *) NULL)
1521 Elf32_External_RegInfo ext;
1523 bfd_mips_elf32_swap_reginfo_out (abfd, ®info, &ext);
1524 if (! bfd_set_section_contents (abfd, reginfo_sec, (PTR) &ext,
1525 (file_ptr) 0, sizeof ext))
1529 if (mdebug_sec != (asection *) NULL)
1531 if (! abfd->output_has_begun)
1533 /* Force the section to be given a file position. */
1534 bfd_set_section_contents (abfd, mdebug_sec, (PTR) NULL,
1535 (file_ptr) 0, (bfd_size_type) 0);
1536 BFD_ASSERT (abfd->output_has_begun);
1538 if (! bfd_ecoff_write_accumulated_debug (mdebug_handle, abfd, &debug,
1540 mdebug_sec->filepos))
1543 bfd_ecoff_debug_free (mdebug_handle, abfd, &debug, swap, info);
1546 /* Handle all the link order information for the sections. */
1547 for (o = abfd->sections;
1548 o != (asection *) NULL;
1551 for (p = o->link_order_head;
1552 p != (struct bfd_link_order *) NULL;
1557 case bfd_section_reloc_link_order:
1558 case bfd_symbol_reloc_link_order:
1559 if (! _bfd_generic_reloc_link_order (abfd, info, o, p))
1563 if (! _bfd_default_link_order (abfd, info, o, p))
1573 /* MIPS ELF uses two common sections. One is the usual one, and the
1574 other is for small objects. All the small objects are kept
1575 together, and then referenced via the gp pointer, which yields
1576 faster assembler code. This is what we use for the small common
1577 section. This approach is copied from ecoff.c. */
1578 static asection mips_elf_scom_section;
1579 static asymbol mips_elf_scom_symbol;
1580 static asymbol *mips_elf_scom_symbol_ptr;
1582 /* MIPS ELF also uses an acommon section, which represents an
1583 allocated common symbol which may be overridden by a
1584 definition in a shared library. */
1585 static asection mips_elf_acom_section;
1586 static asymbol mips_elf_acom_symbol;
1587 static asymbol *mips_elf_acom_symbol_ptr;
1589 /* Handle the special MIPS section numbers that a symbol may use. */
1592 mips_elf_symbol_processing (abfd, asym)
1596 elf_symbol_type *elfsym;
1598 elfsym = (elf_symbol_type *) asym;
1599 switch (elfsym->internal_elf_sym.st_shndx)
1601 case SHN_MIPS_ACOMMON:
1602 /* This section is used in a dynamically linked executable file.
1603 It is an allocated common section. The dynamic linker can
1604 either resolve these symbols to something in a shared
1605 library, or it can just leave them here. For our purposes,
1606 we can consider these symbols to be in a new section. */
1607 if (mips_elf_acom_section.name == NULL)
1609 /* Initialize the acommon section. */
1610 mips_elf_acom_section.name = ".acommon";
1611 mips_elf_acom_section.flags = SEC_NO_FLAGS;
1612 mips_elf_acom_section.output_section = &mips_elf_acom_section;
1613 mips_elf_acom_section.symbol = &mips_elf_acom_symbol;
1614 mips_elf_acom_section.symbol_ptr_ptr = &mips_elf_acom_symbol_ptr;
1615 mips_elf_acom_symbol.name = ".acommon";
1616 mips_elf_acom_symbol.flags = BSF_SECTION_SYM;
1617 mips_elf_acom_symbol.section = &mips_elf_acom_section;
1618 mips_elf_acom_symbol_ptr = &mips_elf_acom_symbol;
1620 asym->section = &mips_elf_acom_section;
1624 /* Common symbols less than the GP size are automatically
1625 treated as SHN_MIPS_SCOMMON symbols. */
1626 if (asym->value > elf_gp_size (abfd))
1629 case SHN_MIPS_SCOMMON:
1630 if (mips_elf_scom_section.name == NULL)
1632 /* Initialize the small common section. */
1633 mips_elf_scom_section.name = ".scommon";
1634 mips_elf_scom_section.flags = SEC_IS_COMMON;
1635 mips_elf_scom_section.output_section = &mips_elf_scom_section;
1636 mips_elf_scom_section.symbol = &mips_elf_scom_symbol;
1637 mips_elf_scom_section.symbol_ptr_ptr = &mips_elf_scom_symbol_ptr;
1638 mips_elf_scom_symbol.name = ".scommon";
1639 mips_elf_scom_symbol.flags = BSF_SECTION_SYM;
1640 mips_elf_scom_symbol.section = &mips_elf_scom_section;
1641 mips_elf_scom_symbol_ptr = &mips_elf_scom_symbol;
1643 asym->section = &mips_elf_scom_section;
1644 asym->value = elfsym->internal_elf_sym.st_size;
1647 case SHN_MIPS_SUNDEFINED:
1648 asym->section = &bfd_und_section;
1653 /* ECOFF swapping routines. These are used when dealing with the
1654 .mdebug section, which is in the ECOFF debugging format. */
1655 static const struct ecoff_debug_swap mips_elf_ecoff_debug_swap =
1657 /* Symbol table magic number. */
1659 /* Alignment of debugging information. E.g., 4. */
1661 /* Sizes of external symbolic information. */
1662 sizeof (struct hdr_ext),
1663 sizeof (struct dnr_ext),
1664 sizeof (struct pdr_ext),
1665 sizeof (struct sym_ext),
1666 sizeof (struct opt_ext),
1667 sizeof (struct fdr_ext),
1668 sizeof (struct rfd_ext),
1669 sizeof (struct ext_ext),
1670 /* Functions to swap in external symbolic data. */
1679 /* Functions to swap out external symbolic data. */
1690 #define TARGET_LITTLE_SYM bfd_elf32_littlemips_vec
1691 #define TARGET_LITTLE_NAME "elf32-littlemips"
1692 #define TARGET_BIG_SYM bfd_elf32_bigmips_vec
1693 #define TARGET_BIG_NAME "elf32-bigmips"
1694 #define ELF_ARCH bfd_arch_mips
1695 #define ELF_MACHINE_CODE EM_MIPS
1696 #define ELF_MAXPAGESIZE 0x10000
1697 #define elf_info_to_howto 0
1698 #define elf_info_to_howto_rel mips_info_to_howto_rel
1699 #define elf_backend_sym_is_global mips_elf_sym_is_global
1700 #define elf_backend_object_p mips_elf_object_p
1701 #define elf_backend_section_from_shdr mips_elf_section_from_shdr
1702 #define elf_backend_fake_sections mips_elf_fake_sections
1703 #define elf_backend_section_from_bfd_section \
1704 mips_elf_section_from_bfd_section
1705 #define elf_backend_section_processing mips_elf_section_processing
1706 #define elf_backend_symbol_processing mips_elf_symbol_processing
1707 #define elf_backend_final_write_processing \
1708 mips_elf_final_write_processing
1709 #define elf_backend_ecoff_debug_swap &mips_elf_ecoff_debug_swap
1711 #define bfd_elf32_bfd_link_add_symbols _bfd_generic_link_add_symbols_collect
1712 #define bfd_elf32_bfd_final_link mips_elf_final_link
1714 #include "elf32-target.h"