1 // tilegx.cc -- tilegx target support for gold.
3 // Copyright (C) 2012-2015 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 got_mod_index_offset_(-1U),
243 tls_get_addr_sym_defined_(false)
246 // Scan the relocations to look for symbol adjustments.
248 gc_process_relocs(Symbol_table
* symtab
,
250 Sized_relobj_file
<size
, big_endian
>* object
,
251 unsigned int data_shndx
,
252 unsigned int sh_type
,
253 const unsigned char* prelocs
,
255 Output_section
* output_section
,
256 bool needs_special_offset_handling
,
257 size_t local_symbol_count
,
258 const unsigned char* plocal_symbols
);
260 // Scan the relocations to look for symbol adjustments.
262 scan_relocs(Symbol_table
* symtab
,
264 Sized_relobj_file
<size
, big_endian
>* object
,
265 unsigned int data_shndx
,
266 unsigned int sh_type
,
267 const unsigned char* prelocs
,
269 Output_section
* output_section
,
270 bool needs_special_offset_handling
,
271 size_t local_symbol_count
,
272 const unsigned char* plocal_symbols
);
274 // Finalize the sections.
276 do_finalize_sections(Layout
*, const Input_objects
*, Symbol_table
*);
278 // Return the value to use for a dynamic which requires special
281 do_dynsym_value(const Symbol
*) const;
283 // Relocate a section.
285 relocate_section(const Relocate_info
<size
, big_endian
>*,
286 unsigned int sh_type
,
287 const unsigned char* prelocs
,
289 Output_section
* output_section
,
290 bool needs_special_offset_handling
,
292 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
293 section_size_type view_size
,
294 const Reloc_symbol_changes
*);
296 // Scan the relocs during a relocatable link.
298 scan_relocatable_relocs(Symbol_table
* symtab
,
300 Sized_relobj_file
<size
, big_endian
>* object
,
301 unsigned int data_shndx
,
302 unsigned int sh_type
,
303 const unsigned char* prelocs
,
305 Output_section
* output_section
,
306 bool needs_special_offset_handling
,
307 size_t local_symbol_count
,
308 const unsigned char* plocal_symbols
,
309 Relocatable_relocs
*);
311 // Relocate a section during a relocatable link.
314 const Relocate_info
<size
, big_endian
>*,
315 unsigned int sh_type
,
316 const unsigned char* prelocs
,
318 Output_section
* output_section
,
319 typename
elfcpp::Elf_types
<size
>::Elf_Off offset_in_output_section
,
320 const Relocatable_relocs
*,
322 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
323 section_size_type view_size
,
324 unsigned char* reloc_view
,
325 section_size_type reloc_view_size
);
327 // Return whether SYM is defined by the ABI.
329 do_is_defined_by_abi(const Symbol
* sym
) const
330 { return strcmp(sym
->name(), "__tls_get_addr") == 0; }
332 // define tilegx specific symbols
334 do_define_standard_symbols(Symbol_table
*, Layout
*);
336 // Return the PLT section.
338 do_plt_address_for_global(const Symbol
* gsym
) const
339 { return this->plt_section()->address_for_global(gsym
); }
342 do_plt_address_for_local(const Relobj
* relobj
, unsigned int symndx
) const
343 { return this->plt_section()->address_for_local(relobj
, symndx
); }
345 // This function should be defined in targets that can use relocation
346 // types to determine (implemented in local_reloc_may_be_function_pointer
347 // and global_reloc_may_be_function_pointer)
348 // if a function's pointer is taken. ICF uses this in safe mode to only
349 // fold those functions whose pointer is defintely not taken. For tilegx
350 // pie binaries, safe ICF cannot be done by looking at relocation types.
352 do_can_check_for_function_pointers() const
355 // Return the base for a DW_EH_PE_datarel encoding.
357 do_ehframe_datarel_base() const;
359 // Return whether there is a GOT section.
361 has_got_section() const
362 { return this->got_
!= NULL
; }
364 // Return the size of the GOT section.
368 gold_assert(this->got_
!= NULL
);
369 return this->got_
->data_size();
372 // Return the number of entries in the GOT.
374 got_entry_count() const
376 if (this->got_
== NULL
)
378 return this->got_size() / (size
/ 8);
381 // Return the number of entries in the PLT.
383 plt_entry_count() const;
385 // Return the offset of the first non-reserved PLT entry.
387 first_plt_entry_offset() const;
389 // Return the size of each PLT entry.
391 plt_entry_size() const;
393 // Create the GOT section for an incremental update.
394 Output_data_got_base
*
395 init_got_plt_for_update(Symbol_table
* symtab
,
397 unsigned int got_count
,
398 unsigned int plt_count
);
400 // Reserve a GOT entry for a local symbol, and regenerate any
401 // necessary dynamic relocations.
403 reserve_local_got_entry(unsigned int got_index
,
404 Sized_relobj
<size
, big_endian
>* obj
,
406 unsigned int got_type
);
408 // Reserve a GOT entry for a global symbol, and regenerate any
409 // necessary dynamic relocations.
411 reserve_global_got_entry(unsigned int got_index
, Symbol
* gsym
,
412 unsigned int got_type
);
414 // Register an existing PLT entry for a global symbol.
416 register_global_plt_entry(Symbol_table
*, Layout
*, unsigned int plt_index
,
419 // Force a COPY relocation for a given symbol.
421 emit_copy_reloc(Symbol_table
*, Symbol
*, Output_section
*, off_t
);
423 // Apply an incremental relocation.
425 apply_relocation(const Relocate_info
<size
, big_endian
>* relinfo
,
426 typename
elfcpp::Elf_types
<size
>::Elf_Addr r_offset
,
428 typename
elfcpp::Elf_types
<size
>::Elf_Swxword r_addend
,
431 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
432 section_size_type view_size
);
435 // The class which scans relocations.
440 : issued_non_pic_error_(false)
444 get_reference_flags(unsigned int r_type
);
447 local(Symbol_table
* symtab
, Layout
* layout
, Target_tilegx
* target
,
448 Sized_relobj_file
<size
, big_endian
>* object
,
449 unsigned int data_shndx
,
450 Output_section
* output_section
,
451 const elfcpp::Rela
<size
, big_endian
>& reloc
, unsigned int r_type
,
452 const elfcpp::Sym
<size
, big_endian
>& lsym
,
456 global(Symbol_table
* symtab
, Layout
* layout
, Target_tilegx
* target
,
457 Sized_relobj_file
<size
, big_endian
>* object
,
458 unsigned int data_shndx
,
459 Output_section
* output_section
,
460 const elfcpp::Rela
<size
, big_endian
>& reloc
, unsigned int r_type
,
464 local_reloc_may_be_function_pointer(Symbol_table
* symtab
, Layout
* layout
,
465 Target_tilegx
* target
,
466 Sized_relobj_file
<size
, big_endian
>* object
,
467 unsigned int data_shndx
,
468 Output_section
* output_section
,
469 const elfcpp::Rela
<size
, big_endian
>& reloc
,
471 const elfcpp::Sym
<size
, big_endian
>& lsym
);
474 global_reloc_may_be_function_pointer(Symbol_table
* symtab
, Layout
* layout
,
475 Target_tilegx
* target
,
476 Sized_relobj_file
<size
, big_endian
>* object
,
477 unsigned int data_shndx
,
478 Output_section
* output_section
,
479 const elfcpp::Rela
<size
, big_endian
>& reloc
,
485 unsupported_reloc_local(Sized_relobj_file
<size
, big_endian
>*,
486 unsigned int r_type
);
489 unsupported_reloc_global(Sized_relobj_file
<size
, big_endian
>*,
490 unsigned int r_type
, Symbol
*);
493 check_non_pic(Relobj
*, unsigned int r_type
);
496 possible_function_pointer_reloc(unsigned int r_type
);
499 reloc_needs_plt_for_ifunc(Sized_relobj_file
<size
, big_endian
>*,
500 unsigned int r_type
);
502 // Whether we have issued an error about a non-PIC compilation.
503 bool issued_non_pic_error_
;
506 // The class which implements relocation.
517 // Do a relocation. Return false if the caller should not issue
518 // any warnings about this relocation.
520 relocate(const Relocate_info
<size
, big_endian
>*, Target_tilegx
*,
522 size_t relnum
, const elfcpp::Rela
<size
, big_endian
>&,
523 unsigned int r_type
, const Sized_symbol
<size
>*,
524 const Symbol_value
<size
>*,
525 unsigned char*, typename
elfcpp::Elf_types
<size
>::Elf_Addr
,
529 // A class which returns the size required for a relocation type,
530 // used while scanning relocs during a relocatable link.
531 class Relocatable_size_for_reloc
535 get_size_for_reloc(unsigned int, Relobj
*);
538 // Adjust TLS relocation type based on the options and whether this
539 // is a local symbol.
540 static tls::Tls_optimization
541 optimize_tls_reloc(bool is_final
, int r_type
);
543 // Get the GOT section, creating it if necessary.
544 Output_data_got
<size
, big_endian
>*
545 got_section(Symbol_table
*, Layout
*);
547 // Get the GOT PLT section.
549 got_plt_section() const
551 gold_assert(this->got_plt_
!= NULL
);
552 return this->got_plt_
;
555 // Create the PLT section.
557 make_plt_section(Symbol_table
* symtab
, Layout
* layout
);
559 // Create a PLT entry for a global symbol.
561 make_plt_entry(Symbol_table
*, Layout
*, Symbol
*);
563 // Create a PLT entry for a local STT_GNU_IFUNC symbol.
565 make_local_ifunc_plt_entry(Symbol_table
*, Layout
*,
566 Sized_relobj_file
<size
, big_endian
>* relobj
,
567 unsigned int local_sym_index
);
569 // Create a GOT entry for the TLS module index.
571 got_mod_index_entry(Symbol_table
* symtab
, Layout
* layout
,
572 Sized_relobj_file
<size
, big_endian
>* object
);
574 // Get the PLT section.
575 Output_data_plt_tilegx
<size
, big_endian
>*
578 gold_assert(this->plt_
!= NULL
);
582 // Get the dynamic reloc section, creating it if necessary.
584 rela_dyn_section(Layout
*);
586 // Get the section to use for IRELATIVE relocations.
588 rela_irelative_section(Layout
*);
590 // Add a potential copy relocation.
592 copy_reloc(Symbol_table
* symtab
, Layout
* layout
,
593 Sized_relobj_file
<size
, big_endian
>* object
,
594 unsigned int shndx
, Output_section
* output_section
,
595 Symbol
* sym
, const elfcpp::Rela
<size
, big_endian
>& reloc
)
597 this->copy_relocs_
.copy_reloc(symtab
, layout
,
598 symtab
->get_sized_symbol
<size
>(sym
),
599 object
, shndx
, output_section
,
600 reloc
, this->rela_dyn_section(layout
));
603 // Information about this specific target which we pass to the
604 // general Target structure.
605 static const Target::Target_info tilegx_info
;
607 // The types of GOT entries needed for this platform.
608 // These values are exposed to the ABI in an incremental link.
609 // Do not renumber existing values without changing the version
610 // number of the .gnu_incremental_inputs section.
613 GOT_TYPE_STANDARD
= 0, // GOT entry for a regular symbol
614 GOT_TYPE_TLS_OFFSET
= 1, // GOT entry for TLS offset
615 GOT_TYPE_TLS_PAIR
= 2, // GOT entry for TLS module/offset pair
616 GOT_TYPE_TLS_DESC
= 3 // GOT entry for TLS_DESC pair
619 // This type is used as the argument to the target specific
620 // relocation routines. The only target specific reloc is
621 // R_X86_64_TLSDESC against a local symbol.
624 Tlsdesc_info(Sized_relobj_file
<size
, big_endian
>* a_object
,
625 unsigned int a_r_sym
)
626 : object(a_object
), r_sym(a_r_sym
)
629 // The object in which the local symbol is defined.
630 Sized_relobj_file
<size
, big_endian
>* object
;
631 // The local symbol index in the object.
636 Output_data_got
<size
, big_endian
>* got_
;
638 Output_data_plt_tilegx
<size
, big_endian
>* plt_
;
639 // The GOT PLT section.
640 Output_data_space
* got_plt_
;
641 // The GOT section for IRELATIVE relocations.
642 Output_data_space
* got_irelative_
;
643 // The _GLOBAL_OFFSET_TABLE_ symbol.
644 Symbol
* global_offset_table_
;
645 // The _TILEGX_DYNAMIC_ symbol.
646 Symbol
* tilegx_dynamic_
;
647 // The dynamic reloc section.
648 Reloc_section
* rela_dyn_
;
649 // The section to use for IRELATIVE relocs.
650 Reloc_section
* rela_irelative_
;
651 // Relocs saved to avoid a COPY reloc.
652 Copy_relocs
<elfcpp::SHT_RELA
, size
, big_endian
> copy_relocs_
;
653 // Offset of the GOT entry for the TLS module index.
654 unsigned int got_mod_index_offset_
;
655 // True if the _tls_get_addr symbol has been defined.
656 bool tls_get_addr_sym_defined_
;
660 const Target::Target_info Target_tilegx
<64, false>::tilegx_info
=
663 false, // is_big_endian
664 elfcpp::EM_TILEGX
, // machine_code
665 false, // has_make_symbol
666 false, // has_resolve
667 false, // has_code_fill
668 true, // is_default_stack_executable
669 false, // can_icf_inline_merge_sections
671 "/lib/ld.so.1", // program interpreter
672 0x10000, // default_text_segment_address
673 0x10000, // abi_pagesize (overridable by -z max-page-size)
674 0x10000, // common_pagesize (overridable by -z common-page-size)
675 false, // isolate_execinstr
677 elfcpp::SHN_UNDEF
, // small_common_shndx
678 elfcpp::SHN_UNDEF
, // large_common_shndx
679 0, // small_common_section_flags
680 0, // large_common_section_flags
681 NULL
, // attributes_section
682 NULL
, // attributes_vendor
683 "_start", // entry_symbol_name
684 32, // hash_entry_size
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
711 "_start", // entry_symbol_name
712 32, // hash_entry_size
716 const Target::Target_info Target_tilegx
<64, true>::tilegx_info
=
719 true, // is_big_endian
720 elfcpp::EM_TILEGX
, // machine_code
721 false, // has_make_symbol
722 false, // has_resolve
723 false, // has_code_fill
724 true, // is_default_stack_executable
725 false, // can_icf_inline_merge_sections
727 "/lib/ld.so.1", // program interpreter
728 0x10000, // default_text_segment_address
729 0x10000, // abi_pagesize (overridable by -z max-page-size)
730 0x10000, // common_pagesize (overridable by -z common-page-size)
731 false, // isolate_execinstr
733 elfcpp::SHN_UNDEF
, // small_common_shndx
734 elfcpp::SHN_UNDEF
, // large_common_shndx
735 0, // small_common_section_flags
736 0, // large_common_section_flags
737 NULL
, // attributes_section
738 NULL
, // attributes_vendor
739 "_start", // entry_symbol_name
740 32, // hash_entry_size
744 const Target::Target_info Target_tilegx
<32, true>::tilegx_info
=
747 true, // is_big_endian
748 elfcpp::EM_TILEGX
, // machine_code
749 false, // has_make_symbol
750 false, // has_resolve
751 false, // has_code_fill
752 true, // is_default_stack_executable
753 false, // can_icf_inline_merge_sections
755 "/lib32/ld.so.1", // program interpreter
756 0x10000, // default_text_segment_address
757 0x10000, // abi_pagesize (overridable by -z max-page-size)
758 0x10000, // common_pagesize (overridable by -z common-page-size)
759 false, // isolate_execinstr
761 elfcpp::SHN_UNDEF
, // small_common_shndx
762 elfcpp::SHN_UNDEF
, // large_common_shndx
763 0, // small_common_section_flags
764 0, // large_common_section_flags
765 NULL
, // attributes_section
766 NULL
, // attributes_vendor
767 "_start", // entry_symbol_name
768 32, // hash_entry_size
771 // tilegx relocation handlers
772 template<int size
, bool big_endian
>
773 class Tilegx_relocate_functions
776 // overflow check will be supported later
779 STATUS_OKAY
, // No error during relocation.
780 STATUS_OVERFLOW
, // Relocation overflow.
781 STATUS_BAD_RELOC
// Relocation cannot be applied.
786 // right shift operand by this number of bits.
787 unsigned char srshift
;
789 // the offset to apply relocation.
790 unsigned char doffset
;
792 // set to 1 for pc-relative relocation.
793 unsigned char is_pcrel
;
795 // size in bits, or 0 if this table entry should be ignored.
798 // whether we need to check overflow.
799 unsigned char overflow
;
802 static const Tilegx_howto howto
[elfcpp::R_TILEGX_NUM
];
806 // Do a simple rela relocation
807 template<int valsize
>
809 rela(unsigned char* view
,
810 const Sized_relobj_file
<size
, big_endian
>* object
,
811 const Symbol_value
<size
>* psymval
,
812 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
813 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset
,
814 elfcpp::Elf_Xword bitmask
)
816 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
817 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
818 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
821 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
)) >> srshift
;
823 reloc
= psymval
->value(object
, addend
) >> srshift
;
825 elfcpp::Elf_Xword dst_mask
= bitmask
<< doffset
;
830 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| (reloc
<<doffset
));
833 // Do a simple rela relocation
834 template<int valsize
>
836 rela_ua(unsigned char* view
,
837 const Sized_relobj_file
<size
, big_endian
>* object
,
838 const Symbol_value
<size
>* psymval
,
839 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
840 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset
,
841 elfcpp::Elf_Xword bitmask
)
843 typedef typename
elfcpp::Swap_unaligned
<valsize
, big_endian
>::Valtype
845 unsigned char* wv
= view
;
846 Valtype val
= elfcpp::Swap_unaligned
<valsize
, big_endian
>::readval(wv
);
849 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
)) >> srshift
;
851 reloc
= psymval
->value(object
, addend
) >> srshift
;
853 elfcpp::Elf_Xword dst_mask
= bitmask
<< doffset
;
858 elfcpp::Swap_unaligned
<valsize
, big_endian
>::writeval(wv
,
859 val
| (reloc
<<doffset
));
862 template<int valsize
>
864 rela(unsigned char* view
,
865 const Sized_relobj_file
<size
, big_endian
>* object
,
866 const Symbol_value
<size
>* psymval
,
867 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
868 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset1
,
869 elfcpp::Elf_Xword bitmask1
, elfcpp::Elf_Xword doffset2
,
870 elfcpp::Elf_Xword bitmask2
)
872 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
873 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
874 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
877 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
)) >> srshift
;
879 reloc
= psymval
->value(object
, addend
) >> srshift
;
881 elfcpp::Elf_Xword dst_mask
= (bitmask1
<< doffset1
)
882 | (bitmask2
<< doffset2
);
884 reloc
= ((reloc
& bitmask1
) << doffset1
)
885 | ((reloc
& bitmask2
) << doffset2
);
887 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| reloc
);
891 // Do a simple PC relative relocation with a Symbol_value with the
892 // addend in the relocation.
893 template<int valsize
>
895 pcrela(unsigned char* view
,
896 const Sized_relobj_file
<size
, big_endian
>* object
,
897 const Symbol_value
<size
>* psymval
,
898 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
899 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
900 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset
,
901 elfcpp::Elf_Xword bitmask
)
904 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
905 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
906 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
909 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
) - address
)
912 reloc
= (psymval
->value(object
, addend
) - address
) >> srshift
;
914 elfcpp::Elf_Xword dst_mask
= bitmask
<< doffset
;
918 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| (reloc
<<doffset
));
921 template<int valsize
>
923 pcrela_ua(unsigned char* view
,
924 const Sized_relobj_file
<size
, big_endian
>* object
,
925 const Symbol_value
<size
>* psymval
,
926 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
927 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
928 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset
,
929 elfcpp::Elf_Xword bitmask
)
932 typedef typename
elfcpp::Swap_unaligned
<valsize
, big_endian
>::Valtype
934 unsigned char* wv
= view
;
937 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
) - address
)
940 reloc
= (psymval
->value(object
, addend
) - address
) >> srshift
;
944 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, reloc
<< doffset
);
947 template<int valsize
>
949 pcrela(unsigned char* view
,
950 const Sized_relobj_file
<size
, big_endian
>* object
,
951 const Symbol_value
<size
>* psymval
,
952 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
953 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
954 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset1
,
955 elfcpp::Elf_Xword bitmask1
, elfcpp::Elf_Xword doffset2
,
956 elfcpp::Elf_Xword bitmask2
)
959 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
960 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
961 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
964 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
) - address
)
967 reloc
= (psymval
->value(object
, addend
) - address
) >> srshift
;
969 elfcpp::Elf_Xword dst_mask
= (bitmask1
<< doffset1
)
970 | (bitmask2
<< doffset2
);
972 reloc
= ((reloc
& bitmask1
) << doffset1
)
973 | ((reloc
& bitmask2
) << doffset2
);
975 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| reloc
);
978 typedef Tilegx_relocate_functions
<size
, big_endian
> This
;
979 typedef Relocate_functions
<size
, big_endian
> Base
;
984 abs64(unsigned char* view
,
985 const Sized_relobj_file
<size
, big_endian
>* object
,
986 const Symbol_value
<size
>* psymval
,
987 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
989 This::template rela_ua
<64>(view
, object
, psymval
, addend
, 0, 0,
990 0xffffffffffffffffllu
);
994 abs32(unsigned char* view
,
995 const Sized_relobj_file
<size
, big_endian
>* object
,
996 const Symbol_value
<size
>* psymval
,
997 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
999 This::template rela_ua
<32>(view
, object
, psymval
, addend
, 0, 0,
1004 abs16(unsigned char* view
,
1005 const Sized_relobj_file
<size
, big_endian
>* object
,
1006 const Symbol_value
<size
>* psymval
,
1007 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
1009 This::template rela_ua
<16>(view
, object
, psymval
, addend
, 0, 0,
1014 pc_abs64(unsigned char* view
,
1015 const Sized_relobj_file
<size
, big_endian
>* object
,
1016 const Symbol_value
<size
>* psymval
,
1017 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1018 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
1020 This::template pcrela_ua
<64>(view
, object
, psymval
, addend
, address
, 0, 0,
1021 0xffffffffffffffffllu
);
1025 pc_abs32(unsigned char* view
,
1026 const Sized_relobj_file
<size
, big_endian
>* object
,
1027 const Symbol_value
<size
>* psymval
,
1028 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1029 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
1031 This::template pcrela_ua
<32>(view
, object
, psymval
, addend
, address
, 0, 0,
1036 pc_abs16(unsigned char* view
,
1037 const Sized_relobj_file
<size
, big_endian
>* object
,
1038 const Symbol_value
<size
>* psymval
,
1039 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1040 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
1042 This::template pcrela_ua
<16>(view
, object
, psymval
, addend
, address
, 0, 0,
1047 imm_x_general(unsigned char* view
,
1048 const Sized_relobj_file
<size
, big_endian
>* object
,
1049 const Symbol_value
<size
>* psymval
,
1050 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1051 Tilegx_howto
&r_howto
)
1053 This::template rela
<64>(view
, object
, psymval
, addend
,
1054 (elfcpp::Elf_Xword
)(r_howto
.srshift
),
1055 (elfcpp::Elf_Xword
)(r_howto
.doffset
),
1056 (elfcpp::Elf_Xword
)((1 << r_howto
.bsize
) - 1));
1060 imm_x_pcrel_general(unsigned char* view
,
1061 const Sized_relobj_file
<size
, big_endian
>* object
,
1062 const Symbol_value
<size
>* psymval
,
1063 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1064 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
1065 Tilegx_howto
&r_howto
)
1067 This::template pcrela
<64>(view
, object
, psymval
, addend
, address
,
1068 (elfcpp::Elf_Xword
)(r_howto
.srshift
),
1069 (elfcpp::Elf_Xword
)(r_howto
.doffset
),
1070 (elfcpp::Elf_Xword
)((1 << r_howto
.bsize
) - 1));
1074 imm_x_two_part_general(unsigned char* view
,
1075 const Sized_relobj_file
<size
, big_endian
>* object
,
1076 const Symbol_value
<size
>* psymval
,
1077 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1078 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
1079 unsigned int r_type
)
1082 elfcpp::Elf_Xword doffset1
= 0llu;
1083 elfcpp::Elf_Xword doffset2
= 0llu;
1084 elfcpp::Elf_Xword dmask1
= 0llu;
1085 elfcpp::Elf_Xword dmask2
= 0llu;
1086 elfcpp::Elf_Xword rshift
= 0llu;
1087 unsigned int pc_rel
= 0;
1091 case elfcpp::R_TILEGX_BROFF_X1
:
1095 dmask2
= 0x1ffc0llu
;
1099 case elfcpp::R_TILEGX_DEST_IMM8_X1
:
1109 This::template pcrela
<64>(view
, object
, psymval
, addend
, address
,
1110 rshift
, doffset1
, dmask1
, doffset2
, dmask2
);
1112 This::template rela
<64>(view
, object
, psymval
, addend
, rshift
,
1113 doffset1
, dmask1
, doffset2
, dmask2
);
1118 tls_relax(unsigned char* view
, unsigned int r_type
,
1119 tls::Tls_optimization opt_t
)
1122 const uint64_t TILEGX_X_MOVE_R0_R0
= 0x283bf8005107f000llu
;
1123 const uint64_t TILEGX_Y_MOVE_R0_R0
= 0xae05f800540bf000llu
;
1124 const uint64_t TILEGX_X_LD
= 0x286ae80000000000llu
;
1125 const uint64_t TILEGX_X_LD4S
= 0x286a980000000000llu
;
1126 const uint64_t TILEGX_X1_FULL_MASK
= 0x3fffffff80000000llu
;
1127 const uint64_t TILEGX_X0_RRR_MASK
= 0x000000007ffc0000llu
;
1128 const uint64_t TILEGX_X1_RRR_MASK
= 0x3ffe000000000000llu
;
1129 const uint64_t TILEGX_Y0_RRR_MASK
= 0x00000000780c0000llu
;
1130 const uint64_t TILEGX_Y1_RRR_MASK
= 0x3c06000000000000llu
;
1131 const uint64_t TILEGX_X0_RRR_SRCB_MASK
= 0x000000007ffff000llu
;
1132 const uint64_t TILEGX_X1_RRR_SRCB_MASK
= 0x3ffff80000000000llu
;
1133 const uint64_t TILEGX_Y0_RRR_SRCB_MASK
= 0x00000000780ff000llu
;
1134 const uint64_t TILEGX_Y1_RRR_SRCB_MASK
= 0x3c07f80000000000llu
;
1135 const uint64_t TILEGX_X_ADD_R0_R0_TP
= 0x2807a800500f5000llu
;
1136 const uint64_t TILEGX_Y_ADD_R0_R0_TP
= 0x9a13a8002c275000llu
;
1137 const uint64_t TILEGX_X_ADDX_R0_R0_TP
= 0x2805a800500b5000llu
;
1138 const uint64_t TILEGX_Y_ADDX_R0_R0_TP
= 0x9a01a8002c035000llu
;
1140 const uint64_t R_TILEGX_IMM8_X0_TLS_ADD_MASK
=
1141 (TILEGX_X0_RRR_MASK
| (0x3Fllu
<< 12));
1143 const uint64_t R_TILEGX_IMM8_X1_TLS_ADD_MASK
=
1144 (TILEGX_X1_RRR_MASK
| (0x3Fllu
<< 43));
1146 const uint64_t R_TILEGX_IMM8_Y0_TLS_ADD_MASK
=
1147 (TILEGX_Y0_RRR_MASK
| (0x3Fllu
<< 12));
1149 const uint64_t R_TILEGX_IMM8_Y1_TLS_ADD_MASK
=
1150 (TILEGX_Y1_RRR_MASK
| (0x3Fllu
<< 43));
1152 const uint64_t R_TILEGX_IMM8_X0_TLS_ADD_LE_MASK
=
1153 (TILEGX_X0_RRR_SRCB_MASK
| (0x3Fllu
<< 6));
1155 const uint64_t R_TILEGX_IMM8_X1_TLS_ADD_LE_MASK
=
1156 (TILEGX_X1_RRR_SRCB_MASK
| (0x3Fllu
<< 37));
1158 const uint64_t R_TILEGX_IMM8_Y0_TLS_ADD_LE_MASK
=
1159 (TILEGX_Y0_RRR_SRCB_MASK
| (0x3Fllu
<< 6));
1161 const uint64_t R_TILEGX_IMM8_Y1_TLS_ADD_LE_MASK
=
1162 (TILEGX_Y1_RRR_SRCB_MASK
| (0x3Fllu
<< 37));
1164 typedef typename
elfcpp::Swap
<64, big_endian
>::Valtype Valtype
;
1165 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
1166 Valtype val
= elfcpp::Swap
<64, big_endian
>::readval(wv
);
1171 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
1172 if (opt_t
== tls::TLSOPT_NONE
) {
1173 // GD/IE: 1. copy dest operand into the second source operand
1174 // 2. change the opcode to "add"
1175 reloc
= (val
& 0x3Fllu
) << 12; // featch the dest reg
1176 reloc
|= ((size
== 32
1177 ? TILEGX_X_ADDX_R0_R0_TP
1178 : TILEGX_X_ADD_R0_R0_TP
)
1179 & TILEGX_X0_RRR_MASK
); // change opcode
1180 val
&= ~R_TILEGX_IMM8_X0_TLS_ADD_MASK
;
1181 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1182 // LE: 1. copy dest operand into the first source operand
1183 // 2. change the opcode to "move"
1184 reloc
= (val
& 0x3Fllu
) << 6;
1185 reloc
|= (TILEGX_X_MOVE_R0_R0
& TILEGX_X0_RRR_SRCB_MASK
);
1186 val
&= ~R_TILEGX_IMM8_X0_TLS_ADD_LE_MASK
;
1190 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
1191 if (opt_t
== tls::TLSOPT_NONE
) {
1192 reloc
= (val
& (0x3Fllu
<< 31)) << 12;
1193 reloc
|= ((size
== 32
1194 ? TILEGX_X_ADDX_R0_R0_TP
1195 : TILEGX_X_ADD_R0_R0_TP
)
1196 & TILEGX_X1_RRR_MASK
);
1197 val
&= ~R_TILEGX_IMM8_X1_TLS_ADD_MASK
;
1198 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1199 reloc
= (val
& (0x3Fllu
<< 31)) << 6;
1200 reloc
|= (TILEGX_X_MOVE_R0_R0
& TILEGX_X1_RRR_SRCB_MASK
);
1201 val
&= ~R_TILEGX_IMM8_X1_TLS_ADD_LE_MASK
;
1205 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
1206 if (opt_t
== tls::TLSOPT_NONE
) {
1207 reloc
= (val
& 0x3Fllu
) << 12;
1208 reloc
|= ((size
== 32
1209 ? TILEGX_Y_ADDX_R0_R0_TP
1210 : TILEGX_Y_ADD_R0_R0_TP
)
1211 & TILEGX_Y0_RRR_MASK
);
1212 val
&= ~R_TILEGX_IMM8_Y0_TLS_ADD_MASK
;
1213 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1214 reloc
= (val
& 0x3Fllu
) << 6;
1215 reloc
|= (TILEGX_Y_MOVE_R0_R0
& TILEGX_Y0_RRR_SRCB_MASK
);
1216 val
&= ~R_TILEGX_IMM8_Y0_TLS_ADD_LE_MASK
;
1220 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
1221 if (opt_t
== tls::TLSOPT_NONE
) {
1222 reloc
= (val
& (0x3Fllu
<< 31)) << 12;
1223 reloc
|= ((size
== 32
1224 ? TILEGX_Y_ADDX_R0_R0_TP
1225 : TILEGX_Y_ADD_R0_R0_TP
)
1226 & TILEGX_Y1_RRR_MASK
);
1227 val
&= ~R_TILEGX_IMM8_Y1_TLS_ADD_MASK
;
1228 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1229 reloc
= (val
& (0x3Fllu
<< 31)) << 6;
1230 reloc
|= (TILEGX_Y_MOVE_R0_R0
& TILEGX_Y1_RRR_SRCB_MASK
);
1231 val
&= ~R_TILEGX_IMM8_Y1_TLS_ADD_LE_MASK
;
1235 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
1236 if (opt_t
== tls::TLSOPT_NONE
) {
1237 // GD see comments for optimize_tls_reloc
1238 reloc
= TILEGX_X_MOVE_R0_R0
& TILEGX_X0_RRR_SRCB_MASK
;
1239 val
&= ~TILEGX_X0_RRR_SRCB_MASK
;
1240 } else if (opt_t
== tls::TLSOPT_TO_IE
1241 || opt_t
== tls::TLSOPT_TO_LE
) {
1244 ? TILEGX_X_ADDX_R0_R0_TP
1245 : TILEGX_X_ADD_R0_R0_TP
)
1246 & TILEGX_X0_RRR_SRCB_MASK
;
1247 val
&= ~TILEGX_X0_RRR_SRCB_MASK
;
1250 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
1251 if (opt_t
== tls::TLSOPT_NONE
) {
1252 reloc
= TILEGX_X_MOVE_R0_R0
& TILEGX_X1_RRR_SRCB_MASK
;
1253 val
&= ~TILEGX_X1_RRR_SRCB_MASK
;
1254 } else if (opt_t
== tls::TLSOPT_TO_IE
1255 || opt_t
== tls::TLSOPT_TO_LE
) {
1257 ? TILEGX_X_ADDX_R0_R0_TP
1258 : TILEGX_X_ADD_R0_R0_TP
)
1259 & TILEGX_X1_RRR_SRCB_MASK
;
1260 val
&= ~TILEGX_X1_RRR_SRCB_MASK
;
1263 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
1264 if (opt_t
== tls::TLSOPT_NONE
) {
1265 reloc
= TILEGX_Y_MOVE_R0_R0
& TILEGX_Y0_RRR_SRCB_MASK
;
1266 val
&= ~TILEGX_Y0_RRR_SRCB_MASK
;
1267 } else if (opt_t
== tls::TLSOPT_TO_IE
1268 || opt_t
== tls::TLSOPT_TO_LE
) {
1270 ? TILEGX_Y_ADDX_R0_R0_TP
1271 : TILEGX_Y_ADD_R0_R0_TP
)
1272 & TILEGX_Y0_RRR_SRCB_MASK
;
1273 val
&= ~TILEGX_Y0_RRR_SRCB_MASK
;
1276 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
1277 if (opt_t
== tls::TLSOPT_NONE
) {
1278 reloc
= TILEGX_Y_MOVE_R0_R0
& TILEGX_Y1_RRR_SRCB_MASK
;
1279 val
&= ~TILEGX_Y1_RRR_SRCB_MASK
;
1280 } else if (opt_t
== tls::TLSOPT_TO_IE
1281 || opt_t
== tls::TLSOPT_TO_LE
) {
1283 ? TILEGX_Y_ADDX_R0_R0_TP
1284 : TILEGX_Y_ADD_R0_R0_TP
)
1285 & TILEGX_Y1_RRR_SRCB_MASK
;
1286 val
&= ~TILEGX_Y1_RRR_SRCB_MASK
;
1289 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
1290 if (opt_t
== tls::TLSOPT_NONE
) {
1295 & TILEGX_X1_RRR_SRCB_MASK
;
1296 val
&= ~TILEGX_X1_RRR_SRCB_MASK
;
1297 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1299 reloc
= TILEGX_X_MOVE_R0_R0
& TILEGX_X1_RRR_SRCB_MASK
;
1300 val
&= ~TILEGX_X1_RRR_SRCB_MASK
;
1304 case elfcpp::R_TILEGX_TLS_GD_CALL
:
1305 if (opt_t
== tls::TLSOPT_TO_IE
) {
1309 : TILEGX_X_LD
) & TILEGX_X1_FULL_MASK
;
1310 val
&= ~TILEGX_X1_FULL_MASK
;
1311 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1313 reloc
= TILEGX_X_MOVE_R0_R0
& TILEGX_X1_FULL_MASK
;
1314 val
&= ~TILEGX_X1_FULL_MASK
;
1316 // should be handled in ::relocate
1323 elfcpp::Swap
<64, big_endian
>::writeval(wv
, val
| reloc
);
1328 const Tilegx_relocate_functions
<64, false>::Tilegx_howto
1329 Tilegx_relocate_functions
<64, false>::howto
[elfcpp::R_TILEGX_NUM
] =
1331 { 0, 0, 0, 0, 0}, // R_TILEGX_NONE
1332 { 0, 0, 0, 64, 0}, // R_TILEGX_64
1333 { 0, 0, 0, 32, 0}, // R_TILEGX_32
1334 { 0, 0, 0, 16, 0}, // R_TILEGX_16
1335 { 0, 0, 0, 8, 0}, // R_TILEGX_8
1336 { 0, 0, 1, 64, 0}, // R_TILEGX_64_PCREL
1337 { 0, 0, 1, 32, 0}, // R_TILEGX_32_PCREL
1338 { 0, 0, 1, 16, 0}, // R_TILEGX_16_PCREL
1339 { 0, 0, 1, 8, 0}, // R_TILEGX_8_PCREL
1340 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0
1341 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1
1342 { 32, 0, 0, 0, 0}, // R_TILEGX_HW2
1343 { 48, 0, 0, 0, 0}, // R_TILEGX_HW3
1344 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0_LAST
1345 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1_LAST
1346 { 32, 0, 0, 0, 0}, // R_TILEGX_HW2_LAST
1347 { 0, 0, 0, 0, 0}, // R_TILEGX_COPY
1348 { 0, 0, 0, 8, 0}, // R_TILEGX_GLOB_DAT
1349 { 0, 0, 0, 0, 0}, // R_TILEGX_JMP_SLOT
1350 { 0, 0, 0, 0, 0}, // R_TILEGX_RELATIVE
1351 { 3, 1, 1, 0, 0}, // R_TILEGX_BROFF_X1
1352 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1
1353 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1_PLT
1354 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X0
1355 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y0
1356 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X1
1357 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y1
1358 { 0, 1, 0, 8, 0}, // R_TILEGX_DEST_IMM8_X1
1359 { 0, 1, 0, 8, 0}, // R_TILEGX_MT_IMM14_X1
1360 { 0, 1, 0, 8, 0}, // R_TILEGX_MF_IMM14_X1
1361 { 0, 1, 0, 8, 0}, // R_TILEGX_MMSTART_X0
1362 { 0, 1, 0, 8, 0}, // R_TILEGX_MMEND_X0
1363 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X0
1364 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X1
1365 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y0
1366 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y1
1367 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0
1368 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0
1369 { 16, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW1
1370 { 16, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW1
1371 { 32, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW2
1372 { 32, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW2
1373 { 48, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW3
1374 { 48, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW3
1375 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST
1376 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST
1377 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST
1378 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST
1379 { 32, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST
1380 { 32, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST
1381 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PCREL
1382 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PCREL
1383 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PCREL
1384 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PCREL
1385 { 32, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PCREL
1386 { 32, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PCREL
1387 { 48, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW3_PCREL
1388 { 48, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW3_PCREL
1389 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PCREL
1390 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PCREL
1391 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PCREL
1392 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PCREL
1393 { 32, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PCREL
1394 { 32, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PCREL
1395 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_GOT
1396 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_GOT
1397 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PLT_PCREL
1398 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PLT_PCREL
1399 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PLT_PCREL
1400 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PLT_PCREL
1401 { 32, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PLT_PCREL
1402 { 32, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PLT_PCREL
1403 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_GOT
1404 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_GOT
1405 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_GOT
1406 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_GOT
1407 { 32, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_GOT
1408 { 32, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_GOT
1409 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_GD
1410 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_GD
1411 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_LE
1412 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_LE
1413 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
1414 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
1415 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
1416 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
1417 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
1418 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
1419 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
1420 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
1421 { 0, 0, 0, 0, 0}, // R_TILEGX_IRELATIVE
1422 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1423 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_IE
1424 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_IE
1425 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
1426 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
1427 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
1428 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
1429 { 32, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
1430 { 32, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
1431 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
1432 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
1433 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
1434 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
1435 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1436 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1437 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD64
1438 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF64
1439 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF64
1440 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD32
1441 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF32
1442 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF32
1443 { 3, 31, 1, 27, 0}, // R_TILEGX_TLS_GD_CALL
1444 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_GD_ADD
1445 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_GD_ADD
1446 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_GD_ADD
1447 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_GD_ADD
1448 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_IE_LOAD
1449 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_ADD
1450 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_ADD
1451 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_ADD
1452 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_ADD
1453 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTINHERIT
1454 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTENTRY
1458 const Tilegx_relocate_functions
<32, false>::Tilegx_howto
1459 Tilegx_relocate_functions
<32, false>::howto
[elfcpp::R_TILEGX_NUM
] =
1461 { 0, 0, 0, 0, 0}, // R_TILEGX_NONE
1462 { 0, 0, 0, 64, 0}, // R_TILEGX_64
1463 { 0, 0, 0, 32, 0}, // R_TILEGX_32
1464 { 0, 0, 0, 16, 0}, // R_TILEGX_16
1465 { 0, 0, 0, 8, 0}, // R_TILEGX_8
1466 { 0, 0, 1, 64, 0}, // R_TILEGX_64_PCREL
1467 { 0, 0, 1, 32, 0}, // R_TILEGX_32_PCREL
1468 { 0, 0, 1, 16, 0}, // R_TILEGX_16_PCREL
1469 { 0, 0, 1, 8, 0}, // R_TILEGX_8_PCREL
1470 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0
1471 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1
1472 { 31, 0, 0, 0, 0}, // R_TILEGX_HW2
1473 { 31, 0, 0, 0, 0}, // R_TILEGX_HW3
1474 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0_LAST
1475 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1_LAST
1476 { 31, 0, 0, 0, 0}, // R_TILEGX_HW2_LAST
1477 { 0, 0, 0, 0, 0}, // R_TILEGX_COPY
1478 { 0, 0, 0, 8, 0}, // R_TILEGX_GLOB_DAT
1479 { 0, 0, 0, 0, 0}, // R_TILEGX_JMP_SLOT
1480 { 0, 0, 0, 0, 0}, // R_TILEGX_RELATIVE
1481 { 3, 1, 1, 0, 0}, // R_TILEGX_BROFF_X1
1482 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1
1483 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1_PLT
1484 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X0
1485 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y0
1486 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X1
1487 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y1
1488 { 0, 1, 0, 8, 0}, // R_TILEGX_DEST_IMM8_X1
1489 { 0, 1, 0, 8, 0}, // R_TILEGX_MT_IMM14_X1
1490 { 0, 1, 0, 8, 0}, // R_TILEGX_MF_IMM14_X1
1491 { 0, 1, 0, 8, 0}, // R_TILEGX_MMSTART_X0
1492 { 0, 1, 0, 8, 0}, // R_TILEGX_MMEND_X0
1493 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X0
1494 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X1
1495 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y0
1496 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y1
1497 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0
1498 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0
1499 { 16, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW1
1500 { 16, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW1
1501 { 31, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW2
1502 { 31, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW2
1503 { 31, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW3
1504 { 31, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW3
1505 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST
1506 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST
1507 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST
1508 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST
1509 { 31, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST
1510 { 31, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST
1511 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PCREL
1512 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PCREL
1513 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PCREL
1514 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PCREL
1515 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PCREL
1516 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PCREL
1517 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW3_PCREL
1518 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW3_PCREL
1519 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PCREL
1520 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PCREL
1521 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PCREL
1522 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PCREL
1523 { 31, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PCREL
1524 { 31, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PCREL
1525 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_GOT
1526 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_GOT
1527 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PLT_PCREL
1528 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PLT_PCREL
1529 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PLT_PCREL
1530 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PLT_PCREL
1531 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PLT_PCREL
1532 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PLT_PCREL
1533 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_GOT
1534 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_GOT
1535 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_GOT
1536 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_GOT
1537 { 31, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_GOT
1538 { 31, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_GOT
1539 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_GD
1540 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_GD
1541 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_LE
1542 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_LE
1543 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
1544 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
1545 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
1546 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
1547 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
1548 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
1549 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
1550 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
1551 { 0, 0, 0, 0, 0}, // R_TILEGX_IRELATIVE
1552 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1553 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_IE
1554 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_IE
1555 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
1556 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
1557 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
1558 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
1559 { 31, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
1560 { 31, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
1561 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
1562 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
1563 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
1564 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
1565 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1566 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1567 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD64
1568 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF64
1569 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF64
1570 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD32
1571 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF32
1572 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF32
1573 { 3, 31, 1, 27, 0}, // R_TILEGX_TLS_GD_CALL
1574 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_GD_ADD
1575 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_GD_ADD
1576 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_GD_ADD
1577 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_GD_ADD
1578 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_IE_LOAD
1579 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_ADD
1580 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_ADD
1581 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_ADD
1582 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_ADD
1583 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTINHERIT
1584 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTENTRY
1588 const Tilegx_relocate_functions
<64, true>::Tilegx_howto
1589 Tilegx_relocate_functions
<64, true>::howto
[elfcpp::R_TILEGX_NUM
] =
1591 { 0, 0, 0, 0, 0}, // R_TILEGX_NONE
1592 { 0, 0, 0, 64, 0}, // R_TILEGX_64
1593 { 0, 0, 0, 32, 0}, // R_TILEGX_32
1594 { 0, 0, 0, 16, 0}, // R_TILEGX_16
1595 { 0, 0, 0, 8, 0}, // R_TILEGX_8
1596 { 0, 0, 1, 64, 0}, // R_TILEGX_64_PCREL
1597 { 0, 0, 1, 32, 0}, // R_TILEGX_32_PCREL
1598 { 0, 0, 1, 16, 0}, // R_TILEGX_16_PCREL
1599 { 0, 0, 1, 8, 0}, // R_TILEGX_8_PCREL
1600 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0
1601 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1
1602 { 32, 0, 0, 0, 0}, // R_TILEGX_HW2
1603 { 48, 0, 0, 0, 0}, // R_TILEGX_HW3
1604 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0_LAST
1605 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1_LAST
1606 { 32, 0, 0, 0, 0}, // R_TILEGX_HW2_LAST
1607 { 0, 0, 0, 0, 0}, // R_TILEGX_COPY
1608 { 0, 0, 0, 8, 0}, // R_TILEGX_GLOB_DAT
1609 { 0, 0, 0, 0, 0}, // R_TILEGX_JMP_SLOT
1610 { 0, 0, 0, 0, 0}, // R_TILEGX_RELATIVE
1611 { 3, 1, 1, 0, 0}, // R_TILEGX_BROFF_X1
1612 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1
1613 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1_PLT
1614 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X0
1615 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y0
1616 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X1
1617 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y1
1618 { 0, 1, 0, 8, 0}, // R_TILEGX_DEST_IMM8_X1
1619 { 0, 1, 0, 8, 0}, // R_TILEGX_MT_IMM14_X1
1620 { 0, 1, 0, 8, 0}, // R_TILEGX_MF_IMM14_X1
1621 { 0, 1, 0, 8, 0}, // R_TILEGX_MMSTART_X0
1622 { 0, 1, 0, 8, 0}, // R_TILEGX_MMEND_X0
1623 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X0
1624 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X1
1625 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y0
1626 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y1
1627 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0
1628 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0
1629 { 16, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW1
1630 { 16, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW1
1631 { 32, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW2
1632 { 32, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW2
1633 { 48, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW3
1634 { 48, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW3
1635 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST
1636 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST
1637 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST
1638 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST
1639 { 32, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST
1640 { 32, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST
1641 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PCREL
1642 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PCREL
1643 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PCREL
1644 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PCREL
1645 { 32, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PCREL
1646 { 32, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PCREL
1647 { 48, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW3_PCREL
1648 { 48, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW3_PCREL
1649 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PCREL
1650 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PCREL
1651 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PCREL
1652 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PCREL
1653 { 32, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PCREL
1654 { 32, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PCREL
1655 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_GOT
1656 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_GOT
1657 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PLT_PCREL
1658 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PLT_PCREL
1659 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PLT_PCREL
1660 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PLT_PCREL
1661 { 32, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PLT_PCREL
1662 { 32, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PLT_PCREL
1663 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_GOT
1664 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_GOT
1665 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_GOT
1666 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_GOT
1667 { 32, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_GOT
1668 { 32, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_GOT
1669 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_GD
1670 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_GD
1671 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_LE
1672 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_LE
1673 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
1674 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
1675 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
1676 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
1677 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
1678 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
1679 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
1680 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
1681 { 0, 0, 0, 0, 0}, // R_TILEGX_IRELATIVE
1682 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1683 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_IE
1684 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_IE
1685 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
1686 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
1687 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
1688 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
1689 { 32, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
1690 { 32, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
1691 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
1692 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
1693 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
1694 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
1695 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1696 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1697 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD64
1698 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF64
1699 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF64
1700 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD32
1701 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF32
1702 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF32
1703 { 3, 31, 1, 27, 0}, // R_TILEGX_TLS_GD_CALL
1704 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_GD_ADD
1705 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_GD_ADD
1706 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_GD_ADD
1707 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_GD_ADD
1708 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_IE_LOAD
1709 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_ADD
1710 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_ADD
1711 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_ADD
1712 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_ADD
1713 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTINHERIT
1714 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTENTRY
1718 const Tilegx_relocate_functions
<32, true>::Tilegx_howto
1719 Tilegx_relocate_functions
<32, true>::howto
[elfcpp::R_TILEGX_NUM
] =
1721 { 0, 0, 0, 0, 0}, // R_TILEGX_NONE
1722 { 0, 0, 0, 64, 0}, // R_TILEGX_64
1723 { 0, 0, 0, 32, 0}, // R_TILEGX_32
1724 { 0, 0, 0, 16, 0}, // R_TILEGX_16
1725 { 0, 0, 0, 8, 0}, // R_TILEGX_8
1726 { 0, 0, 1, 64, 0}, // R_TILEGX_64_PCREL
1727 { 0, 0, 1, 32, 0}, // R_TILEGX_32_PCREL
1728 { 0, 0, 1, 16, 0}, // R_TILEGX_16_PCREL
1729 { 0, 0, 1, 8, 0}, // R_TILEGX_8_PCREL
1730 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0
1731 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1
1732 { 31, 0, 0, 0, 0}, // R_TILEGX_HW2
1733 { 31, 0, 0, 0, 0}, // R_TILEGX_HW3
1734 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0_LAST
1735 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1_LAST
1736 { 31, 0, 0, 0, 0}, // R_TILEGX_HW2_LAST
1737 { 0, 0, 0, 0, 0}, // R_TILEGX_COPY
1738 { 0, 0, 0, 8, 0}, // R_TILEGX_GLOB_DAT
1739 { 0, 0, 0, 0, 0}, // R_TILEGX_JMP_SLOT
1740 { 0, 0, 0, 0, 0}, // R_TILEGX_RELATIVE
1741 { 3, 1, 1, 0, 0}, // R_TILEGX_BROFF_X1
1742 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1
1743 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1_PLT
1744 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X0
1745 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y0
1746 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X1
1747 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y1
1748 { 0, 1, 0, 8, 0}, // R_TILEGX_DEST_IMM8_X1
1749 { 0, 1, 0, 8, 0}, // R_TILEGX_MT_IMM14_X1
1750 { 0, 1, 0, 8, 0}, // R_TILEGX_MF_IMM14_X1
1751 { 0, 1, 0, 8, 0}, // R_TILEGX_MMSTART_X0
1752 { 0, 1, 0, 8, 0}, // R_TILEGX_MMEND_X0
1753 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X0
1754 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X1
1755 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y0
1756 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y1
1757 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0
1758 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0
1759 { 16, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW1
1760 { 16, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW1
1761 { 31, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW2
1762 { 31, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW2
1763 { 31, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW3
1764 { 31, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW3
1765 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST
1766 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST
1767 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST
1768 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST
1769 { 31, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST
1770 { 31, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST
1771 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PCREL
1772 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PCREL
1773 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PCREL
1774 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PCREL
1775 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PCREL
1776 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PCREL
1777 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW3_PCREL
1778 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW3_PCREL
1779 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PCREL
1780 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PCREL
1781 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PCREL
1782 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PCREL
1783 { 31, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PCREL
1784 { 31, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PCREL
1785 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_GOT
1786 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_GOT
1787 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PLT_PCREL
1788 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PLT_PCREL
1789 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PLT_PCREL
1790 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PLT_PCREL
1791 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PLT_PCREL
1792 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PLT_PCREL
1793 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_GOT
1794 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_GOT
1795 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_GOT
1796 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_GOT
1797 { 31, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_GOT
1798 { 31, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_GOT
1799 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_GD
1800 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_GD
1801 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_LE
1802 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_LE
1803 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
1804 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
1805 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
1806 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
1807 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
1808 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
1809 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
1810 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
1811 { 0, 0, 0, 0, 0}, // R_TILEGX_IRELATIVE
1812 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1813 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_IE
1814 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_IE
1815 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
1816 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
1817 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
1818 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
1819 { 31, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
1820 { 31, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
1821 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
1822 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
1823 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
1824 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
1825 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1826 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1827 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD64
1828 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF64
1829 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF64
1830 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD32
1831 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF32
1832 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF32
1833 { 3, 31, 1, 27, 0}, // R_TILEGX_TLS_GD_CALL
1834 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_GD_ADD
1835 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_GD_ADD
1836 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_GD_ADD
1837 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_GD_ADD
1838 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_IE_LOAD
1839 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_ADD
1840 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_ADD
1841 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_ADD
1842 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_ADD
1843 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTINHERIT
1844 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTENTRY
1847 // Get the GOT section, creating it if necessary.
1849 template<int size
, bool big_endian
>
1850 Output_data_got
<size
, big_endian
>*
1851 Target_tilegx
<size
, big_endian
>::got_section(Symbol_table
* symtab
,
1854 if (this->got_
== NULL
)
1856 gold_assert(symtab
!= NULL
&& layout
!= NULL
);
1858 // When using -z now, we can treat .got.plt as a relro section.
1859 // Without -z now, it is modified after program startup by lazy
1861 bool is_got_plt_relro
= parameters
->options().now();
1862 Output_section_order got_order
= (is_got_plt_relro
1864 : ORDER_RELRO_LAST
);
1865 Output_section_order got_plt_order
= (is_got_plt_relro
1867 : ORDER_NON_RELRO_FIRST
);
1869 this->got_
= new Output_data_got
<size
, big_endian
>();
1871 layout
->add_output_section_data(".got", elfcpp::SHT_PROGBITS
,
1873 | elfcpp::SHF_WRITE
),
1874 this->got_
, got_order
, true);
1876 // Define _GLOBAL_OFFSET_TABLE_ at the start of the PLT.
1877 this->global_offset_table_
=
1878 symtab
->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL
,
1879 Symbol_table::PREDEFINED
,
1881 0, 0, elfcpp::STT_OBJECT
,
1883 elfcpp::STV_HIDDEN
, 0,
1886 if (parameters
->options().shared()) {
1887 // we need to keep the address of .dynamic section in the
1888 // first got entry for .so
1889 this->tilegx_dynamic_
=
1890 symtab
->define_in_output_data("_TILEGX_DYNAMIC_", NULL
,
1891 Symbol_table::PREDEFINED
,
1892 layout
->dynamic_section(),
1893 0, 0, elfcpp::STT_OBJECT
,
1895 elfcpp::STV_HIDDEN
, 0,
1898 this->got_
->add_global(this->tilegx_dynamic_
, GOT_TYPE_STANDARD
);
1900 // for executable, just set the first entry to zero.
1901 this->got_
->set_current_data_size(size
/ 8);
1903 this->got_plt_
= new Output_data_space(size
/ 8, "** GOT PLT");
1904 layout
->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS
,
1906 | elfcpp::SHF_WRITE
),
1907 this->got_plt_
, got_plt_order
,
1910 // The first two entries are reserved.
1911 this->got_plt_
->set_current_data_size
1912 (TILEGX_GOTPLT_RESERVE_COUNT
* (size
/ 8));
1914 if (!is_got_plt_relro
)
1916 // Those bytes can go into the relro segment.
1917 layout
->increase_relro(size
/ 8);
1921 // If there are any IRELATIVE relocations, they get GOT entries
1922 // in .got.plt after the jump slot entries.
1923 this->got_irelative_
1924 = new Output_data_space(size
/ 8, "** GOT IRELATIVE PLT");
1925 layout
->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS
,
1927 | elfcpp::SHF_WRITE
),
1928 this->got_irelative_
,
1929 got_plt_order
, is_got_plt_relro
);
1935 // Get the dynamic reloc section, creating it if necessary.
1937 template<int size
, bool big_endian
>
1938 typename Target_tilegx
<size
, big_endian
>::Reloc_section
*
1939 Target_tilegx
<size
, big_endian
>::rela_dyn_section(Layout
* layout
)
1941 if (this->rela_dyn_
== NULL
)
1943 gold_assert(layout
!= NULL
);
1944 this->rela_dyn_
= new Reloc_section(parameters
->options().combreloc());
1945 layout
->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA
,
1946 elfcpp::SHF_ALLOC
, this->rela_dyn_
,
1947 ORDER_DYNAMIC_RELOCS
, false);
1949 return this->rela_dyn_
;
1952 // Get the section to use for IRELATIVE relocs, creating it if
1953 // necessary. These go in .rela.dyn, but only after all other dynamic
1954 // relocations. They need to follow the other dynamic relocations so
1955 // that they can refer to global variables initialized by those
1958 template<int size
, bool big_endian
>
1959 typename Target_tilegx
<size
, big_endian
>::Reloc_section
*
1960 Target_tilegx
<size
, big_endian
>::rela_irelative_section(Layout
* layout
)
1962 if (this->rela_irelative_
== NULL
)
1964 // Make sure we have already created the dynamic reloc section.
1965 this->rela_dyn_section(layout
);
1966 this->rela_irelative_
= new Reloc_section(false);
1967 layout
->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA
,
1968 elfcpp::SHF_ALLOC
, this->rela_irelative_
,
1969 ORDER_DYNAMIC_RELOCS
, false);
1970 gold_assert(this->rela_dyn_
->output_section()
1971 == this->rela_irelative_
->output_section());
1973 return this->rela_irelative_
;
1976 // Initialize the PLT section.
1978 template<int size
, bool big_endian
>
1980 Output_data_plt_tilegx
<size
, big_endian
>::init(Layout
* layout
)
1982 this->rel_
= new Reloc_section(false);
1983 layout
->add_output_section_data(".rela.plt", elfcpp::SHT_RELA
,
1984 elfcpp::SHF_ALLOC
, this->rel_
,
1985 ORDER_DYNAMIC_PLT_RELOCS
, false);
1988 template<int size
, bool big_endian
>
1990 Output_data_plt_tilegx
<size
, big_endian
>::do_adjust_output_section(
1993 os
->set_entsize(this->get_plt_entry_size());
1996 // Add an entry to the PLT.
1998 template<int size
, bool big_endian
>
2000 Output_data_plt_tilegx
<size
, big_endian
>::add_entry(Symbol_table
* symtab
,
2001 Layout
* layout
, Symbol
* gsym
)
2003 gold_assert(!gsym
->has_plt_offset());
2005 unsigned int plt_index
;
2007 section_offset_type got_offset
;
2009 unsigned int* pcount
;
2010 unsigned int reserved
;
2011 Output_data_space
* got
;
2012 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
2013 && gsym
->can_use_relative_reloc(false))
2015 pcount
= &this->irelative_count_
;
2017 got
= this->got_irelative_
;
2021 pcount
= &this->count_
;
2022 reserved
= TILEGX_GOTPLT_RESERVE_COUNT
;
2023 got
= this->got_plt_
;
2026 if (!this->is_data_size_valid())
2028 plt_index
= *pcount
;
2030 // TILEGX .plt section layout
2040 // TILEGX .got.plt section layout
2047 // entries for normal function
2051 // entries for ifunc
2055 if (got
== this->got_irelative_
)
2056 plt_offset
= plt_index
* this->get_plt_entry_size();
2058 plt_offset
= (plt_index
+ 1) * this->get_plt_entry_size();
2062 got_offset
= (plt_index
+ reserved
) * (size
/ 8);
2063 gold_assert(got_offset
== got
->current_data_size());
2065 // Every PLT entry needs a GOT entry which points back to the PLT
2066 // entry (this will be changed by the dynamic linker, normally
2067 // lazily when the function is called).
2068 got
->set_current_data_size(got_offset
+ size
/ 8);
2072 // FIXME: This is probably not correct for IRELATIVE relocs.
2074 // For incremental updates, find an available slot.
2075 plt_offset
= this->free_list_
.allocate(this->get_plt_entry_size(),
2076 this->get_plt_entry_size(), 0);
2077 if (plt_offset
== -1)
2078 gold_fallback(_("out of patch space (PLT);"
2079 " relink with --incremental-full"));
2081 // The GOT and PLT entries have a 1-1 correspondance, so the GOT offset
2082 // can be calculated from the PLT index, adjusting for the three
2083 // reserved entries at the beginning of the GOT.
2084 plt_index
= plt_offset
/ this->get_plt_entry_size() - 1;
2085 got_offset
= (plt_index
+ reserved
) * (size
/ 8);
2088 gsym
->set_plt_offset(plt_offset
);
2090 // Every PLT entry needs a reloc.
2091 this->add_relocation(symtab
, layout
, gsym
, got_offset
);
2093 // Note that we don't need to save the symbol. The contents of the
2094 // PLT are independent of which symbols are used. The symbols only
2095 // appear in the relocations.
2098 // Add an entry to the PLT for a local STT_GNU_IFUNC symbol. Return
2101 template<int size
, bool big_endian
>
2103 Output_data_plt_tilegx
<size
, big_endian
>::add_local_ifunc_entry(
2104 Symbol_table
* symtab
,
2106 Sized_relobj_file
<size
, big_endian
>* relobj
,
2107 unsigned int local_sym_index
)
2109 unsigned int plt_offset
=
2110 this->irelative_count_
* this->get_plt_entry_size();
2111 ++this->irelative_count_
;
2113 section_offset_type got_offset
= this->got_irelative_
->current_data_size();
2115 // Every PLT entry needs a GOT entry which points back to the PLT
2117 this->got_irelative_
->set_current_data_size(got_offset
+ size
/ 8);
2119 // Every PLT entry needs a reloc.
2120 Reloc_section
* rela
= this->rela_irelative(symtab
, layout
);
2121 rela
->add_symbolless_local_addend(relobj
, local_sym_index
,
2122 elfcpp::R_TILEGX_IRELATIVE
,
2123 this->got_irelative_
, got_offset
, 0);
2128 // Add the relocation for a PLT entry.
2130 template<int size
, bool big_endian
>
2132 Output_data_plt_tilegx
<size
, big_endian
>::add_relocation(Symbol_table
* symtab
,
2135 unsigned int got_offset
)
2137 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
2138 && gsym
->can_use_relative_reloc(false))
2140 Reloc_section
* rela
= this->rela_irelative(symtab
, layout
);
2141 rela
->add_symbolless_global_addend(gsym
, elfcpp::R_TILEGX_IRELATIVE
,
2142 this->got_irelative_
, got_offset
, 0);
2146 gsym
->set_needs_dynsym_entry();
2147 this->rel_
->add_global(gsym
, elfcpp::R_TILEGX_JMP_SLOT
, this->got_plt_
,
2152 // Return where the IRELATIVE relocations should go in the PLT. These
2153 // follow the JUMP_SLOT and the TLSDESC relocations.
2155 template<int size
, bool big_endian
>
2156 typename Output_data_plt_tilegx
<size
, big_endian
>::Reloc_section
*
2157 Output_data_plt_tilegx
<size
, big_endian
>::rela_irelative(Symbol_table
* symtab
,
2160 if (this->irelative_rel_
== NULL
)
2162 // case we see any later on.
2163 this->irelative_rel_
= new Reloc_section(false);
2164 layout
->add_output_section_data(".rela.plt", elfcpp::SHT_RELA
,
2165 elfcpp::SHF_ALLOC
, this->irelative_rel_
,
2166 ORDER_DYNAMIC_PLT_RELOCS
, false);
2167 gold_assert(this->irelative_rel_
->output_section()
2168 == this->rel_
->output_section());
2170 if (parameters
->doing_static_link())
2172 // A statically linked executable will only have a .rela.plt
2173 // section to hold R_TILEGX_IRELATIVE relocs for
2174 // STT_GNU_IFUNC symbols. The library will use these
2175 // symbols to locate the IRELATIVE relocs at program startup
2177 symtab
->define_in_output_data("__rela_iplt_start", NULL
,
2178 Symbol_table::PREDEFINED
,
2179 this->irelative_rel_
, 0, 0,
2180 elfcpp::STT_NOTYPE
, elfcpp::STB_GLOBAL
,
2181 elfcpp::STV_HIDDEN
, 0, false, true);
2182 symtab
->define_in_output_data("__rela_iplt_end", NULL
,
2183 Symbol_table::PREDEFINED
,
2184 this->irelative_rel_
, 0, 0,
2185 elfcpp::STT_NOTYPE
, elfcpp::STB_GLOBAL
,
2186 elfcpp::STV_HIDDEN
, 0, true, true);
2189 return this->irelative_rel_
;
2192 // Return the PLT address to use for a global symbol.
2194 template<int size
, bool big_endian
>
2196 Output_data_plt_tilegx
<size
, big_endian
>::address_for_global(
2199 uint64_t offset
= 0;
2200 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
2201 && gsym
->can_use_relative_reloc(false))
2202 offset
= (this->count_
+ 1) * this->get_plt_entry_size();
2203 return this->address() + offset
+ gsym
->plt_offset();
2206 // Return the PLT address to use for a local symbol. These are always
2207 // IRELATIVE relocs.
2209 template<int size
, bool big_endian
>
2211 Output_data_plt_tilegx
<size
, big_endian
>::address_for_local(
2212 const Relobj
* object
,
2215 return (this->address()
2216 + (this->count_
+ 1) * this->get_plt_entry_size()
2217 + object
->local_plt_offset(r_sym
));
2220 // Set the final size.
2221 template<int size
, bool big_endian
>
2223 Output_data_plt_tilegx
<size
, big_endian
>::set_final_data_size()
2225 unsigned int count
= this->count_
+ this->irelative_count_
;
2226 this->set_data_size((count
+ 1) * this->get_plt_entry_size());
2229 // The first entry in the PLT for an executable.
2232 Output_data_plt_tilegx
<64, false>::first_plt_entry
[plt_entry_size
] =
2234 0x00, 0x30, 0x48, 0x51,
2235 0x6e, 0x43, 0xa0, 0x18, // { ld_add r28, r27, 8 }
2236 0x00, 0x30, 0xbc, 0x35,
2237 0x00, 0x40, 0xde, 0x9e, // { ld r27, r27 }
2238 0xff, 0xaf, 0x30, 0x40,
2239 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2241 0x00, 0x00, 0x00, 0x00,
2242 0x00, 0x00, 0x00, 0x00,
2243 0x00, 0x00, 0x00, 0x00,
2244 0x00, 0x00, 0x00, 0x00
2249 Output_data_plt_tilegx
<32, false>::first_plt_entry
[plt_entry_size
] =
2251 0x00, 0x30, 0x48, 0x51,
2252 0x6e, 0x23, 0x58, 0x18, // { ld4s_add r28, r27, 4 }
2253 0x00, 0x30, 0xbc, 0x35,
2254 0x00, 0x40, 0xde, 0x9c, // { ld4s r27, r27 }
2255 0xff, 0xaf, 0x30, 0x40,
2256 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2258 0x00, 0x00, 0x00, 0x00,
2259 0x00, 0x00, 0x00, 0x00,
2260 0x00, 0x00, 0x00, 0x00,
2261 0x00, 0x00, 0x00, 0x00
2266 Output_data_plt_tilegx
<64, true>::first_plt_entry
[plt_entry_size
] =
2268 0x00, 0x30, 0x48, 0x51,
2269 0x6e, 0x43, 0xa0, 0x18, // { ld_add r28, r27, 8 }
2270 0x00, 0x30, 0xbc, 0x35,
2271 0x00, 0x40, 0xde, 0x9e, // { ld r27, r27 }
2272 0xff, 0xaf, 0x30, 0x40,
2273 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2275 0x00, 0x00, 0x00, 0x00,
2276 0x00, 0x00, 0x00, 0x00,
2277 0x00, 0x00, 0x00, 0x00,
2278 0x00, 0x00, 0x00, 0x00
2283 Output_data_plt_tilegx
<32, true>::first_plt_entry
[plt_entry_size
] =
2285 0x00, 0x30, 0x48, 0x51,
2286 0x6e, 0x23, 0x58, 0x18, // { ld4s_add r28, r27, 4 }
2287 0x00, 0x30, 0xbc, 0x35,
2288 0x00, 0x40, 0xde, 0x9c, // { ld4s r27, r27 }
2289 0xff, 0xaf, 0x30, 0x40,
2290 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2292 0x00, 0x00, 0x00, 0x00,
2293 0x00, 0x00, 0x00, 0x00,
2294 0x00, 0x00, 0x00, 0x00,
2295 0x00, 0x00, 0x00, 0x00
2298 template<int size
, bool big_endian
>
2300 Output_data_plt_tilegx
<size
, big_endian
>::fill_first_plt_entry(
2303 memcpy(pov
, first_plt_entry
, plt_entry_size
);
2306 // Subsequent entries in the PLT for an executable.
2310 Output_data_plt_tilegx
<64, false>::plt_entry
[plt_entry_size
] =
2312 0xdc, 0x0f, 0x00, 0x10,
2313 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2314 0xdb, 0x0f, 0x00, 0x10,
2315 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2316 0x9c, 0xc6, 0x0d, 0xd0,
2317 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2318 0x9b, 0xb6, 0xc5, 0xad,
2319 0xff, 0x57, 0xe0, 0x8e, // { add r27, r26, r27 ; info 10 ; ld r28, r28 }
2320 0xdd, 0x0f, 0x00, 0x70,
2321 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2327 Output_data_plt_tilegx
<32, false>::plt_entry
[plt_entry_size
] =
2329 0xdc, 0x0f, 0x00, 0x10,
2330 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2331 0xdb, 0x0f, 0x00, 0x10,
2332 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2333 0x9c, 0xc6, 0x0d, 0xd0,
2334 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2335 0x9b, 0xb6, 0xc5, 0xad,
2336 0xff, 0x57, 0xe0, 0x8c, // { add r27, r26, r27 ; info 10 ; ld4s r28, r28 }
2337 0xdd, 0x0f, 0x00, 0x70,
2338 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2343 Output_data_plt_tilegx
<64, true>::plt_entry
[plt_entry_size
] =
2345 0xdc, 0x0f, 0x00, 0x10,
2346 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2347 0xdb, 0x0f, 0x00, 0x10,
2348 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2349 0x9c, 0xc6, 0x0d, 0xd0,
2350 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2351 0x9b, 0xb6, 0xc5, 0xad,
2352 0xff, 0x57, 0xe0, 0x8e, // { add r27, r26, r27 ; info 10 ; ld r28, r28 }
2353 0xdd, 0x0f, 0x00, 0x70,
2354 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2360 Output_data_plt_tilegx
<32, true>::plt_entry
[plt_entry_size
] =
2362 0xdc, 0x0f, 0x00, 0x10,
2363 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2364 0xdb, 0x0f, 0x00, 0x10,
2365 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2366 0x9c, 0xc6, 0x0d, 0xd0,
2367 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2368 0x9b, 0xb6, 0xc5, 0xad,
2369 0xff, 0x57, 0xe0, 0x8c, // { add r27, r26, r27 ; info 10 ; ld4s r28, r28 }
2370 0xdd, 0x0f, 0x00, 0x70,
2371 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2374 template<int size
, bool big_endian
>
2376 Output_data_plt_tilegx
<size
, big_endian
>::fill_plt_entry(
2378 typename
elfcpp::Elf_types
<size
>::Elf_Addr gotplt_base
,
2379 unsigned int got_offset
,
2380 typename
elfcpp::Elf_types
<size
>::Elf_Addr plt_base
,
2381 unsigned int plt_offset
, unsigned int plt_index
)
2384 const uint32_t TILEGX_IMM16_MASK
= 0xFFFF;
2385 const uint32_t TILEGX_X0_IMM16_BITOFF
= 12;
2386 const uint32_t TILEGX_X1_IMM16_BITOFF
= 43;
2388 typedef typename
elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::Valtype
2390 memcpy(pov
, plt_entry
, plt_entry_size
);
2392 // first bundle in plt stub - x0
2393 Valtype
* wv
= reinterpret_cast<Valtype
*>(pov
);
2394 Valtype val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2396 ((gotplt_base
+ got_offset
) - (plt_base
+ plt_offset
+ 8)) >> 16;
2397 elfcpp::Elf_Xword dst_mask
=
2398 (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X0_IMM16_BITOFF
;
2400 reloc
&= TILEGX_IMM16_MASK
;
2401 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2402 val
| (reloc
<<TILEGX_X0_IMM16_BITOFF
));
2404 // second bundle in plt stub - x1
2405 wv
= reinterpret_cast<Valtype
*>(pov
+ 8);
2406 val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2407 reloc
= (gotplt_base
+ got_offset
) - (plt_base
+ plt_offset
+ 8);
2408 dst_mask
= (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X1_IMM16_BITOFF
;
2410 reloc
&= TILEGX_IMM16_MASK
;
2411 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2412 val
| (reloc
<<TILEGX_X1_IMM16_BITOFF
));
2414 // second bundle in plt stub - x0
2415 wv
= reinterpret_cast<Valtype
*>(pov
+ 8);
2416 val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2417 reloc
= (gotplt_base
- (plt_base
+ plt_offset
+ 8)) >> 16;
2418 dst_mask
= (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X0_IMM16_BITOFF
;
2420 reloc
&= TILEGX_IMM16_MASK
;
2421 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2422 val
| (reloc
<<TILEGX_X0_IMM16_BITOFF
));
2424 // third bundle in plt stub - x1
2425 wv
= reinterpret_cast<Valtype
*>(pov
+ 16);
2426 val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2427 reloc
= gotplt_base
- (plt_base
+ plt_offset
+ 8);
2428 dst_mask
= (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X1_IMM16_BITOFF
;
2430 reloc
&= TILEGX_IMM16_MASK
;
2431 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2432 val
| (reloc
<<TILEGX_X1_IMM16_BITOFF
));
2434 // fifth bundle in plt stub - carry plt_index x0
2435 wv
= reinterpret_cast<Valtype
*>(pov
+ 32);
2436 val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2437 dst_mask
= (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X0_IMM16_BITOFF
;
2439 plt_index
&= TILEGX_IMM16_MASK
;
2440 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2441 val
| (plt_index
<<TILEGX_X0_IMM16_BITOFF
));
2445 // Write out the PLT. This uses the hand-coded instructions above.
2447 template<int size
, bool big_endian
>
2449 Output_data_plt_tilegx
<size
, big_endian
>::do_write(Output_file
* of
)
2451 const off_t offset
= this->offset();
2452 const section_size_type oview_size
=
2453 convert_to_section_size_type(this->data_size());
2454 unsigned char* const oview
= of
->get_output_view(offset
, oview_size
);
2456 const off_t got_file_offset
= this->got_plt_
->offset();
2457 gold_assert(parameters
->incremental_update()
2458 || (got_file_offset
+ this->got_plt_
->data_size()
2459 == this->got_irelative_
->offset()));
2460 const section_size_type got_size
=
2461 convert_to_section_size_type(this->got_plt_
->data_size()
2462 + this->got_irelative_
->data_size());
2463 unsigned char* const got_view
= of
->get_output_view(got_file_offset
,
2466 unsigned char* pov
= oview
;
2468 // The base address of the .plt section.
2469 typename
elfcpp::Elf_types
<size
>::Elf_Addr plt_address
= this->address();
2470 typename
elfcpp::Elf_types
<size
>::Elf_Addr got_address
=
2471 this->got_plt_
->address();
2473 this->fill_first_plt_entry(pov
);
2474 pov
+= this->get_plt_entry_size();
2476 unsigned char* got_pov
= got_view
;
2478 // first entry of .got.plt are set to -1
2479 // second entry of .got.plt are set to 0
2480 memset(got_pov
, 0xff, size
/ 8);
2481 got_pov
+= size
/ 8;
2482 memset(got_pov
, 0x0, size
/ 8);
2483 got_pov
+= size
/ 8;
2485 unsigned int plt_offset
= this->get_plt_entry_size();
2486 const unsigned int count
= this->count_
+ this->irelative_count_
;
2487 unsigned int got_offset
= (size
/ 8) * TILEGX_GOTPLT_RESERVE_COUNT
;
2488 for (unsigned int plt_index
= 0;
2491 pov
+= this->get_plt_entry_size(),
2492 got_pov
+= size
/ 8,
2493 plt_offset
+= this->get_plt_entry_size(),
2494 got_offset
+= size
/ 8)
2496 // Set and adjust the PLT entry itself.
2497 this->fill_plt_entry(pov
, got_address
, got_offset
,
2498 plt_address
, plt_offset
, plt_index
);
2500 // Initialize entry in .got.plt to plt start address
2501 elfcpp::Swap
<size
, big_endian
>::writeval(got_pov
, plt_address
);
2504 gold_assert(static_cast<section_size_type
>(pov
- oview
) == oview_size
);
2505 gold_assert(static_cast<section_size_type
>(got_pov
- got_view
) == got_size
);
2507 of
->write_output_view(offset
, oview_size
, oview
);
2508 of
->write_output_view(got_file_offset
, got_size
, got_view
);
2511 // Create the PLT section.
2513 template<int size
, bool big_endian
>
2515 Target_tilegx
<size
, big_endian
>::make_plt_section(Symbol_table
* symtab
,
2518 if (this->plt_
== NULL
)
2520 // Create the GOT sections first.
2521 this->got_section(symtab
, layout
);
2523 // Ensure that .rela.dyn always appears before .rela.plt,
2524 // becuase on TILE-Gx, .rela.dyn needs to include .rela.plt
2526 this->rela_dyn_section(layout
);
2528 this->plt_
= new Output_data_plt_tilegx
<size
, big_endian
>(layout
,
2529 TILEGX_INST_BUNDLE_SIZE
, this->got_
, this->got_plt_
,
2530 this->got_irelative_
);
2532 layout
->add_output_section_data(".plt", elfcpp::SHT_PROGBITS
,
2534 | elfcpp::SHF_EXECINSTR
),
2535 this->plt_
, ORDER_NON_RELRO_FIRST
,
2538 // Make the sh_info field of .rela.plt point to .plt.
2539 Output_section
* rela_plt_os
= this->plt_
->rela_plt()->output_section();
2540 rela_plt_os
->set_info_section(this->plt_
->output_section());
2544 // Create a PLT entry for a global symbol.
2546 template<int size
, bool big_endian
>
2548 Target_tilegx
<size
, big_endian
>::make_plt_entry(Symbol_table
* symtab
,
2549 Layout
* layout
, Symbol
* gsym
)
2551 if (gsym
->has_plt_offset())
2554 if (this->plt_
== NULL
)
2555 this->make_plt_section(symtab
, layout
);
2557 this->plt_
->add_entry(symtab
, layout
, gsym
);
2560 // Make a PLT entry for a local STT_GNU_IFUNC symbol.
2562 template<int size
, bool big_endian
>
2564 Target_tilegx
<size
, big_endian
>::make_local_ifunc_plt_entry(
2565 Symbol_table
* symtab
, Layout
* layout
,
2566 Sized_relobj_file
<size
, big_endian
>* relobj
,
2567 unsigned int local_sym_index
)
2569 if (relobj
->local_has_plt_offset(local_sym_index
))
2571 if (this->plt_
== NULL
)
2572 this->make_plt_section(symtab
, layout
);
2573 unsigned int plt_offset
= this->plt_
->add_local_ifunc_entry(symtab
, layout
,
2576 relobj
->set_local_plt_offset(local_sym_index
, plt_offset
);
2579 // Return the number of entries in the PLT.
2581 template<int size
, bool big_endian
>
2583 Target_tilegx
<size
, big_endian
>::plt_entry_count() const
2585 if (this->plt_
== NULL
)
2587 return this->plt_
->entry_count();
2590 // Return the offset of the first non-reserved PLT entry.
2592 template<int size
, bool big_endian
>
2594 Target_tilegx
<size
, big_endian
>::first_plt_entry_offset() const
2596 return this->plt_
->first_plt_entry_offset();
2599 // Return the size of each PLT entry.
2601 template<int size
, bool big_endian
>
2603 Target_tilegx
<size
, big_endian
>::plt_entry_size() const
2605 return this->plt_
->get_plt_entry_size();
2608 // Create the GOT and PLT sections for an incremental update.
2610 template<int size
, bool big_endian
>
2611 Output_data_got_base
*
2612 Target_tilegx
<size
, big_endian
>::init_got_plt_for_update(Symbol_table
* symtab
,
2614 unsigned int got_count
,
2615 unsigned int plt_count
)
2617 gold_assert(this->got_
== NULL
);
2620 new Output_data_got
<size
, big_endian
>((got_count
2621 + TILEGX_GOT_RESERVE_COUNT
)
2623 layout
->add_output_section_data(".got", elfcpp::SHT_PROGBITS
,
2625 | elfcpp::SHF_WRITE
),
2626 this->got_
, ORDER_RELRO_LAST
,
2629 // Define _GLOBAL_OFFSET_TABLE_ at the start of the GOT.
2630 this->global_offset_table_
=
2631 symtab
->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL
,
2632 Symbol_table::PREDEFINED
,
2634 0, 0, elfcpp::STT_OBJECT
,
2636 elfcpp::STV_HIDDEN
, 0,
2639 if (parameters
->options().shared()) {
2640 this->tilegx_dynamic_
=
2641 symtab
->define_in_output_data("_TILEGX_DYNAMIC_", NULL
,
2642 Symbol_table::PREDEFINED
,
2643 layout
->dynamic_section(),
2644 0, 0, elfcpp::STT_OBJECT
,
2646 elfcpp::STV_HIDDEN
, 0,
2649 this->got_
->add_global(this->tilegx_dynamic_
, GOT_TYPE_STANDARD
);
2651 this->got_
->set_current_data_size(size
/ 8);
2653 // Add the two reserved entries.
2655 = new Output_data_space((plt_count
+ TILEGX_GOTPLT_RESERVE_COUNT
)
2656 * (size
/ 8), size
/ 8, "** GOT PLT");
2657 layout
->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS
,
2659 | elfcpp::SHF_WRITE
),
2660 this->got_plt_
, ORDER_NON_RELRO_FIRST
,
2663 // If there are any IRELATIVE relocations, they get GOT entries in
2664 // .got.plt after the jump slot.
2665 this->got_irelative_
2666 = new Output_data_space(0, size
/ 8, "** GOT IRELATIVE PLT");
2667 layout
->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS
,
2668 elfcpp::SHF_ALLOC
| elfcpp::SHF_WRITE
,
2669 this->got_irelative_
,
2670 ORDER_NON_RELRO_FIRST
, false);
2672 // Create the PLT section.
2673 this->plt_
= new Output_data_plt_tilegx
<size
, big_endian
>(layout
,
2674 this->plt_entry_size(), this->got_
, this->got_plt_
, this->got_irelative_
,
2677 layout
->add_output_section_data(".plt", elfcpp::SHT_PROGBITS
,
2678 elfcpp::SHF_ALLOC
| elfcpp::SHF_EXECINSTR
,
2679 this->plt_
, ORDER_PLT
, false);
2681 // Make the sh_info field of .rela.plt point to .plt.
2682 Output_section
* rela_plt_os
= this->plt_
->rela_plt()->output_section();
2683 rela_plt_os
->set_info_section(this->plt_
->output_section());
2685 // Create the rela_dyn section.
2686 this->rela_dyn_section(layout
);
2691 // Reserve a GOT entry for a local symbol, and regenerate any
2692 // necessary dynamic relocations.
2694 template<int size
, bool big_endian
>
2696 Target_tilegx
<size
, big_endian
>::reserve_local_got_entry(
2697 unsigned int got_index
,
2698 Sized_relobj
<size
, big_endian
>* obj
,
2700 unsigned int got_type
)
2702 unsigned int got_offset
= (got_index
+ TILEGX_GOT_RESERVE_COUNT
)
2704 Reloc_section
* rela_dyn
= this->rela_dyn_section(NULL
);
2706 this->got_
->reserve_local(got_index
, obj
, r_sym
, got_type
);
2709 case GOT_TYPE_STANDARD
:
2710 if (parameters
->options().output_is_position_independent())
2711 rela_dyn
->add_local_relative(obj
, r_sym
, elfcpp::R_TILEGX_RELATIVE
,
2712 this->got_
, got_offset
, 0, false);
2714 case GOT_TYPE_TLS_OFFSET
:
2715 rela_dyn
->add_local(obj
, r_sym
,
2716 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPOFF32
2717 : elfcpp::R_TILEGX_TLS_DTPOFF64
,
2718 this->got_
, got_offset
, 0);
2720 case GOT_TYPE_TLS_PAIR
:
2721 this->got_
->reserve_slot(got_index
+ 1);
2722 rela_dyn
->add_local(obj
, r_sym
,
2723 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPMOD32
2724 : elfcpp::R_TILEGX_TLS_DTPMOD64
,
2725 this->got_
, got_offset
, 0);
2727 case GOT_TYPE_TLS_DESC
:
2728 gold_fatal(_("TLS_DESC not yet supported for incremental linking"));
2735 // Reserve a GOT entry for a global symbol, and regenerate any
2736 // necessary dynamic relocations.
2738 template<int size
, bool big_endian
>
2740 Target_tilegx
<size
, big_endian
>::reserve_global_got_entry(
2741 unsigned int got_index
, Symbol
* gsym
, unsigned int got_type
)
2743 unsigned int got_offset
= (got_index
+ TILEGX_GOT_RESERVE_COUNT
)
2745 Reloc_section
* rela_dyn
= this->rela_dyn_section(NULL
);
2747 this->got_
->reserve_global(got_index
, gsym
, got_type
);
2750 case GOT_TYPE_STANDARD
:
2751 if (!gsym
->final_value_is_known())
2753 if (gsym
->is_from_dynobj()
2754 || gsym
->is_undefined()
2755 || gsym
->is_preemptible()
2756 || gsym
->type() == elfcpp::STT_GNU_IFUNC
)
2757 rela_dyn
->add_global(gsym
, elfcpp::R_TILEGX_GLOB_DAT
,
2758 this->got_
, got_offset
, 0);
2760 rela_dyn
->add_global_relative(gsym
, elfcpp::R_TILEGX_RELATIVE
,
2761 this->got_
, got_offset
, 0, false);
2764 case GOT_TYPE_TLS_OFFSET
:
2765 rela_dyn
->add_global_relative(gsym
,
2766 size
== 32 ? elfcpp::R_TILEGX_TLS_TPOFF32
2767 : elfcpp::R_TILEGX_TLS_TPOFF64
,
2768 this->got_
, got_offset
, 0, false);
2770 case GOT_TYPE_TLS_PAIR
:
2771 this->got_
->reserve_slot(got_index
+ 1);
2772 rela_dyn
->add_global_relative(gsym
,
2773 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPMOD32
2774 : elfcpp::R_TILEGX_TLS_DTPMOD64
,
2775 this->got_
, got_offset
, 0, false);
2776 rela_dyn
->add_global_relative(gsym
,
2777 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPOFF32
2778 : elfcpp::R_TILEGX_TLS_DTPOFF64
,
2779 this->got_
, got_offset
+ size
/ 8,
2782 case GOT_TYPE_TLS_DESC
:
2783 gold_fatal(_("TLS_DESC not yet supported for TILEGX"));
2790 // Register an existing PLT entry for a global symbol.
2792 template<int size
, bool big_endian
>
2794 Target_tilegx
<size
, big_endian
>::register_global_plt_entry(
2795 Symbol_table
* symtab
, Layout
* layout
, unsigned int plt_index
, Symbol
* gsym
)
2797 gold_assert(this->plt_
!= NULL
);
2798 gold_assert(!gsym
->has_plt_offset());
2800 this->plt_
->reserve_slot(plt_index
);
2802 gsym
->set_plt_offset((plt_index
+ 1) * this->plt_entry_size());
2804 unsigned int got_offset
= (plt_index
+ 2) * (size
/ 8);
2805 this->plt_
->add_relocation(symtab
, layout
, gsym
, got_offset
);
2808 // Force a COPY relocation for a given symbol.
2810 template<int size
, bool big_endian
>
2812 Target_tilegx
<size
, big_endian
>::emit_copy_reloc(
2813 Symbol_table
* symtab
, Symbol
* sym
, Output_section
* os
, off_t offset
)
2815 this->copy_relocs_
.emit_copy_reloc(symtab
,
2816 symtab
->get_sized_symbol
<size
>(sym
),
2819 this->rela_dyn_section(NULL
));
2822 // Create a GOT entry for the TLS module index.
2824 template<int size
, bool big_endian
>
2826 Target_tilegx
<size
, big_endian
>::got_mod_index_entry(Symbol_table
* symtab
,
2828 Sized_relobj_file
<size
, big_endian
>* object
)
2830 if (this->got_mod_index_offset_
== -1U)
2832 gold_assert(symtab
!= NULL
&& layout
!= NULL
&& object
!= NULL
);
2833 Reloc_section
* rela_dyn
= this->rela_dyn_section(layout
);
2834 Output_data_got
<size
, big_endian
>* got
2835 = this->got_section(symtab
, layout
);
2836 unsigned int got_offset
= got
->add_constant(0);
2837 rela_dyn
->add_local(object
, 0,
2838 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPMOD32
2839 : elfcpp::R_TILEGX_TLS_DTPMOD64
, got
,
2841 got
->add_constant(0);
2842 this->got_mod_index_offset_
= got_offset
;
2844 return this->got_mod_index_offset_
;
2847 // Optimize the TLS relocation type based on what we know about the
2848 // symbol. IS_FINAL is true if the final address of this symbol is
2849 // known at link time.
2851 // the transformation rules is described below:
2853 // compiler GD reference
2856 // moveli tmp, hw1_last_tls_gd(x) X0/X1
2857 // shl16insli r0, tmp, hw0_tls_gd(x) X0/X1
2858 // addi r0, got, tls_add(x) Y0/Y1/X0/X1
2859 // jal tls_gd_call(x) X1
2860 // addi adr, r0, tls_gd_add(x) Y0/Y1/X0/X1
2862 // linker tranformation of GD insn sequence
2866 // moveli tmp, hw1_last_tls_gd(x) X0/X1
2867 // shl16insli r0, tmp, hw0_tls_gd(x) X0/X1
2868 // add r0, got, r0 Y0/Y1/X0/X1
2869 // jal plt(__tls_get_addr) X1
2870 // move adr, r0 Y0/Y1/X0/X1
2872 // moveli tmp, hw1_last_tls_ie(x) X0/X1
2873 // shl16insli r0, tmp, hw0_tls_ie(x) X0/X1
2874 // add r0, got, r0 Y0/Y1/X0/X1
2876 // add adr, r0, tp Y0/Y1/X0/X1
2878 // moveli tmp, hw1_last_tls_le(x) X0/X1
2879 // shl16insli r0, tmp, hw0_tls_le(x) X0/X1
2880 // move r0, r0 Y0/Y1/X0/X1
2881 // move r0, r0 Y0/Y1/X0/X1
2882 // add adr, r0, tp Y0/Y1/X0/X1
2885 // compiler IE reference
2888 // moveli tmp, hw1_last_tls_ie(x) X0/X1
2889 // shl16insli tmp, tmp, hw0_tls_ie(x) X0/X1
2890 // addi tmp, got, tls_add(x) Y0/Y1/X0/X1
2891 // ld_tls tmp, tmp, tls_ie_load(x) X1
2892 // add adr, tmp, tp Y0/Y1/X0/X1
2894 // linker transformation for IE insn sequence
2898 // moveli tmp, hw1_last_tls_ie(x) X0/X1
2899 // shl16insli tmp, tmp, hw0_tls_ie(x) X0/X1
2900 // add tmp, got, tmp Y0/Y1/X0/X1
2902 // add adr, tmp, tp Y0/Y1/X0/X1
2904 // moveli tmp, hw1_last_tls_le(x) X0/X1
2905 // shl16insli tmp, tmp, hw0_tls_le(x) X0/X1
2906 // move tmp, tmp Y0/Y1/X0/X1
2907 // move tmp, tmp Y0/Y1/X0/X1
2910 // compiler LE reference
2913 // moveli tmp, hw1_last_tls_le(x) X0/X1
2914 // shl16insli tmp, tmp, hw0_tls_le(x) X0/X1
2915 // add adr, tmp, tp Y0/Y1/X0/X1
2917 template<int size
, bool big_endian
>
2918 tls::Tls_optimization
2919 Target_tilegx
<size
, big_endian
>::optimize_tls_reloc(bool is_final
, int r_type
)
2921 // If we are generating a shared library, then we can't do anything
2923 if (parameters
->options().shared())
2924 return tls::TLSOPT_NONE
;
2928 // unique GD relocations
2929 case elfcpp::R_TILEGX_TLS_GD_CALL
:
2930 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
2931 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
2932 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
2933 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
2934 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
2935 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
2936 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
2937 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
2938 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
2939 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
2940 // These are General-Dynamic which permits fully general TLS
2941 // access. Since we know that we are generating an executable,
2942 // we can convert this to Initial-Exec. If we also know that
2943 // this is a local symbol, we can further switch to Local-Exec.
2945 return tls::TLSOPT_TO_LE
;
2946 return tls::TLSOPT_TO_IE
;
2948 // unique IE relocations
2949 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
2950 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
2951 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
2952 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
2953 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
2954 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
2955 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
2956 // These are Initial-Exec relocs which get the thread offset
2957 // from the GOT. If we know that we are linking against the
2958 // local symbol, we can switch to Local-Exec, which links the
2959 // thread offset into the instruction.
2961 return tls::TLSOPT_TO_LE
;
2962 return tls::TLSOPT_NONE
;
2964 // could be created for both GD and IE
2965 // but they are expanded into the same
2966 // instruction in GD and IE.
2967 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
2968 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
2969 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
2970 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
2972 return tls::TLSOPT_TO_LE
;
2973 return tls::TLSOPT_NONE
;
2975 // unique LE relocations
2976 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
2977 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
2978 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
2979 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
2980 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
2981 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
2982 // When we already have Local-Exec, there is nothing further we
2984 return tls::TLSOPT_NONE
;
2991 // Get the Reference_flags for a particular relocation.
2993 template<int size
, bool big_endian
>
2995 Target_tilegx
<size
, big_endian
>::Scan::get_reference_flags(unsigned int r_type
)
2999 case elfcpp::R_TILEGX_NONE
:
3000 case elfcpp::R_TILEGX_GNU_VTINHERIT
:
3001 case elfcpp::R_TILEGX_GNU_VTENTRY
:
3002 // No symbol reference.
3005 case elfcpp::R_TILEGX_64
:
3006 case elfcpp::R_TILEGX_32
:
3007 case elfcpp::R_TILEGX_16
:
3008 case elfcpp::R_TILEGX_8
:
3009 return Symbol::ABSOLUTE_REF
;
3011 case elfcpp::R_TILEGX_BROFF_X1
:
3012 case elfcpp::R_TILEGX_64_PCREL
:
3013 case elfcpp::R_TILEGX_32_PCREL
:
3014 case elfcpp::R_TILEGX_16_PCREL
:
3015 case elfcpp::R_TILEGX_8_PCREL
:
3016 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3017 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3018 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3019 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3020 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3021 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3022 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3023 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3024 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3025 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3026 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3027 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3028 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3029 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3030 return Symbol::RELATIVE_REF
;
3032 case elfcpp::R_TILEGX_JUMPOFF_X1
:
3033 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT
:
3034 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL
:
3035 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL
:
3036 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL
:
3037 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL
:
3038 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL
:
3039 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL
:
3040 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
:
3041 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
:
3042 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
:
3043 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
:
3044 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
:
3045 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
:
3046 return Symbol::FUNCTION_CALL
| Symbol::RELATIVE_REF
;
3048 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3049 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3050 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3051 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3052 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3053 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3054 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3055 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3056 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3057 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3058 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3059 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3060 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3061 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3062 return Symbol::ABSOLUTE_REF
;
3064 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
3065 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
3066 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
3067 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
3068 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
3069 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
3071 return Symbol::ABSOLUTE_REF
;
3073 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
3074 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
3075 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
3076 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
3077 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
3078 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
3079 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
3080 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
3081 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
3082 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
3083 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
3084 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
3085 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
3086 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
3087 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
3088 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
3089 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
3090 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
3091 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
3092 case elfcpp::R_TILEGX_TLS_DTPMOD32
:
3093 case elfcpp::R_TILEGX_TLS_DTPOFF32
:
3094 case elfcpp::R_TILEGX_TLS_TPOFF32
:
3095 case elfcpp::R_TILEGX_TLS_GD_CALL
:
3096 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
3097 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
3098 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
3099 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
3100 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
3101 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
3102 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
3103 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
3104 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
3105 return Symbol::TLS_REF
;
3107 case elfcpp::R_TILEGX_COPY
:
3108 case elfcpp::R_TILEGX_GLOB_DAT
:
3109 case elfcpp::R_TILEGX_JMP_SLOT
:
3110 case elfcpp::R_TILEGX_RELATIVE
:
3111 case elfcpp::R_TILEGX_TLS_TPOFF64
:
3112 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
3114 // Not expected. We will give an error later.
3119 // Report an unsupported relocation against a local symbol.
3121 template<int size
, bool big_endian
>
3123 Target_tilegx
<size
, big_endian
>::Scan::unsupported_reloc_local(
3124 Sized_relobj_file
<size
, big_endian
>* object
,
3125 unsigned int r_type
)
3127 gold_error(_("%s: unsupported reloc %u against local symbol"),
3128 object
->name().c_str(), r_type
);
3131 // We are about to emit a dynamic relocation of type R_TYPE. If the
3132 // dynamic linker does not support it, issue an error.
3133 template<int size
, bool big_endian
>
3135 Target_tilegx
<size
, big_endian
>::Scan::check_non_pic(Relobj
* object
,
3136 unsigned int r_type
)
3140 // These are the relocation types supported by glibc for tilegx
3141 // which should always work.
3142 case elfcpp::R_TILEGX_RELATIVE
:
3143 case elfcpp::R_TILEGX_GLOB_DAT
:
3144 case elfcpp::R_TILEGX_JMP_SLOT
:
3145 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
3146 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
3147 case elfcpp::R_TILEGX_TLS_TPOFF64
:
3148 case elfcpp::R_TILEGX_8
:
3149 case elfcpp::R_TILEGX_16
:
3150 case elfcpp::R_TILEGX_32
:
3151 case elfcpp::R_TILEGX_64
:
3152 case elfcpp::R_TILEGX_COPY
:
3153 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3154 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3155 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3156 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3157 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3158 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3159 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3160 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3161 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3162 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3163 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3164 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3165 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3166 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3167 case elfcpp::R_TILEGX_BROFF_X1
:
3168 case elfcpp::R_TILEGX_JUMPOFF_X1
:
3169 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3170 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3171 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3172 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3173 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3174 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3175 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3176 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3177 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3178 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3179 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3180 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3181 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3182 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3186 // This prevents us from issuing more than one error per reloc
3187 // section. But we can still wind up issuing more than one
3188 // error per object file.
3189 if (this->issued_non_pic_error_
)
3191 gold_assert(parameters
->options().output_is_position_independent());
3192 object
->error(_("requires unsupported dynamic reloc %u; "
3193 "recompile with -fPIC"),
3195 this->issued_non_pic_error_
= true;
3198 case elfcpp::R_TILEGX_NONE
:
3203 // Return whether we need to make a PLT entry for a relocation of the
3204 // given type against a STT_GNU_IFUNC symbol.
3206 template<int size
, bool big_endian
>
3208 Target_tilegx
<size
, big_endian
>::Scan::reloc_needs_plt_for_ifunc(
3209 Sized_relobj_file
<size
, big_endian
>* object
, unsigned int r_type
)
3211 int flags
= Scan::get_reference_flags(r_type
);
3212 if (flags
& Symbol::TLS_REF
)
3213 gold_error(_("%s: unsupported TLS reloc %u for IFUNC symbol"),
3214 object
->name().c_str(), r_type
);
3218 // Scan a relocation for a local symbol.
3220 template<int size
, bool big_endian
>
3222 Target_tilegx
<size
, big_endian
>::Scan::local(Symbol_table
* symtab
,
3224 Target_tilegx
<size
, big_endian
>* target
,
3225 Sized_relobj_file
<size
, big_endian
>* object
,
3226 unsigned int data_shndx
,
3227 Output_section
* output_section
,
3228 const elfcpp::Rela
<size
, big_endian
>& reloc
,
3229 unsigned int r_type
,
3230 const elfcpp::Sym
<size
, big_endian
>& lsym
,
3236 // A local STT_GNU_IFUNC symbol may require a PLT entry.
3237 bool is_ifunc
= lsym
.get_st_type() == elfcpp::STT_GNU_IFUNC
;
3238 if (is_ifunc
&& this->reloc_needs_plt_for_ifunc(object
, r_type
))
3240 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3241 target
->make_local_ifunc_plt_entry(symtab
, layout
, object
, r_sym
);
3246 case elfcpp::R_TILEGX_NONE
:
3247 case elfcpp::R_TILEGX_GNU_VTINHERIT
:
3248 case elfcpp::R_TILEGX_GNU_VTENTRY
:
3251 // If building a shared library (or a position-independent
3252 // executable), because the runtime address needs plus
3253 // the module base address, so generate a R_TILEGX_RELATIVE.
3254 case elfcpp::R_TILEGX_32
:
3255 case elfcpp::R_TILEGX_64
:
3256 if (parameters
->options().output_is_position_independent())
3258 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3259 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3260 rela_dyn
->add_local_relative(object
, r_sym
,
3261 elfcpp::R_TILEGX_RELATIVE
,
3262 output_section
, data_shndx
,
3263 reloc
.get_r_offset(),
3264 reloc
.get_r_addend(), is_ifunc
);
3268 // If building a shared library (or a position-independent
3269 // executable), we need to create a dynamic relocation for this
3271 case elfcpp::R_TILEGX_8
:
3272 case elfcpp::R_TILEGX_16
:
3273 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3274 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3275 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3276 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3277 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3278 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3279 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3280 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3281 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3282 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3283 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3284 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3285 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3286 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3287 if (parameters
->options().output_is_position_independent())
3289 this->check_non_pic(object
, r_type
);
3291 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3292 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3293 if (lsym
.get_st_type() != elfcpp::STT_SECTION
)
3294 rela_dyn
->add_local(object
, r_sym
, r_type
, output_section
,
3295 data_shndx
, reloc
.get_r_offset(),
3296 reloc
.get_r_addend());
3299 gold_assert(lsym
.get_st_value() == 0);
3300 rela_dyn
->add_symbolless_local_addend(object
, r_sym
, r_type
,
3303 reloc
.get_r_offset(),
3304 reloc
.get_r_addend());
3310 // R_TILEGX_JUMPOFF_X1_PLT against local symbol
3311 // may happen for ifunc case.
3312 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT
:
3313 case elfcpp::R_TILEGX_JUMPOFF_X1
:
3314 case elfcpp::R_TILEGX_64_PCREL
:
3315 case elfcpp::R_TILEGX_32_PCREL
:
3316 case elfcpp::R_TILEGX_16_PCREL
:
3317 case elfcpp::R_TILEGX_8_PCREL
:
3318 case elfcpp::R_TILEGX_BROFF_X1
:
3319 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3320 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3321 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3322 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3323 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3324 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3325 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3326 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3327 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3328 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3329 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3330 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3331 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3332 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3333 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL
:
3334 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL
:
3335 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL
:
3336 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL
:
3337 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL
:
3338 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL
:
3339 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
:
3340 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
:
3341 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
:
3342 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
:
3343 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
:
3344 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
:
3347 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
3348 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
3349 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
3350 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
3351 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
3352 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
3354 // The symbol requires a GOT entry.
3355 Output_data_got
<size
, big_endian
>* got
3356 = target
->got_section(symtab
, layout
);
3357 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3359 // For a STT_GNU_IFUNC symbol we want the PLT offset. That
3360 // lets function pointers compare correctly with shared
3361 // libraries. Otherwise we would need an IRELATIVE reloc.
3364 is_new
= got
->add_local_plt(object
, r_sym
, GOT_TYPE_STANDARD
);
3366 is_new
= got
->add_local(object
, r_sym
, GOT_TYPE_STANDARD
);
3369 // tilegx dynamic linker will not update local got entry,
3370 // so, if we are generating a shared object, we need to add a
3371 // dynamic relocation for this symbol's GOT entry to inform
3372 // dynamic linker plus the load base explictly.
3373 if (parameters
->options().output_is_position_independent())
3375 unsigned int got_offset
3376 = object
->local_got_offset(r_sym
, GOT_TYPE_STANDARD
);
3378 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3379 rela_dyn
->add_local_relative(object
, r_sym
,
3381 got
, got_offset
, 0, is_ifunc
);
3387 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
3388 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
3389 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
3390 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
3391 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
3392 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
3393 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
3394 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
3395 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
3396 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
3397 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
3398 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
3399 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
3400 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
3401 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
3402 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
3403 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
3404 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
3405 case elfcpp::R_TILEGX_TLS_GD_CALL
:
3406 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
3407 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
3408 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
3409 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
3410 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
3411 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
3412 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
3413 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
3414 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
3416 bool output_is_shared
= parameters
->options().shared();
3417 const tls::Tls_optimization opt_t
=
3418 Target_tilegx
<size
, big_endian
>::optimize_tls_reloc(
3419 !output_is_shared
, r_type
);
3423 case elfcpp::R_TILEGX_TLS_GD_CALL
:
3424 // FIXME: predefine __tls_get_addr
3426 // R_TILEGX_TLS_GD_CALL implicitly reference __tls_get_addr,
3427 // while all other target, x86/arm/mips/powerpc/sparc
3428 // generate tls relocation against __tls_get_addr explictly,
3429 // so for TILEGX, we need the following hack.
3430 if (opt_t
== tls::TLSOPT_NONE
) {
3431 if (!target
->tls_get_addr_sym_defined_
) {
3433 options::parse_set(NULL
, "__tls_get_addr",
3434 (gold::options::String_set
*)
3435 ¶meters
->options().undefined());
3436 symtab
->add_undefined_symbols_from_command_line(layout
);
3437 target
->tls_get_addr_sym_defined_
= true;
3438 sym
= symtab
->lookup("__tls_get_addr");
3441 target
->make_plt_entry(symtab
, layout
,
3442 symtab
->lookup("__tls_get_addr"));
3446 // only make effect when applying relocation
3447 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
3448 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
3449 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
3450 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
3451 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
3452 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
3453 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
3454 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
3455 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
3458 // GD: requires two GOT entry for module index and offset
3459 // IE: requires one GOT entry for tp-relative offset
3460 // LE: shouldn't happen for global symbol
3461 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
3462 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
3463 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
3464 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
3465 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
3466 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
3468 if (opt_t
== tls::TLSOPT_NONE
) {
3469 Output_data_got
<size
, big_endian
> *got
3470 = target
->got_section(symtab
, layout
);
3472 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3473 unsigned int shndx
= lsym
.get_st_shndx();
3475 shndx
= object
->adjust_sym_shndx(r_sym
, shndx
,
3478 object
->error(_("local symbol %u has bad shndx %u"),
3481 got
->add_local_pair_with_rel(object
, r_sym
, shndx
,
3483 target
->rela_dyn_section(layout
),
3485 ? elfcpp::R_TILEGX_TLS_DTPMOD32
3486 : elfcpp::R_TILEGX_TLS_DTPMOD64
);
3487 } else if (opt_t
== tls::TLSOPT_TO_IE
) {
3488 Output_data_got
<size
, big_endian
>* got
3489 = target
->got_section(symtab
, layout
);
3490 Reloc_section
* rela_dyn
3491 = target
->rela_dyn_section(layout
);
3493 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3494 unsigned int off
= got
->add_constant(0);
3495 object
->set_local_got_offset(r_sym
,
3496 GOT_TYPE_TLS_OFFSET
,off
);
3497 rela_dyn
->add_symbolless_local_addend(object
, r_sym
,
3499 ? elfcpp::R_TILEGX_TLS_TPOFF32
3500 : elfcpp::R_TILEGX_TLS_TPOFF64
,
3502 } else if (opt_t
!= tls::TLSOPT_TO_LE
)
3503 // only TO_LE is allowed for local symbol
3504 unsupported_reloc_local(object
, r_type
);
3509 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
3510 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
3511 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
3512 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
3513 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
3514 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
3516 layout
->set_has_static_tls();
3517 if (opt_t
== tls::TLSOPT_NONE
) {
3518 Output_data_got
<size
, big_endian
>* got
3519 = target
->got_section(symtab
, layout
);
3520 Reloc_section
* rela_dyn
3521 = target
->rela_dyn_section(layout
);
3523 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3524 unsigned int off
= got
->add_constant(0);
3525 object
->set_local_got_offset(r_sym
,
3526 GOT_TYPE_TLS_OFFSET
, off
);
3527 rela_dyn
->add_symbolless_local_addend(object
, r_sym
,
3529 ? elfcpp::R_TILEGX_TLS_TPOFF32
3530 : elfcpp::R_TILEGX_TLS_TPOFF64
,
3532 } else if (opt_t
!= tls::TLSOPT_TO_LE
)
3533 unsupported_reloc_local(object
, r_type
);
3538 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
3539 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
3540 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
3541 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
3542 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
3543 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
3544 layout
->set_has_static_tls();
3545 if (parameters
->options().shared()) {
3546 // defer to dynamic linker
3547 gold_assert(lsym
.get_st_type() != elfcpp::STT_SECTION
);
3549 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3550 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3551 rela_dyn
->add_symbolless_local_addend(object
, r_sym
, r_type
,
3552 output_section
, data_shndx
,
3553 reloc
.get_r_offset(), 0);
3563 case elfcpp::R_TILEGX_COPY
:
3564 case elfcpp::R_TILEGX_GLOB_DAT
:
3565 case elfcpp::R_TILEGX_JMP_SLOT
:
3566 case elfcpp::R_TILEGX_RELATIVE
:
3567 // These are outstanding tls relocs, which are unexpected when linking
3568 case elfcpp::R_TILEGX_TLS_TPOFF32
:
3569 case elfcpp::R_TILEGX_TLS_TPOFF64
:
3570 case elfcpp::R_TILEGX_TLS_DTPMOD32
:
3571 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
3572 case elfcpp::R_TILEGX_TLS_DTPOFF32
:
3573 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
3574 gold_error(_("%s: unexpected reloc %u in object file"),
3575 object
->name().c_str(), r_type
);
3579 gold_error(_("%s: unsupported reloc %u against local symbol"),
3580 object
->name().c_str(), r_type
);
3586 // Report an unsupported relocation against a global symbol.
3588 template<int size
, bool big_endian
>
3590 Target_tilegx
<size
, big_endian
>::Scan::unsupported_reloc_global(
3591 Sized_relobj_file
<size
, big_endian
>* object
,
3592 unsigned int r_type
,
3595 gold_error(_("%s: unsupported reloc %u against global symbol %s"),
3596 object
->name().c_str(), r_type
, gsym
->demangled_name().c_str());
3599 // Returns true if this relocation type could be that of a function pointer.
3600 template<int size
, bool big_endian
>
3602 Target_tilegx
<size
, big_endian
>::Scan::possible_function_pointer_reloc(
3603 unsigned int r_type
)
3607 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3608 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3609 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3610 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3611 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3612 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3613 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3614 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3615 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3616 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3617 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3618 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3619 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3620 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3621 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3622 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3623 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3624 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3625 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3626 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3627 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3628 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3629 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3630 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3631 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3632 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3633 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3634 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3635 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
3636 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
3637 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
3638 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
3639 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
3640 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
3648 // For safe ICF, scan a relocation for a local symbol to check if it
3649 // corresponds to a function pointer being taken. In that case mark
3650 // the function whose pointer was taken as not foldable.
3652 template<int size
, bool big_endian
>
3654 Target_tilegx
<size
, big_endian
>::Scan::local_reloc_may_be_function_pointer(
3657 Target_tilegx
<size
, big_endian
>* ,
3658 Sized_relobj_file
<size
, big_endian
>* ,
3661 const elfcpp::Rela
<size
, big_endian
>& ,
3662 unsigned int r_type
,
3663 const elfcpp::Sym
<size
, big_endian
>&)
3665 return possible_function_pointer_reloc(r_type
);
3668 // For safe ICF, scan a relocation for a global symbol to check if it
3669 // corresponds to a function pointer being taken. In that case mark
3670 // the function whose pointer was taken as not foldable.
3672 template<int size
, bool big_endian
>
3674 Target_tilegx
<size
, big_endian
>::Scan::global_reloc_may_be_function_pointer(
3677 Target_tilegx
<size
, big_endian
>* ,
3678 Sized_relobj_file
<size
, big_endian
>* ,
3681 const elfcpp::Rela
<size
, big_endian
>& ,
3682 unsigned int r_type
,
3685 // GOT is not a function.
3686 if (strcmp(gsym
->name(), "_GLOBAL_OFFSET_TABLE_") == 0)
3689 // When building a shared library, do not fold symbols whose visibility
3690 // is hidden, internal or protected.
3691 return ((parameters
->options().shared()
3692 && (gsym
->visibility() == elfcpp::STV_INTERNAL
3693 || gsym
->visibility() == elfcpp::STV_PROTECTED
3694 || gsym
->visibility() == elfcpp::STV_HIDDEN
))
3695 || possible_function_pointer_reloc(r_type
));
3698 // Scan a relocation for a global symbol.
3700 template<int size
, bool big_endian
>
3702 Target_tilegx
<size
, big_endian
>::Scan::global(Symbol_table
* symtab
,
3704 Target_tilegx
<size
, big_endian
>* target
,
3705 Sized_relobj_file
<size
, big_endian
>* object
,
3706 unsigned int data_shndx
,
3707 Output_section
* output_section
,
3708 const elfcpp::Rela
<size
, big_endian
>& reloc
,
3709 unsigned int r_type
,
3712 // A reference to _GLOBAL_OFFSET_TABLE_ implies that we need a got
3713 // section. We check here to avoid creating a dynamic reloc against
3714 // _GLOBAL_OFFSET_TABLE_.
3715 if (!target
->has_got_section()
3716 && strcmp(gsym
->name(), "_GLOBAL_OFFSET_TABLE_") == 0)
3717 target
->got_section(symtab
, layout
);
3719 // A STT_GNU_IFUNC symbol may require a PLT entry.
3720 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
3721 && this->reloc_needs_plt_for_ifunc(object
, r_type
))
3722 target
->make_plt_entry(symtab
, layout
, gsym
);
3726 case elfcpp::R_TILEGX_NONE
:
3727 case elfcpp::R_TILEGX_GNU_VTINHERIT
:
3728 case elfcpp::R_TILEGX_GNU_VTENTRY
:
3731 case elfcpp::R_TILEGX_DEST_IMM8_X1
:
3732 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3733 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3734 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3735 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3736 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3737 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3738 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3739 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3740 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3741 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3742 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3743 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3744 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3745 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3746 case elfcpp::R_TILEGX_64
:
3747 case elfcpp::R_TILEGX_32
:
3748 case elfcpp::R_TILEGX_16
:
3749 case elfcpp::R_TILEGX_8
:
3751 // Make a PLT entry if necessary.
3752 if (gsym
->needs_plt_entry())
3754 target
->make_plt_entry(symtab
, layout
, gsym
);
3755 // Since this is not a PC-relative relocation, we may be
3756 // taking the address of a function. In that case we need to
3757 // set the entry in the dynamic symbol table to the address of
3759 if (gsym
->is_from_dynobj() && !parameters
->options().shared())
3760 gsym
->set_needs_dynsym_value();
3762 // Make a dynamic relocation if necessary.
3763 if (gsym
->needs_dynamic_reloc(Scan::get_reference_flags(r_type
)))
3765 if (!parameters
->options().output_is_position_independent()
3766 && gsym
->may_need_copy_reloc())
3768 target
->copy_reloc(symtab
, layout
, object
,
3769 data_shndx
, output_section
, gsym
, reloc
);
3771 else if (((size
== 64 && r_type
== elfcpp::R_TILEGX_64
)
3772 || (size
== 32 && r_type
== elfcpp::R_TILEGX_32
))
3773 && gsym
->type() == elfcpp::STT_GNU_IFUNC
3774 && gsym
->can_use_relative_reloc(false)
3775 && !gsym
->is_from_dynobj()
3776 && !gsym
->is_undefined()
3777 && !gsym
->is_preemptible())
3779 // Use an IRELATIVE reloc for a locally defined
3780 // STT_GNU_IFUNC symbol. This makes a function
3781 // address in a PIE executable match the address in a
3782 // shared library that it links against.
3783 Reloc_section
* rela_dyn
=
3784 target
->rela_irelative_section(layout
);
3785 unsigned int r_type
= elfcpp::R_TILEGX_IRELATIVE
;
3786 rela_dyn
->add_symbolless_global_addend(gsym
, r_type
,
3787 output_section
, object
,
3789 reloc
.get_r_offset(),
3790 reloc
.get_r_addend());
3791 } else if ((r_type
== elfcpp::R_TILEGX_64
3792 || r_type
== elfcpp::R_TILEGX_32
)
3793 && gsym
->can_use_relative_reloc(false))
3795 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3796 rela_dyn
->add_global_relative(gsym
, elfcpp::R_TILEGX_RELATIVE
,
3797 output_section
, object
,
3799 reloc
.get_r_offset(),
3800 reloc
.get_r_addend(), false);
3804 this->check_non_pic(object
, r_type
);
3805 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3806 rela_dyn
->add_global(gsym
, r_type
, output_section
, object
,
3807 data_shndx
, reloc
.get_r_offset(),
3808 reloc
.get_r_addend());
3814 case elfcpp::R_TILEGX_BROFF_X1
:
3815 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3816 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3817 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3818 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3819 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3820 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3821 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3822 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3823 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3824 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3825 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3826 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3827 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3828 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3829 case elfcpp::R_TILEGX_64_PCREL
:
3830 case elfcpp::R_TILEGX_32_PCREL
:
3831 case elfcpp::R_TILEGX_16_PCREL
:
3832 case elfcpp::R_TILEGX_8_PCREL
:
3834 // Make a PLT entry if necessary.
3835 if (gsym
->needs_plt_entry())
3836 target
->make_plt_entry(symtab
, layout
, gsym
);
3837 // Make a dynamic relocation if necessary.
3838 if (gsym
->needs_dynamic_reloc(Scan::get_reference_flags(r_type
)))
3840 if (parameters
->options().output_is_executable()
3841 && gsym
->may_need_copy_reloc())
3843 target
->copy_reloc(symtab
, layout
, object
,
3844 data_shndx
, output_section
, gsym
, reloc
);
3848 this->check_non_pic(object
, r_type
);
3849 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3850 rela_dyn
->add_global(gsym
, r_type
, output_section
, object
,
3851 data_shndx
, reloc
.get_r_offset(),
3852 reloc
.get_r_addend());
3858 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
3859 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
3860 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
3861 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
3862 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
3863 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
3865 // The symbol requires a GOT entry.
3866 Output_data_got
<size
, big_endian
>* got
3867 = target
->got_section(symtab
, layout
);
3868 if (gsym
->final_value_is_known())
3870 // For a STT_GNU_IFUNC symbol we want the PLT address.
3871 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
)
3872 got
->add_global_plt(gsym
, GOT_TYPE_STANDARD
);
3874 got
->add_global(gsym
, GOT_TYPE_STANDARD
);
3878 // If this symbol is not fully resolved, we need to add a
3879 // dynamic relocation for it.
3880 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3882 // Use a GLOB_DAT rather than a RELATIVE reloc if:
3884 // 1) The symbol may be defined in some other module.
3886 // 2) We are building a shared library and this is a
3887 // protected symbol; using GLOB_DAT means that the dynamic
3888 // linker can use the address of the PLT in the main
3889 // executable when appropriate so that function address
3890 // comparisons work.
3892 // 3) This is a STT_GNU_IFUNC symbol in position dependent
3893 // code, again so that function address comparisons work.
3894 if (gsym
->is_from_dynobj()
3895 || gsym
->is_undefined()
3896 || gsym
->is_preemptible()
3897 || (gsym
->visibility() == elfcpp::STV_PROTECTED
3898 && parameters
->options().shared())
3899 || (gsym
->type() == elfcpp::STT_GNU_IFUNC
3900 && parameters
->options().output_is_position_independent()))
3901 got
->add_global_with_rel(gsym
, GOT_TYPE_STANDARD
, rela_dyn
,
3902 elfcpp::R_TILEGX_GLOB_DAT
);
3905 // For a STT_GNU_IFUNC symbol we want to write the PLT
3906 // offset into the GOT, so that function pointer
3907 // comparisons work correctly.
3909 if (gsym
->type() != elfcpp::STT_GNU_IFUNC
)
3910 is_new
= got
->add_global(gsym
, GOT_TYPE_STANDARD
);
3913 is_new
= got
->add_global_plt(gsym
, GOT_TYPE_STANDARD
);
3914 // Tell the dynamic linker to use the PLT address
3915 // when resolving relocations.
3916 if (gsym
->is_from_dynobj()
3917 && !parameters
->options().shared())
3918 gsym
->set_needs_dynsym_value();
3922 unsigned int got_off
= gsym
->got_offset(GOT_TYPE_STANDARD
);
3923 rela_dyn
->add_global_relative(gsym
,
3925 got
, got_off
, 0, false);
3932 // a minor difference here for R_TILEGX_JUMPOFF_X1
3933 // between bfd linker and gold linker for gold, when
3934 // R_TILEGX_JUMPOFF_X1 against global symbol, we
3935 // turn it into JUMPOFF_X1_PLT, otherwise the distance
3936 // to the symbol function may overflow at runtime.
3937 case elfcpp::R_TILEGX_JUMPOFF_X1
:
3939 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT
:
3940 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL
:
3941 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL
:
3942 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL
:
3943 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL
:
3944 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL
:
3945 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL
:
3946 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
:
3947 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
:
3948 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
:
3949 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
:
3950 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
:
3951 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
:
3952 // If the symbol is fully resolved, this is just a PC32 reloc.
3953 // Otherwise we need a PLT entry.
3954 if (gsym
->final_value_is_known())
3956 // If building a shared library, we can also skip the PLT entry
3957 // if the symbol is defined in the output file and is protected
3959 if (gsym
->is_defined()
3960 && !gsym
->is_from_dynobj()
3961 && !gsym
->is_preemptible())
3963 target
->make_plt_entry(symtab
, layout
, gsym
);
3967 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
3968 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
3969 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
3970 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
3971 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
3972 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
3973 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
3974 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
3975 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
3976 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
3977 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
3978 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
3979 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
3980 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
3981 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
3982 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
3983 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
3984 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
3985 case elfcpp::R_TILEGX_TLS_GD_CALL
:
3986 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
3987 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
3988 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
3989 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
3990 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
3991 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
3992 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
3993 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
3994 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
3996 const bool is_final
= gsym
->final_value_is_known();
3997 const tls::Tls_optimization opt_t
=
3998 Target_tilegx
<size
, big_endian
>::optimize_tls_reloc(is_final
,
4003 // only expand to plt against __tls_get_addr in GD model
4004 case elfcpp::R_TILEGX_TLS_GD_CALL
:
4005 if (opt_t
== tls::TLSOPT_NONE
) {
4006 // FIXME: it's better '__tls_get_addr' referenced explictly
4007 if (!target
->tls_get_addr_sym_defined_
) {
4009 options::parse_set(NULL
, "__tls_get_addr",
4010 (gold::options::String_set
*)
4011 ¶meters
->options().undefined());
4012 symtab
->add_undefined_symbols_from_command_line(layout
);
4013 target
->tls_get_addr_sym_defined_
= true;
4014 sym
= symtab
->lookup("__tls_get_addr");
4017 target
->make_plt_entry(symtab
, layout
,
4018 symtab
->lookup("__tls_get_addr"));
4022 // only make effect when applying relocation
4023 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
4024 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
4025 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
4026 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
4027 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
4028 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
4029 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
4030 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
4031 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
4034 // GD: requires two GOT entry for module index and offset
4035 // IE: requires one GOT entry for tp-relative offset
4036 // LE: shouldn't happen for global symbol
4037 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
4038 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
4039 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
4040 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
4041 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
4042 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
4044 if (opt_t
== tls::TLSOPT_NONE
) {
4045 Output_data_got
<size
, big_endian
>* got
4046 = target
->got_section(symtab
, layout
);
4047 got
->add_global_pair_with_rel(gsym
, GOT_TYPE_TLS_PAIR
,
4048 target
->rela_dyn_section(layout
),
4050 ? elfcpp::R_TILEGX_TLS_DTPMOD32
4051 : elfcpp::R_TILEGX_TLS_DTPMOD64
,
4053 ? elfcpp::R_TILEGX_TLS_DTPOFF32
4054 : elfcpp::R_TILEGX_TLS_DTPOFF64
);
4055 } else if (opt_t
== tls::TLSOPT_TO_IE
) {
4056 // Create a GOT entry for the tp-relative offset.
4057 Output_data_got
<size
, big_endian
>* got
4058 = target
->got_section(symtab
, layout
);
4059 got
->add_global_with_rel(gsym
, GOT_TYPE_TLS_OFFSET
,
4060 target
->rela_dyn_section(layout
),
4062 ? elfcpp::R_TILEGX_TLS_TPOFF32
4063 : elfcpp::R_TILEGX_TLS_TPOFF64
);
4064 } else if (opt_t
!= tls::TLSOPT_TO_LE
)
4065 // exteranl symbol should not be optimized to TO_LE
4066 unsupported_reloc_global(object
, r_type
, gsym
);
4071 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
4072 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
4073 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
4074 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
4075 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
4076 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
4078 layout
->set_has_static_tls();
4079 if (opt_t
== tls::TLSOPT_NONE
) {
4080 // Create a GOT entry for the tp-relative offset.
4081 Output_data_got
<size
, big_endian
>* got
4082 = target
->got_section(symtab
, layout
);
4083 got
->add_global_with_rel(gsym
, GOT_TYPE_TLS_OFFSET
,
4084 target
->rela_dyn_section(layout
),
4086 ? elfcpp::R_TILEGX_TLS_TPOFF32
4087 : elfcpp::R_TILEGX_TLS_TPOFF64
);
4088 } else if (opt_t
!= tls::TLSOPT_TO_LE
)
4089 unsupported_reloc_global(object
, r_type
, gsym
);
4094 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
4095 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
4096 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
4097 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
4098 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
4099 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
4100 layout
->set_has_static_tls();
4101 if (parameters
->options().shared()) {
4102 // defer to dynamic linker
4103 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
4104 rela_dyn
->add_symbolless_global_addend(gsym
, r_type
,
4105 output_section
, object
,
4107 reloc
.get_r_offset(), 0);
4117 // below are outstanding relocs
4118 // should not existed in static linking stage
4119 case elfcpp::R_TILEGX_COPY
:
4120 case elfcpp::R_TILEGX_GLOB_DAT
:
4121 case elfcpp::R_TILEGX_JMP_SLOT
:
4122 case elfcpp::R_TILEGX_RELATIVE
:
4123 case elfcpp::R_TILEGX_TLS_TPOFF32
:
4124 case elfcpp::R_TILEGX_TLS_TPOFF64
:
4125 case elfcpp::R_TILEGX_TLS_DTPMOD32
:
4126 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
4127 case elfcpp::R_TILEGX_TLS_DTPOFF32
:
4128 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
4129 gold_error(_("%s: unexpected reloc %u in object file"),
4130 object
->name().c_str(), r_type
);
4134 gold_error(_("%s: unsupported reloc %u against global symbol %s"),
4135 object
->name().c_str(), r_type
,
4136 gsym
->demangled_name().c_str());
4141 template<int size
, bool big_endian
>
4143 Target_tilegx
<size
, big_endian
>::gc_process_relocs(Symbol_table
* symtab
,
4145 Sized_relobj_file
<size
, big_endian
>* object
,
4146 unsigned int data_shndx
,
4147 unsigned int sh_type
,
4148 const unsigned char* prelocs
,
4150 Output_section
* output_section
,
4151 bool needs_special_offset_handling
,
4152 size_t local_symbol_count
,
4153 const unsigned char* plocal_symbols
)
4155 typedef Target_tilegx
<size
, big_endian
> Tilegx
;
4156 typedef typename Target_tilegx
<size
, big_endian
>::Scan Scan
;
4158 if (sh_type
== elfcpp::SHT_REL
)
4163 gold::gc_process_relocs
<size
, big_endian
,
4164 Tilegx
, elfcpp::SHT_RELA
, Scan
,
4165 typename Target_tilegx
<size
, big_endian
>::Relocatable_size_for_reloc
>(
4174 needs_special_offset_handling
,
4178 // Scan relocations for a section.
4180 template<int size
, bool big_endian
>
4182 Target_tilegx
<size
, big_endian
>::scan_relocs(Symbol_table
* symtab
,
4184 Sized_relobj_file
<size
, big_endian
>* object
,
4185 unsigned int data_shndx
,
4186 unsigned int sh_type
,
4187 const unsigned char* prelocs
,
4189 Output_section
* output_section
,
4190 bool needs_special_offset_handling
,
4191 size_t local_symbol_count
,
4192 const unsigned char* plocal_symbols
)
4194 typedef Target_tilegx
<size
, big_endian
> Tilegx
;
4195 typedef typename Target_tilegx
<size
, big_endian
>::Scan Scan
;
4197 if (sh_type
== elfcpp::SHT_REL
)
4199 gold_error(_("%s: unsupported REL reloc section"),
4200 object
->name().c_str());
4204 gold::scan_relocs
<size
, big_endian
, Tilegx
, elfcpp::SHT_RELA
, Scan
>(
4213 needs_special_offset_handling
,
4218 template<int size
, bool big_endian
>
4220 Target_tilegx
<size
, big_endian
>::do_define_standard_symbols(
4221 Symbol_table
* symtab
,
4224 Output_section
* feedback_section
= layout
->find_output_section(".feedback");
4226 if (feedback_section
!= NULL
)
4228 symtab
->define_in_output_data("__feedback_section_end",
4230 Symbol_table::PREDEFINED
,
4238 true, // offset_is_from_end
4243 // Finalize the sections.
4245 template<int size
, bool big_endian
>
4247 Target_tilegx
<size
, big_endian
>::do_finalize_sections(
4249 const Input_objects
*,
4250 Symbol_table
* symtab
)
4252 const Reloc_section
* rel_plt
= (this->plt_
== NULL
4254 : this->plt_
->rela_plt());
4255 layout
->add_target_dynamic_tags(false, this->got_plt_
, rel_plt
,
4256 this->rela_dyn_
, true, true);
4258 // Emit any relocs we saved in an attempt to avoid generating COPY
4260 if (this->copy_relocs_
.any_saved_relocs())
4261 this->copy_relocs_
.emit(this->rela_dyn_section(layout
));
4263 // Set the size of the _GLOBAL_OFFSET_TABLE_ symbol to the size of
4264 // the .got section.
4265 Symbol
* sym
= this->global_offset_table_
;
4268 uint64_t data_size
= this->got_
->current_data_size();
4269 symtab
->get_sized_symbol
<size
>(sym
)->set_symsize(data_size
);
4271 // If the .got section is more than 0x8000 bytes, we add
4272 // 0x8000 to the value of _GLOBAL_OFFSET_TABLE_, so that 16
4273 // bit relocations have a greater chance of working.
4274 if (data_size
>= 0x8000)
4275 symtab
->get_sized_symbol
<size
>(sym
)->set_value(
4276 symtab
->get_sized_symbol
<size
>(sym
)->value() + 0x8000);
4279 if (parameters
->doing_static_link()
4280 && (this->plt_
== NULL
|| !this->plt_
->has_irelative_section()))
4282 // If linking statically, make sure that the __rela_iplt symbols
4283 // were defined if necessary, even if we didn't create a PLT.
4284 static const Define_symbol_in_segment syms
[] =
4287 "__rela_iplt_start", // name
4288 elfcpp::PT_LOAD
, // segment_type
4289 elfcpp::PF_W
, // segment_flags_set
4290 elfcpp::PF(0), // segment_flags_clear
4293 elfcpp::STT_NOTYPE
, // type
4294 elfcpp::STB_GLOBAL
, // binding
4295 elfcpp::STV_HIDDEN
, // visibility
4297 Symbol::SEGMENT_START
, // offset_from_base
4301 "__rela_iplt_end", // name
4302 elfcpp::PT_LOAD
, // segment_type
4303 elfcpp::PF_W
, // segment_flags_set
4304 elfcpp::PF(0), // segment_flags_clear
4307 elfcpp::STT_NOTYPE
, // type
4308 elfcpp::STB_GLOBAL
, // binding
4309 elfcpp::STV_HIDDEN
, // visibility
4311 Symbol::SEGMENT_START
, // offset_from_base
4316 symtab
->define_symbols(layout
, 2, syms
,
4317 layout
->script_options()->saw_sections_clause());
4321 // Perform a relocation.
4323 template<int size
, bool big_endian
>
4325 Target_tilegx
<size
, big_endian
>::Relocate::relocate(
4326 const Relocate_info
<size
, big_endian
>* relinfo
,
4327 Target_tilegx
<size
, big_endian
>* target
,
4330 const elfcpp::Rela
<size
, big_endian
>& rela
,
4331 unsigned int r_type
,
4332 const Sized_symbol
<size
>* gsym
,
4333 const Symbol_value
<size
>* psymval
,
4334 unsigned char* view
,
4335 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
4341 typedef Tilegx_relocate_functions
<size
, big_endian
> TilegxReloc
;
4342 typename
TilegxReloc::Tilegx_howto r_howto
;
4344 const Sized_relobj_file
<size
, big_endian
>* object
= relinfo
->object
;
4346 // Pick the value to use for symbols defined in the PLT.
4347 Symbol_value
<size
> symval
;
4349 && gsym
->use_plt_offset(Scan::get_reference_flags(r_type
)))
4351 symval
.set_output_value(target
->plt_address_for_global(gsym
));
4354 else if (gsym
== NULL
&& psymval
->is_ifunc_symbol())
4356 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
4357 if (object
->local_has_plt_offset(r_sym
))
4359 symval
.set_output_value(target
->plt_address_for_local(object
, r_sym
));
4364 elfcpp::Elf_Xword addend
= rela
.get_r_addend();
4366 // Get the GOT offset if needed.
4367 // For tilegx, the GOT pointer points to the start of the GOT section.
4368 bool have_got_offset
= false;
4370 int got_base
= target
->got_
!= NULL
4371 ? target
->got_
->current_data_size() >= 0x8000 ? 0x8000 : 0
4373 unsigned int got_type
= GOT_TYPE_STANDARD
;
4374 bool always_apply_relocation
= false;
4377 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
4378 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
4379 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
4380 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
4381 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
4382 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
4385 gold_assert(gsym
->has_got_offset(got_type
));
4386 got_offset
= gsym
->got_offset(got_type
) - got_base
;
4390 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
4391 gold_assert(object
->local_has_got_offset(r_sym
, got_type
));
4393 object
->local_got_offset(r_sym
, got_type
) - got_base
;
4395 have_got_offset
= true;
4402 r_howto
= TilegxReloc::howto
[r_type
];
4405 case elfcpp::R_TILEGX_NONE
:
4406 case elfcpp::R_TILEGX_GNU_VTINHERIT
:
4407 case elfcpp::R_TILEGX_GNU_VTENTRY
:
4410 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
4411 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
4412 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
4413 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
4414 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
4415 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
4416 gold_assert(have_got_offset
);
4417 symval
.set_output_value(got_offset
);
4419 always_apply_relocation
= true;
4422 // when under PIC mode, these relocations are deferred to rtld
4423 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
4424 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
4425 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
4426 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
4427 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
4428 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
4429 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
4430 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
4431 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
4432 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
4433 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
4434 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
4435 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
4436 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
4437 if (always_apply_relocation
4438 || !parameters
->options().output_is_position_independent())
4439 TilegxReloc::imm_x_general(view
, object
, psymval
, addend
, r_howto
);
4442 case elfcpp::R_TILEGX_JUMPOFF_X1
:
4443 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT
:
4444 gold_assert(gsym
== NULL
4445 || gsym
->has_plt_offset()
4446 || gsym
->final_value_is_known()
4447 || (gsym
->is_defined()
4448 && !gsym
->is_from_dynobj()
4449 && !gsym
->is_preemptible()));
4450 TilegxReloc::imm_x_pcrel_general(view
, object
, psymval
, addend
,
4455 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL
:
4456 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
4457 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL
:
4458 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
4459 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL
:
4460 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
4461 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL
:
4462 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
4463 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL
:
4464 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
4465 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL
:
4466 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
4467 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
4468 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
4469 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
:
4470 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
4471 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
:
4472 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
4473 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
:
4474 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
4475 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
:
4476 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
4477 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
:
4478 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
4479 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
:
4480 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
4481 TilegxReloc::imm_x_pcrel_general(view
, object
, psymval
, addend
,
4485 case elfcpp::R_TILEGX_BROFF_X1
:
4486 case elfcpp::R_TILEGX_DEST_IMM8_X1
:
4487 TilegxReloc::imm_x_two_part_general(view
, object
, psymval
,
4488 addend
, address
, r_type
);
4492 // below are general relocation types, which can be
4493 // handled by target-independent handlers
4494 case elfcpp::R_TILEGX_64
:
4495 TilegxReloc::abs64(view
, object
, psymval
, addend
);
4498 case elfcpp::R_TILEGX_64_PCREL
:
4499 TilegxReloc::pc_abs64(view
, object
, psymval
, addend
, address
);
4502 case elfcpp::R_TILEGX_32
:
4503 TilegxReloc::abs32(view
, object
, psymval
, addend
);
4506 case elfcpp::R_TILEGX_32_PCREL
:
4507 TilegxReloc::pc_abs32(view
, object
, psymval
, addend
, address
);
4510 case elfcpp::R_TILEGX_16
:
4511 TilegxReloc::abs16(view
, object
, psymval
, addend
);
4514 case elfcpp::R_TILEGX_16_PCREL
:
4515 TilegxReloc::pc_abs16(view
, object
, psymval
, addend
, address
);
4518 case elfcpp::R_TILEGX_8
:
4519 Relocate_functions
<size
, big_endian
>::rela8(view
, object
,
4523 case elfcpp::R_TILEGX_8_PCREL
:
4524 Relocate_functions
<size
, big_endian
>::pcrela8(view
, object
,
4525 psymval
, addend
, address
);
4528 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
4529 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
4530 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
4531 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
4532 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
4533 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
4534 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
4535 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
4536 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
4537 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
4538 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
4539 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
4540 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
4541 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
4542 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
4543 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
4544 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
4545 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
4546 case elfcpp::R_TILEGX_TLS_GD_CALL
:
4547 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
4548 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
4549 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
4550 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
4551 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
4552 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
4553 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
4554 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
4555 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
4557 const bool is_final
= (gsym
== NULL
4558 ? !parameters
->options().shared()
4559 : gsym
->final_value_is_known());
4560 tls::Tls_optimization opt_t
=
4561 Target_tilegx
<size
, big_endian
>::optimize_tls_reloc(is_final
,
4567 case elfcpp::R_TILEGX_TLS_GD_CALL
:
4569 if (opt_t
== tls::TLSOPT_NONE
) {
4570 Symbol
*tls_sym
= relinfo
->symtab
->lookup("__tls_get_addr");
4571 symval
.set_output_value(
4572 target
->plt_address_for_global(tls_sym
));
4574 TilegxReloc::imm_x_pcrel_general(view
, object
, psymval
,
4575 addend
, address
, r_howto
);
4577 else if (opt_t
== tls::TLSOPT_TO_IE
4578 || opt_t
== tls::TLSOPT_TO_LE
)
4579 TilegxReloc::tls_relax(view
, r_type
, opt_t
);
4583 // XX_TLS_GD is the same as normal X_GOT relocation
4584 // except allocating a got entry pair,
4585 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
4586 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
4587 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
4588 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
4589 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
4590 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
4591 if (opt_t
== tls::TLSOPT_NONE
) {
4592 got_type
= GOT_TYPE_TLS_PAIR
;
4593 have_got_offset
= true;
4594 } else if (opt_t
== tls::TLSOPT_TO_IE
) {
4595 got_type
= GOT_TYPE_TLS_OFFSET
;
4596 have_got_offset
= true;
4598 goto do_update_value
;
4599 // XX_TLS_IE is the same as normal X_GOT relocation
4600 // except allocating one additional runtime relocation
4601 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
4602 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
4603 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
4604 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
4605 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
4606 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
4607 if (opt_t
== tls::TLSOPT_NONE
) {
4608 got_type
= GOT_TYPE_TLS_OFFSET
;
4609 have_got_offset
= true;
4612 if (have_got_offset
) {
4614 gold_assert(gsym
->has_got_offset(got_type
));
4615 got_offset
= gsym
->got_offset(got_type
) - got_base
;
4618 = elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
4619 gold_assert(object
->local_has_got_offset(r_sym
, got_type
));
4621 object
->local_got_offset(r_sym
, got_type
) - got_base
;
4625 if (opt_t
== tls::TLSOPT_NONE
4626 || opt_t
== tls::TLSOPT_TO_IE
) {
4627 // for both GD/IE, these relocations
4628 // actually calculate got offset, so
4629 // there behavior are the same
4630 gold_assert(have_got_offset
);
4631 symval
.set_output_value(got_offset
);
4634 TilegxReloc::imm_x_general(view
, object
, psymval
,
4637 } // else if (opt_t == tls::TLSOPT_TO_LE)
4638 // both GD/IE are turned into LE, which
4639 // is absolute relocation.
4649 // t_var1 | t_var2 | t_var3 | ...
4650 // --------------------------------------------------
4652 // so offset to tp should be negative, we get offset
4653 // from the following formular for LE
4655 // t_var1_off = t_var1_sym_value - tls_section_start
4657 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
4658 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
4659 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
4660 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
4661 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
4662 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
4664 Output_segment
*tls_segment
= relinfo
->layout
->tls_segment();
4665 if (tls_segment
== NULL
) {
4666 gold_assert(parameters
->errors()->error_count() > 0
4667 || issue_undefined_symbol_error(gsym
));
4671 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
4672 = psymval
->value(relinfo
->object
, 0);
4673 symval
.set_output_value(value
);
4675 TilegxReloc::imm_x_general(view
, object
, psymval
,
4681 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
4682 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
4683 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
4684 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
4685 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
4686 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
4687 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
4688 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
4689 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
4690 TilegxReloc::tls_relax(view
, r_type
, opt_t
);
4699 // below are outstanding relocs
4700 // should not existed in static linking stage
4701 case elfcpp::R_TILEGX_COPY
:
4702 case elfcpp::R_TILEGX_GLOB_DAT
:
4703 case elfcpp::R_TILEGX_JMP_SLOT
:
4704 case elfcpp::R_TILEGX_RELATIVE
:
4705 case elfcpp::R_TILEGX_TLS_TPOFF32
:
4706 case elfcpp::R_TILEGX_TLS_TPOFF64
:
4707 case elfcpp::R_TILEGX_TLS_DTPMOD32
:
4708 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
4709 case elfcpp::R_TILEGX_TLS_DTPOFF32
:
4710 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
4711 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
4712 _("unexpected reloc %u in object file"),
4717 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
4718 _("unsupported reloc %u"),
4726 // Relocate section data.
4728 template<int size
, bool big_endian
>
4730 Target_tilegx
<size
, big_endian
>::relocate_section(
4731 const Relocate_info
<size
, big_endian
>* relinfo
,
4732 unsigned int sh_type
,
4733 const unsigned char* prelocs
,
4735 Output_section
* output_section
,
4736 bool needs_special_offset_handling
,
4737 unsigned char* view
,
4738 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
4739 section_size_type view_size
,
4740 const Reloc_symbol_changes
* reloc_symbol_changes
)
4742 typedef Target_tilegx
<size
, big_endian
> Tilegx
;
4743 typedef typename Target_tilegx
<size
, big_endian
>::Relocate Tilegx_relocate
;
4745 gold_assert(sh_type
== elfcpp::SHT_RELA
);
4747 gold::relocate_section
<size
, big_endian
, Tilegx
, elfcpp::SHT_RELA
,
4748 Tilegx_relocate
, gold::Default_comdat_behavior
>(
4754 needs_special_offset_handling
,
4758 reloc_symbol_changes
);
4761 // Apply an incremental relocation. Incremental relocations always refer
4762 // to global symbols.
4764 template<int size
, bool big_endian
>
4766 Target_tilegx
<size
, big_endian
>::apply_relocation(
4767 const Relocate_info
<size
, big_endian
>* relinfo
,
4768 typename
elfcpp::Elf_types
<size
>::Elf_Addr r_offset
,
4769 unsigned int r_type
,
4770 typename
elfcpp::Elf_types
<size
>::Elf_Swxword r_addend
,
4772 unsigned char* view
,
4773 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
4774 section_size_type view_size
)
4776 gold::apply_relocation
<size
, big_endian
, Target_tilegx
<size
, big_endian
>,
4777 typename Target_tilegx
<size
, big_endian
>::Relocate
>(
4789 // Return the size of a relocation while scanning during a relocatable
4792 template<int size
, bool big_endian
>
4794 Target_tilegx
<size
,big_endian
>::Relocatable_size_for_reloc::get_size_for_reloc(
4795 unsigned int, Relobj
*)
4797 // We are always SHT_RELA, so we should never get here.
4802 // Scan the relocs during a relocatable link.
4804 template<int size
, bool big_endian
>
4806 Target_tilegx
<size
, big_endian
>::scan_relocatable_relocs(
4807 Symbol_table
* symtab
,
4809 Sized_relobj_file
<size
, big_endian
>* object
,
4810 unsigned int data_shndx
,
4811 unsigned int sh_type
,
4812 const unsigned char* prelocs
,
4814 Output_section
* output_section
,
4815 bool needs_special_offset_handling
,
4816 size_t local_symbol_count
,
4817 const unsigned char* plocal_symbols
,
4818 Relocatable_relocs
* rr
)
4820 gold_assert(sh_type
== elfcpp::SHT_RELA
);
4822 typedef gold::Default_scan_relocatable_relocs
<elfcpp::SHT_RELA
,
4823 Relocatable_size_for_reloc
> Scan_relocatable_relocs
;
4825 gold::scan_relocatable_relocs
<size
, big_endian
, elfcpp::SHT_RELA
,
4826 Scan_relocatable_relocs
>(
4834 needs_special_offset_handling
,
4840 // Relocate a section during a relocatable link.
4842 template<int size
, bool big_endian
>
4844 Target_tilegx
<size
, big_endian
>::relocate_relocs(
4845 const Relocate_info
<size
, big_endian
>* relinfo
,
4846 unsigned int sh_type
,
4847 const unsigned char* prelocs
,
4849 Output_section
* output_section
,
4850 typename
elfcpp::Elf_types
<size
>::Elf_Off offset_in_output_section
,
4851 const Relocatable_relocs
* rr
,
4852 unsigned char* view
,
4853 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
4854 section_size_type view_size
,
4855 unsigned char* reloc_view
,
4856 section_size_type reloc_view_size
)
4858 gold_assert(sh_type
== elfcpp::SHT_RELA
);
4860 gold::relocate_relocs
<size
, big_endian
, elfcpp::SHT_RELA
>(
4865 offset_in_output_section
,
4874 // Return the value to use for a dynamic which requires special
4875 // treatment. This is how we support equality comparisons of function
4876 // pointers across shared library boundaries, as described in the
4877 // processor specific ABI supplement.
4879 template<int size
, bool big_endian
>
4881 Target_tilegx
<size
, big_endian
>::do_dynsym_value(const Symbol
* gsym
) const
4883 gold_assert(gsym
->is_from_dynobj() && gsym
->has_plt_offset());
4884 return this->plt_address_for_global(gsym
);
4887 // Return the value to use for the base of a DW_EH_PE_datarel offset
4888 // in an FDE. Solaris and SVR4 use DW_EH_PE_datarel because their
4889 // assembler can not write out the difference between two labels in
4890 // different sections, so instead of using a pc-relative value they
4891 // use an offset from the GOT.
4893 template<int size
, bool big_endian
>
4895 Target_tilegx
<size
, big_endian
>::do_ehframe_datarel_base() const
4897 gold_assert(this->global_offset_table_
!= NULL
);
4898 Symbol
* sym
= this->global_offset_table_
;
4899 Sized_symbol
<size
>* ssym
= static_cast<Sized_symbol
<size
>*>(sym
);
4900 return ssym
->value();
4903 // The selector for tilegx object files.
4905 template<int size
, bool big_endian
>
4906 class Target_selector_tilegx
: public Target_selector
4909 Target_selector_tilegx()
4910 : Target_selector(elfcpp::EM_TILEGX
, size
, big_endian
,
4912 ? (big_endian
? "elf64-tilegx-be" : "elf64-tilegx-le")
4913 : (big_endian
? "elf32-tilegx-be"
4914 : "elf32-tilegx-le")),
4916 ? (big_endian
? "elf64tilegx_be" : "elf64tilegx")
4917 : (big_endian
? "elf32tilegx_be" : "elf32tilegx")))
4921 do_instantiate_target()
4922 { return new Target_tilegx
<size
, big_endian
>(); }
4926 Target_selector_tilegx
<64, false> target_selector_tilegx64_le
;
4927 Target_selector_tilegx
<32, false> target_selector_tilegx32_le
;
4928 Target_selector_tilegx
<64, true> target_selector_tilegx64_be
;
4929 Target_selector_tilegx
<32, true> target_selector_tilegx32_be
;
4930 } // End anonymous namespace.