1 // s390.cc -- s390 target support for gold.
3 // Copyright (C) 2015-2016 Free Software Foundation, Inc.
4 // Written by Marcin KoĆcielnicki <koriakin@0x04.net>.
6 // This file is part of gold.
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
29 #include "parameters.h"
36 #include "copy-relocs.h"
38 #include "target-reloc.h"
39 #include "target-select.h"
49 // A class to handle the .got.plt section.
52 class Output_data_got_plt_s390
: public Output_section_data_build
55 Output_data_got_plt_s390(Layout
* layout
)
56 : Output_section_data_build(size
/8),
60 Output_data_got_plt_s390(Layout
* layout
, off_t data_size
)
61 : Output_section_data_build(data_size
, size
/8),
66 // Write out the PLT data.
68 do_write(Output_file
*);
70 // Write to a map file.
72 do_print_to_mapfile(Mapfile
* mapfile
) const
73 { mapfile
->print_output_data(this, "** GOT PLT"); }
76 // A pointer to the Layout class, so that we can find the .dynamic
77 // section when we write out the GOT PLT section.
81 // A class to handle the PLT data.
84 class Output_data_plt_s390
: public Output_section_data
87 typedef Output_data_reloc
<elfcpp::SHT_RELA
, true, size
, true>
90 Output_data_plt_s390(Layout
* layout
,
91 Output_data_got
<size
, true>* got
,
92 Output_data_got_plt_s390
<size
>* got_plt
,
93 Output_data_space
* got_irelative
)
94 : Output_section_data(4), layout_(layout
),
95 irelative_rel_(NULL
), got_(got
), got_plt_(got_plt
),
96 got_irelative_(got_irelative
), count_(0),
97 irelative_count_(0), free_list_()
98 { this->init(layout
); }
100 Output_data_plt_s390(Layout
* layout
,
101 Output_data_got
<size
, true>* got
,
102 Output_data_got_plt_s390
<size
>* got_plt
,
103 Output_data_space
* got_irelative
,
104 unsigned int plt_count
)
105 : Output_section_data((plt_count
+ 1) * plt_entry_size
,
107 layout_(layout
), irelative_rel_(NULL
), got_(got
),
108 got_plt_(got_plt
), got_irelative_(got_irelative
), count_(plt_count
),
109 irelative_count_(0), free_list_()
113 // Initialize the free list and reserve the first entry.
114 this->free_list_
.init((plt_count
+ 1) * plt_entry_size
, false);
115 this->free_list_
.remove(0, plt_entry_size
);
118 // Initialize the PLT section.
120 init(Layout
* layout
);
122 // Add an entry to the PLT.
124 add_entry(Symbol_table
*, Layout
*, Symbol
* gsym
);
126 // Add an entry to the PLT for a local STT_GNU_IFUNC symbol.
128 add_local_ifunc_entry(Symbol_table
*, Layout
*,
129 Sized_relobj_file
<size
, true>*, unsigned int);
131 // Add the relocation for a PLT entry.
133 add_relocation(Symbol_table
*, Layout
*, Symbol
*, unsigned int);
135 // Return the .rela.plt section data.
138 { return this->rel_
; }
140 // Return where the IRELATIVE relocations should go in the PLT
143 rela_irelative(Symbol_table
*, Layout
*);
145 // Return whether we created a section for IRELATIVE relocations.
147 has_irelative_section() const
148 { return this->irelative_rel_
!= NULL
; }
150 // Return the number of PLT entries.
153 { return this->count_
+ this->irelative_count_
; }
155 // Return the offset of the first non-reserved PLT entry.
157 first_plt_entry_offset()
158 { return plt_entry_size
; }
160 // Return the size of a PLT entry.
162 get_plt_entry_size() const
163 { return plt_entry_size
; }
165 // Reserve a slot in the PLT for an existing symbol in an incremental update.
167 reserve_slot(unsigned int plt_index
)
169 this->free_list_
.remove((plt_index
+ 1) * plt_entry_size
,
170 (plt_index
+ 2) * plt_entry_size
);
173 // Return the PLT address to use for a global symbol.
175 address_for_global(const Symbol
*);
177 // Return the PLT address to use for a local symbol.
179 address_for_local(const Relobj
*, unsigned int symndx
);
181 // Add .eh_frame information for the PLT.
183 add_eh_frame(Layout
* layout
)
186 layout
->add_eh_frame_for_plt(this,
188 plt_eh_frame_cie_size
,
190 plt_eh_frame_fde_size
);
194 // Fill in the first PLT entry.
196 fill_first_plt_entry(unsigned char* pov
,
197 typename
elfcpp::Elf_types
<size
>::Elf_Addr got_address
,
198 typename
elfcpp::Elf_types
<size
>::Elf_Addr plt_address
);
200 // Fill in a normal PLT entry. Returns the offset into the entry that
201 // should be the initial GOT slot value.
203 fill_plt_entry(unsigned char* pov
,
204 typename
elfcpp::Elf_types
<size
>::Elf_Addr got_address
,
205 typename
elfcpp::Elf_types
<size
>::Elf_Addr plt_address
,
206 unsigned int got_offset
,
207 unsigned int plt_offset
,
208 unsigned int plt_rel_offset
);
211 do_adjust_output_section(Output_section
* os
);
213 // Write to a map file.
215 do_print_to_mapfile(Mapfile
* mapfile
) const
216 { mapfile
->print_output_data(this, _("** PLT")); }
219 // Set the final size.
221 set_final_data_size();
223 // Write out the PLT data.
225 do_write(Output_file
*);
227 // A pointer to the Layout class, so that we can find the .dynamic
228 // section when we write out the GOT PLT section.
230 // The reloc section.
232 // The IRELATIVE relocs, if necessary. These must follow the
233 // regular PLT relocations.
234 Reloc_section
* irelative_rel_
;
236 Output_data_got
<size
, true>* got_
;
237 // The .got.plt section.
238 Output_data_got_plt_s390
<size
>* got_plt_
;
239 // The part of the .got.plt section used for IRELATIVE relocs.
240 Output_data_space
* got_irelative_
;
241 // The number of PLT entries.
243 // Number of PLT entries with R_TILEGX_IRELATIVE relocs. These
244 // follow the regular PLT entries.
245 unsigned int irelative_count_
;
246 // List of available regions within the section, for incremental
248 Free_list free_list_
;
250 // The size of an entry in the PLT.
251 static const int plt_entry_size
= 0x20;
252 // The first entry in the PLT.
253 static const unsigned char first_plt_entry_32_abs
[plt_entry_size
];
254 static const unsigned char first_plt_entry_32_pic
[plt_entry_size
];
255 static const unsigned char first_plt_entry_64
[plt_entry_size
];
256 // Other entries in the PLT for an executable.
257 static const unsigned char plt_entry_32_abs
[plt_entry_size
];
258 static const unsigned char plt_entry_32_pic12
[plt_entry_size
];
259 static const unsigned char plt_entry_32_pic16
[plt_entry_size
];
260 static const unsigned char plt_entry_32_pic
[plt_entry_size
];
261 static const unsigned char plt_entry_64
[plt_entry_size
];
263 // The .eh_frame unwind information for the PLT.
264 static const int plt_eh_frame_cie_size
= 12;
265 static const unsigned char plt_eh_frame_cie
[plt_eh_frame_cie_size
];
266 static const int plt_eh_frame_fde_size
= 12;
267 static const unsigned char plt_eh_frame_fde
[plt_eh_frame_fde_size
];
272 class Target_s390
: public Sized_target
<size
, true>
275 typedef Output_data_reloc
<elfcpp::SHT_RELA
, true, size
, true> Reloc_section
;
278 : Sized_target
<size
, true>(&s390_info
),
279 got_(NULL
), plt_(NULL
), got_plt_(NULL
), got_irelative_(NULL
),
280 global_offset_table_(NULL
), rela_dyn_(NULL
),
281 rela_irelative_(NULL
), copy_relocs_(elfcpp::R_390_COPY
),
282 got_mod_index_offset_(-1U), tls_base_symbol_defined_(false),
286 // Scan the relocations to look for symbol adjustments.
288 gc_process_relocs(Symbol_table
* symtab
,
290 Sized_relobj_file
<size
, true>* object
,
291 unsigned int data_shndx
,
292 unsigned int sh_type
,
293 const unsigned char* prelocs
,
295 Output_section
* output_section
,
296 bool needs_special_offset_handling
,
297 size_t local_symbol_count
,
298 const unsigned char* plocal_symbols
);
300 // Scan the relocations to look for symbol adjustments.
302 scan_relocs(Symbol_table
* symtab
,
304 Sized_relobj_file
<size
, true>* object
,
305 unsigned int data_shndx
,
306 unsigned int sh_type
,
307 const unsigned char* prelocs
,
309 Output_section
* output_section
,
310 bool needs_special_offset_handling
,
311 size_t local_symbol_count
,
312 const unsigned char* plocal_symbols
);
314 // Finalize the sections.
316 do_finalize_sections(Layout
*, const Input_objects
*, Symbol_table
*);
318 // Return the value to use for a dynamic which requires special
321 do_dynsym_value(const Symbol
*) const;
323 // Relocate a section.
325 relocate_section(const Relocate_info
<size
, true>*,
326 unsigned int sh_type
,
327 const unsigned char* prelocs
,
329 Output_section
* output_section
,
330 bool needs_special_offset_handling
,
332 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
333 section_size_type view_size
,
334 const Reloc_symbol_changes
*);
336 // Scan the relocs during a relocatable link.
338 scan_relocatable_relocs(Symbol_table
* symtab
,
340 Sized_relobj_file
<size
, true>* object
,
341 unsigned int data_shndx
,
342 unsigned int sh_type
,
343 const unsigned char* prelocs
,
345 Output_section
* output_section
,
346 bool needs_special_offset_handling
,
347 size_t local_symbol_count
,
348 const unsigned char* plocal_symbols
,
349 Relocatable_relocs
*);
351 // Scan the relocs for --emit-relocs.
353 emit_relocs_scan(Symbol_table
* symtab
,
355 Sized_relobj_file
<size
, true>* object
,
356 unsigned int data_shndx
,
357 unsigned int sh_type
,
358 const unsigned char* prelocs
,
360 Output_section
* output_section
,
361 bool needs_special_offset_handling
,
362 size_t local_symbol_count
,
363 const unsigned char* plocal_syms
,
364 Relocatable_relocs
* rr
);
366 // Return a string used to fill a code section with nops.
368 do_code_fill(section_size_type length
) const;
370 // Emit relocations for a section.
373 const Relocate_info
<size
, true>*,
374 unsigned int sh_type
,
375 const unsigned char* prelocs
,
377 Output_section
* output_section
,
378 typename
elfcpp::Elf_types
<size
>::Elf_Off offset_in_output_section
,
380 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
381 section_size_type view_size
,
382 unsigned char* reloc_view
,
383 section_size_type reloc_view_size
);
385 // Return whether SYM is defined by the ABI.
387 do_is_defined_by_abi(const Symbol
* sym
) const
388 { return strcmp(sym
->name(), "__tls_get_offset") == 0; }
390 // Return the PLT address to use for a global symbol.
392 do_plt_address_for_global(const Symbol
* gsym
) const
393 { return this->plt_section()->address_for_global(gsym
); }
396 do_plt_address_for_local(const Relobj
* relobj
, unsigned int symndx
) const
397 { return this->plt_section()->address_for_local(relobj
, symndx
); }
399 // Return the offset to use for the GOT_INDX'th got entry which is
400 // for a local tls symbol specified by OBJECT, SYMNDX.
402 do_tls_offset_for_local(const Relobj
* object
,
404 unsigned int got_indx
) const;
406 // Return the offset to use for the GOT_INDX'th got entry which is
407 // for global tls symbol GSYM.
409 do_tls_offset_for_global(Symbol
* gsym
, unsigned int got_indx
) const;
411 // This function should be defined in targets that can use relocation
412 // types to determine (implemented in local_reloc_may_be_function_pointer
413 // and global_reloc_may_be_function_pointer)
414 // if a function's pointer is taken. ICF uses this in safe mode to only
415 // fold those functions whose pointer is defintely not taken.
417 do_can_check_for_function_pointers() const
420 // Return the size of the GOT section.
424 gold_assert(this->got_
!= NULL
);
425 return this->got_
->data_size();
428 // Return the number of entries in the GOT.
430 got_entry_count() const
432 if (this->got_
== NULL
)
434 return this->got_size() / (size
/ 8);
437 // Return the number of entries in the PLT.
439 plt_entry_count() const;
441 // Return the offset of the first non-reserved PLT entry.
443 first_plt_entry_offset() const;
445 // Return the size of each PLT entry.
447 plt_entry_size() const;
449 // Create the GOT section for an incremental update.
450 Output_data_got_base
*
451 init_got_plt_for_update(Symbol_table
* symtab
,
453 unsigned int got_count
,
454 unsigned int plt_count
);
456 // Reserve a GOT entry for a local symbol, and regenerate any
457 // necessary dynamic relocations.
459 reserve_local_got_entry(unsigned int got_index
,
460 Sized_relobj
<size
, true>* obj
,
462 unsigned int got_type
);
464 // Reserve a GOT entry for a global symbol, and regenerate any
465 // necessary dynamic relocations.
467 reserve_global_got_entry(unsigned int got_index
, Symbol
* gsym
,
468 unsigned int got_type
);
470 // Register an existing PLT entry for a global symbol.
472 register_global_plt_entry(Symbol_table
*, Layout
*, unsigned int plt_index
,
475 // Force a COPY relocation for a given symbol.
477 emit_copy_reloc(Symbol_table
*, Symbol
*, Output_section
*, off_t
);
479 // Apply an incremental relocation.
481 apply_relocation(const Relocate_info
<size
, true>* relinfo
,
482 typename
elfcpp::Elf_types
<size
>::Elf_Addr r_offset
,
484 typename
elfcpp::Elf_types
<size
>::Elf_Swxword r_addend
,
487 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
488 section_size_type view_size
);
492 // The class which scans relocations.
497 : issued_non_pic_error_(false)
501 get_reference_flags(unsigned int r_type
);
504 local(Symbol_table
* symtab
, Layout
* layout
, Target_s390
* target
,
505 Sized_relobj_file
<size
, true>* object
,
506 unsigned int data_shndx
,
507 Output_section
* output_section
,
508 const elfcpp::Rela
<size
, true>& reloc
, unsigned int r_type
,
509 const elfcpp::Sym
<size
, true>& lsym
,
513 global(Symbol_table
* symtab
, Layout
* layout
, Target_s390
* target
,
514 Sized_relobj_file
<size
, true>* object
,
515 unsigned int data_shndx
,
516 Output_section
* output_section
,
517 const elfcpp::Rela
<size
, true>& reloc
, unsigned int r_type
,
521 local_reloc_may_be_function_pointer(Symbol_table
* symtab
, Layout
* layout
,
523 Sized_relobj_file
<size
, true>* object
,
524 unsigned int data_shndx
,
525 Output_section
* output_section
,
526 const elfcpp::Rela
<size
, true>& reloc
,
528 const elfcpp::Sym
<size
, true>& lsym
);
531 global_reloc_may_be_function_pointer(Symbol_table
* symtab
, Layout
* layout
,
533 Sized_relobj_file
<size
, true>* object
,
534 unsigned int data_shndx
,
535 Output_section
* output_section
,
536 const elfcpp::Rela
<size
, true>& reloc
,
542 unsupported_reloc_local(Sized_relobj_file
<size
, true>*,
543 unsigned int r_type
);
546 unsupported_reloc_global(Sized_relobj_file
<size
, true>*,
547 unsigned int r_type
, Symbol
*);
550 check_non_pic(Relobj
*, unsigned int r_type
);
553 possible_function_pointer_reloc(unsigned int r_type
);
556 reloc_needs_plt_for_ifunc(Sized_relobj_file
<size
, true>*,
557 unsigned int r_type
);
559 // Whether we have issued an error about a non-PIC compilation.
560 bool issued_non_pic_error_
;
563 // The class which implements relocation.
567 // Do a relocation. Return false if the caller should not issue
568 // any warnings about this relocation.
570 relocate(const Relocate_info
<size
, true>*, unsigned int,
571 Target_s390
*, Output_section
*, size_t, const unsigned char*,
572 const Sized_symbol
<size
>*, const Symbol_value
<size
>*,
573 unsigned char*, typename
elfcpp::Elf_types
<size
>::Elf_Addr
,
577 // Do a TLS relocation.
578 inline typename
elfcpp::Elf_types
<size
>::Elf_Addr
579 relocate_tls(const Relocate_info
<size
, true>*, Target_s390
*,
580 size_t relnum
, const elfcpp::Rela
<size
, true>&,
581 unsigned int r_type
, const Sized_symbol
<size
>*,
582 const Symbol_value
<size
>*,
583 unsigned char*, section_size_type
);
585 // Do a TLS General-Dynamic to Initial-Exec transition.
587 tls_gd_to_ie(const Relocate_info
<size
, true>*, size_t relnum
,
588 const elfcpp::Rela
<size
, true>&,
590 section_size_type view_size
);
592 // Do a TLS General-Dynamic to Local-Exec transition.
594 tls_gd_to_le(const Relocate_info
<size
, true>*, size_t relnum
,
595 const elfcpp::Rela
<size
, true>&,
597 section_size_type view_size
);
599 // Do a TLS Local-Dynamic to Local-Exec transition.
601 tls_ld_to_le(const Relocate_info
<size
, true>*, size_t relnum
,
602 const elfcpp::Rela
<size
, true>&,
604 section_size_type view_size
);
606 // Do a TLS Initial-Exec to Local-Exec transition.
608 tls_ie_to_le(const Relocate_info
<size
, true>*, size_t relnum
,
609 const elfcpp::Rela
<size
, true>&,
611 section_size_type view_size
);
614 // Adjust TLS relocation type based on the options and whether this
615 // is a local symbol.
616 static tls::Tls_optimization
617 optimize_tls_reloc(bool is_final
, int r_type
);
619 // Get the GOT section.
620 const Output_data_got
<size
, true>*
623 gold_assert(this->got_
!= NULL
);
627 // Get the GOT section, creating it if necessary.
628 Output_data_got
<size
, true>*
629 got_section(Symbol_table
*, Layout
*);
631 typename
elfcpp::Elf_types
<size
>::Elf_Addr
634 gold_assert(this->got_
!= NULL
);
635 return this->got_plt_
->address();
638 typename
elfcpp::Elf_types
<size
>::Elf_Addr
639 got_main_offset() const
641 gold_assert(this->got_
!= NULL
);
642 return this->got_
->address() - this->got_address();
645 // Create the PLT section.
647 make_plt_section(Symbol_table
* symtab
, Layout
* layout
);
649 // Create a PLT entry for a global symbol.
651 make_plt_entry(Symbol_table
*, Layout
*, Symbol
*);
653 // Create a PLT entry for a local STT_GNU_IFUNC symbol.
655 make_local_ifunc_plt_entry(Symbol_table
*, Layout
*,
656 Sized_relobj_file
<size
, true>* relobj
,
657 unsigned int local_sym_index
);
659 // Create a GOT entry for the TLS module index.
661 got_mod_index_entry(Symbol_table
* symtab
, Layout
* layout
,
662 Sized_relobj_file
<size
, true>* object
);
664 // Get the PLT section.
665 Output_data_plt_s390
<size
>*
668 gold_assert(this->plt_
!= NULL
);
672 // Get the dynamic reloc section, creating it if necessary.
674 rela_dyn_section(Layout
*);
676 // Get the section to use for IRELATIVE relocations.
678 rela_irelative_section(Layout
*);
680 // Add a potential copy relocation.
682 copy_reloc(Symbol_table
* symtab
, Layout
* layout
,
683 Sized_relobj_file
<size
, true>* object
,
684 unsigned int shndx
, Output_section
* output_section
,
685 Symbol
* sym
, const elfcpp::Rela
<size
, true>& reloc
)
687 unsigned int r_type
= elfcpp::elf_r_type
<size
>(reloc
.get_r_info());
688 this->copy_relocs_
.copy_reloc(symtab
, layout
,
689 symtab
->get_sized_symbol
<size
>(sym
),
690 object
, shndx
, output_section
,
691 r_type
, reloc
.get_r_offset(),
692 reloc
.get_r_addend(),
693 this->rela_dyn_section(layout
));
696 // Information about this specific target which we pass to the
697 // general Target structure.
698 static Target::Target_info s390_info
;
700 // The types of GOT entries needed for this platform.
701 // These values are exposed to the ABI in an incremental link.
702 // Do not renumber existing values without changing the version
703 // number of the .gnu_incremental_inputs section.
706 GOT_TYPE_STANDARD
= 0, // GOT entry for a regular symbol
707 GOT_TYPE_TLS_OFFSET
= 1, // GOT entry for TLS offset
708 GOT_TYPE_TLS_PAIR
= 2, // GOT entry for TLS module/offset pair
712 Output_data_got
<size
, true>* got_
;
714 Output_data_plt_s390
<size
>* plt_
;
715 // The GOT PLT section.
716 Output_data_got_plt_s390
<size
>* got_plt_
;
717 // The GOT section for IRELATIVE relocations.
718 Output_data_space
* got_irelative_
;
719 // The _GLOBAL_OFFSET_TABLE_ symbol.
720 Symbol
* global_offset_table_
;
721 // The dynamic reloc section.
722 Reloc_section
* rela_dyn_
;
723 // The section to use for IRELATIVE relocs.
724 Reloc_section
* rela_irelative_
;
725 // Relocs saved to avoid a COPY reloc.
726 Copy_relocs
<elfcpp::SHT_RELA
, size
, true> copy_relocs_
;
727 // Offset of the GOT entry for the TLS module index.
728 unsigned int got_mod_index_offset_
;
729 // True if the _TLS_MODULE_BASE_ symbol has been defined.
730 bool tls_base_symbol_defined_
;
731 // For use in do_tls_offset_for_*
736 Target::Target_info Target_s390
<32>::s390_info
=
739 true, // is_big_endian
740 elfcpp::EM_S390
, // machine_code
741 false, // has_make_symbol
742 false, // has_resolve
743 true, // has_code_fill
744 true, // is_default_stack_executable
745 true, // can_icf_inline_merge_sections
747 "/lib/ld.so.1", // dynamic_linker
748 0x00400000, // default_text_segment_address
749 4 * 1024, // abi_pagesize (overridable by -z max-page-size)
750 4 * 1024, // common_pagesize (overridable by -z common-page-size)
751 false, // isolate_execinstr
753 elfcpp::SHN_UNDEF
, // small_common_shndx
754 elfcpp::SHN_UNDEF
, // large_common_shndx
755 0, // small_common_section_flags
756 0, // large_common_section_flags
757 NULL
, // attributes_section
758 NULL
, // attributes_vendor
759 "_start", // entry_symbol_name
760 32, // hash_entry_size
764 Target::Target_info Target_s390
<64>::s390_info
=
767 true, // is_big_endian
768 elfcpp::EM_S390
, // machine_code
769 false, // has_make_symbol
770 false, // has_resolve
771 true, // has_code_fill
772 true, // is_default_stack_executable
773 true, // can_icf_inline_merge_sections
775 "/lib/ld64.so.1", // dynamic_linker
776 0x80000000ll
, // default_text_segment_address
777 4 * 1024, // abi_pagesize (overridable by -z max-page-size)
778 4 * 1024, // common_pagesize (overridable by -z common-page-size)
779 false, // isolate_execinstr
781 elfcpp::SHN_UNDEF
, // small_common_shndx
782 elfcpp::SHN_UNDEF
, // large_common_shndx
783 0, // small_common_section_flags
784 0, // large_common_section_flags
785 NULL
, // attributes_section
786 NULL
, // attributes_vendor
787 "_start", // entry_symbol_name
788 64, // hash_entry_size
792 class S390_relocate_functions
812 typedef S390_relocate_functions
<size
> This
;
813 typedef typename
elfcpp::Elf_types
<size
>::Elf_Addr Address
;
815 template<int valsize
>
817 has_overflow_signed(Address value
)
819 // limit = 1 << (valsize - 1) without shift count exceeding size of type
820 Address limit
= static_cast<Address
>(1) << ((valsize
- 1) >> 1);
821 limit
<<= ((valsize
- 1) >> 1);
822 limit
<<= ((valsize
- 1) - 2 * ((valsize
- 1) >> 1));
823 return value
+ limit
> (limit
<< 1) - 1;
826 template<int valsize
>
828 has_overflow_unsigned(Address value
)
830 Address limit
= static_cast<Address
>(1) << ((valsize
- 1) >> 1);
831 limit
<<= ((valsize
- 1) >> 1);
832 limit
<<= ((valsize
- 1) - 2 * ((valsize
- 1) >> 1));
833 return value
> (limit
<< 1) - 1;
836 template<int fieldsize
>
838 rela(unsigned char* view
, Address mask
, Address value
)
840 typedef typename
elfcpp::Swap
<fieldsize
, true>::Valtype Valtype
;
841 Valtype
* wv
= reinterpret_cast<Valtype
*>(view
);
842 Valtype val
= elfcpp::Swap
<fieldsize
, true>::readval(view
);
845 elfcpp::Swap
<fieldsize
, true>::writeval(wv
, val
| value
);
849 // R_390_12, R_390_GOT12, R_390_GOTPLT12, R_390_GOTIE12
851 rela12(unsigned char* view
, Address value
)
853 if (This::template has_overflow_unsigned
<12>(value
))
854 return STATUS_OVERFLOW
;
855 This::template rela
<16>(view
, 0x0fff, value
);
859 // R_390_16, R_390_GOT16, R_390_GOTPLT16, R_390_GOTOFF16, R_390_PLTOFF16
861 rela16(unsigned char* view
, Address value
)
863 if (This::template has_overflow_signed
<16>(value
))
864 return STATUS_OVERFLOW
;
865 This::template rela
<16>(view
, 0xffff, value
);
869 // R_390_20, R_390_GOT20, R_390_GOTPLT20, R_390_GOTIE20
871 rela20(unsigned char* view
, Address value
)
873 if (This::template has_overflow_signed
<20>(value
))
874 return STATUS_OVERFLOW
;
875 This::template rela
<16>(view
, 0x0fff, value
);
876 This::template rela
<16>(view
+ 2, 0xff00, value
>> (12 - 8));
880 // R_390_PC12DBL, R_390_PLT12DBL
882 pcrela12dbl(unsigned char* view
, Address value
, Address address
)
885 if ((value
& 1) != 0)
886 return STATUS_OVERFLOW
;
887 if (This::template has_overflow_signed
<13>(value
))
888 return STATUS_OVERFLOW
;
890 This::template rela
<16>(view
, 0x0fff, value
);
894 // R_390_PC16DBL, R_390_PLT16DBL
896 pcrela16dbl(unsigned char* view
, Address value
, Address address
)
899 if ((value
& 1) != 0)
900 return STATUS_OVERFLOW
;
901 if (This::template has_overflow_signed
<17>(value
))
902 return STATUS_OVERFLOW
;
904 This::template rela
<16>(view
, 0xffff, value
);
908 // R_390_PC24DBL, R_390_PLT24DBL
910 pcrela24dbl(unsigned char* view
, Address value
, Address address
)
913 if ((value
& 1) != 0)
914 return STATUS_OVERFLOW
;
915 if (This::template has_overflow_signed
<25>(value
))
916 return STATUS_OVERFLOW
;
918 // Swap doesn't take 24-bit fields well...
919 This::template rela
<8>(view
, 0xff, value
>> 16);
920 This::template rela
<16>(view
+ 1, 0xffff, value
);
924 // R_390_PC32DBL, R_390_PLT32DBL, R_390_GOTPCDBL, R_390_GOTENT, R_390_GOTPLTENT
926 pcrela32dbl(unsigned char* view
, Address value
, Address address
)
928 Address reloc
= value
- address
;
929 if ((reloc
& 1) != 0)
931 gold_warning(_("R_390_PC32DBL target misaligned at %llx"), (long long)address
);
932 // Wait for a fix for https://sourceware.org/bugzilla/show_bug.cgi?id=18960
933 // return STATUS_OVERFLOW;
935 if (This::template has_overflow_signed
<33>(reloc
))
936 return STATUS_OVERFLOW
;
938 if (value
< address
&& size
== 32)
940 This::template rela
<32>(view
, 0xffffffff, reloc
);
946 // Initialize the PLT section.
950 Output_data_plt_s390
<size
>::init(Layout
* layout
)
952 this->rel_
= new Reloc_section(false);
953 layout
->add_output_section_data(".rela.plt", elfcpp::SHT_RELA
,
954 elfcpp::SHF_ALLOC
, this->rel_
,
955 ORDER_DYNAMIC_PLT_RELOCS
, false);
960 Output_data_plt_s390
<size
>::do_adjust_output_section(Output_section
* os
)
962 os
->set_entsize(plt_entry_size
);
965 // Add an entry to the PLT.
969 Output_data_plt_s390
<size
>::add_entry(Symbol_table
* symtab
, Layout
* layout
,
972 gold_assert(!gsym
->has_plt_offset());
974 unsigned int plt_index
;
976 section_offset_type got_offset
;
978 unsigned int* pcount
;
980 unsigned int reserved
;
981 Output_section_data_build
* got
;
982 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
983 && gsym
->can_use_relative_reloc(false))
985 pcount
= &this->irelative_count_
;
988 got
= this->got_irelative_
;
992 pcount
= &this->count_
;
995 got
= this->got_plt_
;
998 if (!this->is_data_size_valid())
1000 // Note that when setting the PLT offset for a non-IRELATIVE
1001 // entry we skip the initial reserved PLT entry.
1002 plt_index
= *pcount
+ offset
;
1003 plt_offset
= plt_index
* plt_entry_size
;
1007 got_offset
= (plt_index
- offset
+ reserved
) * size
/ 8;
1008 gold_assert(got_offset
== got
->current_data_size());
1010 // Every PLT entry needs a GOT entry which points back to the PLT
1011 // entry (this will be changed by the dynamic linker, normally
1012 // lazily when the function is called).
1013 got
->set_current_data_size(got_offset
+ size
/ 8);
1017 // FIXME: This is probably not correct for IRELATIVE relocs.
1019 // For incremental updates, find an available slot.
1020 plt_offset
= this->free_list_
.allocate(plt_entry_size
,
1022 if (plt_offset
== -1)
1023 gold_fallback(_("out of patch space (PLT);"
1024 " relink with --incremental-full"));
1026 // The GOT and PLT entries have a 1-1 correspondance, so the GOT offset
1027 // can be calculated from the PLT index, adjusting for the three
1028 // reserved entries at the beginning of the GOT.
1029 plt_index
= plt_offset
/ plt_entry_size
- 1;
1030 got_offset
= (plt_index
- offset
+ reserved
) * size
/ 8;
1033 gsym
->set_plt_offset(plt_offset
);
1035 // Every PLT entry needs a reloc.
1036 this->add_relocation(symtab
, layout
, gsym
, got_offset
);
1038 // Note that we don't need to save the symbol. The contents of the
1039 // PLT are independent of which symbols are used. The symbols only
1040 // appear in the relocations.
1043 // Add an entry to the PLT for a local STT_GNU_IFUNC symbol. Return
1048 Output_data_plt_s390
<size
>::add_local_ifunc_entry(
1049 Symbol_table
* symtab
,
1051 Sized_relobj_file
<size
, true>* relobj
,
1052 unsigned int local_sym_index
)
1054 unsigned int plt_offset
= this->irelative_count_
* plt_entry_size
;
1055 ++this->irelative_count_
;
1057 section_offset_type got_offset
= this->got_irelative_
->current_data_size();
1059 // Every PLT entry needs a GOT entry which points back to the PLT
1061 this->got_irelative_
->set_current_data_size(got_offset
+ size
/ 8);
1063 // Every PLT entry needs a reloc.
1064 Reloc_section
* rela
= this->rela_irelative(symtab
, layout
);
1065 rela
->add_symbolless_local_addend(relobj
, local_sym_index
,
1066 elfcpp::R_390_IRELATIVE
,
1067 this->got_irelative_
, got_offset
, 0);
1072 // Add the relocation for a PLT entry.
1076 Output_data_plt_s390
<size
>::add_relocation(Symbol_table
* symtab
,
1079 unsigned int got_offset
)
1081 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
1082 && gsym
->can_use_relative_reloc(false))
1084 Reloc_section
* rela
= this->rela_irelative(symtab
, layout
);
1085 rela
->add_symbolless_global_addend(gsym
, elfcpp::R_390_IRELATIVE
,
1086 this->got_irelative_
, got_offset
, 0);
1090 gsym
->set_needs_dynsym_entry();
1091 this->rel_
->add_global(gsym
, elfcpp::R_390_JMP_SLOT
, this->got_plt_
,
1096 // Return where the IRELATIVE relocations should go in the PLT. These
1097 // follow the JUMP_SLOT and the TLSDESC relocations.
1100 typename Output_data_plt_s390
<size
>::Reloc_section
*
1101 Output_data_plt_s390
<size
>::rela_irelative(Symbol_table
* symtab
,
1104 if (this->irelative_rel_
== NULL
)
1106 this->irelative_rel_
= new Reloc_section(false);
1107 layout
->add_output_section_data(".rela.plt", elfcpp::SHT_RELA
,
1108 elfcpp::SHF_ALLOC
, this->irelative_rel_
,
1109 ORDER_DYNAMIC_PLT_RELOCS
, false);
1110 gold_assert(this->irelative_rel_
->output_section()
1111 == this->rel_
->output_section());
1113 if (parameters
->doing_static_link())
1115 // A statically linked executable will only have a .rela.plt
1116 // section to hold R_390_IRELATIVE relocs for
1117 // STT_GNU_IFUNC symbols. The library will use these
1118 // symbols to locate the IRELATIVE relocs at program startup
1120 symtab
->define_in_output_data("__rela_iplt_start", NULL
,
1121 Symbol_table::PREDEFINED
,
1122 this->irelative_rel_
, 0, 0,
1123 elfcpp::STT_NOTYPE
, elfcpp::STB_GLOBAL
,
1124 elfcpp::STV_HIDDEN
, 0, false, true);
1125 symtab
->define_in_output_data("__rela_iplt_end", NULL
,
1126 Symbol_table::PREDEFINED
,
1127 this->irelative_rel_
, 0, 0,
1128 elfcpp::STT_NOTYPE
, elfcpp::STB_GLOBAL
,
1129 elfcpp::STV_HIDDEN
, 0, true, true);
1132 return this->irelative_rel_
;
1135 // Return the PLT address to use for a global symbol.
1139 Output_data_plt_s390
<size
>::address_for_global(const Symbol
* gsym
)
1141 uint64_t offset
= 0;
1142 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
1143 && gsym
->can_use_relative_reloc(false))
1144 offset
= (this->count_
+ 1) * plt_entry_size
;
1145 return this->address() + offset
+ gsym
->plt_offset();
1148 // Return the PLT address to use for a local symbol. These are always
1149 // IRELATIVE relocs.
1153 Output_data_plt_s390
<size
>::address_for_local(const Relobj
* object
,
1156 return (this->address()
1157 + (this->count_
+ 1) * plt_entry_size
1158 + object
->local_plt_offset(r_sym
));
1161 // Set the final size.
1164 Output_data_plt_s390
<size
>::set_final_data_size()
1166 unsigned int count
= this->count_
+ this->irelative_count_
;
1167 this->set_data_size((count
+ 1) * plt_entry_size
);
1172 Output_data_plt_s390
<size
>::first_plt_entry_32_abs
[plt_entry_size
] =
1174 0x50, 0x10, 0xf0, 0x1c, // st %r1, 28(%r15)
1175 0x0d, 0x10, // basr %r1, %r0
1176 0x58, 0x10, 0x10, 0x12, // l %r1, 18(%r1)
1177 0xd2, 0x03, 0xf0, 0x18, 0x10, 0x04, // mvc 24(4,%r15), 4(%r1)
1178 0x58, 0x10, 0x10, 0x08, // l %r1, 8(%r1)
1179 0x07, 0xf1, // br %r1
1180 0x00, 0x00, // padding
1181 0x00, 0x00, 0x00, 0x00, // _GLOBAL_OFFSET_TABLE_ (to fill)
1182 0x00, 0x00, 0x00, 0x00, // padding
1187 Output_data_plt_s390
<size
>::first_plt_entry_32_pic
[plt_entry_size
] =
1189 0x50, 0x10, 0xf0, 0x1c, // st %r1, 28(%r15)
1190 0x58, 0x10, 0xc0, 0x04, // l %r1, 4(%r12)
1191 0x50, 0x10, 0xf0, 0x18, // st %r1, 24(%r15)
1192 0x58, 0x10, 0xc0, 0x08, // l %r1, 8(%r12)
1193 0x07, 0xf1, // br %r1
1194 0x00, 0x00, // padding
1195 0x00, 0x00, 0x00, 0x00, // padding
1196 0x00, 0x00, 0x00, 0x00, // padding
1197 0x00, 0x00, 0x00, 0x00, // padding
1202 Output_data_plt_s390
<size
>::first_plt_entry_64
[plt_entry_size
] =
1204 0xe3, 0x10, 0xf0, 0x38, 0x00, 0x24, // stg %r1, 56(%r15)
1205 0xc0, 0x10, 0x00, 0x00, 0x00, 0x00, // larl %r1, _GLOBAL_OFFSET_TABLE_ (to fill)
1206 0xd2, 0x07, 0xf0, 0x30, 0x10, 0x08, // mvc 48(8,%r15), 8(%r1)
1207 0xe3, 0x10, 0x10, 0x10, 0x00, 0x04, // lg %r1, 16(%r1)
1208 0x07, 0xf1, // br %r1
1216 Output_data_plt_s390
<size
>::fill_first_plt_entry(
1218 typename
elfcpp::Elf_types
<size
>::Elf_Addr got_address
,
1219 typename
elfcpp::Elf_types
<size
>::Elf_Addr plt_address
)
1223 memcpy(pov
, first_plt_entry_64
, plt_entry_size
);
1224 S390_relocate_functions
<size
>::pcrela32dbl(pov
+ 8, got_address
, (plt_address
+ 6));
1226 else if (!parameters
->options().output_is_position_independent())
1228 memcpy(pov
, first_plt_entry_32_abs
, plt_entry_size
);
1229 elfcpp::Swap
<32, true>::writeval(pov
+ 24, got_address
);
1233 memcpy(pov
, first_plt_entry_32_pic
, plt_entry_size
);
1239 Output_data_plt_s390
<size
>::plt_entry_32_abs
[plt_entry_size
] =
1242 0x0d, 0x10, // basr %r1, %r0
1243 0x58, 0x10, 0x10, 0x16, // l %r1, 22(%r1)
1244 0x58, 0x10, 0x10, 0x00, // l %r1, 0(%r1)
1245 0x07, 0xf1, // br %r1
1247 0x0d, 0x10, // basr %r1, %r0
1248 0x58, 0x10, 0x10, 0x0e, // l %r1, 14(%r1)
1249 0xa7, 0xf4, 0x00, 0x00, // j first_plt_entry (to fill)
1250 0x00, 0x00, // padding
1251 0x00, 0x00, 0x00, 0x00, // _GLOBAL_OFFSET_TABLE_+sym@gotplt (to fill)
1252 0x00, 0x00, 0x00, 0x00, // offset of relocation in .rela.plt (to fill)
1257 Output_data_plt_s390
<size
>::plt_entry_32_pic12
[plt_entry_size
] =
1260 0x58, 0x10, 0xc0, 0x00, // l %r1, sym@gotplt(%r12) (to fill)
1261 0x07, 0xf1, // br %r1
1262 0x00, 0x00, // padding
1263 0x00, 0x00, 0x00, 0x00, // padding
1265 0x0d, 0x10, // basr %r1, %r0
1266 0x58, 0x10, 0x10, 0x0e, // l %r1, 14(%r1)
1267 0xa7, 0xf4, 0x00, 0x00, // j first_plt_entry (to fill)
1268 0x00, 0x00, // padding
1269 0x00, 0x00, 0x00, 0x00, // padding
1270 0x00, 0x00, 0x00, 0x00, // offset of relocation in .rela.plt (to fill)
1275 Output_data_plt_s390
<size
>::plt_entry_32_pic16
[plt_entry_size
] =
1278 0xa7, 0x18, 0x00, 0x00, // lhi %r1, sym@gotplt (to fill)
1279 0x58, 0x11, 0xc0, 0x00, // l %r1, 0(%r1, %r12)
1280 0x07, 0xf1, // br %r1
1281 0x00, 0x00, // padding
1283 0x0d, 0x10, // basr %r1, %r0
1284 0x58, 0x10, 0x10, 0x0e, // l %r1, 14(%r1)
1285 0xa7, 0xf4, 0x00, 0x00, // j first_plt_entry (to fill)
1286 0x00, 0x00, // padding
1287 0x00, 0x00, 0x00, 0x00, // padding
1288 0x00, 0x00, 0x00, 0x00, // offset of relocation in .rela.plt (to fill)
1293 Output_data_plt_s390
<size
>::plt_entry_32_pic
[plt_entry_size
] =
1296 0x0d, 0x10, // basr %r1, %r0
1297 0x58, 0x10, 0x10, 0x16, // l %r1, 22(%r1)
1298 0x58, 0x11, 0xc0, 0x00, // l %r1, 0(%r1, %r12)
1299 0x07, 0xf1, // br %r1
1301 0x0d, 0x10, // basr %r1, %r0
1302 0x58, 0x10, 0x10, 0x0e, // l %r1, 14(%r1)
1303 0xa7, 0xf4, 0x00, 0x00, // j first_plt_entry (to fill)
1304 0x00, 0x00, // padding
1305 0x00, 0x00, 0x00, 0x00, // sym@gotplt (to fill)
1306 0x00, 0x00, 0x00, 0x00, // offset of relocation in .rela.plt (to fill)
1311 Output_data_plt_s390
<size
>::plt_entry_64
[plt_entry_size
] =
1314 0xc0, 0x10, 0x00, 0x00, 0x00, 0x00, // larl %r1, _GLOBAL_OFFSET_TABLE_+off (to fill)
1315 0xe3, 0x10, 0x10, 0x00, 0x00, 0x04, // lg %r1, 0(%r1)
1316 0x07, 0xf1, // br %r1
1318 0x0d, 0x10, // basr %r1, %r0
1319 0xe3, 0x10, 0x10, 0x0c, 0x00, 0x14, // lgf %r1, 12(%r1)
1320 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, // jg first_plt_entry (to fill)
1321 0x00, 0x00, 0x00, 0x00, // offset of relocation in .rela.plt (to fill)
1326 Output_data_plt_s390
<size
>::fill_plt_entry(
1328 typename
elfcpp::Elf_types
<size
>::Elf_Addr got_address
,
1329 typename
elfcpp::Elf_types
<size
>::Elf_Addr plt_address
,
1330 unsigned int got_offset
,
1331 unsigned int plt_offset
,
1332 unsigned int plt_rel_offset
)
1336 memcpy(pov
, plt_entry_64
, plt_entry_size
);
1337 S390_relocate_functions
<size
>::pcrela32dbl(pov
+ 2, got_address
+ got_offset
, plt_address
+ plt_offset
);
1338 S390_relocate_functions
<size
>::pcrela32dbl(pov
+ 24, plt_address
, plt_address
+ plt_offset
+ 22);
1342 if (!parameters
->options().output_is_position_independent())
1344 memcpy(pov
, plt_entry_32_abs
, plt_entry_size
);
1345 elfcpp::Swap
<32, true>::writeval(pov
+ 24, got_address
+ got_offset
);
1349 if (got_offset
< 0x1000)
1351 memcpy(pov
, plt_entry_32_pic12
, plt_entry_size
);
1352 S390_relocate_functions
<size
>::rela12(pov
+ 2, got_offset
);
1354 else if (got_offset
< 0x8000)
1356 memcpy(pov
, plt_entry_32_pic16
, plt_entry_size
);
1357 S390_relocate_functions
<size
>::rela16(pov
+ 2, got_offset
);
1361 memcpy(pov
, plt_entry_32_pic
, plt_entry_size
);
1362 elfcpp::Swap
<32, true>::writeval(pov
+ 24, got_offset
);
1365 typename
elfcpp::Elf_types
<size
>::Elf_Addr target
= plt_address
;
1366 if (plt_offset
>= 0x10000)
1368 // Would overflow pcrela16dbl - aim at the farthest previous jump
1370 if (plt_offset
> 0x10000)
1372 // Use the full range of pcrel16dbl.
1373 target
= plt_address
+ plt_offset
- 0x10000 + 18;
1377 // if plt_offset is exactly 0x10000, the above would aim at 18th byte
1378 // of first_plt_entry, which doesn't have the jump back like the others.
1379 // Aim at the next entry instead.
1380 target
= plt_address
+ plt_offset
- 0xffe0 + 18;
1383 S390_relocate_functions
<size
>::pcrela16dbl(pov
+ 20, target
, plt_address
+ plt_offset
+ 18);
1385 elfcpp::Swap
<32, true>::writeval(pov
+ 28, plt_rel_offset
);
1392 // The .eh_frame unwind information for the PLT.
1396 Output_data_plt_s390
<32>::plt_eh_frame_cie
[plt_eh_frame_cie_size
] =
1399 'z', // Augmentation: augmentation size included.
1400 'R', // Augmentation: FDE encoding included.
1401 '\0', // End of augmentation string.
1402 1, // Code alignment factor.
1403 0x7c, // Data alignment factor.
1404 14, // Return address column.
1405 1, // Augmentation size.
1406 (elfcpp::DW_EH_PE_pcrel
// FDE encoding.
1407 | elfcpp::DW_EH_PE_sdata4
),
1408 elfcpp::DW_CFA_def_cfa
, 15, 0x60, // DW_CFA_def_cfa: r15 ofs 0x60.
1413 Output_data_plt_s390
<64>::plt_eh_frame_cie
[plt_eh_frame_cie_size
] =
1416 'z', // Augmentation: augmentation size included.
1417 'R', // Augmentation: FDE encoding included.
1418 '\0', // End of augmentation string.
1419 1, // Code alignment factor.
1420 0x78, // Data alignment factor.
1421 14, // Return address column.
1422 1, // Augmentation size.
1423 (elfcpp::DW_EH_PE_pcrel
// FDE encoding.
1424 | elfcpp::DW_EH_PE_sdata4
),
1425 elfcpp::DW_CFA_def_cfa
, 15, 0xa0, // DW_CFA_def_cfa: r15 ofs 0xa0.
1430 Output_data_plt_s390
<size
>::plt_eh_frame_fde
[plt_eh_frame_fde_size
] =
1432 0, 0, 0, 0, // Replaced with offset to .plt.
1433 0, 0, 0, 0, // Replaced with size of .plt.
1434 0, // Augmentation size.
1440 // Write out the PLT. This uses the hand-coded instructions above,
1441 // and adjusts them as needed.
1445 Output_data_plt_s390
<size
>::do_write(Output_file
* of
)
1447 const off_t offset
= this->offset();
1448 const section_size_type oview_size
=
1449 convert_to_section_size_type(this->data_size());
1450 unsigned char* const oview
= of
->get_output_view(offset
, oview_size
);
1452 const off_t got_file_offset
= this->got_plt_
->offset();
1453 gold_assert(parameters
->incremental_update()
1454 || (got_file_offset
+ this->got_plt_
->data_size()
1455 == this->got_irelative_
->offset()));
1456 const section_size_type got_size
=
1457 convert_to_section_size_type(this->got_plt_
->data_size()
1458 + this->got_irelative_
->data_size());
1459 unsigned char* const got_view
= of
->get_output_view(got_file_offset
,
1462 unsigned char* pov
= oview
;
1464 // The base address of the .plt section.
1465 typename
elfcpp::Elf_types
<size
>::Elf_Addr plt_address
= this->address();
1466 // The base address of the PLT portion of the .got section,
1467 // which is where the GOT pointer will point, and where the
1468 // three reserved GOT entries are located.
1469 typename
elfcpp::Elf_types
<size
>::Elf_Addr got_address
1470 = this->got_plt_
->address();
1472 this->fill_first_plt_entry(pov
, got_address
, plt_address
);
1473 pov
+= this->get_plt_entry_size();
1475 unsigned char* got_pov
= got_view
;
1477 const int rel_size
= elfcpp::Elf_sizes
<size
>::rela_size
;
1479 unsigned int plt_offset
= this->get_plt_entry_size();
1480 unsigned int plt_rel_offset
= 0;
1481 unsigned int got_offset
= 3 * size
/ 8;
1482 const unsigned int count
= this->count_
+ this->irelative_count_
;
1483 // The first three entries in the GOT are reserved, and are written
1484 // by Output_data_got_plt_s390::do_write.
1485 got_pov
+= 3 * size
/ 8;
1487 for (unsigned int plt_index
= 0;
1490 pov
+= plt_entry_size
,
1491 got_pov
+= size
/ 8,
1492 plt_offset
+= plt_entry_size
,
1493 plt_rel_offset
+= rel_size
,
1494 got_offset
+= size
/ 8)
1496 // Set and adjust the PLT entry itself.
1497 unsigned int lazy_offset
= this->fill_plt_entry(pov
,
1498 got_address
, plt_address
,
1499 got_offset
, plt_offset
,
1502 // Set the entry in the GOT.
1503 elfcpp::Swap
<size
, true>::writeval(got_pov
,
1504 plt_address
+ plt_offset
+ lazy_offset
);
1507 gold_assert(static_cast<section_size_type
>(pov
- oview
) == oview_size
);
1508 gold_assert(static_cast<section_size_type
>(got_pov
- got_view
) == got_size
);
1510 of
->write_output_view(offset
, oview_size
, oview
);
1511 of
->write_output_view(got_file_offset
, got_size
, got_view
);
1514 // Get the GOT section, creating it if necessary.
1517 Output_data_got
<size
, true>*
1518 Target_s390
<size
>::got_section(Symbol_table
* symtab
, Layout
* layout
)
1520 if (this->got_
== NULL
)
1522 gold_assert(symtab
!= NULL
&& layout
!= NULL
);
1524 // When using -z now, we can treat .got as a relro section.
1525 // Without -z now, it is modified after program startup by lazy
1527 bool is_got_relro
= parameters
->options().now();
1528 Output_section_order got_order
= (is_got_relro
1532 // The old GNU linker creates a .got.plt section. We just
1533 // create another set of data in the .got section. Note that we
1534 // always create a PLT if we create a GOT, although the PLT
1536 this->got_plt_
= new Output_data_got_plt_s390
<size
>(layout
);
1537 layout
->add_output_section_data(".got", elfcpp::SHT_PROGBITS
,
1538 (elfcpp::SHF_ALLOC
| elfcpp::SHF_WRITE
),
1539 this->got_plt_
, got_order
, is_got_relro
);
1541 // The first three entries are reserved.
1542 this->got_plt_
->set_current_data_size(3 * size
/ 8);
1544 // If there are any IRELATIVE relocations, they get GOT entries
1545 // in .got.plt after the jump slot entries.
1546 this->got_irelative_
= new Output_data_space(size
/ 8, "** GOT IRELATIVE PLT");
1547 layout
->add_output_section_data(".got", elfcpp::SHT_PROGBITS
,
1548 (elfcpp::SHF_ALLOC
| elfcpp::SHF_WRITE
),
1549 this->got_irelative_
,
1550 got_order
, is_got_relro
);
1552 // Unlike some targets (.e.g x86), S/390 does not use separate .got and
1553 // .got.plt sections in output. The output .got section contains both
1554 // PLT and non-PLT GOT entries.
1555 this->got_
= new Output_data_got
<size
, true>();
1557 layout
->add_output_section_data(".got", elfcpp::SHT_PROGBITS
,
1558 (elfcpp::SHF_ALLOC
| elfcpp::SHF_WRITE
),
1559 this->got_
, got_order
, is_got_relro
);
1561 // Define _GLOBAL_OFFSET_TABLE_ at the start of the GOT.
1562 this->global_offset_table_
=
1563 symtab
->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL
,
1564 Symbol_table::PREDEFINED
,
1566 0, 0, elfcpp::STT_OBJECT
,
1568 elfcpp::STV_HIDDEN
, 0,
1575 // Get the dynamic reloc section, creating it if necessary.
1578 typename Target_s390
<size
>::Reloc_section
*
1579 Target_s390
<size
>::rela_dyn_section(Layout
* layout
)
1581 if (this->rela_dyn_
== NULL
)
1583 gold_assert(layout
!= NULL
);
1584 this->rela_dyn_
= new Reloc_section(parameters
->options().combreloc());
1585 layout
->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA
,
1586 elfcpp::SHF_ALLOC
, this->rela_dyn_
,
1587 ORDER_DYNAMIC_RELOCS
, false);
1589 return this->rela_dyn_
;
1592 // Get the section to use for IRELATIVE relocs, creating it if
1593 // necessary. These go in .rela.dyn, but only after all other dynamic
1594 // relocations. They need to follow the other dynamic relocations so
1595 // that they can refer to global variables initialized by those
1599 typename Target_s390
<size
>::Reloc_section
*
1600 Target_s390
<size
>::rela_irelative_section(Layout
* layout
)
1602 if (this->rela_irelative_
== NULL
)
1604 // Make sure we have already created the dynamic reloc section.
1605 this->rela_dyn_section(layout
);
1606 this->rela_irelative_
= new Reloc_section(false);
1607 layout
->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA
,
1608 elfcpp::SHF_ALLOC
, this->rela_irelative_
,
1609 ORDER_DYNAMIC_RELOCS
, false);
1610 gold_assert(this->rela_dyn_
->output_section()
1611 == this->rela_irelative_
->output_section());
1613 return this->rela_irelative_
;
1616 // Write the first three reserved words of the .got.plt section.
1617 // The remainder of the section is written while writing the PLT
1618 // in Output_data_plt_s390::do_write.
1622 Output_data_got_plt_s390
<size
>::do_write(Output_file
* of
)
1624 // The first entry in the GOT is the address of the .dynamic section
1625 // aka the PT_DYNAMIC segment. The next two entries are reserved.
1626 // We saved space for them when we created the section in
1627 // Target_x86_64::got_section.
1628 const off_t got_file_offset
= this->offset();
1629 gold_assert(this->data_size() >= 3 * size
/ 8);
1630 unsigned char* const got_view
=
1631 of
->get_output_view(got_file_offset
, 3 * size
/ 8);
1632 Output_section
* dynamic
= this->layout_
->dynamic_section();
1633 uint64_t dynamic_addr
= dynamic
== NULL
? 0 : dynamic
->address();
1634 elfcpp::Swap
<size
, true>::writeval(got_view
, dynamic_addr
);
1635 memset(got_view
+ size
/ 8, 0, 2 * size
/ 8);
1636 of
->write_output_view(got_file_offset
, 3 * size
/ 8, got_view
);
1639 // Create the PLT section.
1643 Target_s390
<size
>::make_plt_section(Symbol_table
* symtab
, Layout
* layout
)
1645 if (this->plt_
== NULL
)
1647 // Create the GOT sections first.
1648 this->got_section(symtab
, layout
);
1650 // Ensure that .rela.dyn always appears before .rela.plt This is
1651 // necessary due to how, on 32-bit S/390 and some other targets,
1652 // .rela.dyn needs to include .rela.plt in it's range.
1653 this->rela_dyn_section(layout
);
1655 this->plt_
= new Output_data_plt_s390
<size
>(layout
,
1656 this->got_
, this->got_plt_
, this->got_irelative_
);
1658 // Add unwind information if requested.
1659 if (parameters
->options().ld_generated_unwind_info())
1660 this->plt_
->add_eh_frame(layout
);
1662 layout
->add_output_section_data(".plt", elfcpp::SHT_PROGBITS
,
1664 | elfcpp::SHF_EXECINSTR
),
1665 this->plt_
, ORDER_PLT
, false);
1667 // Make the sh_info field of .rela.plt point to .plt.
1668 Output_section
* rela_plt_os
= this->plt_
->rela_plt()->output_section();
1669 rela_plt_os
->set_info_section(this->plt_
->output_section());
1673 // Create a PLT entry for a global symbol.
1677 Target_s390
<size
>::make_plt_entry(Symbol_table
* symtab
, Layout
* layout
,
1680 if (gsym
->has_plt_offset())
1683 if (this->plt_
== NULL
)
1684 this->make_plt_section(symtab
, layout
);
1686 this->plt_
->add_entry(symtab
, layout
, gsym
);
1689 // Make a PLT entry for a local STT_GNU_IFUNC symbol.
1693 Target_s390
<size
>::make_local_ifunc_plt_entry(
1694 Symbol_table
* symtab
, Layout
* layout
,
1695 Sized_relobj_file
<size
, true>* relobj
,
1696 unsigned int local_sym_index
)
1698 if (relobj
->local_has_plt_offset(local_sym_index
))
1700 if (this->plt_
== NULL
)
1701 this->make_plt_section(symtab
, layout
);
1702 unsigned int plt_offset
= this->plt_
->add_local_ifunc_entry(symtab
, layout
,
1705 relobj
->set_local_plt_offset(local_sym_index
, plt_offset
);
1708 // Return the number of entries in the PLT.
1712 Target_s390
<size
>::plt_entry_count() const
1714 if (this->plt_
== NULL
)
1716 return this->plt_
->entry_count();
1719 // Return the offset of the first non-reserved PLT entry.
1723 Target_s390
<size
>::first_plt_entry_offset() const
1725 return this->plt_
->first_plt_entry_offset();
1728 // Return the size of each PLT entry.
1732 Target_s390
<size
>::plt_entry_size() const
1734 return this->plt_
->get_plt_entry_size();
1737 // Create the GOT and PLT sections for an incremental update.
1740 Output_data_got_base
*
1741 Target_s390
<size
>::init_got_plt_for_update(Symbol_table
* symtab
,
1743 unsigned int got_count
,
1744 unsigned int plt_count
)
1746 gold_assert(this->got_
== NULL
);
1748 // Add the three reserved entries.
1749 this->got_plt_
= new Output_data_got_plt_s390
<size
>(layout
, (plt_count
+ 3) * size
/ 8);
1750 layout
->add_output_section_data(".got", elfcpp::SHT_PROGBITS
,
1752 | elfcpp::SHF_WRITE
),
1753 this->got_plt_
, ORDER_NON_RELRO_FIRST
,
1756 // If there are any IRELATIVE relocations, they get GOT entries in
1757 // .got.plt after the jump slot entries.
1758 this->got_irelative_
= new Output_data_space(0, size
/ 8, "** GOT IRELATIVE PLT");
1759 layout
->add_output_section_data(".got", elfcpp::SHT_PROGBITS
,
1760 elfcpp::SHF_ALLOC
| elfcpp::SHF_WRITE
,
1761 this->got_irelative_
,
1762 ORDER_NON_RELRO_FIRST
, false);
1764 this->got_
= new Output_data_got
<size
, true>(got_count
* size
/ 8);
1765 layout
->add_output_section_data(".got", elfcpp::SHT_PROGBITS
,
1767 | elfcpp::SHF_WRITE
),
1768 this->got_
, ORDER_RELRO_LAST
,
1771 // Define _GLOBAL_OFFSET_TABLE_ at the start of the PLT.
1772 this->global_offset_table_
=
1773 symtab
->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL
,
1774 Symbol_table::PREDEFINED
,
1776 0, 0, elfcpp::STT_OBJECT
,
1778 elfcpp::STV_HIDDEN
, 0,
1781 // Create the PLT section.
1782 this->plt_
= new Output_data_plt_s390
<size
>(layout
,
1783 this->got_
, this->got_plt_
, this->got_irelative_
, plt_count
);
1785 // Add unwind information if requested.
1786 if (parameters
->options().ld_generated_unwind_info())
1787 this->plt_
->add_eh_frame(layout
);
1789 layout
->add_output_section_data(".plt", elfcpp::SHT_PROGBITS
,
1790 elfcpp::SHF_ALLOC
| elfcpp::SHF_EXECINSTR
,
1791 this->plt_
, ORDER_PLT
, false);
1793 // Make the sh_info field of .rela.plt point to .plt.
1794 Output_section
* rela_plt_os
= this->plt_
->rela_plt()->output_section();
1795 rela_plt_os
->set_info_section(this->plt_
->output_section());
1797 // Create the rela_dyn section.
1798 this->rela_dyn_section(layout
);
1803 // Reserve a GOT entry for a local symbol, and regenerate any
1804 // necessary dynamic relocations.
1808 Target_s390
<size
>::reserve_local_got_entry(
1809 unsigned int got_index
,
1810 Sized_relobj
<size
, true>* obj
,
1812 unsigned int got_type
)
1814 unsigned int got_offset
= got_index
* size
/ 8;
1815 Reloc_section
* rela_dyn
= this->rela_dyn_section(NULL
);
1817 this->got_
->reserve_local(got_index
, obj
, r_sym
, got_type
);
1820 case GOT_TYPE_STANDARD
:
1821 if (parameters
->options().output_is_position_independent())
1822 rela_dyn
->add_local_relative(obj
, r_sym
, elfcpp::R_390_RELATIVE
,
1823 this->got_
, got_offset
, 0, false);
1825 case GOT_TYPE_TLS_OFFSET
:
1826 rela_dyn
->add_local(obj
, r_sym
, elfcpp::R_390_TLS_TPOFF
,
1827 this->got_
, got_offset
, 0);
1829 case GOT_TYPE_TLS_PAIR
:
1830 this->got_
->reserve_slot(got_index
+ 1);
1831 rela_dyn
->add_local(obj
, r_sym
, elfcpp::R_390_TLS_DTPMOD
,
1832 this->got_
, got_offset
, 0);
1839 // Reserve a GOT entry for a global symbol, and regenerate any
1840 // necessary dynamic relocations.
1844 Target_s390
<size
>::reserve_global_got_entry(unsigned int got_index
,
1846 unsigned int got_type
)
1848 unsigned int got_offset
= got_index
* size
/ 8;
1849 Reloc_section
* rela_dyn
= this->rela_dyn_section(NULL
);
1851 this->got_
->reserve_global(got_index
, gsym
, got_type
);
1854 case GOT_TYPE_STANDARD
:
1855 if (!gsym
->final_value_is_known())
1857 if (gsym
->is_from_dynobj()
1858 || gsym
->is_undefined()
1859 || gsym
->is_preemptible()
1860 || gsym
->type() == elfcpp::STT_GNU_IFUNC
)
1861 rela_dyn
->add_global(gsym
, elfcpp::R_390_GLOB_DAT
,
1862 this->got_
, got_offset
, 0);
1864 rela_dyn
->add_global_relative(gsym
, elfcpp::R_390_RELATIVE
,
1865 this->got_
, got_offset
, 0, false);
1868 case GOT_TYPE_TLS_OFFSET
:
1869 rela_dyn
->add_global_relative(gsym
, elfcpp::R_390_TLS_TPOFF
,
1870 this->got_
, got_offset
, 0, false);
1872 case GOT_TYPE_TLS_PAIR
:
1873 this->got_
->reserve_slot(got_index
+ 1);
1874 rela_dyn
->add_global_relative(gsym
, elfcpp::R_390_TLS_DTPMOD
,
1875 this->got_
, got_offset
, 0, false);
1876 rela_dyn
->add_global_relative(gsym
, elfcpp::R_390_TLS_DTPOFF
,
1877 this->got_
, got_offset
+ size
/ 8, 0, false);
1884 // Register an existing PLT entry for a global symbol.
1888 Target_s390
<size
>::register_global_plt_entry(Symbol_table
* symtab
,
1890 unsigned int plt_index
,
1893 gold_assert(this->plt_
!= NULL
);
1894 gold_assert(!gsym
->has_plt_offset());
1896 this->plt_
->reserve_slot(plt_index
);
1898 gsym
->set_plt_offset((plt_index
+ 1) * this->plt_entry_size());
1900 unsigned int got_offset
= (plt_index
+ 3) * size
/ 8;
1901 this->plt_
->add_relocation(symtab
, layout
, gsym
, got_offset
);
1904 // Force a COPY relocation for a given symbol.
1908 Target_s390
<size
>::emit_copy_reloc(
1909 Symbol_table
* symtab
, Symbol
* sym
, Output_section
* os
, off_t offset
)
1911 this->copy_relocs_
.emit_copy_reloc(symtab
,
1912 symtab
->get_sized_symbol
<size
>(sym
),
1915 this->rela_dyn_section(NULL
));
1918 // Create a GOT entry for the TLS module index.
1922 Target_s390
<size
>::got_mod_index_entry(Symbol_table
* symtab
, Layout
* layout
,
1923 Sized_relobj_file
<size
, true>* object
)
1925 if (this->got_mod_index_offset_
== -1U)
1927 gold_assert(symtab
!= NULL
&& layout
!= NULL
&& object
!= NULL
);
1928 Reloc_section
* rela_dyn
= this->rela_dyn_section(layout
);
1929 Output_data_got
<size
, true>* got
= this->got_section(symtab
, layout
);
1930 unsigned int got_offset
= got
->add_constant(0);
1931 rela_dyn
->add_local(object
, 0, elfcpp::R_390_TLS_DTPMOD
, got
,
1933 got
->add_constant(0);
1934 this->got_mod_index_offset_
= got_offset
;
1936 return this->got_mod_index_offset_
;
1939 // Optimize the TLS relocation type based on what we know about the
1940 // symbol. IS_FINAL is true if the final address of this symbol is
1941 // known at link time.
1944 tls::Tls_optimization
1945 Target_s390
<size
>::optimize_tls_reloc(bool is_final
, int r_type
)
1947 // If we are generating a shared library, then we can't do anything
1949 if (parameters
->options().shared())
1950 return tls::TLSOPT_NONE
;
1954 case elfcpp::R_390_TLS_GD32
:
1955 case elfcpp::R_390_TLS_GD64
:
1956 case elfcpp::R_390_TLS_GDCALL
:
1957 // These are General-Dynamic which permits fully general TLS
1958 // access. Since we know that we are generating an executable,
1959 // we can convert this to Initial-Exec. If we also know that
1960 // this is a local symbol, we can further switch to Local-Exec.
1962 return tls::TLSOPT_TO_LE
;
1963 return tls::TLSOPT_TO_IE
;
1965 case elfcpp::R_390_TLS_LDM32
:
1966 case elfcpp::R_390_TLS_LDM64
:
1967 case elfcpp::R_390_TLS_LDO32
:
1968 case elfcpp::R_390_TLS_LDO64
:
1969 case elfcpp::R_390_TLS_LDCALL
:
1970 // This is Local-Dynamic, which refers to a local symbol in the
1971 // dynamic TLS block. Since we know that we generating an
1972 // executable, we can switch to Local-Exec.
1973 return tls::TLSOPT_TO_LE
;
1975 case elfcpp::R_390_TLS_IE32
:
1976 case elfcpp::R_390_TLS_IE64
:
1977 case elfcpp::R_390_TLS_GOTIE32
:
1978 case elfcpp::R_390_TLS_GOTIE64
:
1979 case elfcpp::R_390_TLS_LOAD
:
1980 // These are Initial-Exec relocs which get the thread offset
1981 // from the GOT. If we know that we are linking against the
1982 // local symbol, we can switch to Local-Exec, which links the
1983 // thread offset into the instruction.
1985 return tls::TLSOPT_TO_LE
;
1986 return tls::TLSOPT_NONE
;
1988 case elfcpp::R_390_TLS_GOTIE12
:
1989 case elfcpp::R_390_TLS_IEENT
:
1990 case elfcpp::R_390_TLS_GOTIE20
:
1991 // These are Initial-Exec, but cannot be optimized.
1992 return tls::TLSOPT_NONE
;
1994 case elfcpp::R_390_TLS_LE32
:
1995 case elfcpp::R_390_TLS_LE64
:
1996 // When we already have Local-Exec, there is nothing further we
1998 return tls::TLSOPT_NONE
;
2005 // Get the Reference_flags for a particular relocation.
2009 Target_s390
<size
>::Scan::get_reference_flags(unsigned int r_type
)
2013 case elfcpp::R_390_NONE
:
2014 case elfcpp::R_390_GNU_VTINHERIT
:
2015 case elfcpp::R_390_GNU_VTENTRY
:
2016 case elfcpp::R_390_GOTPC
:
2017 case elfcpp::R_390_GOTPCDBL
:
2018 // No symbol reference.
2021 case elfcpp::R_390_64
:
2022 case elfcpp::R_390_32
:
2023 case elfcpp::R_390_20
:
2024 case elfcpp::R_390_16
:
2025 case elfcpp::R_390_12
:
2026 case elfcpp::R_390_8
:
2027 return Symbol::ABSOLUTE_REF
;
2029 case elfcpp::R_390_PC12DBL
:
2030 case elfcpp::R_390_PC16
:
2031 case elfcpp::R_390_PC16DBL
:
2032 case elfcpp::R_390_PC24DBL
:
2033 case elfcpp::R_390_PC32
:
2034 case elfcpp::R_390_PC32DBL
:
2035 case elfcpp::R_390_PC64
:
2036 case elfcpp::R_390_GOTOFF16
:
2037 case elfcpp::R_390_GOTOFF32
:
2038 case elfcpp::R_390_GOTOFF64
:
2039 return Symbol::RELATIVE_REF
;
2041 case elfcpp::R_390_PLT12DBL
:
2042 case elfcpp::R_390_PLT16DBL
:
2043 case elfcpp::R_390_PLT24DBL
:
2044 case elfcpp::R_390_PLT32
:
2045 case elfcpp::R_390_PLT32DBL
:
2046 case elfcpp::R_390_PLT64
:
2047 case elfcpp::R_390_PLTOFF16
:
2048 case elfcpp::R_390_PLTOFF32
:
2049 case elfcpp::R_390_PLTOFF64
:
2050 return Symbol::FUNCTION_CALL
| Symbol::RELATIVE_REF
;
2052 case elfcpp::R_390_GOT12
:
2053 case elfcpp::R_390_GOT16
:
2054 case elfcpp::R_390_GOT20
:
2055 case elfcpp::R_390_GOT32
:
2056 case elfcpp::R_390_GOT64
:
2057 case elfcpp::R_390_GOTENT
:
2058 case elfcpp::R_390_GOTPLT12
:
2059 case elfcpp::R_390_GOTPLT16
:
2060 case elfcpp::R_390_GOTPLT20
:
2061 case elfcpp::R_390_GOTPLT32
:
2062 case elfcpp::R_390_GOTPLT64
:
2063 case elfcpp::R_390_GOTPLTENT
:
2065 return Symbol::ABSOLUTE_REF
;
2067 case elfcpp::R_390_TLS_GD32
: // Global-dynamic
2068 case elfcpp::R_390_TLS_GD64
:
2069 case elfcpp::R_390_TLS_GDCALL
:
2070 case elfcpp::R_390_TLS_LDM32
: // Local-dynamic
2071 case elfcpp::R_390_TLS_LDM64
:
2072 case elfcpp::R_390_TLS_LDO32
:
2073 case elfcpp::R_390_TLS_LDO64
:
2074 case elfcpp::R_390_TLS_LDCALL
:
2075 case elfcpp::R_390_TLS_IE32
: // Initial-exec
2076 case elfcpp::R_390_TLS_IE64
:
2077 case elfcpp::R_390_TLS_IEENT
:
2078 case elfcpp::R_390_TLS_GOTIE12
:
2079 case elfcpp::R_390_TLS_GOTIE20
:
2080 case elfcpp::R_390_TLS_GOTIE32
:
2081 case elfcpp::R_390_TLS_GOTIE64
:
2082 case elfcpp::R_390_TLS_LOAD
:
2083 case elfcpp::R_390_TLS_LE32
: // Local-exec
2084 case elfcpp::R_390_TLS_LE64
:
2085 return Symbol::TLS_REF
;
2087 case elfcpp::R_390_COPY
:
2088 case elfcpp::R_390_GLOB_DAT
:
2089 case elfcpp::R_390_JMP_SLOT
:
2090 case elfcpp::R_390_RELATIVE
:
2091 case elfcpp::R_390_IRELATIVE
:
2092 case elfcpp::R_390_TLS_TPOFF
:
2093 case elfcpp::R_390_TLS_DTPOFF
:
2094 case elfcpp::R_390_TLS_DTPMOD
:
2096 // Not expected. We will give an error later.
2101 // Report an unsupported relocation against a local symbol.
2105 Target_s390
<size
>::Scan::unsupported_reloc_local(
2106 Sized_relobj_file
<size
, true>* object
,
2107 unsigned int r_type
)
2109 gold_error(_("%s: unsupported reloc %u against local symbol"),
2110 object
->name().c_str(), r_type
);
2113 // We are about to emit a dynamic relocation of type R_TYPE. If the
2114 // dynamic linker does not support it, issue an error.
2118 Target_s390
<size
>::Scan::check_non_pic(Relobj
* object
, unsigned int r_type
)
2120 gold_assert(r_type
!= elfcpp::R_390_NONE
);
2126 // These are the relocation types supported by glibc for s390 64-bit.
2127 case elfcpp::R_390_RELATIVE
:
2128 case elfcpp::R_390_IRELATIVE
:
2129 case elfcpp::R_390_COPY
:
2130 case elfcpp::R_390_GLOB_DAT
:
2131 case elfcpp::R_390_JMP_SLOT
:
2132 case elfcpp::R_390_TLS_DTPMOD
:
2133 case elfcpp::R_390_TLS_DTPOFF
:
2134 case elfcpp::R_390_TLS_TPOFF
:
2135 case elfcpp::R_390_8
:
2136 case elfcpp::R_390_16
:
2137 case elfcpp::R_390_32
:
2138 case elfcpp::R_390_64
:
2139 case elfcpp::R_390_PC16
:
2140 case elfcpp::R_390_PC16DBL
:
2141 case elfcpp::R_390_PC32
:
2142 case elfcpp::R_390_PC32DBL
:
2143 case elfcpp::R_390_PC64
:
2154 // These are the relocation types supported by glibc for s390 32-bit.
2155 case elfcpp::R_390_RELATIVE
:
2156 case elfcpp::R_390_IRELATIVE
:
2157 case elfcpp::R_390_COPY
:
2158 case elfcpp::R_390_GLOB_DAT
:
2159 case elfcpp::R_390_JMP_SLOT
:
2160 case elfcpp::R_390_TLS_DTPMOD
:
2161 case elfcpp::R_390_TLS_DTPOFF
:
2162 case elfcpp::R_390_TLS_TPOFF
:
2163 case elfcpp::R_390_8
:
2164 case elfcpp::R_390_16
:
2165 case elfcpp::R_390_32
:
2166 case elfcpp::R_390_PC16
:
2167 case elfcpp::R_390_PC16DBL
:
2168 case elfcpp::R_390_PC32
:
2169 case elfcpp::R_390_PC32DBL
:
2177 // This prevents us from issuing more than one error per reloc
2178 // section. But we can still wind up issuing more than one
2179 // error per object file.
2180 if (this->issued_non_pic_error_
)
2182 gold_assert(parameters
->options().output_is_position_independent());
2183 object
->error(_("requires unsupported dynamic reloc; "
2184 "recompile with -fPIC"));
2185 this->issued_non_pic_error_
= true;
2189 // Return whether we need to make a PLT entry for a relocation of the
2190 // given type against a STT_GNU_IFUNC symbol.
2194 Target_s390
<size
>::Scan::reloc_needs_plt_for_ifunc(
2195 Sized_relobj_file
<size
, true>* object
,
2196 unsigned int r_type
)
2198 int flags
= Scan::get_reference_flags(r_type
);
2199 if (flags
& Symbol::TLS_REF
)
2200 gold_error(_("%s: unsupported TLS reloc %u for IFUNC symbol"),
2201 object
->name().c_str(), r_type
);
2205 // Scan a relocation for a local symbol.
2209 Target_s390
<size
>::Scan::local(Symbol_table
* symtab
,
2211 Target_s390
<size
>* target
,
2212 Sized_relobj_file
<size
, true>* object
,
2213 unsigned int data_shndx
,
2214 Output_section
* output_section
,
2215 const elfcpp::Rela
<size
, true>& reloc
,
2216 unsigned int r_type
,
2217 const elfcpp::Sym
<size
, true>& lsym
,
2223 // A local STT_GNU_IFUNC symbol may require a PLT entry.
2224 bool is_ifunc
= lsym
.get_st_type() == elfcpp::STT_GNU_IFUNC
;
2226 if (is_ifunc
&& this->reloc_needs_plt_for_ifunc(object
, r_type
))
2228 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
2229 target
->make_local_ifunc_plt_entry(symtab
, layout
, object
, r_sym
);
2234 case elfcpp::R_390_NONE
:
2235 case elfcpp::R_390_GNU_VTINHERIT
:
2236 case elfcpp::R_390_GNU_VTENTRY
:
2239 case elfcpp::R_390_64
:
2240 // If building a shared library (or a position-independent
2241 // executable), we need to create a dynamic relocation for this
2242 // location. The relocation applied at link time will apply the
2243 // link-time value, so we flag the location with an
2244 // R_390_RELATIVE relocation so the dynamic loader can
2245 // relocate it easily.
2246 if (parameters
->options().output_is_position_independent() && size
== 64)
2248 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
2249 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2250 rela_dyn
->add_local_relative(object
, r_sym
,
2251 elfcpp::R_390_RELATIVE
,
2252 output_section
, data_shndx
,
2253 reloc
.get_r_offset(),
2254 reloc
.get_r_addend(), is_ifunc
);
2258 case elfcpp::R_390_32
:
2259 case elfcpp::R_390_20
:
2260 case elfcpp::R_390_16
:
2261 case elfcpp::R_390_12
:
2262 case elfcpp::R_390_8
:
2263 if (parameters
->options().output_is_position_independent())
2265 if (size
== 32 && r_type
== elfcpp::R_390_32
)
2267 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
2268 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2269 rela_dyn
->add_local_relative(object
, r_sym
,
2270 elfcpp::R_390_RELATIVE
,
2271 output_section
, data_shndx
,
2272 reloc
.get_r_offset(),
2273 reloc
.get_r_addend(), is_ifunc
);
2277 check_non_pic(object
, r_type
);
2279 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2280 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
2281 if (lsym
.get_st_type() != elfcpp::STT_SECTION
)
2282 rela_dyn
->add_local(object
, r_sym
, r_type
, output_section
,
2283 data_shndx
, reloc
.get_r_offset(),
2284 reloc
.get_r_addend());
2287 gold_assert(lsym
.get_st_value() == 0);
2288 unsigned int shndx
= lsym
.get_st_shndx();
2290 shndx
= object
->adjust_sym_shndx(r_sym
, shndx
,
2293 object
->error(_("section symbol %u has bad shndx %u"),
2296 rela_dyn
->add_local_section(object
, shndx
,
2297 r_type
, output_section
,
2298 data_shndx
, reloc
.get_r_offset(),
2299 reloc
.get_r_addend());
2304 case elfcpp::R_390_PC12DBL
:
2305 case elfcpp::R_390_PC16
:
2306 case elfcpp::R_390_PC16DBL
:
2307 case elfcpp::R_390_PC24DBL
:
2308 case elfcpp::R_390_PC32
:
2309 case elfcpp::R_390_PC32DBL
:
2310 case elfcpp::R_390_PC64
:
2313 case elfcpp::R_390_PLT12DBL
:
2314 case elfcpp::R_390_PLT16DBL
:
2315 case elfcpp::R_390_PLT24DBL
:
2316 case elfcpp::R_390_PLT32
:
2317 case elfcpp::R_390_PLT32DBL
:
2318 case elfcpp::R_390_PLT64
:
2319 // Since we know this is a local symbol, we can handle this as a
2323 case elfcpp::R_390_GOTPC
:
2324 case elfcpp::R_390_GOTPCDBL
:
2325 case elfcpp::R_390_GOTOFF16
:
2326 case elfcpp::R_390_GOTOFF32
:
2327 case elfcpp::R_390_GOTOFF64
:
2328 case elfcpp::R_390_PLTOFF16
:
2329 case elfcpp::R_390_PLTOFF32
:
2330 case elfcpp::R_390_PLTOFF64
:
2331 // We need a GOT section.
2332 target
->got_section(symtab
, layout
);
2333 // For PLTOFF*, we'd normally want a PLT section, but since we
2334 // know this is a local symbol, no PLT is needed.
2337 case elfcpp::R_390_GOT12
:
2338 case elfcpp::R_390_GOT16
:
2339 case elfcpp::R_390_GOT20
:
2340 case elfcpp::R_390_GOT32
:
2341 case elfcpp::R_390_GOT64
:
2342 case elfcpp::R_390_GOTENT
:
2343 case elfcpp::R_390_GOTPLT12
:
2344 case elfcpp::R_390_GOTPLT16
:
2345 case elfcpp::R_390_GOTPLT20
:
2346 case elfcpp::R_390_GOTPLT32
:
2347 case elfcpp::R_390_GOTPLT64
:
2348 case elfcpp::R_390_GOTPLTENT
:
2350 // The symbol requires a GOT section.
2351 Output_data_got
<size
, true>* got
= target
->got_section(symtab
, layout
);
2353 // The symbol requires a GOT entry.
2354 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
2356 // For a STT_GNU_IFUNC symbol we want the PLT offset. That
2357 // lets function pointers compare correctly with shared
2358 // libraries. Otherwise we would need an IRELATIVE reloc.
2361 is_new
= got
->add_local_plt(object
, r_sym
, GOT_TYPE_STANDARD
);
2363 is_new
= got
->add_local(object
, r_sym
, GOT_TYPE_STANDARD
);
2366 // If we are generating a shared object, we need to add a
2367 // dynamic relocation for this symbol's GOT entry.
2368 if (parameters
->options().output_is_position_independent())
2370 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2371 unsigned int got_offset
=
2372 object
->local_got_offset(r_sym
, GOT_TYPE_STANDARD
);
2373 rela_dyn
->add_local_relative(object
, r_sym
,
2374 elfcpp::R_390_RELATIVE
,
2375 got
, got_offset
, 0, is_ifunc
);
2378 // For GOTPLT*, we'd normally want a PLT section, but since
2379 // we know this is a local symbol, no PLT is needed.
2383 case elfcpp::R_390_COPY
:
2384 case elfcpp::R_390_GLOB_DAT
:
2385 case elfcpp::R_390_JMP_SLOT
:
2386 case elfcpp::R_390_RELATIVE
:
2387 case elfcpp::R_390_IRELATIVE
:
2388 // These are outstanding tls relocs, which are unexpected when linking
2389 case elfcpp::R_390_TLS_TPOFF
:
2390 case elfcpp::R_390_TLS_DTPOFF
:
2391 case elfcpp::R_390_TLS_DTPMOD
:
2392 gold_error(_("%s: unexpected reloc %u in object file"),
2393 object
->name().c_str(), r_type
);
2396 // These are initial tls relocs, which are expected when linking
2397 case elfcpp::R_390_TLS_GD32
: // Global-dynamic
2398 case elfcpp::R_390_TLS_GD64
:
2399 case elfcpp::R_390_TLS_GDCALL
:
2400 case elfcpp::R_390_TLS_LDM32
: // Local-dynamic
2401 case elfcpp::R_390_TLS_LDM64
:
2402 case elfcpp::R_390_TLS_LDO32
:
2403 case elfcpp::R_390_TLS_LDO64
:
2404 case elfcpp::R_390_TLS_LDCALL
:
2405 case elfcpp::R_390_TLS_IE32
: // Initial-exec
2406 case elfcpp::R_390_TLS_IE64
:
2407 case elfcpp::R_390_TLS_IEENT
:
2408 case elfcpp::R_390_TLS_GOTIE12
:
2409 case elfcpp::R_390_TLS_GOTIE20
:
2410 case elfcpp::R_390_TLS_GOTIE32
:
2411 case elfcpp::R_390_TLS_GOTIE64
:
2412 case elfcpp::R_390_TLS_LOAD
:
2413 case elfcpp::R_390_TLS_LE32
: // Local-exec
2414 case elfcpp::R_390_TLS_LE64
:
2416 bool output_is_shared
= parameters
->options().shared();
2417 const tls::Tls_optimization optimized_type
2418 = Target_s390
<size
>::optimize_tls_reloc(!output_is_shared
,
2422 case elfcpp::R_390_TLS_GD32
: // General-dynamic
2423 case elfcpp::R_390_TLS_GD64
:
2424 case elfcpp::R_390_TLS_GDCALL
:
2425 if (optimized_type
== tls::TLSOPT_NONE
)
2427 // Create a pair of GOT entries for the module index and
2428 // dtv-relative offset.
2429 Output_data_got
<size
, true>* got
2430 = target
->got_section(symtab
, layout
);
2431 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
2432 unsigned int shndx
= lsym
.get_st_shndx();
2434 shndx
= object
->adjust_sym_shndx(r_sym
, shndx
, &is_ordinary
);
2436 object
->error(_("local symbol %u has bad shndx %u"),
2439 got
->add_local_pair_with_rel(object
, r_sym
,
2442 target
->rela_dyn_section(layout
),
2443 elfcpp::R_390_TLS_DTPMOD
);
2445 else if (optimized_type
!= tls::TLSOPT_TO_LE
)
2446 unsupported_reloc_local(object
, r_type
);
2449 case elfcpp::R_390_TLS_LDM32
: // Local-dynamic
2450 case elfcpp::R_390_TLS_LDM64
:
2451 case elfcpp::R_390_TLS_LDCALL
:
2452 if (optimized_type
== tls::TLSOPT_NONE
)
2454 // Create a GOT entry for the module index.
2455 target
->got_mod_index_entry(symtab
, layout
, object
);
2457 else if (optimized_type
!= tls::TLSOPT_TO_LE
)
2458 unsupported_reloc_local(object
, r_type
);
2461 case elfcpp::R_390_TLS_LDO32
:
2462 case elfcpp::R_390_TLS_LDO64
:
2465 case elfcpp::R_390_TLS_IE32
: // Initial-exec
2466 case elfcpp::R_390_TLS_IE64
:
2467 // These two involve an absolute address
2468 if (parameters
->options().shared()
2469 && optimized_type
== tls::TLSOPT_NONE
)
2471 if ((size
== 32 && r_type
== elfcpp::R_390_TLS_IE32
) ||
2472 (size
== 64 && r_type
== elfcpp::R_390_TLS_IE64
))
2474 // We need to create a dynamic relocation.
2475 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2476 unsigned int r_sym
=
2477 elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
2478 rela_dyn
->add_local_relative(object
, r_sym
,
2479 elfcpp::R_390_RELATIVE
,
2480 output_section
, data_shndx
,
2481 reloc
.get_r_offset(),
2482 reloc
.get_r_addend(), false);
2486 unsupported_reloc_local(object
, r_type
);
2490 case elfcpp::R_390_TLS_IEENT
:
2491 case elfcpp::R_390_TLS_GOTIE12
:
2492 case elfcpp::R_390_TLS_GOTIE20
:
2493 case elfcpp::R_390_TLS_GOTIE32
:
2494 case elfcpp::R_390_TLS_GOTIE64
:
2495 case elfcpp::R_390_TLS_LOAD
:
2496 layout
->set_has_static_tls();
2497 if (optimized_type
== tls::TLSOPT_NONE
)
2499 if (!output_is_shared
)
2501 // We're making an executable, and the symbol is local, but
2502 // we cannot optimize to LE. Make a const GOT entry instead.
2503 Output_data_got
<size
, true>* got
2504 = target
->got_section(symtab
, layout
);
2506 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
2507 got
->add_local_plt(object
, r_sym
, GOT_TYPE_TLS_OFFSET
);
2511 // Create a GOT entry for the tp-relative offset.
2512 Output_data_got
<size
, true>* got
2513 = target
->got_section(symtab
, layout
);
2515 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
2516 got
->add_local_with_rel(object
, r_sym
, GOT_TYPE_TLS_OFFSET
,
2517 target
->rela_dyn_section(layout
),
2518 elfcpp::R_390_TLS_TPOFF
);
2521 else if (optimized_type
!= tls::TLSOPT_TO_LE
)
2522 unsupported_reloc_local(object
, r_type
);
2525 case elfcpp::R_390_TLS_LE32
: // Local-exec
2526 case elfcpp::R_390_TLS_LE64
:
2527 layout
->set_has_static_tls();
2528 if (output_is_shared
)
2530 // We need to create a dynamic relocation.
2531 if ((size
== 32 && r_type
== elfcpp::R_390_TLS_LE32
) ||
2532 (size
== 64 && r_type
== elfcpp::R_390_TLS_LE64
))
2534 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2536 = elfcpp::elf_r_sym
<size
>(reloc
.get_r_info());
2537 gold_assert(lsym
.get_st_type() != elfcpp::STT_SECTION
);
2538 rela_dyn
->add_local(object
, r_sym
, elfcpp::R_390_TLS_TPOFF
,
2539 output_section
, data_shndx
,
2540 reloc
.get_r_offset(),
2541 reloc
.get_r_addend());
2545 unsupported_reloc_local(object
, r_type
);
2557 gold_error(_("%s: unsupported reloc %u against local symbol"),
2558 object
->name().c_str(), r_type
);
2563 // Scan a relocation for a global symbol.
2567 Target_s390
<size
>::Scan::global(Symbol_table
* symtab
,
2569 Target_s390
<size
>* target
,
2570 Sized_relobj_file
<size
, true>* object
,
2571 unsigned int data_shndx
,
2572 Output_section
* output_section
,
2573 const elfcpp::Rela
<size
, true>& reloc
,
2574 unsigned int r_type
,
2577 // A STT_GNU_IFUNC symbol may require a PLT entry.
2578 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
2579 && this->reloc_needs_plt_for_ifunc(object
, r_type
))
2580 target
->make_plt_entry(symtab
, layout
, gsym
);
2584 case elfcpp::R_390_NONE
:
2585 case elfcpp::R_390_GNU_VTINHERIT
:
2586 case elfcpp::R_390_GNU_VTENTRY
:
2589 case elfcpp::R_390_64
:
2590 case elfcpp::R_390_32
:
2591 case elfcpp::R_390_20
:
2592 case elfcpp::R_390_16
:
2593 case elfcpp::R_390_12
:
2594 case elfcpp::R_390_8
:
2596 // Make a PLT entry if necessary.
2597 if (gsym
->needs_plt_entry())
2599 target
->make_plt_entry(symtab
, layout
, gsym
);
2600 // Since this is not a PC-relative relocation, we may be
2601 // taking the address of a function. In that case we need to
2602 // set the entry in the dynamic symbol table to the address of
2604 if (gsym
->is_from_dynobj() && !parameters
->options().shared())
2605 gsym
->set_needs_dynsym_value();
2607 // Make a dynamic relocation if necessary.
2608 if (gsym
->needs_dynamic_reloc(Scan::get_reference_flags(r_type
)))
2610 if (!parameters
->options().output_is_position_independent()
2611 && gsym
->may_need_copy_reloc())
2613 target
->copy_reloc(symtab
, layout
, object
,
2614 data_shndx
, output_section
, gsym
, reloc
);
2616 else if (((size
== 64 && r_type
== elfcpp::R_390_64
)
2617 || (size
== 32 && r_type
== elfcpp::R_390_32
))
2618 && gsym
->type() == elfcpp::STT_GNU_IFUNC
2619 && gsym
->can_use_relative_reloc(false)
2620 && !gsym
->is_from_dynobj()
2621 && !gsym
->is_undefined()
2622 && !gsym
->is_preemptible())
2624 // Use an IRELATIVE reloc for a locally defined
2625 // STT_GNU_IFUNC symbol. This makes a function
2626 // address in a PIE executable match the address in a
2627 // shared library that it links against.
2628 Reloc_section
* rela_dyn
=
2629 target
->rela_irelative_section(layout
);
2630 unsigned int r_type
= elfcpp::R_390_IRELATIVE
;
2631 rela_dyn
->add_symbolless_global_addend(gsym
, r_type
,
2632 output_section
, object
,
2634 reloc
.get_r_offset(),
2635 reloc
.get_r_addend());
2637 else if (((size
== 64 && r_type
== elfcpp::R_390_64
)
2638 || (size
== 32 && r_type
== elfcpp::R_390_32
))
2639 && gsym
->can_use_relative_reloc(false))
2641 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2642 rela_dyn
->add_global_relative(gsym
, elfcpp::R_390_RELATIVE
,
2643 output_section
, object
,
2645 reloc
.get_r_offset(),
2646 reloc
.get_r_addend(), false);
2650 check_non_pic(object
, r_type
);
2651 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2652 rela_dyn
->add_global(gsym
, r_type
, output_section
, object
,
2653 data_shndx
, reloc
.get_r_offset(),
2654 reloc
.get_r_addend());
2660 case elfcpp::R_390_PC12DBL
:
2661 case elfcpp::R_390_PC16
:
2662 case elfcpp::R_390_PC16DBL
:
2663 case elfcpp::R_390_PC24DBL
:
2664 case elfcpp::R_390_PC32
:
2665 case elfcpp::R_390_PC32DBL
:
2666 case elfcpp::R_390_PC64
:
2668 // Make a PLT entry if necessary.
2669 if (gsym
->needs_plt_entry())
2671 target
->make_plt_entry(symtab
, layout
, gsym
);
2672 // larl is often used to take address of a function. Aim the
2673 // symbol at the PLT entry.
2674 if (gsym
->is_from_dynobj() && !parameters
->options().shared())
2675 gsym
->set_needs_dynsym_value();
2677 // Make a dynamic relocation if necessary.
2678 if (gsym
->needs_dynamic_reloc(Scan::get_reference_flags(r_type
)))
2680 if (parameters
->options().output_is_executable()
2681 && gsym
->may_need_copy_reloc())
2683 target
->copy_reloc(symtab
, layout
, object
,
2684 data_shndx
, output_section
, gsym
, reloc
);
2688 check_non_pic(object
, r_type
);
2689 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2690 rela_dyn
->add_global(gsym
, r_type
, output_section
, object
,
2691 data_shndx
, reloc
.get_r_offset(),
2692 reloc
.get_r_addend());
2698 case elfcpp::R_390_PLT12DBL
:
2699 case elfcpp::R_390_PLT16DBL
:
2700 case elfcpp::R_390_PLT24DBL
:
2701 case elfcpp::R_390_PLT32
:
2702 case elfcpp::R_390_PLT32DBL
:
2703 case elfcpp::R_390_PLT64
:
2704 // If the symbol is fully resolved, this is just a PC32 reloc.
2705 // Otherwise we need a PLT entry.
2706 if (gsym
->final_value_is_known())
2708 // If building a shared library, we can also skip the PLT entry
2709 // if the symbol is defined in the output file and is protected
2711 if (gsym
->is_defined()
2712 && !gsym
->is_from_dynobj()
2713 && !gsym
->is_preemptible())
2715 target
->make_plt_entry(symtab
, layout
, gsym
);
2718 case elfcpp::R_390_GOTPC
:
2719 case elfcpp::R_390_GOTPCDBL
:
2720 case elfcpp::R_390_GOTOFF16
:
2721 case elfcpp::R_390_GOTOFF32
:
2722 case elfcpp::R_390_GOTOFF64
:
2723 case elfcpp::R_390_PLTOFF16
:
2724 case elfcpp::R_390_PLTOFF32
:
2725 case elfcpp::R_390_PLTOFF64
:
2726 // We need a GOT section.
2727 target
->got_section(symtab
, layout
);
2728 // For PLTOFF*, we also need a PLT entry (but only if the
2729 // symbol is not fully resolved).
2730 if ((r_type
== elfcpp::R_390_PLTOFF16
2731 || r_type
== elfcpp::R_390_PLTOFF32
2732 || r_type
== elfcpp::R_390_PLTOFF64
)
2733 && !gsym
->final_value_is_known())
2734 target
->make_plt_entry(symtab
, layout
, gsym
);
2737 case elfcpp::R_390_GOT12
:
2738 case elfcpp::R_390_GOT16
:
2739 case elfcpp::R_390_GOT20
:
2740 case elfcpp::R_390_GOT32
:
2741 case elfcpp::R_390_GOT64
:
2742 case elfcpp::R_390_GOTENT
:
2743 case elfcpp::R_390_GOTPLT12
:
2744 case elfcpp::R_390_GOTPLT16
:
2745 case elfcpp::R_390_GOTPLT20
:
2746 case elfcpp::R_390_GOTPLT32
:
2747 case elfcpp::R_390_GOTPLT64
:
2748 case elfcpp::R_390_GOTPLTENT
:
2750 // The symbol requires a GOT entry.
2751 Output_data_got
<size
, true>* got
= target
->got_section(symtab
, layout
);
2753 if (gsym
->final_value_is_known())
2755 // For a STT_GNU_IFUNC symbol we want the PLT address.
2756 if (gsym
->type() == elfcpp::STT_GNU_IFUNC
)
2757 got
->add_global_plt(gsym
, GOT_TYPE_STANDARD
);
2759 got
->add_global(gsym
, GOT_TYPE_STANDARD
);
2763 // If this symbol is not fully resolved, we need to add a
2764 // dynamic relocation for it.
2765 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2767 // Use a GLOB_DAT rather than a RELATIVE reloc if:
2769 // 1) The symbol may be defined in some other module.
2771 // 2) We are building a shared library and this is a
2772 // protected symbol; using GLOB_DAT means that the dynamic
2773 // linker can use the address of the PLT in the main
2774 // executable when appropriate so that function address
2775 // comparisons work.
2777 // 3) This is a STT_GNU_IFUNC symbol in position dependent
2778 // code, again so that function address comparisons work.
2779 if (gsym
->is_from_dynobj()
2780 || gsym
->is_undefined()
2781 || gsym
->is_preemptible()
2782 || (gsym
->visibility() == elfcpp::STV_PROTECTED
2783 && parameters
->options().shared())
2784 || (gsym
->type() == elfcpp::STT_GNU_IFUNC
2785 && parameters
->options().output_is_position_independent()))
2786 got
->add_global_with_rel(gsym
, GOT_TYPE_STANDARD
, rela_dyn
,
2787 elfcpp::R_390_GLOB_DAT
);
2790 // For a STT_GNU_IFUNC symbol we want to write the PLT
2791 // offset into the GOT, so that function pointer
2792 // comparisons work correctly.
2794 if (gsym
->type() != elfcpp::STT_GNU_IFUNC
)
2795 is_new
= got
->add_global(gsym
, GOT_TYPE_STANDARD
);
2798 is_new
= got
->add_global_plt(gsym
, GOT_TYPE_STANDARD
);
2799 // Tell the dynamic linker to use the PLT address
2800 // when resolving relocations.
2801 if (gsym
->is_from_dynobj()
2802 && !parameters
->options().shared())
2803 gsym
->set_needs_dynsym_value();
2807 unsigned int got_off
= gsym
->got_offset(GOT_TYPE_STANDARD
);
2808 rela_dyn
->add_global_relative(gsym
,
2809 elfcpp::R_390_RELATIVE
,
2810 got
, got_off
, 0, false);
2817 case elfcpp::R_390_COPY
:
2818 case elfcpp::R_390_GLOB_DAT
:
2819 case elfcpp::R_390_JMP_SLOT
:
2820 case elfcpp::R_390_RELATIVE
:
2821 case elfcpp::R_390_IRELATIVE
:
2822 // These are outstanding tls relocs, which are unexpected when linking
2823 case elfcpp::R_390_TLS_TPOFF
:
2824 case elfcpp::R_390_TLS_DTPOFF
:
2825 case elfcpp::R_390_TLS_DTPMOD
:
2826 gold_error(_("%s: unexpected reloc %u in object file"),
2827 object
->name().c_str(), r_type
);
2830 // These are initial tls relocs, which are expected for global()
2831 case elfcpp::R_390_TLS_GD32
: // Global-dynamic
2832 case elfcpp::R_390_TLS_GD64
:
2833 case elfcpp::R_390_TLS_GDCALL
:
2834 case elfcpp::R_390_TLS_LDM32
: // Local-dynamic
2835 case elfcpp::R_390_TLS_LDM64
:
2836 case elfcpp::R_390_TLS_LDO32
:
2837 case elfcpp::R_390_TLS_LDO64
:
2838 case elfcpp::R_390_TLS_LDCALL
:
2839 case elfcpp::R_390_TLS_IE32
: // Initial-exec
2840 case elfcpp::R_390_TLS_IE64
:
2841 case elfcpp::R_390_TLS_IEENT
:
2842 case elfcpp::R_390_TLS_GOTIE12
:
2843 case elfcpp::R_390_TLS_GOTIE20
:
2844 case elfcpp::R_390_TLS_GOTIE32
:
2845 case elfcpp::R_390_TLS_GOTIE64
:
2846 case elfcpp::R_390_TLS_LOAD
:
2847 case elfcpp::R_390_TLS_LE32
: // Local-exec
2848 case elfcpp::R_390_TLS_LE64
:
2850 // For the optimizable Initial-Exec model, we can treat undef symbols
2851 // as final when building an executable.
2852 const bool is_final
= (gsym
->final_value_is_known() ||
2853 ((r_type
== elfcpp::R_390_TLS_IE32
||
2854 r_type
== elfcpp::R_390_TLS_IE64
||
2855 r_type
== elfcpp::R_390_TLS_GOTIE32
||
2856 r_type
== elfcpp::R_390_TLS_GOTIE64
) &&
2857 gsym
->is_undefined() &&
2858 parameters
->options().output_is_executable()));
2859 const tls::Tls_optimization optimized_type
2860 = Target_s390
<size
>::optimize_tls_reloc(is_final
, r_type
);
2863 case elfcpp::R_390_TLS_GD32
: // General-dynamic
2864 case elfcpp::R_390_TLS_GD64
:
2865 case elfcpp::R_390_TLS_GDCALL
:
2866 if (optimized_type
== tls::TLSOPT_NONE
)
2868 // Create a pair of GOT entries for the module index and
2869 // dtv-relative offset.
2870 Output_data_got
<size
, true>* got
2871 = target
->got_section(symtab
, layout
);
2872 got
->add_global_pair_with_rel(gsym
, GOT_TYPE_TLS_PAIR
,
2873 target
->rela_dyn_section(layout
),
2874 elfcpp::R_390_TLS_DTPMOD
,
2875 elfcpp::R_390_TLS_DTPOFF
);
2877 else if (optimized_type
== tls::TLSOPT_TO_IE
)
2879 // Create a GOT entry for the tp-relative offset.
2880 Output_data_got
<size
, true>* got
2881 = target
->got_section(symtab
, layout
);
2882 got
->add_global_with_rel(gsym
, GOT_TYPE_TLS_OFFSET
,
2883 target
->rela_dyn_section(layout
),
2884 elfcpp::R_390_TLS_TPOFF
);
2886 else if (optimized_type
!= tls::TLSOPT_TO_LE
)
2887 unsupported_reloc_global(object
, r_type
, gsym
);
2890 case elfcpp::R_390_TLS_LDM32
: // Local-dynamic
2891 case elfcpp::R_390_TLS_LDM64
:
2892 case elfcpp::R_390_TLS_LDCALL
:
2893 if (optimized_type
== tls::TLSOPT_NONE
)
2895 // Create a GOT entry for the module index.
2896 target
->got_mod_index_entry(symtab
, layout
, object
);
2898 else if (optimized_type
!= tls::TLSOPT_TO_LE
)
2899 unsupported_reloc_global(object
, r_type
, gsym
);
2902 case elfcpp::R_390_TLS_LDO32
:
2903 case elfcpp::R_390_TLS_LDO64
:
2906 case elfcpp::R_390_TLS_IE32
: // Initial-exec
2907 case elfcpp::R_390_TLS_IE64
:
2908 // These two involve an absolute address
2909 if (parameters
->options().shared())
2911 if ((size
== 32 && r_type
== elfcpp::R_390_TLS_IE32
) ||
2912 (size
== 64 && r_type
== elfcpp::R_390_TLS_IE64
))
2914 // We need to create a dynamic relocation.
2915 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2916 rela_dyn
->add_global_relative(gsym
, elfcpp::R_390_RELATIVE
,
2917 output_section
, object
,
2919 reloc
.get_r_offset(),
2920 reloc
.get_r_addend(), false);
2924 unsupported_reloc_global(object
, r_type
, gsym
);
2928 case elfcpp::R_390_TLS_IEENT
:
2929 case elfcpp::R_390_TLS_GOTIE12
:
2930 case elfcpp::R_390_TLS_GOTIE20
:
2931 case elfcpp::R_390_TLS_GOTIE32
:
2932 case elfcpp::R_390_TLS_GOTIE64
:
2933 case elfcpp::R_390_TLS_LOAD
:
2934 layout
->set_has_static_tls();
2935 if (optimized_type
== tls::TLSOPT_NONE
)
2937 if (is_final
&& !parameters
->options().shared())
2939 // We're making an executable, and the symbol is local, but
2940 // we cannot optimize to LE. Make a const GOT entry instead.
2941 Output_data_got
<size
, true>* got
2942 = target
->got_section(symtab
, layout
);
2943 got
->add_global_plt(gsym
, GOT_TYPE_TLS_OFFSET
);
2947 // Create a GOT entry for the tp-relative offset.
2948 Output_data_got
<size
, true>* got
2949 = target
->got_section(symtab
, layout
);
2950 got
->add_global_with_rel(gsym
, GOT_TYPE_TLS_OFFSET
,
2951 target
->rela_dyn_section(layout
),
2952 elfcpp::R_390_TLS_TPOFF
);
2955 else if (optimized_type
!= tls::TLSOPT_TO_LE
)
2956 unsupported_reloc_global(object
, r_type
, gsym
);
2959 case elfcpp::R_390_TLS_LE32
: // Local-exec
2960 case elfcpp::R_390_TLS_LE64
:
2961 layout
->set_has_static_tls();
2962 if (parameters
->options().shared())
2964 // We need to create a dynamic relocation.
2965 if ((size
== 32 && r_type
== elfcpp::R_390_TLS_LE32
) ||
2966 (size
== 64 && r_type
== elfcpp::R_390_TLS_LE64
))
2968 Reloc_section
* rela_dyn
= target
->rela_dyn_section(layout
);
2969 rela_dyn
->add_global(gsym
, elfcpp::R_390_TLS_TPOFF
,
2970 output_section
, object
,
2971 data_shndx
, reloc
.get_r_offset(),
2972 reloc
.get_r_addend());
2976 unsupported_reloc_global(object
, r_type
, gsym
);
2988 gold_error(_("%s: unsupported reloc %u against global symbol %s"),
2989 object
->name().c_str(), r_type
,
2990 gsym
->demangled_name().c_str());
2996 // Report an unsupported relocation against a global symbol.
3000 Target_s390
<size
>::Scan::unsupported_reloc_global(
3001 Sized_relobj_file
<size
, true>* object
,
3002 unsigned int r_type
,
3005 gold_error(_("%s: unsupported reloc %u against global symbol %s"),
3006 object
->name().c_str(), r_type
, gsym
->demangled_name().c_str());
3009 // Returns true if this relocation type could be that of a function pointer.
3012 Target_s390
<size
>::Scan::possible_function_pointer_reloc(unsigned int r_type
)
3016 case elfcpp::R_390_32
:
3017 case elfcpp::R_390_64
:
3018 case elfcpp::R_390_PC32DBL
: // could be used by larl insn
3019 case elfcpp::R_390_GOT12
:
3020 case elfcpp::R_390_GOT16
:
3021 case elfcpp::R_390_GOT20
:
3022 case elfcpp::R_390_GOT32
:
3023 case elfcpp::R_390_GOT64
:
3024 case elfcpp::R_390_GOTENT
:
3025 case elfcpp::R_390_GOTOFF16
:
3026 case elfcpp::R_390_GOTOFF32
:
3027 case elfcpp::R_390_GOTOFF64
:
3033 // For safe ICF, scan a relocation for a local symbol to check if it
3034 // corresponds to a function pointer being taken. In that case mark
3035 // the function whose pointer was taken as not foldable.
3039 Target_s390
<size
>::Scan::local_reloc_may_be_function_pointer(
3042 Target_s390
<size
>* ,
3043 Sized_relobj_file
<size
, true>* ,
3046 const elfcpp::Rela
<size
, true>& ,
3047 unsigned int r_type
,
3048 const elfcpp::Sym
<size
, true>&)
3050 // When building a shared library, do not fold any local symbols.
3051 return (parameters
->options().shared()
3052 || possible_function_pointer_reloc(r_type
));
3055 // For safe ICF, scan a relocation for a global symbol to check if it
3056 // corresponds to a function pointer being taken. In that case mark
3057 // the function whose pointer was taken as not foldable.
3061 Target_s390
<size
>::Scan::global_reloc_may_be_function_pointer(
3064 Target_s390
<size
>* ,
3065 Sized_relobj_file
<size
, true>* ,
3068 const elfcpp::Rela
<size
, true>& ,
3069 unsigned int r_type
,
3072 // When building a shared library, do not fold symbols whose visibility
3073 // is hidden, internal or protected.
3074 return ((parameters
->options().shared()
3075 && (gsym
->visibility() == elfcpp::STV_INTERNAL
3076 || gsym
->visibility() == elfcpp::STV_PROTECTED
3077 || gsym
->visibility() == elfcpp::STV_HIDDEN
))
3078 || possible_function_pointer_reloc(r_type
));
3083 Target_s390
<size
>::gc_process_relocs(Symbol_table
* symtab
,
3085 Sized_relobj_file
<size
, true>* object
,
3086 unsigned int data_shndx
,
3087 unsigned int sh_type
,
3088 const unsigned char* prelocs
,
3090 Output_section
* output_section
,
3091 bool needs_special_offset_handling
,
3092 size_t local_symbol_count
,
3093 const unsigned char* plocal_symbols
)
3095 typedef gold::Default_classify_reloc
<elfcpp::SHT_RELA
, size
, true>
3098 if (sh_type
== elfcpp::SHT_REL
)
3101 gold::gc_process_relocs
<size
, true, Target_s390
<size
>, Scan
, Classify_reloc
>(
3110 needs_special_offset_handling
,
3115 // Perform a relocation.
3119 Target_s390
<size
>::Relocate::relocate(
3120 const Relocate_info
<size
, true>* relinfo
,
3122 Target_s390
<size
>* target
,
3125 const unsigned char* preloc
,
3126 const Sized_symbol
<size
>* gsym
,
3127 const Symbol_value
<size
>* psymval
,
3128 unsigned char* view
,
3129 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
3130 section_size_type view_size
)
3135 const elfcpp::Rela
<size
, true> rela(preloc
);
3136 unsigned int r_type
= elfcpp::elf_r_type
<size
>(rela
.get_r_info());
3137 const Sized_relobj_file
<size
, true>* object
= relinfo
->object
;
3139 // Pick the value to use for symbols defined in the PLT.
3140 Symbol_value
<size
> symval
;
3142 && gsym
->use_plt_offset(Scan::get_reference_flags(r_type
)))
3144 symval
.set_output_value(target
->plt_address_for_global(gsym
));
3147 else if (gsym
== NULL
&& psymval
->is_ifunc_symbol())
3149 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
3150 if (object
->local_has_plt_offset(r_sym
))
3152 symval
.set_output_value(target
->plt_address_for_local(object
, r_sym
));
3157 const elfcpp::Elf_Xword addend
= rela
.get_r_addend();
3159 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
= 0;
3163 case elfcpp::R_390_PLT64
:
3164 case elfcpp::R_390_PLT32
:
3165 case elfcpp::R_390_PLT32DBL
:
3166 case elfcpp::R_390_PLT24DBL
:
3167 case elfcpp::R_390_PLT16DBL
:
3168 case elfcpp::R_390_PLT12DBL
:
3169 gold_assert(gsym
== NULL
3170 || gsym
->has_plt_offset()
3171 || gsym
->final_value_is_known()
3172 || (gsym
->is_defined()
3173 && !gsym
->is_from_dynobj()
3174 && !gsym
->is_preemptible()));
3176 case elfcpp::R_390_8
:
3177 case elfcpp::R_390_12
:
3178 case elfcpp::R_390_16
:
3179 case elfcpp::R_390_20
:
3180 case elfcpp::R_390_32
:
3181 case elfcpp::R_390_64
:
3182 case elfcpp::R_390_PC16
:
3183 case elfcpp::R_390_PC32
:
3184 case elfcpp::R_390_PC64
:
3185 case elfcpp::R_390_PC32DBL
:
3186 case elfcpp::R_390_PC24DBL
:
3187 case elfcpp::R_390_PC16DBL
:
3188 case elfcpp::R_390_PC12DBL
:
3189 value
= psymval
->value(object
, addend
);
3192 case elfcpp::R_390_GOTPC
:
3193 case elfcpp::R_390_GOTPCDBL
:
3194 gold_assert(gsym
!= NULL
);
3195 value
= target
->got_address() + addend
;
3198 case elfcpp::R_390_PLTOFF64
:
3199 case elfcpp::R_390_PLTOFF32
:
3200 case elfcpp::R_390_PLTOFF16
:
3201 gold_assert(gsym
== NULL
3202 || gsym
->has_plt_offset()
3203 || gsym
->final_value_is_known());
3205 case elfcpp::R_390_GOTOFF64
:
3206 case elfcpp::R_390_GOTOFF32
:
3207 case elfcpp::R_390_GOTOFF16
:
3208 value
= (psymval
->value(object
, addend
)
3209 - target
->got_address());
3212 case elfcpp::R_390_GOT12
:
3213 case elfcpp::R_390_GOT16
:
3214 case elfcpp::R_390_GOT20
:
3215 case elfcpp::R_390_GOT32
:
3216 case elfcpp::R_390_GOT64
:
3217 case elfcpp::R_390_GOTENT
:
3218 case elfcpp::R_390_GOTPLT12
:
3219 case elfcpp::R_390_GOTPLT16
:
3220 case elfcpp::R_390_GOTPLT20
:
3221 case elfcpp::R_390_GOTPLT32
:
3222 case elfcpp::R_390_GOTPLT64
:
3223 case elfcpp::R_390_GOTPLTENT
:
3225 unsigned int got_offset
= 0;
3228 gold_assert(gsym
->has_got_offset(GOT_TYPE_STANDARD
));
3229 got_offset
= gsym
->got_offset(GOT_TYPE_STANDARD
);
3233 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
3234 gold_assert(object
->local_has_got_offset(r_sym
, GOT_TYPE_STANDARD
));
3235 got_offset
= object
->local_got_offset(r_sym
, GOT_TYPE_STANDARD
);
3237 value
= got_offset
+ target
->got_main_offset() + addend
;
3241 // These are initial tls relocs, which are expected when linking
3242 case elfcpp::R_390_TLS_LOAD
:
3243 case elfcpp::R_390_TLS_GDCALL
: // Global-dynamic
3244 case elfcpp::R_390_TLS_GD32
:
3245 case elfcpp::R_390_TLS_GD64
:
3246 case elfcpp::R_390_TLS_LDCALL
: // Local-dynamic
3247 case elfcpp::R_390_TLS_LDM32
:
3248 case elfcpp::R_390_TLS_LDM64
:
3249 case elfcpp::R_390_TLS_LDO32
:
3250 case elfcpp::R_390_TLS_LDO64
:
3251 case elfcpp::R_390_TLS_GOTIE12
: // Initial-exec
3252 case elfcpp::R_390_TLS_GOTIE20
:
3253 case elfcpp::R_390_TLS_GOTIE32
:
3254 case elfcpp::R_390_TLS_GOTIE64
:
3255 case elfcpp::R_390_TLS_IE32
:
3256 case elfcpp::R_390_TLS_IE64
:
3257 case elfcpp::R_390_TLS_IEENT
:
3258 case elfcpp::R_390_TLS_LE32
: // Local-exec
3259 case elfcpp::R_390_TLS_LE64
:
3260 value
= this->relocate_tls(relinfo
, target
, relnum
, rela
, r_type
, gsym
, psymval
,
3268 typename S390_relocate_functions
<size
>::Status status
3269 = S390_relocate_functions
<size
>::STATUS_OK
;
3273 case elfcpp::R_390_NONE
:
3274 case elfcpp::R_390_GNU_VTINHERIT
:
3275 case elfcpp::R_390_GNU_VTENTRY
:
3276 case elfcpp::R_390_TLS_GDCALL
:
3277 case elfcpp::R_390_TLS_LDCALL
:
3278 case elfcpp::R_390_TLS_LOAD
:
3281 case elfcpp::R_390_64
:
3282 case elfcpp::R_390_GOT64
:
3283 case elfcpp::R_390_GOTPLT64
:
3284 case elfcpp::R_390_PLTOFF64
:
3285 case elfcpp::R_390_GOTOFF64
:
3286 case elfcpp::R_390_TLS_GD64
:
3287 case elfcpp::R_390_TLS_LDM64
:
3288 case elfcpp::R_390_TLS_LDO64
:
3289 case elfcpp::R_390_TLS_GOTIE64
:
3290 case elfcpp::R_390_TLS_IE64
:
3291 case elfcpp::R_390_TLS_LE64
:
3292 Relocate_functions
<size
, true>::rela64(view
, value
, 0);
3295 case elfcpp::R_390_32
:
3296 case elfcpp::R_390_GOT32
:
3297 case elfcpp::R_390_GOTPLT32
:
3298 case elfcpp::R_390_PLTOFF32
:
3299 case elfcpp::R_390_GOTOFF32
:
3300 case elfcpp::R_390_TLS_GD32
:
3301 case elfcpp::R_390_TLS_LDM32
:
3302 case elfcpp::R_390_TLS_LDO32
:
3303 case elfcpp::R_390_TLS_GOTIE32
:
3304 case elfcpp::R_390_TLS_IE32
:
3305 case elfcpp::R_390_TLS_LE32
:
3306 Relocate_functions
<size
, true>::rela32(view
, value
, 0);
3309 case elfcpp::R_390_20
:
3310 case elfcpp::R_390_GOT20
:
3311 case elfcpp::R_390_GOTPLT20
:
3312 case elfcpp::R_390_TLS_GOTIE20
:
3313 status
= S390_relocate_functions
<size
>::rela20(view
, value
);
3316 case elfcpp::R_390_16
:
3317 case elfcpp::R_390_GOT16
:
3318 case elfcpp::R_390_GOTPLT16
:
3319 case elfcpp::R_390_PLTOFF16
:
3320 case elfcpp::R_390_GOTOFF16
:
3321 status
= S390_relocate_functions
<size
>::rela16(view
, value
);
3324 case elfcpp::R_390_12
:
3325 case elfcpp::R_390_GOT12
:
3326 case elfcpp::R_390_GOTPLT12
:
3327 case elfcpp::R_390_TLS_GOTIE12
:
3328 status
= S390_relocate_functions
<size
>::rela12(view
, value
);
3331 case elfcpp::R_390_8
:
3332 Relocate_functions
<size
, true>::rela8(view
, value
, 0);
3335 case elfcpp::R_390_PC16
:
3336 Relocate_functions
<size
, true>::pcrela16(view
, value
, 0,
3340 case elfcpp::R_390_PLT64
:
3341 case elfcpp::R_390_PC64
:
3342 Relocate_functions
<size
, true>::pcrela64(view
, value
, 0, address
);
3345 case elfcpp::R_390_PLT32
:
3346 case elfcpp::R_390_PC32
:
3347 case elfcpp::R_390_GOTPC
:
3348 Relocate_functions
<size
, true>::pcrela32(view
, value
, 0, address
);
3351 case elfcpp::R_390_PLT32DBL
:
3352 case elfcpp::R_390_PC32DBL
:
3353 case elfcpp::R_390_GOTPCDBL
:
3354 status
= S390_relocate_functions
<size
>::pcrela32dbl(view
, value
, address
);
3357 case elfcpp::R_390_PLT24DBL
:
3358 case elfcpp::R_390_PC24DBL
:
3359 status
= S390_relocate_functions
<size
>::pcrela24dbl(view
, value
, address
);
3362 case elfcpp::R_390_PLT16DBL
:
3363 case elfcpp::R_390_PC16DBL
:
3364 status
= S390_relocate_functions
<size
>::pcrela16dbl(view
, value
, address
);
3367 case elfcpp::R_390_PLT12DBL
:
3368 case elfcpp::R_390_PC12DBL
:
3369 status
= S390_relocate_functions
<size
>::pcrela12dbl(view
, value
, address
);
3372 case elfcpp::R_390_GOTENT
:
3373 case elfcpp::R_390_GOTPLTENT
:
3374 case elfcpp::R_390_TLS_IEENT
:
3375 value
+= target
->got_address();
3376 status
= S390_relocate_functions
<size
>::pcrela32dbl(view
, value
, address
);
3379 case elfcpp::R_390_COPY
:
3380 case elfcpp::R_390_GLOB_DAT
:
3381 case elfcpp::R_390_JMP_SLOT
:
3382 case elfcpp::R_390_RELATIVE
:
3383 case elfcpp::R_390_IRELATIVE
:
3384 // These are outstanding tls relocs, which are unexpected when linking
3385 case elfcpp::R_390_TLS_TPOFF
:
3386 case elfcpp::R_390_TLS_DTPMOD
:
3387 case elfcpp::R_390_TLS_DTPOFF
:
3388 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3389 _("unexpected reloc %u in object file"),
3394 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3395 _("unsupported reloc %u"),
3400 if (status
!= S390_relocate_functions
<size
>::STATUS_OK
)
3402 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3403 _("relocation overflow"));
3409 // Perform a TLS relocation.
3412 inline typename
elfcpp::Elf_types
<size
>::Elf_Addr
3413 Target_s390
<size
>::Relocate::relocate_tls(
3414 const Relocate_info
<size
, true>* relinfo
,
3415 Target_s390
<size
>* target
,
3417 const elfcpp::Rela
<size
, true>& rela
,
3418 unsigned int r_type
,
3419 const Sized_symbol
<size
>* gsym
,
3420 const Symbol_value
<size
>* psymval
,
3421 unsigned char* view
,
3422 section_size_type view_size
)
3424 Output_segment
* tls_segment
= relinfo
->layout
->tls_segment();
3426 const Sized_relobj_file
<size
, true>* object
= relinfo
->object
;
3427 const elfcpp::Elf_Xword addend
= rela
.get_r_addend();
3428 elfcpp::Shdr
<size
, true> data_shdr(relinfo
->data_shdr
);
3429 bool is_allocatable
= (data_shdr
.get_sh_flags() & elfcpp::SHF_ALLOC
) != 0;
3431 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
3432 = psymval
->value(relinfo
->object
, addend
);
3434 const bool is_final
= (gsym
== NULL
3435 ? !parameters
->options().shared()
3436 : gsym
->final_value_is_known());
3437 tls::Tls_optimization optimized_type
3438 = Target_s390
<size
>::optimize_tls_reloc(is_final
, r_type
);
3441 case elfcpp::R_390_TLS_GDCALL
: // Global-dynamic marker
3442 if (optimized_type
== tls::TLSOPT_TO_LE
)
3444 if (tls_segment
== NULL
)
3446 gold_assert(parameters
->errors()->error_count() > 0
3447 || issue_undefined_symbol_error(gsym
));
3450 this->tls_gd_to_le(relinfo
, relnum
, rela
, view
, view_size
);
3455 if (optimized_type
== tls::TLSOPT_TO_IE
)
3457 this->tls_gd_to_ie(relinfo
, relnum
, rela
, view
, view_size
);
3460 else if (optimized_type
== tls::TLSOPT_NONE
)
3465 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3466 _("unsupported reloc %u"), r_type
);
3469 case elfcpp::R_390_TLS_GD32
: // Global-dynamic
3470 case elfcpp::R_390_TLS_GD64
:
3471 if (optimized_type
== tls::TLSOPT_TO_LE
)
3473 if (tls_segment
== NULL
)
3475 gold_assert(parameters
->errors()->error_count() > 0
3476 || issue_undefined_symbol_error(gsym
));
3479 return value
- tls_segment
->memsz();
3483 unsigned int got_type
= (optimized_type
== tls::TLSOPT_TO_IE
3484 ? GOT_TYPE_TLS_OFFSET
3485 : GOT_TYPE_TLS_PAIR
);
3488 gold_assert(gsym
->has_got_offset(got_type
));
3489 return (gsym
->got_offset(got_type
)
3490 + target
->got_main_offset()
3495 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
3496 gold_assert(object
->local_has_got_offset(r_sym
, got_type
));
3497 return (object
->local_got_offset(r_sym
, got_type
)
3498 + target
->got_main_offset()
3502 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3503 _("unsupported reloc %u"), r_type
);
3506 case elfcpp::R_390_TLS_LDCALL
: // Local-dynamic marker
3507 // This is a marker relocation. If the sequence is being turned to LE,
3508 // we modify the instruction, otherwise the instruction is untouched.
3509 if (optimized_type
== tls::TLSOPT_TO_LE
)
3511 if (tls_segment
== NULL
)
3513 gold_assert(parameters
->errors()->error_count() > 0
3514 || issue_undefined_symbol_error(gsym
));
3517 this->tls_ld_to_le(relinfo
, relnum
, rela
, view
, view_size
);
3520 else if (optimized_type
== tls::TLSOPT_NONE
)
3524 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3525 _("unsupported reloc %u"), r_type
);
3528 case elfcpp::R_390_TLS_LDM32
: // Local-dynamic module
3529 case elfcpp::R_390_TLS_LDM64
:
3530 if (optimized_type
== tls::TLSOPT_TO_LE
)
3532 if (tls_segment
== NULL
)
3534 gold_assert(parameters
->errors()->error_count() > 0
3535 || issue_undefined_symbol_error(gsym
));
3538 // Doesn't matter what we fill it with - it's going to be unused.
3541 else if (optimized_type
== tls::TLSOPT_NONE
)
3543 // Relocate the field with the offset of the GOT entry for
3544 // the module index.
3545 return (target
->got_mod_index_entry(NULL
, NULL
, NULL
)
3547 + target
->got_main_offset());
3549 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3550 _("unsupported reloc %u"), r_type
);
3553 case elfcpp::R_390_TLS_LDO32
: // Local-dynamic offset
3554 case elfcpp::R_390_TLS_LDO64
:
3555 // This relocation type is used in debugging information.
3556 // In that case we need to not optimize the value. If the
3557 // section is not allocatable, then we assume we should not
3558 // optimize this reloc.
3559 if (optimized_type
== tls::TLSOPT_TO_LE
&& is_allocatable
)
3561 if (tls_segment
== NULL
)
3563 gold_assert(parameters
->errors()->error_count() > 0
3564 || issue_undefined_symbol_error(gsym
));
3567 value
-= tls_segment
->memsz();
3571 case elfcpp::R_390_TLS_LOAD
: // Initial-exec marker
3572 // This is a marker relocation. If the sequence is being turned to LE,
3573 // we modify the instruction, otherwise the instruction is untouched.
3575 && gsym
->is_undefined()
3576 && parameters
->options().output_is_executable())
3578 Target_s390
<size
>::Relocate::tls_ie_to_le(relinfo
, relnum
,
3583 else if (optimized_type
== tls::TLSOPT_TO_LE
)
3585 if (tls_segment
== NULL
)
3587 gold_assert(parameters
->errors()->error_count() > 0
3588 || issue_undefined_symbol_error(gsym
));
3591 Target_s390
<size
>::Relocate::tls_ie_to_le(relinfo
, relnum
,
3596 else if (optimized_type
== tls::TLSOPT_NONE
)
3600 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3601 _("unsupported reloc type %u"),
3605 case elfcpp::R_390_TLS_GOTIE12
: // Initial-exec, not optimizable
3606 case elfcpp::R_390_TLS_GOTIE20
:
3607 case elfcpp::R_390_TLS_IEENT
:
3608 case elfcpp::R_390_TLS_GOTIE32
: // Initial-exec, optimizable
3609 case elfcpp::R_390_TLS_GOTIE64
:
3610 case elfcpp::R_390_TLS_IE32
:
3611 case elfcpp::R_390_TLS_IE64
:
3613 && gsym
->is_undefined()
3614 && parameters
->options().output_is_executable()
3615 // These three cannot be optimized to LE, no matter what
3616 && r_type
!= elfcpp::R_390_TLS_GOTIE12
3617 && r_type
!= elfcpp::R_390_TLS_GOTIE20
3618 && r_type
!= elfcpp::R_390_TLS_IEENT
)
3622 else if (optimized_type
== tls::TLSOPT_TO_LE
)
3624 if (tls_segment
== NULL
)
3626 gold_assert(parameters
->errors()->error_count() > 0
3627 || issue_undefined_symbol_error(gsym
));
3630 return value
- tls_segment
->memsz();
3632 else if (optimized_type
== tls::TLSOPT_NONE
)
3634 // Relocate the field with the offset of the GOT entry for
3635 // the tp-relative offset of the symbol.
3636 unsigned int got_offset
;
3639 gold_assert(gsym
->has_got_offset(GOT_TYPE_TLS_OFFSET
));
3640 got_offset
= gsym
->got_offset(GOT_TYPE_TLS_OFFSET
);
3644 unsigned int r_sym
= elfcpp::elf_r_sym
<size
>(rela
.get_r_info());
3645 gold_assert(object
->local_has_got_offset(r_sym
,
3646 GOT_TYPE_TLS_OFFSET
));
3647 got_offset
= object
->local_got_offset(r_sym
, GOT_TYPE_TLS_OFFSET
);
3649 got_offset
+= target
->got_main_offset();
3650 if (r_type
== elfcpp::R_390_TLS_IE32
3651 || r_type
== elfcpp::R_390_TLS_IE64
)
3652 return target
->got_address() + got_offset
+ addend
;
3654 return got_offset
+ addend
;
3656 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3657 _("unsupported reloc type %u"),
3661 case elfcpp::R_390_TLS_LE32
: // Local-exec
3662 case elfcpp::R_390_TLS_LE64
:
3663 if (tls_segment
== NULL
)
3665 gold_assert(parameters
->errors()->error_count() > 0
3666 || issue_undefined_symbol_error(gsym
));
3669 return value
- tls_segment
->memsz();
3674 // Do a relocation in which we convert a TLS General-Dynamic to an
3679 Target_s390
<size
>::Relocate::tls_gd_to_ie(
3680 const Relocate_info
<size
, true>* relinfo
,
3682 const elfcpp::Rela
<size
, true>& rela
,
3683 unsigned char* view
,
3684 section_size_type view_size
)
3686 tls::check_range(relinfo
, relnum
, rela
.get_r_offset(), view_size
, 4);
3687 if (view
[0] == 0x4d)
3689 // bas, don't care about details
3690 // Change to l %r2, 0(%r2, %r12)
3697 else if (view
[0] == 0xc0)
3699 tls::check_range(relinfo
, relnum
, rela
.get_r_offset(), view_size
, 6);
3700 // brasl %r14, __tls_get_offset@plt
3701 if (view
[1] == 0xe5)
3703 // Change to l/lg %r2, 0(%r2, %r12)
3704 // There was a PLT32DBL reloc at the last 4 bytes, overwrite its result.
3729 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3730 _("unsupported op for GD to IE"));
3733 // Do a relocation in which we convert a TLS General-Dynamic to a
3738 Target_s390
<size
>::Relocate::tls_gd_to_le(
3739 const Relocate_info
<size
, true>* relinfo
,
3741 const elfcpp::Rela
<size
, true>& rela
,
3742 unsigned char* view
,
3743 section_size_type view_size
)
3745 tls::check_range(relinfo
, relnum
, rela
.get_r_offset(), view_size
, 2);
3746 if (view
[0] == 0x0d)
3748 // basr, change to nop
3752 else if (view
[0] == 0x4d)
3754 tls::check_range(relinfo
, relnum
, rela
.get_r_offset(), view_size
, 4);
3755 // bas, don't care about details, change to nop
3762 else if (view
[0] == 0xc0)
3764 tls::check_range(relinfo
, relnum
, rela
.get_r_offset(), view_size
, 6);
3765 // brasl %r14, __tls_get_offset@plt
3766 if (view
[1] == 0xe5)
3768 // Change to nop jump. There was a PLT32DBL reloc at the last
3769 // 4 bytes, overwrite its result.
3778 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3779 _("unsupported op for GD to LE"));
3784 Target_s390
<size
>::Relocate::tls_ld_to_le(
3785 const Relocate_info
<size
, true>* relinfo
,
3787 const elfcpp::Rela
<size
, true>& rela
,
3788 unsigned char* view
,
3789 section_size_type view_size
)
3791 tls::check_range(relinfo
, relnum
, rela
.get_r_offset(), view_size
, 4);
3793 if (view
[0] == 0x0d)
3795 // basr, change to nop
3799 else if (view
[0] == 0x4d)
3801 // bas, don't care about details, change to nop
3808 else if (view
[0] == 0xc0)
3810 tls::check_range(relinfo
, relnum
, rela
.get_r_offset(), view_size
, 6);
3811 // brasl %r14, __tls_get_offset@plt
3812 if (view
[1] == 0xe5)
3814 // Change to nop jump. There was a PLT32DBL reloc at the last
3815 // 4 bytes, overwrite its result.
3824 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3825 _("unsupported op for LD to LE"));
3828 // Do a relocation in which we convert a TLS Initial-Exec to a
3833 Target_s390
<size
>::Relocate::tls_ie_to_le(
3834 const Relocate_info
<size
, true>* relinfo
,
3836 const elfcpp::Rela
<size
, true>& rela
,
3837 unsigned char* view
,
3838 section_size_type view_size
)
3840 tls::check_range(relinfo
, relnum
, rela
.get_r_offset(), view_size
, 4);
3842 if (view
[0] == 0x58)
3844 // l %rX, 0(%rY) or l %rX, 0(%rY, %r12)
3845 if ((view
[2] & 0x0f) != 0 || view
[3] != 0)
3847 int rx
= view
[1] >> 4 & 0xf;
3848 int ry
= view
[1] & 0xf;
3849 int rz
= view
[2] >> 4 & 0xf;
3868 view
[1] = rx
<< 4 | ry
;
3873 else if (view
[0] == 0xe3)
3875 tls::check_range(relinfo
, relnum
, rela
.get_r_offset(), view_size
, 6);
3876 // lg %rX, 0(%rY) or lg %rX, 0(%rY, %r12)
3877 if ((view
[2] & 0x0f) != 0 ||
3882 int rx
= view
[1] >> 4 & 0xf;
3883 int ry
= view
[1] & 0xf;
3884 int rz
= view
[2] >> 4 & 0xf;
3901 // to sllg %rX, $rY, 0
3903 view
[1] = rx
<< 4 | ry
;
3912 gold_error_at_location(relinfo
, relnum
, rela
.get_r_offset(),
3913 _("unsupported op for IE to LE"));
3917 // Scan relocations for a section.
3921 Target_s390
<size
>::scan_relocs(Symbol_table
* symtab
,
3923 Sized_relobj_file
<size
, true>* object
,
3924 unsigned int data_shndx
,
3925 unsigned int sh_type
,
3926 const unsigned char* prelocs
,
3928 Output_section
* output_section
,
3929 bool needs_special_offset_handling
,
3930 size_t local_symbol_count
,
3931 const unsigned char* plocal_symbols
)
3933 typedef gold::Default_classify_reloc
<elfcpp::SHT_RELA
, size
, true>
3936 if (sh_type
== elfcpp::SHT_REL
)
3938 gold_error(_("%s: unsupported REL reloc section"),
3939 object
->name().c_str());
3943 gold::scan_relocs
<size
, true, Target_s390
<size
>, Scan
, Classify_reloc
>(
3952 needs_special_offset_handling
,
3957 // Finalize the sections.
3961 Target_s390
<size
>::do_finalize_sections(
3963 const Input_objects
*,
3964 Symbol_table
* symtab
)
3966 const Reloc_section
* rel_plt
= (this->plt_
== NULL
3968 : this->plt_
->rela_plt());
3969 layout
->add_target_dynamic_tags(false, this->got_plt_
, rel_plt
,
3970 this->rela_dyn_
, true, size
== 32);
3972 this->layout_
= layout
;
3974 // Emit any relocs we saved in an attempt to avoid generating COPY
3976 if (this->copy_relocs_
.any_saved_relocs())
3977 this->copy_relocs_
.emit(this->rela_dyn_section(layout
));
3979 // Set the size of the _GLOBAL_OFFSET_TABLE_ symbol to the size of
3980 // the .got section.
3981 Symbol
* sym
= this->global_offset_table_
;
3984 uint64_t data_size
= this->got_
->current_data_size();
3985 symtab
->get_sized_symbol
<size
>(sym
)->set_symsize(data_size
);
3988 if (parameters
->doing_static_link()
3989 && (this->plt_
== NULL
|| !this->plt_
->has_irelative_section()))
3991 // If linking statically, make sure that the __rela_iplt symbols
3992 // were defined if necessary, even if we didn't create a PLT.
3993 static const Define_symbol_in_segment syms
[] =
3996 "__rela_iplt_start", // name
3997 elfcpp::PT_LOAD
, // segment_type
3998 elfcpp::PF_W
, // segment_flags_set
3999 elfcpp::PF(0), // segment_flags_clear
4002 elfcpp::STT_NOTYPE
, // type
4003 elfcpp::STB_GLOBAL
, // binding
4004 elfcpp::STV_HIDDEN
, // visibility
4006 Symbol::SEGMENT_START
, // offset_from_base
4010 "__rela_iplt_end", // name
4011 elfcpp::PT_LOAD
, // segment_type
4012 elfcpp::PF_W
, // segment_flags_set
4013 elfcpp::PF(0), // segment_flags_clear
4016 elfcpp::STT_NOTYPE
, // type
4017 elfcpp::STB_GLOBAL
, // binding
4018 elfcpp::STV_HIDDEN
, // visibility
4020 Symbol::SEGMENT_START
, // offset_from_base
4025 symtab
->define_symbols(layout
, 2, syms
,
4026 layout
->script_options()->saw_sections_clause());
4030 // Scan the relocs during a relocatable link.
4034 Target_s390
<size
>::scan_relocatable_relocs(
4035 Symbol_table
* symtab
,
4037 Sized_relobj_file
<size
, true>* object
,
4038 unsigned int data_shndx
,
4039 unsigned int sh_type
,
4040 const unsigned char* prelocs
,
4042 Output_section
* output_section
,
4043 bool needs_special_offset_handling
,
4044 size_t local_symbol_count
,
4045 const unsigned char* plocal_symbols
,
4046 Relocatable_relocs
* rr
)
4048 typedef gold::Default_classify_reloc
<elfcpp::SHT_RELA
, size
, true>
4050 typedef gold::Default_scan_relocatable_relocs
<Classify_reloc
>
4051 Scan_relocatable_relocs
;
4053 gold_assert(sh_type
== elfcpp::SHT_RELA
);
4055 gold::scan_relocatable_relocs
<size
, true, Scan_relocatable_relocs
>(
4063 needs_special_offset_handling
,
4069 // Scan the relocs for --emit-relocs.
4073 Target_s390
<size
>::emit_relocs_scan(
4074 Symbol_table
* symtab
,
4076 Sized_relobj_file
<size
, true>* object
,
4077 unsigned int data_shndx
,
4078 unsigned int sh_type
,
4079 const unsigned char* prelocs
,
4081 Output_section
* output_section
,
4082 bool needs_special_offset_handling
,
4083 size_t local_symbol_count
,
4084 const unsigned char* plocal_syms
,
4085 Relocatable_relocs
* rr
)
4087 typedef gold::Default_classify_reloc
<elfcpp::SHT_RELA
, size
, true>
4089 typedef gold::Default_emit_relocs_strategy
<Classify_reloc
>
4090 Emit_relocs_strategy
;
4092 gold_assert(sh_type
== elfcpp::SHT_RELA
);
4094 gold::scan_relocatable_relocs
<size
, true, Emit_relocs_strategy
>(
4102 needs_special_offset_handling
,
4108 // Relocate a section during a relocatable link.
4112 Target_s390
<size
>::relocate_relocs(
4113 const Relocate_info
<size
, true>* relinfo
,
4114 unsigned int sh_type
,
4115 const unsigned char* prelocs
,
4117 Output_section
* output_section
,
4118 typename
elfcpp::Elf_types
<size
>::Elf_Off offset_in_output_section
,
4119 unsigned char* view
,
4120 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
4121 section_size_type view_size
,
4122 unsigned char* reloc_view
,
4123 section_size_type reloc_view_size
)
4125 typedef gold::Default_classify_reloc
<elfcpp::SHT_RELA
, size
, true>
4128 gold_assert(sh_type
== elfcpp::SHT_RELA
);
4130 gold::relocate_relocs
<size
, true, Classify_reloc
>(
4135 offset_in_output_section
,
4143 // Return the offset to use for the GOT_INDX'th got entry which is
4144 // for a local tls symbol specified by OBJECT, SYMNDX.
4147 Target_s390
<size
>::do_tls_offset_for_local(
4152 // The only way we can get called is when IEENT/GOTIE12/GOTIE20
4153 // couldn't be optimised to LE.
4154 Output_segment
* tls_segment
= layout_
->tls_segment();
4155 return -tls_segment
->memsz();
4158 // Return the offset to use for the GOT_INDX'th got entry which is
4159 // for global tls symbol GSYM.
4162 Target_s390
<size
>::do_tls_offset_for_global(
4166 Output_segment
* tls_segment
= layout_
->tls_segment();
4167 return -tls_segment
->memsz();
4170 // Return the value to use for a dynamic which requires special
4171 // treatment. This is how we support equality comparisons of function
4172 // pointers across shared library boundaries, as described in the
4173 // processor specific ABI supplement.
4177 Target_s390
<size
>::do_dynsym_value(const Symbol
* gsym
) const
4179 gold_assert(gsym
->is_from_dynobj() && gsym
->has_plt_offset());
4180 return this->plt_address_for_global(gsym
);
4183 // Return a string used to fill a code section with nops to take up
4184 // the specified length.
4188 Target_s390
<size
>::do_code_fill(section_size_type length
) const
4191 gold_warning(_("S/390 code fill of odd length requested"));
4192 return std::string(length
, static_cast<char>(0x07));
4195 // Relocate section data.
4199 Target_s390
<size
>::relocate_section(
4200 const Relocate_info
<size
, true>* relinfo
,
4201 unsigned int sh_type
,
4202 const unsigned char* prelocs
,
4204 Output_section
* output_section
,
4205 bool needs_special_offset_handling
,
4206 unsigned char* view
,
4207 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
4208 section_size_type view_size
,
4209 const Reloc_symbol_changes
* reloc_symbol_changes
)
4211 typedef gold::Default_classify_reloc
<elfcpp::SHT_RELA
, size
, true>
4214 gold_assert(sh_type
== elfcpp::SHT_RELA
);
4216 gold::relocate_section
<size
, true, Target_s390
<size
>, Relocate
,
4217 gold::Default_comdat_behavior
, Classify_reloc
>(
4223 needs_special_offset_handling
,
4227 reloc_symbol_changes
);
4230 // Apply an incremental relocation. Incremental relocations always refer
4231 // to global symbols.
4235 Target_s390
<size
>::apply_relocation(
4236 const Relocate_info
<size
, true>* relinfo
,
4237 typename
elfcpp::Elf_types
<size
>::Elf_Addr r_offset
,
4238 unsigned int r_type
,
4239 typename
elfcpp::Elf_types
<size
>::Elf_Swxword r_addend
,
4241 unsigned char* view
,
4242 typename
elfcpp::Elf_types
<size
>::Elf_Addr address
,
4243 section_size_type view_size
)
4245 gold::apply_relocation
<size
, true, Target_s390
<size
>,
4246 typename Target_s390
<size
>::Relocate
>(
4258 // The selector for s390 object files.
4261 class Target_selector_s390
: public Target_selector
4264 Target_selector_s390()
4265 : Target_selector(elfcpp::EM_S390
, size
, true,
4266 (size
== 64 ? "elf64-s390" : "elf32-s390"),
4267 (size
== 64 ? "elf64_s390" : "elf32_s390"))
4271 do_instantiate_target()
4272 { return new Target_s390
<size
>(); }
4275 Target_selector_s390
<32> target_selector_s390
;
4276 Target_selector_s390
<64> target_selector_s390x
;
4278 } // End anonymous namespace.