1 // tilegx.cc -- tilegx target support for gold.
3 // Copyright 2012, 2013 Free Software Foundation, Inc.
4 // Written by Jiong Wang (jiwang@tilera.com)
6 // This file is part of gold.
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
29 #include "parameters.h"
36 #include "copy-relocs.h"
38 #include "target-reloc.h"
39 #include "target-select.h"
44 // the first got entry reserved
45 const int32_t TILEGX_GOT_RESERVE_COUNT
= 1;
47 // the first two .got.plt entry reserved
48 const int32_t TILEGX_GOTPLT_RESERVE_COUNT
= 2;
50 // 1. for both 64/32 bit mode, the instruction bundle is always 64bit.
51 // 2. thus .plt section should always be aligned to 64 bit.
52 const int32_t TILEGX_INST_BUNDLE_SIZE
= 64;
59 // A class to handle the PLT data.
60 // This is an abstract base class that handles most of the linker details
61 // but does not know the actual contents of PLT entries. The derived
62 // classes below fill in those details.
64 template<int size
, bool big_endian
>
65 class Output_data_plt_tilegx
: public Output_section_data
68 typedef Output_data_reloc
<elfcpp::SHT_RELA
, true,size
, big_endian
>
71 Output_data_plt_tilegx(Layout
* layout
, uint64_t addralign
,
72 Output_data_got
<size
, big_endian
>* got
,
73 Output_data_space
* got_plt
,
74 Output_data_space
* got_irelative
)
75 : Output_section_data(addralign
), layout_(layout
),
76 irelative_rel_(NULL
), got_(got
), got_plt_(got_plt
),
77 got_irelative_(got_irelative
), count_(0),
78 irelative_count_(0), free_list_()
79 { this->init(layout
); }
81 Output_data_plt_tilegx(Layout
* layout
, uint64_t plt_entry_size
,
82 Output_data_got
<size
, big_endian
>* got
,
83 Output_data_space
* got_plt
,
84 Output_data_space
* got_irelative
,
85 unsigned int plt_count
)
86 : Output_section_data((plt_count
+ 1) * plt_entry_size
,
87 TILEGX_INST_BUNDLE_SIZE
, false),
88 layout_(layout
), irelative_rel_(NULL
), got_(got
),
89 got_plt_(got_plt
), got_irelative_(got_irelative
), count_(plt_count
),
90 irelative_count_(0), free_list_()
94 // Initialize the free list and reserve the first entry.
95 this->free_list_
.init((plt_count
+ 1) * plt_entry_size
, false);
96 this->free_list_
.remove(0, plt_entry_size
);
99 // Initialize the PLT section.
101 init(Layout
* layout
);
103 // Add an entry to the PLT.
105 add_entry(Symbol_table
*, Layout
*, Symbol
* gsym
);
107 // Add an entry to the PLT for a local STT_GNU_IFUNC symbol.
109 add_local_ifunc_entry(Symbol_table
*, Layout
*,
110 Sized_relobj_file
<size
, big_endian
>*, unsigned int);
112 // Add the relocation for a PLT entry.
114 add_relocation(Symbol_table
*, Layout
*, Symbol
*, unsigned int);
116 // Return the .rela.plt section data.
119 { return this->rel_
; }
121 // Return where the IRELATIVE relocations should go in the PLT
124 rela_irelative(Symbol_table
*, Layout
*);
126 // Return whether we created a section for IRELATIVE relocations.
128 has_irelative_section() const
129 { return this->irelative_rel_
!= NULL
; }
131 // Return the number of PLT entries.
134 { return this->count_
+ this->irelative_count_
; }
136 // Return the offset of the first non-reserved PLT entry.
138 first_plt_entry_offset()
139 { return this->get_plt_entry_size(); }
141 // Return the size of a PLT entry.
143 get_plt_entry_size() const
144 { return plt_entry_size
; }
146 // Reserve a slot in the PLT for an existing symbol in an incremental update.
148 reserve_slot(unsigned int plt_index
)
150 this->free_list_
.remove((plt_index
+ 1) * this->get_plt_entry_size(),
151 (plt_index
+ 2) * this->get_plt_entry_size());
154 // Return the PLT address to use for a global symbol.
156 address_for_global(const Symbol
*);
158 // Return the PLT address to use for a local symbol.
160 address_for_local(const Relobj
*, unsigned int symndx
);
163 // Fill in the first PLT entry.
165 fill_first_plt_entry(unsigned char*);
167 // Fill in a normal PLT entry. Returns the offset into the entry that
168 // should be the initial GOT slot value.
170 fill_plt_entry(unsigned char*,
171 typename
elfcpp::Elf_types
<size
>::Elf_Addr
,
173 typename
elfcpp::Elf_types
<size
>::Elf_Addr
,
174 unsigned int, unsigned int);
177 do_adjust_output_section(Output_section
* os
);
179 // Write to a map file.
181 do_print_to_mapfile(Mapfile
* mapfile
) const
182 { mapfile
->print_output_data(this, _("** PLT")); }
185 // Set the final size.
187 set_final_data_size();
189 // Write out the PLT data.
191 do_write(Output_file
*);
193 // A pointer to the Layout class, so that we can find the .dynamic
194 // section when we write out the GOT PLT section.
196 // The reloc section.
198 // The IRELATIVE relocs, if necessary. These must follow the
199 // regular PLT relocations.
200 Reloc_section
* irelative_rel_
;
202 Output_data_got
<size
, big_endian
>* got_
;
203 // The .got.plt section.
204 Output_data_space
* got_plt_
;
205 // The part of the .got.plt section used for IRELATIVE relocs.
206 Output_data_space
* got_irelative_
;
207 // The number of PLT entries.
209 // Number of PLT entries with R_TILEGX_IRELATIVE relocs. These
210 // follow the regular PLT entries.
211 unsigned int irelative_count_
;
212 // List of available regions within the section, for incremental
214 Free_list free_list_
;
215 // The size of an entry in the PLT.
216 static const int plt_entry_size
= 40;
217 // The first entry in the PLT.
218 static const unsigned char first_plt_entry
[plt_entry_size
];
219 // Other entries in the PLT for an executable.
220 static const unsigned char plt_entry
[plt_entry_size
];
223 // The tilegx target class.
225 // http://www.tilera.com/scm
226 // TLS info comes from
227 // http://people.redhat.com/drepper/tls.pdf
229 template<int size
, bool big_endian
>
230 class Target_tilegx
: public Sized_target
<size
, big_endian
>
234 typedef Output_data_reloc
<elfcpp::SHT_RELA
, true, size
, big_endian
>
237 Target_tilegx(const Target::Target_info
* info
= &tilegx_info
)
238 : Sized_target
<size
, big_endian
>(info
),
239 got_(NULL
), plt_(NULL
), got_plt_(NULL
), got_irelative_(NULL
),
240 global_offset_table_(NULL
), tilegx_dynamic_(NULL
), rela_dyn_(NULL
),
241 rela_irelative_(NULL
), copy_relocs_(elfcpp::R_TILEGX_COPY
),
242 dynbss_(NULL
), got_mod_index_offset_(-1U),
243 tls_get_addr_sym_defined_(false)
246 // Scan the relocations to look for symbol adjustments.
248 gc_process_relocs(Symbol_table
* symtab
,
250 Sized_relobj_file
<size
, big_endian
>* object
,
251 unsigned int data_shndx
,
252 unsigned int sh_type
,
253 const unsigned char* prelocs
,
255 Output_section
* output_section
,
256 bool needs_special_offset_handling
,
257 size_t local_symbol_count
,
258 const unsigned char* plocal_symbols
);
260 // Scan the relocations to look for symbol adjustments.
262 scan_relocs(Symbol_table
* symtab
,
264 Sized_relobj_file
<size
, big_endian
>* object
,
265 unsigned int data_shndx
,
266 unsigned int sh_type
,
267 const unsigned char* prelocs
,
269 Output_section
* output_section
,
270 bool needs_special_offset_handling
,
271 size_t local_symbol_count
,
272 const unsigned char* plocal_symbols
);
274 // Finalize the sections.
276 do_finalize_sections(Layout
*, const Input_objects
*, Symbol_table
*);
278 // Return the value to use for a dynamic which requires special
281 do_dynsym_value(const Symbol
*) const;
283 // Relocate a section.
285 relocate_section(const Relocate_info
<size
, big_endian
>*,
286 unsigned int sh_type
,
287 const unsigned char* prelocs
,
289 Output_section
* output_section
,
290 bool needs_special_offset_handling
,
292 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
293 section_size_type view_size
,
294 const Reloc_symbol_changes
*);
296 // Scan the relocs during a relocatable link.
298 scan_relocatable_relocs(Symbol_table
* symtab
,
300 Sized_relobj_file
<size
, big_endian
>* object
,
301 unsigned int data_shndx
,
302 unsigned int sh_type
,
303 const unsigned char* prelocs
,
305 Output_section
* output_section
,
306 bool needs_special_offset_handling
,
307 size_t local_symbol_count
,
308 const unsigned char* plocal_symbols
,
309 Relocatable_relocs
*);
311 // Relocate a section during a relocatable link.
314 const Relocate_info
<size
, big_endian
>*,
315 unsigned int sh_type
,
316 const unsigned char* prelocs
,
318 Output_section
* output_section
,
319 typename
elfcpp::Elf_types
<size
>::Elf_Off offset_in_output_section
,
320 const Relocatable_relocs
*,
322 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
323 section_size_type view_size
,
324 unsigned char* reloc_view
,
325 section_size_type reloc_view_size
);
327 // Return whether SYM is defined by the ABI.
329 do_is_defined_by_abi(const Symbol
* sym
) const
330 { return strcmp(sym
->name(), "__tls_get_addr") == 0; }
332 // define tilegx specific symbols
334 do_define_standard_symbols(Symbol_table
*, Layout
*);
336 // Return the PLT section.
338 do_plt_address_for_global(const Symbol
* gsym
) const
339 { return this->plt_section()->address_for_global(gsym
); }
342 do_plt_address_for_local(const Relobj
* relobj
, unsigned int symndx
) const
343 { return this->plt_section()->address_for_local(relobj
, symndx
); }
345 // This function should be defined in targets that can use relocation
346 // types to determine (implemented in local_reloc_may_be_function_pointer
347 // and global_reloc_may_be_function_pointer)
348 // if a function's pointer is taken. ICF uses this in safe mode to only
349 // fold those functions whose pointer is defintely not taken. For tilegx
350 // pie binaries, safe ICF cannot be done by looking at relocation types.
352 do_can_check_for_function_pointers() const
355 // Return the base for a DW_EH_PE_datarel encoding.
357 do_ehframe_datarel_base() const;
359 // Return whether there is a GOT section.
361 has_got_section() const
362 { return this->got_
!= NULL
; }
364 // Return the size of the GOT section.
368 gold_assert(this->got_
!= NULL
);
369 return this->got_
->data_size();
372 // Return the number of entries in the GOT.
374 got_entry_count() const
376 if (this->got_
== NULL
)
378 return this->got_size() / (size
/ 8);
381 // Return the number of entries in the PLT.
383 plt_entry_count() const;
385 // Return the offset of the first non-reserved PLT entry.
387 first_plt_entry_offset() const;
389 // Return the size of each PLT entry.
391 plt_entry_size() const;
393 // Create the GOT section for an incremental update.
394 Output_data_got_base
*
395 init_got_plt_for_update(Symbol_table
* symtab
,
397 unsigned int got_count
,
398 unsigned int plt_count
);
400 // Reserve a GOT entry for a local symbol, and regenerate any
401 // necessary dynamic relocations.
403 reserve_local_got_entry(unsigned int got_index
,
404 Sized_relobj
<size
, big_endian
>* obj
,
406 unsigned int got_type
);
408 // Reserve a GOT entry for a global symbol, and regenerate any
409 // necessary dynamic relocations.
411 reserve_global_got_entry(unsigned int got_index
, Symbol
* gsym
,
412 unsigned int got_type
);
414 // Register an existing PLT entry for a global symbol.
416 register_global_plt_entry(Symbol_table
*, Layout
*, unsigned int plt_index
,
419 // Force a COPY relocation for a given symbol.
421 emit_copy_reloc(Symbol_table
*, Symbol
*, Output_section
*, off_t
);
423 // Apply an incremental relocation.
425 apply_relocation(const Relocate_info
<size
, big_endian
>* relinfo
,
426 typename
elfcpp::Elf_types
<size
>::Elf_Addr r_offset
,
428 typename
elfcpp::Elf_types
<size
>::Elf_Swxword r_addend
,
431 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
432 section_size_type view_size
);
435 // The class which scans relocations.
440 : issued_non_pic_error_(false)
444 get_reference_flags(unsigned int r_type
);
447 local(Symbol_table
* symtab
, Layout
* layout
, Target_tilegx
* target
,
448 Sized_relobj_file
<size
, big_endian
>* object
,
449 unsigned int data_shndx
,
450 Output_section
* output_section
,
451 const elfcpp::Rela
<size
, big_endian
>& reloc
, unsigned int r_type
,
452 const elfcpp::Sym
<size
, big_endian
>& lsym
,
456 global(Symbol_table
* symtab
, Layout
* layout
, Target_tilegx
* target
,
457 Sized_relobj_file
<size
, big_endian
>* object
,
458 unsigned int data_shndx
,
459 Output_section
* output_section
,
460 const elfcpp::Rela
<size
, big_endian
>& reloc
, unsigned int r_type
,
464 local_reloc_may_be_function_pointer(Symbol_table
* symtab
, Layout
* layout
,
465 Target_tilegx
* target
,
466 Sized_relobj_file
<size
, big_endian
>* object
,
467 unsigned int data_shndx
,
468 Output_section
* output_section
,
469 const elfcpp::Rela
<size
, big_endian
>& reloc
,
471 const elfcpp::Sym
<size
, big_endian
>& lsym
);
474 global_reloc_may_be_function_pointer(Symbol_table
* symtab
, Layout
* layout
,
475 Target_tilegx
* target
,
476 Sized_relobj_file
<size
, big_endian
>* object
,
477 unsigned int data_shndx
,
478 Output_section
* output_section
,
479 const elfcpp::Rela
<size
, big_endian
>& reloc
,
485 unsupported_reloc_local(Sized_relobj_file
<size
, big_endian
>*,
486 unsigned int r_type
);
489 unsupported_reloc_global(Sized_relobj_file
<size
, big_endian
>*,
490 unsigned int r_type
, Symbol
*);
493 check_non_pic(Relobj
*, unsigned int r_type
);
496 possible_function_pointer_reloc(unsigned int r_type
);
499 reloc_needs_plt_for_ifunc(Sized_relobj_file
<size
, big_endian
>*,
500 unsigned int r_type
);
502 // Whether we have issued an error about a non-PIC compilation.
503 bool issued_non_pic_error_
;
506 // The class which implements relocation.
517 // Do a relocation. Return false if the caller should not issue
518 // any warnings about this relocation.
520 relocate(const Relocate_info
<size
, big_endian
>*, Target_tilegx
*,
522 size_t relnum
, const elfcpp::Rela
<size
, big_endian
>&,
523 unsigned int r_type
, const Sized_symbol
<size
>*,
524 const Symbol_value
<size
>*,
525 unsigned char*, typename
elfcpp::Elf_types
<size
>::Elf_Addr
,
529 // A class which returns the size required for a relocation type,
530 // used while scanning relocs during a relocatable link.
531 class Relocatable_size_for_reloc
535 get_size_for_reloc(unsigned int, Relobj
*);
538 // Adjust TLS relocation type based on the options and whether this
539 // is a local symbol.
540 static tls::Tls_optimization
541 optimize_tls_reloc(bool is_final
, int r_type
);
543 // Get the GOT section, creating it if necessary.
544 Output_data_got
<size
, big_endian
>*
545 got_section(Symbol_table
*, Layout
*);
547 // Get the GOT PLT section.
549 got_plt_section() const
551 gold_assert(this->got_plt_
!= NULL
);
552 return this->got_plt_
;
555 // Create the PLT section.
557 make_plt_section(Symbol_table
* symtab
, Layout
* layout
);
559 // Create a PLT entry for a global symbol.
561 make_plt_entry(Symbol_table
*, Layout
*, Symbol
*);
563 // Create a PLT entry for a local STT_GNU_IFUNC symbol.
565 make_local_ifunc_plt_entry(Symbol_table
*, Layout
*,
566 Sized_relobj_file
<size
, big_endian
>* relobj
,
567 unsigned int local_sym_index
);
569 // Create a GOT entry for the TLS module index.
571 got_mod_index_entry(Symbol_table
* symtab
, Layout
* layout
,
572 Sized_relobj_file
<size
, big_endian
>* object
);
574 // Get the PLT section.
575 Output_data_plt_tilegx
<size
, big_endian
>*
578 gold_assert(this->plt_
!= NULL
);
582 // Get the dynamic reloc section, creating it if necessary.
584 rela_dyn_section(Layout
*);
586 // Get the section to use for IRELATIVE relocations.
588 rela_irelative_section(Layout
*);
590 // Add a potential copy relocation.
592 copy_reloc(Symbol_table
* symtab
, Layout
* layout
,
593 Sized_relobj_file
<size
, big_endian
>* object
,
594 unsigned int shndx
, Output_section
* output_section
,
595 Symbol
* sym
, const elfcpp::Rela
<size
, big_endian
>& reloc
)
597 this->copy_relocs_
.copy_reloc(symtab
, layout
,
598 symtab
->get_sized_symbol
<size
>(sym
),
599 object
, shndx
, output_section
,
600 reloc
, this->rela_dyn_section(layout
));
603 // Information about this specific target which we pass to the
604 // general Target structure.
605 static const Target::Target_info tilegx_info
;
607 // The types of GOT entries needed for this platform.
608 // These values are exposed to the ABI in an incremental link.
609 // Do not renumber existing values without changing the version
610 // number of the .gnu_incremental_inputs section.
613 GOT_TYPE_STANDARD
= 0, // GOT entry for a regular symbol
614 GOT_TYPE_TLS_OFFSET
= 1, // GOT entry for TLS offset
615 GOT_TYPE_TLS_PAIR
= 2, // GOT entry for TLS module/offset pair
616 GOT_TYPE_TLS_DESC
= 3 // GOT entry for TLS_DESC pair
619 // This type is used as the argument to the target specific
620 // relocation routines. The only target specific reloc is
621 // R_X86_64_TLSDESC against a local symbol.
624 Tlsdesc_info(Sized_relobj_file
<size
, big_endian
>* a_object
,
625 unsigned int a_r_sym
)
626 : object(a_object
), r_sym(a_r_sym
)
629 // The object in which the local symbol is defined.
630 Sized_relobj_file
<size
, big_endian
>* object
;
631 // The local symbol index in the object.
636 Output_data_got
<size
, big_endian
>* got_
;
638 Output_data_plt_tilegx
<size
, big_endian
>* plt_
;
639 // The GOT PLT section.
640 Output_data_space
* got_plt_
;
641 // The GOT section for IRELATIVE relocations.
642 Output_data_space
* got_irelative_
;
643 // The _GLOBAL_OFFSET_TABLE_ symbol.
644 Symbol
* global_offset_table_
;
645 // The _TILEGX_DYNAMIC_ symbol.
646 Symbol
* tilegx_dynamic_
;
647 // The dynamic reloc section.
648 Reloc_section
* rela_dyn_
;
649 // The section to use for IRELATIVE relocs.
650 Reloc_section
* rela_irelative_
;
651 // Relocs saved to avoid a COPY reloc.
652 Copy_relocs
<elfcpp::SHT_RELA
, size
, big_endian
> copy_relocs_
;
653 // Space for variables copied with a COPY reloc.
654 Output_data_space
* dynbss_
;
655 // Offset of the GOT entry for the TLS module index.
656 unsigned int got_mod_index_offset_
;
657 // True if the _tls_get_addr symbol has been defined.
658 bool tls_get_addr_sym_defined_
;
662 const Target::Target_info Target_tilegx
<64, false>::tilegx_info
=
665 false, // is_big_endian
666 elfcpp::EM_TILEGX
, // machine_code
667 false, // has_make_symbol
668 false, // has_resolve
669 false, // has_code_fill
670 true, // is_default_stack_executable
671 false, // can_icf_inline_merge_sections
673 "/lib/ld.so.1", // program interpreter
674 0x10000, // default_text_segment_address
675 0x10000, // abi_pagesize (overridable by -z max-page-size)
676 0x10000, // common_pagesize (overridable by -z common-page-size)
677 false, // isolate_execinstr
679 elfcpp::SHN_UNDEF
, // small_common_shndx
680 elfcpp::SHN_UNDEF
, // large_common_shndx
681 0, // small_common_section_flags
682 0, // large_common_section_flags
683 NULL
, // attributes_section
684 NULL
, // attributes_vendor
685 "_start" // entry_symbol_name
689 const Target::Target_info Target_tilegx
<32, false>::tilegx_info
=
692 false, // is_big_endian
693 elfcpp::EM_TILEGX
, // machine_code
694 false, // has_make_symbol
695 false, // has_resolve
696 false, // has_code_fill
697 true, // is_default_stack_executable
698 false, // can_icf_inline_merge_sections
700 "/lib32/ld.so.1", // program interpreter
701 0x10000, // default_text_segment_address
702 0x10000, // abi_pagesize (overridable by -z max-page-size)
703 0x10000, // common_pagesize (overridable by -z common-page-size)
704 false, // isolate_execinstr
706 elfcpp::SHN_UNDEF
, // small_common_shndx
707 elfcpp::SHN_UNDEF
, // large_common_shndx
708 0, // small_common_section_flags
709 0, // large_common_section_flags
710 NULL
, // attributes_section
711 NULL
, // attributes_vendor
712 "_start" // entry_symbol_name
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
743 const Target::Target_info Target_tilegx
<32, true>::tilegx_info
=
746 true, // is_big_endian
747 elfcpp::EM_TILEGX
, // machine_code
748 false, // has_make_symbol
749 false, // has_resolve
750 false, // has_code_fill
751 true, // is_default_stack_executable
752 false, // can_icf_inline_merge_sections
754 "/lib32/ld.so.1", // program interpreter
755 0x10000, // default_text_segment_address
756 0x10000, // abi_pagesize (overridable by -z max-page-size)
757 0x10000, // common_pagesize (overridable by -z common-page-size)
758 false, // isolate_execinstr
760 elfcpp::SHN_UNDEF
, // small_common_shndx
761 elfcpp::SHN_UNDEF
, // large_common_shndx
762 0, // small_common_section_flags
763 0, // large_common_section_flags
764 NULL
, // attributes_section
765 NULL
, // attributes_vendor
766 "_start" // entry_symbol_name
769 // tilegx relocation handlers
770 template<int size
, bool big_endian
>
771 class Tilegx_relocate_functions
774 // overflow check will be supported later
777 STATUS_OKAY
, // No error during relocation.
778 STATUS_OVERFLOW
, // Relocation overflow.
779 STATUS_BAD_RELOC
// Relocation cannot be applied.
784 // right shift operand by this number of bits.
785 unsigned char srshift
;
787 // the offset to apply relocation.
788 unsigned char doffset
;
790 // set to 1 for pc-relative relocation.
791 unsigned char is_pcrel
;
793 // size in bits, or 0 if this table entry should be ignored.
796 // whether we need to check overflow.
797 unsigned char overflow
;
800 static const Tilegx_howto howto
[elfcpp::R_TILEGX_NUM
];
804 // Do a simple rela relocation
805 template<int valsize
>
807 rela(unsigned char* view
,
808 const Sized_relobj_file
<size
, big_endian
>* object
,
809 const Symbol_value
<size
>* psymval
,
810 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
811 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset
,
812 elfcpp::Elf_Xword bitmask
)
814 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
815 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
816 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
819 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
)) >> srshift
;
821 reloc
= psymval
->value(object
, addend
) >> srshift
;
823 elfcpp::Elf_Xword dst_mask
= bitmask
<< doffset
;
828 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| (reloc
<<doffset
));
831 // Do a simple rela relocation
832 template<int valsize
>
834 rela_ua(unsigned char* view
,
835 const Sized_relobj_file
<size
, big_endian
>* object
,
836 const Symbol_value
<size
>* psymval
,
837 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
838 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset
,
839 elfcpp::Elf_Xword bitmask
)
841 typedef typename
elfcpp::Swap_unaligned
<valsize
, big_endian
>::Valtype
843 unsigned char* wv
= view
;
844 Valtype val
= elfcpp::Swap_unaligned
<valsize
, big_endian
>::readval(wv
);
847 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
)) >> srshift
;
849 reloc
= psymval
->value(object
, addend
) >> srshift
;
851 elfcpp::Elf_Xword dst_mask
= bitmask
<< doffset
;
856 elfcpp::Swap_unaligned
<valsize
, big_endian
>::writeval(wv
,
857 val
| (reloc
<<doffset
));
860 template<int valsize
>
862 rela(unsigned char* view
,
863 const Sized_relobj_file
<size
, big_endian
>* object
,
864 const Symbol_value
<size
>* psymval
,
865 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
866 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset1
,
867 elfcpp::Elf_Xword bitmask1
, elfcpp::Elf_Xword doffset2
,
868 elfcpp::Elf_Xword bitmask2
)
870 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
871 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
872 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
875 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
)) >> srshift
;
877 reloc
= psymval
->value(object
, addend
) >> srshift
;
879 elfcpp::Elf_Xword dst_mask
= (bitmask1
<< doffset1
)
880 | (bitmask2
<< doffset2
);
882 reloc
= ((reloc
& bitmask1
) << doffset1
)
883 | ((reloc
& bitmask2
) << doffset2
);
885 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| reloc
);
889 // Do a simple PC relative relocation with a Symbol_value with the
890 // addend in the relocation.
891 template<int valsize
>
893 pcrela(unsigned char* view
,
894 const Sized_relobj_file
<size
, big_endian
>* object
,
895 const Symbol_value
<size
>* psymval
,
896 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
897 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
898 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset
,
899 elfcpp::Elf_Xword bitmask
)
902 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
903 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
904 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
907 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
) - address
)
910 reloc
= (psymval
->value(object
, addend
) - address
) >> srshift
;
912 elfcpp::Elf_Xword dst_mask
= bitmask
<< doffset
;
916 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| (reloc
<<doffset
));
919 template<int valsize
>
921 pcrela_ua(unsigned char* view
,
922 const Sized_relobj_file
<size
, big_endian
>* object
,
923 const Symbol_value
<size
>* psymval
,
924 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
925 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
926 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset
,
927 elfcpp::Elf_Xword bitmask
)
930 typedef typename
elfcpp::Swap_unaligned
<valsize
, big_endian
>::Valtype
932 unsigned char* wv
= view
;
935 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
) - address
)
938 reloc
= (psymval
->value(object
, addend
) - address
) >> srshift
;
942 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, reloc
<< doffset
);
945 template<int valsize
>
947 pcrela(unsigned char* view
,
948 const Sized_relobj_file
<size
, big_endian
>* object
,
949 const Symbol_value
<size
>* psymval
,
950 typename
elfcpp::Swap
<size
, big_endian
>::Valtype addend
,
951 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
952 elfcpp::Elf_Xword srshift
, elfcpp::Elf_Xword doffset1
,
953 elfcpp::Elf_Xword bitmask1
, elfcpp::Elf_Xword doffset2
,
954 elfcpp::Elf_Xword bitmask2
)
957 typedef typename
elfcpp::Swap
<valsize
, big_endian
>::Valtype Valtype
;
958 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
959 Valtype val
= elfcpp::Swap
<valsize
, big_endian
>::readval(wv
);
962 reloc
= Bits
<32>::sign_extend(psymval
->value(object
, addend
) - address
)
965 reloc
= (psymval
->value(object
, addend
) - address
) >> srshift
;
967 elfcpp::Elf_Xword dst_mask
= (bitmask1
<< doffset1
)
968 | (bitmask2
<< doffset2
);
970 reloc
= ((reloc
& bitmask1
) << doffset1
)
971 | ((reloc
& bitmask2
) << doffset2
);
973 elfcpp::Swap
<valsize
, big_endian
>::writeval(wv
, val
| reloc
);
976 typedef Tilegx_relocate_functions
<size
, big_endian
> This
;
977 typedef Relocate_functions
<size
, big_endian
> Base
;
982 abs64(unsigned char* view
,
983 const Sized_relobj_file
<size
, big_endian
>* object
,
984 const Symbol_value
<size
>* psymval
,
985 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
987 This::template rela_ua
<64>(view
, object
, psymval
, addend
, 0, 0,
988 0xffffffffffffffffllu
);
992 abs32(unsigned char* view
,
993 const Sized_relobj_file
<size
, big_endian
>* object
,
994 const Symbol_value
<size
>* psymval
,
995 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
997 This::template rela_ua
<32>(view
, object
, psymval
, addend
, 0, 0,
1002 abs16(unsigned char* view
,
1003 const Sized_relobj_file
<size
, big_endian
>* object
,
1004 const Symbol_value
<size
>* psymval
,
1005 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
)
1007 This::template rela_ua
<16>(view
, object
, psymval
, addend
, 0, 0,
1012 pc_abs64(unsigned char* view
,
1013 const Sized_relobj_file
<size
, big_endian
>* object
,
1014 const Symbol_value
<size
>* psymval
,
1015 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1016 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
1018 This::template pcrela_ua
<64>(view
, object
, psymval
, addend
, address
, 0, 0,
1019 0xffffffffffffffffllu
);
1023 pc_abs32(unsigned char* view
,
1024 const Sized_relobj_file
<size
, big_endian
>* object
,
1025 const Symbol_value
<size
>* psymval
,
1026 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1027 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
1029 This::template pcrela_ua
<32>(view
, object
, psymval
, addend
, address
, 0, 0,
1034 pc_abs16(unsigned char* view
,
1035 const Sized_relobj_file
<size
, big_endian
>* object
,
1036 const Symbol_value
<size
>* psymval
,
1037 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1038 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
)
1040 This::template pcrela_ua
<16>(view
, object
, psymval
, addend
, address
, 0, 0,
1045 imm_x_general(unsigned char* view
,
1046 const Sized_relobj_file
<size
, big_endian
>* object
,
1047 const Symbol_value
<size
>* psymval
,
1048 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1049 Tilegx_howto
&r_howto
)
1051 This::template rela
<64>(view
, object
, psymval
, addend
,
1052 (elfcpp::Elf_Xword
)(r_howto
.srshift
),
1053 (elfcpp::Elf_Xword
)(r_howto
.doffset
),
1054 (elfcpp::Elf_Xword
)((1 << r_howto
.bsize
) - 1));
1058 imm_x_pcrel_general(unsigned char* view
,
1059 const Sized_relobj_file
<size
, big_endian
>* object
,
1060 const Symbol_value
<size
>* psymval
,
1061 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1062 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
1063 Tilegx_howto
&r_howto
)
1065 This::template pcrela
<64>(view
, object
, psymval
, addend
, address
,
1066 (elfcpp::Elf_Xword
)(r_howto
.srshift
),
1067 (elfcpp::Elf_Xword
)(r_howto
.doffset
),
1068 (elfcpp::Elf_Xword
)((1 << r_howto
.bsize
) - 1));
1072 imm_x_two_part_general(unsigned char* view
,
1073 const Sized_relobj_file
<size
, big_endian
>* object
,
1074 const Symbol_value
<size
>* psymval
,
1075 typename
elfcpp::Elf_types
<size
>::Elf_Addr addend
,
1076 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
1077 unsigned int r_type
)
1080 elfcpp::Elf_Xword doffset1
= 0llu;
1081 elfcpp::Elf_Xword doffset2
= 0llu;
1082 elfcpp::Elf_Xword dmask1
= 0llu;
1083 elfcpp::Elf_Xword dmask2
= 0llu;
1084 elfcpp::Elf_Xword rshift
= 0llu;
1085 unsigned int pc_rel
= 0;
1089 case elfcpp::R_TILEGX_BROFF_X1
:
1093 dmask2
= 0x1ffc0llu
;
1097 case elfcpp::R_TILEGX_DEST_IMM8_X1
:
1107 This::template pcrela
<64>(view
, object
, psymval
, addend
, address
,
1108 rshift
, doffset1
, dmask1
, doffset2
, dmask2
);
1110 This::template rela
<64>(view
, object
, psymval
, addend
, rshift
,
1111 doffset1
, dmask1
, doffset2
, dmask2
);
1116 tls_relax(unsigned char* view
, unsigned int r_type
,
1117 tls::Tls_optimization opt_t
)
1120 const uint64_t TILEGX_X_MOVE_R0_R0
= 0x283bf8005107f000llu
;
1121 const uint64_t TILEGX_Y_MOVE_R0_R0
= 0xae05f800540bf000llu
;
1122 const uint64_t TILEGX_X_LD
= 0x286ae80000000000llu
;
1123 const uint64_t TILEGX_X_LD4S
= 0x286a980000000000llu
;
1124 const uint64_t TILEGX_X1_FULL_MASK
= 0x3fffffff80000000llu
;
1125 const uint64_t TILEGX_X0_RRR_MASK
= 0x000000007ffc0000llu
;
1126 const uint64_t TILEGX_X1_RRR_MASK
= 0x3ffe000000000000llu
;
1127 const uint64_t TILEGX_Y0_RRR_MASK
= 0x00000000780c0000llu
;
1128 const uint64_t TILEGX_Y1_RRR_MASK
= 0x3c06000000000000llu
;
1129 const uint64_t TILEGX_X0_RRR_SRCB_MASK
= 0x000000007ffff000llu
;
1130 const uint64_t TILEGX_X1_RRR_SRCB_MASK
= 0x3ffff80000000000llu
;
1131 const uint64_t TILEGX_Y0_RRR_SRCB_MASK
= 0x00000000780ff000llu
;
1132 const uint64_t TILEGX_Y1_RRR_SRCB_MASK
= 0x3c07f80000000000llu
;
1133 const uint64_t TILEGX_X_ADD_R0_R0_TP
= 0x2807a800500f5000llu
;
1134 const uint64_t TILEGX_Y_ADD_R0_R0_TP
= 0x9a13a8002c275000llu
;
1135 const uint64_t TILEGX_X_ADDX_R0_R0_TP
= 0x2805a800500b5000llu
;
1136 const uint64_t TILEGX_Y_ADDX_R0_R0_TP
= 0x9a01a8002c035000llu
;
1138 const uint64_t R_TILEGX_IMM8_X0_TLS_ADD_MASK
=
1139 (TILEGX_X0_RRR_MASK
| (0x3Fllu
<< 12));
1141 const uint64_t R_TILEGX_IMM8_X1_TLS_ADD_MASK
=
1142 (TILEGX_X1_RRR_MASK
| (0x3Fllu
<< 43));
1144 const uint64_t R_TILEGX_IMM8_Y0_TLS_ADD_MASK
=
1145 (TILEGX_Y0_RRR_MASK
| (0x3Fllu
<< 12));
1147 const uint64_t R_TILEGX_IMM8_Y1_TLS_ADD_MASK
=
1148 (TILEGX_Y1_RRR_MASK
| (0x3Fllu
<< 43));
1150 const uint64_t R_TILEGX_IMM8_X0_TLS_ADD_LE_MASK
=
1151 (TILEGX_X0_RRR_SRCB_MASK
| (0x3Fllu
<< 6));
1153 const uint64_t R_TILEGX_IMM8_X1_TLS_ADD_LE_MASK
=
1154 (TILEGX_X1_RRR_SRCB_MASK
| (0x3Fllu
<< 37));
1156 const uint64_t R_TILEGX_IMM8_Y0_TLS_ADD_LE_MASK
=
1157 (TILEGX_Y0_RRR_SRCB_MASK
| (0x3Fllu
<< 6));
1159 const uint64_t R_TILEGX_IMM8_Y1_TLS_ADD_LE_MASK
=
1160 (TILEGX_Y1_RRR_SRCB_MASK
| (0x3Fllu
<< 37));
1162 typedef typename
elfcpp::Swap
<64, big_endian
>::Valtype Valtype
;
1163 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
1164 Valtype val
= elfcpp::Swap
<64, big_endian
>::readval(wv
);
1169 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
1170 if (opt_t
== tls::TLSOPT_NONE
) {
1171 // GD/IE: 1. copy dest operand into the second source operand
1172 // 2. change the opcode to "add"
1173 reloc
= (val
& 0x3Fllu
) << 12; // featch the dest reg
1174 reloc
|= ((size
== 32
1175 ? TILEGX_X_ADDX_R0_R0_TP
1176 : TILEGX_X_ADD_R0_R0_TP
)
1177 & TILEGX_X0_RRR_MASK
); // change opcode
1178 val
&= ~R_TILEGX_IMM8_X0_TLS_ADD_MASK
;
1179 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1180 // LE: 1. copy dest operand into the first source operand
1181 // 2. change the opcode to "move"
1182 reloc
= (val
& 0x3Fllu
) << 6;
1183 reloc
|= (TILEGX_X_MOVE_R0_R0
& TILEGX_X0_RRR_SRCB_MASK
);
1184 val
&= ~R_TILEGX_IMM8_X0_TLS_ADD_LE_MASK
;
1188 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
1189 if (opt_t
== tls::TLSOPT_NONE
) {
1190 reloc
= (val
& (0x3Fllu
<< 31)) << 12;
1191 reloc
|= ((size
== 32
1192 ? TILEGX_X_ADDX_R0_R0_TP
1193 : TILEGX_X_ADD_R0_R0_TP
)
1194 & TILEGX_X1_RRR_MASK
);
1195 val
&= ~R_TILEGX_IMM8_X1_TLS_ADD_MASK
;
1196 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1197 reloc
= (val
& (0x3Fllu
<< 31)) << 6;
1198 reloc
|= (TILEGX_X_MOVE_R0_R0
& TILEGX_X1_RRR_SRCB_MASK
);
1199 val
&= ~R_TILEGX_IMM8_X1_TLS_ADD_LE_MASK
;
1203 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
1204 if (opt_t
== tls::TLSOPT_NONE
) {
1205 reloc
= (val
& 0x3Fllu
) << 12;
1206 reloc
|= ((size
== 32
1207 ? TILEGX_Y_ADDX_R0_R0_TP
1208 : TILEGX_Y_ADD_R0_R0_TP
)
1209 & TILEGX_Y0_RRR_MASK
);
1210 val
&= ~R_TILEGX_IMM8_Y0_TLS_ADD_MASK
;
1211 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1212 reloc
= (val
& 0x3Fllu
) << 6;
1213 reloc
|= (TILEGX_Y_MOVE_R0_R0
& TILEGX_Y0_RRR_SRCB_MASK
);
1214 val
&= ~R_TILEGX_IMM8_Y0_TLS_ADD_LE_MASK
;
1218 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
1219 if (opt_t
== tls::TLSOPT_NONE
) {
1220 reloc
= (val
& (0x3Fllu
<< 31)) << 12;
1221 reloc
|= ((size
== 32
1222 ? TILEGX_Y_ADDX_R0_R0_TP
1223 : TILEGX_Y_ADD_R0_R0_TP
)
1224 & TILEGX_Y1_RRR_MASK
);
1225 val
&= ~R_TILEGX_IMM8_Y1_TLS_ADD_MASK
;
1226 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1227 reloc
= (val
& (0x3Fllu
<< 31)) << 6;
1228 reloc
|= (TILEGX_Y_MOVE_R0_R0
& TILEGX_Y1_RRR_SRCB_MASK
);
1229 val
&= ~R_TILEGX_IMM8_Y1_TLS_ADD_LE_MASK
;
1233 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
1234 if (opt_t
== tls::TLSOPT_NONE
) {
1235 // GD see comments for optimize_tls_reloc
1236 reloc
= TILEGX_X_MOVE_R0_R0
& TILEGX_X0_RRR_SRCB_MASK
;
1237 val
&= ~TILEGX_X0_RRR_SRCB_MASK
;
1238 } else if (opt_t
== tls::TLSOPT_TO_IE
1239 || opt_t
== tls::TLSOPT_TO_LE
) {
1242 ? TILEGX_X_ADDX_R0_R0_TP
1243 : TILEGX_X_ADD_R0_R0_TP
)
1244 & TILEGX_X0_RRR_SRCB_MASK
;
1245 val
&= ~TILEGX_X0_RRR_SRCB_MASK
;
1248 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
1249 if (opt_t
== tls::TLSOPT_NONE
) {
1250 reloc
= TILEGX_X_MOVE_R0_R0
& TILEGX_X1_RRR_SRCB_MASK
;
1251 val
&= ~TILEGX_X1_RRR_SRCB_MASK
;
1252 } else if (opt_t
== tls::TLSOPT_TO_IE
1253 || opt_t
== tls::TLSOPT_TO_LE
) {
1255 ? TILEGX_X_ADDX_R0_R0_TP
1256 : TILEGX_X_ADD_R0_R0_TP
)
1257 & TILEGX_X1_RRR_SRCB_MASK
;
1258 val
&= ~TILEGX_X1_RRR_SRCB_MASK
;
1261 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
1262 if (opt_t
== tls::TLSOPT_NONE
) {
1263 reloc
= TILEGX_Y_MOVE_R0_R0
& TILEGX_Y0_RRR_SRCB_MASK
;
1264 val
&= ~TILEGX_Y0_RRR_SRCB_MASK
;
1265 } else if (opt_t
== tls::TLSOPT_TO_IE
1266 || opt_t
== tls::TLSOPT_TO_LE
) {
1268 ? TILEGX_Y_ADDX_R0_R0_TP
1269 : TILEGX_Y_ADD_R0_R0_TP
)
1270 & TILEGX_Y0_RRR_SRCB_MASK
;
1271 val
&= ~TILEGX_Y0_RRR_SRCB_MASK
;
1274 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
1275 if (opt_t
== tls::TLSOPT_NONE
) {
1276 reloc
= TILEGX_Y_MOVE_R0_R0
& TILEGX_Y1_RRR_SRCB_MASK
;
1277 val
&= ~TILEGX_Y1_RRR_SRCB_MASK
;
1278 } else if (opt_t
== tls::TLSOPT_TO_IE
1279 || opt_t
== tls::TLSOPT_TO_LE
) {
1281 ? TILEGX_Y_ADDX_R0_R0_TP
1282 : TILEGX_Y_ADD_R0_R0_TP
)
1283 & TILEGX_Y1_RRR_SRCB_MASK
;
1284 val
&= ~TILEGX_Y1_RRR_SRCB_MASK
;
1287 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
1288 if (opt_t
== tls::TLSOPT_NONE
) {
1293 & TILEGX_X1_RRR_SRCB_MASK
;
1294 val
&= ~TILEGX_X1_RRR_SRCB_MASK
;
1295 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1297 reloc
= TILEGX_X_MOVE_R0_R0
& TILEGX_X1_RRR_SRCB_MASK
;
1298 val
&= ~TILEGX_X1_RRR_SRCB_MASK
;
1302 case elfcpp::R_TILEGX_TLS_GD_CALL
:
1303 if (opt_t
== tls::TLSOPT_TO_IE
) {
1307 : TILEGX_X_LD
) & TILEGX_X1_FULL_MASK
;
1308 val
&= ~TILEGX_X1_FULL_MASK
;
1309 } else if (opt_t
== tls::TLSOPT_TO_LE
) {
1311 reloc
= TILEGX_X_MOVE_R0_R0
& TILEGX_X1_FULL_MASK
;
1312 val
&= ~TILEGX_X1_FULL_MASK
;
1314 // should be handled in ::relocate
1321 elfcpp::Swap
<64, big_endian
>::writeval(wv
, val
| reloc
);
1326 const Tilegx_relocate_functions
<64, false>::Tilegx_howto
1327 Tilegx_relocate_functions
<64, false>::howto
[elfcpp::R_TILEGX_NUM
] =
1329 { 0, 0, 0, 0, 0}, // R_TILEGX_NONE
1330 { 0, 0, 0, 64, 0}, // R_TILEGX_64
1331 { 0, 0, 0, 32, 0}, // R_TILEGX_32
1332 { 0, 0, 0, 16, 0}, // R_TILEGX_16
1333 { 0, 0, 0, 8, 0}, // R_TILEGX_8
1334 { 0, 0, 1, 64, 0}, // R_TILEGX_64_PCREL
1335 { 0, 0, 1, 32, 0}, // R_TILEGX_32_PCREL
1336 { 0, 0, 1, 16, 0}, // R_TILEGX_16_PCREL
1337 { 0, 0, 1, 8, 0}, // R_TILEGX_8_PCREL
1338 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0
1339 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1
1340 { 32, 0, 0, 0, 0}, // R_TILEGX_HW2
1341 { 48, 0, 0, 0, 0}, // R_TILEGX_HW3
1342 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0_LAST
1343 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1_LAST
1344 { 32, 0, 0, 0, 0}, // R_TILEGX_HW2_LAST
1345 { 0, 0, 0, 0, 0}, // R_TILEGX_COPY
1346 { 0, 0, 0, 8, 0}, // R_TILEGX_GLOB_DAT
1347 { 0, 0, 0, 0, 0}, // R_TILEGX_JMP_SLOT
1348 { 0, 0, 0, 0, 0}, // R_TILEGX_RELATIVE
1349 { 3, 1, 1, 0, 0}, // R_TILEGX_BROFF_X1
1350 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1
1351 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1_PLT
1352 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X0
1353 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y0
1354 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X1
1355 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y1
1356 { 0, 1, 0, 8, 0}, // R_TILEGX_DEST_IMM8_X1
1357 { 0, 1, 0, 8, 0}, // R_TILEGX_MT_IMM14_X1
1358 { 0, 1, 0, 8, 0}, // R_TILEGX_MF_IMM14_X1
1359 { 0, 1, 0, 8, 0}, // R_TILEGX_MMSTART_X0
1360 { 0, 1, 0, 8, 0}, // R_TILEGX_MMEND_X0
1361 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X0
1362 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X1
1363 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y0
1364 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y1
1365 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0
1366 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0
1367 { 16, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW1
1368 { 16, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW1
1369 { 32, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW2
1370 { 32, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW2
1371 { 48, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW3
1372 { 48, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW3
1373 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST
1374 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST
1375 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST
1376 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST
1377 { 32, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST
1378 { 32, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST
1379 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PCREL
1380 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PCREL
1381 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PCREL
1382 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PCREL
1383 { 32, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PCREL
1384 { 32, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PCREL
1385 { 48, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW3_PCREL
1386 { 48, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW3_PCREL
1387 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PCREL
1388 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PCREL
1389 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PCREL
1390 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PCREL
1391 { 32, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PCREL
1392 { 32, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PCREL
1393 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_GOT
1394 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_GOT
1395 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PLT_PCREL
1396 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PLT_PCREL
1397 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PLT_PCREL
1398 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PLT_PCREL
1399 { 32, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PLT_PCREL
1400 { 32, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PLT_PCREL
1401 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_GOT
1402 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_GOT
1403 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_GOT
1404 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_GOT
1405 { 32, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_GOT
1406 { 32, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_GOT
1407 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_GD
1408 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_GD
1409 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_LE
1410 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_LE
1411 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
1412 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
1413 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
1414 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
1415 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
1416 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
1417 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
1418 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
1419 { 0, 0, 0, 0, 0}, // R_TILEGX_IRELATIVE
1420 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1421 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_IE
1422 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_IE
1423 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
1424 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
1425 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
1426 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
1427 { 32, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
1428 { 32, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
1429 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
1430 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
1431 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
1432 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
1433 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1434 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1435 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD64
1436 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF64
1437 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF64
1438 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD32
1439 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF32
1440 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF32
1441 { 3, 31, 1, 27, 0}, // R_TILEGX_TLS_GD_CALL
1442 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_GD_ADD
1443 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_GD_ADD
1444 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_GD_ADD
1445 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_GD_ADD
1446 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_IE_LOAD
1447 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_ADD
1448 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_ADD
1449 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_ADD
1450 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_ADD
1451 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTINHERIT
1452 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTENTRY
1456 const Tilegx_relocate_functions
<32, false>::Tilegx_howto
1457 Tilegx_relocate_functions
<32, false>::howto
[elfcpp::R_TILEGX_NUM
] =
1459 { 0, 0, 0, 0, 0}, // R_TILEGX_NONE
1460 { 0, 0, 0, 64, 0}, // R_TILEGX_64
1461 { 0, 0, 0, 32, 0}, // R_TILEGX_32
1462 { 0, 0, 0, 16, 0}, // R_TILEGX_16
1463 { 0, 0, 0, 8, 0}, // R_TILEGX_8
1464 { 0, 0, 1, 64, 0}, // R_TILEGX_64_PCREL
1465 { 0, 0, 1, 32, 0}, // R_TILEGX_32_PCREL
1466 { 0, 0, 1, 16, 0}, // R_TILEGX_16_PCREL
1467 { 0, 0, 1, 8, 0}, // R_TILEGX_8_PCREL
1468 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0
1469 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1
1470 { 31, 0, 0, 0, 0}, // R_TILEGX_HW2
1471 { 31, 0, 0, 0, 0}, // R_TILEGX_HW3
1472 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0_LAST
1473 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1_LAST
1474 { 31, 0, 0, 0, 0}, // R_TILEGX_HW2_LAST
1475 { 0, 0, 0, 0, 0}, // R_TILEGX_COPY
1476 { 0, 0, 0, 8, 0}, // R_TILEGX_GLOB_DAT
1477 { 0, 0, 0, 0, 0}, // R_TILEGX_JMP_SLOT
1478 { 0, 0, 0, 0, 0}, // R_TILEGX_RELATIVE
1479 { 3, 1, 1, 0, 0}, // R_TILEGX_BROFF_X1
1480 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1
1481 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1_PLT
1482 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X0
1483 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y0
1484 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X1
1485 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y1
1486 { 0, 1, 0, 8, 0}, // R_TILEGX_DEST_IMM8_X1
1487 { 0, 1, 0, 8, 0}, // R_TILEGX_MT_IMM14_X1
1488 { 0, 1, 0, 8, 0}, // R_TILEGX_MF_IMM14_X1
1489 { 0, 1, 0, 8, 0}, // R_TILEGX_MMSTART_X0
1490 { 0, 1, 0, 8, 0}, // R_TILEGX_MMEND_X0
1491 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X0
1492 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X1
1493 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y0
1494 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y1
1495 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0
1496 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0
1497 { 16, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW1
1498 { 16, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW1
1499 { 31, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW2
1500 { 31, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW2
1501 { 31, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW3
1502 { 31, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW3
1503 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST
1504 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST
1505 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST
1506 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST
1507 { 31, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST
1508 { 31, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST
1509 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PCREL
1510 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PCREL
1511 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PCREL
1512 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PCREL
1513 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PCREL
1514 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PCREL
1515 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW3_PCREL
1516 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW3_PCREL
1517 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PCREL
1518 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PCREL
1519 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PCREL
1520 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PCREL
1521 { 31, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PCREL
1522 { 31, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PCREL
1523 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_GOT
1524 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_GOT
1525 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PLT_PCREL
1526 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PLT_PCREL
1527 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PLT_PCREL
1528 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PLT_PCREL
1529 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PLT_PCREL
1530 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PLT_PCREL
1531 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_GOT
1532 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_GOT
1533 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_GOT
1534 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_GOT
1535 { 31, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_GOT
1536 { 31, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_GOT
1537 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_GD
1538 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_GD
1539 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_LE
1540 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_LE
1541 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
1542 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
1543 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
1544 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
1545 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
1546 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
1547 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
1548 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
1549 { 0, 0, 0, 0, 0}, // R_TILEGX_IRELATIVE
1550 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1551 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_IE
1552 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_IE
1553 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
1554 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
1555 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
1556 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
1557 { 31, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
1558 { 31, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
1559 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
1560 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
1561 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
1562 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
1563 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1564 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1565 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD64
1566 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF64
1567 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF64
1568 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD32
1569 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF32
1570 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF32
1571 { 3, 31, 1, 27, 0}, // R_TILEGX_TLS_GD_CALL
1572 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_GD_ADD
1573 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_GD_ADD
1574 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_GD_ADD
1575 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_GD_ADD
1576 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_IE_LOAD
1577 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_ADD
1578 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_ADD
1579 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_ADD
1580 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_ADD
1581 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTINHERIT
1582 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTENTRY
1586 const Tilegx_relocate_functions
<64, true>::Tilegx_howto
1587 Tilegx_relocate_functions
<64, true>::howto
[elfcpp::R_TILEGX_NUM
] =
1589 { 0, 0, 0, 0, 0}, // R_TILEGX_NONE
1590 { 0, 0, 0, 64, 0}, // R_TILEGX_64
1591 { 0, 0, 0, 32, 0}, // R_TILEGX_32
1592 { 0, 0, 0, 16, 0}, // R_TILEGX_16
1593 { 0, 0, 0, 8, 0}, // R_TILEGX_8
1594 { 0, 0, 1, 64, 0}, // R_TILEGX_64_PCREL
1595 { 0, 0, 1, 32, 0}, // R_TILEGX_32_PCREL
1596 { 0, 0, 1, 16, 0}, // R_TILEGX_16_PCREL
1597 { 0, 0, 1, 8, 0}, // R_TILEGX_8_PCREL
1598 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0
1599 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1
1600 { 32, 0, 0, 0, 0}, // R_TILEGX_HW2
1601 { 48, 0, 0, 0, 0}, // R_TILEGX_HW3
1602 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0_LAST
1603 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1_LAST
1604 { 32, 0, 0, 0, 0}, // R_TILEGX_HW2_LAST
1605 { 0, 0, 0, 0, 0}, // R_TILEGX_COPY
1606 { 0, 0, 0, 8, 0}, // R_TILEGX_GLOB_DAT
1607 { 0, 0, 0, 0, 0}, // R_TILEGX_JMP_SLOT
1608 { 0, 0, 0, 0, 0}, // R_TILEGX_RELATIVE
1609 { 3, 1, 1, 0, 0}, // R_TILEGX_BROFF_X1
1610 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1
1611 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1_PLT
1612 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X0
1613 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y0
1614 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X1
1615 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y1
1616 { 0, 1, 0, 8, 0}, // R_TILEGX_DEST_IMM8_X1
1617 { 0, 1, 0, 8, 0}, // R_TILEGX_MT_IMM14_X1
1618 { 0, 1, 0, 8, 0}, // R_TILEGX_MF_IMM14_X1
1619 { 0, 1, 0, 8, 0}, // R_TILEGX_MMSTART_X0
1620 { 0, 1, 0, 8, 0}, // R_TILEGX_MMEND_X0
1621 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X0
1622 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X1
1623 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y0
1624 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y1
1625 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0
1626 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0
1627 { 16, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW1
1628 { 16, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW1
1629 { 32, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW2
1630 { 32, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW2
1631 { 48, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW3
1632 { 48, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW3
1633 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST
1634 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST
1635 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST
1636 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST
1637 { 32, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST
1638 { 32, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST
1639 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PCREL
1640 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PCREL
1641 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PCREL
1642 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PCREL
1643 { 32, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PCREL
1644 { 32, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PCREL
1645 { 48, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW3_PCREL
1646 { 48, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW3_PCREL
1647 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PCREL
1648 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PCREL
1649 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PCREL
1650 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PCREL
1651 { 32, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PCREL
1652 { 32, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PCREL
1653 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_GOT
1654 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_GOT
1655 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PLT_PCREL
1656 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PLT_PCREL
1657 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PLT_PCREL
1658 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PLT_PCREL
1659 { 32, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PLT_PCREL
1660 { 32, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PLT_PCREL
1661 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_GOT
1662 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_GOT
1663 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_GOT
1664 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_GOT
1665 { 32, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_GOT
1666 { 32, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_GOT
1667 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_GD
1668 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_GD
1669 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_LE
1670 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_LE
1671 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
1672 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
1673 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
1674 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
1675 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
1676 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
1677 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
1678 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
1679 { 0, 0, 0, 0, 0}, // R_TILEGX_IRELATIVE
1680 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1681 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_IE
1682 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_IE
1683 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
1684 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
1685 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
1686 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
1687 { 32, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
1688 { 32, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
1689 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
1690 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
1691 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
1692 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
1693 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1694 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1695 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD64
1696 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF64
1697 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF64
1698 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD32
1699 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF32
1700 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF32
1701 { 3, 31, 1, 27, 0}, // R_TILEGX_TLS_GD_CALL
1702 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_GD_ADD
1703 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_GD_ADD
1704 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_GD_ADD
1705 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_GD_ADD
1706 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_IE_LOAD
1707 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_ADD
1708 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_ADD
1709 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_ADD
1710 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_ADD
1711 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTINHERIT
1712 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTENTRY
1716 const Tilegx_relocate_functions
<32, true>::Tilegx_howto
1717 Tilegx_relocate_functions
<32, true>::howto
[elfcpp::R_TILEGX_NUM
] =
1719 { 0, 0, 0, 0, 0}, // R_TILEGX_NONE
1720 { 0, 0, 0, 64, 0}, // R_TILEGX_64
1721 { 0, 0, 0, 32, 0}, // R_TILEGX_32
1722 { 0, 0, 0, 16, 0}, // R_TILEGX_16
1723 { 0, 0, 0, 8, 0}, // R_TILEGX_8
1724 { 0, 0, 1, 64, 0}, // R_TILEGX_64_PCREL
1725 { 0, 0, 1, 32, 0}, // R_TILEGX_32_PCREL
1726 { 0, 0, 1, 16, 0}, // R_TILEGX_16_PCREL
1727 { 0, 0, 1, 8, 0}, // R_TILEGX_8_PCREL
1728 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0
1729 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1
1730 { 31, 0, 0, 0, 0}, // R_TILEGX_HW2
1731 { 31, 0, 0, 0, 0}, // R_TILEGX_HW3
1732 { 0, 0, 0, 0, 0}, // R_TILEGX_HW0_LAST
1733 { 16, 0, 0, 0, 0}, // R_TILEGX_HW1_LAST
1734 { 31, 0, 0, 0, 0}, // R_TILEGX_HW2_LAST
1735 { 0, 0, 0, 0, 0}, // R_TILEGX_COPY
1736 { 0, 0, 0, 8, 0}, // R_TILEGX_GLOB_DAT
1737 { 0, 0, 0, 0, 0}, // R_TILEGX_JMP_SLOT
1738 { 0, 0, 0, 0, 0}, // R_TILEGX_RELATIVE
1739 { 3, 1, 1, 0, 0}, // R_TILEGX_BROFF_X1
1740 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1
1741 { 3, 31, 1, 27, 0}, // R_TILEGX_JUMPOFF_X1_PLT
1742 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X0
1743 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y0
1744 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_X1
1745 { 0, 1, 0, 8, 0}, // R_TILEGX_IMM8_Y1
1746 { 0, 1, 0, 8, 0}, // R_TILEGX_DEST_IMM8_X1
1747 { 0, 1, 0, 8, 0}, // R_TILEGX_MT_IMM14_X1
1748 { 0, 1, 0, 8, 0}, // R_TILEGX_MF_IMM14_X1
1749 { 0, 1, 0, 8, 0}, // R_TILEGX_MMSTART_X0
1750 { 0, 1, 0, 8, 0}, // R_TILEGX_MMEND_X0
1751 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X0
1752 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_X1
1753 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y0
1754 { 0, 1, 0, 8, 0}, // R_TILEGX_SHAMT_Y1
1755 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0
1756 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0
1757 { 16, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW1
1758 { 16, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW1
1759 { 31, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW2
1760 { 31, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW2
1761 { 31, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW3
1762 { 31, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW3
1763 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST
1764 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST
1765 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST
1766 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST
1767 { 31, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST
1768 { 31, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST
1769 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PCREL
1770 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PCREL
1771 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PCREL
1772 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PCREL
1773 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PCREL
1774 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PCREL
1775 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW3_PCREL
1776 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW3_PCREL
1777 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PCREL
1778 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PCREL
1779 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PCREL
1780 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PCREL
1781 { 31, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PCREL
1782 { 31, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PCREL
1783 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_GOT
1784 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_GOT
1785 { 0, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW0_PLT_PCREL
1786 { 0, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW0_PLT_PCREL
1787 { 16, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW1_PLT_PCREL
1788 { 16, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW1_PLT_PCREL
1789 { 31, 12, 1, 16, 0}, // R_TILEGX_IMM16_X0_HW2_PLT_PCREL
1790 { 31, 43, 1, 16, 0}, // R_TILEGX_IMM16_X1_HW2_PLT_PCREL
1791 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_GOT
1792 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_GOT
1793 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_GOT
1794 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_GOT
1795 { 31, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_GOT
1796 { 31, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_GOT
1797 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_GD
1798 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_GD
1799 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_LE
1800 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_LE
1801 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
1802 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
1803 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
1804 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
1805 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
1806 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
1807 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
1808 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
1809 { 0, 0, 0, 0, 0}, // R_TILEGX_IRELATIVE
1810 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1811 { 0, 12, 0, 16, 0}, // R_TILEGX_IMM16_X0_HW0_TLS_IE
1812 { 0, 43, 0, 16, 0}, // R_TILEGX_IMM16_X1_HW0_TLS_IE
1813 { 0, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
1814 { 0, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
1815 { 16, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
1816 { 16, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
1817 { 31, 12, 1, 16, 1}, // R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
1818 { 31, 43, 1, 16, 1}, // R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
1819 { 0, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
1820 { 0, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
1821 { 16, 12, 0, 16, 1}, // R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
1822 { 16, 43, 0, 16, 1}, // R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
1823 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1824 { 0, 0, 0, 0, 0}, // R_TILEGX_INVALID
1825 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD64
1826 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF64
1827 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF64
1828 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPMOD32
1829 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_DTPOFF32
1830 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_TPOFF32
1831 { 3, 31, 1, 27, 0}, // R_TILEGX_TLS_GD_CALL
1832 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_GD_ADD
1833 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_GD_ADD
1834 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_GD_ADD
1835 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_GD_ADD
1836 { 0, 0, 0, 0, 0}, // R_TILEGX_TLS_IE_LOAD
1837 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X0_TLS_ADD
1838 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_X1_TLS_ADD
1839 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y0_TLS_ADD
1840 { 0, 0, 0, 0, 0}, // R_TILEGX_IMM8_Y1_TLS_ADD
1841 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTINHERIT
1842 { 0, 0, 0, 0, 0}, // R_TILEGX_GNU_VTENTRY
1845 // Get the GOT section, creating it if necessary.
1847 template<int size
, bool big_endian
>
1848 Output_data_got
<size
, big_endian
>*
1849 Target_tilegx
<size
, big_endian
>::got_section(Symbol_table
* symtab
,
1852 if (this->got_
== NULL
)
1854 gold_assert(symtab
!= NULL
&& layout
!= NULL
);
1856 // When using -z now, we can treat .got.plt as a relro section.
1857 // Without -z now, it is modified after program startup by lazy
1859 bool is_got_plt_relro
= parameters
->options().now();
1860 Output_section_order got_order
= (is_got_plt_relro
1862 : ORDER_RELRO_LAST
);
1863 Output_section_order got_plt_order
= (is_got_plt_relro
1865 : ORDER_NON_RELRO_FIRST
);
1867 this->got_
= new Output_data_got
<size
, big_endian
>();
1869 layout
->add_output_section_data(".got", elfcpp::SHT_PROGBITS
,
1871 | elfcpp::SHF_WRITE
),
1872 this->got_
, got_order
, true);
1874 // Define _GLOBAL_OFFSET_TABLE_ at the start of the PLT.
1875 this->global_offset_table_
=
1876 symtab
->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL
,
1877 Symbol_table::PREDEFINED
,
1879 0, 0, elfcpp::STT_OBJECT
,
1881 elfcpp::STV_HIDDEN
, 0,
1884 if (parameters
->options().shared()) {
1885 // we need to keep the address of .dynamic section in the
1886 // first got entry for .so
1887 this->tilegx_dynamic_
=
1888 symtab
->define_in_output_data("_TILEGX_DYNAMIC_", NULL
,
1889 Symbol_table::PREDEFINED
,
1890 layout
->dynamic_section(),
1891 0, 0, elfcpp::STT_OBJECT
,
1893 elfcpp::STV_HIDDEN
, 0,
1896 this->got_
->add_global(this->tilegx_dynamic_
, GOT_TYPE_STANDARD
);
1898 // for executable, just set the first entry to zero.
1899 this->got_
->set_current_data_size(size
/ 8);
1901 this->got_plt_
= new Output_data_space(size
/ 8, "** GOT PLT");
1902 layout
->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS
,
1904 | elfcpp::SHF_WRITE
),
1905 this->got_plt_
, got_plt_order
,
1908 // The first two entries are reserved.
1909 this->got_plt_
->set_current_data_size
1910 (TILEGX_GOTPLT_RESERVE_COUNT
* (size
/ 8));
1912 if (!is_got_plt_relro
)
1914 // Those bytes can go into the relro segment.
1915 layout
->increase_relro(size
/ 8);
1919 // If there are any IRELATIVE relocations, they get GOT entries
1920 // in .got.plt after the jump slot entries.
1921 this->got_irelative_
1922 = new Output_data_space(size
/ 8, "** GOT IRELATIVE PLT");
1923 layout
->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS
,
1925 | elfcpp::SHF_WRITE
),
1926 this->got_irelative_
,
1927 got_plt_order
, is_got_plt_relro
);
1933 // Get the dynamic reloc section, creating it if necessary.
1935 template<int size
, bool big_endian
>
1936 typename Target_tilegx
<size
, big_endian
>::Reloc_section
*
1937 Target_tilegx
<size
, big_endian
>::rela_dyn_section(Layout
* layout
)
1939 if (this->rela_dyn_
== NULL
)
1941 gold_assert(layout
!= NULL
);
1942 this->rela_dyn_
= new Reloc_section(parameters
->options().combreloc());
1943 layout
->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA
,
1944 elfcpp::SHF_ALLOC
, this->rela_dyn_
,
1945 ORDER_DYNAMIC_RELOCS
, false);
1947 return this->rela_dyn_
;
1950 // Get the section to use for IRELATIVE relocs, creating it if
1951 // necessary. These go in .rela.dyn, but only after all other dynamic
1952 // relocations. They need to follow the other dynamic relocations so
1953 // that they can refer to global variables initialized by those
1956 template<int size
, bool big_endian
>
1957 typename Target_tilegx
<size
, big_endian
>::Reloc_section
*
1958 Target_tilegx
<size
, big_endian
>::rela_irelative_section(Layout
* layout
)
1960 if (this->rela_irelative_
== NULL
)
1962 // Make sure we have already created the dynamic reloc section.
1963 this->rela_dyn_section(layout
);
1964 this->rela_irelative_
= new Reloc_section(false);
1965 layout
->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA
,
1966 elfcpp::SHF_ALLOC
, this->rela_irelative_
,
1967 ORDER_DYNAMIC_RELOCS
, false);
1968 gold_assert(this->rela_dyn_
->output_section()
1969 == this->rela_irelative_
->output_section());
1971 return this->rela_irelative_
;
1974 // Initialize the PLT section.
1976 template<int size
, bool big_endian
>
1978 Output_data_plt_tilegx
<size
, big_endian
>::init(Layout
* layout
)
1980 this->rel_
= new Reloc_section(false);
1981 layout
->add_output_section_data(".rela.plt", elfcpp::SHT_RELA
,
1982 elfcpp::SHF_ALLOC
, this->rel_
,
1983 ORDER_DYNAMIC_PLT_RELOCS
, false);
1986 template<int size
, bool big_endian
>
1988 Output_data_plt_tilegx
<size
, big_endian
>::do_adjust_output_section(
1991 os
->set_entsize(this->get_plt_entry_size());
1994 // Add an entry to the PLT.
1996 template<int size
, bool big_endian
>
1998 Output_data_plt_tilegx
<size
, big_endian
>::add_entry(Symbol_table
* symtab
,
1999 Layout
* layout
, Symbol
* gsym
)
2001 gold_assert(!gsym
->has_plt_offset());
2003 unsigned int plt_index
;
2005 section_offset_type got_offset
;
2007 unsigned int* pcount
;
2008 unsigned int reserved
;
2009 Output_data_space
* got
;
2010 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
2011 && gsym
->can_use_relative_reloc(false))
2013 pcount
= &this->irelative_count_
;
2015 got
= this->got_irelative_
;
2019 pcount
= &this->count_
;
2020 reserved
= TILEGX_GOTPLT_RESERVE_COUNT
;
2021 got
= this->got_plt_
;
2024 if (!this->is_data_size_valid())
2026 plt_index
= *pcount
;
2028 // TILEGX .plt section layout
2038 // TILEGX .got.plt section layout
2045 // entries for normal function
2049 // entries for ifunc
2053 if (got
== this->got_irelative_
)
2054 plt_offset
= plt_index
* this->get_plt_entry_size();
2056 plt_offset
= (plt_index
+ 1) * this->get_plt_entry_size();
2060 got_offset
= (plt_index
+ reserved
) * (size
/ 8);
2061 gold_assert(got_offset
== got
->current_data_size());
2063 // Every PLT entry needs a GOT entry which points back to the PLT
2064 // entry (this will be changed by the dynamic linker, normally
2065 // lazily when the function is called).
2066 got
->set_current_data_size(got_offset
+ size
/ 8);
2070 // FIXME: This is probably not correct for IRELATIVE relocs.
2072 // For incremental updates, find an available slot.
2073 plt_offset
= this->free_list_
.allocate(this->get_plt_entry_size(),
2074 this->get_plt_entry_size(), 0);
2075 if (plt_offset
== -1)
2076 gold_fallback(_("out of patch space (PLT);"
2077 " relink with --incremental-full"));
2079 // The GOT and PLT entries have a 1-1 correspondance, so the GOT offset
2080 // can be calculated from the PLT index, adjusting for the three
2081 // reserved entries at the beginning of the GOT.
2082 plt_index
= plt_offset
/ this->get_plt_entry_size() - 1;
2083 got_offset
= (plt_index
+ reserved
) * (size
/ 8);
2086 gsym
->set_plt_offset(plt_offset
);
2088 // Every PLT entry needs a reloc.
2089 this->add_relocation(symtab
, layout
, gsym
, got_offset
);
2091 // Note that we don't need to save the symbol. The contents of the
2092 // PLT are independent of which symbols are used. The symbols only
2093 // appear in the relocations.
2096 // Add an entry to the PLT for a local STT_GNU_IFUNC symbol. Return
2099 template<int size
, bool big_endian
>
2101 Output_data_plt_tilegx
<size
, big_endian
>::add_local_ifunc_entry(
2102 Symbol_table
* symtab
,
2104 Sized_relobj_file
<size
, big_endian
>* relobj
,
2105 unsigned int local_sym_index
)
2107 unsigned int plt_offset
=
2108 this->irelative_count_
* this->get_plt_entry_size();
2109 ++this->irelative_count_
;
2111 section_offset_type got_offset
= this->got_irelative_
->current_data_size();
2113 // Every PLT entry needs a GOT entry which points back to the PLT
2115 this->got_irelative_
->set_current_data_size(got_offset
+ size
/ 8);
2117 // Every PLT entry needs a reloc.
2118 Reloc_section
* rela
= this->rela_irelative(symtab
, layout
);
2119 rela
->add_symbolless_local_addend(relobj
, local_sym_index
,
2120 elfcpp::R_TILEGX_IRELATIVE
,
2121 this->got_irelative_
, got_offset
, 0);
2126 // Add the relocation for a PLT entry.
2128 template<int size
, bool big_endian
>
2130 Output_data_plt_tilegx
<size
, big_endian
>::add_relocation(Symbol_table
* symtab
,
2133 unsigned int got_offset
)
2135 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
2136 && gsym
->can_use_relative_reloc(false))
2138 Reloc_section
* rela
= this->rela_irelative(symtab
, layout
);
2139 rela
->add_symbolless_global_addend(gsym
, elfcpp::R_TILEGX_IRELATIVE
,
2140 this->got_irelative_
, got_offset
, 0);
2144 gsym
->set_needs_dynsym_entry();
2145 this->rel_
->add_global(gsym
, elfcpp::R_TILEGX_JMP_SLOT
, this->got_plt_
,
2150 // Return where the IRELATIVE relocations should go in the PLT. These
2151 // follow the JUMP_SLOT and the TLSDESC relocations.
2153 template<int size
, bool big_endian
>
2154 typename Output_data_plt_tilegx
<size
, big_endian
>::Reloc_section
*
2155 Output_data_plt_tilegx
<size
, big_endian
>::rela_irelative(Symbol_table
* symtab
,
2158 if (this->irelative_rel_
== NULL
)
2160 // case we see any later on.
2161 this->irelative_rel_
= new Reloc_section(false);
2162 layout
->add_output_section_data(".rela.plt", elfcpp::SHT_RELA
,
2163 elfcpp::SHF_ALLOC
, this->irelative_rel_
,
2164 ORDER_DYNAMIC_PLT_RELOCS
, false);
2165 gold_assert(this->irelative_rel_
->output_section()
2166 == this->rel_
->output_section());
2168 if (parameters
->doing_static_link())
2170 // A statically linked executable will only have a .rela.plt
2171 // section to hold R_TILEGX_IRELATIVE relocs for
2172 // STT_GNU_IFUNC symbols. The library will use these
2173 // symbols to locate the IRELATIVE relocs at program startup
2175 symtab
->define_in_output_data("__rela_iplt_start", NULL
,
2176 Symbol_table::PREDEFINED
,
2177 this->irelative_rel_
, 0, 0,
2178 elfcpp::STT_NOTYPE
, elfcpp::STB_GLOBAL
,
2179 elfcpp::STV_HIDDEN
, 0, false, true);
2180 symtab
->define_in_output_data("__rela_iplt_end", NULL
,
2181 Symbol_table::PREDEFINED
,
2182 this->irelative_rel_
, 0, 0,
2183 elfcpp::STT_NOTYPE
, elfcpp::STB_GLOBAL
,
2184 elfcpp::STV_HIDDEN
, 0, true, true);
2187 return this->irelative_rel_
;
2190 // Return the PLT address to use for a global symbol.
2192 template<int size
, bool big_endian
>
2194 Output_data_plt_tilegx
<size
, big_endian
>::address_for_global(
2197 uint64_t offset
= 0;
2198 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
2199 && gsym
->can_use_relative_reloc(false))
2200 offset
= (this->count_
+ 1) * this->get_plt_entry_size();
2201 return this->address() + offset
+ gsym
->plt_offset();
2204 // Return the PLT address to use for a local symbol. These are always
2205 // IRELATIVE relocs.
2207 template<int size
, bool big_endian
>
2209 Output_data_plt_tilegx
<size
, big_endian
>::address_for_local(
2210 const Relobj
* object
,
2213 return (this->address()
2214 + (this->count_
+ 1) * this->get_plt_entry_size()
2215 + object
->local_plt_offset(r_sym
));
2218 // Set the final size.
2219 template<int size
, bool big_endian
>
2221 Output_data_plt_tilegx
<size
, big_endian
>::set_final_data_size()
2223 unsigned int count
= this->count_
+ this->irelative_count_
;
2224 this->set_data_size((count
+ 1) * this->get_plt_entry_size());
2227 // The first entry in the PLT for an executable.
2230 Output_data_plt_tilegx
<64, false>::first_plt_entry
[plt_entry_size
] =
2232 0x00, 0x30, 0x48, 0x51,
2233 0x6e, 0x43, 0xa0, 0x18, // { ld_add r28, r27, 8 }
2234 0x00, 0x30, 0xbc, 0x35,
2235 0x00, 0x40, 0xde, 0x9e, // { ld r27, r27 }
2236 0xff, 0xaf, 0x30, 0x40,
2237 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2239 0x00, 0x00, 0x00, 0x00,
2240 0x00, 0x00, 0x00, 0x00,
2241 0x00, 0x00, 0x00, 0x00,
2242 0x00, 0x00, 0x00, 0x00
2247 Output_data_plt_tilegx
<32, false>::first_plt_entry
[plt_entry_size
] =
2249 0x00, 0x30, 0x48, 0x51,
2250 0x6e, 0x23, 0x58, 0x18, // { ld4s_add r28, r27, 4 }
2251 0x00, 0x30, 0xbc, 0x35,
2252 0x00, 0x40, 0xde, 0x9c, // { ld4s r27, r27 }
2253 0xff, 0xaf, 0x30, 0x40,
2254 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2256 0x00, 0x00, 0x00, 0x00,
2257 0x00, 0x00, 0x00, 0x00,
2258 0x00, 0x00, 0x00, 0x00,
2259 0x00, 0x00, 0x00, 0x00
2264 Output_data_plt_tilegx
<64, true>::first_plt_entry
[plt_entry_size
] =
2266 0x00, 0x30, 0x48, 0x51,
2267 0x6e, 0x43, 0xa0, 0x18, // { ld_add r28, r27, 8 }
2268 0x00, 0x30, 0xbc, 0x35,
2269 0x00, 0x40, 0xde, 0x9e, // { ld r27, r27 }
2270 0xff, 0xaf, 0x30, 0x40,
2271 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2273 0x00, 0x00, 0x00, 0x00,
2274 0x00, 0x00, 0x00, 0x00,
2275 0x00, 0x00, 0x00, 0x00,
2276 0x00, 0x00, 0x00, 0x00
2281 Output_data_plt_tilegx
<32, true>::first_plt_entry
[plt_entry_size
] =
2283 0x00, 0x30, 0x48, 0x51,
2284 0x6e, 0x23, 0x58, 0x18, // { ld4s_add r28, r27, 4 }
2285 0x00, 0x30, 0xbc, 0x35,
2286 0x00, 0x40, 0xde, 0x9c, // { ld4s r27, r27 }
2287 0xff, 0xaf, 0x30, 0x40,
2288 0x60, 0x73, 0x6a, 0x28, // { info 10 ; jr r27 }
2290 0x00, 0x00, 0x00, 0x00,
2291 0x00, 0x00, 0x00, 0x00,
2292 0x00, 0x00, 0x00, 0x00,
2293 0x00, 0x00, 0x00, 0x00
2296 template<int size
, bool big_endian
>
2298 Output_data_plt_tilegx
<size
, big_endian
>::fill_first_plt_entry(
2301 memcpy(pov
, first_plt_entry
, plt_entry_size
);
2304 // Subsequent entries in the PLT for an executable.
2308 Output_data_plt_tilegx
<64, false>::plt_entry
[plt_entry_size
] =
2310 0xdc, 0x0f, 0x00, 0x10,
2311 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2312 0xdb, 0x0f, 0x00, 0x10,
2313 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2314 0x9c, 0xc6, 0x0d, 0xd0,
2315 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2316 0x9b, 0xb6, 0xc5, 0xad,
2317 0xff, 0x57, 0xe0, 0x8e, // { add r27, r26, r27 ; info 10 ; ld r28, r28 }
2318 0xdd, 0x0f, 0x00, 0x70,
2319 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2325 Output_data_plt_tilegx
<32, false>::plt_entry
[plt_entry_size
] =
2327 0xdc, 0x0f, 0x00, 0x10,
2328 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2329 0xdb, 0x0f, 0x00, 0x10,
2330 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2331 0x9c, 0xc6, 0x0d, 0xd0,
2332 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2333 0x9b, 0xb6, 0xc5, 0xad,
2334 0xff, 0x57, 0xe0, 0x8c, // { add r27, r26, r27 ; info 10 ; ld4s r28, r28 }
2335 0xdd, 0x0f, 0x00, 0x70,
2336 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2341 Output_data_plt_tilegx
<64, true>::plt_entry
[plt_entry_size
] =
2343 0xdc, 0x0f, 0x00, 0x10,
2344 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2345 0xdb, 0x0f, 0x00, 0x10,
2346 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2347 0x9c, 0xc6, 0x0d, 0xd0,
2348 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2349 0x9b, 0xb6, 0xc5, 0xad,
2350 0xff, 0x57, 0xe0, 0x8e, // { add r27, r26, r27 ; info 10 ; ld r28, r28 }
2351 0xdd, 0x0f, 0x00, 0x70,
2352 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2358 Output_data_plt_tilegx
<32, true>::plt_entry
[plt_entry_size
] =
2360 0xdc, 0x0f, 0x00, 0x10,
2361 0x0d, 0xf0, 0x6a, 0x28, // { moveli r28, 0 ; lnk r26 }
2362 0xdb, 0x0f, 0x00, 0x10,
2363 0x8e, 0x03, 0x00, 0x38, // { moveli r27, 0 ; shl16insli r28, r28, 0 }
2364 0x9c, 0xc6, 0x0d, 0xd0,
2365 0x6d, 0x03, 0x00, 0x38, // { add r28, r26, r28 ; shl16insli r27, r27, 0 }
2366 0x9b, 0xb6, 0xc5, 0xad,
2367 0xff, 0x57, 0xe0, 0x8c, // { add r27, r26, r27 ; info 10 ; ld4s r28, r28 }
2368 0xdd, 0x0f, 0x00, 0x70,
2369 0x80, 0x73, 0x6a, 0x28, // { shl16insli r29, zero, 0 ; jr r28 }
2372 template<int size
, bool big_endian
>
2374 Output_data_plt_tilegx
<size
, big_endian
>::fill_plt_entry(
2376 typename
elfcpp::Elf_types
<size
>::Elf_Addr gotplt_base
,
2377 unsigned int got_offset
,
2378 typename
elfcpp::Elf_types
<size
>::Elf_Addr plt_base
,
2379 unsigned int plt_offset
, unsigned int plt_index
)
2382 const uint32_t TILEGX_IMM16_MASK
= 0xFFFF;
2383 const uint32_t TILEGX_X0_IMM16_BITOFF
= 12;
2384 const uint32_t TILEGX_X1_IMM16_BITOFF
= 43;
2386 typedef typename
elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::Valtype
2388 memcpy(pov
, plt_entry
, plt_entry_size
);
2390 // first bundle in plt stub - x0
2391 Valtype
* wv
= reinterpret_cast<Valtype
*>(pov
);
2392 Valtype val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2394 ((gotplt_base
+ got_offset
) - (plt_base
+ plt_offset
+ 8)) >> 16;
2395 elfcpp::Elf_Xword dst_mask
=
2396 (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X0_IMM16_BITOFF
;
2398 reloc
&= TILEGX_IMM16_MASK
;
2399 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2400 val
| (reloc
<<TILEGX_X0_IMM16_BITOFF
));
2402 // second bundle in plt stub - x1
2403 wv
= reinterpret_cast<Valtype
*>(pov
+ 8);
2404 val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2405 reloc
= (gotplt_base
+ got_offset
) - (plt_base
+ plt_offset
+ 8);
2406 dst_mask
= (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X1_IMM16_BITOFF
;
2408 reloc
&= TILEGX_IMM16_MASK
;
2409 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2410 val
| (reloc
<<TILEGX_X1_IMM16_BITOFF
));
2412 // second bundle in plt stub - x0
2413 wv
= reinterpret_cast<Valtype
*>(pov
+ 8);
2414 val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2415 reloc
= (gotplt_base
- (plt_base
+ plt_offset
+ 8)) >> 16;
2416 dst_mask
= (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X0_IMM16_BITOFF
;
2418 reloc
&= TILEGX_IMM16_MASK
;
2419 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2420 val
| (reloc
<<TILEGX_X0_IMM16_BITOFF
));
2422 // third bundle in plt stub - x1
2423 wv
= reinterpret_cast<Valtype
*>(pov
+ 16);
2424 val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2425 reloc
= gotplt_base
- (plt_base
+ plt_offset
+ 8);
2426 dst_mask
= (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X1_IMM16_BITOFF
;
2428 reloc
&= TILEGX_IMM16_MASK
;
2429 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2430 val
| (reloc
<<TILEGX_X1_IMM16_BITOFF
));
2432 // fifth bundle in plt stub - carry plt_index x0
2433 wv
= reinterpret_cast<Valtype
*>(pov
+ 32);
2434 val
= elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::readval(wv
);
2435 dst_mask
= (elfcpp::Elf_Xword
)(TILEGX_IMM16_MASK
) << TILEGX_X0_IMM16_BITOFF
;
2437 plt_index
&= TILEGX_IMM16_MASK
;
2438 elfcpp::Swap
<TILEGX_INST_BUNDLE_SIZE
, big_endian
>::writeval(wv
,
2439 val
| (plt_index
<<TILEGX_X0_IMM16_BITOFF
));
2443 // Write out the PLT. This uses the hand-coded instructions above.
2445 template<int size
, bool big_endian
>
2447 Output_data_plt_tilegx
<size
, big_endian
>::do_write(Output_file
* of
)
2449 const off_t offset
= this->offset();
2450 const section_size_type oview_size
=
2451 convert_to_section_size_type(this->data_size());
2452 unsigned char* const oview
= of
->get_output_view(offset
, oview_size
);
2454 const off_t got_file_offset
= this->got_plt_
->offset();
2455 gold_assert(parameters
->incremental_update()
2456 || (got_file_offset
+ this->got_plt_
->data_size()
2457 == this->got_irelative_
->offset()));
2458 const section_size_type got_size
=
2459 convert_to_section_size_type(this->got_plt_
->data_size()
2460 + this->got_irelative_
->data_size());
2461 unsigned char* const got_view
= of
->get_output_view(got_file_offset
,
2464 unsigned char* pov
= oview
;
2466 // The base address of the .plt section.
2467 typename
elfcpp::Elf_types
<size
>::Elf_Addr plt_address
= this->address();
2468 typename
elfcpp::Elf_types
<size
>::Elf_Addr got_address
=
2469 this->got_plt_
->address();
2471 this->fill_first_plt_entry(pov
);
2472 pov
+= this->get_plt_entry_size();
2474 unsigned char* got_pov
= got_view
;
2476 // first entry of .got.plt are set to -1
2477 // second entry of .got.plt are set to 0
2478 memset(got_pov
, 0xff, size
/ 8);
2479 got_pov
+= size
/ 8;
2480 memset(got_pov
, 0x0, size
/ 8);
2481 got_pov
+= size
/ 8;
2483 unsigned int plt_offset
= this->get_plt_entry_size();
2484 const unsigned int count
= this->count_
+ this->irelative_count_
;
2485 unsigned int got_offset
= (size
/ 8) * TILEGX_GOTPLT_RESERVE_COUNT
;
2486 for (unsigned int plt_index
= 0;
2489 pov
+= this->get_plt_entry_size(),
2490 got_pov
+= size
/ 8,
2491 plt_offset
+= this->get_plt_entry_size(),
2492 got_offset
+= size
/ 8)
2494 // Set and adjust the PLT entry itself.
2495 this->fill_plt_entry(pov
, got_address
, got_offset
,
2496 plt_address
, plt_offset
, plt_index
);
2498 // Initialize entry in .got.plt to plt start address
2499 elfcpp::Swap
<size
, big_endian
>::writeval(got_pov
, plt_address
);
2502 gold_assert(static_cast<section_size_type
>(pov
- oview
) == oview_size
);
2503 gold_assert(static_cast<section_size_type
>(got_pov
- got_view
) == got_size
);
2505 of
->write_output_view(offset
, oview_size
, oview
);
2506 of
->write_output_view(got_file_offset
, got_size
, got_view
);
2509 // Create the PLT section.
2511 template<int size
, bool big_endian
>
2513 Target_tilegx
<size
, big_endian
>::make_plt_section(Symbol_table
* symtab
,
2516 if (this->plt_
== NULL
)
2518 // Create the GOT sections first.
2519 this->got_section(symtab
, layout
);
2521 // Ensure that .rela.dyn always appears before .rela.plt,
2522 // becuase on TILE-Gx, .rela.dyn needs to include .rela.plt
2524 this->rela_dyn_section(layout
);
2526 this->plt_
= new Output_data_plt_tilegx
<size
, big_endian
>(layout
,
2527 TILEGX_INST_BUNDLE_SIZE
, this->got_
, this->got_plt_
,
2528 this->got_irelative_
);
2530 layout
->add_output_section_data(".plt", elfcpp::SHT_PROGBITS
,
2532 | elfcpp::SHF_EXECINSTR
),
2533 this->plt_
, ORDER_NON_RELRO_FIRST
,
2536 // Make the sh_info field of .rela.plt point to .plt.
2537 Output_section
* rela_plt_os
= this->plt_
->rela_plt()->output_section();
2538 rela_plt_os
->set_info_section(this->plt_
->output_section());
2542 // Create a PLT entry for a global symbol.
2544 template<int size
, bool big_endian
>
2546 Target_tilegx
<size
, big_endian
>::make_plt_entry(Symbol_table
* symtab
,
2547 Layout
* layout
, Symbol
* gsym
)
2549 if (gsym
->has_plt_offset())
2552 if (this->plt_
== NULL
)
2553 this->make_plt_section(symtab
, layout
);
2555 this->plt_
->add_entry(symtab
, layout
, gsym
);
2558 // Make a PLT entry for a local STT_GNU_IFUNC symbol.
2560 template<int size
, bool big_endian
>
2562 Target_tilegx
<size
, big_endian
>::make_local_ifunc_plt_entry(
2563 Symbol_table
* symtab
, Layout
* layout
,
2564 Sized_relobj_file
<size
, big_endian
>* relobj
,
2565 unsigned int local_sym_index
)
2567 if (relobj
->local_has_plt_offset(local_sym_index
))
2569 if (this->plt_
== NULL
)
2570 this->make_plt_section(symtab
, layout
);
2571 unsigned int plt_offset
= this->plt_
->add_local_ifunc_entry(symtab
, layout
,
2574 relobj
->set_local_plt_offset(local_sym_index
, plt_offset
);
2577 // Return the number of entries in the PLT.
2579 template<int size
, bool big_endian
>
2581 Target_tilegx
<size
, big_endian
>::plt_entry_count() const
2583 if (this->plt_
== NULL
)
2585 return this->plt_
->entry_count();
2588 // Return the offset of the first non-reserved PLT entry.
2590 template<int size
, bool big_endian
>
2592 Target_tilegx
<size
, big_endian
>::first_plt_entry_offset() const
2594 return this->plt_
->first_plt_entry_offset();
2597 // Return the size of each PLT entry.
2599 template<int size
, bool big_endian
>
2601 Target_tilegx
<size
, big_endian
>::plt_entry_size() const
2603 return this->plt_
->get_plt_entry_size();
2606 // Create the GOT and PLT sections for an incremental update.
2608 template<int size
, bool big_endian
>
2609 Output_data_got_base
*
2610 Target_tilegx
<size
, big_endian
>::init_got_plt_for_update(Symbol_table
* symtab
,
2612 unsigned int got_count
,
2613 unsigned int plt_count
)
2615 gold_assert(this->got_
== NULL
);
2618 new Output_data_got
<size
, big_endian
>((got_count
2619 + TILEGX_GOT_RESERVE_COUNT
)
2621 layout
->add_output_section_data(".got", elfcpp::SHT_PROGBITS
,
2623 | elfcpp::SHF_WRITE
),
2624 this->got_
, ORDER_RELRO_LAST
,
2627 // Define _GLOBAL_OFFSET_TABLE_ at the start of the GOT.
2628 this->global_offset_table_
=
2629 symtab
->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL
,
2630 Symbol_table::PREDEFINED
,
2632 0, 0, elfcpp::STT_OBJECT
,
2634 elfcpp::STV_HIDDEN
, 0,
2637 if (parameters
->options().shared()) {
2638 this->tilegx_dynamic_
=
2639 symtab
->define_in_output_data("_TILEGX_DYNAMIC_", NULL
,
2640 Symbol_table::PREDEFINED
,
2641 layout
->dynamic_section(),
2642 0, 0, elfcpp::STT_OBJECT
,
2644 elfcpp::STV_HIDDEN
, 0,
2647 this->got_
->add_global(this->tilegx_dynamic_
, GOT_TYPE_STANDARD
);
2649 this->got_
->set_current_data_size(size
/ 8);
2651 // Add the two reserved entries.
2653 = new Output_data_space((plt_count
+ TILEGX_GOTPLT_RESERVE_COUNT
)
2654 * (size
/ 8), size
/ 8, "** GOT PLT");
2655 layout
->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS
,
2657 | elfcpp::SHF_WRITE
),
2658 this->got_plt_
, ORDER_NON_RELRO_FIRST
,
2661 // If there are any IRELATIVE relocations, they get GOT entries in
2662 // .got.plt after the jump slot.
2663 this->got_irelative_
2664 = new Output_data_space(0, size
/ 8, "** GOT IRELATIVE PLT");
2665 layout
->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS
,
2666 elfcpp::SHF_ALLOC
| elfcpp::SHF_WRITE
,
2667 this->got_irelative_
,
2668 ORDER_NON_RELRO_FIRST
, false);
2670 // Create the PLT section.
2671 this->plt_
= new Output_data_plt_tilegx
<size
, big_endian
>(layout
,
2672 this->plt_entry_size(), this->got_
, this->got_plt_
, this->got_irelative_
,
2675 layout
->add_output_section_data(".plt", elfcpp::SHT_PROGBITS
,
2676 elfcpp::SHF_ALLOC
| elfcpp::SHF_EXECINSTR
,
2677 this->plt_
, ORDER_PLT
, false);
2679 // Make the sh_info field of .rela.plt point to .plt.
2680 Output_section
* rela_plt_os
= this->plt_
->rela_plt()->output_section();
2681 rela_plt_os
->set_info_section(this->plt_
->output_section());
2683 // Create the rela_dyn section.
2684 this->rela_dyn_section(layout
);
2689 // Reserve a GOT entry for a local symbol, and regenerate any
2690 // necessary dynamic relocations.
2692 template<int size
, bool big_endian
>
2694 Target_tilegx
<size
, big_endian
>::reserve_local_got_entry(
2695 unsigned int got_index
,
2696 Sized_relobj
<size
, big_endian
>* obj
,
2698 unsigned int got_type
)
2700 unsigned int got_offset
= (got_index
+ TILEGX_GOT_RESERVE_COUNT
)
2702 Reloc_section
* rela_dyn
= this->rela_dyn_section(NULL
);
2704 this->got_
->reserve_local(got_index
, obj
, r_sym
, got_type
);
2707 case GOT_TYPE_STANDARD
:
2708 if (parameters
->options().output_is_position_independent())
2709 rela_dyn
->add_local_relative(obj
, r_sym
, elfcpp::R_TILEGX_RELATIVE
,
2710 this->got_
, got_offset
, 0, false);
2712 case GOT_TYPE_TLS_OFFSET
:
2713 rela_dyn
->add_local(obj
, r_sym
,
2714 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPOFF32
2715 : elfcpp::R_TILEGX_TLS_DTPOFF64
,
2716 this->got_
, got_offset
, 0);
2718 case GOT_TYPE_TLS_PAIR
:
2719 this->got_
->reserve_slot(got_index
+ 1);
2720 rela_dyn
->add_local(obj
, r_sym
,
2721 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPMOD32
2722 : elfcpp::R_TILEGX_TLS_DTPMOD64
,
2723 this->got_
, got_offset
, 0);
2725 case GOT_TYPE_TLS_DESC
:
2726 gold_fatal(_("TLS_DESC not yet supported for incremental linking"));
2733 // Reserve a GOT entry for a global symbol, and regenerate any
2734 // necessary dynamic relocations.
2736 template<int size
, bool big_endian
>
2738 Target_tilegx
<size
, big_endian
>::reserve_global_got_entry(
2739 unsigned int got_index
, Symbol
* gsym
, unsigned int got_type
)
2741 unsigned int got_offset
= (got_index
+ TILEGX_GOT_RESERVE_COUNT
)
2743 Reloc_section
* rela_dyn
= this->rela_dyn_section(NULL
);
2745 this->got_
->reserve_global(got_index
, gsym
, got_type
);
2748 case GOT_TYPE_STANDARD
:
2749 if (!gsym
->final_value_is_known())
2751 if (gsym
->is_from_dynobj()
2752 || gsym
->is_undefined()
2753 || gsym
->is_preemptible()
2754 || gsym
->type() == elfcpp::STT_GNU_IFUNC
)
2755 rela_dyn
->add_global(gsym
, elfcpp::R_TILEGX_GLOB_DAT
,
2756 this->got_
, got_offset
, 0);
2758 rela_dyn
->add_global_relative(gsym
, elfcpp::R_TILEGX_RELATIVE
,
2759 this->got_
, got_offset
, 0, false);
2762 case GOT_TYPE_TLS_OFFSET
:
2763 rela_dyn
->add_global_relative(gsym
,
2764 size
== 32 ? elfcpp::R_TILEGX_TLS_TPOFF32
2765 : elfcpp::R_TILEGX_TLS_TPOFF64
,
2766 this->got_
, got_offset
, 0, false);
2768 case GOT_TYPE_TLS_PAIR
:
2769 this->got_
->reserve_slot(got_index
+ 1);
2770 rela_dyn
->add_global_relative(gsym
,
2771 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPMOD32
2772 : elfcpp::R_TILEGX_TLS_DTPMOD64
,
2773 this->got_
, got_offset
, 0, false);
2774 rela_dyn
->add_global_relative(gsym
,
2775 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPOFF32
2776 : elfcpp::R_TILEGX_TLS_DTPOFF64
,
2777 this->got_
, got_offset
+ size
/ 8,
2780 case GOT_TYPE_TLS_DESC
:
2781 gold_fatal(_("TLS_DESC not yet supported for TILEGX"));
2788 // Register an existing PLT entry for a global symbol.
2790 template<int size
, bool big_endian
>
2792 Target_tilegx
<size
, big_endian
>::register_global_plt_entry(
2793 Symbol_table
* symtab
, Layout
* layout
, unsigned int plt_index
, Symbol
* gsym
)
2795 gold_assert(this->plt_
!= NULL
);
2796 gold_assert(!gsym
->has_plt_offset());
2798 this->plt_
->reserve_slot(plt_index
);
2800 gsym
->set_plt_offset((plt_index
+ 1) * this->plt_entry_size());
2802 unsigned int got_offset
= (plt_index
+ 2) * (size
/ 8);
2803 this->plt_
->add_relocation(symtab
, layout
, gsym
, got_offset
);
2806 // Force a COPY relocation for a given symbol.
2808 template<int size
, bool big_endian
>
2810 Target_tilegx
<size
, big_endian
>::emit_copy_reloc(
2811 Symbol_table
* symtab
, Symbol
* sym
, Output_section
* os
, off_t offset
)
2813 this->copy_relocs_
.emit_copy_reloc(symtab
,
2814 symtab
->get_sized_symbol
<size
>(sym
),
2817 this->rela_dyn_section(NULL
));
2820 // Create a GOT entry for the TLS module index.
2822 template<int size
, bool big_endian
>
2824 Target_tilegx
<size
, big_endian
>::got_mod_index_entry(Symbol_table
* symtab
,
2826 Sized_relobj_file
<size
, big_endian
>* object
)
2828 if (this->got_mod_index_offset_
== -1U)
2830 gold_assert(symtab
!= NULL
&& layout
!= NULL
&& object
!= NULL
);
2831 Reloc_section
* rela_dyn
= this->rela_dyn_section(layout
);
2832 Output_data_got
<size
, big_endian
>* got
2833 = this->got_section(symtab
, layout
);
2834 unsigned int got_offset
= got
->add_constant(0);
2835 rela_dyn
->add_local(object
, 0,
2836 size
== 32 ? elfcpp::R_TILEGX_TLS_DTPMOD32
2837 : elfcpp::R_TILEGX_TLS_DTPMOD64
, got
,
2839 got
->add_constant(0);
2840 this->got_mod_index_offset_
= got_offset
;
2842 return this->got_mod_index_offset_
;
2845 // Optimize the TLS relocation type based on what we know about the
2846 // symbol. IS_FINAL is true if the final address of this symbol is
2847 // known at link time.
2849 // the transformation rules is described below:
2851 // compiler GD reference
2854 // moveli tmp, hw1_last_tls_gd(x) X0/X1
2855 // shl16insli r0, tmp, hw0_tls_gd(x) X0/X1
2856 // addi r0, got, tls_add(x) Y0/Y1/X0/X1
2857 // jal tls_gd_call(x) X1
2858 // addi adr, r0, tls_gd_add(x) Y0/Y1/X0/X1
2860 // linker tranformation of GD insn sequence
2864 // moveli tmp, hw1_last_tls_gd(x) X0/X1
2865 // shl16insli r0, tmp, hw0_tls_gd(x) X0/X1
2866 // add r0, got, r0 Y0/Y1/X0/X1
2867 // jal plt(__tls_get_addr) X1
2868 // move adr, r0 Y0/Y1/X0/X1
2870 // moveli tmp, hw1_last_tls_ie(x) X0/X1
2871 // shl16insli r0, tmp, hw0_tls_ie(x) X0/X1
2872 // add r0, got, r0 Y0/Y1/X0/X1
2874 // add adr, r0, tp Y0/Y1/X0/X1
2876 // moveli tmp, hw1_last_tls_le(x) X0/X1
2877 // shl16insli r0, tmp, hw0_tls_le(x) X0/X1
2878 // move r0, r0 Y0/Y1/X0/X1
2879 // move r0, r0 Y0/Y1/X0/X1
2880 // add adr, r0, tp Y0/Y1/X0/X1
2883 // compiler IE reference
2886 // moveli tmp, hw1_last_tls_ie(x) X0/X1
2887 // shl16insli tmp, tmp, hw0_tls_ie(x) X0/X1
2888 // addi tmp, got, tls_add(x) Y0/Y1/X0/X1
2889 // ld_tls tmp, tmp, tls_ie_load(x) X1
2890 // add adr, tmp, tp Y0/Y1/X0/X1
2892 // linker transformation for IE insn sequence
2896 // moveli tmp, hw1_last_tls_ie(x) X0/X1
2897 // shl16insli tmp, tmp, hw0_tls_ie(x) X0/X1
2898 // add tmp, got, tmp Y0/Y1/X0/X1
2900 // add adr, tmp, tp Y0/Y1/X0/X1
2902 // moveli tmp, hw1_last_tls_le(x) X0/X1
2903 // shl16insli tmp, tmp, hw0_tls_le(x) X0/X1
2904 // move tmp, tmp Y0/Y1/X0/X1
2905 // move tmp, tmp Y0/Y1/X0/X1
2908 // compiler LE reference
2911 // moveli tmp, hw1_last_tls_le(x) X0/X1
2912 // shl16insli tmp, tmp, hw0_tls_le(x) X0/X1
2913 // add adr, tmp, tp Y0/Y1/X0/X1
2915 template<int size
, bool big_endian
>
2916 tls::Tls_optimization
2917 Target_tilegx
<size
, big_endian
>::optimize_tls_reloc(bool is_final
, int r_type
)
2919 // If we are generating a shared library, then we can't do anything
2921 if (parameters
->options().shared())
2922 return tls::TLSOPT_NONE
;
2926 // unique GD relocations
2927 case elfcpp::R_TILEGX_TLS_GD_CALL
:
2928 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
2929 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
2930 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
2931 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
2932 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
2933 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
2934 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
2935 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
2936 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
2937 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
2938 // These are General-Dynamic which permits fully general TLS
2939 // access. Since we know that we are generating an executable,
2940 // we can convert this to Initial-Exec. If we also know that
2941 // this is a local symbol, we can further switch to Local-Exec.
2943 return tls::TLSOPT_TO_LE
;
2944 return tls::TLSOPT_TO_IE
;
2946 // unique IE relocations
2947 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
2948 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
2949 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
2950 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
2951 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
2952 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
2953 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
2954 // These are Initial-Exec relocs which get the thread offset
2955 // from the GOT. If we know that we are linking against the
2956 // local symbol, we can switch to Local-Exec, which links the
2957 // thread offset into the instruction.
2959 return tls::TLSOPT_TO_LE
;
2960 return tls::TLSOPT_NONE
;
2962 // could be created for both GD and IE
2963 // but they are expanded into the same
2964 // instruction in GD and IE.
2965 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
2966 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
2967 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
2968 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
2970 return tls::TLSOPT_TO_LE
;
2971 return tls::TLSOPT_NONE
;
2973 // unique LE relocations
2974 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
2975 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
2976 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
2977 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
2978 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
2979 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
2980 // When we already have Local-Exec, there is nothing further we
2982 return tls::TLSOPT_NONE
;
2989 // Get the Reference_flags for a particular relocation.
2991 template<int size
, bool big_endian
>
2993 Target_tilegx
<size
, big_endian
>::Scan::get_reference_flags(unsigned int r_type
)
2997 case elfcpp::R_TILEGX_NONE
:
2998 case elfcpp::R_TILEGX_GNU_VTINHERIT
:
2999 case elfcpp::R_TILEGX_GNU_VTENTRY
:
3000 // No symbol reference.
3003 case elfcpp::R_TILEGX_64
:
3004 case elfcpp::R_TILEGX_32
:
3005 case elfcpp::R_TILEGX_16
:
3006 case elfcpp::R_TILEGX_8
:
3007 return Symbol::ABSOLUTE_REF
;
3009 case elfcpp::R_TILEGX_BROFF_X1
:
3010 case elfcpp::R_TILEGX_64_PCREL
:
3011 case elfcpp::R_TILEGX_32_PCREL
:
3012 case elfcpp::R_TILEGX_16_PCREL
:
3013 case elfcpp::R_TILEGX_8_PCREL
:
3014 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3015 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3016 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3017 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3018 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3019 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3020 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3021 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3022 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3023 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3024 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3025 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3026 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3027 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3028 return Symbol::RELATIVE_REF
;
3030 case elfcpp::R_TILEGX_JUMPOFF_X1
:
3031 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT
:
3032 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL
:
3033 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL
:
3034 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL
:
3035 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL
:
3036 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL
:
3037 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL
:
3038 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
:
3039 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
:
3040 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
:
3041 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
:
3042 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
:
3043 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
:
3044 return Symbol::FUNCTION_CALL
| Symbol::RELATIVE_REF
;
3046 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3047 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3048 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3049 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3050 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3051 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3052 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3053 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3054 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3055 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3056 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3057 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3058 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3059 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3060 return Symbol::ABSOLUTE_REF
;
3062 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
3063 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
3064 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
3065 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
3066 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
3067 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
3069 return Symbol::ABSOLUTE_REF
;
3071 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
3072 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
3073 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
3074 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
3075 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
3076 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
3077 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
3078 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
3079 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
3080 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
3081 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
3082 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
3083 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
3084 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
3085 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
3086 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
3087 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
3088 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
3089 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
3090 case elfcpp::R_TILEGX_TLS_DTPMOD32
:
3091 case elfcpp::R_TILEGX_TLS_DTPOFF32
:
3092 case elfcpp::R_TILEGX_TLS_TPOFF32
:
3093 case elfcpp::R_TILEGX_TLS_GD_CALL
:
3094 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
3095 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
3096 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
3097 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
3098 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
3099 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
3100 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
3101 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
3102 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
3103 return Symbol::TLS_REF
;
3105 case elfcpp::R_TILEGX_COPY
:
3106 case elfcpp::R_TILEGX_GLOB_DAT
:
3107 case elfcpp::R_TILEGX_JMP_SLOT
:
3108 case elfcpp::R_TILEGX_RELATIVE
:
3109 case elfcpp::R_TILEGX_TLS_TPOFF64
:
3110 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
3112 // Not expected. We will give an error later.
3117 // Report an unsupported relocation against a local symbol.
3119 template<int size
, bool big_endian
>
3121 Target_tilegx
<size
, big_endian
>::Scan::unsupported_reloc_local(
3122 Sized_relobj_file
<size
, big_endian
>* object
,
3123 unsigned int r_type
)
3125 gold_error(_("%s: unsupported reloc %u against local symbol"),
3126 object
->name().c_str(), r_type
);
3129 // We are about to emit a dynamic relocation of type R_TYPE. If the
3130 // dynamic linker does not support it, issue an error.
3131 template<int size
, bool big_endian
>
3133 Target_tilegx
<size
, big_endian
>::Scan::check_non_pic(Relobj
* object
,
3134 unsigned int r_type
)
3138 // These are the relocation types supported by glibc for tilegx
3139 // which should always work.
3140 case elfcpp::R_TILEGX_RELATIVE
:
3141 case elfcpp::R_TILEGX_GLOB_DAT
:
3142 case elfcpp::R_TILEGX_JMP_SLOT
:
3143 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
3144 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
3145 case elfcpp::R_TILEGX_TLS_TPOFF64
:
3146 case elfcpp::R_TILEGX_8
:
3147 case elfcpp::R_TILEGX_16
:
3148 case elfcpp::R_TILEGX_32
:
3149 case elfcpp::R_TILEGX_64
:
3150 case elfcpp::R_TILEGX_COPY
:
3151 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3152 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3153 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3154 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3155 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3156 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3157 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3158 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3159 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3160 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3161 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3162 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3163 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3164 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3165 case elfcpp::R_TILEGX_BROFF_X1
:
3166 case elfcpp::R_TILEGX_JUMPOFF_X1
:
3167 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3168 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3169 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3170 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3171 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3172 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3173 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3174 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3175 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3176 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3177 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3178 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3179 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3180 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3184 // This prevents us from issuing more than one error per reloc
3185 // section. But we can still wind up issuing more than one
3186 // error per object file.
3187 if (this->issued_non_pic_error_
)
3189 gold_assert(parameters
->options().output_is_position_independent());
3190 object
->error(_("requires unsupported dynamic reloc %u; "
3191 "recompile with -fPIC"),
3193 this->issued_non_pic_error_
= true;
3196 case elfcpp::R_TILEGX_NONE
:
3201 // Return whether we need to make a PLT entry for a relocation of the
3202 // given type against a STT_GNU_IFUNC symbol.
3204 template<int size
, bool big_endian
>
3206 Target_tilegx
<size
, big_endian
>::Scan::reloc_needs_plt_for_ifunc(
3207 Sized_relobj_file
<size
, big_endian
>* object
, unsigned int r_type
)
3209 int flags
= Scan::get_reference_flags(r_type
);
3210 if (flags
& Symbol::TLS_REF
)
3211 gold_error(_("%s: unsupported TLS reloc %u for IFUNC symbol"),
3212 object
->name().c_str(), r_type
);
3216 // Scan a relocation for a local symbol.
3218 template<int size
, bool big_endian
>
3220 Target_tilegx
<size
, big_endian
>::Scan::local(Symbol_table
* symtab
,
3222 Target_tilegx
<size
, big_endian
>* target
,
3223 Sized_relobj_file
<size
, big_endian
>* object
,
3224 unsigned int data_shndx
,
3225 Output_section
* output_section
,
3226 const elfcpp::Rela
<size
, big_endian
>& reloc
,
3227 unsigned int r_type
,
3228 const elfcpp::Sym
<size
, big_endian
>& lsym
,
3234 // A local STT_GNU_IFUNC symbol may require a PLT entry.
3235 bool is_ifunc
= lsym
.get_st_type() == elfcpp::STT_GNU_IFUNC
;
3236 if (is_ifunc
&& this->reloc_needs_plt_for_ifunc(object
, r_type
))
3238 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3239 target
->make_local_ifunc_plt_entry(symtab
, layout
, object
, r_sym
);
3244 case elfcpp::R_TILEGX_NONE
:
3245 case elfcpp::R_TILEGX_GNU_VTINHERIT
:
3246 case elfcpp::R_TILEGX_GNU_VTENTRY
:
3249 // If building a shared library (or a position-independent
3250 // executable), because the runtime address needs plus
3251 // the module base address, so generate a R_TILEGX_RELATIVE.
3252 case elfcpp::R_TILEGX_32
:
3253 case elfcpp::R_TILEGX_64
:
3254 if (parameters
->options().output_is_position_independent())
3256 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3257 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3258 rela_dyn
->add_local_relative(object
, r_sym
,
3259 elfcpp::R_TILEGX_RELATIVE
,
3260 output_section
, data_shndx
,
3261 reloc
.get_r_offset(),
3262 reloc
.get_r_addend(), is_ifunc
);
3266 // If building a shared library (or a position-independent
3267 // executable), we need to create a dynamic relocation for this
3269 case elfcpp::R_TILEGX_8
:
3270 case elfcpp::R_TILEGX_16
:
3271 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3272 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3273 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3274 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3275 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3276 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3277 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3278 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3279 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3280 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3281 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3282 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3283 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3284 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3285 if (parameters
->options().output_is_position_independent())
3287 this->check_non_pic(object
, r_type
);
3289 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3290 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3291 if (lsym
.get_st_type() != elfcpp::STT_SECTION
)
3292 rela_dyn
->add_local(object
, r_sym
, r_type
, output_section
,
3293 data_shndx
, reloc
.get_r_offset(),
3294 reloc
.get_r_addend());
3297 gold_assert(lsym
.get_st_value() == 0);
3298 rela_dyn
->add_symbolless_local_addend(object
, r_sym
, r_type
,
3301 reloc
.get_r_offset(),
3302 reloc
.get_r_addend());
3308 // R_TILEGX_JUMPOFF_X1_PLT against local symbol
3309 // may happen for ifunc case.
3310 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT
:
3311 case elfcpp::R_TILEGX_JUMPOFF_X1
:
3312 case elfcpp::R_TILEGX_64_PCREL
:
3313 case elfcpp::R_TILEGX_32_PCREL
:
3314 case elfcpp::R_TILEGX_16_PCREL
:
3315 case elfcpp::R_TILEGX_8_PCREL
:
3316 case elfcpp::R_TILEGX_BROFF_X1
:
3317 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3318 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3319 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3320 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3321 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3322 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3323 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3324 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3325 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3326 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3327 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3328 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3329 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3330 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3331 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL
:
3332 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL
:
3333 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL
:
3334 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL
:
3335 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL
:
3336 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL
:
3337 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
:
3338 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
:
3339 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
:
3340 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
:
3341 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
:
3342 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
:
3345 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
3346 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
3347 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
3348 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
3349 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
3350 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
3352 // The symbol requires a GOT entry.
3353 Output_data_got
<size
, big_endian
>* got
3354 = target
->got_section(symtab
, layout
);
3355 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3357 // For a STT_GNU_IFUNC symbol we want the PLT offset. That
3358 // lets function pointers compare correctly with shared
3359 // libraries. Otherwise we would need an IRELATIVE reloc.
3362 is_new
= got
->add_local_plt(object
, r_sym
, GOT_TYPE_STANDARD
);
3364 is_new
= got
->add_local(object
, r_sym
, GOT_TYPE_STANDARD
);
3367 // tilegx dynamic linker will not update local got entry,
3368 // so, if we are generating a shared object, we need to add a
3369 // dynamic relocation for this symbol's GOT entry to inform
3370 // dynamic linker plus the load base explictly.
3371 if (parameters
->options().output_is_position_independent())
3373 unsigned int got_offset
3374 = object
->local_got_offset(r_sym
, GOT_TYPE_STANDARD
);
3376 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3377 rela_dyn
->add_local_relative(object
, r_sym
,
3379 got
, got_offset
, 0, is_ifunc
);
3385 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
3386 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
3387 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
3388 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
3389 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
3390 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
3391 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
3392 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
3393 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
3394 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
3395 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
3396 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
3397 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
3398 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
3399 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
3400 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
3401 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
3402 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
3403 case elfcpp::R_TILEGX_TLS_GD_CALL
:
3404 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
3405 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
3406 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
3407 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
3408 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
3409 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
3410 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
3411 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
3412 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
3414 bool output_is_shared
= parameters
->options().shared();
3415 const tls::Tls_optimization opt_t
=
3416 Target_tilegx
<size
, big_endian
>::optimize_tls_reloc(
3417 !output_is_shared
, r_type
);
3421 case elfcpp::R_TILEGX_TLS_GD_CALL
:
3422 // FIXME: predefine __tls_get_addr
3424 // R_TILEGX_TLS_GD_CALL implicitly reference __tls_get_addr,
3425 // while all other target, x86/arm/mips/powerpc/sparc
3426 // generate tls relocation against __tls_get_addr explictly,
3427 // so for TILEGX, we need the following hack.
3428 if (opt_t
== tls::TLSOPT_NONE
) {
3429 if (!target
->tls_get_addr_sym_defined_
) {
3431 options::parse_set(NULL
, "__tls_get_addr",
3432 (gold::options::String_set
*)
3433 ¶meters
->options().undefined());
3434 symtab
->add_undefined_symbols_from_command_line(layout
);
3435 target
->tls_get_addr_sym_defined_
= true;
3436 sym
= symtab
->lookup("__tls_get_addr");
3439 target
->make_plt_entry(symtab
, layout
,
3440 symtab
->lookup("__tls_get_addr"));
3444 // only make effect when applying relocation
3445 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
3446 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
3447 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
3448 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
3449 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
3450 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
3451 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
3452 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
3453 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
3456 // GD: requires two GOT entry for module index and offset
3457 // IE: requires one GOT entry for tp-relative offset
3458 // LE: shouldn't happen for global symbol
3459 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
3460 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
3461 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
3462 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
3463 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
3464 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
3466 if (opt_t
== tls::TLSOPT_NONE
) {
3467 Output_data_got
<size
, big_endian
> *got
3468 = target
->got_section(symtab
, layout
);
3470 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3471 unsigned int shndx
= lsym
.get_st_shndx();
3473 shndx
= object
->adjust_sym_shndx(r_sym
, shndx
,
3476 object
->error(_("local symbol %u has bad shndx %u"),
3479 got
->add_local_pair_with_rel(object
, r_sym
, shndx
,
3481 target
->rela_dyn_section(layout
),
3483 ? elfcpp::R_TILEGX_TLS_DTPMOD32
3484 : elfcpp::R_TILEGX_TLS_DTPMOD64
);
3485 } else if (opt_t
== tls::TLSOPT_TO_IE
) {
3486 Output_data_got
<size
, big_endian
>* got
3487 = target
->got_section(symtab
, layout
);
3488 Reloc_section
* rela_dyn
3489 = target
->rela_dyn_section(layout
);
3491 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3492 unsigned int off
= got
->add_constant(0);
3493 object
->set_local_got_offset(r_sym
,
3494 GOT_TYPE_TLS_OFFSET
,off
);
3495 rela_dyn
->add_symbolless_local_addend(object
, r_sym
,
3497 ? elfcpp::R_TILEGX_TLS_TPOFF32
3498 : elfcpp::R_TILEGX_TLS_TPOFF64
,
3500 } else if (opt_t
!= tls::TLSOPT_TO_LE
)
3501 // only TO_LE is allowed for local symbol
3502 unsupported_reloc_local(object
, r_type
);
3507 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
3508 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
3509 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
3510 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
3511 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
3512 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
3514 layout
->set_has_static_tls();
3515 if (opt_t
== tls::TLSOPT_NONE
) {
3516 Output_data_got
<size
, big_endian
>* got
3517 = target
->got_section(symtab
, layout
);
3518 Reloc_section
* rela_dyn
3519 = target
->rela_dyn_section(layout
);
3521 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3522 unsigned int off
= got
->add_constant(0);
3523 object
->set_local_got_offset(r_sym
,
3524 GOT_TYPE_TLS_OFFSET
, off
);
3525 rela_dyn
->add_symbolless_local_addend(object
, r_sym
,
3527 ? elfcpp::R_TILEGX_TLS_TPOFF32
3528 : elfcpp::R_TILEGX_TLS_TPOFF64
,
3530 } else if (opt_t
!= tls::TLSOPT_TO_LE
)
3531 unsupported_reloc_local(object
, r_type
);
3536 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
3537 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
3538 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
3539 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
3540 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
3541 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
3542 layout
->set_has_static_tls();
3543 if (parameters
->options().shared()) {
3544 // defer to dynamic linker
3545 gold_assert(lsym
.get_st_type() != elfcpp::STT_SECTION
);
3547 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
3548 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3549 rela_dyn
->add_symbolless_local_addend(object
, r_sym
, r_type
,
3550 output_section
, data_shndx
,
3551 reloc
.get_r_offset(), 0);
3561 case elfcpp::R_TILEGX_COPY
:
3562 case elfcpp::R_TILEGX_GLOB_DAT
:
3563 case elfcpp::R_TILEGX_JMP_SLOT
:
3564 case elfcpp::R_TILEGX_RELATIVE
:
3565 // These are outstanding tls relocs, which are unexpected when linking
3566 case elfcpp::R_TILEGX_TLS_TPOFF32
:
3567 case elfcpp::R_TILEGX_TLS_TPOFF64
:
3568 case elfcpp::R_TILEGX_TLS_DTPMOD32
:
3569 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
3570 case elfcpp::R_TILEGX_TLS_DTPOFF32
:
3571 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
3572 gold_error(_("%s: unexpected reloc %u in object file"),
3573 object
->name().c_str(), r_type
);
3577 gold_error(_("%s: unsupported reloc %u against local symbol"),
3578 object
->name().c_str(), r_type
);
3584 // Report an unsupported relocation against a global symbol.
3586 template<int size
, bool big_endian
>
3588 Target_tilegx
<size
, big_endian
>::Scan::unsupported_reloc_global(
3589 Sized_relobj_file
<size
, big_endian
>* object
,
3590 unsigned int r_type
,
3593 gold_error(_("%s: unsupported reloc %u against global symbol %s"),
3594 object
->name().c_str(), r_type
, gsym
->demangled_name().c_str());
3597 // Returns true if this relocation type could be that of a function pointer.
3598 template<int size
, bool big_endian
>
3600 Target_tilegx
<size
, big_endian
>::Scan::possible_function_pointer_reloc(
3601 unsigned int r_type
)
3605 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3606 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3607 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3608 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3609 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3610 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3611 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3612 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3613 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3614 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3615 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3616 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3617 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3618 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3619 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3620 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3621 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3622 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3623 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3624 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3625 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3626 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3627 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3628 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3629 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3630 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3631 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3632 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3633 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
3634 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
3635 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
3636 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
3637 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
3638 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
3646 // For safe ICF, scan a relocation for a local symbol to check if it
3647 // corresponds to a function pointer being taken. In that case mark
3648 // the function whose pointer was taken as not foldable.
3650 template<int size
, bool big_endian
>
3652 Target_tilegx
<size
, big_endian
>::Scan::local_reloc_may_be_function_pointer(
3655 Target_tilegx
<size
, big_endian
>* ,
3656 Sized_relobj_file
<size
, big_endian
>* ,
3659 const elfcpp::Rela
<size
, big_endian
>& ,
3660 unsigned int r_type
,
3661 const elfcpp::Sym
<size
, big_endian
>&)
3663 return possible_function_pointer_reloc(r_type
);
3666 // For safe ICF, scan a relocation for a global symbol to check if it
3667 // corresponds to a function pointer being taken. In that case mark
3668 // the function whose pointer was taken as not foldable.
3670 template<int size
, bool big_endian
>
3672 Target_tilegx
<size
, big_endian
>::Scan::global_reloc_may_be_function_pointer(
3675 Target_tilegx
<size
, big_endian
>* ,
3676 Sized_relobj_file
<size
, big_endian
>* ,
3679 const elfcpp::Rela
<size
, big_endian
>& ,
3680 unsigned int r_type
,
3683 // GOT is not a function.
3684 if (strcmp(gsym
->name(), "_GLOBAL_OFFSET_TABLE_") == 0)
3687 // When building a shared library, do not fold symbols whose visibility
3688 // is hidden, internal or protected.
3689 return ((parameters
->options().shared()
3690 && (gsym
->visibility() == elfcpp::STV_INTERNAL
3691 || gsym
->visibility() == elfcpp::STV_PROTECTED
3692 || gsym
->visibility() == elfcpp::STV_HIDDEN
))
3693 || possible_function_pointer_reloc(r_type
));
3696 // Scan a relocation for a global symbol.
3698 template<int size
, bool big_endian
>
3700 Target_tilegx
<size
, big_endian
>::Scan::global(Symbol_table
* symtab
,
3702 Target_tilegx
<size
, big_endian
>* target
,
3703 Sized_relobj_file
<size
, big_endian
>* object
,
3704 unsigned int data_shndx
,
3705 Output_section
* output_section
,
3706 const elfcpp::Rela
<size
, big_endian
>& reloc
,
3707 unsigned int r_type
,
3710 // A reference to _GLOBAL_OFFSET_TABLE_ implies that we need a got
3711 // section. We check here to avoid creating a dynamic reloc against
3712 // _GLOBAL_OFFSET_TABLE_.
3713 if (!target
->has_got_section()
3714 && strcmp(gsym
->name(), "_GLOBAL_OFFSET_TABLE_") == 0)
3715 target
->got_section(symtab
, layout
);
3717 // A STT_GNU_IFUNC symbol may require a PLT entry.
3718 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
3719 && this->reloc_needs_plt_for_ifunc(object
, r_type
))
3720 target
->make_plt_entry(symtab
, layout
, gsym
);
3724 case elfcpp::R_TILEGX_NONE
:
3725 case elfcpp::R_TILEGX_GNU_VTINHERIT
:
3726 case elfcpp::R_TILEGX_GNU_VTENTRY
:
3729 case elfcpp::R_TILEGX_DEST_IMM8_X1
:
3730 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
3731 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
3732 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
3733 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
3734 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
3735 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
3736 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
3737 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
3738 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
3739 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
3740 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
3741 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
3742 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
3743 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
3744 case elfcpp::R_TILEGX_64
:
3745 case elfcpp::R_TILEGX_32
:
3746 case elfcpp::R_TILEGX_16
:
3747 case elfcpp::R_TILEGX_8
:
3749 // Make a PLT entry if necessary.
3750 if (gsym
->needs_plt_entry())
3752 target
->make_plt_entry(symtab
, layout
, gsym
);
3753 // Since this is not a PC-relative relocation, we may be
3754 // taking the address of a function. In that case we need to
3755 // set the entry in the dynamic symbol table to the address of
3757 if (gsym
->is_from_dynobj() && !parameters
->options().shared())
3758 gsym
->set_needs_dynsym_value();
3760 // Make a dynamic relocation if necessary.
3761 if (gsym
->needs_dynamic_reloc(Scan::get_reference_flags(r_type
)))
3763 if (gsym
->may_need_copy_reloc())
3765 target
->copy_reloc(symtab
, layout
, object
,
3766 data_shndx
, output_section
, gsym
, reloc
);
3768 else if (((size
== 64 && r_type
== elfcpp::R_TILEGX_64
)
3769 || (size
== 32 && r_type
== elfcpp::R_TILEGX_32
))
3770 && gsym
->type() == elfcpp::STT_GNU_IFUNC
3771 && gsym
->can_use_relative_reloc(false)
3772 && !gsym
->is_from_dynobj()
3773 && !gsym
->is_undefined()
3774 && !gsym
->is_preemptible())
3776 // Use an IRELATIVE reloc for a locally defined
3777 // STT_GNU_IFUNC symbol. This makes a function
3778 // address in a PIE executable match the address in a
3779 // shared library that it links against.
3780 Reloc_section
* rela_dyn
=
3781 target
->rela_irelative_section(layout
);
3782 unsigned int r_type
= elfcpp::R_TILEGX_IRELATIVE
;
3783 rela_dyn
->add_symbolless_global_addend(gsym
, r_type
,
3784 output_section
, object
,
3786 reloc
.get_r_offset(),
3787 reloc
.get_r_addend());
3788 } else if ((r_type
== elfcpp::R_TILEGX_64
3789 || r_type
== elfcpp::R_TILEGX_32
)
3790 && gsym
->can_use_relative_reloc(false))
3792 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3793 rela_dyn
->add_global_relative(gsym
, elfcpp::R_TILEGX_RELATIVE
,
3794 output_section
, object
,
3796 reloc
.get_r_offset(),
3797 reloc
.get_r_addend(), false);
3801 this->check_non_pic(object
, r_type
);
3802 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3803 rela_dyn
->add_global(gsym
, r_type
, output_section
, object
,
3804 data_shndx
, reloc
.get_r_offset(),
3805 reloc
.get_r_addend());
3811 case elfcpp::R_TILEGX_BROFF_X1
:
3812 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
3813 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
3814 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
3815 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
3816 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
3817 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
3818 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
3819 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
3820 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
3821 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
3822 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
3823 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
3824 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
3825 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
3826 case elfcpp::R_TILEGX_64_PCREL
:
3827 case elfcpp::R_TILEGX_32_PCREL
:
3828 case elfcpp::R_TILEGX_16_PCREL
:
3829 case elfcpp::R_TILEGX_8_PCREL
:
3831 // Make a PLT entry if necessary.
3832 if (gsym
->needs_plt_entry())
3833 target
->make_plt_entry(symtab
, layout
, gsym
);
3834 // Make a dynamic relocation if necessary.
3835 if (gsym
->needs_dynamic_reloc(Scan::get_reference_flags(r_type
)))
3837 if (gsym
->may_need_copy_reloc())
3839 target
->copy_reloc(symtab
, layout
, object
,
3840 data_shndx
, output_section
, gsym
, reloc
);
3844 this->check_non_pic(object
, r_type
);
3845 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3846 rela_dyn
->add_global(gsym
, r_type
, output_section
, object
,
3847 data_shndx
, reloc
.get_r_offset(),
3848 reloc
.get_r_addend());
3854 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
3855 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
3856 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
3857 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
3858 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
3859 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
3861 // The symbol requires a GOT entry.
3862 Output_data_got
<size
, big_endian
>* got
3863 = target
->got_section(symtab
, layout
);
3864 if (gsym
->final_value_is_known())
3866 // For a STT_GNU_IFUNC symbol we want the PLT address.
3867 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
)
3868 got
->add_global_plt(gsym
, GOT_TYPE_STANDARD
);
3870 got
->add_global(gsym
, GOT_TYPE_STANDARD
);
3874 // If this symbol is not fully resolved, we need to add a
3875 // dynamic relocation for it.
3876 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
3878 // Use a GLOB_DAT rather than a RELATIVE reloc if:
3880 // 1) The symbol may be defined in some other module.
3882 // 2) We are building a shared library and this is a
3883 // protected symbol; using GLOB_DAT means that the dynamic
3884 // linker can use the address of the PLT in the main
3885 // executable when appropriate so that function address
3886 // comparisons work.
3888 // 3) This is a STT_GNU_IFUNC symbol in position dependent
3889 // code, again so that function address comparisons work.
3890 if (gsym
->is_from_dynobj()
3891 || gsym
->is_undefined()
3892 || gsym
->is_preemptible()
3893 || (gsym
->visibility() == elfcpp::STV_PROTECTED
3894 && parameters
->options().shared())
3895 || (gsym
->type() == elfcpp::STT_GNU_IFUNC
3896 && parameters
->options().output_is_position_independent()))
3897 got
->add_global_with_rel(gsym
, GOT_TYPE_STANDARD
, rela_dyn
,
3898 elfcpp::R_TILEGX_GLOB_DAT
);
3901 // For a STT_GNU_IFUNC symbol we want to write the PLT
3902 // offset into the GOT, so that function pointer
3903 // comparisons work correctly.
3905 if (gsym
->type() != elfcpp::STT_GNU_IFUNC
)
3906 is_new
= got
->add_global(gsym
, GOT_TYPE_STANDARD
);
3909 is_new
= got
->add_global_plt(gsym
, GOT_TYPE_STANDARD
);
3910 // Tell the dynamic linker to use the PLT address
3911 // when resolving relocations.
3912 if (gsym
->is_from_dynobj()
3913 && !parameters
->options().shared())
3914 gsym
->set_needs_dynsym_value();
3918 unsigned int got_off
= gsym
->got_offset(GOT_TYPE_STANDARD
);
3919 rela_dyn
->add_global_relative(gsym
,
3921 got
, got_off
, 0, false);
3928 // a minor difference here for R_TILEGX_JUMPOFF_X1
3929 // between bfd linker and gold linker for gold, when
3930 // R_TILEGX_JUMPOFF_X1 against global symbol, we
3931 // turn it into JUMPOFF_X1_PLT, otherwise the distance
3932 // to the symbol function may overflow at runtime.
3933 case elfcpp::R_TILEGX_JUMPOFF_X1
:
3935 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT
:
3936 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL
:
3937 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL
:
3938 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL
:
3939 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL
:
3940 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL
:
3941 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL
:
3942 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
:
3943 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
:
3944 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
:
3945 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
:
3946 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
:
3947 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
:
3948 // If the symbol is fully resolved, this is just a PC32 reloc.
3949 // Otherwise we need a PLT entry.
3950 if (gsym
->final_value_is_known())
3952 // If building a shared library, we can also skip the PLT entry
3953 // if the symbol is defined in the output file and is protected
3955 if (gsym
->is_defined()
3956 && !gsym
->is_from_dynobj()
3957 && !gsym
->is_preemptible())
3959 target
->make_plt_entry(symtab
, layout
, gsym
);
3963 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
3964 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
3965 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
3966 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
3967 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
3968 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
3969 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
3970 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
3971 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
3972 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
3973 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
3974 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
3975 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
3976 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
3977 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
3978 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
3979 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
3980 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
3981 case elfcpp::R_TILEGX_TLS_GD_CALL
:
3982 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
3983 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
3984 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
3985 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
3986 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
3987 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
3988 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
3989 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
3990 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
3992 const bool is_final
= gsym
->final_value_is_known();
3993 const tls::Tls_optimization opt_t
=
3994 Target_tilegx
<size
, big_endian
>::optimize_tls_reloc(is_final
,
3999 // only expand to plt against __tls_get_addr in GD model
4000 case elfcpp::R_TILEGX_TLS_GD_CALL
:
4001 if (opt_t
== tls::TLSOPT_NONE
) {
4002 // FIXME: it's better '__tls_get_addr' referenced explictly
4003 if (!target
->tls_get_addr_sym_defined_
) {
4005 options::parse_set(NULL
, "__tls_get_addr",
4006 (gold::options::String_set
*)
4007 ¶meters
->options().undefined());
4008 symtab
->add_undefined_symbols_from_command_line(layout
);
4009 target
->tls_get_addr_sym_defined_
= true;
4010 sym
= symtab
->lookup("__tls_get_addr");
4013 target
->make_plt_entry(symtab
, layout
,
4014 symtab
->lookup("__tls_get_addr"));
4018 // only make effect when applying relocation
4019 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
4020 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
4021 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
4022 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
4023 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
4024 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
4025 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
4026 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
4027 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
4030 // GD: requires two GOT entry for module index and offset
4031 // IE: requires one GOT entry for tp-relative offset
4032 // LE: shouldn't happen for global symbol
4033 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
4034 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
4035 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
4036 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
4037 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
4038 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
4040 if (opt_t
== tls::TLSOPT_NONE
) {
4041 Output_data_got
<size
, big_endian
>* got
4042 = target
->got_section(symtab
, layout
);
4043 got
->add_global_pair_with_rel(gsym
, GOT_TYPE_TLS_PAIR
,
4044 target
->rela_dyn_section(layout
),
4046 ? elfcpp::R_TILEGX_TLS_DTPMOD32
4047 : elfcpp::R_TILEGX_TLS_DTPMOD64
,
4049 ? elfcpp::R_TILEGX_TLS_DTPOFF32
4050 : elfcpp::R_TILEGX_TLS_DTPOFF64
);
4051 } else if (opt_t
== tls::TLSOPT_TO_IE
) {
4052 // Create a GOT entry for the tp-relative offset.
4053 Output_data_got
<size
, big_endian
>* got
4054 = target
->got_section(symtab
, layout
);
4055 got
->add_global_with_rel(gsym
, GOT_TYPE_TLS_OFFSET
,
4056 target
->rela_dyn_section(layout
),
4058 ? elfcpp::R_TILEGX_TLS_TPOFF32
4059 : elfcpp::R_TILEGX_TLS_TPOFF64
);
4060 } else if (opt_t
!= tls::TLSOPT_TO_LE
)
4061 // exteranl symbol should not be optimized to TO_LE
4062 unsupported_reloc_global(object
, r_type
, gsym
);
4067 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
4068 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
4069 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
4070 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
4071 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
4072 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
4074 layout
->set_has_static_tls();
4075 if (opt_t
== tls::TLSOPT_NONE
) {
4076 // Create a GOT entry for the tp-relative offset.
4077 Output_data_got
<size
, big_endian
>* got
4078 = target
->got_section(symtab
, layout
);
4079 got
->add_global_with_rel(gsym
, GOT_TYPE_TLS_OFFSET
,
4080 target
->rela_dyn_section(layout
),
4082 ? elfcpp::R_TILEGX_TLS_TPOFF32
4083 : elfcpp::R_TILEGX_TLS_TPOFF64
);
4084 } else if (opt_t
!= tls::TLSOPT_TO_LE
)
4085 unsupported_reloc_global(object
, r_type
, gsym
);
4090 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
4091 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
4092 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
4093 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
4094 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
4095 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
4096 layout
->set_has_static_tls();
4097 if (parameters
->options().shared()) {
4098 // defer to dynamic linker
4099 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
4100 rela_dyn
->add_symbolless_global_addend(gsym
, r_type
,
4101 output_section
, object
,
4103 reloc
.get_r_offset(), 0);
4113 // below are outstanding relocs
4114 // should not existed in static linking stage
4115 case elfcpp::R_TILEGX_COPY
:
4116 case elfcpp::R_TILEGX_GLOB_DAT
:
4117 case elfcpp::R_TILEGX_JMP_SLOT
:
4118 case elfcpp::R_TILEGX_RELATIVE
:
4119 case elfcpp::R_TILEGX_TLS_TPOFF32
:
4120 case elfcpp::R_TILEGX_TLS_TPOFF64
:
4121 case elfcpp::R_TILEGX_TLS_DTPMOD32
:
4122 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
4123 case elfcpp::R_TILEGX_TLS_DTPOFF32
:
4124 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
4125 gold_error(_("%s: unexpected reloc %u in object file"),
4126 object
->name().c_str(), r_type
);
4130 gold_error(_("%s: unsupported reloc %u against global symbol %s"),
4131 object
->name().c_str(), r_type
,
4132 gsym
->demangled_name().c_str());
4137 template<int size
, bool big_endian
>
4139 Target_tilegx
<size
, big_endian
>::gc_process_relocs(Symbol_table
* symtab
,
4141 Sized_relobj_file
<size
, big_endian
>* object
,
4142 unsigned int data_shndx
,
4143 unsigned int sh_type
,
4144 const unsigned char* prelocs
,
4146 Output_section
* output_section
,
4147 bool needs_special_offset_handling
,
4148 size_t local_symbol_count
,
4149 const unsigned char* plocal_symbols
)
4151 typedef Target_tilegx
<size
, big_endian
> Tilegx
;
4152 typedef typename Target_tilegx
<size
, big_endian
>::Scan Scan
;
4154 if (sh_type
== elfcpp::SHT_REL
)
4159 gold::gc_process_relocs
<size
, big_endian
,
4160 Tilegx
, elfcpp::SHT_RELA
, Scan
,
4161 typename Target_tilegx
<size
, big_endian
>::Relocatable_size_for_reloc
>(
4170 needs_special_offset_handling
,
4174 // Scan relocations for a section.
4176 template<int size
, bool big_endian
>
4178 Target_tilegx
<size
, big_endian
>::scan_relocs(Symbol_table
* symtab
,
4180 Sized_relobj_file
<size
, big_endian
>* object
,
4181 unsigned int data_shndx
,
4182 unsigned int sh_type
,
4183 const unsigned char* prelocs
,
4185 Output_section
* output_section
,
4186 bool needs_special_offset_handling
,
4187 size_t local_symbol_count
,
4188 const unsigned char* plocal_symbols
)
4190 typedef Target_tilegx
<size
, big_endian
> Tilegx
;
4191 typedef typename Target_tilegx
<size
, big_endian
>::Scan Scan
;
4193 if (sh_type
== elfcpp::SHT_REL
)
4195 gold_error(_("%s: unsupported REL reloc section"),
4196 object
->name().c_str());
4200 gold::scan_relocs
<size
, big_endian
, Tilegx
, elfcpp::SHT_RELA
, Scan
>(
4209 needs_special_offset_handling
,
4214 template<int size
, bool big_endian
>
4216 Target_tilegx
<size
, big_endian
>::do_define_standard_symbols(
4217 Symbol_table
* symtab
,
4220 Output_section
* feedback_section
= layout
->find_output_section(".feedback");
4222 if (feedback_section
!= NULL
)
4224 symtab
->define_in_output_data("__feedback_section_end",
4226 Symbol_table::PREDEFINED
,
4234 true, // offset_is_from_end
4239 // Finalize the sections.
4241 template<int size
, bool big_endian
>
4243 Target_tilegx
<size
, big_endian
>::do_finalize_sections(
4245 const Input_objects
*,
4246 Symbol_table
* symtab
)
4248 const Reloc_section
* rel_plt
= (this->plt_
== NULL
4250 : this->plt_
->rela_plt());
4251 layout
->add_target_dynamic_tags(false, this->got_plt_
, rel_plt
,
4252 this->rela_dyn_
, true, true);
4254 // Emit any relocs we saved in an attempt to avoid generating COPY
4256 if (this->copy_relocs_
.any_saved_relocs())
4257 this->copy_relocs_
.emit(this->rela_dyn_section(layout
));
4259 // Set the size of the _GLOBAL_OFFSET_TABLE_ symbol to the size of
4260 // the .got section.
4261 Symbol
* sym
= this->global_offset_table_
;
4264 uint64_t data_size
= this->got_
->current_data_size();
4265 symtab
->get_sized_symbol
<size
>(sym
)->set_symsize(data_size
);
4267 // If the .got section is more than 0x8000 bytes, we add
4268 // 0x8000 to the value of _GLOBAL_OFFSET_TABLE_, so that 16
4269 // bit relocations have a greater chance of working.
4270 if (data_size
>= 0x8000)
4271 symtab
->get_sized_symbol
<size
>(sym
)->set_value(
4272 symtab
->get_sized_symbol
<size
>(sym
)->value() + 0x8000);
4275 if (parameters
->doing_static_link()
4276 && (this->plt_
== NULL
|| !this->plt_
->has_irelative_section()))
4278 // If linking statically, make sure that the __rela_iplt symbols
4279 // were defined if necessary, even if we didn't create a PLT.
4280 static const Define_symbol_in_segment syms
[] =
4283 "__rela_iplt_start", // name
4284 elfcpp::PT_LOAD
, // segment_type
4285 elfcpp::PF_W
, // segment_flags_set
4286 elfcpp::PF(0), // segment_flags_clear
4289 elfcpp::STT_NOTYPE
, // type
4290 elfcpp::STB_GLOBAL
, // binding
4291 elfcpp::STV_HIDDEN
, // visibility
4293 Symbol::SEGMENT_START
, // offset_from_base
4297 "__rela_iplt_end", // name
4298 elfcpp::PT_LOAD
, // segment_type
4299 elfcpp::PF_W
, // segment_flags_set
4300 elfcpp::PF(0), // segment_flags_clear
4303 elfcpp::STT_NOTYPE
, // type
4304 elfcpp::STB_GLOBAL
, // binding
4305 elfcpp::STV_HIDDEN
, // visibility
4307 Symbol::SEGMENT_START
, // offset_from_base
4312 symtab
->define_symbols(layout
, 2, syms
,
4313 layout
->script_options()->saw_sections_clause());
4317 // Perform a relocation.
4319 template<int size
, bool big_endian
>
4321 Target_tilegx
<size
, big_endian
>::Relocate::relocate(
4322 const Relocate_info
<size
, big_endian
>* relinfo
,
4323 Target_tilegx
<size
, big_endian
>* target
,
4326 const elfcpp::Rela
<size
, big_endian
>& rela
,
4327 unsigned int r_type
,
4328 const Sized_symbol
<size
>* gsym
,
4329 const Symbol_value
<size
>* psymval
,
4330 unsigned char* view
,
4331 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
4337 typedef Tilegx_relocate_functions
<size
, big_endian
> TilegxReloc
;
4338 typename
TilegxReloc::Tilegx_howto r_howto
;
4340 const Sized_relobj_file
<size
, big_endian
>* object
= relinfo
->object
;
4342 // Pick the value to use for symbols defined in the PLT.
4343 Symbol_value
<size
> symval
;
4345 && gsym
->use_plt_offset(Scan::get_reference_flags(r_type
)))
4347 symval
.set_output_value(target
->plt_address_for_global(gsym
));
4350 else if (gsym
== NULL
&& psymval
->is_ifunc_symbol())
4352 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
4353 if (object
->local_has_plt_offset(r_sym
))
4355 symval
.set_output_value(target
->plt_address_for_local(object
, r_sym
));
4360 elfcpp::Elf_Xword addend
= rela
.get_r_addend();
4362 // Get the GOT offset if needed.
4363 // For tilegx, the GOT pointer points to the start of the GOT section.
4364 bool have_got_offset
= false;
4366 int got_base
= target
->got_
!= NULL
4367 ? target
->got_
->current_data_size() >= 0x8000 ? 0x8000 : 0
4369 unsigned int got_type
= GOT_TYPE_STANDARD
;
4370 bool always_apply_relocation
= false;
4373 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
4374 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
4375 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
4376 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
4377 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
4378 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
4381 gold_assert(gsym
->has_got_offset(got_type
));
4382 got_offset
= gsym
->got_offset(got_type
) - got_base
;
4386 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
4387 gold_assert(object
->local_has_got_offset(r_sym
, got_type
));
4389 object
->local_got_offset(r_sym
, got_type
) - got_base
;
4391 have_got_offset
= true;
4398 r_howto
= TilegxReloc::howto
[r_type
];
4401 case elfcpp::R_TILEGX_NONE
:
4402 case elfcpp::R_TILEGX_GNU_VTINHERIT
:
4403 case elfcpp::R_TILEGX_GNU_VTENTRY
:
4406 case elfcpp::R_TILEGX_IMM16_X0_HW0_GOT
:
4407 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_GOT
:
4408 case elfcpp::R_TILEGX_IMM16_X1_HW0_GOT
:
4409 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_GOT
:
4410 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_GOT
:
4411 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_GOT
:
4412 gold_assert(have_got_offset
);
4413 symval
.set_output_value(got_offset
);
4415 always_apply_relocation
= true;
4418 // when under PIC mode, these relocations are deferred to rtld
4419 case elfcpp::R_TILEGX_IMM16_X0_HW0
:
4420 case elfcpp::R_TILEGX_IMM16_X1_HW0
:
4421 case elfcpp::R_TILEGX_IMM16_X0_HW1
:
4422 case elfcpp::R_TILEGX_IMM16_X1_HW1
:
4423 case elfcpp::R_TILEGX_IMM16_X0_HW2
:
4424 case elfcpp::R_TILEGX_IMM16_X1_HW2
:
4425 case elfcpp::R_TILEGX_IMM16_X0_HW3
:
4426 case elfcpp::R_TILEGX_IMM16_X1_HW3
:
4427 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST
:
4428 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST
:
4429 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST
:
4430 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST
:
4431 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST
:
4432 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST
:
4433 if (always_apply_relocation
4434 || !parameters
->options().output_is_position_independent())
4435 TilegxReloc::imm_x_general(view
, object
, psymval
, addend
, r_howto
);
4438 case elfcpp::R_TILEGX_JUMPOFF_X1
:
4439 case elfcpp::R_TILEGX_JUMPOFF_X1_PLT
:
4440 gold_assert(gsym
== NULL
4441 || gsym
->has_plt_offset()
4442 || gsym
->final_value_is_known()
4443 || (gsym
->is_defined()
4444 && !gsym
->is_from_dynobj()
4445 && !gsym
->is_preemptible()));
4446 TilegxReloc::imm_x_pcrel_general(view
, object
, psymval
, addend
,
4451 case elfcpp::R_TILEGX_IMM16_X0_HW0_PLT_PCREL
:
4452 case elfcpp::R_TILEGX_IMM16_X0_HW0_PCREL
:
4453 case elfcpp::R_TILEGX_IMM16_X1_HW0_PLT_PCREL
:
4454 case elfcpp::R_TILEGX_IMM16_X1_HW0_PCREL
:
4455 case elfcpp::R_TILEGX_IMM16_X0_HW1_PLT_PCREL
:
4456 case elfcpp::R_TILEGX_IMM16_X0_HW1_PCREL
:
4457 case elfcpp::R_TILEGX_IMM16_X1_HW1_PLT_PCREL
:
4458 case elfcpp::R_TILEGX_IMM16_X1_HW1_PCREL
:
4459 case elfcpp::R_TILEGX_IMM16_X0_HW2_PLT_PCREL
:
4460 case elfcpp::R_TILEGX_IMM16_X0_HW2_PCREL
:
4461 case elfcpp::R_TILEGX_IMM16_X1_HW2_PLT_PCREL
:
4462 case elfcpp::R_TILEGX_IMM16_X1_HW2_PCREL
:
4463 case elfcpp::R_TILEGX_IMM16_X0_HW3_PCREL
:
4464 case elfcpp::R_TILEGX_IMM16_X1_HW3_PCREL
:
4465 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
:
4466 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_PCREL
:
4467 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
:
4468 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_PCREL
:
4469 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
:
4470 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_PCREL
:
4471 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
:
4472 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_PCREL
:
4473 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
:
4474 case elfcpp::R_TILEGX_IMM16_X0_HW2_LAST_PCREL
:
4475 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
:
4476 case elfcpp::R_TILEGX_IMM16_X1_HW2_LAST_PCREL
:
4477 TilegxReloc::imm_x_pcrel_general(view
, object
, psymval
, addend
,
4481 case elfcpp::R_TILEGX_BROFF_X1
:
4482 case elfcpp::R_TILEGX_DEST_IMM8_X1
:
4483 TilegxReloc::imm_x_two_part_general(view
, object
, psymval
,
4484 addend
, address
, r_type
);
4488 // below are general relocation types, which can be
4489 // handled by target-independent handlers
4490 case elfcpp::R_TILEGX_64
:
4491 TilegxReloc::abs64(view
, object
, psymval
, addend
);
4494 case elfcpp::R_TILEGX_64_PCREL
:
4495 TilegxReloc::pc_abs64(view
, object
, psymval
, addend
, address
);
4498 case elfcpp::R_TILEGX_32
:
4499 TilegxReloc::abs32(view
, object
, psymval
, addend
);
4502 case elfcpp::R_TILEGX_32_PCREL
:
4503 TilegxReloc::pc_abs32(view
, object
, psymval
, addend
, address
);
4506 case elfcpp::R_TILEGX_16
:
4507 TilegxReloc::abs16(view
, object
, psymval
, addend
);
4510 case elfcpp::R_TILEGX_16_PCREL
:
4511 TilegxReloc::pc_abs16(view
, object
, psymval
, addend
, address
);
4514 case elfcpp::R_TILEGX_8
:
4515 Relocate_functions
<size
, big_endian
>::rela8(view
, object
,
4519 case elfcpp::R_TILEGX_8_PCREL
:
4520 Relocate_functions
<size
, big_endian
>::pcrela8(view
, object
,
4521 psymval
, addend
, address
);
4524 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
4525 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
4526 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
4527 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
4528 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
4529 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
4530 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
4531 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
4532 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
4533 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
4534 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
4535 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
4536 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
4537 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
4538 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
4539 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
4540 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
4541 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
4542 case elfcpp::R_TILEGX_TLS_GD_CALL
:
4543 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
4544 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
4545 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
4546 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
4547 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
4548 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
4549 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
4550 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
4551 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
4553 const bool is_final
= (gsym
== NULL
4554 ? !parameters
->options().shared()
4555 : gsym
->final_value_is_known());
4556 tls::Tls_optimization opt_t
=
4557 Target_tilegx
<size
, big_endian
>::optimize_tls_reloc(is_final
,
4563 case elfcpp::R_TILEGX_TLS_GD_CALL
:
4565 if (opt_t
== tls::TLSOPT_NONE
) {
4566 Symbol
*tls_sym
= relinfo
->symtab
->lookup("__tls_get_addr");
4567 symval
.set_output_value(
4568 target
->plt_address_for_global(tls_sym
));
4570 TilegxReloc::imm_x_pcrel_general(view
, object
, psymval
,
4571 addend
, address
, r_howto
);
4573 else if (opt_t
== tls::TLSOPT_TO_IE
4574 || opt_t
== tls::TLSOPT_TO_LE
)
4575 TilegxReloc::tls_relax(view
, r_type
, opt_t
);
4579 // XX_TLS_GD is the same as normal X_GOT relocation
4580 // except allocating a got entry pair,
4581 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_GD
:
4582 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_GD
:
4583 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
:
4584 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
:
4585 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
:
4586 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
:
4587 if (opt_t
== tls::TLSOPT_NONE
) {
4588 got_type
= GOT_TYPE_TLS_PAIR
;
4589 have_got_offset
= true;
4590 } else if (opt_t
== tls::TLSOPT_TO_IE
) {
4591 got_type
= GOT_TYPE_TLS_OFFSET
;
4592 have_got_offset
= true;
4594 goto do_update_value
;
4595 // XX_TLS_IE is the same as normal X_GOT relocation
4596 // except allocating one additional runtime relocation
4597 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_IE
:
4598 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_IE
:
4599 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
:
4600 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
:
4601 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
:
4602 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
:
4603 if (opt_t
== tls::TLSOPT_NONE
) {
4604 got_type
= GOT_TYPE_TLS_OFFSET
;
4605 have_got_offset
= true;
4608 if (have_got_offset
) {
4610 gold_assert(gsym
->has_got_offset(got_type
));
4611 got_offset
= gsym
->got_offset(got_type
) - got_base
;
4614 = elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
4615 gold_assert(object
->local_has_got_offset(r_sym
, got_type
));
4617 object
->local_got_offset(r_sym
, got_type
) - got_base
;
4621 if (opt_t
== tls::TLSOPT_NONE
4622 || opt_t
== tls::TLSOPT_TO_IE
) {
4623 // for both GD/IE, these relocations
4624 // actually calculate got offset, so
4625 // there behavior are the same
4626 gold_assert(have_got_offset
);
4627 symval
.set_output_value(got_offset
);
4630 TilegxReloc::imm_x_general(view
, object
, psymval
,
4633 } // else if (opt_t == tls::TLSOPT_TO_LE)
4634 // both GD/IE are turned into LE, which
4635 // is absolute relocation.
4645 // t_var1 | t_var2 | t_var3 | ...
4646 // --------------------------------------------------
4648 // so offset to tp should be negative, we get offset
4649 // from the following formular for LE
4651 // t_var1_off = t_var1_sym_value - tls_section_start
4653 case elfcpp::R_TILEGX_IMM16_X0_HW0_TLS_LE
:
4654 case elfcpp::R_TILEGX_IMM16_X1_HW0_TLS_LE
:
4655 case elfcpp::R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
:
4656 case elfcpp::R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
:
4657 case elfcpp::R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
:
4658 case elfcpp::R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
:
4660 Output_segment
*tls_segment
= relinfo
->layout
->tls_segment();
4661 if (tls_segment
== NULL
) {
4662 gold_assert(parameters
->errors()->error_count() > 0
4663 || issue_undefined_symbol_error(gsym
));
4667 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
4668 = psymval
->value(relinfo
->object
, 0);
4669 symval
.set_output_value(value
);
4671 TilegxReloc::imm_x_general(view
, object
, psymval
,
4677 case elfcpp::R_TILEGX_TLS_IE_LOAD
:
4678 case elfcpp::R_TILEGX_IMM8_X0_TLS_ADD
:
4679 case elfcpp::R_TILEGX_IMM8_X1_TLS_ADD
:
4680 case elfcpp::R_TILEGX_IMM8_Y0_TLS_ADD
:
4681 case elfcpp::R_TILEGX_IMM8_Y1_TLS_ADD
:
4682 case elfcpp::R_TILEGX_IMM8_X0_TLS_GD_ADD
:
4683 case elfcpp::R_TILEGX_IMM8_X1_TLS_GD_ADD
:
4684 case elfcpp::R_TILEGX_IMM8_Y0_TLS_GD_ADD
:
4685 case elfcpp::R_TILEGX_IMM8_Y1_TLS_GD_ADD
:
4686 TilegxReloc::tls_relax(view
, r_type
, opt_t
);
4695 // below are outstanding relocs
4696 // should not existed in static linking stage
4697 case elfcpp::R_TILEGX_COPY
:
4698 case elfcpp::R_TILEGX_GLOB_DAT
:
4699 case elfcpp::R_TILEGX_JMP_SLOT
:
4700 case elfcpp::R_TILEGX_RELATIVE
:
4701 case elfcpp::R_TILEGX_TLS_TPOFF32
:
4702 case elfcpp::R_TILEGX_TLS_TPOFF64
:
4703 case elfcpp::R_TILEGX_TLS_DTPMOD32
:
4704 case elfcpp::R_TILEGX_TLS_DTPMOD64
:
4705 case elfcpp::R_TILEGX_TLS_DTPOFF32
:
4706 case elfcpp::R_TILEGX_TLS_DTPOFF64
:
4707 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
4708 _("unexpected reloc %u in object file"),
4713 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
4714 _("unsupported reloc %u"),
4722 // Relocate section data.
4724 template<int size
, bool big_endian
>
4726 Target_tilegx
<size
, big_endian
>::relocate_section(
4727 const Relocate_info
<size
, big_endian
>* relinfo
,
4728 unsigned int sh_type
,
4729 const unsigned char* prelocs
,
4731 Output_section
* output_section
,
4732 bool needs_special_offset_handling
,
4733 unsigned char* view
,
4734 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
4735 section_size_type view_size
,
4736 const Reloc_symbol_changes
* reloc_symbol_changes
)
4738 typedef Target_tilegx
<size
, big_endian
> Tilegx
;
4739 typedef typename Target_tilegx
<size
, big_endian
>::Relocate Tilegx_relocate
;
4741 gold_assert(sh_type
== elfcpp::SHT_RELA
);
4743 gold::relocate_section
<size
, big_endian
, Tilegx
, elfcpp::SHT_RELA
,
4744 Tilegx_relocate
, gold::Default_comdat_behavior
>(
4750 needs_special_offset_handling
,
4754 reloc_symbol_changes
);
4757 // Apply an incremental relocation. Incremental relocations always refer
4758 // to global symbols.
4760 template<int size
, bool big_endian
>
4762 Target_tilegx
<size
, big_endian
>::apply_relocation(
4763 const Relocate_info
<size
, big_endian
>* relinfo
,
4764 typename
elfcpp::Elf_types
<size
>::Elf_Addr r_offset
,
4765 unsigned int r_type
,
4766 typename
elfcpp::Elf_types
<size
>::Elf_Swxword r_addend
,
4768 unsigned char* view
,
4769 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
4770 section_size_type view_size
)
4772 gold::apply_relocation
<size
, big_endian
, Target_tilegx
<size
, big_endian
>,
4773 typename Target_tilegx
<size
, big_endian
>::Relocate
>(
4785 // Return the size of a relocation while scanning during a relocatable
4788 template<int size
, bool big_endian
>
4790 Target_tilegx
<size
,big_endian
>::Relocatable_size_for_reloc::get_size_for_reloc(
4791 unsigned int, Relobj
*)
4793 // We are always SHT_RELA, so we should never get here.
4798 // Scan the relocs during a relocatable link.
4800 template<int size
, bool big_endian
>
4802 Target_tilegx
<size
, big_endian
>::scan_relocatable_relocs(
4803 Symbol_table
* symtab
,
4805 Sized_relobj_file
<size
, big_endian
>* object
,
4806 unsigned int data_shndx
,
4807 unsigned int sh_type
,
4808 const unsigned char* prelocs
,
4810 Output_section
* output_section
,
4811 bool needs_special_offset_handling
,
4812 size_t local_symbol_count
,
4813 const unsigned char* plocal_symbols
,
4814 Relocatable_relocs
* rr
)
4816 gold_assert(sh_type
== elfcpp::SHT_RELA
);
4818 typedef gold::Default_scan_relocatable_relocs
<elfcpp::SHT_RELA
,
4819 Relocatable_size_for_reloc
> Scan_relocatable_relocs
;
4821 gold::scan_relocatable_relocs
<size
, big_endian
, elfcpp::SHT_RELA
,
4822 Scan_relocatable_relocs
>(
4830 needs_special_offset_handling
,
4836 // Relocate a section during a relocatable link.
4838 template<int size
, bool big_endian
>
4840 Target_tilegx
<size
, big_endian
>::relocate_relocs(
4841 const Relocate_info
<size
, big_endian
>* relinfo
,
4842 unsigned int sh_type
,
4843 const unsigned char* prelocs
,
4845 Output_section
* output_section
,
4846 typename
elfcpp::Elf_types
<size
>::Elf_Off offset_in_output_section
,
4847 const Relocatable_relocs
* rr
,
4848 unsigned char* view
,
4849 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
4850 section_size_type view_size
,
4851 unsigned char* reloc_view
,
4852 section_size_type reloc_view_size
)
4854 gold_assert(sh_type
== elfcpp::SHT_RELA
);
4856 gold::relocate_relocs
<size
, big_endian
, elfcpp::SHT_RELA
>(
4861 offset_in_output_section
,
4870 // Return the value to use for a dynamic which requires special
4871 // treatment. This is how we support equality comparisons of function
4872 // pointers across shared library boundaries, as described in the
4873 // processor specific ABI supplement.
4875 template<int size
, bool big_endian
>
4877 Target_tilegx
<size
, big_endian
>::do_dynsym_value(const Symbol
* gsym
) const
4879 gold_assert(gsym
->is_from_dynobj() && gsym
->has_plt_offset());
4880 return this->plt_address_for_global(gsym
);
4883 // Return the value to use for the base of a DW_EH_PE_datarel offset
4884 // in an FDE. Solaris and SVR4 use DW_EH_PE_datarel because their
4885 // assembler can not write out the difference between two labels in
4886 // different sections, so instead of using a pc-relative value they
4887 // use an offset from the GOT.
4889 template<int size
, bool big_endian
>
4891 Target_tilegx
<size
, big_endian
>::do_ehframe_datarel_base() const
4893 gold_assert(this->global_offset_table_
!= NULL
);
4894 Symbol
* sym
= this->global_offset_table_
;
4895 Sized_symbol
<size
>* ssym
= static_cast<Sized_symbol
<size
>*>(sym
);
4896 return ssym
->value();
4899 // The selector for tilegx object files.
4901 template<int size
, bool big_endian
>
4902 class Target_selector_tilegx
: public Target_selector
4905 Target_selector_tilegx()
4906 : Target_selector(elfcpp::EM_TILEGX
, size
, big_endian
,
4908 ? (big_endian
? "elf64-tilegx-be" : "elf64-tilegx-le")
4909 : (big_endian
? "elf32-tilegx-be"
4910 : "elf32-tilegx-le")),
4912 ? (big_endian
? "elf64tilegx_be" : "elf64tilegx")
4913 : (big_endian
? "elf32tilegx_be" : "elf32tilegx")))
4917 do_instantiate_target()
4918 { return new Target_tilegx
<size
, big_endian
>(); }
4922 Target_selector_tilegx
<64, false> target_selector_tilegx64_le
;
4923 Target_selector_tilegx
<32, false> target_selector_tilegx32_le
;
4924 Target_selector_tilegx
<64, true> target_selector_tilegx64_be
;
4925 Target_selector_tilegx
<32, true> target_selector_tilegx32_be
;
4926 } // End anonymous namespace.