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 off_t 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;
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(const Relobj*,
2208 return this->address() + (this->count_ + 1) * this->get_plt_entry_size();
2211 // Set the final size.
2212 template<int size, bool big_endian>
2214 Output_data_plt_tilegx<size, big_endian>::set_final_data_size()
2216 unsigned int count = this->count_ + this->irelative_count_;
2217 this->set_data_size((count + 1) * this->get_plt_entry_size());
2220 // The first entry in the PLT for an executable.
2223 Output_data_plt_tilegx<64, false>::first_plt_entry[plt_entry_size] =
2225 0x00, 0x30, 0x48, 0x51,
2226 0x6e, 0x43, 0xa0, 0x18, // { ld_add r28, r27, 8 }
2227 0x00, 0x30, 0xbc, 0x35,
2228 0x00, 0x40, 0xde, 0x9e, // { ld r27, r27 }
2229 0xff, 0xaf, 0x30, 0x40,
2230 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2232 0x00, 0x00, 0x00, 0x00,
2233 0x00, 0x00, 0x00, 0x00,
2234 0x00, 0x00, 0x00, 0x00,
2235 0x00, 0x00, 0x00, 0x00
2240 Output_data_plt_tilegx<32, false>::first_plt_entry[plt_entry_size] =
2242 0x00, 0x30, 0x48, 0x51,
2243 0x6e, 0x23, 0x58, 0x18, // { ld4s_add r28, r27, 4 }
2244 0x00, 0x30, 0xbc, 0x35,
2245 0x00, 0x40, 0xde, 0x9c, // { ld4s r27, r27 }
2246 0xff, 0xaf, 0x30, 0x40,
2247 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2249 0x00, 0x00, 0x00, 0x00,
2250 0x00, 0x00, 0x00, 0x00,
2251 0x00, 0x00, 0x00, 0x00,
2252 0x00, 0x00, 0x00, 0x00
2257 Output_data_plt_tilegx<64, true>::first_plt_entry[plt_entry_size] =
2259 0x00, 0x30, 0x48, 0x51,
2260 0x6e, 0x43, 0xa0, 0x18, // { ld_add r28, r27, 8 }
2261 0x00, 0x30, 0xbc, 0x35,
2262 0x00, 0x40, 0xde, 0x9e, // { ld r27, r27 }
2263 0xff, 0xaf, 0x30, 0x40,
2264 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2266 0x00, 0x00, 0x00, 0x00,
2267 0x00, 0x00, 0x00, 0x00,
2268 0x00, 0x00, 0x00, 0x00,
2269 0x00, 0x00, 0x00, 0x00
2274 Output_data_plt_tilegx<32, true>::first_plt_entry[plt_entry_size] =
2276 0x00, 0x30, 0x48, 0x51,
2277 0x6e, 0x23, 0x58, 0x18, // { ld4s_add r28, r27, 4 }
2278 0x00, 0x30, 0xbc, 0x35,
2279 0x00, 0x40, 0xde, 0x9c, // { ld4s r27, r27 }
2280 0xff, 0xaf, 0x30, 0x40,
2281 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2283 0x00, 0x00, 0x00, 0x00,
2284 0x00, 0x00, 0x00, 0x00,
2285 0x00, 0x00, 0x00, 0x00,
2286 0x00, 0x00, 0x00, 0x00
2289 template<int size, bool big_endian>
2291 Output_data_plt_tilegx<size, big_endian>::fill_first_plt_entry(
2294 memcpy(pov, first_plt_entry, plt_entry_size);
2297 // Subsequent entries in the PLT for an executable.
2301 Output_data_plt_tilegx<64, false>::plt_entry[plt_entry_size] =
2303 0xdc, 0x0f, 0x00, 0x10,
2304 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2305 0xdb, 0x0f, 0x00, 0x10,
2306 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2307 0x9c, 0xc6, 0x0d, 0xd0,
2308 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2309 0x9b, 0xb6, 0xc5, 0xad,
2310 0xff, 0x57, 0xe0, 0x8e, // { add r27, r26, r27 ; info 10 ; ld r28, r28 }
2311 0xdd, 0x0f, 0x00, 0x70,
2312 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2318 Output_data_plt_tilegx<32, false>::plt_entry[plt_entry_size] =
2320 0xdc, 0x0f, 0x00, 0x10,
2321 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2322 0xdb, 0x0f, 0x00, 0x10,
2323 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2324 0x9c, 0xc6, 0x0d, 0xd0,
2325 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2326 0x9b, 0xb6, 0xc5, 0xad,
2327 0xff, 0x57, 0xe0, 0x8c, // { add r27, r26, r27 ; info 10 ; ld4s r28, r28 }
2328 0xdd, 0x0f, 0x00, 0x70,
2329 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2334 Output_data_plt_tilegx<64, true>::plt_entry[plt_entry_size] =
2336 0xdc, 0x0f, 0x00, 0x10,
2337 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2338 0xdb, 0x0f, 0x00, 0x10,
2339 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2340 0x9c, 0xc6, 0x0d, 0xd0,
2341 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2342 0x9b, 0xb6, 0xc5, 0xad,
2343 0xff, 0x57, 0xe0, 0x8e, // { add r27, r26, r27 ; info 10 ; ld r28, r28 }
2344 0xdd, 0x0f, 0x00, 0x70,
2345 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2351 Output_data_plt_tilegx<32, true>::plt_entry[plt_entry_size] =
2353 0xdc, 0x0f, 0x00, 0x10,
2354 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2355 0xdb, 0x0f, 0x00, 0x10,
2356 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2357 0x9c, 0xc6, 0x0d, 0xd0,
2358 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2359 0x9b, 0xb6, 0xc5, 0xad,
2360 0xff, 0x57, 0xe0, 0x8c, // { add r27, r26, r27 ; info 10 ; ld4s r28, r28 }
2361 0xdd, 0x0f, 0x00, 0x70,
2362 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2365 template<int size, bool big_endian>
2367 Output_data_plt_tilegx<size, big_endian>::fill_plt_entry(
2369 typename elfcpp::Elf_types<size>::Elf_Addr gotplt_base,
2370 unsigned int got_offset,
2371 typename elfcpp::Elf_types<size>::Elf_Addr plt_base,
2372 unsigned int plt_offset, unsigned int plt_index)
2375 const uint32_t TILEGX_IMM16_MASK = 0xFFFF;
2376 const uint32_t TILEGX_X0_IMM16_BITOFF = 12;
2377 const uint32_t TILEGX_X1_IMM16_BITOFF = 43;
2379 typedef typename elfcpp::Swap<TILEGX_INST_BUNDLE_SIZE, big_endian>::Valtype
2381 memcpy(pov, plt_entry, plt_entry_size);
2383 // first bundle in plt stub - x0
2384 Valtype* wv = reinterpret_cast<Valtype*>(pov);
2385 Valtype val = elfcpp::Swap<TILEGX_INST_BUNDLE_SIZE, big_endian>::readval(wv);
2387 ((gotplt_base + got_offset) - (plt_base + plt_offset + 8)) >> 16;
2388 elfcpp::Elf_Xword dst_mask =
2389 (elfcpp::Elf_Xword)(TILEGX_IMM16_MASK) << TILEGX_X0_IMM16_BITOFF;
2391 reloc &= TILEGX_IMM16_MASK;
2392 elfcpp::Swap<TILEGX_INST_BUNDLE_SIZE, big_endian>::writeval(wv,
2393 val | (reloc<<TILEGX_X0_IMM16_BITOFF));
2395 // second bundle in plt stub - x1
2396 wv = reinterpret_cast<Valtype*>(pov + 8);
2397 val = elfcpp::Swap<TILEGX_INST_BUNDLE_SIZE, big_endian>::readval(wv);
2398 reloc = (gotplt_base + got_offset) - (plt_base + plt_offset + 8);
2399 dst_mask = (elfcpp::Elf_Xword)(TILEGX_IMM16_MASK) << TILEGX_X1_IMM16_BITOFF;
2401 reloc &= TILEGX_IMM16_MASK;
2402 elfcpp::Swap<TILEGX_INST_BUNDLE_SIZE, big_endian>::writeval(wv,
2403 val | (reloc<<TILEGX_X1_IMM16_BITOFF));
2405 // second bundle in plt stub - x0
2406 wv = reinterpret_cast<Valtype*>(pov + 8);
2407 val = elfcpp::Swap<TILEGX_INST_BUNDLE_SIZE, big_endian>::readval(wv);
2408 reloc = (gotplt_base - (plt_base + plt_offset + 8)) >> 16;
2409 dst_mask = (elfcpp::Elf_Xword)(TILEGX_IMM16_MASK) << TILEGX_X0_IMM16_BITOFF;
2411 reloc &= TILEGX_IMM16_MASK;
2412 elfcpp::Swap<TILEGX_INST_BUNDLE_SIZE, big_endian>::writeval(wv,
2413 val | (reloc<<TILEGX_X0_IMM16_BITOFF));
2415 // third bundle in plt stub - x1
2416 wv = reinterpret_cast<Valtype*>(pov + 16);
2417 val = elfcpp::Swap<TILEGX_INST_BUNDLE_SIZE, big_endian>::readval(wv);
2418 reloc = gotplt_base - (plt_base + plt_offset + 8);
2419 dst_mask = (elfcpp::Elf_Xword)(TILEGX_IMM16_MASK) << TILEGX_X1_IMM16_BITOFF;
2421 reloc &= TILEGX_IMM16_MASK;
2422 elfcpp::Swap<TILEGX_INST_BUNDLE_SIZE, big_endian>::writeval(wv,
2423 val | (reloc<<TILEGX_X1_IMM16_BITOFF));
2425 // fifth bundle in plt stub - carry plt_index x0
2426 wv = reinterpret_cast<Valtype*>(pov + 32);
2427 val = elfcpp::Swap<TILEGX_INST_BUNDLE_SIZE, big_endian>::readval(wv);
2428 dst_mask = (elfcpp::Elf_Xword)(TILEGX_IMM16_MASK) << TILEGX_X0_IMM16_BITOFF;
2430 plt_index &= TILEGX_IMM16_MASK;
2431 elfcpp::Swap<TILEGX_INST_BUNDLE_SIZE, big_endian>::writeval(wv,
2432 val | (plt_index<<TILEGX_X0_IMM16_BITOFF));
2436 // Write out the PLT. This uses the hand-coded instructions above.
2438 template<int size, bool big_endian>
2440 Output_data_plt_tilegx<size, big_endian>::do_write(Output_file* of)
2442 const off_t offset = this->offset();
2443 const section_size_type oview_size =
2444 convert_to_section_size_type(this->data_size());
2445 unsigned char* const oview = of->get_output_view(offset, oview_size);
2447 const off_t got_file_offset = this->got_plt_->offset();
2448 gold_assert(parameters->incremental_update()
2449 || (got_file_offset + this->got_plt_->data_size()
2450 == this->got_irelative_->offset()));
2451 const section_size_type got_size =
2452 convert_to_section_size_type(this->got_plt_->data_size()
2453 + this->got_irelative_->data_size());
2454 unsigned char* const got_view = of->get_output_view(got_file_offset,
2457 unsigned char* pov = oview;
2459 // The base address of the .plt section.
2460 typename elfcpp::Elf_types<size>::Elf_Addr plt_address = this->address();
2461 typename elfcpp::Elf_types<size>::Elf_Addr got_address =
2462 this->got_plt_->address();
2464 this->fill_first_plt_entry(pov);
2465 pov += this->get_plt_entry_size();
2467 unsigned char* got_pov = got_view;
2469 // first entry of .got.plt are set to -1
2470 // second entry of .got.plt are set to 0
2471 memset(got_pov, 0xff, size / 8);
2472 got_pov += size / 8;
2473 memset(got_pov, 0x0, size / 8);
2474 got_pov += size / 8;
2476 unsigned int plt_offset = this->get_plt_entry_size();
2477 const unsigned int count = this->count_ + this->irelative_count_;
2478 unsigned int got_offset = (size / 8) * TILEGX_GOTPLT_RESERVE_COUNT;
2479 for (unsigned int plt_index = 0;
2482 pov += this->get_plt_entry_size(),
2483 got_pov += size / 8,
2484 plt_offset += this->get_plt_entry_size(),
2485 got_offset += size / 8)
2487 // Set and adjust the PLT entry itself.
2488 this->fill_plt_entry(pov, got_address, got_offset,
2489 plt_address, plt_offset, plt_index);
2491 // Initialize entry in .got.plt to plt start address
2492 elfcpp::Swap<size, big_endian>::writeval(got_pov, plt_address);
2495 gold_assert(static_cast<section_size_type>(pov - oview) == oview_size);
2496 gold_assert(static_cast<section_size_type>(got_pov - got_view) == got_size);
2498 of->write_output_view(offset, oview_size, oview);
2499 of->write_output_view(got_file_offset, got_size, got_view);
2502 // Create the PLT section.
2504 template<int size, bool big_endian>
2506 Target_tilegx<size, big_endian>::make_plt_section(Symbol_table* symtab,
2509 if (this->plt_ == NULL)
2511 // Create the GOT sections first.
2512 this->got_section(symtab, layout);
2514 // Ensure that .rela.dyn always appears before .rela.plt,
2515 // becuase on TILE-Gx, .rela.dyn needs to include .rela.plt
2517 this->rela_dyn_section(layout);
2519 this->plt_ = new Output_data_plt_tilegx<size, big_endian>(layout,
2520 TILEGX_INST_BUNDLE_SIZE, this->got_, this->got_plt_,
2521 this->got_irelative_);
2523 layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS,
2525 | elfcpp::SHF_EXECINSTR),
2526 this->plt_, ORDER_NON_RELRO_FIRST,
2529 // Make the sh_info field of .rela.plt point to .plt.
2530 Output_section* rela_plt_os = this->plt_->rela_plt()->output_section();
2531 rela_plt_os->set_info_section(this->plt_->output_section());
2535 // Create a PLT entry for a global symbol.
2537 template<int size, bool big_endian>
2539 Target_tilegx<size, big_endian>::make_plt_entry(Symbol_table* symtab,
2540 Layout* layout, Symbol* gsym)
2542 if (gsym->has_plt_offset())
2545 if (this->plt_ == NULL)
2546 this->make_plt_section(symtab, layout);
2548 this->plt_->add_entry(symtab, layout, gsym);
2551 // Make a PLT entry for a local STT_GNU_IFUNC symbol.
2553 template<int size, bool big_endian>
2555 Target_tilegx<size, big_endian>::make_local_ifunc_plt_entry(
2556 Symbol_table* symtab, Layout* layout,
2557 Sized_relobj_file<size, big_endian>* relobj,
2558 unsigned int local_sym_index)
2560 if (relobj->local_has_plt_offset(local_sym_index))
2562 if (this->plt_ == NULL)
2563 this->make_plt_section(symtab, layout);
2564 unsigned int plt_offset = this->plt_->add_local_ifunc_entry(symtab, layout,
2567 relobj->set_local_plt_offset(local_sym_index, plt_offset);
2570 // Return the number of entries in the PLT.
2572 template<int size, bool big_endian>
2574 Target_tilegx<size, big_endian>::plt_entry_count() const
2576 if (this->plt_ == NULL)
2578 return this->plt_->entry_count();
2581 // Return the offset of the first non-reserved PLT entry.
2583 template<int size, bool big_endian>
2585 Target_tilegx<size, big_endian>::first_plt_entry_offset() const
2587 return this->plt_->first_plt_entry_offset();
2590 // Return the size of each PLT entry.
2592 template<int size, bool big_endian>
2594 Target_tilegx<size, big_endian>::plt_entry_size() const
2596 return this->plt_->get_plt_entry_size();
2599 // Create the GOT and PLT sections for an incremental update.
2601 template<int size, bool big_endian>
2602 Output_data_got_base*
2603 Target_tilegx<size, big_endian>::init_got_plt_for_update(Symbol_table* symtab,
2605 unsigned int got_count,
2606 unsigned int plt_count)
2608 gold_assert(this->got_ == NULL);
2611 new Output_data_got<size, big_endian>((got_count
2612 + TILEGX_GOT_RESERVE_COUNT)
2614 layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
2616 | elfcpp::SHF_WRITE),
2617 this->got_, ORDER_RELRO_LAST,
2620 // Define _GLOBAL_OFFSET_TABLE_ at the start of the GOT.
2621 this->global_offset_table_ =
2622 symtab->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL,
2623 Symbol_table::PREDEFINED,
2625 0, 0, elfcpp::STT_OBJECT,
2627 elfcpp::STV_HIDDEN, 0,
2630 if (parameters->options().shared()) {
2631 this->tilegx_dynamic_ =
2632 symtab->define_in_output_data("_TILEGX_DYNAMIC_", NULL,
2633 Symbol_table::PREDEFINED,
2634 layout->dynamic_section(),
2635 0, 0, elfcpp::STT_OBJECT,
2637 elfcpp::STV_HIDDEN, 0,
2640 this->got_->add_global(this->tilegx_dynamic_, GOT_TYPE_STANDARD);
2642 this->got_->set_current_data_size(size / 8);
2644 // Add the two reserved entries.
2646 = new Output_data_space((plt_count + TILEGX_GOTPLT_RESERVE_COUNT)
2647 * (size / 8), size / 8, "** GOT PLT");
2648 layout->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS,
2650 | elfcpp::SHF_WRITE),
2651 this->got_plt_, ORDER_NON_RELRO_FIRST,
2654 // If there are any IRELATIVE relocations, they get GOT entries in
2655 // .got.plt after the jump slot.
2656 this->got_irelative_
2657 = new Output_data_space(0, size / 8, "** GOT IRELATIVE PLT");
2658 layout->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS,
2659 elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE,
2660 this->got_irelative_,
2661 ORDER_NON_RELRO_FIRST, false);
2663 // Create the PLT section.
2664 this->plt_ = new Output_data_plt_tilegx<size, big_endian>(layout,
2665 this->plt_entry_size(), this->got_, this->got_plt_, this->got_irelative_,
2668 layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS,
2669 elfcpp::SHF_ALLOC | elfcpp::SHF_EXECINSTR,
2670 this->plt_, ORDER_PLT, false);
2672 // Make the sh_info field of .rela.plt point to .plt.
2673 Output_section* rela_plt_os = this->plt_->rela_plt()->output_section();
2674 rela_plt_os->set_info_section(this->plt_->output_section());
2676 // Create the rela_dyn section.
2677 this->rela_dyn_section(layout);
2682 // Reserve a GOT entry for a local symbol, and regenerate any
2683 // necessary dynamic relocations.
2685 template<int size, bool big_endian>
2687 Target_tilegx<size, big_endian>::reserve_local_got_entry(
2688 unsigned int got_index,
2689 Sized_relobj<size, big_endian>* obj,
2691 unsigned int got_type)
2693 unsigned int got_offset = (got_index + TILEGX_GOT_RESERVE_COUNT)
2695 Reloc_section* rela_dyn = this->rela_dyn_section(NULL);
2697 this->got_->reserve_local(got_index, obj, r_sym, got_type);
2700 case GOT_TYPE_STANDARD:
2701 if (parameters->options().output_is_position_independent())
2702 rela_dyn->add_local_relative(obj, r_sym, elfcpp::R_TILEGX_RELATIVE,
2703 this->got_, got_offset, 0, false);
2705 case GOT_TYPE_TLS_OFFSET:
2706 rela_dyn->add_local(obj, r_sym,
2707 size == 32 ? elfcpp::R_TILEGX_TLS_DTPOFF32
2708 : elfcpp::R_TILEGX_TLS_DTPOFF64,
2709 this->got_, got_offset, 0);
2711 case GOT_TYPE_TLS_PAIR:
2712 this->got_->reserve_slot(got_index + 1);
2713 rela_dyn->add_local(obj, r_sym,
2714 size == 32 ? elfcpp::R_TILEGX_TLS_DTPMOD32
2715 : elfcpp::R_TILEGX_TLS_DTPMOD64,
2716 this->got_, got_offset, 0);
2718 case GOT_TYPE_TLS_DESC:
2719 gold_fatal(_("TLS_DESC not yet supported for incremental linking"));
2726 // Reserve a GOT entry for a global symbol, and regenerate any
2727 // necessary dynamic relocations.
2729 template<int size, bool big_endian>
2731 Target_tilegx<size, big_endian>::reserve_global_got_entry(
2732 unsigned int got_index, Symbol* gsym, unsigned int got_type)
2734 unsigned int got_offset = (got_index + TILEGX_GOT_RESERVE_COUNT)
2736 Reloc_section* rela_dyn = this->rela_dyn_section(NULL);
2738 this->got_->reserve_global(got_index, gsym, got_type);
2741 case GOT_TYPE_STANDARD:
2742 if (!gsym->final_value_is_known())
2744 if (gsym->is_from_dynobj()
2745 || gsym->is_undefined()
2746 || gsym->is_preemptible()
2747 || gsym->type() == elfcpp::STT_GNU_IFUNC)
2748 rela_dyn->add_global(gsym, elfcpp::R_TILEGX_GLOB_DAT,
2749 this->got_, got_offset, 0);
2751 rela_dyn->add_global_relative(gsym, elfcpp::R_TILEGX_RELATIVE,
2752 this->got_, got_offset, 0, false);
2755 case GOT_TYPE_TLS_OFFSET:
2756 rela_dyn->add_global_relative(gsym,
2757 size == 32 ? elfcpp::R_TILEGX_TLS_TPOFF32
2758 : elfcpp::R_TILEGX_TLS_TPOFF64,
2759 this->got_, got_offset, 0, false);
2761 case GOT_TYPE_TLS_PAIR:
2762 this->got_->reserve_slot(got_index + 1);
2763 rela_dyn->add_global_relative(gsym,
2764 size == 32 ? elfcpp::R_TILEGX_TLS_DTPMOD32
2765 : elfcpp::R_TILEGX_TLS_DTPMOD64,
2766 this->got_, got_offset, 0, false);
2767 rela_dyn->add_global_relative(gsym,
2768 size == 32 ? elfcpp::R_TILEGX_TLS_DTPOFF32
2769 : elfcpp::R_TILEGX_TLS_DTPOFF64,
2770 this->got_, got_offset + size / 8,
2773 case GOT_TYPE_TLS_DESC:
2774 gold_fatal(_("TLS_DESC not yet supported for TILEGX"));
2781 // Register an existing PLT entry for a global symbol.
2783 template<int size, bool big_endian>
2785 Target_tilegx<size, big_endian>::register_global_plt_entry(
2786 Symbol_table* symtab, Layout* layout, unsigned int plt_index, Symbol* gsym)
2788 gold_assert(this->plt_ != NULL);
2789 gold_assert(!gsym->has_plt_offset());
2791 this->plt_->reserve_slot(plt_index);
2793 gsym->set_plt_offset((plt_index + 1) * this->plt_entry_size());
2795 unsigned int got_offset = (plt_index + 2) * (size / 8);
2796 this->plt_->add_relocation(symtab, layout, gsym, got_offset);
2799 // Force a COPY relocation for a given symbol.
2801 template<int size, bool big_endian>
2803 Target_tilegx<size, big_endian>::emit_copy_reloc(
2804 Symbol_table* symtab, Symbol* sym, Output_section* os, off_t offset)
2806 this->copy_relocs_.emit_copy_reloc(symtab,
2807 symtab->get_sized_symbol<size>(sym),
2810 this->rela_dyn_section(NULL));
2813 // Create a GOT entry for the TLS module index.
2815 template<int size, bool big_endian>
2817 Target_tilegx<size, big_endian>::got_mod_index_entry(Symbol_table* symtab,
2819 Sized_relobj_file<size, big_endian>* object)
2821 if (this->got_mod_index_offset_ == -1U)
2823 gold_assert(symtab != NULL && layout != NULL && object != NULL);
2824 Reloc_section* rela_dyn = this->rela_dyn_section(layout);
2825 Output_data_got<size, big_endian>* got
2826 = this->got_section(symtab, layout);
2827 unsigned int got_offset = got->add_constant(0);
2828 rela_dyn->add_local(object, 0,
2829 size == 32 ? elfcpp::R_TILEGX_TLS_DTPMOD32
2830 : elfcpp::R_TILEGX_TLS_DTPMOD64, got,
2832 got->add_constant(0);
2833 this->got_mod_index_offset_ = got_offset;
2835 return this->got_mod_index_offset_;
2838 // Optimize the TLS relocation type based on what we know about the
2839 // symbol. IS_FINAL is true if the final address of this symbol is
2840 // known at link time.
2842 // the transformation rules is described below:
2844 // compiler GD reference
2847 // moveli tmp, hw1_last_tls_gd(x) X0/X1
2848 // shl16insli r0, tmp, hw0_tls_gd(x) X0/X1
2849 // addi r0, got, tls_add(x) Y0/Y1/X0/X1
2850 // jal tls_gd_call(x) X1
2851 // addi adr, r0, tls_gd_add(x) Y0/Y1/X0/X1
2853 // linker tranformation of GD insn sequence
2857 // moveli tmp, hw1_last_tls_gd(x) X0/X1
2858 // shl16insli r0, tmp, hw0_tls_gd(x) X0/X1
2859 // add r0, got, r0 Y0/Y1/X0/X1
2860 // jal plt(__tls_get_addr) X1
2861 // move adr, r0 Y0/Y1/X0/X1
2863 // moveli tmp, hw1_last_tls_ie(x) X0/X1
2864 // shl16insli r0, tmp, hw0_tls_ie(x) X0/X1
2865 // add r0, got, r0 Y0/Y1/X0/X1
2867 // add adr, r0, tp Y0/Y1/X0/X1
2869 // moveli tmp, hw1_last_tls_le(x) X0/X1
2870 // shl16insli r0, tmp, hw0_tls_le(x) X0/X1
2871 // move r0, r0 Y0/Y1/X0/X1
2872 // move r0, r0 Y0/Y1/X0/X1
2873 // add adr, r0, tp Y0/Y1/X0/X1
2876 // compiler IE reference
2879 // moveli tmp, hw1_last_tls_ie(x) X0/X1
2880 // shl16insli tmp, tmp, hw0_tls_ie(x) X0/X1
2881 // addi tmp, got, tls_add(x) Y0/Y1/X0/X1
2882 // ld_tls tmp, tmp, tls_ie_load(x) X1
2883 // add adr, tmp, tp Y0/Y1/X0/X1
2885 // linker transformation for IE insn sequence
2889 // moveli tmp, hw1_last_tls_ie(x) X0/X1
2890 // shl16insli tmp, tmp, hw0_tls_ie(x) X0/X1
2891 // add tmp, got, tmp Y0/Y1/X0/X1
2893 // add adr, tmp, tp Y0/Y1/X0/X1
2895 // moveli tmp, hw1_last_tls_le(x) X0/X1
2896 // shl16insli tmp, tmp, hw0_tls_le(x) X0/X1
2897 // move tmp, tmp Y0/Y1/X0/X1
2898 // move tmp, tmp Y0/Y1/X0/X1
2901 // compiler LE reference
2904 // moveli tmp, hw1_last_tls_le(x) X0/X1
2905 // shl16insli tmp, tmp, hw0_tls_le(x) X0/X1
2906 // add adr, tmp, tp Y0/Y1/X0/X1
2908 template<int size, bool big_endian>
2909 tls::Tls_optimization
2910 Target_tilegx<size, big_endian>::optimize_tls_reloc(bool is_final, int r_type)
2912 // If we are generating a shared library, then we can't do anything
2914 if (parameters->options().shared())
2915 return tls::TLSOPT_NONE;
2919 // unique GD relocations
2920 case elfcpp::R_TILEGX_TLS_GD_CALL:
2921 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD:
2922 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD:
2923 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD:
2924 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD:
2925 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD:
2926 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD:
2927 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
2928 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
2929 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
2930 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
2931 // These are General-Dynamic which permits fully general TLS
2932 // access. Since we know that we are generating an executable,
2933 // we can convert this to Initial-Exec. If we also know that
2934 // this is a local symbol, we can further switch to Local-Exec.
2936 return tls::TLSOPT_TO_LE;
2937 return tls::TLSOPT_TO_IE;
2939 // unique IE relocations
2940 case elfcpp::R_TILEGX_TLS_IE_LOAD:
2941 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE:
2942 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE:
2943 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE:
2944 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE:
2945 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE:
2946 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE:
2947 // These are Initial-Exec relocs which get the thread offset
2948 // from the GOT. If we know that we are linking against the
2949 // local symbol, we can switch to Local-Exec, which links the
2950 // thread offset into the instruction.
2952 return tls::TLSOPT_TO_LE;
2953 return tls::TLSOPT_NONE;
2955 // could be created for both GD and IE
2956 // but they are expanded into the same
2957 // instruction in GD and IE.
2958 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD:
2959 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD:
2960 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD:
2961 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD:
2963 return tls::TLSOPT_TO_LE;
2964 return tls::TLSOPT_NONE;
2966 // unique LE relocations
2967 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE:
2968 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE:
2969 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE:
2970 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE:
2971 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE:
2972 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE:
2973 // When we already have Local-Exec, there is nothing further we
2975 return tls::TLSOPT_NONE;
2982 // Get the Reference_flags for a particular relocation.
2984 template<int size, bool big_endian>
2986 Target_tilegx<size, big_endian>::Scan::get_reference_flags(unsigned int r_type)
2990 case elfcpp::R_TILEGX_NONE:
2991 case elfcpp::R_TILEGX_GNU_VTINHERIT:
2992 case elfcpp::R_TILEGX_GNU_VTENTRY:
2993 // No symbol reference.
2996 case elfcpp::R_TILEGX_64:
2997 case elfcpp::R_TILEGX_32:
2998 case elfcpp::R_TILEGX_16:
2999 case elfcpp::R_TILEGX_8:
3000 return Symbol::ABSOLUTE_REF;
3002 case elfcpp::R_TILEGX_BROFF_X1:
3003 case elfcpp::R_TILEGX_64_PCREL:
3004 case elfcpp::R_TILEGX_32_PCREL:
3005 case elfcpp::R_TILEGX_16_PCREL:
3006 case elfcpp::R_TILEGX_8_PCREL:
3007 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL:
3008 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL:
3009 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL:
3010 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL:
3011 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL:
3012 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL:
3013 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL:
3014 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL:
3015 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL:
3016 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL:
3017 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL:
3018 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL:
3019 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL:
3020 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL:
3021 return Symbol::RELATIVE_REF;
3023 case elfcpp::R_TILEGX_JUMPOFF_X1:
3024 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT:
3025 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL:
3026 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL:
3027 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL:
3028 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL:
3029 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL:
3030 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL:
3031 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL:
3032 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL:
3033 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL:
3034 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL:
3035 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL:
3036 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL:
3037 return Symbol::FUNCTION_CALL | Symbol::RELATIVE_REF;
3039 case elfcpp::R_TILEGX_IMM16_X0_HW0:
3040 case elfcpp::R_TILEGX_IMM16_X1_HW0:
3041 case elfcpp::R_TILEGX_IMM16_X0_HW1:
3042 case elfcpp::R_TILEGX_IMM16_X1_HW1:
3043 case elfcpp::R_TILEGX_IMM16_X0_HW2:
3044 case elfcpp::R_TILEGX_IMM16_X1_HW2:
3045 case elfcpp::R_TILEGX_IMM16_X0_HW3:
3046 case elfcpp::R_TILEGX_IMM16_X1_HW3:
3047 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST:
3048 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST:
3049 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST:
3050 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST:
3051 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST:
3052 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST:
3053 return Symbol::ABSOLUTE_REF;
3055 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT:
3056 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT:
3057 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT:
3058 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT:
3059 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT:
3060 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT:
3062 return Symbol::ABSOLUTE_REF;
3064 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD:
3065 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD:
3066 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE:
3067 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE:
3068 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE:
3069 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE:
3070 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE:
3071 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE:
3072 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
3073 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
3074 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
3075 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
3076 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE:
3077 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE:
3078 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE:
3079 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE:
3080 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE:
3081 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE:
3082 case elfcpp::R_TILEGX_TLS_DTPOFF64:
3083 case elfcpp::R_TILEGX_TLS_DTPMOD32:
3084 case elfcpp::R_TILEGX_TLS_DTPOFF32:
3085 case elfcpp::R_TILEGX_TLS_TPOFF32:
3086 case elfcpp::R_TILEGX_TLS_GD_CALL:
3087 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD:
3088 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD:
3089 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD:
3090 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD:
3091 case elfcpp::R_TILEGX_TLS_IE_LOAD:
3092 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD:
3093 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD:
3094 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD:
3095 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD:
3096 return Symbol::TLS_REF;
3098 case elfcpp::R_TILEGX_COPY:
3099 case elfcpp::R_TILEGX_GLOB_DAT:
3100 case elfcpp::R_TILEGX_JMP_SLOT:
3101 case elfcpp::R_TILEGX_RELATIVE:
3102 case elfcpp::R_TILEGX_TLS_TPOFF64:
3103 case elfcpp::R_TILEGX_TLS_DTPMOD64:
3105 // Not expected. We will give an error later.
3110 // Report an unsupported relocation against a local symbol.
3112 template<int size, bool big_endian>
3114 Target_tilegx<size, big_endian>::Scan::unsupported_reloc_local(
3115 Sized_relobj_file<size, big_endian>* object,
3116 unsigned int r_type)
3118 gold_error(_("%s: unsupported reloc %u against local symbol"),
3119 object->name().c_str(), r_type);
3122 // We are about to emit a dynamic relocation of type R_TYPE. If the
3123 // dynamic linker does not support it, issue an error.
3124 template<int size, bool big_endian>
3126 Target_tilegx<size, big_endian>::Scan::check_non_pic(Relobj* object,
3127 unsigned int r_type)
3131 // These are the relocation types supported by glibc for tilegx
3132 // which should always work.
3133 case elfcpp::R_TILEGX_RELATIVE:
3134 case elfcpp::R_TILEGX_GLOB_DAT:
3135 case elfcpp::R_TILEGX_JMP_SLOT:
3136 case elfcpp::R_TILEGX_TLS_DTPMOD64:
3137 case elfcpp::R_TILEGX_TLS_DTPOFF64:
3138 case elfcpp::R_TILEGX_TLS_TPOFF64:
3139 case elfcpp::R_TILEGX_8:
3140 case elfcpp::R_TILEGX_16:
3141 case elfcpp::R_TILEGX_32:
3142 case elfcpp::R_TILEGX_64:
3143 case elfcpp::R_TILEGX_COPY:
3144 case elfcpp::R_TILEGX_IMM16_X0_HW0:
3145 case elfcpp::R_TILEGX_IMM16_X1_HW0:
3146 case elfcpp::R_TILEGX_IMM16_X0_HW1:
3147 case elfcpp::R_TILEGX_IMM16_X1_HW1:
3148 case elfcpp::R_TILEGX_IMM16_X0_HW2:
3149 case elfcpp::R_TILEGX_IMM16_X1_HW2:
3150 case elfcpp::R_TILEGX_IMM16_X0_HW3:
3151 case elfcpp::R_TILEGX_IMM16_X1_HW3:
3152 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST:
3153 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST:
3154 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST:
3155 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST:
3156 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST:
3157 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST:
3158 case elfcpp::R_TILEGX_BROFF_X1:
3159 case elfcpp::R_TILEGX_JUMPOFF_X1:
3160 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL:
3161 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL:
3162 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL:
3163 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL:
3164 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL:
3165 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL:
3166 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL:
3167 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL:
3168 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL:
3169 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL:
3170 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL:
3171 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL:
3172 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL:
3173 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL:
3177 // This prevents us from issuing more than one error per reloc
3178 // section. But we can still wind up issuing more than one
3179 // error per object file.
3180 if (this->issued_non_pic_error_)
3182 gold_assert(parameters->options().output_is_position_independent());
3183 object->error(_("requires unsupported dynamic reloc %u; "
3184 "recompile with -fPIC"),
3186 this->issued_non_pic_error_ = true;
3189 case elfcpp::R_TILEGX_NONE:
3194 // Return whether we need to make a PLT entry for a relocation of the
3195 // given type against a STT_GNU_IFUNC symbol.
3197 template<int size, bool big_endian>
3199 Target_tilegx<size, big_endian>::Scan::reloc_needs_plt_for_ifunc(
3200 Sized_relobj_file<size, big_endian>* object, unsigned int r_type)
3202 int flags = Scan::get_reference_flags(r_type);
3203 if (flags & Symbol::TLS_REF)
3204 gold_error(_("%s: unsupported TLS reloc %u for IFUNC symbol"),
3205 object->name().c_str(), r_type);
3209 // Scan a relocation for a local symbol.
3211 template<int size, bool big_endian>
3213 Target_tilegx<size, big_endian>::Scan::local(Symbol_table* symtab,
3215 Target_tilegx<size, big_endian>* target,
3216 Sized_relobj_file<size, big_endian>* object,
3217 unsigned int data_shndx,
3218 Output_section* output_section,
3219 const elfcpp::Rela<size, big_endian>& reloc,
3220 unsigned int r_type,
3221 const elfcpp::Sym<size, big_endian>& lsym,
3227 // A local STT_GNU_IFUNC symbol may require a PLT entry.
3228 bool is_ifunc = lsym.get_st_type() == elfcpp::STT_GNU_IFUNC;
3229 if (is_ifunc && this->reloc_needs_plt_for_ifunc(object, r_type))
3231 unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
3232 target->make_local_ifunc_plt_entry(symtab, layout, object, r_sym);
3237 case elfcpp::R_TILEGX_NONE:
3238 case elfcpp::R_TILEGX_GNU_VTINHERIT:
3239 case elfcpp::R_TILEGX_GNU_VTENTRY:
3242 // If building a shared library (or a position-independent
3243 // executable), because the runtime address needs plus
3244 // the module base address, so generate a R_TILEGX_RELATIVE.
3245 case elfcpp::R_TILEGX_32:
3246 case elfcpp::R_TILEGX_64:
3247 if (parameters->options().output_is_position_independent())
3249 unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
3250 Reloc_section* rela_dyn = target->rela_dyn_section(layout);
3251 rela_dyn->add_local_relative(object, r_sym,
3252 elfcpp::R_TILEGX_RELATIVE,
3253 output_section, data_shndx,
3254 reloc.get_r_offset(),
3255 reloc.get_r_addend(), is_ifunc);
3259 // If building a shared library (or a position-independent
3260 // executable), we need to create a dynamic relocation for this
3262 case elfcpp::R_TILEGX_8:
3263 case elfcpp::R_TILEGX_16:
3264 case elfcpp::R_TILEGX_IMM16_X0_HW0:
3265 case elfcpp::R_TILEGX_IMM16_X1_HW0:
3266 case elfcpp::R_TILEGX_IMM16_X0_HW1:
3267 case elfcpp::R_TILEGX_IMM16_X1_HW1:
3268 case elfcpp::R_TILEGX_IMM16_X0_HW2:
3269 case elfcpp::R_TILEGX_IMM16_X1_HW2:
3270 case elfcpp::R_TILEGX_IMM16_X0_HW3:
3271 case elfcpp::R_TILEGX_IMM16_X1_HW3:
3272 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST:
3273 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST:
3274 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST:
3275 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST:
3276 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST:
3277 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST:
3278 if (parameters->options().output_is_position_independent())
3280 this->check_non_pic(object, r_type);
3282 Reloc_section* rela_dyn = target->rela_dyn_section(layout);
3283 unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
3284 if (lsym.get_st_type() != elfcpp::STT_SECTION)
3285 rela_dyn->add_local(object, r_sym, r_type, output_section,
3286 data_shndx, reloc.get_r_offset(),
3287 reloc.get_r_addend());
3290 gold_assert(lsym.get_st_value() == 0);
3291 rela_dyn->add_symbolless_local_addend(object, r_sym, r_type,
3294 reloc.get_r_offset(),
3295 reloc.get_r_addend());
3301 // R_TILEGX_JUMPOFF_X1_PLT against local symbol
3302 // may happen for ifunc case.
3303 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT:
3304 case elfcpp::R_TILEGX_JUMPOFF_X1:
3305 case elfcpp::R_TILEGX_64_PCREL:
3306 case elfcpp::R_TILEGX_32_PCREL:
3307 case elfcpp::R_TILEGX_16_PCREL:
3308 case elfcpp::R_TILEGX_8_PCREL:
3309 case elfcpp::R_TILEGX_BROFF_X1:
3310 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL:
3311 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL:
3312 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL:
3313 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL:
3314 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL:
3315 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL:
3316 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL:
3317 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL:
3318 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL:
3319 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL:
3320 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL:
3321 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL:
3322 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL:
3323 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL:
3324 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL:
3325 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL:
3326 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL:
3327 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL:
3328 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL:
3329 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL:
3330 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL:
3331 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL:
3332 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL:
3333 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL:
3334 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL:
3335 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL:
3338 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT:
3339 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT:
3340 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT:
3341 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT:
3342 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT:
3343 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT:
3345 // The symbol requires a GOT entry.
3346 Output_data_got<size, big_endian>* got
3347 = target->got_section(symtab, layout);
3348 unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
3350 // For a STT_GNU_IFUNC symbol we want the PLT offset. That
3351 // lets function pointers compare correctly with shared
3352 // libraries. Otherwise we would need an IRELATIVE reloc.
3355 is_new = got->add_local_plt(object, r_sym, GOT_TYPE_STANDARD);
3357 is_new = got->add_local(object, r_sym, GOT_TYPE_STANDARD);
3360 // tilegx dynamic linker will not update local got entry,
3361 // so, if we are generating a shared object, we need to add a
3362 // dynamic relocation for this symbol's GOT entry to inform
3363 // dynamic linker plus the load base explictly.
3364 if (parameters->options().output_is_position_independent())
3366 unsigned int got_offset
3367 = object->local_got_offset(r_sym, GOT_TYPE_STANDARD);
3369 Reloc_section* rela_dyn = target->rela_dyn_section(layout);
3370 rela_dyn->add_local_relative(object, r_sym,
3372 got, got_offset, 0, is_ifunc);
3378 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD:
3379 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD:
3380 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE:
3381 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE:
3382 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE:
3383 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE:
3384 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE:
3385 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE:
3386 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
3387 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
3388 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
3389 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
3390 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE:
3391 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE:
3392 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE:
3393 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE:
3394 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE:
3395 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE:
3396 case elfcpp::R_TILEGX_TLS_GD_CALL:
3397 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD:
3398 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD:
3399 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD:
3400 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD:
3401 case elfcpp::R_TILEGX_TLS_IE_LOAD:
3402 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD:
3403 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD:
3404 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD:
3405 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD:
3407 bool output_is_shared = parameters->options().shared();
3408 const tls::Tls_optimization opt_t =
3409 Target_tilegx<size, big_endian>::optimize_tls_reloc(
3410 !output_is_shared, r_type);
3414 case elfcpp::R_TILEGX_TLS_GD_CALL:
3415 // FIXME: predefine __tls_get_addr
3417 // R_TILEGX_TLS_GD_CALL implicitly reference __tls_get_addr,
3418 // while all other target, x86/arm/mips/powerpc/sparc
3419 // generate tls relocation against __tls_get_addr explictly,
3420 // so for TILEGX, we need the following hack.
3421 if (opt_t == tls::TLSOPT_NONE) {
3422 if (!target->tls_get_addr_sym_defined_) {
3424 options::parse_set(NULL, "__tls_get_addr",
3425 (gold::options::String_set*)
3426 ¶meters->options().undefined());
3427 symtab->add_undefined_symbols_from_command_line(layout);
3428 target->tls_get_addr_sym_defined_ = true;
3429 sym = symtab->lookup("__tls_get_addr");
3432 target->make_plt_entry(symtab, layout,
3433 symtab->lookup("__tls_get_addr"));
3437 // only make effect when applying relocation
3438 case elfcpp::R_TILEGX_TLS_IE_LOAD:
3439 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD:
3440 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD:
3441 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD:
3442 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD:
3443 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD:
3444 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD:
3445 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD:
3446 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD:
3449 // GD: requires two GOT entry for module index and offset
3450 // IE: requires one GOT entry for tp-relative offset
3451 // LE: shouldn't happen for global symbol
3452 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD:
3453 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD:
3454 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
3455 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
3456 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
3457 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
3459 if (opt_t == tls::TLSOPT_NONE) {
3460 Output_data_got<size, big_endian> *got
3461 = target->got_section(symtab, layout);
3463 = elfcpp::elf_r_sym<size>(reloc.get_r_info());
3464 unsigned int shndx = lsym.get_st_shndx();
3466 shndx = object->adjust_sym_shndx(r_sym, shndx,
3469 object->error(_("local symbol %u has bad shndx %u"),
3472 got->add_local_pair_with_rel(object, r_sym, shndx,
3474 target->rela_dyn_section(layout),
3476 ? elfcpp::R_TILEGX_TLS_DTPMOD32
3477 : elfcpp::R_TILEGX_TLS_DTPMOD64);
3478 } else if (opt_t == tls::TLSOPT_TO_IE) {
3479 Output_data_got<size, big_endian>* got
3480 = target->got_section(symtab, layout);
3481 Reloc_section* rela_dyn
3482 = target->rela_dyn_section(layout);
3484 = elfcpp::elf_r_sym<size>(reloc.get_r_info());
3485 unsigned int off = got->add_constant(0);
3486 object->set_local_got_offset(r_sym,
3487 GOT_TYPE_TLS_OFFSET,off);
3488 rela_dyn->add_symbolless_local_addend(object, r_sym,
3490 ? elfcpp::R_TILEGX_TLS_TPOFF32
3491 : elfcpp::R_TILEGX_TLS_TPOFF64,
3493 } else if (opt_t != tls::TLSOPT_TO_LE)
3494 // only TO_LE is allowed for local symbol
3495 unsupported_reloc_local(object, r_type);
3500 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE:
3501 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE:
3502 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE:
3503 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE:
3504 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE:
3505 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE:
3507 layout->set_has_static_tls();
3508 if (opt_t == tls::TLSOPT_NONE) {
3509 Output_data_got<size, big_endian>* got
3510 = target->got_section(symtab, layout);
3511 Reloc_section* rela_dyn
3512 = target->rela_dyn_section(layout);
3514 = elfcpp::elf_r_sym<size>(reloc.get_r_info());
3515 unsigned int off = got->add_constant(0);
3516 object->set_local_got_offset(r_sym,
3517 GOT_TYPE_TLS_OFFSET, off);
3518 rela_dyn->add_symbolless_local_addend(object, r_sym,
3520 ? elfcpp::R_TILEGX_TLS_TPOFF32
3521 : elfcpp::R_TILEGX_TLS_TPOFF64,
3523 } else if (opt_t != tls::TLSOPT_TO_LE)
3524 unsupported_reloc_local(object, r_type);
3529 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE:
3530 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE:
3531 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE:
3532 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE:
3533 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE:
3534 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE:
3535 layout->set_has_static_tls();
3536 if (parameters->options().shared()) {
3537 // defer to dynamic linker
3538 gold_assert(lsym.get_st_type() != elfcpp::STT_SECTION);
3540 = elfcpp::elf_r_sym<size>(reloc.get_r_info());
3541 Reloc_section* rela_dyn = target->rela_dyn_section(layout);
3542 rela_dyn->add_symbolless_local_addend(object, r_sym, r_type,
3543 output_section, data_shndx,
3544 reloc.get_r_offset(), 0);
3554 case elfcpp::R_TILEGX_COPY:
3555 case elfcpp::R_TILEGX_GLOB_DAT:
3556 case elfcpp::R_TILEGX_JMP_SLOT:
3557 case elfcpp::R_TILEGX_RELATIVE:
3558 // These are outstanding tls relocs, which are unexpected when linking
3559 case elfcpp::R_TILEGX_TLS_TPOFF32:
3560 case elfcpp::R_TILEGX_TLS_TPOFF64:
3561 case elfcpp::R_TILEGX_TLS_DTPMOD32:
3562 case elfcpp::R_TILEGX_TLS_DTPMOD64:
3563 case elfcpp::R_TILEGX_TLS_DTPOFF32:
3564 case elfcpp::R_TILEGX_TLS_DTPOFF64:
3565 gold_error(_("%s: unexpected reloc %u in object file"),
3566 object->name().c_str(), r_type);
3570 gold_error(_("%s: unsupported reloc %u against local symbol"),
3571 object->name().c_str(), r_type);
3577 // Report an unsupported relocation against a global symbol.
3579 template<int size, bool big_endian>
3581 Target_tilegx<size, big_endian>::Scan::unsupported_reloc_global(
3582 Sized_relobj_file<size, big_endian>* object,
3583 unsigned int r_type,
3586 gold_error(_("%s: unsupported reloc %u against global symbol %s"),
3587 object->name().c_str(), r_type, gsym->demangled_name().c_str());
3590 // Returns true if this relocation type could be that of a function pointer.
3591 template<int size, bool big_endian>
3593 Target_tilegx<size, big_endian>::Scan::possible_function_pointer_reloc(
3594 unsigned int r_type)
3598 case elfcpp::R_TILEGX_IMM16_X0_HW0:
3599 case elfcpp::R_TILEGX_IMM16_X1_HW0:
3600 case elfcpp::R_TILEGX_IMM16_X0_HW1:
3601 case elfcpp::R_TILEGX_IMM16_X1_HW1:
3602 case elfcpp::R_TILEGX_IMM16_X0_HW2:
3603 case elfcpp::R_TILEGX_IMM16_X1_HW2:
3604 case elfcpp::R_TILEGX_IMM16_X0_HW3:
3605 case elfcpp::R_TILEGX_IMM16_X1_HW3:
3606 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST:
3607 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST:
3608 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST:
3609 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST:
3610 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST:
3611 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST:
3612 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL:
3613 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL:
3614 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL:
3615 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL:
3616 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL:
3617 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL:
3618 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL:
3619 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL:
3620 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL:
3621 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL:
3622 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL:
3623 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL:
3624 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL:
3625 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL:
3626 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT:
3627 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT:
3628 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT:
3629 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT:
3630 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT:
3631 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT:
3639 // For safe ICF, scan a relocation for a local symbol to check if it
3640 // corresponds to a function pointer being taken. In that case mark
3641 // the function whose pointer was taken as not foldable.
3643 template<int size, bool big_endian>
3645 Target_tilegx<size, big_endian>::Scan::local_reloc_may_be_function_pointer(
3648 Target_tilegx<size, big_endian>* ,
3649 Sized_relobj_file<size, big_endian>* ,
3652 const elfcpp::Rela<size, big_endian>& ,
3653 unsigned int r_type,
3654 const elfcpp::Sym<size, big_endian>&)
3656 return possible_function_pointer_reloc(r_type);
3659 // For safe ICF, scan a relocation for a global symbol to check if it
3660 // corresponds to a function pointer being taken. In that case mark
3661 // the function whose pointer was taken as not foldable.
3663 template<int size, bool big_endian>
3665 Target_tilegx<size, big_endian>::Scan::global_reloc_may_be_function_pointer(
3668 Target_tilegx<size, big_endian>* ,
3669 Sized_relobj_file<size, big_endian>* ,
3672 const elfcpp::Rela<size, big_endian>& ,
3673 unsigned int r_type,
3676 // GOT is not a function.
3677 if (strcmp(gsym->name(), "_GLOBAL_OFFSET_TABLE_") == 0)
3680 // When building a shared library, do not fold symbols whose visibility
3681 // is hidden, internal or protected.
3682 return ((parameters->options().shared()
3683 && (gsym->visibility() == elfcpp::STV_INTERNAL
3684 || gsym->visibility() == elfcpp::STV_PROTECTED
3685 || gsym->visibility() == elfcpp::STV_HIDDEN))
3686 || possible_function_pointer_reloc(r_type));
3689 // Scan a relocation for a global symbol.
3691 template<int size, bool big_endian>
3693 Target_tilegx<size, big_endian>::Scan::global(Symbol_table* symtab,
3695 Target_tilegx<size, big_endian>* target,
3696 Sized_relobj_file<size, big_endian>* object,
3697 unsigned int data_shndx,
3698 Output_section* output_section,
3699 const elfcpp::Rela<size, big_endian>& reloc,
3700 unsigned int r_type,
3703 // A reference to _GLOBAL_OFFSET_TABLE_ implies that we need a got
3704 // section. We check here to avoid creating a dynamic reloc against
3705 // _GLOBAL_OFFSET_TABLE_.
3706 if (!target->has_got_section()
3707 && strcmp(gsym->name(), "_GLOBAL_OFFSET_TABLE_") == 0)
3708 target->got_section(symtab, layout);
3710 // A STT_GNU_IFUNC symbol may require a PLT entry.
3711 if (gsym->type() == elfcpp::STT_GNU_IFUNC
3712 && this->reloc_needs_plt_for_ifunc(object, r_type))
3713 target->make_plt_entry(symtab, layout, gsym);
3717 case elfcpp::R_TILEGX_NONE:
3718 case elfcpp::R_TILEGX_GNU_VTINHERIT:
3719 case elfcpp::R_TILEGX_GNU_VTENTRY:
3722 case elfcpp::R_TILEGX_DEST_IMM8_X1:
3723 case elfcpp::R_TILEGX_IMM16_X0_HW0:
3724 case elfcpp::R_TILEGX_IMM16_X1_HW0:
3725 case elfcpp::R_TILEGX_IMM16_X0_HW1:
3726 case elfcpp::R_TILEGX_IMM16_X1_HW1:
3727 case elfcpp::R_TILEGX_IMM16_X0_HW2:
3728 case elfcpp::R_TILEGX_IMM16_X1_HW2:
3729 case elfcpp::R_TILEGX_IMM16_X0_HW3:
3730 case elfcpp::R_TILEGX_IMM16_X1_HW3:
3731 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST:
3732 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST:
3733 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST:
3734 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST:
3735 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST:
3736 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST:
3737 case elfcpp::R_TILEGX_64:
3738 case elfcpp::R_TILEGX_32:
3739 case elfcpp::R_TILEGX_16:
3740 case elfcpp::R_TILEGX_8:
3742 // Make a PLT entry if necessary.
3743 if (gsym->needs_plt_entry())
3745 target->make_plt_entry(symtab, layout, gsym);
3746 // Since this is not a PC-relative relocation, we may be
3747 // taking the address of a function. In that case we need to
3748 // set the entry in the dynamic symbol table to the address of
3750 if (gsym->is_from_dynobj() && !parameters->options().shared())
3751 gsym->set_needs_dynsym_value();
3753 // Make a dynamic relocation if necessary.
3754 if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type)))
3756 if (gsym->may_need_copy_reloc())
3758 target->copy_reloc(symtab, layout, object,
3759 data_shndx, output_section, gsym, reloc);
3761 else if (((size == 64 && r_type == elfcpp::R_TILEGX_64)
3762 || (size == 32 && r_type == elfcpp::R_TILEGX_32))
3763 && gsym->type() == elfcpp::STT_GNU_IFUNC
3764 && gsym->can_use_relative_reloc(false)
3765 && !gsym->is_from_dynobj()
3766 && !gsym->is_undefined()
3767 && !gsym->is_preemptible())
3769 // Use an IRELATIVE reloc for a locally defined
3770 // STT_GNU_IFUNC symbol. This makes a function
3771 // address in a PIE executable match the address in a
3772 // shared library that it links against.
3773 Reloc_section* rela_dyn =
3774 target->rela_irelative_section(layout);
3775 unsigned int r_type = elfcpp::R_TILEGX_IRELATIVE;
3776 rela_dyn->add_symbolless_global_addend(gsym, r_type,
3777 output_section, object,
3779 reloc.get_r_offset(),
3780 reloc.get_r_addend());
3781 } else if ((r_type == elfcpp::R_TILEGX_64
3782 || r_type == elfcpp::R_TILEGX_32)
3783 && gsym->can_use_relative_reloc(false))
3785 Reloc_section* rela_dyn = target->rela_dyn_section(layout);
3786 rela_dyn->add_global_relative(gsym, elfcpp::R_TILEGX_RELATIVE,
3787 output_section, object,
3789 reloc.get_r_offset(),
3790 reloc.get_r_addend(), false);
3794 this->check_non_pic(object, r_type);
3795 Reloc_section* rela_dyn = target->rela_dyn_section(layout);
3796 rela_dyn->add_global(gsym, r_type, output_section, object,
3797 data_shndx, reloc.get_r_offset(),
3798 reloc.get_r_addend());
3804 case elfcpp::R_TILEGX_BROFF_X1:
3805 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL:
3806 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL:
3807 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL:
3808 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL:
3809 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL:
3810 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL:
3811 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL:
3812 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL:
3813 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL:
3814 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL:
3815 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL:
3816 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL:
3817 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL:
3818 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL:
3819 case elfcpp::R_TILEGX_64_PCREL:
3820 case elfcpp::R_TILEGX_32_PCREL:
3821 case elfcpp::R_TILEGX_16_PCREL:
3822 case elfcpp::R_TILEGX_8_PCREL:
3824 // Make a PLT entry if necessary.
3825 if (gsym->needs_plt_entry())
3826 target->make_plt_entry(symtab, layout, gsym);
3827 // Make a dynamic relocation if necessary.
3828 if (gsym->needs_dynamic_reloc(Scan::get_reference_flags(r_type)))
3830 if (gsym->may_need_copy_reloc())
3832 target->copy_reloc(symtab, layout, object,
3833 data_shndx, output_section, gsym, reloc);
3837 this->check_non_pic(object, r_type);
3838 Reloc_section* rela_dyn = target->rela_dyn_section(layout);
3839 rela_dyn->add_global(gsym, r_type, output_section, object,
3840 data_shndx, reloc.get_r_offset(),
3841 reloc.get_r_addend());
3847 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT:
3848 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT:
3849 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT:
3850 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT:
3851 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT:
3852 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT:
3854 // The symbol requires a GOT entry.
3855 Output_data_got<size, big_endian>* got
3856 = target->got_section(symtab, layout);
3857 if (gsym->final_value_is_known())
3859 // For a STT_GNU_IFUNC symbol we want the PLT address.
3860 if (gsym->type() == elfcpp::STT_GNU_IFUNC)
3861 got->add_global_plt(gsym, GOT_TYPE_STANDARD);
3863 got->add_global(gsym, GOT_TYPE_STANDARD);
3867 // If this symbol is not fully resolved, we need to add a
3868 // dynamic relocation for it.
3869 Reloc_section* rela_dyn = target->rela_dyn_section(layout);
3871 // Use a GLOB_DAT rather than a RELATIVE reloc if:
3873 // 1) The symbol may be defined in some other module.
3875 // 2) We are building a shared library and this is a
3876 // protected symbol; using GLOB_DAT means that the dynamic
3877 // linker can use the address of the PLT in the main
3878 // executable when appropriate so that function address
3879 // comparisons work.
3881 // 3) This is a STT_GNU_IFUNC symbol in position dependent
3882 // code, again so that function address comparisons work.
3883 if (gsym->is_from_dynobj()
3884 || gsym->is_undefined()
3885 || gsym->is_preemptible()
3886 || (gsym->visibility() == elfcpp::STV_PROTECTED
3887 && parameters->options().shared())
3888 || (gsym->type() == elfcpp::STT_GNU_IFUNC
3889 && parameters->options().output_is_position_independent()))
3890 got->add_global_with_rel(gsym, GOT_TYPE_STANDARD, rela_dyn,
3891 elfcpp::R_TILEGX_GLOB_DAT);
3894 // For a STT_GNU_IFUNC symbol we want to write the PLT
3895 // offset into the GOT, so that function pointer
3896 // comparisons work correctly.
3898 if (gsym->type() != elfcpp::STT_GNU_IFUNC)
3899 is_new = got->add_global(gsym, GOT_TYPE_STANDARD);
3902 is_new = got->add_global_plt(gsym, GOT_TYPE_STANDARD);
3903 // Tell the dynamic linker to use the PLT address
3904 // when resolving relocations.
3905 if (gsym->is_from_dynobj()
3906 && !parameters->options().shared())
3907 gsym->set_needs_dynsym_value();
3911 unsigned int got_off = gsym->got_offset(GOT_TYPE_STANDARD);
3912 rela_dyn->add_global_relative(gsym,
3914 got, got_off, 0, false);
3921 // a minor difference here for R_TILEGX_JUMPOFF_X1
3922 // between bfd linker and gold linker for gold, when
3923 // R_TILEGX_JUMPOFF_X1 against global symbol, we
3924 // turn it into JUMPOFF_X1_PLT, otherwise the distance
3925 // to the symbol function may overflow at runtime.
3926 case elfcpp::R_TILEGX_JUMPOFF_X1:
3928 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT:
3929 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL:
3930 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL:
3931 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL:
3932 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL:
3933 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL:
3934 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL:
3935 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL:
3936 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL:
3937 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL:
3938 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL:
3939 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL:
3940 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL:
3941 // If the symbol is fully resolved, this is just a PC32 reloc.
3942 // Otherwise we need a PLT entry.
3943 if (gsym->final_value_is_known())
3945 // If building a shared library, we can also skip the PLT entry
3946 // if the symbol is defined in the output file and is protected
3948 if (gsym->is_defined()
3949 && !gsym->is_from_dynobj()
3950 && !gsym->is_preemptible())
3952 target->make_plt_entry(symtab, layout, gsym);
3956 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD:
3957 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD:
3958 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE:
3959 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE:
3960 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE:
3961 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE:
3962 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE:
3963 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE:
3964 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
3965 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
3966 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
3967 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
3968 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE:
3969 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE:
3970 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE:
3971 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE:
3972 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE:
3973 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE:
3974 case elfcpp::R_TILEGX_TLS_GD_CALL:
3975 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD:
3976 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD:
3977 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD:
3978 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD:
3979 case elfcpp::R_TILEGX_TLS_IE_LOAD:
3980 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD:
3981 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD:
3982 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD:
3983 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD:
3985 const bool is_final = gsym->final_value_is_known();
3986 const tls::Tls_optimization opt_t =
3987 Target_tilegx<size, big_endian>::optimize_tls_reloc(is_final,
3992 // only expand to plt against __tls_get_addr in GD model
3993 case elfcpp::R_TILEGX_TLS_GD_CALL:
3994 if (opt_t == tls::TLSOPT_NONE) {
3995 // FIXME: it's better '__tls_get_addr' referenced explictly
3996 if (!target->tls_get_addr_sym_defined_) {
3998 options::parse_set(NULL, "__tls_get_addr",
3999 (gold::options::String_set*)
4000 ¶meters->options().undefined());
4001 symtab->add_undefined_symbols_from_command_line(layout);
4002 target->tls_get_addr_sym_defined_ = true;
4003 sym = symtab->lookup("__tls_get_addr");
4006 target->make_plt_entry(symtab, layout,
4007 symtab->lookup("__tls_get_addr"));
4011 // only make effect when applying relocation
4012 case elfcpp::R_TILEGX_TLS_IE_LOAD:
4013 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD:
4014 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD:
4015 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD:
4016 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD:
4017 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD:
4018 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD:
4019 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD:
4020 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD:
4023 // GD: requires two GOT entry for module index and offset
4024 // IE: requires one GOT entry for tp-relative offset
4025 // LE: shouldn't happen for global symbol
4026 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD:
4027 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD:
4028 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
4029 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
4030 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
4031 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
4033 if (opt_t == tls::TLSOPT_NONE) {
4034 Output_data_got<size, big_endian>* got
4035 = target->got_section(symtab, layout);
4036 got->add_global_pair_with_rel(gsym, GOT_TYPE_TLS_PAIR,
4037 target->rela_dyn_section(layout),
4039 ? elfcpp::R_TILEGX_TLS_DTPMOD32
4040 : elfcpp::R_TILEGX_TLS_DTPMOD64,
4042 ? elfcpp::R_TILEGX_TLS_DTPOFF32
4043 : elfcpp::R_TILEGX_TLS_DTPOFF64);
4044 } else if (opt_t == tls::TLSOPT_TO_IE) {
4045 // Create a GOT entry for the tp-relative offset.
4046 Output_data_got<size, big_endian>* got
4047 = target->got_section(symtab, layout);
4048 got->add_global_with_rel(gsym, GOT_TYPE_TLS_OFFSET,
4049 target->rela_dyn_section(layout),
4051 ? elfcpp::R_TILEGX_TLS_TPOFF32
4052 : elfcpp::R_TILEGX_TLS_TPOFF64);
4053 } else if (opt_t != tls::TLSOPT_TO_LE)
4054 // exteranl symbol should not be optimized to TO_LE
4055 unsupported_reloc_global(object, r_type, gsym);
4060 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE:
4061 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE:
4062 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE:
4063 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE:
4064 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE:
4065 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE:
4067 layout->set_has_static_tls();
4068 if (opt_t == tls::TLSOPT_NONE) {
4069 // Create a GOT entry for the tp-relative offset.
4070 Output_data_got<size, big_endian>* got
4071 = target->got_section(symtab, layout);
4072 got->add_global_with_rel(gsym, GOT_TYPE_TLS_OFFSET,
4073 target->rela_dyn_section(layout),
4075 ? elfcpp::R_TILEGX_TLS_TPOFF32
4076 : elfcpp::R_TILEGX_TLS_TPOFF64);
4077 } else if (opt_t != tls::TLSOPT_TO_LE)
4078 unsupported_reloc_global(object, r_type, gsym);
4083 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE:
4084 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE:
4085 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE:
4086 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE:
4087 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE:
4088 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE:
4089 layout->set_has_static_tls();
4090 if (parameters->options().shared()) {
4091 // defer to dynamic linker
4092 Reloc_section* rela_dyn = target->rela_dyn_section(layout);
4093 rela_dyn->add_symbolless_global_addend(gsym, r_type,
4094 output_section, object,
4096 reloc.get_r_offset(), 0);
4106 // below are outstanding relocs
4107 // should not existed in static linking stage
4108 case elfcpp::R_TILEGX_COPY:
4109 case elfcpp::R_TILEGX_GLOB_DAT:
4110 case elfcpp::R_TILEGX_JMP_SLOT:
4111 case elfcpp::R_TILEGX_RELATIVE:
4112 case elfcpp::R_TILEGX_TLS_TPOFF32:
4113 case elfcpp::R_TILEGX_TLS_TPOFF64:
4114 case elfcpp::R_TILEGX_TLS_DTPMOD32:
4115 case elfcpp::R_TILEGX_TLS_DTPMOD64:
4116 case elfcpp::R_TILEGX_TLS_DTPOFF32:
4117 case elfcpp::R_TILEGX_TLS_DTPOFF64:
4118 gold_error(_("%s: unexpected reloc %u in object file"),
4119 object->name().c_str(), r_type);
4123 gold_error(_("%s: unsupported reloc %u against global symbol %s"),
4124 object->name().c_str(), r_type,
4125 gsym->demangled_name().c_str());
4130 template<int size, bool big_endian>
4132 Target_tilegx<size, big_endian>::gc_process_relocs(Symbol_table* symtab,
4134 Sized_relobj_file<size, big_endian>* object,
4135 unsigned int data_shndx,
4136 unsigned int sh_type,
4137 const unsigned char* prelocs,
4139 Output_section* output_section,
4140 bool needs_special_offset_handling,
4141 size_t local_symbol_count,
4142 const unsigned char* plocal_symbols)
4144 typedef Target_tilegx<size, big_endian> Tilegx;
4145 typedef typename Target_tilegx<size, big_endian>::Scan Scan;
4147 if (sh_type == elfcpp::SHT_REL)
4152 gold::gc_process_relocs<size, big_endian,
4153 Tilegx, elfcpp::SHT_RELA, Scan,
4154 typename Target_tilegx<size, big_endian>::Relocatable_size_for_reloc>(
4163 needs_special_offset_handling,
4167 // Scan relocations for a section.
4169 template<int size, bool big_endian>
4171 Target_tilegx<size, big_endian>::scan_relocs(Symbol_table* symtab,
4173 Sized_relobj_file<size, big_endian>* object,
4174 unsigned int data_shndx,
4175 unsigned int sh_type,
4176 const unsigned char* prelocs,
4178 Output_section* output_section,
4179 bool needs_special_offset_handling,
4180 size_t local_symbol_count,
4181 const unsigned char* plocal_symbols)
4183 typedef Target_tilegx<size, big_endian> Tilegx;
4184 typedef typename Target_tilegx<size, big_endian>::Scan Scan;
4186 if (sh_type == elfcpp::SHT_REL)
4188 gold_error(_("%s: unsupported REL reloc section"),
4189 object->name().c_str());
4193 gold::scan_relocs<size, big_endian, Tilegx, elfcpp::SHT_RELA, Scan>(
4202 needs_special_offset_handling,
4207 template<int size, bool big_endian>
4209 Target_tilegx<size, big_endian>::do_define_standard_symbols(
4210 Symbol_table* symtab,
4213 Output_section* feedback_section = layout->find_output_section(".feedback");
4215 if (feedback_section != NULL)
4217 symtab->define_in_output_data("__feedback_section_end",
4219 Symbol_table::PREDEFINED,
4227 true, // offset_is_from_end
4232 // Finalize the sections.
4234 template<int size, bool big_endian>
4236 Target_tilegx<size, big_endian>::do_finalize_sections(
4238 const Input_objects*,
4239 Symbol_table* symtab)
4241 const Reloc_section* rel_plt = (this->plt_ == NULL
4243 : this->plt_->rela_plt());
4244 layout->add_target_dynamic_tags(false, this->got_plt_, rel_plt,
4245 this->rela_dyn_, true, true);
4247 // Emit any relocs we saved in an attempt to avoid generating COPY
4249 if (this->copy_relocs_.any_saved_relocs())
4250 this->copy_relocs_.emit(this->rela_dyn_section(layout));
4252 // Set the size of the _GLOBAL_OFFSET_TABLE_ symbol to the size of
4253 // the .got section.
4254 Symbol* sym = this->global_offset_table_;
4257 uint64_t data_size = this->got_->current_data_size();
4258 symtab->get_sized_symbol<size>(sym)->set_symsize(data_size);
4260 // If the .got section is more than 0x8000 bytes, we add
4261 // 0x8000 to the value of _GLOBAL_OFFSET_TABLE_, so that 16
4262 // bit relocations have a greater chance of working.
4263 if (data_size >= 0x8000)
4264 symtab->get_sized_symbol<size>(sym)->set_value(
4265 symtab->get_sized_symbol<size>(sym)->value() + 0x8000);
4268 if (parameters->doing_static_link()
4269 && (this->plt_ == NULL || !this->plt_->has_irelative_section()))
4271 // If linking statically, make sure that the __rela_iplt symbols
4272 // were defined if necessary, even if we didn't create a PLT.
4273 static const Define_symbol_in_segment syms[] =
4276 "__rela_iplt_start", // name
4277 elfcpp::PT_LOAD, // segment_type
4278 elfcpp::PF_W, // segment_flags_set
4279 elfcpp::PF(0), // segment_flags_clear
4282 elfcpp::STT_NOTYPE, // type
4283 elfcpp::STB_GLOBAL, // binding
4284 elfcpp::STV_HIDDEN, // visibility
4286 Symbol::SEGMENT_START, // offset_from_base
4290 "__rela_iplt_end", // name
4291 elfcpp::PT_LOAD, // segment_type
4292 elfcpp::PF_W, // segment_flags_set
4293 elfcpp::PF(0), // segment_flags_clear
4296 elfcpp::STT_NOTYPE, // type
4297 elfcpp::STB_GLOBAL, // binding
4298 elfcpp::STV_HIDDEN, // visibility
4300 Symbol::SEGMENT_START, // offset_from_base
4305 symtab->define_symbols(layout, 2, syms,
4306 layout->script_options()->saw_sections_clause());
4310 // Perform a relocation.
4312 template<int size, bool big_endian>
4314 Target_tilegx<size, big_endian>::Relocate::relocate(
4315 const Relocate_info<size, big_endian>* relinfo,
4316 Target_tilegx<size, big_endian>* target,
4319 const elfcpp::Rela<size, big_endian>& rela,
4320 unsigned int r_type,
4321 const Sized_symbol<size>* gsym,
4322 const Symbol_value<size>* psymval,
4323 unsigned char* view,
4324 typename elfcpp::Elf_types<size>::Elf_Addr address,
4327 typedef Tilegx_relocate_functions<size, big_endian> TilegxReloc;
4328 typename TilegxReloc::Tilegx_howto r_howto;
4330 const Sized_relobj_file<size, big_endian>* object = relinfo->object;
4332 // Pick the value to use for symbols defined in the PLT.
4333 Symbol_value<size> symval;
4335 && gsym->use_plt_offset(Scan::get_reference_flags(r_type)))
4337 symval.set_output_value(target->plt_address_for_global(gsym)
4338 + gsym->plt_offset());
4341 else if (gsym == NULL && psymval->is_ifunc_symbol())
4343 unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info());
4344 if (object->local_has_plt_offset(r_sym))
4346 symval.set_output_value(target->plt_address_for_local(object, r_sym)
4347 + object->local_plt_offset(r_sym));
4352 elfcpp::Elf_Xword addend = rela.get_r_addend();
4354 // Get the GOT offset if needed.
4355 // For tilegx, the GOT pointer points to the start of the GOT section.
4356 bool have_got_offset = false;
4358 int got_base = target->got_ != NULL
4359 ? target->got_->current_data_size() >= 0x8000 ? 0x8000 : 0
4361 unsigned int got_type = GOT_TYPE_STANDARD;
4362 bool always_apply_relocation = false;
4365 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT:
4366 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT:
4367 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT:
4368 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT:
4369 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT:
4370 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT:
4373 gold_assert(gsym->has_got_offset(got_type));
4374 got_offset = gsym->got_offset(got_type) - got_base;
4378 unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info());
4379 gold_assert(object->local_has_got_offset(r_sym, got_type));
4381 object->local_got_offset(r_sym, got_type) - got_base;
4383 have_got_offset = true;
4390 r_howto = TilegxReloc::howto[r_type];
4393 case elfcpp::R_TILEGX_NONE:
4394 case elfcpp::R_TILEGX_GNU_VTINHERIT:
4395 case elfcpp::R_TILEGX_GNU_VTENTRY:
4398 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT:
4399 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT:
4400 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT:
4401 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT:
4402 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT:
4403 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT:
4404 gold_assert(have_got_offset);
4405 symval.set_output_value(got_offset);
4407 always_apply_relocation = true;
4410 // when under PIC mode, these relocations are deferred to rtld
4411 case elfcpp::R_TILEGX_IMM16_X0_HW0:
4412 case elfcpp::R_TILEGX_IMM16_X1_HW0:
4413 case elfcpp::R_TILEGX_IMM16_X0_HW1:
4414 case elfcpp::R_TILEGX_IMM16_X1_HW1:
4415 case elfcpp::R_TILEGX_IMM16_X0_HW2:
4416 case elfcpp::R_TILEGX_IMM16_X1_HW2:
4417 case elfcpp::R_TILEGX_IMM16_X0_HW3:
4418 case elfcpp::R_TILEGX_IMM16_X1_HW3:
4419 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST:
4420 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST:
4421 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST:
4422 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST:
4423 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST:
4424 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST:
4425 if (always_apply_relocation
4426 || !parameters->options().output_is_position_independent())
4427 TilegxReloc::imm_x_general(view, object, psymval, addend, r_howto);
4430 case elfcpp::R_TILEGX_JUMPOFF_X1:
4431 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT:
4432 gold_assert(gsym == NULL
4433 || gsym->has_plt_offset()
4434 || gsym->final_value_is_known()
4435 || (gsym->is_defined()
4436 && !gsym->is_from_dynobj()
4437 && !gsym->is_preemptible()));
4438 TilegxReloc::imm_x_pcrel_general(view, object, psymval, addend,
4443 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL:
4444 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL:
4445 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL:
4446 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL:
4447 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL:
4448 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL:
4449 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL:
4450 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL:
4451 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL:
4452 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL:
4453 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL:
4454 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL:
4455 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL:
4456 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL:
4457 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL:
4458 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL:
4459 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL:
4460 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL:
4461 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL:
4462 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL:
4463 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL:
4464 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL:
4465 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL:
4466 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL:
4467 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL:
4468 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL:
4469 TilegxReloc::imm_x_pcrel_general(view, object, psymval, addend,
4473 case elfcpp::R_TILEGX_BROFF_X1:
4474 case elfcpp::R_TILEGX_DEST_IMM8_X1:
4475 TilegxReloc::imm_x_two_part_general(view, object, psymval,
4476 addend, address, r_type);
4480 // below are general relocation types, which can be
4481 // handled by target-independent handlers
4482 case elfcpp::R_TILEGX_64:
4483 TilegxReloc::abs64(view, object, psymval, addend);
4486 case elfcpp::R_TILEGX_64_PCREL:
4487 TilegxReloc::pc_abs64(view, object, psymval, addend, address);
4490 case elfcpp::R_TILEGX_32:
4491 TilegxReloc::abs32(view, object, psymval, addend);
4494 case elfcpp::R_TILEGX_32_PCREL:
4495 TilegxReloc::pc_abs32(view, object, psymval, addend, address);
4498 case elfcpp::R_TILEGX_16:
4499 TilegxReloc::abs16(view, object, psymval, addend);
4502 case elfcpp::R_TILEGX_16_PCREL:
4503 TilegxReloc::pc_abs16(view, object, psymval, addend, address);
4506 case elfcpp::R_TILEGX_8:
4507 Relocate_functions<size, big_endian>::rela8(view, object,
4511 case elfcpp::R_TILEGX_8_PCREL:
4512 Relocate_functions<size, big_endian>::pcrela8(view, object,
4513 psymval, addend, address);
4516 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD:
4517 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD:
4518 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE:
4519 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE:
4520 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE:
4521 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE:
4522 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE:
4523 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE:
4524 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
4525 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
4526 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
4527 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
4528 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE:
4529 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE:
4530 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE:
4531 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE:
4532 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE:
4533 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE:
4534 case elfcpp::R_TILEGX_TLS_GD_CALL:
4535 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD:
4536 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD:
4537 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD:
4538 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD:
4539 case elfcpp::R_TILEGX_TLS_IE_LOAD:
4540 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD:
4541 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD:
4542 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD:
4543 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD:
4545 const bool is_final = (gsym == NULL
4546 ? !parameters->options().shared()
4547 : gsym->final_value_is_known());
4548 tls::Tls_optimization opt_t =
4549 Target_tilegx<size, big_endian>::optimize_tls_reloc(is_final,
4555 case elfcpp::R_TILEGX_TLS_GD_CALL:
4557 if (opt_t == tls::TLSOPT_NONE) {
4558 Symbol *tls_sym = relinfo->symtab->lookup("__tls_get_addr");
4559 symval.set_output_value(
4560 target->plt_address_for_global(tls_sym)
4561 + tls_sym->plt_offset());
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,
4737 elfcpp::SHT_RELA, Tilegx_relocate>(
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 off_t 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) + gsym->plt_offset();
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.