1 // sparc.cc -- sparc target support for gold.
3 // Copyright 2008, 2009 Free Software Foundation, Inc.
4 // Written by David S. Miller <davem@davemloft.net>.
6 // This file is part of gold.
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
30 #include "parameters.h"
37 #include "copy-relocs.h"
39 #include "target-reloc.h"
40 #include "target-select.h"
50 template<int size
, bool big_endian
>
51 class Output_data_plt_sparc
;
53 template<int size
, bool big_endian
>
54 class Target_sparc
: public Sized_target
<size
, big_endian
>
57 typedef Output_data_reloc
<elfcpp::SHT_RELA
, true, size
, big_endian
> Reloc_section
;
60 : Sized_target
<size
, big_endian
>(&sparc_info
),
61 got_(NULL
), plt_(NULL
), rela_dyn_(NULL
),
62 copy_relocs_(elfcpp::R_SPARC_COPY
), dynbss_(NULL
),
63 got_mod_index_offset_(-1U), tls_get_addr_sym_(NULL
)
67 // Process the relocations to determine unreferenced sections for
68 // garbage collection.
70 gc_process_relocs(Symbol_table
* symtab
,
72 Sized_relobj
<size
, big_endian
>* object
,
73 unsigned int data_shndx
,
75 const unsigned char* prelocs
,
77 Output_section
* output_section
,
78 bool needs_special_offset_handling
,
79 size_t local_symbol_count
,
80 const unsigned char* plocal_symbols
);
82 // Scan the relocations to look for symbol adjustments.
84 scan_relocs(Symbol_table
* symtab
,
86 Sized_relobj
<size
, big_endian
>* object
,
87 unsigned int data_shndx
,
89 const unsigned char* prelocs
,
91 Output_section
* output_section
,
92 bool needs_special_offset_handling
,
93 size_t local_symbol_count
,
94 const unsigned char* plocal_symbols
);
95 // Finalize the sections.
97 do_finalize_sections(Layout
*, const Input_objects
*, Symbol_table
*);
99 // Return the value to use for a dynamic which requires special
102 do_dynsym_value(const Symbol
*) const;
104 // Relocate a section.
106 relocate_section(const Relocate_info
<size
, big_endian
>*,
107 unsigned int sh_type
,
108 const unsigned char* prelocs
,
110 Output_section
* output_section
,
111 bool needs_special_offset_handling
,
113 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
114 section_size_type view_size
,
115 const Reloc_symbol_changes
*);
117 // Scan the relocs during a relocatable link.
119 scan_relocatable_relocs(Symbol_table
* symtab
,
121 Sized_relobj
<size
, big_endian
>* object
,
122 unsigned int data_shndx
,
123 unsigned int sh_type
,
124 const unsigned char* prelocs
,
126 Output_section
* output_section
,
127 bool needs_special_offset_handling
,
128 size_t local_symbol_count
,
129 const unsigned char* plocal_symbols
,
130 Relocatable_relocs
*);
132 // Relocate a section during a relocatable link.
134 relocate_for_relocatable(const Relocate_info
<size
, big_endian
>*,
135 unsigned int sh_type
,
136 const unsigned char* prelocs
,
138 Output_section
* output_section
,
139 off_t offset_in_output_section
,
140 const Relocatable_relocs
*,
142 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
143 section_size_type view_size
,
144 unsigned char* reloc_view
,
145 section_size_type reloc_view_size
);
146 // Return whether SYM is defined by the ABI.
148 do_is_defined_by_abi(const Symbol
* sym
) const
150 // XXX Really need to support this better...
151 if (sym
->type() == elfcpp::STT_SPARC_REGISTER
)
154 return strcmp(sym
->name(), "___tls_get_addr") == 0;
157 // Return whether there is a GOT section.
159 has_got_section() const
160 { return this->got_
!= NULL
; }
162 // Return the size of the GOT section.
166 gold_assert(this->got_
!= NULL
);
167 return this->got_
->data_size();
172 // The class which scans relocations.
177 : issued_non_pic_error_(false)
181 local(Symbol_table
* symtab
, Layout
* layout
, Target_sparc
* target
,
182 Sized_relobj
<size
, big_endian
>* object
,
183 unsigned int data_shndx
,
184 Output_section
* output_section
,
185 const elfcpp::Rela
<size
, big_endian
>& reloc
, unsigned int r_type
,
186 const elfcpp::Sym
<size
, big_endian
>& lsym
);
189 global(Symbol_table
* symtab
, Layout
* layout
, Target_sparc
* target
,
190 Sized_relobj
<size
, big_endian
>* object
,
191 unsigned int data_shndx
,
192 Output_section
* output_section
,
193 const elfcpp::Rela
<size
, big_endian
>& reloc
, unsigned int r_type
,
197 local_reloc_may_be_function_pointer(Symbol_table
* , Layout
* ,
199 Sized_relobj
<size
, big_endian
>* ,
202 const elfcpp::Rela
<size
, big_endian
>& ,
204 const elfcpp::Sym
<size
, big_endian
>&)
208 global_reloc_may_be_function_pointer(Symbol_table
* , Layout
* ,
210 Sized_relobj
<size
, big_endian
>* ,
213 const elfcpp::Rela
<size
,
215 unsigned int , Symbol
*)
221 unsupported_reloc_local(Sized_relobj
<size
, big_endian
>*,
222 unsigned int r_type
);
225 unsupported_reloc_global(Sized_relobj
<size
, big_endian
>*,
226 unsigned int r_type
, Symbol
*);
229 generate_tls_call(Symbol_table
* symtab
, Layout
* layout
,
230 Target_sparc
* target
);
233 check_non_pic(Relobj
*, unsigned int r_type
);
235 // Whether we have issued an error about a non-PIC compilation.
236 bool issued_non_pic_error_
;
239 // The class which implements relocation.
244 : ignore_gd_add_(false)
249 if (this->ignore_gd_add_
)
251 // FIXME: This needs to specify the location somehow.
252 gold_error(_("missing expected TLS relocation"));
256 // Do a relocation. Return false if the caller should not issue
257 // any warnings about this relocation.
259 relocate(const Relocate_info
<size
, big_endian
>*, Target_sparc
*,
260 Output_section
*, size_t relnum
,
261 const elfcpp::Rela
<size
, big_endian
>&,
262 unsigned int r_type
, const Sized_symbol
<size
>*,
263 const Symbol_value
<size
>*,
265 typename
elfcpp::Elf_types
<size
>::Elf_Addr
,
269 // Do a TLS relocation.
271 relocate_tls(const Relocate_info
<size
, big_endian
>*, Target_sparc
* target
,
272 size_t relnum
, const elfcpp::Rela
<size
, big_endian
>&,
273 unsigned int r_type
, const Sized_symbol
<size
>*,
274 const Symbol_value
<size
>*,
276 typename
elfcpp::Elf_types
<size
>::Elf_Addr
,
279 // Ignore the next relocation which should be R_SPARC_TLS_GD_ADD
283 // A class which returns the size required for a relocation type,
284 // used while scanning relocs during a relocatable link.
285 class Relocatable_size_for_reloc
289 get_size_for_reloc(unsigned int, Relobj
*);
292 // Get the GOT section, creating it if necessary.
293 Output_data_got
<size
, big_endian
>*
294 got_section(Symbol_table
*, Layout
*);
296 // Create a PLT entry for a global symbol.
298 make_plt_entry(Symbol_table
*, Layout
*, Symbol
*);
300 // Create a GOT entry for the TLS module index.
302 got_mod_index_entry(Symbol_table
* symtab
, Layout
* layout
,
303 Sized_relobj
<size
, big_endian
>* object
);
305 // Return the gsym for "__tls_get_addr". Cache if not already
308 tls_get_addr_sym(Symbol_table
* symtab
)
310 if (!this->tls_get_addr_sym_
)
311 this->tls_get_addr_sym_
= symtab
->lookup("__tls_get_addr", NULL
);
312 gold_assert(this->tls_get_addr_sym_
);
313 return this->tls_get_addr_sym_
;
316 // Get the PLT section.
317 const Output_data_plt_sparc
<size
, big_endian
>*
320 gold_assert(this->plt_
!= NULL
);
324 // Get the dynamic reloc section, creating it if necessary.
326 rela_dyn_section(Layout
*);
328 // Copy a relocation against a global symbol.
330 copy_reloc(Symbol_table
* symtab
, Layout
* layout
,
331 Sized_relobj
<size
, big_endian
>* object
,
332 unsigned int shndx
, Output_section
* output_section
,
333 Symbol
* sym
, const elfcpp::Rela
<size
, big_endian
>& reloc
)
335 this->copy_relocs_
.copy_reloc(symtab
, layout
,
336 symtab
->get_sized_symbol
<size
>(sym
),
337 object
, shndx
, output_section
,
338 reloc
, this->rela_dyn_section(layout
));
341 // Information about this specific target which we pass to the
342 // general Target structure.
343 static Target::Target_info sparc_info
;
345 // The types of GOT entries needed for this platform.
348 GOT_TYPE_STANDARD
= 0, // GOT entry for a regular symbol
349 GOT_TYPE_TLS_OFFSET
= 1, // GOT entry for TLS offset
350 GOT_TYPE_TLS_PAIR
= 2, // GOT entry for TLS module/offset pair
354 Output_data_got
<size
, big_endian
>* got_
;
356 Output_data_plt_sparc
<size
, big_endian
>* plt_
;
357 // The dynamic reloc section.
358 Reloc_section
* rela_dyn_
;
359 // Relocs saved to avoid a COPY reloc.
360 Copy_relocs
<elfcpp::SHT_RELA
, size
, big_endian
> copy_relocs_
;
361 // Space for variables copied with a COPY reloc.
362 Output_data_space
* dynbss_
;
363 // Offset of the GOT entry for the TLS module index;
364 unsigned int got_mod_index_offset_
;
365 // Cached pointer to __tls_get_addr symbol
366 Symbol
* tls_get_addr_sym_
;
370 Target::Target_info Target_sparc
<32, true>::sparc_info
=
373 true, // is_big_endian
374 elfcpp::EM_SPARC
, // machine_code
375 false, // has_make_symbol
376 false, // has_resolve
377 false, // has_code_fill
378 true, // is_default_stack_executable
380 "/usr/lib/ld.so.1", // dynamic_linker
381 0x00010000, // default_text_segment_address
382 64 * 1024, // abi_pagesize (overridable by -z max-page-size)
383 8 * 1024, // common_pagesize (overridable by -z common-page-size)
384 elfcpp::SHN_UNDEF
, // small_common_shndx
385 elfcpp::SHN_UNDEF
, // large_common_shndx
386 0, // small_common_section_flags
387 0, // large_common_section_flags
388 NULL
, // attributes_section
389 NULL
// attributes_vendor
393 Target::Target_info Target_sparc
<64, true>::sparc_info
=
396 true, // is_big_endian
397 elfcpp::EM_SPARCV9
, // machine_code
398 false, // has_make_symbol
399 false, // has_resolve
400 false, // has_code_fill
401 true, // is_default_stack_executable
403 "/usr/lib/sparcv9/ld.so.1", // dynamic_linker
404 0x100000, // default_text_segment_address
405 64 * 1024, // abi_pagesize (overridable by -z max-page-size)
406 8 * 1024, // common_pagesize (overridable by -z common-page-size)
407 elfcpp::SHN_UNDEF
, // small_common_shndx
408 elfcpp::SHN_UNDEF
, // large_common_shndx
409 0, // small_common_section_flags
410 0, // large_common_section_flags
411 NULL
, // attributes_section
412 NULL
// attributes_vendor
415 // We have to take care here, even when operating in little-endian
416 // mode, sparc instructions are still big endian.
417 template<int size
, bool big_endian
>
418 class Sparc_relocate_functions
421 // Do a simple relocation with the addend in the relocation.
422 template<int valsize
>
424 rela(unsigned char* view
,
425 unsigned int right_shift
,
426 typename
elfcpp::Elf_types
<valsize
>::Elf_Addr dst_mask
,
427 typename
elfcpp::Swap
<size
, big_endian
>::Valtype value
,
428 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
)
430 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
431 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
432 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
433 Valtype reloc
= ((value
+ addend
) >> right_shift
);
438 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| reloc
);
441 // Do a simple relocation using a symbol value with the addend in
443 template<int valsize
>
445 rela(unsigned char* view
,
446 unsigned int right_shift
,
447 typename
elfcpp::Elf_types
<valsize
>::Elf_Addr dst_mask
,
448 const Sized_relobj
<size
, big_endian
>* object
,
449 const Symbol_value
<size
>* psymval
,
450 typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype addend
)
452 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
453 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
454 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
455 Valtype reloc
= (psymval
->value(object
, addend
) >> right_shift
);
460 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| reloc
);
463 // Do a simple relocation using a symbol value with the addend in
464 // the relocation, unaligned.
465 template<int valsize
>
467 rela_ua(unsigned char* view
,
468 unsigned int right_shift
, elfcpp::Elf_Xword dst_mask
,
469 const Sized_relobj
<size
, big_endian
>* object
,
470 const Symbol_value
<size
>* psymval
,
471 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
)
473 typedef typename
elfcpp::Swap_unaligned
<valsize
,
474 big_endian
>::Valtype Valtype
;
475 unsigned char* wv
= view
;
476 Valtype val
= elfcpp::Swap_unaligned
<valsize
, big_endian
>::readval(wv
);
477 Valtype reloc
= (psymval
->value(object
, addend
) >> right_shift
);
482 elfcpp::Swap_unaligned
<valsize
, big_endian
>::writeval(wv
, val
| reloc
);
485 // Do a simple PC relative relocation with a Symbol_value with the
486 // addend in the relocation.
487 template<int valsize
>
489 pcrela(unsigned char* view
,
490 unsigned int right_shift
,
491 typename
elfcpp::Elf_types
<valsize
>::Elf_Addr dst_mask
,
492 const Sized_relobj
<size
, big_endian
>* object
,
493 const Symbol_value
<size
>* psymval
,
494 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
495 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
497 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
498 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
499 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
500 Valtype reloc
= ((psymval
->value(object
, addend
) - address
)
506 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| reloc
);
509 template<int valsize
>
511 pcrela_unaligned(unsigned char* view
,
512 const Sized_relobj
<size
, big_endian
>* object
,
513 const Symbol_value
<size
>* psymval
,
514 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
515 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
517 typedef typename
elfcpp::Swap_unaligned
<valsize
,
518 big_endian
>::Valtype Valtype
;
519 unsigned char* wv
= view
;
520 Valtype reloc
= (psymval
->value(object
, addend
) - address
);
522 elfcpp::Swap_unaligned
<valsize
, big_endian
>::writeval(wv
, reloc
);
525 typedef Sparc_relocate_functions
<size
, big_endian
> This
;
526 typedef Sparc_relocate_functions
<size
, true> This_insn
;
529 // R_SPARC_WDISP30: (Symbol + Addend - Address) >> 2
531 wdisp30(unsigned char* view
,
532 const Sized_relobj
<size
, big_endian
>* object
,
533 const Symbol_value
<size
>* psymval
,
534 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
535 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
537 This_insn::template pcrela
<32>(view
, 2, 0x3fffffff, object
,
538 psymval
, addend
, address
);
541 // R_SPARC_WDISP22: (Symbol + Addend - Address) >> 2
543 wdisp22(unsigned char* view
,
544 const Sized_relobj
<size
, big_endian
>* object
,
545 const Symbol_value
<size
>* psymval
,
546 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
547 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
549 This_insn::template pcrela
<32>(view
, 2, 0x003fffff, object
,
550 psymval
, addend
, address
);
553 // R_SPARC_WDISP19: (Symbol + Addend - Address) >> 2
555 wdisp19(unsigned char* view
,
556 const Sized_relobj
<size
, big_endian
>* object
,
557 const Symbol_value
<size
>* psymval
,
558 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
559 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
561 This_insn::template pcrela
<32>(view
, 2, 0x0007ffff, object
,
562 psymval
, addend
, address
);
565 // R_SPARC_WDISP16: (Symbol + Addend - Address) >> 2
567 wdisp16(unsigned char* view
,
568 const Sized_relobj
<size
, big_endian
>* object
,
569 const Symbol_value
<size
>* psymval
,
570 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
571 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
573 typedef typename
elfcpp::Swap
<32, true>::Valtype Valtype
;
574 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
575 Valtype val
= elfcpp::Swap
<32, true>::readval(wv
);
576 Valtype reloc
= ((psymval
->value(object
, addend
) - address
)
579 // The relocation value is split between the low 14 bits,
581 val
&= ~((0x3 << 20) | 0x3fff);
582 reloc
= (((reloc
& 0xc000) << (20 - 14))
583 | (reloc
& 0x3ffff));
585 elfcpp::Swap
<32, true>::writeval(wv
, val
| reloc
);
588 // R_SPARC_PC22: (Symbol + Addend - Address) >> 10
590 pc22(unsigned char* view
,
591 const Sized_relobj
<size
, big_endian
>* object
,
592 const Symbol_value
<size
>* psymval
,
593 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
594 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
596 This_insn::template pcrela
<32>(view
, 10, 0x003fffff, object
,
597 psymval
, addend
, address
);
600 // R_SPARC_PC10: (Symbol + Addend - Address) & 0x3ff
602 pc10(unsigned char* view
,
603 const Sized_relobj
<size
, big_endian
>* object
,
604 const Symbol_value
<size
>* psymval
,
605 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
606 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
608 This_insn::template pcrela
<32>(view
, 0, 0x000003ff, object
,
609 psymval
, addend
, address
);
612 // R_SPARC_HI22: (Symbol + Addend) >> 10
614 hi22(unsigned char* view
,
615 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
,
616 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
618 This_insn::template rela
<32>(view
, 10, 0x003fffff, value
, addend
);
621 // R_SPARC_HI22: (Symbol + Addend) >> 10
623 hi22(unsigned char* view
,
624 const Sized_relobj
<size
, big_endian
>* object
,
625 const Symbol_value
<size
>* psymval
,
626 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
628 This_insn::template rela
<32>(view
, 10, 0x003fffff, object
, psymval
, addend
);
631 // R_SPARC_PCPLT22: (Symbol + Addend - Address) >> 10
633 pcplt22(unsigned char* view
,
634 const Sized_relobj
<size
, big_endian
>* object
,
635 const Symbol_value
<size
>* psymval
,
636 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
637 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
639 This_insn::template pcrela
<32>(view
, 10, 0x003fffff, object
,
640 psymval
, addend
, address
);
643 // R_SPARC_LO10: (Symbol + Addend) & 0x3ff
645 lo10(unsigned char* view
,
646 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
,
647 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
649 This_insn::template rela
<32>(view
, 0, 0x000003ff, value
, addend
);
652 // R_SPARC_LO10: (Symbol + Addend) & 0x3ff
654 lo10(unsigned char* view
,
655 const Sized_relobj
<size
, big_endian
>* object
,
656 const Symbol_value
<size
>* psymval
,
657 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
659 This_insn::template rela
<32>(view
, 0, 0x000003ff, object
, psymval
, addend
);
662 // R_SPARC_LO10: (Symbol + Addend) & 0x3ff
664 lo10(unsigned char* view
,
665 const Sized_relobj
<size
, big_endian
>* object
,
666 const Symbol_value
<size
>* psymval
,
667 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
668 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
670 This_insn::template pcrela
<32>(view
, 0, 0x000003ff, object
,
671 psymval
, addend
, address
);
674 // R_SPARC_OLO10: ((Symbol + Addend) & 0x3ff) + Addend2
676 olo10(unsigned char* view
,
677 const Sized_relobj
<size
, big_endian
>* object
,
678 const Symbol_value
<size
>* psymval
,
679 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
680 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend2
)
682 typedef typename
elfcpp::Swap
<32, true>::Valtype Valtype
;
683 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
684 Valtype val
= elfcpp::Swap
<32, true>::readval(wv
);
685 Valtype reloc
= psymval
->value(object
, addend
);
692 elfcpp::Swap
<32, true>::writeval(wv
, val
| reloc
);
695 // R_SPARC_22: (Symbol + Addend)
697 rela32_22(unsigned char* view
,
698 const Sized_relobj
<size
, big_endian
>* object
,
699 const Symbol_value
<size
>* psymval
,
700 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
702 This_insn::template rela
<32>(view
, 0, 0x003fffff, object
, psymval
, addend
);
705 // R_SPARC_13: (Symbol + Addend)
707 rela32_13(unsigned char* view
,
708 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
,
709 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
711 This_insn::template rela
<32>(view
, 0, 0x00001fff, value
, addend
);
714 // R_SPARC_13: (Symbol + Addend)
716 rela32_13(unsigned char* view
,
717 const Sized_relobj
<size
, big_endian
>* object
,
718 const Symbol_value
<size
>* psymval
,
719 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
721 This_insn::template rela
<32>(view
, 0, 0x00001fff, object
, psymval
, addend
);
724 // R_SPARC_UA16: (Symbol + Addend)
726 ua16(unsigned char* view
,
727 const Sized_relobj
<size
, big_endian
>* object
,
728 const Symbol_value
<size
>* psymval
,
729 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
731 This::template rela_ua
<16>(view
, 0, 0xffff, object
, psymval
, addend
);
734 // R_SPARC_UA32: (Symbol + Addend)
736 ua32(unsigned char* view
,
737 const Sized_relobj
<size
, big_endian
>* object
,
738 const Symbol_value
<size
>* psymval
,
739 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
741 This::template rela_ua
<32>(view
, 0, 0xffffffff, object
, psymval
, addend
);
744 // R_SPARC_UA64: (Symbol + Addend)
746 ua64(unsigned char* view
,
747 const Sized_relobj
<size
, big_endian
>* object
,
748 const Symbol_value
<size
>* psymval
,
749 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
751 This::template rela_ua
<64>(view
, 0, ~(elfcpp::Elf_Xword
) 0,
752 object
, psymval
, addend
);
755 // R_SPARC_DISP8: (Symbol + Addend - Address)
757 disp8(unsigned char* view
,
758 const Sized_relobj
<size
, big_endian
>* object
,
759 const Symbol_value
<size
>* psymval
,
760 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
761 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
763 This::template pcrela_unaligned
<8>(view
, object
, psymval
,
767 // R_SPARC_DISP16: (Symbol + Addend - Address)
769 disp16(unsigned char* view
,
770 const Sized_relobj
<size
, big_endian
>* object
,
771 const Symbol_value
<size
>* psymval
,
772 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
773 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
775 This::template pcrela_unaligned
<16>(view
, object
, psymval
,
779 // R_SPARC_DISP32: (Symbol + Addend - Address)
781 disp32(unsigned char* view
,
782 const Sized_relobj
<size
, big_endian
>* object
,
783 const Symbol_value
<size
>* psymval
,
784 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
785 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
787 This::template pcrela_unaligned
<32>(view
, object
, psymval
,
791 // R_SPARC_DISP64: (Symbol + Addend - Address)
793 disp64(unsigned char* view
,
794 const Sized_relobj
<size
, big_endian
>* object
,
795 const Symbol_value
<size
>* psymval
,
796 elfcpp::Elf_Xword addend
,
797 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
799 This::template pcrela_unaligned
<64>(view
, object
, psymval
,
803 // R_SPARC_H44: (Symbol + Addend) >> 22
805 h44(unsigned char* view
,
806 const Sized_relobj
<size
, big_endian
>* object
,
807 const Symbol_value
<size
>* psymval
,
808 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
810 This_insn::template rela
<32>(view
, 22, 0x003fffff, object
, psymval
, addend
);
813 // R_SPARC_M44: ((Symbol + Addend) >> 12) & 0x3ff
815 m44(unsigned char* view
,
816 const Sized_relobj
<size
, big_endian
>* object
,
817 const Symbol_value
<size
>* psymval
,
818 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
820 This_insn::template rela
<32>(view
, 12, 0x000003ff, object
, psymval
, addend
);
823 // R_SPARC_L44: (Symbol + Addend) & 0xfff
825 l44(unsigned char* view
,
826 const Sized_relobj
<size
, big_endian
>* object
,
827 const Symbol_value
<size
>* psymval
,
828 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
830 This_insn::template rela
<32>(view
, 0, 0x00000fff, object
, psymval
, addend
);
833 // R_SPARC_HH22: (Symbol + Addend) >> 42
835 hh22(unsigned char* view
,
836 const Sized_relobj
<size
, big_endian
>* object
,
837 const Symbol_value
<size
>* psymval
,
838 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
840 This_insn::template rela
<32>(view
, 42, 0x003fffff, object
, psymval
, addend
);
843 // R_SPARC_PC_HH22: (Symbol + Addend - Address) >> 42
845 pc_hh22(unsigned char* view
,
846 const Sized_relobj
<size
, big_endian
>* object
,
847 const Symbol_value
<size
>* psymval
,
848 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
849 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
851 This_insn::template pcrela
<32>(view
, 42, 0x003fffff, object
,
852 psymval
, addend
, address
);
855 // R_SPARC_HM10: ((Symbol + Addend) >> 32) & 0x3ff
857 hm10(unsigned char* view
,
858 const Sized_relobj
<size
, big_endian
>* object
,
859 const Symbol_value
<size
>* psymval
,
860 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
862 This_insn::template rela
<32>(view
, 32, 0x000003ff, object
, psymval
, addend
);
865 // R_SPARC_PC_HM10: ((Symbol + Addend - Address) >> 32) & 0x3ff
867 pc_hm10(unsigned char* view
,
868 const Sized_relobj
<size
, big_endian
>* object
,
869 const Symbol_value
<size
>* psymval
,
870 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
871 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
873 This_insn::template pcrela
<32>(view
, 32, 0x000003ff, object
,
874 psymval
, addend
, address
);
877 // R_SPARC_11: (Symbol + Addend)
879 rela32_11(unsigned char* view
,
880 const Sized_relobj
<size
, big_endian
>* object
,
881 const Symbol_value
<size
>* psymval
,
882 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
884 This_insn::template rela
<32>(view
, 0, 0x000007ff, object
, psymval
, addend
);
887 // R_SPARC_10: (Symbol + Addend)
889 rela32_10(unsigned char* view
,
890 const Sized_relobj
<size
, big_endian
>* object
,
891 const Symbol_value
<size
>* psymval
,
892 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
894 This_insn::template rela
<32>(view
, 0, 0x000003ff, object
, psymval
, addend
);
897 // R_SPARC_7: (Symbol + Addend)
899 rela32_7(unsigned char* view
,
900 const Sized_relobj
<size
, big_endian
>* object
,
901 const Symbol_value
<size
>* psymval
,
902 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
904 This_insn::template rela
<32>(view
, 0, 0x0000007f, object
, psymval
, addend
);
907 // R_SPARC_6: (Symbol + Addend)
909 rela32_6(unsigned char* view
,
910 const Sized_relobj
<size
, big_endian
>* object
,
911 const Symbol_value
<size
>* psymval
,
912 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
914 This_insn::template rela
<32>(view
, 0, 0x0000003f, object
, psymval
, addend
);
917 // R_SPARC_5: (Symbol + Addend)
919 rela32_5(unsigned char* view
,
920 const Sized_relobj
<size
, big_endian
>* object
,
921 const Symbol_value
<size
>* psymval
,
922 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
924 This_insn::template rela
<32>(view
, 0, 0x0000001f, object
, psymval
, addend
);
927 // R_SPARC_TLS_LDO_HIX22: @dtpoff(Symbol + Addend) >> 10
929 ldo_hix22(unsigned char* view
,
930 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
,
931 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
933 This_insn::hi22(view
, value
, addend
);
936 // R_SPARC_TLS_LDO_LOX10: @dtpoff(Symbol + Addend) & 0x3ff
938 ldo_lox10(unsigned char* view
,
939 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
,
940 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
942 typedef typename
elfcpp::Swap
<32, true>::Valtype Valtype
;
943 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
944 Valtype val
= elfcpp::Swap
<32, true>::readval(wv
);
945 Valtype reloc
= (value
+ addend
);
950 elfcpp::Swap
<32, true>::writeval(wv
, val
| reloc
);
953 // R_SPARC_TLS_LE_HIX22: (@tpoff(Symbol + Addend) ^ 0xffffffffffffffff) >> 10
955 hix22(unsigned char* view
,
956 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
,
957 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
959 typedef typename
elfcpp::Swap
<32, true>::Valtype Valtype
;
960 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
961 Valtype val
= elfcpp::Swap
<32, true>::readval(wv
);
962 Valtype reloc
= (value
+ addend
);
966 reloc
^= ~(Valtype
)0;
971 elfcpp::Swap
<32, true>::writeval(wv
, val
| reloc
);
974 // R_SPARC_HIX22: ((Symbol + Addend) ^ 0xffffffffffffffff) >> 10
976 hix22(unsigned char* view
,
977 const Sized_relobj
<size
, big_endian
>* object
,
978 const Symbol_value
<size
>* psymval
,
979 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
981 typedef typename
elfcpp::Swap
<32, true>::Valtype Valtype
;
982 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
983 Valtype val
= elfcpp::Swap
<32, true>::readval(wv
);
984 Valtype reloc
= psymval
->value(object
, addend
);
988 reloc
^= ~(Valtype
)0;
993 elfcpp::Swap
<32, true>::writeval(wv
, val
| reloc
);
997 // R_SPARC_TLS_LE_LOX10: (@tpoff(Symbol + Addend) & 0x3ff) | 0x1c00
999 lox10(unsigned char* view
,
1000 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
,
1001 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
1003 typedef typename
elfcpp::Swap
<32, true>::Valtype Valtype
;
1004 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
1005 Valtype val
= elfcpp::Swap
<32, true>::readval(wv
);
1006 Valtype reloc
= (value
+ addend
);
1012 elfcpp::Swap
<32, true>::writeval(wv
, val
| reloc
);
1015 // R_SPARC_LOX10: ((Symbol + Addend) & 0x3ff) | 0x1c00
1017 lox10(unsigned char* view
,
1018 const Sized_relobj
<size
, big_endian
>* object
,
1019 const Symbol_value
<size
>* psymval
,
1020 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
1022 typedef typename
elfcpp::Swap
<32, true>::Valtype Valtype
;
1023 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
1024 Valtype val
= elfcpp::Swap
<32, true>::readval(wv
);
1025 Valtype reloc
= psymval
->value(object
, addend
);
1031 elfcpp::Swap
<32, true>::writeval(wv
, val
| reloc
);
1035 // Get the GOT section, creating it if necessary.
1037 template<int size
, bool big_endian
>
1038 Output_data_got
<size
, big_endian
>*
1039 Target_sparc
<size
, big_endian
>::got_section(Symbol_table
* symtab
,
1042 if (this->got_
== NULL
)
1044 gold_assert(symtab
!= NULL
&& layout
!= NULL
);
1046 this->got_
= new Output_data_got
<size
, big_endian
>();
1049 os
= layout
->add_output_section_data(".got", elfcpp::SHT_PROGBITS
,
1051 | elfcpp::SHF_WRITE
),
1052 this->got_
, false, true, false,
1055 // Define _GLOBAL_OFFSET_TABLE_ at the start of the .got section.
1056 symtab
->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL
,
1057 Symbol_table::PREDEFINED
,
1059 0, 0, elfcpp::STT_OBJECT
,
1061 elfcpp::STV_HIDDEN
, 0,
1068 // Get the dynamic reloc section, creating it if necessary.
1070 template<int size
, bool big_endian
>
1071 typename Target_sparc
<size
, big_endian
>::Reloc_section
*
1072 Target_sparc
<size
, big_endian
>::rela_dyn_section(Layout
* layout
)
1074 if (this->rela_dyn_
== NULL
)
1076 gold_assert(layout
!= NULL
);
1077 this->rela_dyn_
= new Reloc_section(parameters
->options().combreloc());
1078 layout
->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA
,
1079 elfcpp::SHF_ALLOC
, this->rela_dyn_
, true,
1080 false, false, false);
1082 return this->rela_dyn_
;
1085 // A class to handle the PLT data.
1087 template<int size
, bool big_endian
>
1088 class Output_data_plt_sparc
: public Output_section_data
1091 typedef Output_data_reloc
<elfcpp::SHT_RELA
, true,
1092 size
, big_endian
> Reloc_section
;
1094 Output_data_plt_sparc(Layout
*);
1096 // Add an entry to the PLT.
1097 void add_entry(Symbol
* gsym
);
1099 // Return the .rela.plt section data.
1100 const Reloc_section
* rel_plt() const
1106 void do_adjust_output_section(Output_section
* os
);
1108 // Write to a map file.
1110 do_print_to_mapfile(Mapfile
* mapfile
) const
1111 { mapfile
->print_output_data(this, _("** PLT")); }
1114 // The size of an entry in the PLT.
1115 static const int base_plt_entry_size
= (size
== 32 ? 12 : 32);
1117 static const unsigned int plt_entries_per_block
= 160;
1118 static const unsigned int plt_insn_chunk_size
= 24;
1119 static const unsigned int plt_pointer_chunk_size
= 8;
1120 static const unsigned int plt_block_size
=
1121 (plt_entries_per_block
1122 * (plt_insn_chunk_size
+ plt_pointer_chunk_size
));
1124 // Set the final size.
1126 set_final_data_size()
1128 unsigned int full_count
= this->count_
+ 4;
1129 unsigned int extra
= (size
== 32 ? 4 : 0);
1131 if (size
== 32 || full_count
< 32768)
1132 this->set_data_size((full_count
* base_plt_entry_size
) + extra
);
1135 unsigned int ext_cnt
= full_count
- 32768;
1137 this->set_data_size((32768 * base_plt_entry_size
)
1139 * (plt_insn_chunk_size
1140 + plt_pointer_chunk_size
)));
1144 // Write out the PLT data.
1146 do_write(Output_file
*);
1148 // The reloc section.
1149 Reloc_section
* rel_
;
1150 // The number of PLT entries.
1151 unsigned int count_
;
1154 // Define the constants as required by C++ standard.
1156 template<int size
, bool big_endian
>
1157 const int Output_data_plt_sparc
<size
, big_endian
>::base_plt_entry_size
;
1159 template<int size
, bool big_endian
>
1161 Output_data_plt_sparc
<size
, big_endian
>::plt_entries_per_block
;
1163 template<int size
, bool big_endian
>
1164 const unsigned int Output_data_plt_sparc
<size
, big_endian
>::plt_insn_chunk_size
;
1166 template<int size
, bool big_endian
>
1168 Output_data_plt_sparc
<size
, big_endian
>::plt_pointer_chunk_size
;
1170 template<int size
, bool big_endian
>
1171 const unsigned int Output_data_plt_sparc
<size
, big_endian
>::plt_block_size
;
1173 // Create the PLT section. The ordinary .got section is an argument,
1174 // since we need to refer to the start.
1176 template<int size
, bool big_endian
>
1177 Output_data_plt_sparc
<size
, big_endian
>::Output_data_plt_sparc(Layout
* layout
)
1178 : Output_section_data(size
== 32 ? 4 : 8), count_(0)
1180 this->rel_
= new Reloc_section(false);
1181 layout
->add_output_section_data(".rela.plt", elfcpp::SHT_RELA
,
1182 elfcpp::SHF_ALLOC
, this->rel_
, true,
1183 false, false, false);
1186 template<int size
, bool big_endian
>
1188 Output_data_plt_sparc
<size
, big_endian
>::do_adjust_output_section(Output_section
* os
)
1193 // Add an entry to the PLT.
1195 template<int size
, bool big_endian
>
1197 Output_data_plt_sparc
<size
, big_endian
>::add_entry(Symbol
* gsym
)
1199 gold_assert(!gsym
->has_plt_offset());
1201 unsigned int index
= this->count_
+ 4;
1202 section_offset_type plt_offset
;
1204 if (size
== 32 || index
< 32768)
1205 plt_offset
= index
* base_plt_entry_size
;
1208 unsigned int ext_index
= index
- 32768;
1210 plt_offset
= (32768 * base_plt_entry_size
)
1211 + ((ext_index
/ plt_entries_per_block
)
1213 + ((ext_index
% plt_entries_per_block
)
1214 * plt_insn_chunk_size
);
1217 gsym
->set_plt_offset(plt_offset
);
1221 // Every PLT entry needs a reloc.
1222 gsym
->set_needs_dynsym_entry();
1223 this->rel_
->add_global(gsym
, elfcpp::R_SPARC_JMP_SLOT
, this,
1226 // Note that we don't need to save the symbol. The contents of the
1227 // PLT are independent of which symbols are used. The symbols only
1228 // appear in the relocations.
1231 static const unsigned int sparc_nop
= 0x01000000;
1232 static const unsigned int sparc_sethi_g1
= 0x03000000;
1233 static const unsigned int sparc_branch_always
= 0x30800000;
1234 static const unsigned int sparc_branch_always_pt
= 0x30680000;
1235 static const unsigned int sparc_mov
= 0x80100000;
1236 static const unsigned int sparc_mov_g0_o0
= 0x90100000;
1237 static const unsigned int sparc_mov_o7_g5
= 0x8a10000f;
1238 static const unsigned int sparc_call_plus_8
= 0x40000002;
1239 static const unsigned int sparc_ldx_o7_imm_g1
= 0xc25be000;
1240 static const unsigned int sparc_jmpl_o7_g1_g1
= 0x83c3c001;
1241 static const unsigned int sparc_mov_g5_o7
= 0x9e100005;
1243 // Write out the PLT.
1245 template<int size
, bool big_endian
>
1247 Output_data_plt_sparc
<size
, big_endian
>::do_write(Output_file
* of
)
1249 const off_t offset
= this->offset();
1250 const section_size_type oview_size
=
1251 convert_to_section_size_type(this->data_size());
1252 unsigned char* const oview
= of
->get_output_view(offset
, oview_size
);
1253 unsigned char* pov
= oview
;
1255 memset(pov
, 0, base_plt_entry_size
* 4);
1256 pov
+= base_plt_entry_size
* 4;
1258 unsigned int plt_offset
= base_plt_entry_size
* 4;
1259 const unsigned int count
= this->count_
;
1265 limit
= (count
> 32768 ? 32768 : count
);
1267 for (unsigned int i
= 0; i
< limit
; ++i
)
1269 elfcpp::Swap
<32, true>::writeval(pov
+ 0x00,
1270 sparc_sethi_g1
+ plt_offset
);
1271 elfcpp::Swap
<32, true>::writeval(pov
+ 0x04,
1272 sparc_branch_always_pt
+
1273 (((base_plt_entry_size
-
1274 (plt_offset
+ 4)) >> 2) &
1276 elfcpp::Swap
<32, true>::writeval(pov
+ 0x08, sparc_nop
);
1277 elfcpp::Swap
<32, true>::writeval(pov
+ 0x0c, sparc_nop
);
1278 elfcpp::Swap
<32, true>::writeval(pov
+ 0x10, sparc_nop
);
1279 elfcpp::Swap
<32, true>::writeval(pov
+ 0x14, sparc_nop
);
1280 elfcpp::Swap
<32, true>::writeval(pov
+ 0x18, sparc_nop
);
1281 elfcpp::Swap
<32, true>::writeval(pov
+ 0x1c, sparc_nop
);
1283 pov
+= base_plt_entry_size
;
1284 plt_offset
+= base_plt_entry_size
;
1289 unsigned int ext_cnt
= count
- 32768;
1290 unsigned int blks
= ext_cnt
/ plt_entries_per_block
;
1292 for (unsigned int i
= 0; i
< blks
; ++i
)
1294 unsigned int data_off
= (plt_entries_per_block
1295 * plt_insn_chunk_size
) - 4;
1297 for (unsigned int j
= 0; j
< plt_entries_per_block
; ++j
)
1299 elfcpp::Swap
<32, true>::writeval(pov
+ 0x00,
1301 elfcpp::Swap
<32, true>::writeval(pov
+ 0x04,
1303 elfcpp::Swap
<32, true>::writeval(pov
+ 0x08,
1305 elfcpp::Swap
<32, true>::writeval(pov
+ 0x0c,
1306 sparc_ldx_o7_imm_g1
+
1307 (data_off
& 0x1fff));
1308 elfcpp::Swap
<32, true>::writeval(pov
+ 0x10,
1309 sparc_jmpl_o7_g1_g1
);
1310 elfcpp::Swap
<32, true>::writeval(pov
+ 0x14,
1313 elfcpp::Swap
<64, big_endian
>::writeval(
1314 pov
+ 0x4 + data_off
,
1315 (elfcpp::Elf_Xword
) (oview
- (pov
+ 0x04)));
1317 pov
+= plt_insn_chunk_size
;
1322 unsigned int sub_blk_cnt
= ext_cnt
% plt_entries_per_block
;
1323 for (unsigned int i
= 0; i
< sub_blk_cnt
; ++i
)
1325 unsigned int data_off
= (sub_blk_cnt
1326 * plt_insn_chunk_size
) - 4;
1328 for (unsigned int j
= 0; j
< plt_entries_per_block
; ++j
)
1330 elfcpp::Swap
<32, true>::writeval(pov
+ 0x00,
1332 elfcpp::Swap
<32, true>::writeval(pov
+ 0x04,
1334 elfcpp::Swap
<32, true>::writeval(pov
+ 0x08,
1336 elfcpp::Swap
<32, true>::writeval(pov
+ 0x0c,
1337 sparc_ldx_o7_imm_g1
+
1338 (data_off
& 0x1fff));
1339 elfcpp::Swap
<32, true>::writeval(pov
+ 0x10,
1340 sparc_jmpl_o7_g1_g1
);
1341 elfcpp::Swap
<32, true>::writeval(pov
+ 0x14,
1344 elfcpp::Swap
<64, big_endian
>::writeval(
1345 pov
+ 0x4 + data_off
,
1346 (elfcpp::Elf_Xword
) (oview
- (pov
+ 0x04)));
1348 pov
+= plt_insn_chunk_size
;
1356 for (unsigned int i
= 0; i
< count
; ++i
)
1358 elfcpp::Swap
<32, true>::writeval(pov
+ 0x00,
1359 sparc_sethi_g1
+ plt_offset
);
1360 elfcpp::Swap
<32, true>::writeval(pov
+ 0x04,
1361 sparc_branch_always
+
1362 (((- (plt_offset
+ 4)) >> 2) &
1364 elfcpp::Swap
<32, true>::writeval(pov
+ 0x08, sparc_nop
);
1366 pov
+= base_plt_entry_size
;
1367 plt_offset
+= base_plt_entry_size
;
1370 elfcpp::Swap
<32, true>::writeval(pov
, sparc_nop
);
1374 gold_assert(static_cast<section_size_type
>(pov
- oview
) == oview_size
);
1376 of
->write_output_view(offset
, oview_size
, oview
);
1379 // Create a PLT entry for a global symbol.
1381 template<int size
, bool big_endian
>
1383 Target_sparc
<size
, big_endian
>::make_plt_entry(Symbol_table
* symtab
,
1387 if (gsym
->has_plt_offset())
1390 if (this->plt_
== NULL
)
1392 // Create the GOT sections first.
1393 this->got_section(symtab
, layout
);
1395 // Ensure that .rela.dyn always appears before .rela.plt This is
1396 // necessary due to how, on Sparc and some other targets, .rela.dyn
1397 // needs to include .rela.plt in it's range.
1398 this->rela_dyn_section(layout
);
1400 this->plt_
= new Output_data_plt_sparc
<size
, big_endian
>(layout
);
1401 layout
->add_output_section_data(".plt", elfcpp::SHT_PROGBITS
,
1403 | elfcpp::SHF_EXECINSTR
1404 | elfcpp::SHF_WRITE
),
1405 this->plt_
, false, false, false, false);
1407 // Define _PROCEDURE_LINKAGE_TABLE_ at the start of the .plt section.
1408 symtab
->define_in_output_data("_PROCEDURE_LINKAGE_TABLE_", NULL
,
1409 Symbol_table::PREDEFINED
,
1411 0, 0, elfcpp::STT_OBJECT
,
1413 elfcpp::STV_HIDDEN
, 0,
1417 this->plt_
->add_entry(gsym
);
1420 // Create a GOT entry for the TLS module index.
1422 template<int size
, bool big_endian
>
1424 Target_sparc
<size
, big_endian
>::got_mod_index_entry(Symbol_table
* symtab
,
1426 Sized_relobj
<size
, big_endian
>* object
)
1428 if (this->got_mod_index_offset_
== -1U)
1430 gold_assert(symtab
!= NULL
&& layout
!= NULL
&& object
!= NULL
);
1431 Reloc_section
* rela_dyn
= this->rela_dyn_section(layout
);
1432 Output_data_got
<size
, big_endian
>* got
;
1433 unsigned int got_offset
;
1435 got
= this->got_section(symtab
, layout
);
1436 got_offset
= got
->add_constant(0);
1437 rela_dyn
->add_local(object
, 0,
1439 elfcpp::R_SPARC_TLS_DTPMOD64
:
1440 elfcpp::R_SPARC_TLS_DTPMOD32
), got
,
1442 got
->add_constant(0);
1443 this->got_mod_index_offset_
= got_offset
;
1445 return this->got_mod_index_offset_
;
1448 // Optimize the TLS relocation type based on what we know about the
1449 // symbol. IS_FINAL is true if the final address of this symbol is
1450 // known at link time.
1452 static tls::Tls_optimization
1453 optimize_tls_reloc(bool is_final
, int r_type
)
1455 // If we are generating a shared library, then we can't do anything
1457 if (parameters
->options().shared())
1458 return tls::TLSOPT_NONE
;
1462 case elfcpp::R_SPARC_TLS_GD_HI22
: // Global-dynamic
1463 case elfcpp::R_SPARC_TLS_GD_LO10
:
1464 case elfcpp::R_SPARC_TLS_GD_ADD
:
1465 case elfcpp::R_SPARC_TLS_GD_CALL
:
1466 // These are General-Dynamic which permits fully general TLS
1467 // access. Since we know that we are generating an executable,
1468 // we can convert this to Initial-Exec. If we also know that
1469 // this is a local symbol, we can further switch to Local-Exec.
1471 return tls::TLSOPT_TO_LE
;
1472 return tls::TLSOPT_TO_IE
;
1474 case elfcpp::R_SPARC_TLS_LDM_HI22
: // Local-dynamic
1475 case elfcpp::R_SPARC_TLS_LDM_LO10
:
1476 case elfcpp::R_SPARC_TLS_LDM_ADD
:
1477 case elfcpp::R_SPARC_TLS_LDM_CALL
:
1478 // This is Local-Dynamic, which refers to a local symbol in the
1479 // dynamic TLS block. Since we know that we generating an
1480 // executable, we can switch to Local-Exec.
1481 return tls::TLSOPT_TO_LE
;
1483 case elfcpp::R_SPARC_TLS_LDO_HIX22
: // Alternate local-dynamic
1484 case elfcpp::R_SPARC_TLS_LDO_LOX10
:
1485 case elfcpp::R_SPARC_TLS_LDO_ADD
:
1486 // Another type of Local-Dynamic relocation.
1487 return tls::TLSOPT_TO_LE
;
1489 case elfcpp::R_SPARC_TLS_IE_HI22
: // Initial-exec
1490 case elfcpp::R_SPARC_TLS_IE_LO10
:
1491 case elfcpp::R_SPARC_TLS_IE_LD
:
1492 case elfcpp::R_SPARC_TLS_IE_LDX
:
1493 case elfcpp::R_SPARC_TLS_IE_ADD
:
1494 // These are Initial-Exec relocs which get the thread offset
1495 // from the GOT. If we know that we are linking against the
1496 // local symbol, we can switch to Local-Exec, which links the
1497 // thread offset into the instruction.
1499 return tls::TLSOPT_TO_LE
;
1500 return tls::TLSOPT_NONE
;
1502 case elfcpp::R_SPARC_TLS_LE_HIX22
: // Local-exec
1503 case elfcpp::R_SPARC_TLS_LE_LOX10
:
1504 // When we already have Local-Exec, there is nothing further we
1506 return tls::TLSOPT_NONE
;
1513 // Generate a PLT entry slot for a call to __tls_get_addr
1514 template<int size
, bool big_endian
>
1516 Target_sparc
<size
, big_endian
>::Scan::generate_tls_call(Symbol_table
* symtab
,
1518 Target_sparc
<size
, big_endian
>* target
)
1520 Symbol
* gsym
= target
->tls_get_addr_sym(symtab
);
1522 target
->make_plt_entry(symtab
, layout
, gsym
);
1525 // Report an unsupported relocation against a local symbol.
1527 template<int size
, bool big_endian
>
1529 Target_sparc
<size
, big_endian
>::Scan::unsupported_reloc_local(
1530 Sized_relobj
<size
, big_endian
>* object
,
1531 unsigned int r_type
)
1533 gold_error(_("%s: unsupported reloc %u against local symbol"),
1534 object
->name().c_str(), r_type
);
1537 // We are about to emit a dynamic relocation of type R_TYPE. If the
1538 // dynamic linker does not support it, issue an error.
1540 template<int size
, bool big_endian
>
1542 Target_sparc
<size
, big_endian
>::Scan::check_non_pic(Relobj
* object
, unsigned int r_type
)
1544 gold_assert(r_type
!= elfcpp::R_SPARC_NONE
);
1550 // These are the relocation types supported by glibc for sparc 64-bit.
1551 case elfcpp::R_SPARC_RELATIVE
:
1552 case elfcpp::R_SPARC_COPY
:
1553 case elfcpp::R_SPARC_64
:
1554 case elfcpp::R_SPARC_GLOB_DAT
:
1555 case elfcpp::R_SPARC_JMP_SLOT
:
1556 case elfcpp::R_SPARC_TLS_DTPMOD64
:
1557 case elfcpp::R_SPARC_TLS_DTPOFF64
:
1558 case elfcpp::R_SPARC_TLS_TPOFF64
:
1559 case elfcpp::R_SPARC_TLS_LE_HIX22
:
1560 case elfcpp::R_SPARC_TLS_LE_LOX10
:
1561 case elfcpp::R_SPARC_8
:
1562 case elfcpp::R_SPARC_16
:
1563 case elfcpp::R_SPARC_DISP8
:
1564 case elfcpp::R_SPARC_DISP16
:
1565 case elfcpp::R_SPARC_DISP32
:
1566 case elfcpp::R_SPARC_WDISP30
:
1567 case elfcpp::R_SPARC_LO10
:
1568 case elfcpp::R_SPARC_HI22
:
1569 case elfcpp::R_SPARC_OLO10
:
1570 case elfcpp::R_SPARC_H44
:
1571 case elfcpp::R_SPARC_M44
:
1572 case elfcpp::R_SPARC_L44
:
1573 case elfcpp::R_SPARC_HH22
:
1574 case elfcpp::R_SPARC_HM10
:
1575 case elfcpp::R_SPARC_LM22
:
1576 case elfcpp::R_SPARC_UA16
:
1577 case elfcpp::R_SPARC_UA32
:
1578 case elfcpp::R_SPARC_UA64
:
1589 // These are the relocation types supported by glibc for sparc 32-bit.
1590 case elfcpp::R_SPARC_RELATIVE
:
1591 case elfcpp::R_SPARC_COPY
:
1592 case elfcpp::R_SPARC_GLOB_DAT
:
1593 case elfcpp::R_SPARC_32
:
1594 case elfcpp::R_SPARC_JMP_SLOT
:
1595 case elfcpp::R_SPARC_TLS_DTPMOD32
:
1596 case elfcpp::R_SPARC_TLS_DTPOFF32
:
1597 case elfcpp::R_SPARC_TLS_TPOFF32
:
1598 case elfcpp::R_SPARC_TLS_LE_HIX22
:
1599 case elfcpp::R_SPARC_TLS_LE_LOX10
:
1600 case elfcpp::R_SPARC_8
:
1601 case elfcpp::R_SPARC_16
:
1602 case elfcpp::R_SPARC_DISP8
:
1603 case elfcpp::R_SPARC_DISP16
:
1604 case elfcpp::R_SPARC_DISP32
:
1605 case elfcpp::R_SPARC_LO10
:
1606 case elfcpp::R_SPARC_WDISP30
:
1607 case elfcpp::R_SPARC_HI22
:
1608 case elfcpp::R_SPARC_UA16
:
1609 case elfcpp::R_SPARC_UA32
:
1617 // This prevents us from issuing more than one error per reloc
1618 // section. But we can still wind up issuing more than one
1619 // error per object file.
1620 if (this->issued_non_pic_error_
)
1622 gold_assert(parameters
->options().output_is_position_independent());
1623 object
->error(_("requires unsupported dynamic reloc; "
1624 "recompile with -fPIC"));
1625 this->issued_non_pic_error_
= true;
1629 // Scan a relocation for a local symbol.
1631 template<int size
, bool big_endian
>
1633 Target_sparc
<size
, big_endian
>::Scan::local(
1634 Symbol_table
* symtab
,
1636 Target_sparc
<size
, big_endian
>* target
,
1637 Sized_relobj
<size
, big_endian
>* object
,
1638 unsigned int data_shndx
,
1639 Output_section
* output_section
,
1640 const elfcpp::Rela
<size
, big_endian
>& reloc
,
1641 unsigned int r_type
,
1642 const elfcpp::Sym
<size
, big_endian
>& lsym
)
1644 unsigned int orig_r_type
= r_type
;
1649 case elfcpp::R_SPARC_NONE
:
1650 case elfcpp::R_SPARC_REGISTER
:
1651 case elfcpp::R_SPARC_GNU_VTINHERIT
:
1652 case elfcpp::R_SPARC_GNU_VTENTRY
:
1655 case elfcpp::R_SPARC_64
:
1656 case elfcpp::R_SPARC_32
:
1657 // If building a shared library (or a position-independent
1658 // executable), we need to create a dynamic relocation for
1659 // this location. The relocation applied at link time will
1660 // apply the link-time value, so we flag the location with
1661 // an R_SPARC_RELATIVE relocation so the dynamic loader can
1662 // relocate it easily.
1663 if (parameters
->options().output_is_position_independent())
1665 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
1666 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
1667 rela_dyn
->add_local_relative(object
, r_sym
, elfcpp::R_SPARC_RELATIVE
,
1668 output_section
, data_shndx
,
1669 reloc
.get_r_offset(),
1670 reloc
.get_r_addend());
1674 case elfcpp::R_SPARC_HIX22
:
1675 case elfcpp::R_SPARC_LOX10
:
1676 case elfcpp::R_SPARC_H44
:
1677 case elfcpp::R_SPARC_M44
:
1678 case elfcpp::R_SPARC_L44
:
1679 case elfcpp::R_SPARC_HH22
:
1680 case elfcpp::R_SPARC_HM10
:
1681 case elfcpp::R_SPARC_LM22
:
1682 case elfcpp::R_SPARC_UA64
:
1683 case elfcpp::R_SPARC_UA32
:
1684 case elfcpp::R_SPARC_UA16
:
1685 case elfcpp::R_SPARC_HI22
:
1686 case elfcpp::R_SPARC_LO10
:
1687 case elfcpp::R_SPARC_OLO10
:
1688 case elfcpp::R_SPARC_16
:
1689 case elfcpp::R_SPARC_11
:
1690 case elfcpp::R_SPARC_10
:
1691 case elfcpp::R_SPARC_8
:
1692 case elfcpp::R_SPARC_7
:
1693 case elfcpp::R_SPARC_6
:
1694 case elfcpp::R_SPARC_5
:
1695 // If building a shared library (or a position-independent
1696 // executable), we need to create a dynamic relocation for
1698 if (parameters
->options().output_is_position_independent())
1700 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
1701 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
1703 check_non_pic(object
, r_type
);
1704 if (lsym
.get_st_type() != elfcpp::STT_SECTION
)
1706 rela_dyn
->add_local(object
, r_sym
, orig_r_type
, output_section
,
1707 data_shndx
, reloc
.get_r_offset(),
1708 reloc
.get_r_addend());
1712 gold_assert(lsym
.get_st_value() == 0);
1713 rela_dyn
->add_symbolless_local_addend(object
, r_sym
, orig_r_type
,
1714 output_section
, data_shndx
,
1715 reloc
.get_r_offset(),
1716 reloc
.get_r_addend());
1721 case elfcpp::R_SPARC_WDISP30
:
1722 case elfcpp::R_SPARC_WPLT30
:
1723 case elfcpp::R_SPARC_WDISP22
:
1724 case elfcpp::R_SPARC_WDISP19
:
1725 case elfcpp::R_SPARC_WDISP16
:
1726 case elfcpp::R_SPARC_DISP8
:
1727 case elfcpp::R_SPARC_DISP16
:
1728 case elfcpp::R_SPARC_DISP32
:
1729 case elfcpp::R_SPARC_DISP64
:
1730 case elfcpp::R_SPARC_PC10
:
1731 case elfcpp::R_SPARC_PC22
:
1734 case elfcpp::R_SPARC_GOTDATA_OP
:
1735 case elfcpp::R_SPARC_GOTDATA_OP_HIX22
:
1736 case elfcpp::R_SPARC_GOTDATA_OP_LOX10
:
1737 case elfcpp::R_SPARC_GOT10
:
1738 case elfcpp::R_SPARC_GOT13
:
1739 case elfcpp::R_SPARC_GOT22
:
1741 // The symbol requires a GOT entry.
1742 Output_data_got
<size
, big_endian
>* got
;
1745 got
= target
->got_section(symtab
, layout
);
1746 r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
1748 // If we are generating a shared object, we need to add a
1749 // dynamic relocation for this symbol's GOT entry.
1750 if (parameters
->options().output_is_position_independent())
1752 if (!object
->local_has_got_offset(r_sym
, GOT_TYPE_STANDARD
))
1754 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
1757 off
= got
->add_constant(0);
1758 object
->set_local_got_offset(r_sym
, GOT_TYPE_STANDARD
, off
);
1759 rela_dyn
->add_local_relative(object
, r_sym
,
1760 elfcpp::R_SPARC_RELATIVE
,
1765 got
->add_local(object
, r_sym
, GOT_TYPE_STANDARD
);
1769 // These are initial TLS relocs, which are expected when
1771 case elfcpp::R_SPARC_TLS_GD_HI22
: // Global-dynamic
1772 case elfcpp::R_SPARC_TLS_GD_LO10
:
1773 case elfcpp::R_SPARC_TLS_GD_ADD
:
1774 case elfcpp::R_SPARC_TLS_GD_CALL
:
1775 case elfcpp::R_SPARC_TLS_LDM_HI22
: // Local-dynamic
1776 case elfcpp::R_SPARC_TLS_LDM_LO10
:
1777 case elfcpp::R_SPARC_TLS_LDM_ADD
:
1778 case elfcpp::R_SPARC_TLS_LDM_CALL
:
1779 case elfcpp::R_SPARC_TLS_LDO_HIX22
: // Alternate local-dynamic
1780 case elfcpp::R_SPARC_TLS_LDO_LOX10
:
1781 case elfcpp::R_SPARC_TLS_LDO_ADD
:
1782 case elfcpp::R_SPARC_TLS_IE_HI22
: // Initial-exec
1783 case elfcpp::R_SPARC_TLS_IE_LO10
:
1784 case elfcpp::R_SPARC_TLS_IE_LD
:
1785 case elfcpp::R_SPARC_TLS_IE_LDX
:
1786 case elfcpp::R_SPARC_TLS_IE_ADD
:
1787 case elfcpp::R_SPARC_TLS_LE_HIX22
: // Local-exec
1788 case elfcpp::R_SPARC_TLS_LE_LOX10
:
1790 bool output_is_shared
= parameters
->options().shared();
1791 const tls::Tls_optimization optimized_type
1792 = optimize_tls_reloc(!output_is_shared
, r_type
);
1795 case elfcpp::R_SPARC_TLS_GD_HI22
: // Global-dynamic
1796 case elfcpp::R_SPARC_TLS_GD_LO10
:
1797 case elfcpp::R_SPARC_TLS_GD_ADD
:
1798 case elfcpp::R_SPARC_TLS_GD_CALL
:
1799 if (optimized_type
== tls::TLSOPT_NONE
)
1801 // Create a pair of GOT entries for the module index and
1802 // dtv-relative offset.
1803 Output_data_got
<size
, big_endian
>* got
1804 = target
->got_section(symtab
, layout
);
1805 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
1806 unsigned int shndx
= lsym
.get_st_shndx();
1808 shndx
= object
->adjust_sym_shndx(r_sym
, shndx
, &is_ordinary
);
1810 object
->error(_("local symbol %u has bad shndx %u"),
1813 got
->add_local_pair_with_rela(object
, r_sym
,
1814 lsym
.get_st_shndx(),
1816 target
->rela_dyn_section(layout
),
1818 ? elfcpp::R_SPARC_TLS_DTPMOD64
1819 : elfcpp::R_SPARC_TLS_DTPMOD32
),
1821 if (r_type
== elfcpp::R_SPARC_TLS_GD_CALL
)
1822 generate_tls_call(symtab
, layout
, target
);
1824 else if (optimized_type
!= tls::TLSOPT_TO_LE
)
1825 unsupported_reloc_local(object
, r_type
);
1828 case elfcpp::R_SPARC_TLS_LDM_HI22
: // Local-dynamic
1829 case elfcpp::R_SPARC_TLS_LDM_LO10
:
1830 case elfcpp::R_SPARC_TLS_LDM_ADD
:
1831 case elfcpp::R_SPARC_TLS_LDM_CALL
:
1832 if (optimized_type
== tls::TLSOPT_NONE
)
1834 // Create a GOT entry for the module index.
1835 target
->got_mod_index_entry(symtab
, layout
, object
);
1837 if (r_type
== elfcpp::R_SPARC_TLS_LDM_CALL
)
1838 generate_tls_call(symtab
, layout
, target
);
1840 else if (optimized_type
!= tls::TLSOPT_TO_LE
)
1841 unsupported_reloc_local(object
, r_type
);
1844 case elfcpp::R_SPARC_TLS_LDO_HIX22
: // Alternate local-dynamic
1845 case elfcpp::R_SPARC_TLS_LDO_LOX10
:
1846 case elfcpp::R_SPARC_TLS_LDO_ADD
:
1849 case elfcpp::R_SPARC_TLS_IE_HI22
: // Initial-exec
1850 case elfcpp::R_SPARC_TLS_IE_LO10
:
1851 case elfcpp::R_SPARC_TLS_IE_LD
:
1852 case elfcpp::R_SPARC_TLS_IE_LDX
:
1853 case elfcpp::R_SPARC_TLS_IE_ADD
:
1854 layout
->set_has_static_tls();
1855 if (optimized_type
== tls::TLSOPT_NONE
)
1857 // Create a GOT entry for the tp-relative offset.
1858 Output_data_got
<size
, big_endian
>* got
1859 = target
->got_section(symtab
, layout
);
1860 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
1862 if (!object
->local_has_got_offset(r_sym
, GOT_TYPE_TLS_OFFSET
))
1864 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
1865 unsigned int off
= got
->add_constant(0);
1867 object
->set_local_got_offset(r_sym
, GOT_TYPE_TLS_OFFSET
, off
);
1869 rela_dyn
->add_symbolless_local_addend(object
, r_sym
,
1871 elfcpp::R_SPARC_TLS_TPOFF64
:
1872 elfcpp::R_SPARC_TLS_TPOFF32
),
1876 else if (optimized_type
!= tls::TLSOPT_TO_LE
)
1877 unsupported_reloc_local(object
, r_type
);
1880 case elfcpp::R_SPARC_TLS_LE_HIX22
: // Local-exec
1881 case elfcpp::R_SPARC_TLS_LE_LOX10
:
1882 layout
->set_has_static_tls();
1883 if (output_is_shared
)
1885 // We need to create a dynamic relocation.
1886 gold_assert(lsym
.get_st_type() != elfcpp::STT_SECTION
);
1887 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
1888 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
1889 rela_dyn
->add_symbolless_local_addend(object
, r_sym
, r_type
,
1890 output_section
, data_shndx
,
1891 reloc
.get_r_offset(), 0);
1898 // These are relocations which should only be seen by the
1899 // dynamic linker, and should never be seen here.
1900 case elfcpp::R_SPARC_COPY
:
1901 case elfcpp::R_SPARC_GLOB_DAT
:
1902 case elfcpp::R_SPARC_JMP_SLOT
:
1903 case elfcpp::R_SPARC_RELATIVE
:
1904 case elfcpp::R_SPARC_TLS_DTPMOD64
:
1905 case elfcpp::R_SPARC_TLS_DTPMOD32
:
1906 case elfcpp::R_SPARC_TLS_DTPOFF64
:
1907 case elfcpp::R_SPARC_TLS_DTPOFF32
:
1908 case elfcpp::R_SPARC_TLS_TPOFF64
:
1909 case elfcpp::R_SPARC_TLS_TPOFF32
:
1910 gold_error(_("%s: unexpected reloc %u in object file"),
1911 object
->name().c_str(), r_type
);
1915 unsupported_reloc_local(object
, r_type
);
1920 // Report an unsupported relocation against a global symbol.
1922 template<int size
, bool big_endian
>
1924 Target_sparc
<size
, big_endian
>::Scan::unsupported_reloc_global(
1925 Sized_relobj
<size
, big_endian
>* object
,
1926 unsigned int r_type
,
1929 gold_error(_("%s: unsupported reloc %u against global symbol %s"),
1930 object
->name().c_str(), r_type
, gsym
->demangled_name().c_str());
1933 // Scan a relocation for a global symbol.
1935 template<int size
, bool big_endian
>
1937 Target_sparc
<size
, big_endian
>::Scan::global(
1938 Symbol_table
* symtab
,
1940 Target_sparc
<size
, big_endian
>* target
,
1941 Sized_relobj
<size
, big_endian
>* object
,
1942 unsigned int data_shndx
,
1943 Output_section
* output_section
,
1944 const elfcpp::Rela
<size
, big_endian
>& reloc
,
1945 unsigned int r_type
,
1948 unsigned int orig_r_type
= r_type
;
1950 // A reference to _GLOBAL_OFFSET_TABLE_ implies that we need a got
1951 // section. We check here to avoid creating a dynamic reloc against
1952 // _GLOBAL_OFFSET_TABLE_.
1953 if (!target
->has_got_section()
1954 && strcmp(gsym
->name(), "_GLOBAL_OFFSET_TABLE_") == 0)
1955 target
->got_section(symtab
, layout
);
1960 case elfcpp::R_SPARC_NONE
:
1961 case elfcpp::R_SPARC_REGISTER
:
1962 case elfcpp::R_SPARC_GNU_VTINHERIT
:
1963 case elfcpp::R_SPARC_GNU_VTENTRY
:
1966 case elfcpp::R_SPARC_PLT64
:
1967 case elfcpp::R_SPARC_PLT32
:
1968 case elfcpp::R_SPARC_HIPLT22
:
1969 case elfcpp::R_SPARC_LOPLT10
:
1970 case elfcpp::R_SPARC_PCPLT32
:
1971 case elfcpp::R_SPARC_PCPLT22
:
1972 case elfcpp::R_SPARC_PCPLT10
:
1973 case elfcpp::R_SPARC_WPLT30
:
1974 // If the symbol is fully resolved, this is just a PC32 reloc.
1975 // Otherwise we need a PLT entry.
1976 if (gsym
->final_value_is_known())
1978 // If building a shared library, we can also skip the PLT entry
1979 // if the symbol is defined in the output file and is protected
1981 if (gsym
->is_defined()
1982 && !gsym
->is_from_dynobj()
1983 && !gsym
->is_preemptible())
1985 target
->make_plt_entry(symtab
, layout
, gsym
);
1988 case elfcpp::R_SPARC_DISP8
:
1989 case elfcpp::R_SPARC_DISP16
:
1990 case elfcpp::R_SPARC_DISP32
:
1991 case elfcpp::R_SPARC_DISP64
:
1992 case elfcpp::R_SPARC_PC_HH22
:
1993 case elfcpp::R_SPARC_PC_HM10
:
1994 case elfcpp::R_SPARC_PC_LM22
:
1995 case elfcpp::R_SPARC_PC10
:
1996 case elfcpp::R_SPARC_PC22
:
1997 case elfcpp::R_SPARC_WDISP30
:
1998 case elfcpp::R_SPARC_WDISP22
:
1999 case elfcpp::R_SPARC_WDISP19
:
2000 case elfcpp::R_SPARC_WDISP16
:
2002 if (gsym
->needs_plt_entry())
2003 target
->make_plt_entry(symtab
, layout
, gsym
);
2004 // Make a dynamic relocation if necessary.
2005 int flags
= Symbol::NON_PIC_REF
;
2006 if (gsym
->type() == elfcpp::STT_FUNC
)
2007 flags
|= Symbol::FUNCTION_CALL
;
2008 if (gsym
->needs_dynamic_reloc(flags
))
2010 if (gsym
->may_need_copy_reloc())
2012 target
->copy_reloc(symtab
, layout
, object
,
2013 data_shndx
, output_section
, gsym
,
2018 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2019 check_non_pic(object
, r_type
);
2020 rela_dyn
->add_global(gsym
, orig_r_type
, output_section
, object
,
2021 data_shndx
, reloc
.get_r_offset(),
2022 reloc
.get_r_addend());
2028 case elfcpp::R_SPARC_UA64
:
2029 case elfcpp::R_SPARC_64
:
2030 case elfcpp::R_SPARC_HIX22
:
2031 case elfcpp::R_SPARC_LOX10
:
2032 case elfcpp::R_SPARC_H44
:
2033 case elfcpp::R_SPARC_M44
:
2034 case elfcpp::R_SPARC_L44
:
2035 case elfcpp::R_SPARC_HH22
:
2036 case elfcpp::R_SPARC_HM10
:
2037 case elfcpp::R_SPARC_LM22
:
2038 case elfcpp::R_SPARC_HI22
:
2039 case elfcpp::R_SPARC_LO10
:
2040 case elfcpp::R_SPARC_OLO10
:
2041 case elfcpp::R_SPARC_UA32
:
2042 case elfcpp::R_SPARC_32
:
2043 case elfcpp::R_SPARC_UA16
:
2044 case elfcpp::R_SPARC_16
:
2045 case elfcpp::R_SPARC_11
:
2046 case elfcpp::R_SPARC_10
:
2047 case elfcpp::R_SPARC_8
:
2048 case elfcpp::R_SPARC_7
:
2049 case elfcpp::R_SPARC_6
:
2050 case elfcpp::R_SPARC_5
:
2052 // Make a PLT entry if necessary.
2053 if (gsym
->needs_plt_entry())
2055 target
->make_plt_entry(symtab
, layout
, gsym
);
2056 // Since this is not a PC-relative relocation, we may be
2057 // taking the address of a function. In that case we need to
2058 // set the entry in the dynamic symbol table to the address of
2060 if (gsym
->is_from_dynobj() && !parameters
->options().shared())
2061 gsym
->set_needs_dynsym_value();
2063 // Make a dynamic relocation if necessary.
2064 if (gsym
->needs_dynamic_reloc(Symbol::ABSOLUTE_REF
))
2066 unsigned int r_off
= reloc
.get_r_offset();
2068 // The assembler can sometimes emit unaligned relocations
2069 // for dwarf2 cfi directives.
2072 case elfcpp::R_SPARC_16
:
2074 orig_r_type
= r_type
= elfcpp::R_SPARC_UA16
;
2076 case elfcpp::R_SPARC_32
:
2078 orig_r_type
= r_type
= elfcpp::R_SPARC_UA32
;
2080 case elfcpp::R_SPARC_64
:
2082 orig_r_type
= r_type
= elfcpp::R_SPARC_UA64
;
2084 case elfcpp::R_SPARC_UA16
:
2086 orig_r_type
= r_type
= elfcpp::R_SPARC_16
;
2088 case elfcpp::R_SPARC_UA32
:
2090 orig_r_type
= r_type
= elfcpp::R_SPARC_32
;
2092 case elfcpp::R_SPARC_UA64
:
2094 orig_r_type
= r_type
= elfcpp::R_SPARC_64
;
2098 if (gsym
->may_need_copy_reloc())
2100 target
->copy_reloc(symtab
, layout
, object
,
2101 data_shndx
, output_section
, gsym
, reloc
);
2103 else if ((r_type
== elfcpp::R_SPARC_32
2104 || r_type
== elfcpp::R_SPARC_64
)
2105 && gsym
->can_use_relative_reloc(false))
2107 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2108 rela_dyn
->add_global_relative(gsym
, elfcpp::R_SPARC_RELATIVE
,
2109 output_section
, object
,
2110 data_shndx
, reloc
.get_r_offset(),
2111 reloc
.get_r_addend());
2115 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2117 check_non_pic(object
, r_type
);
2118 if (gsym
->is_from_dynobj()
2119 || gsym
->is_undefined()
2120 || gsym
->is_preemptible())
2121 rela_dyn
->add_global(gsym
, orig_r_type
, output_section
,
2123 reloc
.get_r_offset(),
2124 reloc
.get_r_addend());
2126 rela_dyn
->add_symbolless_global_addend(gsym
, orig_r_type
,
2129 reloc
.get_r_offset(),
2130 reloc
.get_r_addend());
2136 case elfcpp::R_SPARC_GOTDATA_OP
:
2137 case elfcpp::R_SPARC_GOTDATA_OP_HIX22
:
2138 case elfcpp::R_SPARC_GOTDATA_OP_LOX10
:
2139 case elfcpp::R_SPARC_GOT10
:
2140 case elfcpp::R_SPARC_GOT13
:
2141 case elfcpp::R_SPARC_GOT22
:
2143 // The symbol requires a GOT entry.
2144 Output_data_got
<size
, big_endian
>* got
;
2146 got
= target
->got_section(symtab
, layout
);
2147 if (gsym
->final_value_is_known())
2148 got
->add_global(gsym
, GOT_TYPE_STANDARD
);
2151 // If this symbol is not fully resolved, we need to add a
2152 // dynamic relocation for it.
2153 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2154 if (gsym
->is_from_dynobj()
2155 || gsym
->is_undefined()
2156 || gsym
->is_preemptible())
2157 got
->add_global_with_rela(gsym
, GOT_TYPE_STANDARD
, rela_dyn
,
2158 elfcpp::R_SPARC_GLOB_DAT
);
2159 else if (!gsym
->has_got_offset(GOT_TYPE_STANDARD
))
2161 unsigned int off
= got
->add_constant(0);
2163 gsym
->set_got_offset(GOT_TYPE_STANDARD
, off
);
2164 rela_dyn
->add_global_relative(gsym
, elfcpp::R_SPARC_RELATIVE
,
2171 // These are initial tls relocs, which are expected when
2173 case elfcpp::R_SPARC_TLS_GD_HI22
: // Global-dynamic
2174 case elfcpp::R_SPARC_TLS_GD_LO10
:
2175 case elfcpp::R_SPARC_TLS_GD_ADD
:
2176 case elfcpp::R_SPARC_TLS_GD_CALL
:
2177 case elfcpp::R_SPARC_TLS_LDM_HI22
: // Local-dynamic
2178 case elfcpp::R_SPARC_TLS_LDM_LO10
:
2179 case elfcpp::R_SPARC_TLS_LDM_ADD
:
2180 case elfcpp::R_SPARC_TLS_LDM_CALL
:
2181 case elfcpp::R_SPARC_TLS_LDO_HIX22
: // Alternate local-dynamic
2182 case elfcpp::R_SPARC_TLS_LDO_LOX10
:
2183 case elfcpp::R_SPARC_TLS_LDO_ADD
:
2184 case elfcpp::R_SPARC_TLS_LE_HIX22
:
2185 case elfcpp::R_SPARC_TLS_LE_LOX10
:
2186 case elfcpp::R_SPARC_TLS_IE_HI22
: // Initial-exec
2187 case elfcpp::R_SPARC_TLS_IE_LO10
:
2188 case elfcpp::R_SPARC_TLS_IE_LD
:
2189 case elfcpp::R_SPARC_TLS_IE_LDX
:
2190 case elfcpp::R_SPARC_TLS_IE_ADD
:
2192 const bool is_final
= gsym
->final_value_is_known();
2193 const tls::Tls_optimization optimized_type
2194 = optimize_tls_reloc(is_final
, r_type
);
2197 case elfcpp::R_SPARC_TLS_GD_HI22
: // Global-dynamic
2198 case elfcpp::R_SPARC_TLS_GD_LO10
:
2199 case elfcpp::R_SPARC_TLS_GD_ADD
:
2200 case elfcpp::R_SPARC_TLS_GD_CALL
:
2201 if (optimized_type
== tls::TLSOPT_NONE
)
2203 // Create a pair of GOT entries for the module index and
2204 // dtv-relative offset.
2205 Output_data_got
<size
, big_endian
>* got
2206 = target
->got_section(symtab
, layout
);
2207 got
->add_global_pair_with_rela(gsym
, GOT_TYPE_TLS_PAIR
,
2208 target
->rela_dyn_section(layout
),
2210 elfcpp::R_SPARC_TLS_DTPMOD64
:
2211 elfcpp::R_SPARC_TLS_DTPMOD32
),
2213 elfcpp::R_SPARC_TLS_DTPOFF64
:
2214 elfcpp::R_SPARC_TLS_DTPOFF32
));
2216 // Emit R_SPARC_WPLT30 against "__tls_get_addr"
2217 if (r_type
== elfcpp::R_SPARC_TLS_GD_CALL
)
2218 generate_tls_call(symtab
, layout
, target
);
2220 else if (optimized_type
== tls::TLSOPT_TO_IE
)
2222 // Create a GOT entry for the tp-relative offset.
2223 Output_data_got
<size
, big_endian
>* got
2224 = target
->got_section(symtab
, layout
);
2225 got
->add_global_with_rela(gsym
, GOT_TYPE_TLS_OFFSET
,
2226 target
->rela_dyn_section(layout
),
2228 elfcpp::R_SPARC_TLS_TPOFF64
:
2229 elfcpp::R_SPARC_TLS_TPOFF32
));
2231 else if (optimized_type
!= tls::TLSOPT_TO_LE
)
2232 unsupported_reloc_global(object
, r_type
, gsym
);
2235 case elfcpp::R_SPARC_TLS_LDM_HI22
: // Local-dynamic
2236 case elfcpp::R_SPARC_TLS_LDM_LO10
:
2237 case elfcpp::R_SPARC_TLS_LDM_ADD
:
2238 case elfcpp::R_SPARC_TLS_LDM_CALL
:
2239 if (optimized_type
== tls::TLSOPT_NONE
)
2241 // Create a GOT entry for the module index.
2242 target
->got_mod_index_entry(symtab
, layout
, object
);
2244 if (r_type
== elfcpp::R_SPARC_TLS_LDM_CALL
)
2245 generate_tls_call(symtab
, layout
, target
);
2247 else if (optimized_type
!= tls::TLSOPT_TO_LE
)
2248 unsupported_reloc_global(object
, r_type
, gsym
);
2251 case elfcpp::R_SPARC_TLS_LDO_HIX22
: // Alternate local-dynamic
2252 case elfcpp::R_SPARC_TLS_LDO_LOX10
:
2253 case elfcpp::R_SPARC_TLS_LDO_ADD
:
2256 case elfcpp::R_SPARC_TLS_LE_HIX22
:
2257 case elfcpp::R_SPARC_TLS_LE_LOX10
:
2258 layout
->set_has_static_tls();
2259 if (parameters
->options().shared())
2261 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2262 rela_dyn
->add_symbolless_global_addend(gsym
, orig_r_type
,
2263 output_section
, object
,
2264 data_shndx
, reloc
.get_r_offset(),
2269 case elfcpp::R_SPARC_TLS_IE_HI22
: // Initial-exec
2270 case elfcpp::R_SPARC_TLS_IE_LO10
:
2271 case elfcpp::R_SPARC_TLS_IE_LD
:
2272 case elfcpp::R_SPARC_TLS_IE_LDX
:
2273 case elfcpp::R_SPARC_TLS_IE_ADD
:
2274 layout
->set_has_static_tls();
2275 if (optimized_type
== tls::TLSOPT_NONE
)
2277 // Create a GOT entry for the tp-relative offset.
2278 Output_data_got
<size
, big_endian
>* got
2279 = target
->got_section(symtab
, layout
);
2280 got
->add_global_with_rela(gsym
, GOT_TYPE_TLS_OFFSET
,
2281 target
->rela_dyn_section(layout
),
2283 elfcpp::R_SPARC_TLS_TPOFF64
:
2284 elfcpp::R_SPARC_TLS_TPOFF32
));
2286 else if (optimized_type
!= tls::TLSOPT_TO_LE
)
2287 unsupported_reloc_global(object
, r_type
, gsym
);
2293 // These are relocations which should only be seen by the
2294 // dynamic linker, and should never be seen here.
2295 case elfcpp::R_SPARC_COPY
:
2296 case elfcpp::R_SPARC_GLOB_DAT
:
2297 case elfcpp::R_SPARC_JMP_SLOT
:
2298 case elfcpp::R_SPARC_RELATIVE
:
2299 case elfcpp::R_SPARC_TLS_DTPMOD64
:
2300 case elfcpp::R_SPARC_TLS_DTPMOD32
:
2301 case elfcpp::R_SPARC_TLS_DTPOFF64
:
2302 case elfcpp::R_SPARC_TLS_DTPOFF32
:
2303 case elfcpp::R_SPARC_TLS_TPOFF64
:
2304 case elfcpp::R_SPARC_TLS_TPOFF32
:
2305 gold_error(_("%s: unexpected reloc %u in object file"),
2306 object
->name().c_str(), r_type
);
2310 unsupported_reloc_global(object
, r_type
, gsym
);
2315 // Process relocations for gc.
2317 template<int size
, bool big_endian
>
2319 Target_sparc
<size
, big_endian
>::gc_process_relocs(
2320 Symbol_table
* symtab
,
2322 Sized_relobj
<size
, big_endian
>* object
,
2323 unsigned int data_shndx
,
2325 const unsigned char* prelocs
,
2327 Output_section
* output_section
,
2328 bool needs_special_offset_handling
,
2329 size_t local_symbol_count
,
2330 const unsigned char* plocal_symbols
)
2332 typedef Target_sparc
<size
, big_endian
> Sparc
;
2333 typedef typename Target_sparc
<size
, big_endian
>::Scan Scan
;
2335 gold::gc_process_relocs
<size
, big_endian
, Sparc
, elfcpp::SHT_RELA
, Scan
>(
2344 needs_special_offset_handling
,
2349 // Scan relocations for a section.
2351 template<int size
, bool big_endian
>
2353 Target_sparc
<size
, big_endian
>::scan_relocs(
2354 Symbol_table
* symtab
,
2356 Sized_relobj
<size
, big_endian
>* object
,
2357 unsigned int data_shndx
,
2358 unsigned int sh_type
,
2359 const unsigned char* prelocs
,
2361 Output_section
* output_section
,
2362 bool needs_special_offset_handling
,
2363 size_t local_symbol_count
,
2364 const unsigned char* plocal_symbols
)
2366 typedef Target_sparc
<size
, big_endian
> Sparc
;
2367 typedef typename Target_sparc
<size
, big_endian
>::Scan Scan
;
2369 if (sh_type
== elfcpp::SHT_REL
)
2371 gold_error(_("%s: unsupported REL reloc section"),
2372 object
->name().c_str());
2376 gold::scan_relocs
<size
, big_endian
, Sparc
, elfcpp::SHT_RELA
, Scan
>(
2385 needs_special_offset_handling
,
2390 // Finalize the sections.
2392 template<int size
, bool big_endian
>
2394 Target_sparc
<size
, big_endian
>::do_finalize_sections(
2396 const Input_objects
*,
2399 // Fill in some more dynamic tags.
2400 const Reloc_section
* rel_plt
= (this->plt_
== NULL
2402 : this->plt_
->rel_plt());
2403 layout
->add_target_dynamic_tags(false, this->plt_
, rel_plt
,
2404 this->rela_dyn_
, true, true);
2406 // Emit any relocs we saved in an attempt to avoid generating COPY
2408 if (this->copy_relocs_
.any_saved_relocs())
2409 this->copy_relocs_
.emit(this->rela_dyn_section(layout
));
2412 // Perform a relocation.
2414 template<int size
, bool big_endian
>
2416 Target_sparc
<size
, big_endian
>::Relocate::relocate(
2417 const Relocate_info
<size
, big_endian
>* relinfo
,
2418 Target_sparc
* target
,
2421 const elfcpp::Rela
<size
, big_endian
>& rela
,
2422 unsigned int r_type
,
2423 const Sized_symbol
<size
>* gsym
,
2424 const Symbol_value
<size
>* psymval
,
2425 unsigned char* view
,
2426 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
2427 section_size_type view_size
)
2431 if (this->ignore_gd_add_
)
2433 if (r_type
!= elfcpp::R_SPARC_TLS_GD_ADD
)
2434 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
2435 _("missing expected TLS relocation"));
2438 this->ignore_gd_add_
= false;
2443 typedef Sparc_relocate_functions
<size
, big_endian
> Reloc
;
2445 // Pick the value to use for symbols defined in shared objects.
2446 Symbol_value
<size
> symval
;
2448 && gsym
->use_plt_offset(r_type
== elfcpp::R_SPARC_DISP8
2449 || r_type
== elfcpp::R_SPARC_DISP16
2450 || r_type
== elfcpp::R_SPARC_DISP32
2451 || r_type
== elfcpp::R_SPARC_DISP64
2452 || r_type
== elfcpp::R_SPARC_PC_HH22
2453 || r_type
== elfcpp::R_SPARC_PC_HM10
2454 || r_type
== elfcpp::R_SPARC_PC_LM22
2455 || r_type
== elfcpp::R_SPARC_PC10
2456 || r_type
== elfcpp::R_SPARC_PC22
2457 || r_type
== elfcpp::R_SPARC_WDISP30
2458 || r_type
== elfcpp::R_SPARC_WDISP22
2459 || r_type
== elfcpp::R_SPARC_WDISP19
2460 || r_type
== elfcpp::R_SPARC_WDISP16
))
2462 elfcpp::Elf_Xword value
;
2464 value
= target
->plt_section()->address() + gsym
->plt_offset();
2466 symval
.set_output_value(value
);
2471 const Sized_relobj
<size
, big_endian
>* object
= relinfo
->object
;
2472 const elfcpp::Elf_Xword addend
= rela
.get_r_addend();
2474 // Get the GOT offset if needed. Unlike i386 and x86_64, our GOT
2475 // pointer points to the beginning, not the end, of the table.
2476 // So we just use the plain offset.
2477 bool have_got_offset
= false;
2478 unsigned int got_offset
= 0;
2481 case elfcpp::R_SPARC_GOTDATA_OP
:
2482 case elfcpp::R_SPARC_GOTDATA_OP_HIX22
:
2483 case elfcpp::R_SPARC_GOTDATA_OP_LOX10
:
2484 case elfcpp::R_SPARC_GOT10
:
2485 case elfcpp::R_SPARC_GOT13
:
2486 case elfcpp::R_SPARC_GOT22
:
2489 gold_assert(gsym
->has_got_offset(GOT_TYPE_STANDARD
));
2490 got_offset
= gsym
->got_offset(GOT_TYPE_STANDARD
);
2494 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
2495 gold_assert(object
->local_has_got_offset(r_sym
, GOT_TYPE_STANDARD
));
2496 got_offset
= object
->local_got_offset(r_sym
, GOT_TYPE_STANDARD
);
2498 have_got_offset
= true;
2507 case elfcpp::R_SPARC_NONE
:
2508 case elfcpp::R_SPARC_REGISTER
:
2509 case elfcpp::R_SPARC_GNU_VTINHERIT
:
2510 case elfcpp::R_SPARC_GNU_VTENTRY
:
2513 case elfcpp::R_SPARC_8
:
2514 Relocate_functions
<size
, big_endian
>::rela8(view
, object
,
2518 case elfcpp::R_SPARC_16
:
2519 if (rela
.get_r_offset() & 0x1)
2521 // The assembler can sometimes emit unaligned relocations
2522 // for dwarf2 cfi directives.
2523 Reloc::ua16(view
, object
, psymval
, addend
);
2526 Relocate_functions
<size
, big_endian
>::rela16(view
, object
,
2530 case elfcpp::R_SPARC_32
:
2531 if (!parameters
->options().output_is_position_independent())
2533 if (rela
.get_r_offset() & 0x3)
2535 // The assembler can sometimes emit unaligned relocations
2536 // for dwarf2 cfi directives.
2537 Reloc::ua32(view
, object
, psymval
, addend
);
2540 Relocate_functions
<size
, big_endian
>::rela32(view
, object
,
2545 case elfcpp::R_SPARC_DISP8
:
2546 Reloc::disp8(view
, object
, psymval
, addend
, address
);
2549 case elfcpp::R_SPARC_DISP16
:
2550 Reloc::disp16(view
, object
, psymval
, addend
, address
);
2553 case elfcpp::R_SPARC_DISP32
:
2554 Reloc::disp32(view
, object
, psymval
, addend
, address
);
2557 case elfcpp::R_SPARC_DISP64
:
2558 Reloc::disp64(view
, object
, psymval
, addend
, address
);
2561 case elfcpp::R_SPARC_WDISP30
:
2562 case elfcpp::R_SPARC_WPLT30
:
2563 Reloc::wdisp30(view
, object
, psymval
, addend
, address
);
2566 case elfcpp::R_SPARC_WDISP22
:
2567 Reloc::wdisp22(view
, object
, psymval
, addend
, address
);
2570 case elfcpp::R_SPARC_WDISP19
:
2571 Reloc::wdisp19(view
, object
, psymval
, addend
, address
);
2574 case elfcpp::R_SPARC_WDISP16
:
2575 Reloc::wdisp16(view
, object
, psymval
, addend
, address
);
2578 case elfcpp::R_SPARC_HI22
:
2579 Reloc::hi22(view
, object
, psymval
, addend
);
2582 case elfcpp::R_SPARC_22
:
2583 Reloc::rela32_22(view
, object
, psymval
, addend
);
2586 case elfcpp::R_SPARC_13
:
2587 Reloc::rela32_13(view
, object
, psymval
, addend
);
2590 case elfcpp::R_SPARC_LO10
:
2591 Reloc::lo10(view
, object
, psymval
, addend
);
2594 case elfcpp::R_SPARC_GOT10
:
2595 Reloc::lo10(view
, got_offset
, addend
);
2598 case elfcpp::R_SPARC_GOTDATA_OP
:
2601 case elfcpp::R_SPARC_GOTDATA_OP_LOX10
:
2602 case elfcpp::R_SPARC_GOT13
:
2603 Reloc::rela32_13(view
, got_offset
, addend
);
2606 case elfcpp::R_SPARC_GOTDATA_OP_HIX22
:
2607 case elfcpp::R_SPARC_GOT22
:
2608 Reloc::hi22(view
, got_offset
, addend
);
2611 case elfcpp::R_SPARC_PC10
:
2612 Reloc::pc10(view
, object
, psymval
, addend
, address
);
2615 case elfcpp::R_SPARC_PC22
:
2616 Reloc::pc22(view
, object
, psymval
, addend
, address
);
2619 case elfcpp::R_SPARC_TLS_DTPOFF32
:
2620 case elfcpp::R_SPARC_UA32
:
2621 Reloc::ua32(view
, object
, psymval
, addend
);
2624 case elfcpp::R_SPARC_PLT64
:
2625 Relocate_functions
<size
, big_endian
>::rela64(view
, object
,
2629 case elfcpp::R_SPARC_PLT32
:
2630 Relocate_functions
<size
, big_endian
>::rela32(view
, object
,
2634 case elfcpp::R_SPARC_HIPLT22
:
2635 Reloc::hi22(view
, object
, psymval
, addend
);
2638 case elfcpp::R_SPARC_LOPLT10
:
2639 Reloc::lo10(view
, object
, psymval
, addend
);
2642 case elfcpp::R_SPARC_PCPLT32
:
2643 Reloc::disp32(view
, object
, psymval
, addend
, address
);
2646 case elfcpp::R_SPARC_PCPLT22
:
2647 Reloc::pcplt22(view
, object
, psymval
, addend
, address
);
2650 case elfcpp::R_SPARC_PCPLT10
:
2651 Reloc::lo10(view
, object
, psymval
, addend
, address
);
2654 case elfcpp::R_SPARC_64
:
2655 if (!parameters
->options().output_is_position_independent())
2657 if (rela
.get_r_offset() & 0x7)
2659 // The assembler can sometimes emit unaligned relocations
2660 // for dwarf2 cfi directives.
2661 Reloc::ua64(view
, object
, psymval
, addend
);
2664 Relocate_functions
<size
, big_endian
>::rela64(view
, object
,
2669 case elfcpp::R_SPARC_OLO10
:
2671 unsigned int addend2
= rela
.get_r_info() & 0xffffffff;
2672 addend2
= ((addend2
>> 8) ^ 0x800000) - 0x800000;
2673 Reloc::olo10(view
, object
, psymval
, addend
, addend2
);
2677 case elfcpp::R_SPARC_HH22
:
2678 Reloc::hh22(view
, object
, psymval
, addend
);
2681 case elfcpp::R_SPARC_PC_HH22
:
2682 Reloc::pc_hh22(view
, object
, psymval
, addend
, address
);
2685 case elfcpp::R_SPARC_HM10
:
2686 Reloc::hm10(view
, object
, psymval
, addend
);
2689 case elfcpp::R_SPARC_PC_HM10
:
2690 Reloc::pc_hm10(view
, object
, psymval
, addend
, address
);
2693 case elfcpp::R_SPARC_LM22
:
2694 Reloc::hi22(view
, object
, psymval
, addend
);
2697 case elfcpp::R_SPARC_PC_LM22
:
2698 Reloc::pcplt22(view
, object
, psymval
, addend
, address
);
2701 case elfcpp::R_SPARC_11
:
2702 Reloc::rela32_11(view
, object
, psymval
, addend
);
2705 case elfcpp::R_SPARC_10
:
2706 Reloc::rela32_10(view
, object
, psymval
, addend
);
2709 case elfcpp::R_SPARC_7
:
2710 Reloc::rela32_7(view
, object
, psymval
, addend
);
2713 case elfcpp::R_SPARC_6
:
2714 Reloc::rela32_6(view
, object
, psymval
, addend
);
2717 case elfcpp::R_SPARC_5
:
2718 Reloc::rela32_5(view
, object
, psymval
, addend
);
2721 case elfcpp::R_SPARC_HIX22
:
2722 Reloc::hix22(view
, object
, psymval
, addend
);
2725 case elfcpp::R_SPARC_LOX10
:
2726 Reloc::lox10(view
, object
, psymval
, addend
);
2729 case elfcpp::R_SPARC_H44
:
2730 Reloc::h44(view
, object
, psymval
, addend
);
2733 case elfcpp::R_SPARC_M44
:
2734 Reloc::m44(view
, object
, psymval
, addend
);
2737 case elfcpp::R_SPARC_L44
:
2738 Reloc::l44(view
, object
, psymval
, addend
);
2741 case elfcpp::R_SPARC_TLS_DTPOFF64
:
2742 case elfcpp::R_SPARC_UA64
:
2743 Reloc::ua64(view
, object
, psymval
, addend
);
2746 case elfcpp::R_SPARC_UA16
:
2747 Reloc::ua16(view
, object
, psymval
, addend
);
2750 case elfcpp::R_SPARC_TLS_GD_HI22
:
2751 case elfcpp::R_SPARC_TLS_GD_LO10
:
2752 case elfcpp::R_SPARC_TLS_GD_ADD
:
2753 case elfcpp::R_SPARC_TLS_GD_CALL
:
2754 case elfcpp::R_SPARC_TLS_LDM_HI22
:
2755 case elfcpp::R_SPARC_TLS_LDM_LO10
:
2756 case elfcpp::R_SPARC_TLS_LDM_ADD
:
2757 case elfcpp::R_SPARC_TLS_LDM_CALL
:
2758 case elfcpp::R_SPARC_TLS_LDO_HIX22
:
2759 case elfcpp::R_SPARC_TLS_LDO_LOX10
:
2760 case elfcpp::R_SPARC_TLS_LDO_ADD
:
2761 case elfcpp::R_SPARC_TLS_IE_HI22
:
2762 case elfcpp::R_SPARC_TLS_IE_LO10
:
2763 case elfcpp::R_SPARC_TLS_IE_LD
:
2764 case elfcpp::R_SPARC_TLS_IE_LDX
:
2765 case elfcpp::R_SPARC_TLS_IE_ADD
:
2766 case elfcpp::R_SPARC_TLS_LE_HIX22
:
2767 case elfcpp::R_SPARC_TLS_LE_LOX10
:
2768 this->relocate_tls(relinfo
, target
, relnum
, rela
,
2769 r_type
, gsym
, psymval
, view
,
2770 address
, view_size
);
2773 case elfcpp::R_SPARC_COPY
:
2774 case elfcpp::R_SPARC_GLOB_DAT
:
2775 case elfcpp::R_SPARC_JMP_SLOT
:
2776 case elfcpp::R_SPARC_RELATIVE
:
2777 // These are outstanding tls relocs, which are unexpected when
2779 case elfcpp::R_SPARC_TLS_DTPMOD64
:
2780 case elfcpp::R_SPARC_TLS_DTPMOD32
:
2781 case elfcpp::R_SPARC_TLS_TPOFF64
:
2782 case elfcpp::R_SPARC_TLS_TPOFF32
:
2783 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
2784 _("unexpected reloc %u in object file"),
2789 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
2790 _("unsupported reloc %u"),
2798 // Perform a TLS relocation.
2800 template<int size
, bool big_endian
>
2802 Target_sparc
<size
, big_endian
>::Relocate::relocate_tls(
2803 const Relocate_info
<size
, big_endian
>* relinfo
,
2804 Target_sparc
<size
, big_endian
>* target
,
2806 const elfcpp::Rela
<size
, big_endian
>& rela
,
2807 unsigned int r_type
,
2808 const Sized_symbol
<size
>* gsym
,
2809 const Symbol_value
<size
>* psymval
,
2810 unsigned char* view
,
2811 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
2814 Output_segment
* tls_segment
= relinfo
->layout
->tls_segment();
2815 typedef Sparc_relocate_functions
<size
, big_endian
> Reloc
;
2816 const Sized_relobj
<size
, big_endian
>* object
= relinfo
->object
;
2817 typedef typename
elfcpp::Swap
<32, true>::Valtype Insntype
;
2819 const elfcpp::Elf_Xword addend
= rela
.get_r_addend();
2820 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
= psymval
->value(object
, 0);
2822 const bool is_final
=
2824 ? !parameters
->options().output_is_position_independent()
2825 : gsym
->final_value_is_known());
2826 const tls::Tls_optimization optimized_type
2827 = optimize_tls_reloc(is_final
, r_type
);
2831 case elfcpp::R_SPARC_TLS_GD_HI22
:
2832 case elfcpp::R_SPARC_TLS_GD_LO10
:
2833 case elfcpp::R_SPARC_TLS_GD_ADD
:
2834 case elfcpp::R_SPARC_TLS_GD_CALL
:
2835 if (optimized_type
== tls::TLSOPT_TO_LE
)
2837 Insntype
* wv
= reinterpret_cast<Insntype
*>(view
);
2840 value
-= tls_segment
->memsz();
2844 case elfcpp::R_SPARC_TLS_GD_HI22
:
2845 // TLS_GD_HI22 --> TLS_LE_HIX22
2846 Reloc::hix22(view
, value
, addend
);
2849 case elfcpp::R_SPARC_TLS_GD_LO10
:
2850 // TLS_GD_LO10 --> TLS_LE_LOX10
2851 Reloc::lox10(view
, value
, addend
);
2854 case elfcpp::R_SPARC_TLS_GD_ADD
:
2855 // add %reg1, %reg2, %reg3 --> mov %g7, %reg2, %reg3
2856 val
= elfcpp::Swap
<32, true>::readval(wv
);
2857 val
= (val
& ~0x7c000) | 0x1c000;
2858 elfcpp::Swap
<32, true>::writeval(wv
, val
);
2860 case elfcpp::R_SPARC_TLS_GD_CALL
:
2861 // call __tls_get_addr --> nop
2862 elfcpp::Swap
<32, true>::writeval(wv
, sparc_nop
);
2869 unsigned int got_type
= (optimized_type
== tls::TLSOPT_TO_IE
2870 ? GOT_TYPE_TLS_OFFSET
2871 : GOT_TYPE_TLS_PAIR
);
2874 gold_assert(gsym
->has_got_offset(got_type
));
2875 value
= gsym
->got_offset(got_type
);
2879 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
2880 gold_assert(object
->local_has_got_offset(r_sym
, got_type
));
2881 value
= object
->local_got_offset(r_sym
, got_type
);
2883 if (optimized_type
== tls::TLSOPT_TO_IE
)
2885 Insntype
* wv
= reinterpret_cast<Insntype
*>(view
);
2890 case elfcpp::R_SPARC_TLS_GD_HI22
:
2891 // TLS_GD_HI22 --> TLS_IE_HI22
2892 Reloc::hi22(view
, value
, addend
);
2895 case elfcpp::R_SPARC_TLS_GD_LO10
:
2896 // TLS_GD_LO10 --> TLS_IE_LO10
2897 Reloc::lo10(view
, value
, addend
);
2900 case elfcpp::R_SPARC_TLS_GD_ADD
:
2901 // add %reg1, %reg2, %reg3 --> ld [%reg1 + %reg2], %reg3
2902 val
= elfcpp::Swap
<32, true>::readval(wv
);
2909 elfcpp::Swap
<32, true>::writeval(wv
, val
);
2912 case elfcpp::R_SPARC_TLS_GD_CALL
:
2913 // The compiler can put the TLS_GD_ADD instruction
2914 // into the delay slot of the call. If so, we need
2915 // to transpose the two instructions so that the
2916 // the new sequence works properly.
2918 // The test we use is if the instruction in the
2919 // delay slot is an add with destination register
2921 val
= elfcpp::Swap
<32, true>::readval(wv
+ 1);
2922 if ((val
& 0x81f80000) == 0x80000000
2923 && ((val
>> 25) & 0x1f) == 0x8)
2930 elfcpp::Swap
<32, true>::writeval(wv
, val
);
2933 this->ignore_gd_add_
= true;
2936 // call __tls_get_addr --> add %g7, %o0, %o0
2937 elfcpp::Swap
<32, true>::writeval(wv
, 0x9001c008);
2942 else if (optimized_type
== tls::TLSOPT_NONE
)
2946 case elfcpp::R_SPARC_TLS_GD_HI22
:
2947 Reloc::hi22(view
, value
, addend
);
2949 case elfcpp::R_SPARC_TLS_GD_LO10
:
2950 Reloc::lo10(view
, value
, addend
);
2952 case elfcpp::R_SPARC_TLS_GD_ADD
:
2954 case elfcpp::R_SPARC_TLS_GD_CALL
:
2956 Symbol_value
<size
> symval
;
2957 elfcpp::Elf_Xword value
;
2960 tsym
= target
->tls_get_addr_sym_
;
2962 value
= (target
->plt_section()->address() +
2963 tsym
->plt_offset());
2964 symval
.set_output_value(value
);
2965 Reloc::wdisp30(view
, object
, &symval
, addend
, address
);
2972 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
2973 _("unsupported reloc %u"),
2977 case elfcpp::R_SPARC_TLS_LDM_HI22
:
2978 case elfcpp::R_SPARC_TLS_LDM_LO10
:
2979 case elfcpp::R_SPARC_TLS_LDM_ADD
:
2980 case elfcpp::R_SPARC_TLS_LDM_CALL
:
2981 if (optimized_type
== tls::TLSOPT_TO_LE
)
2983 Insntype
* wv
= reinterpret_cast<Insntype
*>(view
);
2987 case elfcpp::R_SPARC_TLS_LDM_HI22
:
2988 case elfcpp::R_SPARC_TLS_LDM_LO10
:
2989 case elfcpp::R_SPARC_TLS_LDM_ADD
:
2990 elfcpp::Swap
<32, true>::writeval(wv
, sparc_nop
);
2993 case elfcpp::R_SPARC_TLS_LDM_CALL
:
2994 elfcpp::Swap
<32, true>::writeval(wv
, sparc_mov_g0_o0
);
2999 else if (optimized_type
== tls::TLSOPT_NONE
)
3001 // Relocate the field with the offset of the GOT entry for
3002 // the module index.
3003 unsigned int got_offset
;
3005 got_offset
= target
->got_mod_index_entry(NULL
, NULL
, NULL
);
3008 case elfcpp::R_SPARC_TLS_LDM_HI22
:
3009 Reloc::hi22(view
, got_offset
, addend
);
3011 case elfcpp::R_SPARC_TLS_LDM_LO10
:
3012 Reloc::lo10(view
, got_offset
, addend
);
3014 case elfcpp::R_SPARC_TLS_LDM_ADD
:
3016 case elfcpp::R_SPARC_TLS_LDM_CALL
:
3018 Symbol_value
<size
> symval
;
3019 elfcpp::Elf_Xword value
;
3022 tsym
= target
->tls_get_addr_sym_
;
3024 value
= (target
->plt_section()->address() +
3025 tsym
->plt_offset());
3026 symval
.set_output_value(value
);
3027 Reloc::wdisp30(view
, object
, &symval
, addend
, address
);
3033 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3034 _("unsupported reloc %u"),
3038 // These relocs can appear in debugging sections, in which case
3039 // we won't see the TLS_LDM relocs. The local_dynamic_type
3040 // field tells us this.
3041 case elfcpp::R_SPARC_TLS_LDO_HIX22
:
3042 if (optimized_type
== tls::TLSOPT_TO_LE
)
3044 value
-= tls_segment
->memsz();
3045 Reloc::hix22(view
, value
, addend
);
3048 Reloc::ldo_hix22(view
, value
, addend
);
3050 case elfcpp::R_SPARC_TLS_LDO_LOX10
:
3051 if (optimized_type
== tls::TLSOPT_TO_LE
)
3053 value
-= tls_segment
->memsz();
3054 Reloc::lox10(view
, value
, addend
);
3057 Reloc::ldo_lox10(view
, value
, addend
);
3059 case elfcpp::R_SPARC_TLS_LDO_ADD
:
3060 if (optimized_type
== tls::TLSOPT_TO_LE
)
3062 Insntype
* wv
= reinterpret_cast<Insntype
*>(view
);
3065 // add %reg1, %reg2, %reg3 --> add %g7, %reg2, %reg3
3066 val
= elfcpp::Swap
<32, true>::readval(wv
);
3067 val
= (val
& ~0x7c000) | 0x1c000;
3068 elfcpp::Swap
<32, true>::writeval(wv
, val
);
3072 // When optimizing IE --> LE, the only relocation that is handled
3073 // differently is R_SPARC_TLS_IE_LD, it is rewritten from
3074 // 'ld{,x} [rs1 + rs2], rd' into 'mov rs2, rd' or simply a NOP is
3075 // rs2 and rd are the same.
3076 case elfcpp::R_SPARC_TLS_IE_LD
:
3077 case elfcpp::R_SPARC_TLS_IE_LDX
:
3078 if (optimized_type
== tls::TLSOPT_TO_LE
)
3080 Insntype
* wv
= reinterpret_cast<Insntype
*>(view
);
3081 Insntype val
= elfcpp::Swap
<32, true>::readval(wv
);
3082 Insntype rs2
= val
& 0x1f;
3083 Insntype rd
= (val
>> 25) & 0x1f;
3088 val
= sparc_mov
| (val
& 0x3e00001f);
3090 elfcpp::Swap
<32, true>::writeval(wv
, val
);
3094 case elfcpp::R_SPARC_TLS_IE_HI22
:
3095 case elfcpp::R_SPARC_TLS_IE_LO10
:
3096 if (optimized_type
== tls::TLSOPT_TO_LE
)
3098 value
-= tls_segment
->memsz();
3101 case elfcpp::R_SPARC_TLS_IE_HI22
:
3102 // IE_HI22 --> LE_HIX22
3103 Reloc::hix22(view
, value
, addend
);
3105 case elfcpp::R_SPARC_TLS_IE_LO10
:
3106 // IE_LO10 --> LE_LOX10
3107 Reloc::lox10(view
, value
, addend
);
3112 else if (optimized_type
== tls::TLSOPT_NONE
)
3114 // Relocate the field with the offset of the GOT entry for
3115 // the tp-relative offset of the symbol.
3118 gold_assert(gsym
->has_got_offset(GOT_TYPE_TLS_OFFSET
));
3119 value
= gsym
->got_offset(GOT_TYPE_TLS_OFFSET
);
3123 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
3124 gold_assert(object
->local_has_got_offset(r_sym
,
3125 GOT_TYPE_TLS_OFFSET
));
3126 value
= object
->local_got_offset(r_sym
,
3127 GOT_TYPE_TLS_OFFSET
);
3131 case elfcpp::R_SPARC_TLS_IE_HI22
:
3132 Reloc::hi22(view
, value
, addend
);
3134 case elfcpp::R_SPARC_TLS_IE_LO10
:
3135 Reloc::lo10(view
, value
, addend
);
3140 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3141 _("unsupported reloc %u"),
3145 case elfcpp::R_SPARC_TLS_IE_ADD
:
3146 // This seems to be mainly so that we can find the addition
3147 // instruction if there is one. There doesn't seem to be any
3148 // actual relocation to apply.
3151 case elfcpp::R_SPARC_TLS_LE_HIX22
:
3152 // If we're creating a shared library, a dynamic relocation will
3153 // have been created for this location, so do not apply it now.
3154 if (!parameters
->options().shared())
3156 value
-= tls_segment
->memsz();
3157 Reloc::hix22(view
, value
, addend
);
3161 case elfcpp::R_SPARC_TLS_LE_LOX10
:
3162 // If we're creating a shared library, a dynamic relocation will
3163 // have been created for this location, so do not apply it now.
3164 if (!parameters
->options().shared())
3166 value
-= tls_segment
->memsz();
3167 Reloc::lox10(view
, value
, addend
);
3173 // Relocate section data.
3175 template<int size
, bool big_endian
>
3177 Target_sparc
<size
, big_endian
>::relocate_section(
3178 const Relocate_info
<size
, big_endian
>* relinfo
,
3179 unsigned int sh_type
,
3180 const unsigned char* prelocs
,
3182 Output_section
* output_section
,
3183 bool needs_special_offset_handling
,
3184 unsigned char* view
,
3185 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
3186 section_size_type view_size
,
3187 const Reloc_symbol_changes
* reloc_symbol_changes
)
3189 typedef Target_sparc
<size
, big_endian
> Sparc
;
3190 typedef typename Target_sparc
<size
, big_endian
>::Relocate Sparc_relocate
;
3192 gold_assert(sh_type
== elfcpp::SHT_RELA
);
3194 gold::relocate_section
<size
, big_endian
, Sparc
, elfcpp::SHT_RELA
,
3201 needs_special_offset_handling
,
3205 reloc_symbol_changes
);
3208 // Return the size of a relocation while scanning during a relocatable
3211 template<int size
, bool big_endian
>
3213 Target_sparc
<size
, big_endian
>::Relocatable_size_for_reloc::get_size_for_reloc(
3217 // We are always SHT_RELA, so we should never get here.
3222 // Scan the relocs during a relocatable link.
3224 template<int size
, bool big_endian
>
3226 Target_sparc
<size
, big_endian
>::scan_relocatable_relocs(
3227 Symbol_table
* symtab
,
3229 Sized_relobj
<size
, big_endian
>* object
,
3230 unsigned int data_shndx
,
3231 unsigned int sh_type
,
3232 const unsigned char* prelocs
,
3234 Output_section
* output_section
,
3235 bool needs_special_offset_handling
,
3236 size_t local_symbol_count
,
3237 const unsigned char* plocal_symbols
,
3238 Relocatable_relocs
* rr
)
3240 gold_assert(sh_type
== elfcpp::SHT_RELA
);
3242 typedef gold::Default_scan_relocatable_relocs
<elfcpp::SHT_RELA
,
3243 Relocatable_size_for_reloc
> Scan_relocatable_relocs
;
3245 gold::scan_relocatable_relocs
<size
, big_endian
, elfcpp::SHT_RELA
,
3246 Scan_relocatable_relocs
>(
3254 needs_special_offset_handling
,
3260 // Relocate a section during a relocatable link.
3262 template<int size
, bool big_endian
>
3264 Target_sparc
<size
, big_endian
>::relocate_for_relocatable(
3265 const Relocate_info
<size
, big_endian
>* relinfo
,
3266 unsigned int sh_type
,
3267 const unsigned char* prelocs
,
3269 Output_section
* output_section
,
3270 off_t offset_in_output_section
,
3271 const Relocatable_relocs
* rr
,
3272 unsigned char* view
,
3273 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
3274 section_size_type view_size
,
3275 unsigned char* reloc_view
,
3276 section_size_type reloc_view_size
)
3278 gold_assert(sh_type
== elfcpp::SHT_RELA
);
3280 gold::relocate_for_relocatable
<size
, big_endian
, elfcpp::SHT_RELA
>(
3285 offset_in_output_section
,
3294 // Return the value to use for a dynamic which requires special
3295 // treatment. This is how we support equality comparisons of function
3296 // pointers across shared library boundaries, as described in the
3297 // processor specific ABI supplement.
3299 template<int size
, bool big_endian
>
3301 Target_sparc
<size
, big_endian
>::do_dynsym_value(const Symbol
* gsym
) const
3303 gold_assert(gsym
->is_from_dynobj() && gsym
->has_plt_offset());
3304 return this->plt_section()->address() + gsym
->plt_offset();
3307 // The selector for sparc object files.
3309 template<int size
, bool big_endian
>
3310 class Target_selector_sparc
: public Target_selector
3313 Target_selector_sparc()
3314 : Target_selector(elfcpp::EM_NONE
, size
, big_endian
,
3315 (size
== 64 ? "elf64-sparc" : "elf32-sparc"))
3318 Target
* do_recognize(int machine
, int, int)
3323 if (machine
!= elfcpp::EM_SPARCV9
)
3328 if (machine
!= elfcpp::EM_SPARC
3329 && machine
!= elfcpp::EM_SPARC32PLUS
)
3337 return this->instantiate_target();
3340 Target
* do_instantiate_target()
3341 { return new Target_sparc
<size
, big_endian
>(); }
3344 Target_selector_sparc
<32, true> target_selector_sparc32
;
3345 Target_selector_sparc
<64, true> target_selector_sparc64
;
3347 } // End anonymous namespace.