1 /* SPARC-specific support for 32-bit ELF
2 Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 #include "elf/sparc.h"
27 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
28 PARAMS ((bfd *, bfd_reloc_code_real_type));
29 static void elf_info_to_howto
30 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
31 static boolean elf32_sparc_check_relocs
32 PARAMS ((bfd *, struct bfd_link_info *, asection *,
33 const Elf_Internal_Rela *));
34 static boolean elf32_sparc_adjust_dynamic_symbol
35 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
36 static boolean elf32_sparc_adjust_dynindx
37 PARAMS ((struct elf_link_hash_entry *, PTR));
38 static boolean elf32_sparc_size_dynamic_sections
39 PARAMS ((bfd *, struct bfd_link_info *));
40 static boolean elf32_sparc_relocate_section
41 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
42 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
43 static boolean elf32_sparc_finish_dynamic_symbol
44 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
46 static boolean elf32_sparc_finish_dynamic_sections
47 PARAMS ((bfd *, struct bfd_link_info *));
48 static boolean elf32_sparc_merge_private_bfd_data PARAMS ((bfd *, bfd *));
49 static boolean elf32_sparc_object_p
51 static void elf32_sparc_final_write_processing
52 PARAMS ((bfd *, boolean));
57 R_SPARC_8, R_SPARC_16, R_SPARC_32,
58 R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32,
59 R_SPARC_WDISP30, R_SPARC_WDISP22,
60 R_SPARC_HI22, R_SPARC_22,
61 R_SPARC_13, R_SPARC_LO10,
62 R_SPARC_GOT10, R_SPARC_GOT13, R_SPARC_GOT22,
63 R_SPARC_PC10, R_SPARC_PC22,
66 R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT,
73 static CONST char *CONST reloc_type_names[] =
76 "R_SPARC_8", "R_SPARC_16", "R_SPARC_32",
77 "R_SPARC_DISP8", "R_SPARC_DISP16", "R_SPARC_DISP32",
78 "R_SPARC_WDISP30", "R_SPARC_WDISP22",
79 "R_SPARC_HI22", "R_SPARC_22",
80 "R_SPARC_13", "R_SPARC_LO10",
81 "R_SPARC_GOT10", "R_SPARC_GOT13", "R_SPARC_GOT22",
82 "R_SPARC_PC10", "R_SPARC_PC22",
85 "R_SPARC_GLOB_DAT", "R_SPARC_JMP_SLOT",
91 static reloc_howto_type elf_sparc_howto_table[] =
93 HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc,"R_SPARC_NONE", false,0,0x00000000,true),
94 HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,"R_SPARC_8", false,0,0x000000ff,true),
95 HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,"R_SPARC_16", false,0,0x0000ffff,true),
96 HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,"R_SPARC_32", false,0,0xffffffff,true),
97 HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, bfd_elf_generic_reloc,"R_SPARC_DISP8", false,0,0x000000ff,true),
98 HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, bfd_elf_generic_reloc,"R_SPARC_DISP16", false,0,0x0000ffff,true),
99 HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, bfd_elf_generic_reloc,"R_SPARC_DISP32", false,0,0x00ffffff,true),
100 HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc,"R_SPARC_WDISP30", false,0,0x3fffffff,true),
101 HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, bfd_elf_generic_reloc,"R_SPARC_WDISP22", false,0,0x003fffff,true),
102 HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc,"R_SPARC_HI22", false,0,0x003fffff,true),
103 HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,"R_SPARC_22", false,0,0x003fffff,true),
104 HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,"R_SPARC_13", false,0,0x00001fff,true),
105 HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc,"R_SPARC_LO10", false,0,0x000003ff,true),
106 HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc,"R_SPARC_GOT10", false,0,0x000003ff,true),
107 HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_signed, bfd_elf_generic_reloc,"R_SPARC_GOT13", false,0,0x00001fff,true),
108 HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc,"R_SPARC_GOT22", false,0,0x003fffff,true),
109 HOWTO(R_SPARC_PC10, 0,2,10,true, 0,complain_overflow_dont, bfd_elf_generic_reloc,"R_SPARC_PC10", false,0,0x000003ff,true),
110 HOWTO(R_SPARC_PC22, 10,2,22,true, 0,complain_overflow_bitfield,bfd_elf_generic_reloc,"R_SPARC_PC22", false,0,0x003fffff,true),
111 HOWTO(R_SPARC_WPLT30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc,"R_SPARC_WPLT30", false,0,0x3fffffff,true),
112 HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc,"R_SPARC_COPY", false,0,0x00000000,true),
113 HOWTO(R_SPARC_GLOB_DAT,0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc,"R_SPARC_GLOB_DAT",false,0,0x00000000,true),
114 HOWTO(R_SPARC_JMP_SLOT,0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc,"R_SPARC_JMP_SLOT",false,0,0x00000000,true),
115 HOWTO(R_SPARC_RELATIVE,0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc,"R_SPARC_RELATIVE",false,0,0x00000000,true),
116 HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc,"R_SPARC_UA32", false,0,0x00000000,true),
119 struct elf_reloc_map {
120 unsigned char bfd_reloc_val;
121 unsigned char elf_reloc_val;
124 static CONST struct elf_reloc_map sparc_reloc_map[] =
126 { BFD_RELOC_NONE, R_SPARC_NONE, },
127 { BFD_RELOC_16, R_SPARC_16, },
128 { BFD_RELOC_8, R_SPARC_8 },
129 { BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
130 { BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits. */
131 { BFD_RELOC_32, R_SPARC_32 },
132 { BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
133 { BFD_RELOC_HI22, R_SPARC_HI22 },
134 { BFD_RELOC_LO10, R_SPARC_LO10, },
135 { BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
136 { BFD_RELOC_SPARC22, R_SPARC_22 },
137 { BFD_RELOC_SPARC13, R_SPARC_13 },
138 { BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
139 { BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
140 { BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
141 { BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
142 { BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
143 { BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
144 { BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
145 { BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
146 { BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
147 { BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
148 { BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
149 /*{ BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
152 static reloc_howto_type *
153 bfd_elf32_bfd_reloc_type_lookup (abfd, code)
155 bfd_reloc_code_real_type code;
158 for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct elf_reloc_map); i++)
160 if (sparc_reloc_map[i].bfd_reloc_val == code)
161 return &elf_sparc_howto_table[(int) sparc_reloc_map[i].elf_reloc_val];
167 elf_info_to_howto (abfd, cache_ptr, dst)
170 Elf_Internal_Rela *dst;
172 BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_SPARC_max);
173 cache_ptr->howto = &elf_sparc_howto_table[ELF32_R_TYPE(dst->r_info)];
177 /* Functions for the SPARC ELF linker. */
179 /* The name of the dynamic interpreter. This is put in the .interp
182 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
184 /* The nop opcode we use. */
186 #define SPARC_NOP 0x01000000
188 /* The size in bytes of an entry in the procedure linkage table. */
190 #define PLT_ENTRY_SIZE 12
192 /* The first four entries in a procedure linkage table are reserved,
193 and the initial contents are unimportant (we zero them out).
194 Subsequent entries look like this. See the SVR4 ABI SPARC
195 supplement to see how this works. */
197 /* sethi %hi(.-.plt0),%g1. We fill in the address later. */
198 #define PLT_ENTRY_WORD0 0x03000000
199 /* b,a .plt0. We fill in the offset later. */
200 #define PLT_ENTRY_WORD1 0x30800000
202 #define PLT_ENTRY_WORD2 SPARC_NOP
204 /* Look through the relocs for a section during the first phase, and
205 allocate space in the global offset table or procedure linkage
209 elf32_sparc_check_relocs (abfd, info, sec, relocs)
211 struct bfd_link_info *info;
213 const Elf_Internal_Rela *relocs;
216 Elf_Internal_Shdr *symtab_hdr;
217 struct elf_link_hash_entry **sym_hashes;
218 bfd_vma *local_got_offsets;
219 const Elf_Internal_Rela *rel;
220 const Elf_Internal_Rela *rel_end;
225 if (info->relocateable)
228 dynobj = elf_hash_table (info)->dynobj;
229 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
230 sym_hashes = elf_sym_hashes (abfd);
231 local_got_offsets = elf_local_got_offsets (abfd);
237 rel_end = relocs + sec->reloc_count;
238 for (rel = relocs; rel < rel_end; rel++)
240 unsigned long r_symndx;
241 struct elf_link_hash_entry *h;
243 r_symndx = ELF32_R_SYM (rel->r_info);
244 if (r_symndx < symtab_hdr->sh_info)
247 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
249 switch (ELF32_R_TYPE (rel->r_info))
254 /* This symbol requires a global offset table entry. */
258 /* Create the .got section. */
259 elf_hash_table (info)->dynobj = dynobj = abfd;
260 if (! _bfd_elf_create_got_section (dynobj, info))
266 sgot = bfd_get_section_by_name (dynobj, ".got");
267 BFD_ASSERT (sgot != NULL);
271 && (h != NULL || info->shared))
273 srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
276 srelgot = bfd_make_section (dynobj, ".rela.got");
278 || ! bfd_set_section_flags (dynobj, srelgot,
284 || ! bfd_set_section_alignment (dynobj, srelgot, 2))
291 if (h->got_offset != (bfd_vma) -1)
293 /* We have already allocated space in the .got. */
296 h->got_offset = sgot->_raw_size;
298 /* Make sure this symbol is output as a dynamic symbol. */
299 if (h->dynindx == -1)
301 if (! bfd_elf32_link_record_dynamic_symbol (info, h))
305 srelgot->_raw_size += sizeof (Elf32_External_Rela);
309 /* This is a global offset table entry for a local
311 if (local_got_offsets == NULL)
314 register unsigned int i;
316 size = symtab_hdr->sh_info * sizeof (bfd_vma);
317 local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
318 if (local_got_offsets == NULL)
320 elf_local_got_offsets (abfd) = local_got_offsets;
321 for (i = 0; i < symtab_hdr->sh_info; i++)
322 local_got_offsets[i] = (bfd_vma) -1;
324 if (local_got_offsets[r_symndx] != (bfd_vma) -1)
326 /* We have already allocated space in the .got. */
329 local_got_offsets[r_symndx] = sgot->_raw_size;
333 /* If we are generating a shared object, we need to
334 output a R_SPARC_RELATIVE reloc so that the
335 dynamic linker can adjust this GOT entry. */
336 srelgot->_raw_size += sizeof (Elf32_External_Rela);
340 sgot->_raw_size += 4;
345 /* This symbol requires a procedure linkage table entry. We
346 actually build the entry in adjust_dynamic_symbol,
347 because this might be a case of linking PIC code without
348 linking in any dynamic objects, in which case we don't
349 need to generate a procedure linkage table after all. */
353 /* It does not make sense to have a procedure linkage
354 table entry for a local symbol. */
355 bfd_set_error (bfd_error_bad_value);
359 /* Make sure this symbol is output as a dynamic symbol. */
360 if (h->dynindx == -1)
362 if (! bfd_elf32_link_record_dynamic_symbol (info, h))
366 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
373 && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
379 case R_SPARC_WDISP30:
380 case R_SPARC_WDISP22:
393 && (sec->flags & SEC_ALLOC) != 0)
395 /* When creating a shared object, we must copy these
396 relocs into the output file. We create a reloc
397 section in dynobj and make room for the reloc. */
402 name = (bfd_elf_string_from_elf_section
404 elf_elfheader (abfd)->e_shstrndx,
405 elf_section_data (sec)->rel_hdr.sh_name));
409 BFD_ASSERT (strncmp (name, ".rela", 5) == 0
410 && strcmp (bfd_get_section_name (abfd, sec),
413 sreloc = bfd_get_section_by_name (dynobj, name);
416 sreloc = bfd_make_section (dynobj, name);
418 || ! bfd_set_section_flags (dynobj, sreloc,
424 || ! bfd_set_section_alignment (dynobj, sreloc, 2))
429 sreloc->_raw_size += sizeof (Elf32_External_Rela);
442 /* Adjust a symbol defined by a dynamic object and referenced by a
443 regular object. The current definition is in some section of the
444 dynamic object, but we're not including those sections. We have to
445 change the definition to something the rest of the link can
449 elf32_sparc_adjust_dynamic_symbol (info, h)
450 struct bfd_link_info *info;
451 struct elf_link_hash_entry *h;
455 unsigned int power_of_two;
457 dynobj = elf_hash_table (info)->dynobj;
459 /* Make sure we know what is going on here. */
460 BFD_ASSERT (dynobj != NULL
461 && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
462 || h->weakdef != NULL
463 || ((h->elf_link_hash_flags
464 & ELF_LINK_HASH_DEF_DYNAMIC) != 0
465 && (h->elf_link_hash_flags
466 & ELF_LINK_HASH_REF_REGULAR) != 0
467 && (h->elf_link_hash_flags
468 & ELF_LINK_HASH_DEF_REGULAR) == 0)));
470 /* If this is a function, put it in the procedure linkage table. We
471 will fill in the contents of the procedure linkage table later
472 (although we could actually do it here). */
473 if (h->type == STT_FUNC
474 || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
476 if (! elf_hash_table (info)->dynamic_sections_created)
478 /* This case can occur if we saw a WPLT30 reloc in an input
479 file, but none of the input files were dynamic objects.
480 In such a case, we don't actually need to build a
481 procedure linkage table, and we can just do a WDISP30
483 BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
487 s = bfd_get_section_by_name (dynobj, ".plt");
488 BFD_ASSERT (s != NULL);
490 /* The first four entries in .plt are reserved. */
491 if (s->_raw_size == 0)
492 s->_raw_size = 4 * PLT_ENTRY_SIZE;
494 /* The procedure linkage table has a maximum size. */
495 if (s->_raw_size >= 0x400000)
497 bfd_set_error (bfd_error_bad_value);
501 /* If this symbol is not defined in a regular file, and we are
502 not generating a shared library, then set the symbol to this
503 location in the .plt. This is required to make function
504 pointers compare as equal between the normal executable and
505 the shared library. */
507 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
509 h->root.u.def.section = s;
510 h->root.u.def.value = s->_raw_size;
513 h->plt_offset = s->_raw_size;
515 /* Make room for this entry. */
516 s->_raw_size += PLT_ENTRY_SIZE;
518 /* We also need to make an entry in the .rela.plt section. */
520 s = bfd_get_section_by_name (dynobj, ".rela.plt");
521 BFD_ASSERT (s != NULL);
522 s->_raw_size += sizeof (Elf32_External_Rela);
527 /* If this is a weak symbol, and there is a real definition, the
528 processor independent code will have arranged for us to see the
529 real definition first, and we can just use the same value. */
530 if (h->weakdef != NULL)
532 BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
533 || h->weakdef->root.type == bfd_link_hash_defweak);
534 h->root.u.def.section = h->weakdef->root.u.def.section;
535 h->root.u.def.value = h->weakdef->root.u.def.value;
539 /* This is a reference to a symbol defined by a dynamic object which
540 is not a function. */
542 /* If we are creating a shared library, we must presume that the
543 only references to the symbol are via the global offset table.
544 For such cases we need not do anything here; the relocations will
545 be handled correctly by relocate_section. */
549 /* We must allocate the symbol in our .dynbss section, which will
550 become part of the .bss section of the executable. There will be
551 an entry for this symbol in the .dynsym section. The dynamic
552 object will contain position independent code, so all references
553 from the dynamic object to this symbol will go through the global
554 offset table. The dynamic linker will use the .dynsym entry to
555 determine the address it must put in the global offset table, so
556 both the dynamic object and the regular object will refer to the
557 same memory location for the variable. */
559 s = bfd_get_section_by_name (dynobj, ".dynbss");
560 BFD_ASSERT (s != NULL);
562 /* If the symbol is currently defined in the .bss section of the
563 dynamic object, then it is OK to simply initialize it to zero.
564 If the symbol is in some other section, we must generate a
565 R_SPARC_COPY reloc to tell the dynamic linker to copy the initial
566 value out of the dynamic object and into the runtime process
567 image. We need to remember the offset into the .rel.bss section
568 we are going to use. */
569 if ((h->root.u.def.section->flags & SEC_LOAD) != 0)
573 srel = bfd_get_section_by_name (dynobj, ".rela.bss");
574 BFD_ASSERT (srel != NULL);
575 srel->_raw_size += sizeof (Elf32_External_Rela);
576 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
579 /* We need to figure out the alignment required for this symbol. I
580 have no idea how ELF linkers handle this. */
581 power_of_two = bfd_log2 (h->size);
582 if (power_of_two > 3)
585 /* Apply the required alignment. */
586 s->_raw_size = BFD_ALIGN (s->_raw_size,
587 (bfd_size_type) (1 << power_of_two));
588 if (power_of_two > bfd_get_section_alignment (dynobj, s))
590 if (! bfd_set_section_alignment (dynobj, s, power_of_two))
594 /* Define the symbol as being at this point in the section. */
595 h->root.u.def.section = s;
596 h->root.u.def.value = s->_raw_size;
598 /* Increment the section size to make room for the symbol. */
599 s->_raw_size += h->size;
604 /* Set the sizes of the dynamic sections. */
607 elf32_sparc_size_dynamic_sections (output_bfd, info)
609 struct bfd_link_info *info;
616 dynobj = elf_hash_table (info)->dynobj;
617 BFD_ASSERT (dynobj != NULL);
619 if (elf_hash_table (info)->dynamic_sections_created)
621 /* Set the contents of the .interp section to the interpreter. */
624 s = bfd_get_section_by_name (dynobj, ".interp");
625 BFD_ASSERT (s != NULL);
626 s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
627 s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
630 /* Make space for the trailing nop in .plt. */
631 s = bfd_get_section_by_name (dynobj, ".plt");
632 BFD_ASSERT (s != NULL);
633 if (s->_raw_size > 0)
638 /* We may have created entries in the .rela.got section.
639 However, if we are not creating the dynamic sections, we will
640 not actually use these entries. Reset the size of .rela.got,
641 which will cause it to get stripped from the output file
643 s = bfd_get_section_by_name (dynobj, ".rela.got");
648 /* The check_relocs and adjust_dynamic_symbol entry points have
649 determined the sizes of the various dynamic sections. Allocate
653 for (s = dynobj->sections; s != NULL; s = s->next)
658 if ((s->flags & SEC_IN_MEMORY) == 0)
661 /* It's OK to base decisions on the section name, because none
662 of the dynobj section names depend upon the input files. */
663 name = bfd_get_section_name (dynobj, s);
667 if (strncmp (name, ".rela", 5) == 0)
669 if (s->_raw_size == 0)
671 /* If we don't need this section, strip it from the
672 output file. This is to handle .rela.bss and
673 .rel.plt. We must create it in
674 create_dynamic_sections, because it must be created
675 before the linker maps input sections to output
676 sections. The linker does that before
677 adjust_dynamic_symbol is called, and it is that
678 function which decides whether anything needs to go
679 into these sections. */
686 /* If this relocation section applies to a read only
687 section, then we probably need a DT_TEXTREL entry. */
688 target = bfd_get_section_by_name (output_bfd, name + 5);
690 && (target->flags & SEC_READONLY) != 0)
693 if (strcmp (name, ".rela.plt") == 0)
696 /* We use the reloc_count field as a counter if we need
697 to copy relocs into the output file. */
701 else if (strcmp (name, ".plt") != 0
702 && strcmp (name, ".got") != 0)
704 /* It's not one of our sections, so don't allocate space. */
712 for (spp = &s->output_section->owner->sections;
713 *spp != s->output_section;
716 *spp = s->output_section->next;
717 --s->output_section->owner->section_count;
722 /* Allocate memory for the section contents. */
723 s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
724 if (s->contents == NULL && s->_raw_size != 0)
728 if (elf_hash_table (info)->dynamic_sections_created)
730 /* Add some entries to the .dynamic section. We fill in the
731 values later, in elf32_sparc_finish_dynamic_sections, but we
732 must add the entries now so that we get the correct size for
733 the .dynamic section. The DT_DEBUG entry is filled in by the
734 dynamic linker and used by the debugger. */
737 if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
741 if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0))
746 if (! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
747 || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
748 || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
752 if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
753 || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
754 || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
755 sizeof (Elf32_External_Rela)))
760 if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
765 /* If we are generating a shared library, we generate a section
766 symbol for each output section. These are local symbols, which
767 means that they must come first in the dynamic symbol table.
768 That means we must increment the dynamic symbol index of every
769 other dynamic symbol. */
774 c = bfd_count_sections (output_bfd);
775 elf_link_hash_traverse (elf_hash_table (info),
776 elf32_sparc_adjust_dynindx,
778 elf_hash_table (info)->dynsymcount += c;
780 for (i = 1, s = output_bfd->sections; s != NULL; s = s->next, i++)
782 elf_section_data (s)->dynindx = i;
783 /* These symbols will have no names, so we don't need to
784 fiddle with dynstr_index. */
791 /* Increment the index of a dynamic symbol by a given amount. Called
792 via elf_link_hash_traverse. */
795 elf32_sparc_adjust_dynindx (h, cparg)
796 struct elf_link_hash_entry *h;
799 int *cp = (int *) cparg;
801 if (h->dynindx != -1)
806 /* Relocate a SPARC ELF section. */
809 elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
810 contents, relocs, local_syms, local_sections)
812 struct bfd_link_info *info;
814 asection *input_section;
816 Elf_Internal_Rela *relocs;
817 Elf_Internal_Sym *local_syms;
818 asection **local_sections;
821 Elf_Internal_Shdr *symtab_hdr;
822 struct elf_link_hash_entry **sym_hashes;
823 bfd_vma *local_got_offsets;
827 Elf_Internal_Rela *rel;
828 Elf_Internal_Rela *relend;
830 dynobj = elf_hash_table (info)->dynobj;
831 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
832 sym_hashes = elf_sym_hashes (input_bfd);
833 local_got_offsets = elf_local_got_offsets (input_bfd);
840 relend = relocs + input_section->reloc_count;
841 for (; rel < relend; rel++)
844 reloc_howto_type *howto;
845 unsigned long r_symndx;
846 struct elf_link_hash_entry *h;
847 Elf_Internal_Sym *sym;
850 bfd_reloc_status_type r;
852 r_type = ELF32_R_TYPE (rel->r_info);
853 if (r_type < 0 || r_type >= (int) R_SPARC_max)
855 bfd_set_error (bfd_error_bad_value);
858 howto = elf_sparc_howto_table + r_type;
860 r_symndx = ELF32_R_SYM (rel->r_info);
862 if (info->relocateable)
864 /* This is a relocateable link. We don't have to change
865 anything, unless the reloc is against a section symbol,
866 in which case we have to adjust according to where the
867 section symbol winds up in the output section. */
868 if (r_symndx < symtab_hdr->sh_info)
870 sym = local_syms + r_symndx;
871 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
873 sec = local_sections[r_symndx];
874 rel->r_addend += sec->output_offset + sym->st_value;
881 /* This is a final link. */
885 if (r_symndx < symtab_hdr->sh_info)
887 sym = local_syms + r_symndx;
888 sec = local_sections[r_symndx];
889 relocation = (sec->output_section->vma
895 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
896 if (h->root.type == bfd_link_hash_defined
897 || h->root.type == bfd_link_hash_defweak)
899 sec = h->root.u.def.section;
900 if ((r_type == R_SPARC_WPLT30
901 && h->plt_offset != (bfd_vma) -1)
902 || ((r_type == R_SPARC_GOT10
903 || r_type == R_SPARC_GOT13
904 || r_type == R_SPARC_GOT22)
905 && elf_hash_table (info)->dynamic_sections_created
908 || (h->elf_link_hash_flags
909 & ELF_LINK_HASH_DEF_REGULAR) == 0))
912 || (h->elf_link_hash_flags
913 & ELF_LINK_HASH_DEF_REGULAR) == 0)
914 && (input_section->flags & SEC_ALLOC) != 0
915 && (r_type == R_SPARC_8
916 || r_type == R_SPARC_16
917 || r_type == R_SPARC_32
918 || r_type == R_SPARC_DISP8
919 || r_type == R_SPARC_DISP16
920 || r_type == R_SPARC_DISP32
921 || r_type == R_SPARC_WDISP30
922 || r_type == R_SPARC_WDISP22
923 || r_type == R_SPARC_HI22
924 || r_type == R_SPARC_22
925 || r_type == R_SPARC_13
926 || r_type == R_SPARC_LO10
927 || r_type == R_SPARC_UA32
928 || ((r_type == R_SPARC_PC10
929 || r_type == R_SPARC_PC22)
930 && strcmp (h->root.root.string,
931 "_GLOBAL_OFFSET_TABLE_") != 0))))
933 /* In these cases, we don't need the relocation
934 value. We check specially because in some
935 obscure cases sec->output_section will be NULL. */
939 relocation = (h->root.u.def.value
940 + sec->output_section->vma
941 + sec->output_offset);
943 else if (h->root.type == bfd_link_hash_undefweak)
945 else if (info->shared && !info->symbolic)
949 if (! ((*info->callbacks->undefined_symbol)
950 (info, h->root.root.string, input_bfd,
951 input_section, rel->r_offset)))
962 /* Relocation is to the entry for this symbol in the global
966 sgot = bfd_get_section_by_name (dynobj, ".got");
967 BFD_ASSERT (sgot != NULL);
975 BFD_ASSERT (off != (bfd_vma) -1);
977 if (! elf_hash_table (info)->dynamic_sections_created
980 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
982 /* This is actually a static link, or it is a
983 -Bsymbolic link and the symbol is defined
984 locally. We must initialize this entry in the
985 global offset table. Since the offset must
986 always be a multiple of 4, we use the least
987 significant bit to record whether we have
988 initialized it already.
990 When doing a dynamic link, we create a .rela.got
991 relocation entry to initialize the value. This
992 is done in the finish_dynamic_symbol routine. */
997 bfd_put_32 (output_bfd, relocation,
998 sgot->contents + off);
1003 relocation = sgot->output_offset + off;
1009 BFD_ASSERT (local_got_offsets != NULL
1010 && local_got_offsets[r_symndx] != (bfd_vma) -1);
1012 off = local_got_offsets[r_symndx];
1014 /* The offset must always be a multiple of 4. We use
1015 the least significant bit to record whether we have
1016 already processed this entry. */
1021 bfd_put_32 (output_bfd, relocation, sgot->contents + off);
1026 Elf_Internal_Rela outrel;
1028 /* We need to generate a R_SPARC_RELATIVE reloc
1029 for the dynamic linker. */
1030 srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
1031 BFD_ASSERT (srelgot != NULL);
1033 outrel.r_offset = (sgot->output_section->vma
1034 + sgot->output_offset
1036 outrel.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE);
1037 outrel.r_addend = 0;
1038 bfd_elf32_swap_reloca_out (output_bfd, &outrel,
1039 (((Elf32_External_Rela *)
1041 + srelgot->reloc_count));
1042 ++srelgot->reloc_count;
1045 local_got_offsets[r_symndx] |= 1;
1048 relocation = sgot->output_offset + off;
1053 case R_SPARC_WPLT30:
1054 /* Relocation is to the entry for this symbol in the
1055 procedure linkage table. */
1056 BFD_ASSERT (h != NULL);
1058 if (h->plt_offset == (bfd_vma) -1)
1060 /* We didn't make a PLT entry for this symbol. This
1061 happens when statically linking PIC code, or when
1062 using -Bsymbolic. */
1068 splt = bfd_get_section_by_name (dynobj, ".plt");
1069 BFD_ASSERT (splt != NULL);
1072 relocation = (splt->output_section->vma
1073 + splt->output_offset
1080 && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
1084 case R_SPARC_DISP16:
1085 case R_SPARC_DISP32:
1086 case R_SPARC_WDISP30:
1087 case R_SPARC_WDISP22:
1100 && (input_section->flags & SEC_ALLOC) != 0)
1102 Elf_Internal_Rela outrel;
1104 /* When generating a shared object, these relocations
1105 are copied into the output file to be resolved at run
1112 name = (bfd_elf_string_from_elf_section
1114 elf_elfheader (input_bfd)->e_shstrndx,
1115 elf_section_data (input_section)->rel_hdr.sh_name));
1119 BFD_ASSERT (strncmp (name, ".rela", 5) == 0
1120 && strcmp (bfd_get_section_name (input_bfd,
1124 sreloc = bfd_get_section_by_name (dynobj, name);
1125 BFD_ASSERT (sreloc != NULL);
1128 outrel.r_offset = (rel->r_offset
1129 + input_section->output_section->vma
1130 + input_section->output_offset);
1132 && (! info->symbolic
1133 || (h->elf_link_hash_flags
1134 & ELF_LINK_HASH_DEF_REGULAR) == 0))
1136 BFD_ASSERT (h->dynindx != -1);
1137 outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
1138 outrel.r_addend = rel->r_addend;
1142 if (r_type == R_SPARC_32)
1144 outrel.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE);
1145 outrel.r_addend = relocation + rel->r_addend;
1152 sec = local_sections[r_symndx];
1155 BFD_ASSERT (h->root.type == bfd_link_hash_defined
1157 == bfd_link_hash_defweak));
1158 sec = h->root.u.def.section;
1160 if (sec != NULL && bfd_is_abs_section (sec))
1162 else if (sec == NULL || sec->owner == NULL)
1164 bfd_set_error (bfd_error_bad_value);
1171 osec = sec->output_section;
1172 indx = elf_section_data (osec)->dynindx;
1177 outrel.r_info = ELF32_R_INFO (indx, r_type);
1178 outrel.r_addend = relocation + rel->r_addend;
1182 bfd_elf32_swap_reloca_out (output_bfd, &outrel,
1183 (((Elf32_External_Rela *)
1185 + sreloc->reloc_count));
1186 ++sreloc->reloc_count;
1188 /* This reloc will be computed at runtime, so there's no
1189 need to do anything now. */
1197 r = _bfd_final_link_relocate (howto, input_bfd, input_section,
1198 contents, rel->r_offset,
1199 relocation, rel->r_addend);
1201 if (r != bfd_reloc_ok)
1206 case bfd_reloc_outofrange:
1208 case bfd_reloc_overflow:
1213 name = h->root.root.string;
1216 name = bfd_elf_string_from_elf_section (input_bfd,
1217 symtab_hdr->sh_link,
1222 name = bfd_section_name (input_bfd, sec);
1224 if (! ((*info->callbacks->reloc_overflow)
1225 (info, name, howto->name, (bfd_vma) 0,
1226 input_bfd, input_section, rel->r_offset)))
1237 /* Finish up dynamic symbol handling. We set the contents of various
1238 dynamic sections here. */
1241 elf32_sparc_finish_dynamic_symbol (output_bfd, info, h, sym)
1243 struct bfd_link_info *info;
1244 struct elf_link_hash_entry *h;
1245 Elf_Internal_Sym *sym;
1249 dynobj = elf_hash_table (info)->dynobj;
1251 if (h->plt_offset != (bfd_vma) -1)
1255 Elf_Internal_Rela rela;
1257 /* This symbol has an entry in the procedure linkage table. Set
1260 BFD_ASSERT (h->dynindx != -1);
1262 splt = bfd_get_section_by_name (dynobj, ".plt");
1263 srela = bfd_get_section_by_name (dynobj, ".rela.plt");
1264 BFD_ASSERT (splt != NULL && srela != NULL);
1266 /* Fill in the entry in the procedure linkage table. */
1267 bfd_put_32 (output_bfd,
1268 PLT_ENTRY_WORD0 + h->plt_offset,
1269 splt->contents + h->plt_offset);
1270 bfd_put_32 (output_bfd,
1272 + (((- (h->plt_offset + 4)) >> 2) & 0x3fffff)),
1273 splt->contents + h->plt_offset + 4);
1274 bfd_put_32 (output_bfd, PLT_ENTRY_WORD2,
1275 splt->contents + h->plt_offset + 8);
1277 /* Fill in the entry in the .rela.plt section. */
1278 rela.r_offset = (splt->output_section->vma
1279 + splt->output_offset
1281 rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_JMP_SLOT);
1283 bfd_elf32_swap_reloca_out (output_bfd, &rela,
1284 ((Elf32_External_Rela *) srela->contents
1285 + h->plt_offset / PLT_ENTRY_SIZE - 4));
1287 if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
1289 /* Mark the symbol as undefined, rather than as defined in
1290 the .plt section. Leave the value alone. */
1291 sym->st_shndx = SHN_UNDEF;
1295 if (h->got_offset != (bfd_vma) -1)
1299 Elf_Internal_Rela rela;
1301 /* This symbol has an entry in the global offset table. Set it
1304 BFD_ASSERT (h->dynindx != -1);
1306 sgot = bfd_get_section_by_name (dynobj, ".got");
1307 srela = bfd_get_section_by_name (dynobj, ".rela.got");
1308 BFD_ASSERT (sgot != NULL && srela != NULL);
1310 rela.r_offset = (sgot->output_section->vma
1311 + sgot->output_offset
1312 + (h->got_offset &~ 1));
1314 /* If this is a -Bsymbolic link, and the symbol is defined
1315 locally, we just want to emit a RELATIVE reloc. The entry in
1316 the global offset table will already have been initialized in
1317 the relocate_section function. */
1320 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
1321 rela.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE);
1324 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got_offset);
1325 rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_GLOB_DAT);
1329 bfd_elf32_swap_reloca_out (output_bfd, &rela,
1330 ((Elf32_External_Rela *) srela->contents
1331 + srela->reloc_count));
1332 ++srela->reloc_count;
1335 if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
1338 Elf_Internal_Rela rela;
1340 /* This symbols needs a copy reloc. Set it up. */
1342 BFD_ASSERT (h->dynindx != -1);
1344 s = bfd_get_section_by_name (h->root.u.def.section->owner,
1346 BFD_ASSERT (s != NULL);
1348 rela.r_offset = (h->root.u.def.value
1349 + h->root.u.def.section->output_section->vma
1350 + h->root.u.def.section->output_offset);
1351 rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_COPY);
1353 bfd_elf32_swap_reloca_out (output_bfd, &rela,
1354 ((Elf32_External_Rela *) s->contents
1359 /* Mark some specially defined symbols as absolute. */
1360 if (strcmp (h->root.root.string, "_DYNAMIC") == 0
1361 || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
1362 || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
1363 sym->st_shndx = SHN_ABS;
1368 /* Finish up the dynamic sections. */
1371 elf32_sparc_finish_dynamic_sections (output_bfd, info)
1373 struct bfd_link_info *info;
1379 dynobj = elf_hash_table (info)->dynobj;
1381 sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
1383 if (elf_hash_table (info)->dynamic_sections_created)
1386 Elf32_External_Dyn *dyncon, *dynconend;
1388 splt = bfd_get_section_by_name (dynobj, ".plt");
1389 BFD_ASSERT (splt != NULL && sdyn != NULL);
1391 dyncon = (Elf32_External_Dyn *) sdyn->contents;
1392 dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
1393 for (; dyncon < dynconend; dyncon++)
1395 Elf_Internal_Dyn dyn;
1399 bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
1403 case DT_PLTGOT: name = ".plt"; size = false; break;
1404 case DT_PLTRELSZ: name = ".rela.plt"; size = true; break;
1405 case DT_JMPREL: name = ".rela.plt"; size = false; break;
1406 default: name = NULL; size = false; break;
1413 s = bfd_get_section_by_name (output_bfd, name);
1419 dyn.d_un.d_ptr = s->vma;
1422 if (s->_cooked_size != 0)
1423 dyn.d_un.d_val = s->_cooked_size;
1425 dyn.d_un.d_val = s->_raw_size;
1428 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
1432 /* Clear the first four entries in the procedure linkage table,
1433 and put a nop in the last four bytes. */
1434 if (splt->_raw_size > 0)
1436 memset (splt->contents, 0, 4 * PLT_ENTRY_SIZE);
1437 bfd_put_32 (output_bfd, SPARC_NOP,
1438 splt->contents + splt->_raw_size - 4);
1441 elf_section_data (splt->output_section)->this_hdr.sh_entsize =
1445 /* Set the first entry in the global offset table to the address of
1446 the dynamic section. */
1447 sgot = bfd_get_section_by_name (dynobj, ".got");
1448 BFD_ASSERT (sgot != NULL);
1449 if (sgot->_raw_size > 0)
1452 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
1454 bfd_put_32 (output_bfd,
1455 sdyn->output_section->vma + sdyn->output_offset,
1459 elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
1465 Elf_Internal_Sym sym;
1467 /* Set up the section symbols for the output sections. */
1469 sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
1470 BFD_ASSERT (sdynsym != NULL);
1474 sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
1477 for (s = output_bfd->sections; s != NULL; s = s->next)
1481 sym.st_value = s->vma;
1483 indx = elf_section_data (s)->this_idx;
1484 BFD_ASSERT (indx > 0);
1485 sym.st_shndx = indx;
1487 bfd_elf32_swap_symbol_out (output_bfd, &sym,
1488 (PTR) (((Elf32_External_Sym *)
1490 + elf_section_data (s)->dynindx));
1493 /* Set the sh_info field of the output .dynsym section to the
1494 index of the first global symbol. */
1495 elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
1496 bfd_count_sections (output_bfd) + 1;
1502 /* Functions for dealing with the e_flags field.
1504 We don't define set_private_flags or copy_private_bfd_data because
1505 the only currently defined values are based on the bfd mach number,
1506 so we use the latter instead and defer setting e_flags until the
1507 file is written out. */
1509 /* Merge backend specific data from an object file to the output
1510 object file when linking. */
1513 elf32_sparc_merge_private_bfd_data (ibfd, obfd)
1519 /* This function is selected based on the input vector. We only
1520 want to copy information over if the output BFD also uses Elf
1522 if (bfd_get_flavour (obfd) != bfd_target_elf_flavour)
1528 /* ??? The native linker doesn't do this so we can't (otherwise gcc would
1529 have to know which linker is being used). Instead, the native linker
1530 bumps up the architecture level when it has to. However, I still think
1531 warnings like these are good, so it would be nice to have them turned on
1534 /* If the output machine is normal sparc, we can't allow v9 input files. */
1535 if (bfd_get_mach (obfd) == bfd_mach_sparc
1536 && (bfd_get_mach (ibfd) == bfd_mach_sparc_v8plus
1537 || bfd_get_mach (ibfd) == bfd_mach_sparc_v8plusa))
1540 (*_bfd_error_handler)
1541 ("%s: compiled for a v8plus system and target is v8",
1542 bfd_get_filename (ibfd));
1544 /* If the output machine is v9, we can't allow v9+vis input files. */
1545 if (bfd_get_mach (obfd) == bfd_mach_sparc_v8plus
1546 && bfd_get_mach (ibfd) == bfd_mach_sparc_v8plusa)
1549 (*_bfd_error_handler)
1550 ("%s: compiled for a v8plusa system and target is v8plus",
1551 bfd_get_filename (ibfd));
1554 if (bfd_get_mach (ibfd) >= bfd_mach_sparc_v9)
1557 (*_bfd_error_handler)
1558 ("%s: compiled for a 64 bit system and target is 32 bit",
1559 bfd_get_filename (ibfd));
1561 else if (bfd_get_mach (obfd) < bfd_get_mach (ibfd))
1562 bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd));
1567 bfd_set_error (bfd_error_bad_value);
1574 /* Set the right machine number. */
1577 elf32_sparc_object_p (abfd)
1580 if (elf_elfheader (abfd)->e_machine == EM_SPARC32PLUS)
1582 if (elf_elfheader (abfd)->e_flags & EF_SPARC_SUN_US1)
1583 return bfd_default_set_arch_mach (abfd, bfd_arch_sparc,
1584 bfd_mach_sparc_v8plusa);
1585 else if (elf_elfheader (abfd)->e_flags & EF_SPARC_32PLUS)
1586 return bfd_default_set_arch_mach (abfd, bfd_arch_sparc,
1587 bfd_mach_sparc_v8plus);
1592 return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, bfd_mach_sparc);
1595 /* The final processing done just before writing out the object file.
1596 We need to set the e_machine field appropriately. */
1599 elf32_sparc_final_write_processing (abfd, linker)
1603 switch (bfd_get_mach (abfd))
1605 case bfd_mach_sparc :
1606 break; /* nothing to do */
1607 case bfd_mach_sparc_v8plus :
1608 elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
1609 elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
1610 elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS;
1612 case bfd_mach_sparc_v8plusa :
1613 elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
1614 elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
1615 elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS | EF_SPARC_SUN_US1;
1622 #define TARGET_BIG_SYM bfd_elf32_sparc_vec
1623 #define TARGET_BIG_NAME "elf32-sparc"
1624 #define ELF_ARCH bfd_arch_sparc
1625 #define ELF_MACHINE_CODE EM_SPARC
1626 #define ELF_MACHINE_ALT1 EM_SPARC32PLUS
1627 #define ELF_MAXPAGESIZE 0x10000
1628 #define elf_backend_create_dynamic_sections \
1629 _bfd_elf_create_dynamic_sections
1630 #define elf_backend_check_relocs elf32_sparc_check_relocs
1631 #define elf_backend_adjust_dynamic_symbol \
1632 elf32_sparc_adjust_dynamic_symbol
1633 #define elf_backend_size_dynamic_sections \
1634 elf32_sparc_size_dynamic_sections
1635 #define elf_backend_relocate_section elf32_sparc_relocate_section
1636 #define elf_backend_finish_dynamic_symbol \
1637 elf32_sparc_finish_dynamic_symbol
1638 #define elf_backend_finish_dynamic_sections \
1639 elf32_sparc_finish_dynamic_sections
1640 #define bfd_elf32_bfd_merge_private_bfd_data \
1641 elf32_sparc_merge_private_bfd_data
1642 #define elf_backend_object_p elf32_sparc_object_p
1643 #define elf_backend_final_write_processing \
1644 elf32_sparc_final_write_processing
1645 #define elf_backend_want_got_plt 0
1646 #define elf_backend_plt_readonly 0
1647 #define elf_backend_want_plt_sym 1
1649 #include "elf32-target.h"