1 // tilegx.cc -- tilegx target support for gold.
3 // Copyright 2012 Free Software Foundation, Inc.
4 // Written by Jiong Wang (jiwang@tilera.com)
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.
29 #include "parameters.h"
36 #include "copy-relocs.h"
38 #include "target-reloc.h"
39 #include "target-select.h"
44 // the first got entry reserved
45 const int32_t TILEGX_GOT_RESERVE_COUNT
= 1;
47 // the first two .got.plt entry reserved
48 const int32_t TILEGX_GOTPLT_RESERVE_COUNT
= 2;
50 // 1. for both 64/32 bit mode, the instruction bundle is always 64bit.
51 // 2. thus .plt section should always be aligned to 64 bit.
52 const int32_t TILEGX_INST_BUNDLE_SIZE
= 64;
59 // A class to handle the PLT data.
60 // This is an abstract base class that handles most of the linker details
61 // but does not know the actual contents of PLT entries. The derived
62 // classes below fill in those details.
64 template<int size
, bool big_endian
>
65 class Output_data_plt_tilegx
: public Output_section_data
68 typedef Output_data_reloc
<elfcpp::SHT_RELA
, true,size
, big_endian
>
71 Output_data_plt_tilegx(Layout
* layout
, uint64_t addralign
,
72 Output_data_got
<size
, big_endian
>* got
,
73 Output_data_space
* got_plt
,
74 Output_data_space
* got_irelative
)
75 : Output_section_data(addralign
), layout_(layout
),
76 irelative_rel_(NULL
), got_(got
), got_plt_(got_plt
),
77 got_irelative_(got_irelative
), count_(0),
78 irelative_count_(0), free_list_()
79 { this->init(layout
); }
81 Output_data_plt_tilegx(Layout
* layout
, uint64_t plt_entry_size
,
82 Output_data_got
<size
, big_endian
>* got
,
83 Output_data_space
* got_plt
,
84 Output_data_space
* got_irelative
,
85 unsigned int plt_count
)
86 : Output_section_data((plt_count
+ 1) * plt_entry_size
,
87 TILEGX_INST_BUNDLE_SIZE
, false),
88 layout_(layout
), irelative_rel_(NULL
), got_(got
),
89 got_plt_(got_plt
), got_irelative_(got_irelative
), count_(plt_count
),
90 irelative_count_(0), free_list_()
94 // Initialize the free list and reserve the first entry.
95 this->free_list_
.init((plt_count
+ 1) * plt_entry_size
, false);
96 this->free_list_
.remove(0, plt_entry_size
);
99 // Initialize the PLT section.
101 init(Layout
* layout
);
103 // Add an entry to the PLT.
105 add_entry(Symbol_table
*, Layout
*, Symbol
* gsym
);
107 // Add an entry to the PLT for a local STT_GNU_IFUNC symbol.
109 add_local_ifunc_entry(Symbol_table
*, Layout
*,
110 Sized_relobj_file
<size
, big_endian
>*, unsigned int);
112 // Add the relocation for a PLT entry.
114 add_relocation(Symbol_table
*, Layout
*, Symbol
*, unsigned int);
116 // Return the .rela.plt section data.
119 { return this->rel_
; }
121 // Return where the IRELATIVE relocations should go in the PLT
124 rela_irelative(Symbol_table
*, Layout
*);
126 // Return whether we created a section for IRELATIVE relocations.
128 has_irelative_section() const
129 { return this->irelative_rel_
!= NULL
; }
131 // Return the number of PLT entries.
134 { return this->count_
+ this->irelative_count_
; }
136 // Return the offset of the first non-reserved PLT entry.
138 first_plt_entry_offset()
139 { return this->get_plt_entry_size(); }
141 // Return the size of a PLT entry.
143 get_plt_entry_size() const
144 { return plt_entry_size
; }
146 // Reserve a slot in the PLT for an existing symbol in an incremental update.
148 reserve_slot(unsigned int plt_index
)
150 this->free_list_
.remove((plt_index
+ 1) * this->get_plt_entry_size(),
151 (plt_index
+ 2) * this->get_plt_entry_size());
154 // Return the PLT address to use for a global symbol.
156 address_for_global(const Symbol
*);
158 // Return the PLT address to use for a local symbol.
160 address_for_local(const Relobj
*, unsigned int symndx
);
163 // Fill in the first PLT entry.
165 fill_first_plt_entry(unsigned char*);
167 // Fill in a normal PLT entry. Returns the offset into the entry that
168 // should be the initial GOT slot value.
170 fill_plt_entry(unsigned char*,
171 typename
elfcpp::Elf_types
<size
>::Elf_Addr
,
173 typename
elfcpp::Elf_types
<size
>::Elf_Addr
,
174 unsigned int, unsigned int);
177 do_adjust_output_section(Output_section
* os
);
179 // Write to a map file.
181 do_print_to_mapfile(Mapfile
* mapfile
) const
182 { mapfile
->print_output_data(this, _("** PLT")); }
185 // Set the final size.
187 set_final_data_size();
189 // Write out the PLT data.
191 do_write(Output_file
*);
193 // A pointer to the Layout class, so that we can find the .dynamic
194 // section when we write out the GOT PLT section.
196 // The reloc section.
198 // The IRELATIVE relocs, if necessary. These must follow the
199 // regular PLT relocations.
200 Reloc_section
* irelative_rel_
;
202 Output_data_got
<size
, big_endian
>* got_
;
203 // The .got.plt section.
204 Output_data_space
* got_plt_
;
205 // The part of the .got.plt section used for IRELATIVE relocs.
206 Output_data_space
* got_irelative_
;
207 // The number of PLT entries.
209 // Number of PLT entries with R_TILEGX_IRELATIVE relocs. These
210 // follow the regular PLT entries.
211 unsigned int irelative_count_
;
212 // List of available regions within the section, for incremental
214 Free_list free_list_
;
215 // The size of an entry in the PLT.
216 static const int plt_entry_size
= 40;
217 // The first entry in the PLT.
218 static const unsigned char first_plt_entry
[plt_entry_size
];
219 // Other entries in the PLT for an executable.
220 static const unsigned char plt_entry
[plt_entry_size
];
223 // The tilegx target class.
225 // http://www.tilera.com/scm
226 // TLS info comes from
227 // http://people.redhat.com/drepper/tls.pdf
229 template<int size
, bool big_endian
>
230 class Target_tilegx
: public Sized_target
<size
, big_endian
>
234 typedef Output_data_reloc
<elfcpp::SHT_RELA
, true, size
, big_endian
>
237 Target_tilegx(const Target::Target_info
* info
= &tilegx_info
)
238 : Sized_target
<size
, big_endian
>(info
),
239 got_(NULL
), plt_(NULL
), got_plt_(NULL
), got_irelative_(NULL
),
240 global_offset_table_(NULL
), tilegx_dynamic_(NULL
), rela_dyn_(NULL
),
241 rela_irelative_(NULL
), copy_relocs_(elfcpp::R_TILEGX_COPY
),
242 dynbss_(NULL
), got_mod_index_offset_(-1U),
243 tls_get_addr_sym_defined_(false)
246 // Scan the relocations to look for symbol adjustments.
248 gc_process_relocs(Symbol_table
* symtab
,
250 Sized_relobj_file
<size
, big_endian
>* object
,
251 unsigned int data_shndx
,
252 unsigned int sh_type
,
253 const unsigned char* prelocs
,
255 Output_section
* output_section
,
256 bool needs_special_offset_handling
,
257 size_t local_symbol_count
,
258 const unsigned char* plocal_symbols
);
260 // Scan the relocations to look for symbol adjustments.
262 scan_relocs(Symbol_table
* symtab
,
264 Sized_relobj_file
<size
, big_endian
>* object
,
265 unsigned int data_shndx
,
266 unsigned int sh_type
,
267 const unsigned char* prelocs
,
269 Output_section
* output_section
,
270 bool needs_special_offset_handling
,
271 size_t local_symbol_count
,
272 const unsigned char* plocal_symbols
);
274 // Finalize the sections.
276 do_finalize_sections(Layout
*, const Input_objects
*, Symbol_table
*);
278 // Return the value to use for a dynamic which requires special
281 do_dynsym_value(const Symbol
*) const;
283 // Relocate a section.
285 relocate_section(const Relocate_info
<size
, big_endian
>*,
286 unsigned int sh_type
,
287 const unsigned char* prelocs
,
289 Output_section
* output_section
,
290 bool needs_special_offset_handling
,
292 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
293 section_size_type view_size
,
294 const Reloc_symbol_changes
*);
296 // Scan the relocs during a relocatable link.
298 scan_relocatable_relocs(Symbol_table
* symtab
,
300 Sized_relobj_file
<size
, big_endian
>* object
,
301 unsigned int data_shndx
,
302 unsigned int sh_type
,
303 const unsigned char* prelocs
,
305 Output_section
* output_section
,
306 bool needs_special_offset_handling
,
307 size_t local_symbol_count
,
308 const unsigned char* plocal_symbols
,
309 Relocatable_relocs
*);
311 // Relocate a section during a relocatable link.
314 const Relocate_info
<size
, big_endian
>*,
315 unsigned int sh_type
,
316 const unsigned char* prelocs
,
318 Output_section
* output_section
,
319 typename
elfcpp::Elf_types
<size
>::Elf_Off offset_in_output_section
,
320 const Relocatable_relocs
*,
322 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
323 section_size_type view_size
,
324 unsigned char* reloc_view
,
325 section_size_type reloc_view_size
);
327 // Return whether SYM is defined by the ABI.
329 do_is_defined_by_abi(const Symbol
* sym
) const
330 { return strcmp(sym
->name(), "__tls_get_addr") == 0; }
332 // define tilegx specific symbols
334 do_define_standard_symbols(Symbol_table
*, Layout
*);
336 // Return the PLT section.
338 do_plt_address_for_global(const Symbol
* gsym
) const
339 { return this->plt_section()->address_for_global(gsym
); }
342 do_plt_address_for_local(const Relobj
* relobj
, unsigned int symndx
) const
343 { return this->plt_section()->address_for_local(relobj
, symndx
); }
345 // This function should be defined in targets that can use relocation
346 // types to determine (implemented in local_reloc_may_be_function_pointer
347 // and global_reloc_may_be_function_pointer)
348 // if a function's pointer is taken. ICF uses this in safe mode to only
349 // fold those functions whose pointer is defintely not taken. For tilegx
350 // pie binaries, safe ICF cannot be done by looking at relocation types.
352 do_can_check_for_function_pointers() const
355 // Return the base for a DW_EH_PE_datarel encoding.
357 do_ehframe_datarel_base() const;
359 // Return whether there is a GOT section.
361 has_got_section() const
362 { return this->got_
!= NULL
; }
364 // Return the size of the GOT section.
368 gold_assert(this->got_
!= NULL
);
369 return this->got_
->data_size();
372 // Return the number of entries in the GOT.
374 got_entry_count() const
376 if (this->got_
== NULL
)
378 return this->got_size() / (size
/ 8);
381 // Return the number of entries in the PLT.
383 plt_entry_count() const;
385 // Return the offset of the first non-reserved PLT entry.
387 first_plt_entry_offset() const;
389 // Return the size of each PLT entry.
391 plt_entry_size() const;
393 // Create the GOT section for an incremental update.
394 Output_data_got_base
*
395 init_got_plt_for_update(Symbol_table
* symtab
,
397 unsigned int got_count
,
398 unsigned int plt_count
);
400 // Reserve a GOT entry for a local symbol, and regenerate any
401 // necessary dynamic relocations.
403 reserve_local_got_entry(unsigned int got_index
,
404 Sized_relobj
<size
, big_endian
>* obj
,
406 unsigned int got_type
);
408 // Reserve a GOT entry for a global symbol, and regenerate any
409 // necessary dynamic relocations.
411 reserve_global_got_entry(unsigned int got_index
, Symbol
* gsym
,
412 unsigned int got_type
);
414 // Register an existing PLT entry for a global symbol.
416 register_global_plt_entry(Symbol_table
*, Layout
*, unsigned int plt_index
,
419 // Force a COPY relocation for a given symbol.
421 emit_copy_reloc(Symbol_table
*, Symbol
*, Output_section
*, off_t
);
423 // Apply an incremental relocation.
425 apply_relocation(const Relocate_info
<size
, big_endian
>* relinfo
,
426 typename
elfcpp::Elf_types
<size
>::Elf_Addr r_offset
,
428 typename
elfcpp::Elf_types
<size
>::Elf_Swxword r_addend
,
431 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
432 section_size_type view_size
);
435 // The class which scans relocations.
440 : issued_non_pic_error_(false)
444 get_reference_flags(unsigned int r_type
);
447 local(Symbol_table
* symtab
, Layout
* layout
, Target_tilegx
* target
,
448 Sized_relobj_file
<size
, big_endian
>* object
,
449 unsigned int data_shndx
,
450 Output_section
* output_section
,
451 const elfcpp::Rela
<size
, big_endian
>& reloc
, unsigned int r_type
,
452 const elfcpp::Sym
<size
, big_endian
>& lsym
,
456 global(Symbol_table
* symtab
, Layout
* layout
, Target_tilegx
* target
,
457 Sized_relobj_file
<size
, big_endian
>* object
,
458 unsigned int data_shndx
,
459 Output_section
* output_section
,
460 const elfcpp::Rela
<size
, big_endian
>& reloc
, unsigned int r_type
,
464 local_reloc_may_be_function_pointer(Symbol_table
* symtab
, Layout
* layout
,
465 Target_tilegx
* target
,
466 Sized_relobj_file
<size
, big_endian
>* object
,
467 unsigned int data_shndx
,
468 Output_section
* output_section
,
469 const elfcpp::Rela
<size
, big_endian
>& reloc
,
471 const elfcpp::Sym
<size
, big_endian
>& lsym
);
474 global_reloc_may_be_function_pointer(Symbol_table
* symtab
, Layout
* layout
,
475 Target_tilegx
* target
,
476 Sized_relobj_file
<size
, big_endian
>* object
,
477 unsigned int data_shndx
,
478 Output_section
* output_section
,
479 const elfcpp::Rela
<size
, big_endian
>& reloc
,
485 unsupported_reloc_local(Sized_relobj_file
<size
, big_endian
>*,
486 unsigned int r_type
);
489 unsupported_reloc_global(Sized_relobj_file
<size
, big_endian
>*,
490 unsigned int r_type
, Symbol
*);
493 check_non_pic(Relobj
*, unsigned int r_type
);
496 possible_function_pointer_reloc(unsigned int r_type
);
499 reloc_needs_plt_for_ifunc(Sized_relobj_file
<size
, big_endian
>*,
500 unsigned int r_type
);
502 // Whether we have issued an error about a non-PIC compilation.
503 bool issued_non_pic_error_
;
506 // The class which implements relocation.
517 // Do a relocation. Return false if the caller should not issue
518 // any warnings about this relocation.
520 relocate(const Relocate_info
<size
, big_endian
>*, Target_tilegx
*,
522 size_t relnum
, const elfcpp::Rela
<size
, big_endian
>&,
523 unsigned int r_type
, const Sized_symbol
<size
>*,
524 const Symbol_value
<size
>*,
525 unsigned char*, typename
elfcpp::Elf_types
<size
>::Elf_Addr
,
529 // A class which returns the size required for a relocation type,
530 // used while scanning relocs during a relocatable link.
531 class Relocatable_size_for_reloc
535 get_size_for_reloc(unsigned int, Relobj
*);
538 // Adjust TLS relocation type based on the options and whether this
539 // is a local symbol.
540 static tls::Tls_optimization
541 optimize_tls_reloc(bool is_final
, int r_type
);
543 // Get the GOT section, creating it if necessary.
544 Output_data_got
<size
, big_endian
>*
545 got_section(Symbol_table
*, Layout
*);
547 // Get the GOT PLT section.
549 got_plt_section() const
551 gold_assert(this->got_plt_
!= NULL
);
552 return this->got_plt_
;
555 // Create the PLT section.
557 make_plt_section(Symbol_table
* symtab
, Layout
* layout
);
559 // Create a PLT entry for a global symbol.
561 make_plt_entry(Symbol_table
*, Layout
*, Symbol
*);
563 // Create a PLT entry for a local STT_GNU_IFUNC symbol.
565 make_local_ifunc_plt_entry(Symbol_table
*, Layout
*,
566 Sized_relobj_file
<size
, big_endian
>* relobj
,
567 unsigned int local_sym_index
);
569 // Create a GOT entry for the TLS module index.
571 got_mod_index_entry(Symbol_table
* symtab
, Layout
* layout
,
572 Sized_relobj_file
<size
, big_endian
>* object
);
574 // Get the PLT section.
575 Output_data_plt_tilegx
<size
, big_endian
>*
578 gold_assert(this->plt_
!= NULL
);
582 // Get the dynamic reloc section, creating it if necessary.
584 rela_dyn_section(Layout
*);
586 // Get the section to use for IRELATIVE relocations.
588 rela_irelative_section(Layout
*);
590 // Add a potential copy relocation.
592 copy_reloc(Symbol_table
* symtab
, Layout
* layout
,
593 Sized_relobj_file
<size
, big_endian
>* object
,
594 unsigned int shndx
, Output_section
* output_section
,
595 Symbol
* sym
, const elfcpp::Rela
<size
, big_endian
>& reloc
)
597 this->copy_relocs_
.copy_reloc(symtab
, layout
,
598 symtab
->get_sized_symbol
<size
>(sym
),
599 object
, shndx
, output_section
,
600 reloc
, this->rela_dyn_section(layout
));
603 // Information about this specific target which we pass to the
604 // general Target structure.
605 static const Target::Target_info tilegx_info
;
607 // The types of GOT entries needed for this platform.
608 // These values are exposed to the ABI in an incremental link.
609 // Do not renumber existing values without changing the version
610 // number of the .gnu_incremental_inputs section.
613 GOT_TYPE_STANDARD
= 0, // GOT entry for a regular symbol
614 GOT_TYPE_TLS_OFFSET
= 1, // GOT entry for TLS offset
615 GOT_TYPE_TLS_PAIR
= 2, // GOT entry for TLS module/offset pair
616 GOT_TYPE_TLS_DESC
= 3 // GOT entry for TLS_DESC pair
619 // This type is used as the argument to the target specific
620 // relocation routines. The only target specific reloc is
621 // R_X86_64_TLSDESC against a local symbol.
624 Tlsdesc_info(Sized_relobj_file
<size
, big_endian
>* a_object
,
625 unsigned int a_r_sym
)
626 : object(a_object
), r_sym(a_r_sym
)
629 // The object in which the local symbol is defined.
630 Sized_relobj_file
<size
, big_endian
>* object
;
631 // The local symbol index in the object.
636 Output_data_got
<size
, big_endian
>* got_
;
638 Output_data_plt_tilegx
<size
, big_endian
>* plt_
;
639 // The GOT PLT section.
640 Output_data_space
* got_plt_
;
641 // The GOT section for IRELATIVE relocations.
642 Output_data_space
* got_irelative_
;
643 // The _GLOBAL_OFFSET_TABLE_ symbol.
644 Symbol
* global_offset_table_
;
645 // The _TILEGX_DYNAMIC_ symbol.
646 Symbol
* tilegx_dynamic_
;
647 // The dynamic reloc section.
648 Reloc_section
* rela_dyn_
;
649 // The section to use for IRELATIVE relocs.
650 Reloc_section
* rela_irelative_
;
651 // Relocs saved to avoid a COPY reloc.
652 Copy_relocs
<elfcpp::SHT_RELA
, size
, big_endian
> copy_relocs_
;
653 // Space for variables copied with a COPY reloc.
654 Output_data_space
* dynbss_
;
655 // Offset of the GOT entry for the TLS module index.
656 unsigned int got_mod_index_offset_
;
657 // True if the _tls_get_addr symbol has been defined.
658 bool tls_get_addr_sym_defined_
;
662 const Target::Target_info Target_tilegx
<64, false>::tilegx_info
=
665 false, // is_big_endian
666 elfcpp::EM_TILEGX
, // machine_code
667 false, // has_make_symbol
668 false, // has_resolve
669 false, // has_code_fill
670 true, // is_default_stack_executable
671 false, // can_icf_inline_merge_sections
673 "/lib/ld.so.1", // program interpreter
674 0x10000, // default_text_segment_address
675 0x10000, // abi_pagesize (overridable by -z max-page-size)
676 0x10000, // common_pagesize (overridable by -z common-page-size)
677 false, // isolate_execinstr
679 elfcpp::SHN_UNDEF
, // small_common_shndx
680 elfcpp::SHN_UNDEF
, // large_common_shndx
681 0, // small_common_section_flags
682 0, // large_common_section_flags
683 NULL
, // attributes_section
684 NULL
// attributes_vendor
688 const Target::Target_info Target_tilegx
<32, false>::tilegx_info
=
691 false, // is_big_endian
692 elfcpp::EM_TILEGX
, // machine_code
693 false, // has_make_symbol
694 false, // has_resolve
695 false, // has_code_fill
696 true, // is_default_stack_executable
697 false, // can_icf_inline_merge_sections
699 "/lib32/ld.so.1", // program interpreter
700 0x10000, // default_text_segment_address
701 0x10000, // abi_pagesize (overridable by -z max-page-size)
702 0x10000, // common_pagesize (overridable by -z common-page-size)
703 false, // isolate_execinstr
705 elfcpp::SHN_UNDEF
, // small_common_shndx
706 elfcpp::SHN_UNDEF
, // large_common_shndx
707 0, // small_common_section_flags
708 0, // large_common_section_flags
709 NULL
, // attributes_section
710 NULL
// attributes_vendor
714 const Target::Target_info Target_tilegx
<64, true>::tilegx_info
=
717 true, // is_big_endian
718 elfcpp::EM_TILEGX
, // machine_code
719 false, // has_make_symbol
720 false, // has_resolve
721 false, // has_code_fill
722 true, // is_default_stack_executable
723 false, // can_icf_inline_merge_sections
725 "/lib/ld.so.1", // program interpreter
726 0x10000, // default_text_segment_address
727 0x10000, // abi_pagesize (overridable by -z max-page-size)
728 0x10000, // common_pagesize (overridable by -z common-page-size)
729 false, // isolate_execinstr
731 elfcpp::SHN_UNDEF
, // small_common_shndx
732 elfcpp::SHN_UNDEF
, // large_common_shndx
733 0, // small_common_section_flags
734 0, // large_common_section_flags
735 NULL
, // attributes_section
736 NULL
// attributes_vendor
740 const Target::Target_info Target_tilegx
<32, true>::tilegx_info
=
743 true, // is_big_endian
744 elfcpp::EM_TILEGX
, // machine_code
745 false, // has_make_symbol
746 false, // has_resolve
747 false, // has_code_fill
748 true, // is_default_stack_executable
749 false, // can_icf_inline_merge_sections
751 "/lib32/ld.so.1", // program interpreter
752 0x10000, // default_text_segment_address
753 0x10000, // abi_pagesize (overridable by -z max-page-size)
754 0x10000, // common_pagesize (overridable by -z common-page-size)
755 false, // isolate_execinstr
757 elfcpp::SHN_UNDEF
, // small_common_shndx
758 elfcpp::SHN_UNDEF
, // large_common_shndx
759 0, // small_common_section_flags
760 0, // large_common_section_flags
761 NULL
, // attributes_section
762 NULL
// attributes_vendor
765 // tilegx relocation handlers
766 template<int size
, bool big_endian
>
767 class Tilegx_relocate_functions
770 // overflow check will be supported later
773 STATUS_OKAY
, // No error during relocation.
774 STATUS_OVERFLOW
, // Relocation overflow.
775 STATUS_BAD_RELOC
// Relocation cannot be applied.
780 // right shift operand by this number of bits.
781 unsigned char srshift
;
783 // the offset to apply relocation.
784 unsigned char doffset
;
786 // set to 1 for pc-relative relocation.
787 unsigned char is_pcrel
;
789 // size in bits, or 0 if this table entry should be ignored.
792 // whether we need to check overflow.
793 unsigned char overflow
;
796 static const Tilegx_howto howto
[elfcpp::R_TILEGX_NUM
];
800 // Do a simple rela relocation
801 template<int valsize
>
803 rela(unsigned char* view
,
804 const Sized_relobj_file
<size
, big_endian
>* object
,
805 const Symbol_value
<size
>* psymval
,
806 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
807 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset
,
808 elfcpp::Elf_Xword bitmask
)
810 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
811 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
812 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
815 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
)) >> srshift
;
817 reloc
= psymval
->value(object
, addend
) >> srshift
;
819 elfcpp::Elf_Xword dst_mask
= bitmask
<< doffset
;
824 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| (reloc
<<doffset
));
827 // Do a simple rela relocation
828 template<int valsize
>
830 rela_ua(unsigned char* view
,
831 const Sized_relobj_file
<size
, big_endian
>* object
,
832 const Symbol_value
<size
>* psymval
,
833 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
834 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset
,
835 elfcpp::Elf_Xword bitmask
)
837 typedef typename
elfcpp::Swap_unaligned
<valsize
, big_endian
>::Valtype
839 unsigned char* wv
= view
;
840 Valtype val
= elfcpp::Swap_unaligned
<valsize
, big_endian
>::readval(wv
);
843 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
)) >> srshift
;
845 reloc
= psymval
->value(object
, addend
) >> srshift
;
847 elfcpp::Elf_Xword dst_mask
= bitmask
<< doffset
;
852 elfcpp::Swap_unaligned
<valsize
, big_endian
>::writeval(wv
,
853 val
| (reloc
<<doffset
));
856 template<int valsize
>
858 rela(unsigned char* view
,
859 const Sized_relobj_file
<size
, big_endian
>* object
,
860 const Symbol_value
<size
>* psymval
,
861 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
862 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset1
,
863 elfcpp::Elf_Xword bitmask1
, elfcpp::Elf_Xword doffset2
,
864 elfcpp::Elf_Xword bitmask2
)
866 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
867 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
868 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
871 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
)) >> srshift
;
873 reloc
= psymval
->value(object
, addend
) >> srshift
;
875 elfcpp::Elf_Xword dst_mask
= (bitmask1
<< doffset1
)
876 | (bitmask2
<< doffset2
);
878 reloc
= ((reloc
& bitmask1
) << doffset1
)
879 | ((reloc
& bitmask2
) << doffset2
);
881 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| reloc
);
885 // Do a simple PC relative relocation with a Symbol_value with the
886 // addend in the relocation.
887 template<int valsize
>
889 pcrela(unsigned char* view
,
890 const Sized_relobj_file
<size
, big_endian
>* object
,
891 const Symbol_value
<size
>* psymval
,
892 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
893 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
894 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset
,
895 elfcpp::Elf_Xword bitmask
)
898 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
899 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
900 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
903 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
) - address
)
906 reloc
= (psymval
->value(object
, addend
) - address
) >> srshift
;
908 elfcpp::Elf_Xword dst_mask
= bitmask
<< doffset
;
912 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| (reloc
<<doffset
));
915 template<int valsize
>
917 pcrela_ua(unsigned char* view
,
918 const Sized_relobj_file
<size
, big_endian
>* object
,
919 const Symbol_value
<size
>* psymval
,
920 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
921 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
922 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset
,
923 elfcpp::Elf_Xword bitmask
)
926 typedef typename
elfcpp::Swap_unaligned
<valsize
, big_endian
>::Valtype
928 unsigned char* wv
= view
;
931 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
) - address
)
934 reloc
= (psymval
->value(object
, addend
) - address
) >> srshift
;
938 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, reloc
<< doffset
);
941 template<int valsize
>
943 pcrela(unsigned char* view
,
944 const Sized_relobj_file
<size
, big_endian
>* object
,
945 const Symbol_value
<size
>* psymval
,
946 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
947 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
948 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset1
,
949 elfcpp::Elf_Xword bitmask1
, elfcpp::Elf_Xword doffset2
,
950 elfcpp::Elf_Xword bitmask2
)
953 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
954 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
955 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
958 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
) - address
)
961 reloc
= (psymval
->value(object
, addend
) - address
) >> srshift
;
963 elfcpp::Elf_Xword dst_mask
= (bitmask1
<< doffset1
)
964 | (bitmask2
<< doffset2
);
966 reloc
= ((reloc
& bitmask1
) << doffset1
)
967 | ((reloc
& bitmask2
) << doffset2
);
969 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| reloc
);
972 typedef Tilegx_relocate_functions
<size
, big_endian
> This
;
973 typedef Relocate_functions
<size
, big_endian
> Base
;
978 abs64(unsigned char* view
,
979 const Sized_relobj_file
<size
, big_endian
>* object
,
980 const Symbol_value
<size
>* psymval
,
981 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
983 This::template rela_ua
<64>(view
, object
, psymval
, addend
, 0, 0,
984 0xffffffffffffffffllu
);
988 abs32(unsigned char* view
,
989 const Sized_relobj_file
<size
, big_endian
>* object
,
990 const Symbol_value
<size
>* psymval
,
991 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
993 This::template rela_ua
<32>(view
, object
, psymval
, addend
, 0, 0,
998 abs16(unsigned char* view
,
999 const Sized_relobj_file
<size
, big_endian
>* object
,
1000 const Symbol_value
<size
>* psymval
,
1001 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
1003 This::template rela_ua
<16>(view
, object
, psymval
, addend
, 0, 0,
1008 pc_abs64(unsigned char* view
,
1009 const Sized_relobj_file
<size
, big_endian
>* object
,
1010 const Symbol_value
<size
>* psymval
,
1011 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1012 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
1014 This::template pcrela_ua
<64>(view
, object
, psymval
, addend
, address
, 0, 0,
1015 0xffffffffffffffffllu
);
1019 pc_abs32(unsigned char* view
,
1020 const Sized_relobj_file
<size
, big_endian
>* object
,
1021 const Symbol_value
<size
>* psymval
,
1022 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1023 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
1025 This::template pcrela_ua
<32>(view
, object
, psymval
, addend
, address
, 0, 0,
1030 pc_abs16(unsigned char* view
,
1031 const Sized_relobj_file
<size
, big_endian
>* object
,
1032 const Symbol_value
<size
>* psymval
,
1033 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1034 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
1036 This::template pcrela_ua
<16>(view
, object
, psymval
, addend
, address
, 0, 0,
1041 imm_x_general(unsigned char* view
,
1042 const Sized_relobj_file
<size
, big_endian
>* object
,
1043 const Symbol_value
<size
>* psymval
,
1044 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1045 Tilegx_howto
&r_howto
)
1047 This::template rela
<64>(view
, object
, psymval
, addend
,
1048 (elfcpp::Elf_Xword
)(r_howto
.srshift
),
1049 (elfcpp::Elf_Xword
)(r_howto
.doffset
),
1050 (elfcpp::Elf_Xword
)((1 << r_howto
.bsize
) - 1));
1054 imm_x_pcrel_general(unsigned char* view
,
1055 const Sized_relobj_file
<size
, big_endian
>* object
,
1056 const Symbol_value
<size
>* psymval
,
1057 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1058 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
1059 Tilegx_howto
&r_howto
)
1061 This::template pcrela
<64>(view
, object
, psymval
, addend
, address
,
1062 (elfcpp::Elf_Xword
)(r_howto
.srshift
),
1063 (elfcpp::Elf_Xword
)(r_howto
.doffset
),
1064 (elfcpp::Elf_Xword
)((1 << r_howto
.bsize
) - 1));
1068 imm_x_two_part_general(unsigned char* view
,
1069 const Sized_relobj_file
<size
, big_endian
>* object
,
1070 const Symbol_value
<size
>* psymval
,
1071 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1072 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
1073 unsigned int r_type
)
1076 elfcpp::Elf_Xword doffset1
= 0llu;
1077 elfcpp::Elf_Xword doffset2
= 0llu;
1078 elfcpp::Elf_Xword dmask1
= 0llu;
1079 elfcpp::Elf_Xword dmask2
= 0llu;
1080 elfcpp::Elf_Xword rshift
= 0llu;
1081 unsigned int pc_rel
= 0;
1085 case elfcpp::R_TILEGX_BROFF_X1
:
1089 dmask2
= 0x1ffc0llu
;
1093 case elfcpp::R_TILEGX_DEST_IMM8_X1
:
1103 This::template pcrela
<64>(view
, object
, psymval
, addend
, address
,
1104 rshift
, doffset1
, dmask1
, doffset2
, dmask2
);
1106 This::template rela
<64>(view
, object
, psymval
, addend
, rshift
,
1107 doffset1
, dmask1
, doffset2
, dmask2
);
1112 tls_relax(unsigned char* view
, unsigned int r_type
,
1113 tls::Tls_optimization opt_t
)
1116 const uint64_t TILEGX_X_MOVE_R0_R0
= 0x283bf8005107f000llu
;
1117 const uint64_t TILEGX_Y_MOVE_R0_R0
= 0xae05f800540bf000llu
;
1118 const uint64_t TILEGX_X_LD
= 0x286ae80000000000llu
;
1119 const uint64_t TILEGX_X_LD4S
= 0x286a980000000000llu
;
1120 const uint64_t TILEGX_X1_FULL_MASK
= 0x3fffffff80000000llu
;
1121 const uint64_t TILEGX_X0_RRR_MASK
= 0x000000007ffc0000llu
;
1122 const uint64_t TILEGX_X1_RRR_MASK
= 0x3ffe000000000000llu
;
1123 const uint64_t TILEGX_Y0_RRR_MASK
= 0x00000000780c0000llu
;
1124 const uint64_t TILEGX_Y1_RRR_MASK
= 0x3c06000000000000llu
;
1125 const uint64_t TILEGX_X0_RRR_SRCB_MASK
= 0x000000007ffff000llu
;
1126 const uint64_t TILEGX_X1_RRR_SRCB_MASK
= 0x3ffff80000000000llu
;
1127 const uint64_t TILEGX_Y0_RRR_SRCB_MASK
= 0x00000000780ff000llu
;
1128 const uint64_t TILEGX_Y1_RRR_SRCB_MASK
= 0x3c07f80000000000llu
;
1129 const uint64_t TILEGX_X_ADD_R0_R0_TP
= 0x2807a800500f5000llu
;
1130 const uint64_t TILEGX_Y_ADD_R0_R0_TP
= 0x9a13a8002c275000llu
;
1131 const uint64_t TILEGX_X_ADDX_R0_R0_TP
= 0x2805a800500b5000llu
;
1132 const uint64_t TILEGX_Y_ADDX_R0_R0_TP
= 0x9a01a8002c035000llu
;
1134 const uint64_t R_TILEGX_IMM8_X0_TLS_ADD_MASK
=
1135 (TILEGX_X0_RRR_MASK
| (0x3Fllu
<< 12));
1137 const uint64_t R_TILEGX_IMM8_X1_TLS_ADD_MASK
=
1138 (TILEGX_X1_RRR_MASK
| (0x3Fllu
<< 43));
1140 const uint64_t R_TILEGX_IMM8_Y0_TLS_ADD_MASK
=
1141 (TILEGX_Y0_RRR_MASK
| (0x3Fllu
<< 12));
1143 const uint64_t R_TILEGX_IMM8_Y1_TLS_ADD_MASK
=
1144 (TILEGX_Y1_RRR_MASK
| (0x3Fllu
<< 43));
1146 const uint64_t R_TILEGX_IMM8_X0_TLS_ADD_LE_MASK
=
1147 (TILEGX_X0_RRR_SRCB_MASK
| (0x3Fllu
<< 6));
1149 const uint64_t R_TILEGX_IMM8_X1_TLS_ADD_LE_MASK
=
1150 (TILEGX_X1_RRR_SRCB_MASK
| (0x3Fllu
<< 37));
1152 const uint64_t R_TILEGX_IMM8_Y0_TLS_ADD_LE_MASK
=
1153 (TILEGX_Y0_RRR_SRCB_MASK
| (0x3Fllu
<< 6));
1155 const uint64_t R_TILEGX_IMM8_Y1_TLS_ADD_LE_MASK
=
1156 (TILEGX_Y1_RRR_SRCB_MASK
| (0x3Fllu
<< 37));
1158 typedef typename
elfcpp::Swap
<64, big_endian
>::Valtype Valtype
;
1159 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
1160 Valtype val
= elfcpp::Swap
<64, big_endian
>::readval(wv
);
1165 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
1166 if (opt_t
== tls::TLSOPT_NONE
) {
1167 // GD/IE: 1. copy dest operand into the second source operand
1168 // 2. change the opcode to "add"
1169 reloc
= (val
& 0x3Fllu
) << 12; // featch the dest reg
1170 reloc
|= ((size
== 32
1171 ? TILEGX_X_ADDX_R0_R0_TP
1172 : TILEGX_X_ADD_R0_R0_TP
)
1173 & TILEGX_X0_RRR_MASK
); // change opcode
1174 val
&= ~R_TILEGX_IMM8_X0_TLS_ADD_MASK
;
1175 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1176 // LE: 1. copy dest operand into the first source operand
1177 // 2. change the opcode to "move"
1178 reloc
= (val
& 0x3Fllu
) << 6;
1179 reloc
|= (TILEGX_X_MOVE_R0_R0
& TILEGX_X0_RRR_SRCB_MASK
);
1180 val
&= ~R_TILEGX_IMM8_X0_TLS_ADD_LE_MASK
;
1184 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
1185 if (opt_t
== tls::TLSOPT_NONE
) {
1186 reloc
= (val
& (0x3Fllu
<< 31)) << 12;
1187 reloc
|= ((size
== 32
1188 ? TILEGX_X_ADDX_R0_R0_TP
1189 : TILEGX_X_ADD_R0_R0_TP
)
1190 & TILEGX_X1_RRR_MASK
);
1191 val
&= ~R_TILEGX_IMM8_X1_TLS_ADD_MASK
;
1192 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1193 reloc
= (val
& (0x3Fllu
<< 31)) << 6;
1194 reloc
|= (TILEGX_X_MOVE_R0_R0
& TILEGX_X1_RRR_SRCB_MASK
);
1195 val
&= ~R_TILEGX_IMM8_X1_TLS_ADD_LE_MASK
;
1199 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
1200 if (opt_t
== tls::TLSOPT_NONE
) {
1201 reloc
= (val
& 0x3Fllu
) << 12;
1202 reloc
|= ((size
== 32
1203 ? TILEGX_Y_ADDX_R0_R0_TP
1204 : TILEGX_Y_ADD_R0_R0_TP
)
1205 & TILEGX_Y0_RRR_MASK
);
1206 val
&= ~R_TILEGX_IMM8_Y0_TLS_ADD_MASK
;
1207 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1208 reloc
= (val
& 0x3Fllu
) << 6;
1209 reloc
|= (TILEGX_Y_MOVE_R0_R0
& TILEGX_Y0_RRR_SRCB_MASK
);
1210 val
&= ~R_TILEGX_IMM8_Y0_TLS_ADD_LE_MASK
;
1214 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
1215 if (opt_t
== tls::TLSOPT_NONE
) {
1216 reloc
= (val
& (0x3Fllu
<< 31)) << 12;
1217 reloc
|= ((size
== 32
1218 ? TILEGX_Y_ADDX_R0_R0_TP
1219 : TILEGX_Y_ADD_R0_R0_TP
)
1220 & TILEGX_Y1_RRR_MASK
);
1221 val
&= ~R_TILEGX_IMM8_Y1_TLS_ADD_MASK
;
1222 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1223 reloc
= (val
& (0x3Fllu
<< 31)) << 6;
1224 reloc
|= (TILEGX_Y_MOVE_R0_R0
& TILEGX_Y1_RRR_SRCB_MASK
);
1225 val
&= ~R_TILEGX_IMM8_Y1_TLS_ADD_LE_MASK
;
1229 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
1230 if (opt_t
== tls::TLSOPT_NONE
) {
1231 // GD see comments for optimize_tls_reloc
1232 reloc
= TILEGX_X_MOVE_R0_R0
& TILEGX_X0_RRR_SRCB_MASK
;
1233 val
&= ~TILEGX_X0_RRR_SRCB_MASK
;
1234 } else if (opt_t
== tls::TLSOPT_TO_IE
1235 || opt_t
== tls::TLSOPT_TO_LE
) {
1238 ? TILEGX_X_ADDX_R0_R0_TP
1239 : TILEGX_X_ADD_R0_R0_TP
)
1240 & TILEGX_X0_RRR_SRCB_MASK
;
1241 val
&= ~TILEGX_X0_RRR_SRCB_MASK
;
1244 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
1245 if (opt_t
== tls::TLSOPT_NONE
) {
1246 reloc
= TILEGX_X_MOVE_R0_R0
& TILEGX_X1_RRR_SRCB_MASK
;
1247 val
&= ~TILEGX_X1_RRR_SRCB_MASK
;
1248 } else if (opt_t
== tls::TLSOPT_TO_IE
1249 || opt_t
== tls::TLSOPT_TO_LE
) {
1251 ? TILEGX_X_ADDX_R0_R0_TP
1252 : TILEGX_X_ADD_R0_R0_TP
)
1253 & TILEGX_X1_RRR_SRCB_MASK
;
1254 val
&= ~TILEGX_X1_RRR_SRCB_MASK
;
1257 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
1258 if (opt_t
== tls::TLSOPT_NONE
) {
1259 reloc
= TILEGX_Y_MOVE_R0_R0
& TILEGX_Y0_RRR_SRCB_MASK
;
1260 val
&= ~TILEGX_Y0_RRR_SRCB_MASK
;
1261 } else if (opt_t
== tls::TLSOPT_TO_IE
1262 || opt_t
== tls::TLSOPT_TO_LE
) {
1264 ? TILEGX_Y_ADDX_R0_R0_TP
1265 : TILEGX_Y_ADD_R0_R0_TP
)
1266 & TILEGX_Y0_RRR_SRCB_MASK
;
1267 val
&= ~TILEGX_Y0_RRR_SRCB_MASK
;
1270 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
1271 if (opt_t
== tls::TLSOPT_NONE
) {
1272 reloc
= TILEGX_Y_MOVE_R0_R0
& TILEGX_Y1_RRR_SRCB_MASK
;
1273 val
&= ~TILEGX_Y1_RRR_SRCB_MASK
;
1274 } else if (opt_t
== tls::TLSOPT_TO_IE
1275 || opt_t
== tls::TLSOPT_TO_LE
) {
1277 ? TILEGX_Y_ADDX_R0_R0_TP
1278 : TILEGX_Y_ADD_R0_R0_TP
)
1279 & TILEGX_Y1_RRR_SRCB_MASK
;
1280 val
&= ~TILEGX_Y1_RRR_SRCB_MASK
;
1283 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
1284 if (opt_t
== tls::TLSOPT_NONE
) {
1289 & TILEGX_X1_RRR_SRCB_MASK
;
1290 val
&= ~TILEGX_X1_RRR_SRCB_MASK
;
1291 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1293 reloc
= TILEGX_X_MOVE_R0_R0
& TILEGX_X1_RRR_SRCB_MASK
;
1294 val
&= ~TILEGX_X1_RRR_SRCB_MASK
;
1298 case elfcpp::R_TILEGX_TLS_GD_CALL
:
1299 if (opt_t
== tls::TLSOPT_TO_IE
) {
1303 : TILEGX_X_LD
) & TILEGX_X1_FULL_MASK
;
1304 val
&= ~TILEGX_X1_FULL_MASK
;
1305 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1307 reloc
= TILEGX_X_MOVE_R0_R0
& TILEGX_X1_FULL_MASK
;
1308 val
&= ~TILEGX_X1_FULL_MASK
;
1310 // should be handled in ::relocate
1317 elfcpp::Swap
<64, big_endian
>::writeval(wv
, val
| reloc
);
1322 const Tilegx_relocate_functions
<64, false>::Tilegx_howto
1323 Tilegx_relocate_functions
<64, false>::howto
[elfcpp::R_TILEGX_NUM
] =
1325 { 0, 0, 0, 0, 0}, // R_TILEGX_NONE
1326 { 0, 0, 0, 64, 0}, // R_TILEGX_64
1327 { 0, 0, 0, 32, 0}, // R_TILEGX_32
1328 { 0, 0, 0, 16, 0}, // R_TILEGX_16
1329 { 0, 0, 0, 8, 0}, // R_TILEGX_8
1330 { 0, 0, 1, 64, 0}, // R_TILEGX_64_PCREL
1331 { 0, 0, 1, 32, 0}, // R_TILEGX_32_PCREL
1332 { 0, 0, 1, 16, 0}, // R_TILEGX_16_PCREL
1333 { 0, 0, 1, 8, 0}, // R_TILEGX_8_PCREL
1334 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0
1335 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1
1336 { 32, 0, 0, 0, 0}, // R_TILEGX_HW2
1337 { 48, 0, 0, 0, 0}, // R_TILEGX_HW3
1338 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0_LAST
1339 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1_LAST
1340 { 32, 0, 0, 0, 0}, // R_TILEGX_HW2_LAST
1341 { 0, 0, 0, 0, 0}, // R_TILEGX_COPY
1342 { 0, 0, 0, 8, 0}, // R_TILEGX_GLOB_DAT
1343 { 0, 0, 0, 0, 0}, // R_TILEGX_JMP_SLOT
1344 { 0, 0, 0, 0, 0}, // R_TILEGX_RELATIVE
1345 { 3, 1, 1, 0, 0}, // R_TILEGX_BROFF_X1
1346 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1
1347 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1_PLT
1348 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X0
1349 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y0
1350 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X1
1351 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y1
1352 { 0, 1, 0, 8, 0}, // R_TILEGX_DEST_IMM8_X1
1353 { 0, 1, 0, 8, 0}, // R_TILEGX_MT_IMM14_X1
1354 { 0, 1, 0, 8, 0}, // R_TILEGX_MF_IMM14_X1
1355 { 0, 1, 0, 8, 0}, // R_TILEGX_MMSTART_X0
1356 { 0, 1, 0, 8, 0}, // R_TILEGX_MMEND_X0
1357 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X0
1358 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X1
1359 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y0
1360 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y1
1361 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0
1362 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0
1363 { 16, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW1
1364 { 16, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW1
1365 { 32, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW2
1366 { 32, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW2
1367 { 48, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW3
1368 { 48, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW3
1369 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST
1370 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST
1371 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST
1372 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST
1373 { 32, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST
1374 { 32, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST
1375 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PCREL
1376 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PCREL
1377 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PCREL
1378 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PCREL
1379 { 32, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PCREL
1380 { 32, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PCREL
1381 { 48, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW3_PCREL
1382 { 48, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW3_PCREL
1383 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PCREL
1384 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PCREL
1385 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PCREL
1386 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PCREL
1387 { 32, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PCREL
1388 { 32, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PCREL
1389 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_GOT
1390 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_GOT
1391 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PLT_PCREL
1392 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PLT_PCREL
1393 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PLT_PCREL
1394 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PLT_PCREL
1395 { 32, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PLT_PCREL
1396 { 32, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PLT_PCREL
1397 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_GOT
1398 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_GOT
1399 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_GOT
1400 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_GOT
1401 { 32, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_GOT
1402 { 32, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_GOT
1403 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_GD
1404 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_GD
1405 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_LE
1406 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_LE
1407 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
1408 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
1409 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
1410 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
1411 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
1412 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
1413 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
1414 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
1415 { 0, 0, 0, 0, 0}, // R_TILEGX_IRELATIVE
1416 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1417 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_IE
1418 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_IE
1419 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
1420 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
1421 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
1422 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
1423 { 32, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
1424 { 32, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
1425 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
1426 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
1427 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
1428 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
1429 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1430 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1431 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD64
1432 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF64
1433 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF64
1434 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD32
1435 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF32
1436 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF32
1437 { 3, 31, 1, 27, 0}, // R_TILEGX_TLS_GD_CALL
1438 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_GD_ADD
1439 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_GD_ADD
1440 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_GD_ADD
1441 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_GD_ADD
1442 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_IE_LOAD
1443 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_ADD
1444 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_ADD
1445 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_ADD
1446 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_ADD
1447 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTINHERIT
1448 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTENTRY
1452 const Tilegx_relocate_functions
<32, false>::Tilegx_howto
1453 Tilegx_relocate_functions
<32, false>::howto
[elfcpp::R_TILEGX_NUM
] =
1455 { 0, 0, 0, 0, 0}, // R_TILEGX_NONE
1456 { 0, 0, 0, 64, 0}, // R_TILEGX_64
1457 { 0, 0, 0, 32, 0}, // R_TILEGX_32
1458 { 0, 0, 0, 16, 0}, // R_TILEGX_16
1459 { 0, 0, 0, 8, 0}, // R_TILEGX_8
1460 { 0, 0, 1, 64, 0}, // R_TILEGX_64_PCREL
1461 { 0, 0, 1, 32, 0}, // R_TILEGX_32_PCREL
1462 { 0, 0, 1, 16, 0}, // R_TILEGX_16_PCREL
1463 { 0, 0, 1, 8, 0}, // R_TILEGX_8_PCREL
1464 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0
1465 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1
1466 { 31, 0, 0, 0, 0}, // R_TILEGX_HW2
1467 { 31, 0, 0, 0, 0}, // R_TILEGX_HW3
1468 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0_LAST
1469 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1_LAST
1470 { 31, 0, 0, 0, 0}, // R_TILEGX_HW2_LAST
1471 { 0, 0, 0, 0, 0}, // R_TILEGX_COPY
1472 { 0, 0, 0, 8, 0}, // R_TILEGX_GLOB_DAT
1473 { 0, 0, 0, 0, 0}, // R_TILEGX_JMP_SLOT
1474 { 0, 0, 0, 0, 0}, // R_TILEGX_RELATIVE
1475 { 3, 1, 1, 0, 0}, // R_TILEGX_BROFF_X1
1476 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1
1477 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1_PLT
1478 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X0
1479 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y0
1480 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X1
1481 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y1
1482 { 0, 1, 0, 8, 0}, // R_TILEGX_DEST_IMM8_X1
1483 { 0, 1, 0, 8, 0}, // R_TILEGX_MT_IMM14_X1
1484 { 0, 1, 0, 8, 0}, // R_TILEGX_MF_IMM14_X1
1485 { 0, 1, 0, 8, 0}, // R_TILEGX_MMSTART_X0
1486 { 0, 1, 0, 8, 0}, // R_TILEGX_MMEND_X0
1487 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X0
1488 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X1
1489 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y0
1490 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y1
1491 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0
1492 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0
1493 { 16, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW1
1494 { 16, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW1
1495 { 31, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW2
1496 { 31, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW2
1497 { 31, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW3
1498 { 31, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW3
1499 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST
1500 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST
1501 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST
1502 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST
1503 { 31, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST
1504 { 31, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST
1505 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PCREL
1506 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PCREL
1507 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PCREL
1508 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PCREL
1509 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PCREL
1510 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PCREL
1511 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW3_PCREL
1512 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW3_PCREL
1513 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PCREL
1514 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PCREL
1515 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PCREL
1516 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PCREL
1517 { 31, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PCREL
1518 { 31, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PCREL
1519 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_GOT
1520 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_GOT
1521 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PLT_PCREL
1522 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PLT_PCREL
1523 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PLT_PCREL
1524 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PLT_PCREL
1525 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PLT_PCREL
1526 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PLT_PCREL
1527 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_GOT
1528 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_GOT
1529 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_GOT
1530 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_GOT
1531 { 31, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_GOT
1532 { 31, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_GOT
1533 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_GD
1534 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_GD
1535 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_LE
1536 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_LE
1537 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
1538 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
1539 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
1540 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
1541 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
1542 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
1543 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
1544 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
1545 { 0, 0, 0, 0, 0}, // R_TILEGX_IRELATIVE
1546 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1547 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_IE
1548 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_IE
1549 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
1550 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
1551 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
1552 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
1553 { 31, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
1554 { 31, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
1555 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
1556 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
1557 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
1558 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
1559 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1560 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1561 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD64
1562 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF64
1563 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF64
1564 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD32
1565 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF32
1566 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF32
1567 { 3, 31, 1, 27, 0}, // R_TILEGX_TLS_GD_CALL
1568 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_GD_ADD
1569 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_GD_ADD
1570 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_GD_ADD
1571 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_GD_ADD
1572 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_IE_LOAD
1573 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_ADD
1574 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_ADD
1575 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_ADD
1576 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_ADD
1577 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTINHERIT
1578 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTENTRY
1582 const Tilegx_relocate_functions
<64, true>::Tilegx_howto
1583 Tilegx_relocate_functions
<64, true>::howto
[elfcpp::R_TILEGX_NUM
] =
1585 { 0, 0, 0, 0, 0}, // R_TILEGX_NONE
1586 { 0, 0, 0, 64, 0}, // R_TILEGX_64
1587 { 0, 0, 0, 32, 0}, // R_TILEGX_32
1588 { 0, 0, 0, 16, 0}, // R_TILEGX_16
1589 { 0, 0, 0, 8, 0}, // R_TILEGX_8
1590 { 0, 0, 1, 64, 0}, // R_TILEGX_64_PCREL
1591 { 0, 0, 1, 32, 0}, // R_TILEGX_32_PCREL
1592 { 0, 0, 1, 16, 0}, // R_TILEGX_16_PCREL
1593 { 0, 0, 1, 8, 0}, // R_TILEGX_8_PCREL
1594 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0
1595 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1
1596 { 32, 0, 0, 0, 0}, // R_TILEGX_HW2
1597 { 48, 0, 0, 0, 0}, // R_TILEGX_HW3
1598 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0_LAST
1599 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1_LAST
1600 { 32, 0, 0, 0, 0}, // R_TILEGX_HW2_LAST
1601 { 0, 0, 0, 0, 0}, // R_TILEGX_COPY
1602 { 0, 0, 0, 8, 0}, // R_TILEGX_GLOB_DAT
1603 { 0, 0, 0, 0, 0}, // R_TILEGX_JMP_SLOT
1604 { 0, 0, 0, 0, 0}, // R_TILEGX_RELATIVE
1605 { 3, 1, 1, 0, 0}, // R_TILEGX_BROFF_X1
1606 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1
1607 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1_PLT
1608 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X0
1609 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y0
1610 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X1
1611 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y1
1612 { 0, 1, 0, 8, 0}, // R_TILEGX_DEST_IMM8_X1
1613 { 0, 1, 0, 8, 0}, // R_TILEGX_MT_IMM14_X1
1614 { 0, 1, 0, 8, 0}, // R_TILEGX_MF_IMM14_X1
1615 { 0, 1, 0, 8, 0}, // R_TILEGX_MMSTART_X0
1616 { 0, 1, 0, 8, 0}, // R_TILEGX_MMEND_X0
1617 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X0
1618 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X1
1619 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y0
1620 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y1
1621 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0
1622 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0
1623 { 16, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW1
1624 { 16, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW1
1625 { 32, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW2
1626 { 32, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW2
1627 { 48, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW3
1628 { 48, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW3
1629 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST
1630 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST
1631 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST
1632 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST
1633 { 32, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST
1634 { 32, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST
1635 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PCREL
1636 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PCREL
1637 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PCREL
1638 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PCREL
1639 { 32, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PCREL
1640 { 32, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PCREL
1641 { 48, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW3_PCREL
1642 { 48, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW3_PCREL
1643 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PCREL
1644 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PCREL
1645 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PCREL
1646 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PCREL
1647 { 32, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PCREL
1648 { 32, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PCREL
1649 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_GOT
1650 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_GOT
1651 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PLT_PCREL
1652 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PLT_PCREL
1653 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PLT_PCREL
1654 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PLT_PCREL
1655 { 32, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PLT_PCREL
1656 { 32, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PLT_PCREL
1657 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_GOT
1658 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_GOT
1659 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_GOT
1660 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_GOT
1661 { 32, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_GOT
1662 { 32, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_GOT
1663 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_GD
1664 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_GD
1665 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_LE
1666 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_LE
1667 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
1668 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
1669 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
1670 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
1671 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
1672 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
1673 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
1674 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
1675 { 0, 0, 0, 0, 0}, // R_TILEGX_IRELATIVE
1676 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1677 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_IE
1678 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_IE
1679 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
1680 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
1681 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
1682 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
1683 { 32, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
1684 { 32, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
1685 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
1686 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
1687 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
1688 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
1689 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1690 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1691 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD64
1692 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF64
1693 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF64
1694 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD32
1695 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF32
1696 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF32
1697 { 3, 31, 1, 27, 0}, // R_TILEGX_TLS_GD_CALL
1698 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_GD_ADD
1699 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_GD_ADD
1700 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_GD_ADD
1701 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_GD_ADD
1702 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_IE_LOAD
1703 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_ADD
1704 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_ADD
1705 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_ADD
1706 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_ADD
1707 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTINHERIT
1708 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTENTRY
1712 const Tilegx_relocate_functions
<32, true>::Tilegx_howto
1713 Tilegx_relocate_functions
<32, true>::howto
[elfcpp::R_TILEGX_NUM
] =
1715 { 0, 0, 0, 0, 0}, // R_TILEGX_NONE
1716 { 0, 0, 0, 64, 0}, // R_TILEGX_64
1717 { 0, 0, 0, 32, 0}, // R_TILEGX_32
1718 { 0, 0, 0, 16, 0}, // R_TILEGX_16
1719 { 0, 0, 0, 8, 0}, // R_TILEGX_8
1720 { 0, 0, 1, 64, 0}, // R_TILEGX_64_PCREL
1721 { 0, 0, 1, 32, 0}, // R_TILEGX_32_PCREL
1722 { 0, 0, 1, 16, 0}, // R_TILEGX_16_PCREL
1723 { 0, 0, 1, 8, 0}, // R_TILEGX_8_PCREL
1724 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0
1725 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1
1726 { 31, 0, 0, 0, 0}, // R_TILEGX_HW2
1727 { 31, 0, 0, 0, 0}, // R_TILEGX_HW3
1728 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0_LAST
1729 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1_LAST
1730 { 31, 0, 0, 0, 0}, // R_TILEGX_HW2_LAST
1731 { 0, 0, 0, 0, 0}, // R_TILEGX_COPY
1732 { 0, 0, 0, 8, 0}, // R_TILEGX_GLOB_DAT
1733 { 0, 0, 0, 0, 0}, // R_TILEGX_JMP_SLOT
1734 { 0, 0, 0, 0, 0}, // R_TILEGX_RELATIVE
1735 { 3, 1, 1, 0, 0}, // R_TILEGX_BROFF_X1
1736 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1
1737 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1_PLT
1738 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X0
1739 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y0
1740 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X1
1741 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y1
1742 { 0, 1, 0, 8, 0}, // R_TILEGX_DEST_IMM8_X1
1743 { 0, 1, 0, 8, 0}, // R_TILEGX_MT_IMM14_X1
1744 { 0, 1, 0, 8, 0}, // R_TILEGX_MF_IMM14_X1
1745 { 0, 1, 0, 8, 0}, // R_TILEGX_MMSTART_X0
1746 { 0, 1, 0, 8, 0}, // R_TILEGX_MMEND_X0
1747 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X0
1748 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X1
1749 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y0
1750 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y1
1751 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0
1752 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0
1753 { 16, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW1
1754 { 16, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW1
1755 { 31, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW2
1756 { 31, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW2
1757 { 31, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW3
1758 { 31, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW3
1759 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST
1760 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST
1761 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST
1762 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST
1763 { 31, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST
1764 { 31, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST
1765 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PCREL
1766 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PCREL
1767 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PCREL
1768 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PCREL
1769 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PCREL
1770 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PCREL
1771 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW3_PCREL
1772 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW3_PCREL
1773 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PCREL
1774 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PCREL
1775 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PCREL
1776 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PCREL
1777 { 31, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PCREL
1778 { 31, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PCREL
1779 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_GOT
1780 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_GOT
1781 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PLT_PCREL
1782 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PLT_PCREL
1783 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PLT_PCREL
1784 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PLT_PCREL
1785 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PLT_PCREL
1786 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PLT_PCREL
1787 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_GOT
1788 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_GOT
1789 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_GOT
1790 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_GOT
1791 { 31, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_GOT
1792 { 31, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_GOT
1793 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_GD
1794 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_GD
1795 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_LE
1796 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_LE
1797 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
1798 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
1799 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
1800 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
1801 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
1802 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
1803 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
1804 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
1805 { 0, 0, 0, 0, 0}, // R_TILEGX_IRELATIVE
1806 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1807 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_IE
1808 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_IE
1809 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
1810 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
1811 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
1812 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
1813 { 31, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
1814 { 31, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
1815 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
1816 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
1817 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
1818 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
1819 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1820 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1821 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD64
1822 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF64
1823 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF64
1824 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD32
1825 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF32
1826 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF32
1827 { 3, 31, 1, 27, 0}, // R_TILEGX_TLS_GD_CALL
1828 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_GD_ADD
1829 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_GD_ADD
1830 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_GD_ADD
1831 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_GD_ADD
1832 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_IE_LOAD
1833 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_ADD
1834 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_ADD
1835 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_ADD
1836 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_ADD
1837 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTINHERIT
1838 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTENTRY
1841 // Get the GOT section, creating it if necessary.
1843 template<int size
, bool big_endian
>
1844 Output_data_got
<size
, big_endian
>*
1845 Target_tilegx
<size
, big_endian
>::got_section(Symbol_table
* symtab
,
1848 if (this->got_
== NULL
)
1850 gold_assert(symtab
!= NULL
&& layout
!= NULL
);
1852 // When using -z now, we can treat .got.plt as a relro section.
1853 // Without -z now, it is modified after program startup by lazy
1855 bool is_got_plt_relro
= parameters
->options().now();
1856 Output_section_order got_order
= (is_got_plt_relro
1858 : ORDER_RELRO_LAST
);
1859 Output_section_order got_plt_order
= (is_got_plt_relro
1861 : ORDER_NON_RELRO_FIRST
);
1863 this->got_
= new Output_data_got
<size
, big_endian
>();
1865 layout
->add_output_section_data(".got", elfcpp::SHT_PROGBITS
,
1867 | elfcpp::SHF_WRITE
),
1868 this->got_
, got_order
, true);
1870 // Define _GLOBAL_OFFSET_TABLE_ at the start of the PLT.
1871 this->global_offset_table_
=
1872 symtab
->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL
,
1873 Symbol_table::PREDEFINED
,
1875 0, 0, elfcpp::STT_OBJECT
,
1877 elfcpp::STV_HIDDEN
, 0,
1880 if (parameters
->options().shared()) {
1881 // we need to keep the address of .dynamic section in the
1882 // first got entry for .so
1883 this->tilegx_dynamic_
=
1884 symtab
->define_in_output_data("_TILEGX_DYNAMIC_", NULL
,
1885 Symbol_table::PREDEFINED
,
1886 layout
->dynamic_section(),
1887 0, 0, elfcpp::STT_OBJECT
,
1889 elfcpp::STV_HIDDEN
, 0,
1892 this->got_
->add_global(this->tilegx_dynamic_
, GOT_TYPE_STANDARD
);
1894 // for executable, just set the first entry to zero.
1895 this->got_
->set_current_data_size(size
/ 8);
1897 this->got_plt_
= new Output_data_space(size
/ 8, "** GOT PLT");
1898 layout
->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS
,
1900 | elfcpp::SHF_WRITE
),
1901 this->got_plt_
, got_plt_order
,
1904 // The first two entries are reserved.
1905 this->got_plt_
->set_current_data_size
1906 (TILEGX_GOTPLT_RESERVE_COUNT
* (size
/ 8));
1908 if (!is_got_plt_relro
)
1910 // Those bytes can go into the relro segment.
1911 layout
->increase_relro(size
/ 8);
1915 // If there are any IRELATIVE relocations, they get GOT entries
1916 // in .got.plt after the jump slot entries.
1917 this->got_irelative_
1918 = new Output_data_space(size
/ 8, "** GOT IRELATIVE PLT");
1919 layout
->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS
,
1921 | elfcpp::SHF_WRITE
),
1922 this->got_irelative_
,
1923 got_plt_order
, is_got_plt_relro
);
1929 // Get the dynamic reloc section, creating it if necessary.
1931 template<int size
, bool big_endian
>
1932 typename Target_tilegx
<size
, big_endian
>::Reloc_section
*
1933 Target_tilegx
<size
, big_endian
>::rela_dyn_section(Layout
* layout
)
1935 if (this->rela_dyn_
== NULL
)
1937 gold_assert(layout
!= NULL
);
1938 this->rela_dyn_
= new Reloc_section(parameters
->options().combreloc());
1939 layout
->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA
,
1940 elfcpp::SHF_ALLOC
, this->rela_dyn_
,
1941 ORDER_DYNAMIC_RELOCS
, false);
1943 return this->rela_dyn_
;
1946 // Get the section to use for IRELATIVE relocs, creating it if
1947 // necessary. These go in .rela.dyn, but only after all other dynamic
1948 // relocations. They need to follow the other dynamic relocations so
1949 // that they can refer to global variables initialized by those
1952 template<int size
, bool big_endian
>
1953 typename Target_tilegx
<size
, big_endian
>::Reloc_section
*
1954 Target_tilegx
<size
, big_endian
>::rela_irelative_section(Layout
* layout
)
1956 if (this->rela_irelative_
== NULL
)
1958 // Make sure we have already created the dynamic reloc section.
1959 this->rela_dyn_section(layout
);
1960 this->rela_irelative_
= new Reloc_section(false);
1961 layout
->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA
,
1962 elfcpp::SHF_ALLOC
, this->rela_irelative_
,
1963 ORDER_DYNAMIC_RELOCS
, false);
1964 gold_assert(this->rela_dyn_
->output_section()
1965 == this->rela_irelative_
->output_section());
1967 return this->rela_irelative_
;
1970 // Initialize the PLT section.
1972 template<int size
, bool big_endian
>
1974 Output_data_plt_tilegx
<size
, big_endian
>::init(Layout
* layout
)
1976 this->rel_
= new Reloc_section(false);
1977 layout
->add_output_section_data(".rela.plt", elfcpp::SHT_RELA
,
1978 elfcpp::SHF_ALLOC
, this->rel_
,
1979 ORDER_DYNAMIC_PLT_RELOCS
, false);
1982 template<int size
, bool big_endian
>
1984 Output_data_plt_tilegx
<size
, big_endian
>::do_adjust_output_section(
1987 os
->set_entsize(this->get_plt_entry_size());
1990 // Add an entry to the PLT.
1992 template<int size
, bool big_endian
>
1994 Output_data_plt_tilegx
<size
, big_endian
>::add_entry(Symbol_table
* symtab
,
1995 Layout
* layout
, Symbol
* gsym
)
1997 gold_assert(!gsym
->has_plt_offset());
1999 unsigned int plt_index
;
2001 section_offset_type got_offset
;
2003 unsigned int* pcount
;
2004 unsigned int reserved
;
2005 Output_data_space
* got
;
2006 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
2007 && gsym
->can_use_relative_reloc(false))
2009 pcount
= &this->irelative_count_
;
2011 got
= this->got_irelative_
;
2015 pcount
= &this->count_
;
2016 reserved
= TILEGX_GOTPLT_RESERVE_COUNT
;
2017 got
= this->got_plt_
;
2020 if (!this->is_data_size_valid())
2022 plt_index
= *pcount
;
2024 // TILEGX .plt section layout
2034 // TILEGX .got.plt section layout
2041 // entries for normal function
2045 // entries for ifunc
2049 if (got
== this->got_irelative_
)
2050 plt_offset
= plt_index
* this->get_plt_entry_size();
2052 plt_offset
= (plt_index
+ 1) * this->get_plt_entry_size();
2056 got_offset
= (plt_index
+ reserved
) * (size
/ 8);
2057 gold_assert(got_offset
== got
->current_data_size());
2059 // Every PLT entry needs a GOT entry which points back to the PLT
2060 // entry (this will be changed by the dynamic linker, normally
2061 // lazily when the function is called).
2062 got
->set_current_data_size(got_offset
+ size
/ 8);
2066 // FIXME: This is probably not correct for IRELATIVE relocs.
2068 // For incremental updates, find an available slot.
2069 plt_offset
= this->free_list_
.allocate(this->get_plt_entry_size(),
2070 this->get_plt_entry_size(), 0);
2071 if (plt_offset
== -1)
2072 gold_fallback(_("out of patch space (PLT);"
2073 " relink with --incremental-full"));
2075 // The GOT and PLT entries have a 1-1 correspondance, so the GOT offset
2076 // can be calculated from the PLT index, adjusting for the three
2077 // reserved entries at the beginning of the GOT.
2078 plt_index
= plt_offset
/ this->get_plt_entry_size() - 1;
2079 got_offset
= (plt_index
+ reserved
) * (size
/ 8);
2082 gsym
->set_plt_offset(plt_offset
);
2084 // Every PLT entry needs a reloc.
2085 this->add_relocation(symtab
, layout
, gsym
, got_offset
);
2087 // Note that we don't need to save the symbol. The contents of the
2088 // PLT are independent of which symbols are used. The symbols only
2089 // appear in the relocations.
2092 // Add an entry to the PLT for a local STT_GNU_IFUNC symbol. Return
2095 template<int size
, bool big_endian
>
2097 Output_data_plt_tilegx
<size
, big_endian
>::add_local_ifunc_entry(
2098 Symbol_table
* symtab
,
2100 Sized_relobj_file
<size
, big_endian
>* relobj
,
2101 unsigned int local_sym_index
)
2103 unsigned int plt_offset
=
2104 this->irelative_count_
* this->get_plt_entry_size();
2105 ++this->irelative_count_
;
2107 section_offset_type got_offset
= this->got_irelative_
->current_data_size();
2109 // Every PLT entry needs a GOT entry which points back to the PLT
2111 this->got_irelative_
->set_current_data_size(got_offset
+ size
/ 8);
2113 // Every PLT entry needs a reloc.
2114 Reloc_section
* rela
= this->rela_irelative(symtab
, layout
);
2115 rela
->add_symbolless_local_addend(relobj
, local_sym_index
,
2116 elfcpp::R_TILEGX_IRELATIVE
,
2117 this->got_irelative_
, got_offset
, 0);
2122 // Add the relocation for a PLT entry.
2124 template<int size
, bool big_endian
>
2126 Output_data_plt_tilegx
<size
, big_endian
>::add_relocation(Symbol_table
* symtab
,
2129 unsigned int got_offset
)
2131 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
2132 && gsym
->can_use_relative_reloc(false))
2134 Reloc_section
* rela
= this->rela_irelative(symtab
, layout
);
2135 rela
->add_symbolless_global_addend(gsym
, elfcpp::R_TILEGX_IRELATIVE
,
2136 this->got_irelative_
, got_offset
, 0);
2140 gsym
->set_needs_dynsym_entry();
2141 this->rel_
->add_global(gsym
, elfcpp::R_TILEGX_JMP_SLOT
, this->got_plt_
,
2146 // Return where the IRELATIVE relocations should go in the PLT. These
2147 // follow the JUMP_SLOT and the TLSDESC relocations.
2149 template<int size
, bool big_endian
>
2150 typename Output_data_plt_tilegx
<size
, big_endian
>::Reloc_section
*
2151 Output_data_plt_tilegx
<size
, big_endian
>::rela_irelative(Symbol_table
* symtab
,
2154 if (this->irelative_rel_
== NULL
)
2156 // case we see any later on.
2157 this->irelative_rel_
= new Reloc_section(false);
2158 layout
->add_output_section_data(".rela.plt", elfcpp::SHT_RELA
,
2159 elfcpp::SHF_ALLOC
, this->irelative_rel_
,
2160 ORDER_DYNAMIC_PLT_RELOCS
, false);
2161 gold_assert(this->irelative_rel_
->output_section()
2162 == this->rel_
->output_section());
2164 if (parameters
->doing_static_link())
2166 // A statically linked executable will only have a .rela.plt
2167 // section to hold R_TILEGX_IRELATIVE relocs for
2168 // STT_GNU_IFUNC symbols. The library will use these
2169 // symbols to locate the IRELATIVE relocs at program startup
2171 symtab
->define_in_output_data("__rela_iplt_start", NULL
,
2172 Symbol_table::PREDEFINED
,
2173 this->irelative_rel_
, 0, 0,
2174 elfcpp::STT_NOTYPE
, elfcpp::STB_GLOBAL
,
2175 elfcpp::STV_HIDDEN
, 0, false, true);
2176 symtab
->define_in_output_data("__rela_iplt_end", NULL
,
2177 Symbol_table::PREDEFINED
,
2178 this->irelative_rel_
, 0, 0,
2179 elfcpp::STT_NOTYPE
, elfcpp::STB_GLOBAL
,
2180 elfcpp::STV_HIDDEN
, 0, true, true);
2183 return this->irelative_rel_
;
2186 // Return the PLT address to use for a global symbol.
2188 template<int size
, bool big_endian
>
2190 Output_data_plt_tilegx
<size
, big_endian
>::address_for_global(
2193 uint64_t offset
= 0;
2194 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
2195 && gsym
->can_use_relative_reloc(false))
2196 offset
= (this->count_
+ 1) * this->get_plt_entry_size();
2197 return this->address() + offset
+ gsym
->plt_offset();
2200 // Return the PLT address to use for a local symbol. These are always
2201 // IRELATIVE relocs.
2203 template<int size
, bool big_endian
>
2205 Output_data_plt_tilegx
<size
, big_endian
>::address_for_local(
2206 const Relobj
* object
,
2209 return (this->address()
2210 + (this->count_
+ 1) * this->get_plt_entry_size()
2211 + object
->local_plt_offset(r_sym
));
2214 // Set the final size.
2215 template<int size
, bool big_endian
>
2217 Output_data_plt_tilegx
<size
, big_endian
>::set_final_data_size()
2219 unsigned int count
= this->count_
+ this->irelative_count_
;
2220 this->set_data_size((count
+ 1) * this->get_plt_entry_size());
2223 // The first entry in the PLT for an executable.
2226 Output_data_plt_tilegx
<64, false>::first_plt_entry
[plt_entry_size
] =
2228 0x00, 0x30, 0x48, 0x51,
2229 0x6e, 0x43, 0xa0, 0x18, // { ld_add r28, r27, 8 }
2230 0x00, 0x30, 0xbc, 0x35,
2231 0x00, 0x40, 0xde, 0x9e, // { ld r27, r27 }
2232 0xff, 0xaf, 0x30, 0x40,
2233 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2235 0x00, 0x00, 0x00, 0x00,
2236 0x00, 0x00, 0x00, 0x00,
2237 0x00, 0x00, 0x00, 0x00,
2238 0x00, 0x00, 0x00, 0x00
2243 Output_data_plt_tilegx
<32, false>::first_plt_entry
[plt_entry_size
] =
2245 0x00, 0x30, 0x48, 0x51,
2246 0x6e, 0x23, 0x58, 0x18, // { ld4s_add r28, r27, 4 }
2247 0x00, 0x30, 0xbc, 0x35,
2248 0x00, 0x40, 0xde, 0x9c, // { ld4s r27, r27 }
2249 0xff, 0xaf, 0x30, 0x40,
2250 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2252 0x00, 0x00, 0x00, 0x00,
2253 0x00, 0x00, 0x00, 0x00,
2254 0x00, 0x00, 0x00, 0x00,
2255 0x00, 0x00, 0x00, 0x00
2260 Output_data_plt_tilegx
<64, true>::first_plt_entry
[plt_entry_size
] =
2262 0x00, 0x30, 0x48, 0x51,
2263 0x6e, 0x43, 0xa0, 0x18, // { ld_add r28, r27, 8 }
2264 0x00, 0x30, 0xbc, 0x35,
2265 0x00, 0x40, 0xde, 0x9e, // { ld r27, r27 }
2266 0xff, 0xaf, 0x30, 0x40,
2267 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2269 0x00, 0x00, 0x00, 0x00,
2270 0x00, 0x00, 0x00, 0x00,
2271 0x00, 0x00, 0x00, 0x00,
2272 0x00, 0x00, 0x00, 0x00
2277 Output_data_plt_tilegx
<32, true>::first_plt_entry
[plt_entry_size
] =
2279 0x00, 0x30, 0x48, 0x51,
2280 0x6e, 0x23, 0x58, 0x18, // { ld4s_add r28, r27, 4 }
2281 0x00, 0x30, 0xbc, 0x35,
2282 0x00, 0x40, 0xde, 0x9c, // { ld4s r27, r27 }
2283 0xff, 0xaf, 0x30, 0x40,
2284 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2286 0x00, 0x00, 0x00, 0x00,
2287 0x00, 0x00, 0x00, 0x00,
2288 0x00, 0x00, 0x00, 0x00,
2289 0x00, 0x00, 0x00, 0x00
2292 template<int size
, bool big_endian
>
2294 Output_data_plt_tilegx
<size
, big_endian
>::fill_first_plt_entry(
2297 memcpy(pov
, first_plt_entry
, plt_entry_size
);
2300 // Subsequent entries in the PLT for an executable.
2304 Output_data_plt_tilegx
<64, false>::plt_entry
[plt_entry_size
] =
2306 0xdc, 0x0f, 0x00, 0x10,
2307 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2308 0xdb, 0x0f, 0x00, 0x10,
2309 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2310 0x9c, 0xc6, 0x0d, 0xd0,
2311 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2312 0x9b, 0xb6, 0xc5, 0xad,
2313 0xff, 0x57, 0xe0, 0x8e, // { add r27, r26, r27 ; info 10 ; ld r28, r28 }
2314 0xdd, 0x0f, 0x00, 0x70,
2315 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2321 Output_data_plt_tilegx
<32, false>::plt_entry
[plt_entry_size
] =
2323 0xdc, 0x0f, 0x00, 0x10,
2324 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2325 0xdb, 0x0f, 0x00, 0x10,
2326 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2327 0x9c, 0xc6, 0x0d, 0xd0,
2328 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2329 0x9b, 0xb6, 0xc5, 0xad,
2330 0xff, 0x57, 0xe0, 0x8c, // { add r27, r26, r27 ; info 10 ; ld4s r28, r28 }
2331 0xdd, 0x0f, 0x00, 0x70,
2332 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2337 Output_data_plt_tilegx
<64, true>::plt_entry
[plt_entry_size
] =
2339 0xdc, 0x0f, 0x00, 0x10,
2340 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2341 0xdb, 0x0f, 0x00, 0x10,
2342 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2343 0x9c, 0xc6, 0x0d, 0xd0,
2344 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2345 0x9b, 0xb6, 0xc5, 0xad,
2346 0xff, 0x57, 0xe0, 0x8e, // { add r27, r26, r27 ; info 10 ; ld r28, r28 }
2347 0xdd, 0x0f, 0x00, 0x70,
2348 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2354 Output_data_plt_tilegx
<32, true>::plt_entry
[plt_entry_size
] =
2356 0xdc, 0x0f, 0x00, 0x10,
2357 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2358 0xdb, 0x0f, 0x00, 0x10,
2359 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2360 0x9c, 0xc6, 0x0d, 0xd0,
2361 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2362 0x9b, 0xb6, 0xc5, 0xad,
2363 0xff, 0x57, 0xe0, 0x8c, // { add r27, r26, r27 ; info 10 ; ld4s r28, r28 }
2364 0xdd, 0x0f, 0x00, 0x70,
2365 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2368 template<int size
, bool big_endian
>
2370 Output_data_plt_tilegx
<size
, big_endian
>::fill_plt_entry(
2372 typename
elfcpp::Elf_types
<size
>::Elf_Addr gotplt_base
,
2373 unsigned int got_offset
,
2374 typename
elfcpp::Elf_types
<size
>::Elf_Addr plt_base
,
2375 unsigned int plt_offset
, unsigned int plt_index
)
2378 const uint32_t TILEGX_IMM16_MASK
= 0xFFFF;
2379 const uint32_t TILEGX_X0_IMM16_BITOFF
= 12;
2380 const uint32_t TILEGX_X1_IMM16_BITOFF
= 43;
2382 typedef typename
elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::Valtype
2384 memcpy(pov
, plt_entry
, plt_entry_size
);
2386 // first bundle in plt stub - x0
2387 Valtype
* wv
= reinterpret_cast<Valtype
*>(pov
);
2388 Valtype val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2390 ((gotplt_base
+ got_offset
) - (plt_base
+ plt_offset
+ 8)) >> 16;
2391 elfcpp::Elf_Xword dst_mask
=
2392 (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X0_IMM16_BITOFF
;
2394 reloc
&= TILEGX_IMM16_MASK
;
2395 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2396 val
| (reloc
<<TILEGX_X0_IMM16_BITOFF
));
2398 // second bundle in plt stub - x1
2399 wv
= reinterpret_cast<Valtype
*>(pov
+ 8);
2400 val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2401 reloc
= (gotplt_base
+ got_offset
) - (plt_base
+ plt_offset
+ 8);
2402 dst_mask
= (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X1_IMM16_BITOFF
;
2404 reloc
&= TILEGX_IMM16_MASK
;
2405 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2406 val
| (reloc
<<TILEGX_X1_IMM16_BITOFF
));
2408 // second bundle in plt stub - x0
2409 wv
= reinterpret_cast<Valtype
*>(pov
+ 8);
2410 val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2411 reloc
= (gotplt_base
- (plt_base
+ plt_offset
+ 8)) >> 16;
2412 dst_mask
= (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X0_IMM16_BITOFF
;
2414 reloc
&= TILEGX_IMM16_MASK
;
2415 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2416 val
| (reloc
<<TILEGX_X0_IMM16_BITOFF
));
2418 // third bundle in plt stub - x1
2419 wv
= reinterpret_cast<Valtype
*>(pov
+ 16);
2420 val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2421 reloc
= gotplt_base
- (plt_base
+ plt_offset
+ 8);
2422 dst_mask
= (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X1_IMM16_BITOFF
;
2424 reloc
&= TILEGX_IMM16_MASK
;
2425 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2426 val
| (reloc
<<TILEGX_X1_IMM16_BITOFF
));
2428 // fifth bundle in plt stub - carry plt_index x0
2429 wv
= reinterpret_cast<Valtype
*>(pov
+ 32);
2430 val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2431 dst_mask
= (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X0_IMM16_BITOFF
;
2433 plt_index
&= TILEGX_IMM16_MASK
;
2434 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2435 val
| (plt_index
<<TILEGX_X0_IMM16_BITOFF
));
2439 // Write out the PLT. This uses the hand-coded instructions above.
2441 template<int size
, bool big_endian
>
2443 Output_data_plt_tilegx
<size
, big_endian
>::do_write(Output_file
* of
)
2445 const off_t offset
= this->offset();
2446 const section_size_type oview_size
=
2447 convert_to_section_size_type(this->data_size());
2448 unsigned char* const oview
= of
->get_output_view(offset
, oview_size
);
2450 const off_t got_file_offset
= this->got_plt_
->offset();
2451 gold_assert(parameters
->incremental_update()
2452 || (got_file_offset
+ this->got_plt_
->data_size()
2453 == this->got_irelative_
->offset()));
2454 const section_size_type got_size
=
2455 convert_to_section_size_type(this->got_plt_
->data_size()
2456 + this->got_irelative_
->data_size());
2457 unsigned char* const got_view
= of
->get_output_view(got_file_offset
,
2460 unsigned char* pov
= oview
;
2462 // The base address of the .plt section.
2463 typename
elfcpp::Elf_types
<size
>::Elf_Addr plt_address
= this->address();
2464 typename
elfcpp::Elf_types
<size
>::Elf_Addr got_address
=
2465 this->got_plt_
->address();
2467 this->fill_first_plt_entry(pov
);
2468 pov
+= this->get_plt_entry_size();
2470 unsigned char* got_pov
= got_view
;
2472 // first entry of .got.plt are set to -1
2473 // second entry of .got.plt are set to 0
2474 memset(got_pov
, 0xff, size
/ 8);
2475 got_pov
+= size
/ 8;
2476 memset(got_pov
, 0x0, size
/ 8);
2477 got_pov
+= size
/ 8;
2479 unsigned int plt_offset
= this->get_plt_entry_size();
2480 const unsigned int count
= this->count_
+ this->irelative_count_
;
2481 unsigned int got_offset
= (size
/ 8) * TILEGX_GOTPLT_RESERVE_COUNT
;
2482 for (unsigned int plt_index
= 0;
2485 pov
+= this->get_plt_entry_size(),
2486 got_pov
+= size
/ 8,
2487 plt_offset
+= this->get_plt_entry_size(),
2488 got_offset
+= size
/ 8)
2490 // Set and adjust the PLT entry itself.
2491 this->fill_plt_entry(pov
, got_address
, got_offset
,
2492 plt_address
, plt_offset
, plt_index
);
2494 // Initialize entry in .got.plt to plt start address
2495 elfcpp::Swap
<size
, big_endian
>::writeval(got_pov
, plt_address
);
2498 gold_assert(static_cast<section_size_type
>(pov
- oview
) == oview_size
);
2499 gold_assert(static_cast<section_size_type
>(got_pov
- got_view
) == got_size
);
2501 of
->write_output_view(offset
, oview_size
, oview
);
2502 of
->write_output_view(got_file_offset
, got_size
, got_view
);
2505 // Create the PLT section.
2507 template<int size
, bool big_endian
>
2509 Target_tilegx
<size
, big_endian
>::make_plt_section(Symbol_table
* symtab
,
2512 if (this->plt_
== NULL
)
2514 // Create the GOT sections first.
2515 this->got_section(symtab
, layout
);
2517 // Ensure that .rela.dyn always appears before .rela.plt,
2518 // becuase on TILE-Gx, .rela.dyn needs to include .rela.plt
2520 this->rela_dyn_section(layout
);
2522 this->plt_
= new Output_data_plt_tilegx
<size
, big_endian
>(layout
,
2523 TILEGX_INST_BUNDLE_SIZE
, this->got_
, this->got_plt_
,
2524 this->got_irelative_
);
2526 layout
->add_output_section_data(".plt", elfcpp::SHT_PROGBITS
,
2528 | elfcpp::SHF_EXECINSTR
),
2529 this->plt_
, ORDER_NON_RELRO_FIRST
,
2532 // Make the sh_info field of .rela.plt point to .plt.
2533 Output_section
* rela_plt_os
= this->plt_
->rela_plt()->output_section();
2534 rela_plt_os
->set_info_section(this->plt_
->output_section());
2538 // Create a PLT entry for a global symbol.
2540 template<int size
, bool big_endian
>
2542 Target_tilegx
<size
, big_endian
>::make_plt_entry(Symbol_table
* symtab
,
2543 Layout
* layout
, Symbol
* gsym
)
2545 if (gsym
->has_plt_offset())
2548 if (this->plt_
== NULL
)
2549 this->make_plt_section(symtab
, layout
);
2551 this->plt_
->add_entry(symtab
, layout
, gsym
);
2554 // Make a PLT entry for a local STT_GNU_IFUNC symbol.
2556 template<int size
, bool big_endian
>
2558 Target_tilegx
<size
, big_endian
>::make_local_ifunc_plt_entry(
2559 Symbol_table
* symtab
, Layout
* layout
,
2560 Sized_relobj_file
<size
, big_endian
>* relobj
,
2561 unsigned int local_sym_index
)
2563 if (relobj
->local_has_plt_offset(local_sym_index
))
2565 if (this->plt_
== NULL
)
2566 this->make_plt_section(symtab
, layout
);
2567 unsigned int plt_offset
= this->plt_
->add_local_ifunc_entry(symtab
, layout
,
2570 relobj
->set_local_plt_offset(local_sym_index
, plt_offset
);
2573 // Return the number of entries in the PLT.
2575 template<int size
, bool big_endian
>
2577 Target_tilegx
<size
, big_endian
>::plt_entry_count() const
2579 if (this->plt_
== NULL
)
2581 return this->plt_
->entry_count();
2584 // Return the offset of the first non-reserved PLT entry.
2586 template<int size
, bool big_endian
>
2588 Target_tilegx
<size
, big_endian
>::first_plt_entry_offset() const
2590 return this->plt_
->first_plt_entry_offset();
2593 // Return the size of each PLT entry.
2595 template<int size
, bool big_endian
>
2597 Target_tilegx
<size
, big_endian
>::plt_entry_size() const
2599 return this->plt_
->get_plt_entry_size();
2602 // Create the GOT and PLT sections for an incremental update.
2604 template<int size
, bool big_endian
>
2605 Output_data_got_base
*
2606 Target_tilegx
<size
, big_endian
>::init_got_plt_for_update(Symbol_table
* symtab
,
2608 unsigned int got_count
,
2609 unsigned int plt_count
)
2611 gold_assert(this->got_
== NULL
);
2614 new Output_data_got
<size
, big_endian
>((got_count
2615 + TILEGX_GOT_RESERVE_COUNT
)
2617 layout
->add_output_section_data(".got", elfcpp::SHT_PROGBITS
,
2619 | elfcpp::SHF_WRITE
),
2620 this->got_
, ORDER_RELRO_LAST
,
2623 // Define _GLOBAL_OFFSET_TABLE_ at the start of the GOT.
2624 this->global_offset_table_
=
2625 symtab
->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL
,
2626 Symbol_table::PREDEFINED
,
2628 0, 0, elfcpp::STT_OBJECT
,
2630 elfcpp::STV_HIDDEN
, 0,
2633 if (parameters
->options().shared()) {
2634 this->tilegx_dynamic_
=
2635 symtab
->define_in_output_data("_TILEGX_DYNAMIC_", NULL
,
2636 Symbol_table::PREDEFINED
,
2637 layout
->dynamic_section(),
2638 0, 0, elfcpp::STT_OBJECT
,
2640 elfcpp::STV_HIDDEN
, 0,
2643 this->got_
->add_global(this->tilegx_dynamic_
, GOT_TYPE_STANDARD
);
2645 this->got_
->set_current_data_size(size
/ 8);
2647 // Add the two reserved entries.
2649 = new Output_data_space((plt_count
+ TILEGX_GOTPLT_RESERVE_COUNT
)
2650 * (size
/ 8), size
/ 8, "** GOT PLT");
2651 layout
->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS
,
2653 | elfcpp::SHF_WRITE
),
2654 this->got_plt_
, ORDER_NON_RELRO_FIRST
,
2657 // If there are any IRELATIVE relocations, they get GOT entries in
2658 // .got.plt after the jump slot.
2659 this->got_irelative_
2660 = new Output_data_space(0, size
/ 8, "** GOT IRELATIVE PLT");
2661 layout
->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS
,
2662 elfcpp::SHF_ALLOC
| elfcpp::SHF_WRITE
,
2663 this->got_irelative_
,
2664 ORDER_NON_RELRO_FIRST
, false);
2666 // Create the PLT section.
2667 this->plt_
= new Output_data_plt_tilegx
<size
, big_endian
>(layout
,
2668 this->plt_entry_size(), this->got_
, this->got_plt_
, this->got_irelative_
,
2671 layout
->add_output_section_data(".plt", elfcpp::SHT_PROGBITS
,
2672 elfcpp::SHF_ALLOC
| elfcpp::SHF_EXECINSTR
,
2673 this->plt_
, ORDER_PLT
, false);
2675 // Make the sh_info field of .rela.plt point to .plt.
2676 Output_section
* rela_plt_os
= this->plt_
->rela_plt()->output_section();
2677 rela_plt_os
->set_info_section(this->plt_
->output_section());
2679 // Create the rela_dyn section.
2680 this->rela_dyn_section(layout
);
2685 // Reserve a GOT entry for a local symbol, and regenerate any
2686 // necessary dynamic relocations.
2688 template<int size
, bool big_endian
>
2690 Target_tilegx
<size
, big_endian
>::reserve_local_got_entry(
2691 unsigned int got_index
,
2692 Sized_relobj
<size
, big_endian
>* obj
,
2694 unsigned int got_type
)
2696 unsigned int got_offset
= (got_index
+ TILEGX_GOT_RESERVE_COUNT
)
2698 Reloc_section
* rela_dyn
= this->rela_dyn_section(NULL
);
2700 this->got_
->reserve_local(got_index
, obj
, r_sym
, got_type
);
2703 case GOT_TYPE_STANDARD
:
2704 if (parameters
->options().output_is_position_independent())
2705 rela_dyn
->add_local_relative(obj
, r_sym
, elfcpp::R_TILEGX_RELATIVE
,
2706 this->got_
, got_offset
, 0, false);
2708 case GOT_TYPE_TLS_OFFSET
:
2709 rela_dyn
->add_local(obj
, r_sym
,
2710 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPOFF32
2711 : elfcpp::R_TILEGX_TLS_DTPOFF64
,
2712 this->got_
, got_offset
, 0);
2714 case GOT_TYPE_TLS_PAIR
:
2715 this->got_
->reserve_slot(got_index
+ 1);
2716 rela_dyn
->add_local(obj
, r_sym
,
2717 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPMOD32
2718 : elfcpp::R_TILEGX_TLS_DTPMOD64
,
2719 this->got_
, got_offset
, 0);
2721 case GOT_TYPE_TLS_DESC
:
2722 gold_fatal(_("TLS_DESC not yet supported for incremental linking"));
2729 // Reserve a GOT entry for a global symbol, and regenerate any
2730 // necessary dynamic relocations.
2732 template<int size
, bool big_endian
>
2734 Target_tilegx
<size
, big_endian
>::reserve_global_got_entry(
2735 unsigned int got_index
, Symbol
* gsym
, unsigned int got_type
)
2737 unsigned int got_offset
= (got_index
+ TILEGX_GOT_RESERVE_COUNT
)
2739 Reloc_section
* rela_dyn
= this->rela_dyn_section(NULL
);
2741 this->got_
->reserve_global(got_index
, gsym
, got_type
);
2744 case GOT_TYPE_STANDARD
:
2745 if (!gsym
->final_value_is_known())
2747 if (gsym
->is_from_dynobj()
2748 || gsym
->is_undefined()
2749 || gsym
->is_preemptible()
2750 || gsym
->type() == elfcpp::STT_GNU_IFUNC
)
2751 rela_dyn
->add_global(gsym
, elfcpp::R_TILEGX_GLOB_DAT
,
2752 this->got_
, got_offset
, 0);
2754 rela_dyn
->add_global_relative(gsym
, elfcpp::R_TILEGX_RELATIVE
,
2755 this->got_
, got_offset
, 0, false);
2758 case GOT_TYPE_TLS_OFFSET
:
2759 rela_dyn
->add_global_relative(gsym
,
2760 size
== 32 ? elfcpp::R_TILEGX_TLS_TPOFF32
2761 : elfcpp::R_TILEGX_TLS_TPOFF64
,
2762 this->got_
, got_offset
, 0, false);
2764 case GOT_TYPE_TLS_PAIR
:
2765 this->got_
->reserve_slot(got_index
+ 1);
2766 rela_dyn
->add_global_relative(gsym
,
2767 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPMOD32
2768 : elfcpp::R_TILEGX_TLS_DTPMOD64
,
2769 this->got_
, got_offset
, 0, false);
2770 rela_dyn
->add_global_relative(gsym
,
2771 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPOFF32
2772 : elfcpp::R_TILEGX_TLS_DTPOFF64
,
2773 this->got_
, got_offset
+ size
/ 8,
2776 case GOT_TYPE_TLS_DESC
:
2777 gold_fatal(_("TLS_DESC not yet supported for TILEGX"));
2784 // Register an existing PLT entry for a global symbol.
2786 template<int size
, bool big_endian
>
2788 Target_tilegx
<size
, big_endian
>::register_global_plt_entry(
2789 Symbol_table
* symtab
, Layout
* layout
, unsigned int plt_index
, Symbol
* gsym
)
2791 gold_assert(this->plt_
!= NULL
);
2792 gold_assert(!gsym
->has_plt_offset());
2794 this->plt_
->reserve_slot(plt_index
);
2796 gsym
->set_plt_offset((plt_index
+ 1) * this->plt_entry_size());
2798 unsigned int got_offset
= (plt_index
+ 2) * (size
/ 8);
2799 this->plt_
->add_relocation(symtab
, layout
, gsym
, got_offset
);
2802 // Force a COPY relocation for a given symbol.
2804 template<int size
, bool big_endian
>
2806 Target_tilegx
<size
, big_endian
>::emit_copy_reloc(
2807 Symbol_table
* symtab
, Symbol
* sym
, Output_section
* os
, off_t offset
)
2809 this->copy_relocs_
.emit_copy_reloc(symtab
,
2810 symtab
->get_sized_symbol
<size
>(sym
),
2813 this->rela_dyn_section(NULL
));
2816 // Create a GOT entry for the TLS module index.
2818 template<int size
, bool big_endian
>
2820 Target_tilegx
<size
, big_endian
>::got_mod_index_entry(Symbol_table
* symtab
,
2822 Sized_relobj_file
<size
, big_endian
>* object
)
2824 if (this->got_mod_index_offset_
== -1U)
2826 gold_assert(symtab
!= NULL
&& layout
!= NULL
&& object
!= NULL
);
2827 Reloc_section
* rela_dyn
= this->rela_dyn_section(layout
);
2828 Output_data_got
<size
, big_endian
>* got
2829 = this->got_section(symtab
, layout
);
2830 unsigned int got_offset
= got
->add_constant(0);
2831 rela_dyn
->add_local(object
, 0,
2832 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPMOD32
2833 : elfcpp::R_TILEGX_TLS_DTPMOD64
, got
,
2835 got
->add_constant(0);
2836 this->got_mod_index_offset_
= got_offset
;
2838 return this->got_mod_index_offset_
;
2841 // Optimize the TLS relocation type based on what we know about the
2842 // symbol. IS_FINAL is true if the final address of this symbol is
2843 // known at link time.
2845 // the transformation rules is described below:
2847 // compiler GD reference
2850 // moveli tmp, hw1_last_tls_gd(x) X0/X1
2851 // shl16insli r0, tmp, hw0_tls_gd(x) X0/X1
2852 // addi r0, got, tls_add(x) Y0/Y1/X0/X1
2853 // jal tls_gd_call(x) X1
2854 // addi adr, r0, tls_gd_add(x) Y0/Y1/X0/X1
2856 // linker tranformation of GD insn sequence
2860 // moveli tmp, hw1_last_tls_gd(x) X0/X1
2861 // shl16insli r0, tmp, hw0_tls_gd(x) X0/X1
2862 // add r0, got, r0 Y0/Y1/X0/X1
2863 // jal plt(__tls_get_addr) X1
2864 // move adr, r0 Y0/Y1/X0/X1
2866 // moveli tmp, hw1_last_tls_ie(x) X0/X1
2867 // shl16insli r0, tmp, hw0_tls_ie(x) X0/X1
2868 // add r0, got, r0 Y0/Y1/X0/X1
2870 // add adr, r0, tp Y0/Y1/X0/X1
2872 // moveli tmp, hw1_last_tls_le(x) X0/X1
2873 // shl16insli r0, tmp, hw0_tls_le(x) X0/X1
2874 // move r0, r0 Y0/Y1/X0/X1
2875 // move r0, r0 Y0/Y1/X0/X1
2876 // add adr, r0, tp Y0/Y1/X0/X1
2879 // compiler IE reference
2882 // moveli tmp, hw1_last_tls_ie(x) X0/X1
2883 // shl16insli tmp, tmp, hw0_tls_ie(x) X0/X1
2884 // addi tmp, got, tls_add(x) Y0/Y1/X0/X1
2885 // ld_tls tmp, tmp, tls_ie_load(x) X1
2886 // add adr, tmp, tp Y0/Y1/X0/X1
2888 // linker transformation for IE insn sequence
2892 // moveli tmp, hw1_last_tls_ie(x) X0/X1
2893 // shl16insli tmp, tmp, hw0_tls_ie(x) X0/X1
2894 // add tmp, got, tmp Y0/Y1/X0/X1
2896 // add adr, tmp, tp Y0/Y1/X0/X1
2898 // moveli tmp, hw1_last_tls_le(x) X0/X1
2899 // shl16insli tmp, tmp, hw0_tls_le(x) X0/X1
2900 // move tmp, tmp Y0/Y1/X0/X1
2901 // move tmp, tmp Y0/Y1/X0/X1
2904 // compiler LE reference
2907 // moveli tmp, hw1_last_tls_le(x) X0/X1
2908 // shl16insli tmp, tmp, hw0_tls_le(x) X0/X1
2909 // add adr, tmp, tp Y0/Y1/X0/X1
2911 template<int size
, bool big_endian
>
2912 tls::Tls_optimization
2913 Target_tilegx
<size
, big_endian
>::optimize_tls_reloc(bool is_final
, int r_type
)
2915 // If we are generating a shared library, then we can't do anything
2917 if (parameters
->options().shared())
2918 return tls::TLSOPT_NONE
;
2922 // unique GD relocations
2923 case elfcpp::R_TILEGX_TLS_GD_CALL
:
2924 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
2925 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
2926 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
2927 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
2928 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
2929 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
2930 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
2931 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
2932 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
2933 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
2934 // These are General-Dynamic which permits fully general TLS
2935 // access. Since we know that we are generating an executable,
2936 // we can convert this to Initial-Exec. If we also know that
2937 // this is a local symbol, we can further switch to Local-Exec.
2939 return tls::TLSOPT_TO_LE
;
2940 return tls::TLSOPT_TO_IE
;
2942 // unique IE relocations
2943 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
2944 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
2945 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
2946 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
2947 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
2948 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
2949 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
2950 // These are Initial-Exec relocs which get the thread offset
2951 // from the GOT. If we know that we are linking against the
2952 // local symbol, we can switch to Local-Exec, which links the
2953 // thread offset into the instruction.
2955 return tls::TLSOPT_TO_LE
;
2956 return tls::TLSOPT_NONE
;
2958 // could be created for both GD and IE
2959 // but they are expanded into the same
2960 // instruction in GD and IE.
2961 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
2962 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
2963 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
2964 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
2966 return tls::TLSOPT_TO_LE
;
2967 return tls::TLSOPT_NONE
;
2969 // unique LE relocations
2970 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
2971 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
2972 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
2973 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
2974 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
2975 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
2976 // When we already have Local-Exec, there is nothing further we
2978 return tls::TLSOPT_NONE
;
2985 // Get the Reference_flags for a particular relocation.
2987 template<int size
, bool big_endian
>
2989 Target_tilegx
<size
, big_endian
>::Scan::get_reference_flags(unsigned int r_type
)
2993 case elfcpp::R_TILEGX_NONE
:
2994 case elfcpp::R_TILEGX_GNU_VTINHERIT
:
2995 case elfcpp::R_TILEGX_GNU_VTENTRY
:
2996 // No symbol reference.
2999 case elfcpp::R_TILEGX_64
:
3000 case elfcpp::R_TILEGX_32
:
3001 case elfcpp::R_TILEGX_16
:
3002 case elfcpp::R_TILEGX_8
:
3003 return Symbol::ABSOLUTE_REF
;
3005 case elfcpp::R_TILEGX_BROFF_X1
:
3006 case elfcpp::R_TILEGX_64_PCREL
:
3007 case elfcpp::R_TILEGX_32_PCREL
:
3008 case elfcpp::R_TILEGX_16_PCREL
:
3009 case elfcpp::R_TILEGX_8_PCREL
:
3010 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3011 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3012 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3013 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3014 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3015 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3016 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3017 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3018 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3019 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3020 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3021 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3022 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3023 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3024 return Symbol::RELATIVE_REF
;
3026 case elfcpp::R_TILEGX_JUMPOFF_X1
:
3027 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT
:
3028 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL
:
3029 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL
:
3030 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL
:
3031 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL
:
3032 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL
:
3033 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL
:
3034 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
:
3035 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
:
3036 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
:
3037 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
:
3038 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
:
3039 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
:
3040 return Symbol::FUNCTION_CALL
| Symbol::RELATIVE_REF
;
3042 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3043 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3044 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3045 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3046 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3047 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3048 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3049 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3050 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3051 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3052 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3053 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3054 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3055 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3056 return Symbol::ABSOLUTE_REF
;
3058 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
3059 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
3060 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
3061 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
3062 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
3063 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
3065 return Symbol::ABSOLUTE_REF
;
3067 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
3068 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
3069 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
3070 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
3071 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
3072 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
3073 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
3074 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
3075 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
3076 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
3077 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
3078 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
3079 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
3080 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
3081 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
3082 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
3083 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
3084 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
3085 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
3086 case elfcpp::R_TILEGX_TLS_DTPMOD32
:
3087 case elfcpp::R_TILEGX_TLS_DTPOFF32
:
3088 case elfcpp::R_TILEGX_TLS_TPOFF32
:
3089 case elfcpp::R_TILEGX_TLS_GD_CALL
:
3090 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
3091 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
3092 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
3093 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
3094 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
3095 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
3096 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
3097 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
3098 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
3099 return Symbol::TLS_REF
;
3101 case elfcpp::R_TILEGX_COPY
:
3102 case elfcpp::R_TILEGX_GLOB_DAT
:
3103 case elfcpp::R_TILEGX_JMP_SLOT
:
3104 case elfcpp::R_TILEGX_RELATIVE
:
3105 case elfcpp::R_TILEGX_TLS_TPOFF64
:
3106 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
3108 // Not expected. We will give an error later.
3113 // Report an unsupported relocation against a local symbol.
3115 template<int size
, bool big_endian
>
3117 Target_tilegx
<size
, big_endian
>::Scan::unsupported_reloc_local(
3118 Sized_relobj_file
<size
, big_endian
>* object
,
3119 unsigned int r_type
)
3121 gold_error(_("%s: unsupported reloc %u against local symbol"),
3122 object
->name().c_str(), r_type
);
3125 // We are about to emit a dynamic relocation of type R_TYPE. If the
3126 // dynamic linker does not support it, issue an error.
3127 template<int size
, bool big_endian
>
3129 Target_tilegx
<size
, big_endian
>::Scan::check_non_pic(Relobj
* object
,
3130 unsigned int r_type
)
3134 // These are the relocation types supported by glibc for tilegx
3135 // which should always work.
3136 case elfcpp::R_TILEGX_RELATIVE
:
3137 case elfcpp::R_TILEGX_GLOB_DAT
:
3138 case elfcpp::R_TILEGX_JMP_SLOT
:
3139 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
3140 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
3141 case elfcpp::R_TILEGX_TLS_TPOFF64
:
3142 case elfcpp::R_TILEGX_8
:
3143 case elfcpp::R_TILEGX_16
:
3144 case elfcpp::R_TILEGX_32
:
3145 case elfcpp::R_TILEGX_64
:
3146 case elfcpp::R_TILEGX_COPY
:
3147 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3148 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3149 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3150 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3151 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3152 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3153 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3154 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3155 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3156 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3157 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3158 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3159 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3160 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3161 case elfcpp::R_TILEGX_BROFF_X1
:
3162 case elfcpp::R_TILEGX_JUMPOFF_X1
:
3163 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3164 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3165 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3166 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3167 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3168 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3169 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3170 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3171 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3172 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3173 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3174 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3175 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3176 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3180 // This prevents us from issuing more than one error per reloc
3181 // section. But we can still wind up issuing more than one
3182 // error per object file.
3183 if (this->issued_non_pic_error_
)
3185 gold_assert(parameters
->options().output_is_position_independent());
3186 object
->error(_("requires unsupported dynamic reloc %u; "
3187 "recompile with -fPIC"),
3189 this->issued_non_pic_error_
= true;
3192 case elfcpp::R_TILEGX_NONE
:
3197 // Return whether we need to make a PLT entry for a relocation of the
3198 // given type against a STT_GNU_IFUNC symbol.
3200 template<int size
, bool big_endian
>
3202 Target_tilegx
<size
, big_endian
>::Scan::reloc_needs_plt_for_ifunc(
3203 Sized_relobj_file
<size
, big_endian
>* object
, unsigned int r_type
)
3205 int flags
= Scan::get_reference_flags(r_type
);
3206 if (flags
& Symbol::TLS_REF
)
3207 gold_error(_("%s: unsupported TLS reloc %u for IFUNC symbol"),
3208 object
->name().c_str(), r_type
);
3212 // Scan a relocation for a local symbol.
3214 template<int size
, bool big_endian
>
3216 Target_tilegx
<size
, big_endian
>::Scan::local(Symbol_table
* symtab
,
3218 Target_tilegx
<size
, big_endian
>* target
,
3219 Sized_relobj_file
<size
, big_endian
>* object
,
3220 unsigned int data_shndx
,
3221 Output_section
* output_section
,
3222 const elfcpp::Rela
<size
, big_endian
>& reloc
,
3223 unsigned int r_type
,
3224 const elfcpp::Sym
<size
, big_endian
>& lsym
,
3230 // A local STT_GNU_IFUNC symbol may require a PLT entry.
3231 bool is_ifunc
= lsym
.get_st_type() == elfcpp::STT_GNU_IFUNC
;
3232 if (is_ifunc
&& this->reloc_needs_plt_for_ifunc(object
, r_type
))
3234 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3235 target
->make_local_ifunc_plt_entry(symtab
, layout
, object
, r_sym
);
3240 case elfcpp::R_TILEGX_NONE
:
3241 case elfcpp::R_TILEGX_GNU_VTINHERIT
:
3242 case elfcpp::R_TILEGX_GNU_VTENTRY
:
3245 // If building a shared library (or a position-independent
3246 // executable), because the runtime address needs plus
3247 // the module base address, so generate a R_TILEGX_RELATIVE.
3248 case elfcpp::R_TILEGX_32
:
3249 case elfcpp::R_TILEGX_64
:
3250 if (parameters
->options().output_is_position_independent())
3252 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3253 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3254 rela_dyn
->add_local_relative(object
, r_sym
,
3255 elfcpp::R_TILEGX_RELATIVE
,
3256 output_section
, data_shndx
,
3257 reloc
.get_r_offset(),
3258 reloc
.get_r_addend(), is_ifunc
);
3262 // If building a shared library (or a position-independent
3263 // executable), we need to create a dynamic relocation for this
3265 case elfcpp::R_TILEGX_8
:
3266 case elfcpp::R_TILEGX_16
:
3267 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3268 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3269 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3270 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3271 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3272 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3273 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3274 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3275 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3276 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3277 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3278 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3279 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3280 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3281 if (parameters
->options().output_is_position_independent())
3283 this->check_non_pic(object
, r_type
);
3285 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3286 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3287 if (lsym
.get_st_type() != elfcpp::STT_SECTION
)
3288 rela_dyn
->add_local(object
, r_sym
, r_type
, output_section
,
3289 data_shndx
, reloc
.get_r_offset(),
3290 reloc
.get_r_addend());
3293 gold_assert(lsym
.get_st_value() == 0);
3294 rela_dyn
->add_symbolless_local_addend(object
, r_sym
, r_type
,
3297 reloc
.get_r_offset(),
3298 reloc
.get_r_addend());
3304 // R_TILEGX_JUMPOFF_X1_PLT against local symbol
3305 // may happen for ifunc case.
3306 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT
:
3307 case elfcpp::R_TILEGX_JUMPOFF_X1
:
3308 case elfcpp::R_TILEGX_64_PCREL
:
3309 case elfcpp::R_TILEGX_32_PCREL
:
3310 case elfcpp::R_TILEGX_16_PCREL
:
3311 case elfcpp::R_TILEGX_8_PCREL
:
3312 case elfcpp::R_TILEGX_BROFF_X1
:
3313 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3314 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3315 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3316 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3317 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3318 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3319 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3320 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3321 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3322 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3323 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3324 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3325 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3326 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3327 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL
:
3328 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL
:
3329 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL
:
3330 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL
:
3331 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL
:
3332 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL
:
3333 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
:
3334 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
:
3335 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
:
3336 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
:
3337 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
:
3338 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
:
3341 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
3342 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
3343 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
3344 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
3345 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
3346 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
3348 // The symbol requires a GOT entry.
3349 Output_data_got
<size
, big_endian
>* got
3350 = target
->got_section(symtab
, layout
);
3351 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3353 // For a STT_GNU_IFUNC symbol we want the PLT offset. That
3354 // lets function pointers compare correctly with shared
3355 // libraries. Otherwise we would need an IRELATIVE reloc.
3358 is_new
= got
->add_local_plt(object
, r_sym
, GOT_TYPE_STANDARD
);
3360 is_new
= got
->add_local(object
, r_sym
, GOT_TYPE_STANDARD
);
3363 // tilegx dynamic linker will not update local got entry,
3364 // so, if we are generating a shared object, we need to add a
3365 // dynamic relocation for this symbol's GOT entry to inform
3366 // dynamic linker plus the load base explictly.
3367 if (parameters
->options().output_is_position_independent())
3369 unsigned int got_offset
3370 = object
->local_got_offset(r_sym
, GOT_TYPE_STANDARD
);
3372 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3373 rela_dyn
->add_local_relative(object
, r_sym
,
3375 got
, got_offset
, 0, is_ifunc
);
3381 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
3382 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
3383 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
3384 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
3385 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
3386 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
3387 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
3388 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
3389 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
3390 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
3391 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
3392 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
3393 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
3394 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
3395 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
3396 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
3397 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
3398 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
3399 case elfcpp::R_TILEGX_TLS_GD_CALL
:
3400 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
3401 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
3402 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
3403 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
3404 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
3405 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
3406 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
3407 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
3408 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
3410 bool output_is_shared
= parameters
->options().shared();
3411 const tls::Tls_optimization opt_t
=
3412 Target_tilegx
<size
, big_endian
>::optimize_tls_reloc(
3413 !output_is_shared
, r_type
);
3417 case elfcpp::R_TILEGX_TLS_GD_CALL
:
3418 // FIXME: predefine __tls_get_addr
3420 // R_TILEGX_TLS_GD_CALL implicitly reference __tls_get_addr,
3421 // while all other target, x86/arm/mips/powerpc/sparc
3422 // generate tls relocation against __tls_get_addr explictly,
3423 // so for TILEGX, we need the following hack.
3424 if (opt_t
== tls::TLSOPT_NONE
) {
3425 if (!target
->tls_get_addr_sym_defined_
) {
3427 options::parse_set(NULL
, "__tls_get_addr",
3428 (gold::options::String_set
*)
3429 ¶meters
->options().undefined());
3430 symtab
->add_undefined_symbols_from_command_line(layout
);
3431 target
->tls_get_addr_sym_defined_
= true;
3432 sym
= symtab
->lookup("__tls_get_addr");
3435 target
->make_plt_entry(symtab
, layout
,
3436 symtab
->lookup("__tls_get_addr"));
3440 // only make effect when applying relocation
3441 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
3442 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
3443 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
3444 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
3445 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
3446 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
3447 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
3448 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
3449 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
3452 // GD: requires two GOT entry for module index and offset
3453 // IE: requires one GOT entry for tp-relative offset
3454 // LE: shouldn't happen for global symbol
3455 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
3456 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
3457 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
3458 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
3459 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
3460 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
3462 if (opt_t
== tls::TLSOPT_NONE
) {
3463 Output_data_got
<size
, big_endian
> *got
3464 = target
->got_section(symtab
, layout
);
3466 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3467 unsigned int shndx
= lsym
.get_st_shndx();
3469 shndx
= object
->adjust_sym_shndx(r_sym
, shndx
,
3472 object
->error(_("local symbol %u has bad shndx %u"),
3475 got
->add_local_pair_with_rel(object
, r_sym
, shndx
,
3477 target
->rela_dyn_section(layout
),
3479 ? elfcpp::R_TILEGX_TLS_DTPMOD32
3480 : elfcpp::R_TILEGX_TLS_DTPMOD64
);
3481 } else if (opt_t
== tls::TLSOPT_TO_IE
) {
3482 Output_data_got
<size
, big_endian
>* got
3483 = target
->got_section(symtab
, layout
);
3484 Reloc_section
* rela_dyn
3485 = target
->rela_dyn_section(layout
);
3487 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3488 unsigned int off
= got
->add_constant(0);
3489 object
->set_local_got_offset(r_sym
,
3490 GOT_TYPE_TLS_OFFSET
,off
);
3491 rela_dyn
->add_symbolless_local_addend(object
, r_sym
,
3493 ? elfcpp::R_TILEGX_TLS_TPOFF32
3494 : elfcpp::R_TILEGX_TLS_TPOFF64
,
3496 } else if (opt_t
!= tls::TLSOPT_TO_LE
)
3497 // only TO_LE is allowed for local symbol
3498 unsupported_reloc_local(object
, r_type
);
3503 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
3504 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
3505 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
3506 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
3507 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
3508 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
3510 layout
->set_has_static_tls();
3511 if (opt_t
== tls::TLSOPT_NONE
) {
3512 Output_data_got
<size
, big_endian
>* got
3513 = target
->got_section(symtab
, layout
);
3514 Reloc_section
* rela_dyn
3515 = target
->rela_dyn_section(layout
);
3517 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3518 unsigned int off
= got
->add_constant(0);
3519 object
->set_local_got_offset(r_sym
,
3520 GOT_TYPE_TLS_OFFSET
, off
);
3521 rela_dyn
->add_symbolless_local_addend(object
, r_sym
,
3523 ? elfcpp::R_TILEGX_TLS_TPOFF32
3524 : elfcpp::R_TILEGX_TLS_TPOFF64
,
3526 } else if (opt_t
!= tls::TLSOPT_TO_LE
)
3527 unsupported_reloc_local(object
, r_type
);
3532 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
3533 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
3534 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
3535 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
3536 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
3537 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
3538 layout
->set_has_static_tls();
3539 if (parameters
->options().shared()) {
3540 // defer to dynamic linker
3541 gold_assert(lsym
.get_st_type() != elfcpp::STT_SECTION
);
3543 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3544 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3545 rela_dyn
->add_symbolless_local_addend(object
, r_sym
, r_type
,
3546 output_section
, data_shndx
,
3547 reloc
.get_r_offset(), 0);
3557 case elfcpp::R_TILEGX_COPY
:
3558 case elfcpp::R_TILEGX_GLOB_DAT
:
3559 case elfcpp::R_TILEGX_JMP_SLOT
:
3560 case elfcpp::R_TILEGX_RELATIVE
:
3561 // These are outstanding tls relocs, which are unexpected when linking
3562 case elfcpp::R_TILEGX_TLS_TPOFF32
:
3563 case elfcpp::R_TILEGX_TLS_TPOFF64
:
3564 case elfcpp::R_TILEGX_TLS_DTPMOD32
:
3565 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
3566 case elfcpp::R_TILEGX_TLS_DTPOFF32
:
3567 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
3568 gold_error(_("%s: unexpected reloc %u in object file"),
3569 object
->name().c_str(), r_type
);
3573 gold_error(_("%s: unsupported reloc %u against local symbol"),
3574 object
->name().c_str(), r_type
);
3580 // Report an unsupported relocation against a global symbol.
3582 template<int size
, bool big_endian
>
3584 Target_tilegx
<size
, big_endian
>::Scan::unsupported_reloc_global(
3585 Sized_relobj_file
<size
, big_endian
>* object
,
3586 unsigned int r_type
,
3589 gold_error(_("%s: unsupported reloc %u against global symbol %s"),
3590 object
->name().c_str(), r_type
, gsym
->demangled_name().c_str());
3593 // Returns true if this relocation type could be that of a function pointer.
3594 template<int size
, bool big_endian
>
3596 Target_tilegx
<size
, big_endian
>::Scan::possible_function_pointer_reloc(
3597 unsigned int r_type
)
3601 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3602 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3603 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3604 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3605 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3606 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3607 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3608 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3609 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3610 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3611 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3612 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3613 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3614 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3615 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3616 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3617 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3618 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3619 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3620 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3621 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3622 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3623 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3624 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3625 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3626 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3627 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3628 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3629 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
3630 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
3631 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
3632 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
3633 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
3634 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
3642 // For safe ICF, scan a relocation for a local symbol to check if it
3643 // corresponds to a function pointer being taken. In that case mark
3644 // the function whose pointer was taken as not foldable.
3646 template<int size
, bool big_endian
>
3648 Target_tilegx
<size
, big_endian
>::Scan::local_reloc_may_be_function_pointer(
3651 Target_tilegx
<size
, big_endian
>* ,
3652 Sized_relobj_file
<size
, big_endian
>* ,
3655 const elfcpp::Rela
<size
, big_endian
>& ,
3656 unsigned int r_type
,
3657 const elfcpp::Sym
<size
, big_endian
>&)
3659 return possible_function_pointer_reloc(r_type
);
3662 // For safe ICF, scan a relocation for a global symbol to check if it
3663 // corresponds to a function pointer being taken. In that case mark
3664 // the function whose pointer was taken as not foldable.
3666 template<int size
, bool big_endian
>
3668 Target_tilegx
<size
, big_endian
>::Scan::global_reloc_may_be_function_pointer(
3671 Target_tilegx
<size
, big_endian
>* ,
3672 Sized_relobj_file
<size
, big_endian
>* ,
3675 const elfcpp::Rela
<size
, big_endian
>& ,
3676 unsigned int r_type
,
3679 // GOT is not a function.
3680 if (strcmp(gsym
->name(), "_GLOBAL_OFFSET_TABLE_") == 0)
3683 // When building a shared library, do not fold symbols whose visibility
3684 // is hidden, internal or protected.
3685 return ((parameters
->options().shared()
3686 && (gsym
->visibility() == elfcpp::STV_INTERNAL
3687 || gsym
->visibility() == elfcpp::STV_PROTECTED
3688 || gsym
->visibility() == elfcpp::STV_HIDDEN
))
3689 || possible_function_pointer_reloc(r_type
));
3692 // Scan a relocation for a global symbol.
3694 template<int size
, bool big_endian
>
3696 Target_tilegx
<size
, big_endian
>::Scan::global(Symbol_table
* symtab
,
3698 Target_tilegx
<size
, big_endian
>* target
,
3699 Sized_relobj_file
<size
, big_endian
>* object
,
3700 unsigned int data_shndx
,
3701 Output_section
* output_section
,
3702 const elfcpp::Rela
<size
, big_endian
>& reloc
,
3703 unsigned int r_type
,
3706 // A reference to _GLOBAL_OFFSET_TABLE_ implies that we need a got
3707 // section. We check here to avoid creating a dynamic reloc against
3708 // _GLOBAL_OFFSET_TABLE_.
3709 if (!target
->has_got_section()
3710 && strcmp(gsym
->name(), "_GLOBAL_OFFSET_TABLE_") == 0)
3711 target
->got_section(symtab
, layout
);
3713 // A STT_GNU_IFUNC symbol may require a PLT entry.
3714 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
3715 && this->reloc_needs_plt_for_ifunc(object
, r_type
))
3716 target
->make_plt_entry(symtab
, layout
, gsym
);
3720 case elfcpp::R_TILEGX_NONE
:
3721 case elfcpp::R_TILEGX_GNU_VTINHERIT
:
3722 case elfcpp::R_TILEGX_GNU_VTENTRY
:
3725 case elfcpp::R_TILEGX_DEST_IMM8_X1
:
3726 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3727 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3728 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3729 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3730 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3731 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3732 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3733 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3734 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3735 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3736 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3737 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3738 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3739 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3740 case elfcpp::R_TILEGX_64
:
3741 case elfcpp::R_TILEGX_32
:
3742 case elfcpp::R_TILEGX_16
:
3743 case elfcpp::R_TILEGX_8
:
3745 // Make a PLT entry if necessary.
3746 if (gsym
->needs_plt_entry())
3748 target
->make_plt_entry(symtab
, layout
, gsym
);
3749 // Since this is not a PC-relative relocation, we may be
3750 // taking the address of a function. In that case we need to
3751 // set the entry in the dynamic symbol table to the address of
3753 if (gsym
->is_from_dynobj() && !parameters
->options().shared())
3754 gsym
->set_needs_dynsym_value();
3756 // Make a dynamic relocation if necessary.
3757 if (gsym
->needs_dynamic_reloc(Scan::get_reference_flags(r_type
)))
3759 if (gsym
->may_need_copy_reloc())
3761 target
->copy_reloc(symtab
, layout
, object
,
3762 data_shndx
, output_section
, gsym
, reloc
);
3764 else if (((size
== 64 && r_type
== elfcpp::R_TILEGX_64
)
3765 || (size
== 32 && r_type
== elfcpp::R_TILEGX_32
))
3766 && gsym
->type() == elfcpp::STT_GNU_IFUNC
3767 && gsym
->can_use_relative_reloc(false)
3768 && !gsym
->is_from_dynobj()
3769 && !gsym
->is_undefined()
3770 && !gsym
->is_preemptible())
3772 // Use an IRELATIVE reloc for a locally defined
3773 // STT_GNU_IFUNC symbol. This makes a function
3774 // address in a PIE executable match the address in a
3775 // shared library that it links against.
3776 Reloc_section
* rela_dyn
=
3777 target
->rela_irelative_section(layout
);
3778 unsigned int r_type
= elfcpp::R_TILEGX_IRELATIVE
;
3779 rela_dyn
->add_symbolless_global_addend(gsym
, r_type
,
3780 output_section
, object
,
3782 reloc
.get_r_offset(),
3783 reloc
.get_r_addend());
3784 } else if ((r_type
== elfcpp::R_TILEGX_64
3785 || r_type
== elfcpp::R_TILEGX_32
)
3786 && gsym
->can_use_relative_reloc(false))
3788 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3789 rela_dyn
->add_global_relative(gsym
, elfcpp::R_TILEGX_RELATIVE
,
3790 output_section
, object
,
3792 reloc
.get_r_offset(),
3793 reloc
.get_r_addend(), false);
3797 this->check_non_pic(object
, r_type
);
3798 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3799 rela_dyn
->add_global(gsym
, r_type
, output_section
, object
,
3800 data_shndx
, reloc
.get_r_offset(),
3801 reloc
.get_r_addend());
3807 case elfcpp::R_TILEGX_BROFF_X1
:
3808 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3809 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3810 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3811 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3812 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3813 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3814 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3815 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3816 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3817 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3818 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3819 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3820 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3821 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3822 case elfcpp::R_TILEGX_64_PCREL
:
3823 case elfcpp::R_TILEGX_32_PCREL
:
3824 case elfcpp::R_TILEGX_16_PCREL
:
3825 case elfcpp::R_TILEGX_8_PCREL
:
3827 // Make a PLT entry if necessary.
3828 if (gsym
->needs_plt_entry())
3829 target
->make_plt_entry(symtab
, layout
, gsym
);
3830 // Make a dynamic relocation if necessary.
3831 if (gsym
->needs_dynamic_reloc(Scan::get_reference_flags(r_type
)))
3833 if (gsym
->may_need_copy_reloc())
3835 target
->copy_reloc(symtab
, layout
, object
,
3836 data_shndx
, output_section
, gsym
, reloc
);
3840 this->check_non_pic(object
, r_type
);
3841 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3842 rela_dyn
->add_global(gsym
, r_type
, output_section
, object
,
3843 data_shndx
, reloc
.get_r_offset(),
3844 reloc
.get_r_addend());
3850 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
3851 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
3852 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
3853 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
3854 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
3855 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
3857 // The symbol requires a GOT entry.
3858 Output_data_got
<size
, big_endian
>* got
3859 = target
->got_section(symtab
, layout
);
3860 if (gsym
->final_value_is_known())
3862 // For a STT_GNU_IFUNC symbol we want the PLT address.
3863 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
)
3864 got
->add_global_plt(gsym
, GOT_TYPE_STANDARD
);
3866 got
->add_global(gsym
, GOT_TYPE_STANDARD
);
3870 // If this symbol is not fully resolved, we need to add a
3871 // dynamic relocation for it.
3872 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3874 // Use a GLOB_DAT rather than a RELATIVE reloc if:
3876 // 1) The symbol may be defined in some other module.
3878 // 2) We are building a shared library and this is a
3879 // protected symbol; using GLOB_DAT means that the dynamic
3880 // linker can use the address of the PLT in the main
3881 // executable when appropriate so that function address
3882 // comparisons work.
3884 // 3) This is a STT_GNU_IFUNC symbol in position dependent
3885 // code, again so that function address comparisons work.
3886 if (gsym
->is_from_dynobj()
3887 || gsym
->is_undefined()
3888 || gsym
->is_preemptible()
3889 || (gsym
->visibility() == elfcpp::STV_PROTECTED
3890 && parameters
->options().shared())
3891 || (gsym
->type() == elfcpp::STT_GNU_IFUNC
3892 && parameters
->options().output_is_position_independent()))
3893 got
->add_global_with_rel(gsym
, GOT_TYPE_STANDARD
, rela_dyn
,
3894 elfcpp::R_TILEGX_GLOB_DAT
);
3897 // For a STT_GNU_IFUNC symbol we want to write the PLT
3898 // offset into the GOT, so that function pointer
3899 // comparisons work correctly.
3901 if (gsym
->type() != elfcpp::STT_GNU_IFUNC
)
3902 is_new
= got
->add_global(gsym
, GOT_TYPE_STANDARD
);
3905 is_new
= got
->add_global_plt(gsym
, GOT_TYPE_STANDARD
);
3906 // Tell the dynamic linker to use the PLT address
3907 // when resolving relocations.
3908 if (gsym
->is_from_dynobj()
3909 && !parameters
->options().shared())
3910 gsym
->set_needs_dynsym_value();
3914 unsigned int got_off
= gsym
->got_offset(GOT_TYPE_STANDARD
);
3915 rela_dyn
->add_global_relative(gsym
,
3917 got
, got_off
, 0, false);
3924 // a minor difference here for R_TILEGX_JUMPOFF_X1
3925 // between bfd linker and gold linker for gold, when
3926 // R_TILEGX_JUMPOFF_X1 against global symbol, we
3927 // turn it into JUMPOFF_X1_PLT, otherwise the distance
3928 // to the symbol function may overflow at runtime.
3929 case elfcpp::R_TILEGX_JUMPOFF_X1
:
3931 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT
:
3932 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL
:
3933 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL
:
3934 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL
:
3935 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL
:
3936 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL
:
3937 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL
:
3938 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
:
3939 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
:
3940 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
:
3941 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
:
3942 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
:
3943 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
:
3944 // If the symbol is fully resolved, this is just a PC32 reloc.
3945 // Otherwise we need a PLT entry.
3946 if (gsym
->final_value_is_known())
3948 // If building a shared library, we can also skip the PLT entry
3949 // if the symbol is defined in the output file and is protected
3951 if (gsym
->is_defined()
3952 && !gsym
->is_from_dynobj()
3953 && !gsym
->is_preemptible())
3955 target
->make_plt_entry(symtab
, layout
, gsym
);
3959 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
3960 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
3961 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
3962 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
3963 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
3964 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
3965 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
3966 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
3967 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
3968 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
3969 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
3970 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
3971 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
3972 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
3973 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
3974 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
3975 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
3976 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
3977 case elfcpp::R_TILEGX_TLS_GD_CALL
:
3978 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
3979 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
3980 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
3981 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
3982 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
3983 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
3984 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
3985 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
3986 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
3988 const bool is_final
= gsym
->final_value_is_known();
3989 const tls::Tls_optimization opt_t
=
3990 Target_tilegx
<size
, big_endian
>::optimize_tls_reloc(is_final
,
3995 // only expand to plt against __tls_get_addr in GD model
3996 case elfcpp::R_TILEGX_TLS_GD_CALL
:
3997 if (opt_t
== tls::TLSOPT_NONE
) {
3998 // FIXME: it's better '__tls_get_addr' referenced explictly
3999 if (!target
->tls_get_addr_sym_defined_
) {
4001 options::parse_set(NULL
, "__tls_get_addr",
4002 (gold::options::String_set
*)
4003 ¶meters
->options().undefined());
4004 symtab
->add_undefined_symbols_from_command_line(layout
);
4005 target
->tls_get_addr_sym_defined_
= true;
4006 sym
= symtab
->lookup("__tls_get_addr");
4009 target
->make_plt_entry(symtab
, layout
,
4010 symtab
->lookup("__tls_get_addr"));
4014 // only make effect when applying relocation
4015 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
4016 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
4017 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
4018 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
4019 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
4020 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
4021 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
4022 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
4023 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
4026 // GD: requires two GOT entry for module index and offset
4027 // IE: requires one GOT entry for tp-relative offset
4028 // LE: shouldn't happen for global symbol
4029 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
4030 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
4031 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
4032 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
4033 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
4034 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
4036 if (opt_t
== tls::TLSOPT_NONE
) {
4037 Output_data_got
<size
, big_endian
>* got
4038 = target
->got_section(symtab
, layout
);
4039 got
->add_global_pair_with_rel(gsym
, GOT_TYPE_TLS_PAIR
,
4040 target
->rela_dyn_section(layout
),
4042 ? elfcpp::R_TILEGX_TLS_DTPMOD32
4043 : elfcpp::R_TILEGX_TLS_DTPMOD64
,
4045 ? elfcpp::R_TILEGX_TLS_DTPOFF32
4046 : elfcpp::R_TILEGX_TLS_DTPOFF64
);
4047 } else if (opt_t
== tls::TLSOPT_TO_IE
) {
4048 // Create a GOT entry for the tp-relative offset.
4049 Output_data_got
<size
, big_endian
>* got
4050 = target
->got_section(symtab
, layout
);
4051 got
->add_global_with_rel(gsym
, GOT_TYPE_TLS_OFFSET
,
4052 target
->rela_dyn_section(layout
),
4054 ? elfcpp::R_TILEGX_TLS_TPOFF32
4055 : elfcpp::R_TILEGX_TLS_TPOFF64
);
4056 } else if (opt_t
!= tls::TLSOPT_TO_LE
)
4057 // exteranl symbol should not be optimized to TO_LE
4058 unsupported_reloc_global(object
, r_type
, gsym
);
4063 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
4064 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
4065 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
4066 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
4067 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
4068 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
4070 layout
->set_has_static_tls();
4071 if (opt_t
== tls::TLSOPT_NONE
) {
4072 // Create a GOT entry for the tp-relative offset.
4073 Output_data_got
<size
, big_endian
>* got
4074 = target
->got_section(symtab
, layout
);
4075 got
->add_global_with_rel(gsym
, GOT_TYPE_TLS_OFFSET
,
4076 target
->rela_dyn_section(layout
),
4078 ? elfcpp::R_TILEGX_TLS_TPOFF32
4079 : elfcpp::R_TILEGX_TLS_TPOFF64
);
4080 } else if (opt_t
!= tls::TLSOPT_TO_LE
)
4081 unsupported_reloc_global(object
, r_type
, gsym
);
4086 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
4087 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
4088 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
4089 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
4090 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
4091 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
4092 layout
->set_has_static_tls();
4093 if (parameters
->options().shared()) {
4094 // defer to dynamic linker
4095 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
4096 rela_dyn
->add_symbolless_global_addend(gsym
, r_type
,
4097 output_section
, object
,
4099 reloc
.get_r_offset(), 0);
4109 // below are outstanding relocs
4110 // should not existed in static linking stage
4111 case elfcpp::R_TILEGX_COPY
:
4112 case elfcpp::R_TILEGX_GLOB_DAT
:
4113 case elfcpp::R_TILEGX_JMP_SLOT
:
4114 case elfcpp::R_TILEGX_RELATIVE
:
4115 case elfcpp::R_TILEGX_TLS_TPOFF32
:
4116 case elfcpp::R_TILEGX_TLS_TPOFF64
:
4117 case elfcpp::R_TILEGX_TLS_DTPMOD32
:
4118 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
4119 case elfcpp::R_TILEGX_TLS_DTPOFF32
:
4120 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
4121 gold_error(_("%s: unexpected reloc %u in object file"),
4122 object
->name().c_str(), r_type
);
4126 gold_error(_("%s: unsupported reloc %u against global symbol %s"),
4127 object
->name().c_str(), r_type
,
4128 gsym
->demangled_name().c_str());
4133 template<int size
, bool big_endian
>
4135 Target_tilegx
<size
, big_endian
>::gc_process_relocs(Symbol_table
* symtab
,
4137 Sized_relobj_file
<size
, big_endian
>* object
,
4138 unsigned int data_shndx
,
4139 unsigned int sh_type
,
4140 const unsigned char* prelocs
,
4142 Output_section
* output_section
,
4143 bool needs_special_offset_handling
,
4144 size_t local_symbol_count
,
4145 const unsigned char* plocal_symbols
)
4147 typedef Target_tilegx
<size
, big_endian
> Tilegx
;
4148 typedef typename Target_tilegx
<size
, big_endian
>::Scan Scan
;
4150 if (sh_type
== elfcpp::SHT_REL
)
4155 gold::gc_process_relocs
<size
, big_endian
,
4156 Tilegx
, elfcpp::SHT_RELA
, Scan
,
4157 typename Target_tilegx
<size
, big_endian
>::Relocatable_size_for_reloc
>(
4166 needs_special_offset_handling
,
4170 // Scan relocations for a section.
4172 template<int size
, bool big_endian
>
4174 Target_tilegx
<size
, big_endian
>::scan_relocs(Symbol_table
* symtab
,
4176 Sized_relobj_file
<size
, big_endian
>* object
,
4177 unsigned int data_shndx
,
4178 unsigned int sh_type
,
4179 const unsigned char* prelocs
,
4181 Output_section
* output_section
,
4182 bool needs_special_offset_handling
,
4183 size_t local_symbol_count
,
4184 const unsigned char* plocal_symbols
)
4186 typedef Target_tilegx
<size
, big_endian
> Tilegx
;
4187 typedef typename Target_tilegx
<size
, big_endian
>::Scan Scan
;
4189 if (sh_type
== elfcpp::SHT_REL
)
4191 gold_error(_("%s: unsupported REL reloc section"),
4192 object
->name().c_str());
4196 gold::scan_relocs
<size
, big_endian
, Tilegx
, elfcpp::SHT_RELA
, Scan
>(
4205 needs_special_offset_handling
,
4210 template<int size
, bool big_endian
>
4212 Target_tilegx
<size
, big_endian
>::do_define_standard_symbols(
4213 Symbol_table
* symtab
,
4216 Output_section
* feedback_section
= layout
->find_output_section(".feedback");
4218 if (feedback_section
!= NULL
)
4220 symtab
->define_in_output_data("__feedback_section_end",
4222 Symbol_table::PREDEFINED
,
4230 true, // offset_is_from_end
4235 // Finalize the sections.
4237 template<int size
, bool big_endian
>
4239 Target_tilegx
<size
, big_endian
>::do_finalize_sections(
4241 const Input_objects
*,
4242 Symbol_table
* symtab
)
4244 const Reloc_section
* rel_plt
= (this->plt_
== NULL
4246 : this->plt_
->rela_plt());
4247 layout
->add_target_dynamic_tags(false, this->got_plt_
, rel_plt
,
4248 this->rela_dyn_
, true, true);
4250 // Emit any relocs we saved in an attempt to avoid generating COPY
4252 if (this->copy_relocs_
.any_saved_relocs())
4253 this->copy_relocs_
.emit(this->rela_dyn_section(layout
));
4255 // Set the size of the _GLOBAL_OFFSET_TABLE_ symbol to the size of
4256 // the .got section.
4257 Symbol
* sym
= this->global_offset_table_
;
4260 uint64_t data_size
= this->got_
->current_data_size();
4261 symtab
->get_sized_symbol
<size
>(sym
)->set_symsize(data_size
);
4263 // If the .got section is more than 0x8000 bytes, we add
4264 // 0x8000 to the value of _GLOBAL_OFFSET_TABLE_, so that 16
4265 // bit relocations have a greater chance of working.
4266 if (data_size
>= 0x8000)
4267 symtab
->get_sized_symbol
<size
>(sym
)->set_value(
4268 symtab
->get_sized_symbol
<size
>(sym
)->value() + 0x8000);
4271 if (parameters
->doing_static_link()
4272 && (this->plt_
== NULL
|| !this->plt_
->has_irelative_section()))
4274 // If linking statically, make sure that the __rela_iplt symbols
4275 // were defined if necessary, even if we didn't create a PLT.
4276 static const Define_symbol_in_segment syms
[] =
4279 "__rela_iplt_start", // name
4280 elfcpp::PT_LOAD
, // segment_type
4281 elfcpp::PF_W
, // segment_flags_set
4282 elfcpp::PF(0), // segment_flags_clear
4285 elfcpp::STT_NOTYPE
, // type
4286 elfcpp::STB_GLOBAL
, // binding
4287 elfcpp::STV_HIDDEN
, // visibility
4289 Symbol::SEGMENT_START
, // offset_from_base
4293 "__rela_iplt_end", // name
4294 elfcpp::PT_LOAD
, // segment_type
4295 elfcpp::PF_W
, // segment_flags_set
4296 elfcpp::PF(0), // segment_flags_clear
4299 elfcpp::STT_NOTYPE
, // type
4300 elfcpp::STB_GLOBAL
, // binding
4301 elfcpp::STV_HIDDEN
, // visibility
4303 Symbol::SEGMENT_START
, // offset_from_base
4308 symtab
->define_symbols(layout
, 2, syms
,
4309 layout
->script_options()->saw_sections_clause());
4313 // Perform a relocation.
4315 template<int size
, bool big_endian
>
4317 Target_tilegx
<size
, big_endian
>::Relocate::relocate(
4318 const Relocate_info
<size
, big_endian
>* relinfo
,
4319 Target_tilegx
<size
, big_endian
>* target
,
4322 const elfcpp::Rela
<size
, big_endian
>& rela
,
4323 unsigned int r_type
,
4324 const Sized_symbol
<size
>* gsym
,
4325 const Symbol_value
<size
>* psymval
,
4326 unsigned char* view
,
4327 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
4330 typedef Tilegx_relocate_functions
<size
, big_endian
> TilegxReloc
;
4331 typename
TilegxReloc::Tilegx_howto r_howto
;
4333 const Sized_relobj_file
<size
, big_endian
>* object
= relinfo
->object
;
4335 // Pick the value to use for symbols defined in the PLT.
4336 Symbol_value
<size
> symval
;
4338 && gsym
->use_plt_offset(Scan::get_reference_flags(r_type
)))
4340 symval
.set_output_value(target
->plt_address_for_global(gsym
));
4343 else if (gsym
== NULL
&& psymval
->is_ifunc_symbol())
4345 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
4346 if (object
->local_has_plt_offset(r_sym
))
4348 symval
.set_output_value(target
->plt_address_for_local(object
, r_sym
));
4353 elfcpp::Elf_Xword addend
= rela
.get_r_addend();
4355 // Get the GOT offset if needed.
4356 // For tilegx, the GOT pointer points to the start of the GOT section.
4357 bool have_got_offset
= false;
4359 int got_base
= target
->got_
!= NULL
4360 ? target
->got_
->current_data_size() >= 0x8000 ? 0x8000 : 0
4362 unsigned int got_type
= GOT_TYPE_STANDARD
;
4363 bool always_apply_relocation
= false;
4366 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
4367 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
4368 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
4369 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
4370 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
4371 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
4374 gold_assert(gsym
->has_got_offset(got_type
));
4375 got_offset
= gsym
->got_offset(got_type
) - got_base
;
4379 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
4380 gold_assert(object
->local_has_got_offset(r_sym
, got_type
));
4382 object
->local_got_offset(r_sym
, got_type
) - got_base
;
4384 have_got_offset
= true;
4391 r_howto
= TilegxReloc::howto
[r_type
];
4394 case elfcpp::R_TILEGX_NONE
:
4395 case elfcpp::R_TILEGX_GNU_VTINHERIT
:
4396 case elfcpp::R_TILEGX_GNU_VTENTRY
:
4399 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
4400 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
4401 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
4402 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
4403 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
4404 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
4405 gold_assert(have_got_offset
);
4406 symval
.set_output_value(got_offset
);
4408 always_apply_relocation
= true;
4411 // when under PIC mode, these relocations are deferred to rtld
4412 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
4413 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
4414 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
4415 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
4416 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
4417 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
4418 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
4419 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
4420 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
4421 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
4422 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
4423 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
4424 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
4425 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
4426 if (always_apply_relocation
4427 || !parameters
->options().output_is_position_independent())
4428 TilegxReloc::imm_x_general(view
, object
, psymval
, addend
, r_howto
);
4431 case elfcpp::R_TILEGX_JUMPOFF_X1
:
4432 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT
:
4433 gold_assert(gsym
== NULL
4434 || gsym
->has_plt_offset()
4435 || gsym
->final_value_is_known()
4436 || (gsym
->is_defined()
4437 && !gsym
->is_from_dynobj()
4438 && !gsym
->is_preemptible()));
4439 TilegxReloc::imm_x_pcrel_general(view
, object
, psymval
, addend
,
4444 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL
:
4445 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
4446 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL
:
4447 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
4448 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL
:
4449 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
4450 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL
:
4451 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
4452 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL
:
4453 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
4454 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL
:
4455 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
4456 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
4457 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
4458 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
:
4459 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
4460 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
:
4461 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
4462 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
:
4463 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
4464 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
:
4465 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
4466 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
:
4467 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
4468 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
:
4469 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
4470 TilegxReloc::imm_x_pcrel_general(view
, object
, psymval
, addend
,
4474 case elfcpp::R_TILEGX_BROFF_X1
:
4475 case elfcpp::R_TILEGX_DEST_IMM8_X1
:
4476 TilegxReloc::imm_x_two_part_general(view
, object
, psymval
,
4477 addend
, address
, r_type
);
4481 // below are general relocation types, which can be
4482 // handled by target-independent handlers
4483 case elfcpp::R_TILEGX_64
:
4484 TilegxReloc::abs64(view
, object
, psymval
, addend
);
4487 case elfcpp::R_TILEGX_64_PCREL
:
4488 TilegxReloc::pc_abs64(view
, object
, psymval
, addend
, address
);
4491 case elfcpp::R_TILEGX_32
:
4492 TilegxReloc::abs32(view
, object
, psymval
, addend
);
4495 case elfcpp::R_TILEGX_32_PCREL
:
4496 TilegxReloc::pc_abs32(view
, object
, psymval
, addend
, address
);
4499 case elfcpp::R_TILEGX_16
:
4500 TilegxReloc::abs16(view
, object
, psymval
, addend
);
4503 case elfcpp::R_TILEGX_16_PCREL
:
4504 TilegxReloc::pc_abs16(view
, object
, psymval
, addend
, address
);
4507 case elfcpp::R_TILEGX_8
:
4508 Relocate_functions
<size
, big_endian
>::rela8(view
, object
,
4512 case elfcpp::R_TILEGX_8_PCREL
:
4513 Relocate_functions
<size
, big_endian
>::pcrela8(view
, object
,
4514 psymval
, addend
, address
);
4517 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
4518 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
4519 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
4520 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
4521 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
4522 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
4523 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
4524 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
4525 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
4526 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
4527 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
4528 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
4529 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
4530 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
4531 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
4532 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
4533 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
4534 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
4535 case elfcpp::R_TILEGX_TLS_GD_CALL
:
4536 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
4537 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
4538 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
4539 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
4540 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
4541 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
4542 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
4543 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
4544 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
4546 const bool is_final
= (gsym
== NULL
4547 ? !parameters
->options().shared()
4548 : gsym
->final_value_is_known());
4549 tls::Tls_optimization opt_t
=
4550 Target_tilegx
<size
, big_endian
>::optimize_tls_reloc(is_final
,
4556 case elfcpp::R_TILEGX_TLS_GD_CALL
:
4558 if (opt_t
== tls::TLSOPT_NONE
) {
4559 Symbol
*tls_sym
= relinfo
->symtab
->lookup("__tls_get_addr");
4560 symval
.set_output_value(
4561 target
->plt_address_for_global(tls_sym
));
4563 TilegxReloc::imm_x_pcrel_general(view
, object
, psymval
,
4564 addend
, address
, r_howto
);
4566 else if (opt_t
== tls::TLSOPT_TO_IE
4567 || opt_t
== tls::TLSOPT_TO_LE
)
4568 TilegxReloc::tls_relax(view
, r_type
, opt_t
);
4572 // XX_TLS_GD is the same as normal X_GOT relocation
4573 // except allocating a got entry pair,
4574 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
4575 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
4576 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
4577 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
4578 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
4579 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
4580 if (opt_t
== tls::TLSOPT_NONE
) {
4581 got_type
= GOT_TYPE_TLS_PAIR
;
4582 have_got_offset
= true;
4583 } else if (opt_t
== tls::TLSOPT_TO_IE
) {
4584 got_type
= GOT_TYPE_TLS_OFFSET
;
4585 have_got_offset
= true;
4587 goto do_update_value
;
4588 // XX_TLS_IE is the same as normal X_GOT relocation
4589 // except allocating one additional runtime relocation
4590 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
4591 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
4592 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
4593 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
4594 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
4595 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
4596 if (opt_t
== tls::TLSOPT_NONE
) {
4597 got_type
= GOT_TYPE_TLS_OFFSET
;
4598 have_got_offset
= true;
4601 if (have_got_offset
) {
4603 gold_assert(gsym
->has_got_offset(got_type
));
4604 got_offset
= gsym
->got_offset(got_type
) - got_base
;
4607 = elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
4608 gold_assert(object
->local_has_got_offset(r_sym
, got_type
));
4610 object
->local_got_offset(r_sym
, got_type
) - got_base
;
4614 if (opt_t
== tls::TLSOPT_NONE
4615 || opt_t
== tls::TLSOPT_TO_IE
) {
4616 // for both GD/IE, these relocations
4617 // actually calculate got offset, so
4618 // there behavior are the same
4619 gold_assert(have_got_offset
);
4620 symval
.set_output_value(got_offset
);
4623 TilegxReloc::imm_x_general(view
, object
, psymval
,
4626 } // else if (opt_t == tls::TLSOPT_TO_LE)
4627 // both GD/IE are turned into LE, which
4628 // is absolute relocation.
4638 // t_var1 | t_var2 | t_var3 | ...
4639 // --------------------------------------------------
4641 // so offset to tp should be negative, we get offset
4642 // from the following formular for LE
4644 // t_var1_off = t_var1_sym_value - tls_section_start
4646 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
4647 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
4648 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
4649 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
4650 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
4651 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
4653 Output_segment
*tls_segment
= relinfo
->layout
->tls_segment();
4654 if (tls_segment
== NULL
) {
4655 gold_assert(parameters
->errors()->error_count() > 0
4656 || issue_undefined_symbol_error(gsym
));
4660 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
4661 = psymval
->value(relinfo
->object
, 0);
4662 symval
.set_output_value(value
);
4664 TilegxReloc::imm_x_general(view
, object
, psymval
,
4670 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
4671 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
4672 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
4673 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
4674 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
4675 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
4676 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
4677 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
4678 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
4679 TilegxReloc::tls_relax(view
, r_type
, opt_t
);
4688 // below are outstanding relocs
4689 // should not existed in static linking stage
4690 case elfcpp::R_TILEGX_COPY
:
4691 case elfcpp::R_TILEGX_GLOB_DAT
:
4692 case elfcpp::R_TILEGX_JMP_SLOT
:
4693 case elfcpp::R_TILEGX_RELATIVE
:
4694 case elfcpp::R_TILEGX_TLS_TPOFF32
:
4695 case elfcpp::R_TILEGX_TLS_TPOFF64
:
4696 case elfcpp::R_TILEGX_TLS_DTPMOD32
:
4697 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
4698 case elfcpp::R_TILEGX_TLS_DTPOFF32
:
4699 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
4700 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
4701 _("unexpected reloc %u in object file"),
4706 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
4707 _("unsupported reloc %u"),
4715 // Relocate section data.
4717 template<int size
, bool big_endian
>
4719 Target_tilegx
<size
, big_endian
>::relocate_section(
4720 const Relocate_info
<size
, big_endian
>* relinfo
,
4721 unsigned int sh_type
,
4722 const unsigned char* prelocs
,
4724 Output_section
* output_section
,
4725 bool needs_special_offset_handling
,
4726 unsigned char* view
,
4727 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
4728 section_size_type view_size
,
4729 const Reloc_symbol_changes
* reloc_symbol_changes
)
4731 typedef Target_tilegx
<size
, big_endian
> Tilegx
;
4732 typedef typename Target_tilegx
<size
, big_endian
>::Relocate Tilegx_relocate
;
4734 gold_assert(sh_type
== elfcpp::SHT_RELA
);
4736 gold::relocate_section
<size
, big_endian
, Tilegx
, elfcpp::SHT_RELA
,
4737 Tilegx_relocate
, gold::Default_comdat_behavior
>(
4743 needs_special_offset_handling
,
4747 reloc_symbol_changes
);
4750 // Apply an incremental relocation. Incremental relocations always refer
4751 // to global symbols.
4753 template<int size
, bool big_endian
>
4755 Target_tilegx
<size
, big_endian
>::apply_relocation(
4756 const Relocate_info
<size
, big_endian
>* relinfo
,
4757 typename
elfcpp::Elf_types
<size
>::Elf_Addr r_offset
,
4758 unsigned int r_type
,
4759 typename
elfcpp::Elf_types
<size
>::Elf_Swxword r_addend
,
4761 unsigned char* view
,
4762 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
4763 section_size_type view_size
)
4765 gold::apply_relocation
<size
, big_endian
, Target_tilegx
<size
, big_endian
>,
4766 typename Target_tilegx
<size
, big_endian
>::Relocate
>(
4778 // Return the size of a relocation while scanning during a relocatable
4781 template<int size
, bool big_endian
>
4783 Target_tilegx
<size
,big_endian
>::Relocatable_size_for_reloc::get_size_for_reloc(
4784 unsigned int, Relobj
*)
4786 // We are always SHT_RELA, so we should never get here.
4791 // Scan the relocs during a relocatable link.
4793 template<int size
, bool big_endian
>
4795 Target_tilegx
<size
, big_endian
>::scan_relocatable_relocs(
4796 Symbol_table
* symtab
,
4798 Sized_relobj_file
<size
, big_endian
>* object
,
4799 unsigned int data_shndx
,
4800 unsigned int sh_type
,
4801 const unsigned char* prelocs
,
4803 Output_section
* output_section
,
4804 bool needs_special_offset_handling
,
4805 size_t local_symbol_count
,
4806 const unsigned char* plocal_symbols
,
4807 Relocatable_relocs
* rr
)
4809 gold_assert(sh_type
== elfcpp::SHT_RELA
);
4811 typedef gold::Default_scan_relocatable_relocs
<elfcpp::SHT_RELA
,
4812 Relocatable_size_for_reloc
> Scan_relocatable_relocs
;
4814 gold::scan_relocatable_relocs
<size
, big_endian
, elfcpp::SHT_RELA
,
4815 Scan_relocatable_relocs
>(
4823 needs_special_offset_handling
,
4829 // Relocate a section during a relocatable link.
4831 template<int size
, bool big_endian
>
4833 Target_tilegx
<size
, big_endian
>::relocate_relocs(
4834 const Relocate_info
<size
, big_endian
>* relinfo
,
4835 unsigned int sh_type
,
4836 const unsigned char* prelocs
,
4838 Output_section
* output_section
,
4839 typename
elfcpp::Elf_types
<size
>::Elf_Off offset_in_output_section
,
4840 const Relocatable_relocs
* rr
,
4841 unsigned char* view
,
4842 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
4843 section_size_type view_size
,
4844 unsigned char* reloc_view
,
4845 section_size_type reloc_view_size
)
4847 gold_assert(sh_type
== elfcpp::SHT_RELA
);
4849 gold::relocate_relocs
<size
, big_endian
, elfcpp::SHT_RELA
>(
4854 offset_in_output_section
,
4863 // Return the value to use for a dynamic which requires special
4864 // treatment. This is how we support equality comparisons of function
4865 // pointers across shared library boundaries, as described in the
4866 // processor specific ABI supplement.
4868 template<int size
, bool big_endian
>
4870 Target_tilegx
<size
, big_endian
>::do_dynsym_value(const Symbol
* gsym
) const
4872 gold_assert(gsym
->is_from_dynobj() && gsym
->has_plt_offset());
4873 return this->plt_address_for_global(gsym
);
4876 // Return the value to use for the base of a DW_EH_PE_datarel offset
4877 // in an FDE. Solaris and SVR4 use DW_EH_PE_datarel because their
4878 // assembler can not write out the difference between two labels in
4879 // different sections, so instead of using a pc-relative value they
4880 // use an offset from the GOT.
4882 template<int size
, bool big_endian
>
4884 Target_tilegx
<size
, big_endian
>::do_ehframe_datarel_base() const
4886 gold_assert(this->global_offset_table_
!= NULL
);
4887 Symbol
* sym
= this->global_offset_table_
;
4888 Sized_symbol
<size
>* ssym
= static_cast<Sized_symbol
<size
>*>(sym
);
4889 return ssym
->value();
4892 // The selector for tilegx object files.
4894 template<int size
, bool big_endian
>
4895 class Target_selector_tilegx
: public Target_selector
4898 Target_selector_tilegx()
4899 : Target_selector(elfcpp::EM_TILEGX
, size
, big_endian
,
4901 ? (big_endian
? "elf64-tilegx-be" : "elf64-tilegx-le")
4902 : (big_endian
? "elf32-tilegx-be"
4903 : "elf32-tilegx-le")),
4905 ? (big_endian
? "elf64tilegx_be" : "elf64tilegx")
4906 : (big_endian
? "elf32tilegx_be" : "elf32tilegx")))
4910 do_instantiate_target()
4911 { return new Target_tilegx
<size
, big_endian
>(); }
4915 Target_selector_tilegx
<64, false> target_selector_tilegx64_le
;
4916 Target_selector_tilegx
<32, false> target_selector_tilegx32_le
;
4917 Target_selector_tilegx
<64, true> target_selector_tilegx64_be
;
4918 Target_selector_tilegx
<32, true> target_selector_tilegx32_be
;
4919 } // End anonymous namespace.