1 // reloc.cc -- relocate input files for gold.
3 // Copyright 2006, 2007 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
27 #include "workqueue.h"
37 // Read_relocs methods.
39 // These tasks just read the relocation information from the file.
40 // After reading it, the start another task to process the
41 // information. These tasks requires access to the file.
44 Read_relocs::is_runnable()
46 return this->object_->is_locked() ? this->object_->token() : NULL;
52 Read_relocs::locks(Task_locker* tl)
54 tl->add(this, this->object_->token());
57 // Read the relocations and then start a Scan_relocs_task.
60 Read_relocs::run(Workqueue* workqueue)
62 Read_relocs_data *rd = new Read_relocs_data;
63 this->object_->read_relocs(rd);
64 this->object_->release();
66 workqueue->queue_front(new Scan_relocs(this->options_, this->symtab_,
67 this->layout_, this->object_, rd,
68 this->symtab_lock_, this->blocker_));
71 // Return a debugging name for the task.
74 Read_relocs::get_name() const
76 return "Read_relocs " + this->object_->name();
79 // Scan_relocs methods.
81 // These tasks scan the relocations read by Read_relocs and mark up
82 // the symbol table to indicate which relocations are required. We
83 // use a lock on the symbol table to keep them from interfering with
87 Scan_relocs::is_runnable()
89 if (!this->symtab_lock_->is_writable())
90 return this->symtab_lock_;
91 if (this->object_->is_locked())
92 return this->object_->token();
96 // Return the locks we hold: one on the file, one on the symbol table
100 Scan_relocs::locks(Task_locker* tl)
102 tl->add(this, this->object_->token());
103 tl->add(this, this->symtab_lock_);
104 tl->add(this, this->blocker_);
110 Scan_relocs::run(Workqueue*)
112 this->object_->scan_relocs(this->options_, this->symtab_, this->layout_,
114 this->object_->release();
119 // Return a debugging name for the task.
122 Scan_relocs::get_name() const
124 return "Scan_relocs " + this->object_->name();
127 // Relocate_task methods.
129 // We may have to wait for the output sections to be written.
132 Relocate_task::is_runnable()
134 if (this->object_->relocs_must_follow_section_writes()
135 && this->output_sections_blocker_->is_blocked())
136 return this->output_sections_blocker_;
138 if (this->object_->is_locked())
139 return this->object_->token();
144 // We want to lock the file while we run. We want to unblock
145 // INPUT_SECTIONS_BLOCKER and FINAL_BLOCKER when we are done.
146 // INPUT_SECTIONS_BLOCKER may be NULL.
149 Relocate_task::locks(Task_locker* tl)
151 if (this->input_sections_blocker_ != NULL)
152 tl->add(this, this->input_sections_blocker_);
153 tl->add(this, this->final_blocker_);
154 tl->add(this, this->object_->token());
160 Relocate_task::run(Workqueue*)
162 this->object_->relocate(this->options_, this->symtab_, this->layout_,
165 // This is normally the last thing we will do with an object, so
166 // uncache all views.
167 this->object_->clear_view_cache_marks();
169 this->object_->release();
172 // Return a debugging name for the task.
175 Relocate_task::get_name() const
177 return "Relocate_task " + this->object_->name();
180 // Read the relocs and local symbols from the object file and store
181 // the information in RD.
183 template<int size, bool big_endian>
185 Sized_relobj<size, big_endian>::do_read_relocs(Read_relocs_data* rd)
189 unsigned int shnum = this->shnum();
193 rd->relocs.reserve(shnum / 2);
195 std::vector<Map_to_output>& map_sections(this->map_to_output());
197 const unsigned char *pshdrs = this->get_view(this->elf_file_.shoff(),
198 shnum * This::shdr_size,
200 // Skip the first, dummy, section.
201 const unsigned char *ps = pshdrs + This::shdr_size;
202 for (unsigned int i = 1; i < shnum; ++i, ps += This::shdr_size)
204 typename This::Shdr shdr(ps);
206 unsigned int sh_type = shdr.get_sh_type();
207 if (sh_type != elfcpp::SHT_REL && sh_type != elfcpp::SHT_RELA)
210 unsigned int shndx = shdr.get_sh_info();
213 this->error(_("relocation section %u has bad info %u"),
218 Output_section* os = map_sections[shndx].output_section;
222 // We are scanning relocations in order to fill out the GOT and
223 // PLT sections. Relocations for sections which are not
224 // allocated (typically debugging sections) should not add new
225 // GOT and PLT entries. So we skip them.
226 typename This::Shdr secshdr(pshdrs + shndx * This::shdr_size);
227 if ((secshdr.get_sh_flags() & elfcpp::SHF_ALLOC) == 0)
230 if (shdr.get_sh_link() != this->symtab_shndx_)
232 this->error(_("relocation section %u uses unexpected "
234 i, shdr.get_sh_link());
238 off_t sh_size = shdr.get_sh_size();
240 unsigned int reloc_size;
241 if (sh_type == elfcpp::SHT_REL)
242 reloc_size = elfcpp::Elf_sizes<size>::rel_size;
244 reloc_size = elfcpp::Elf_sizes<size>::rela_size;
245 if (reloc_size != shdr.get_sh_entsize())
247 this->error(_("unexpected entsize for reloc section %u: %lu != %u"),
248 i, static_cast<unsigned long>(shdr.get_sh_entsize()),
253 size_t reloc_count = sh_size / reloc_size;
254 if (static_cast<off_t>(reloc_count * reloc_size) != sh_size)
256 this->error(_("reloc section %u size %lu uneven"),
257 i, static_cast<unsigned long>(sh_size));
261 rd->relocs.push_back(Section_relocs());
262 Section_relocs& sr(rd->relocs.back());
264 sr.data_shndx = shndx;
265 sr.contents = this->get_lasting_view(shdr.get_sh_offset(), sh_size,
267 sr.sh_type = sh_type;
268 sr.reloc_count = reloc_count;
269 sr.output_section = os;
270 sr.needs_special_offset_handling = map_sections[shndx].offset == -1;
273 // Read the local symbols.
274 gold_assert(this->symtab_shndx_ != -1U);
275 if (this->symtab_shndx_ == 0 || this->local_symbol_count_ == 0)
276 rd->local_symbols = NULL;
279 typename This::Shdr symtabshdr(pshdrs
280 + this->symtab_shndx_ * This::shdr_size);
281 gold_assert(symtabshdr.get_sh_type() == elfcpp::SHT_SYMTAB);
282 const int sym_size = This::sym_size;
283 const unsigned int loccount = this->local_symbol_count_;
284 gold_assert(loccount == symtabshdr.get_sh_info());
285 off_t locsize = loccount * sym_size;
286 rd->local_symbols = this->get_lasting_view(symtabshdr.get_sh_offset(),
291 // Scan the relocs and adjust the symbol table. This looks for
292 // relocations which require GOT/PLT/COPY relocations.
294 template<int size, bool big_endian>
296 Sized_relobj<size, big_endian>::do_scan_relocs(const General_options& options,
297 Symbol_table* symtab,
299 Read_relocs_data* rd)
301 Sized_target<size, big_endian>* target = this->sized_target();
303 const unsigned char* local_symbols;
304 if (rd->local_symbols == NULL)
305 local_symbols = NULL;
307 local_symbols = rd->local_symbols->data();
309 for (Read_relocs_data::Relocs_list::iterator p = rd->relocs.begin();
310 p != rd->relocs.end();
313 target->scan_relocs(options, symtab, layout, this, p->data_shndx,
314 p->sh_type, p->contents->data(), p->reloc_count,
315 p->output_section, p->needs_special_offset_handling,
316 this->local_symbol_count_,
322 if (rd->local_symbols != NULL)
324 delete rd->local_symbols;
325 rd->local_symbols = NULL;
329 // Relocate the input sections and write out the local symbols.
331 template<int size, bool big_endian>
333 Sized_relobj<size, big_endian>::do_relocate(const General_options& options,
334 const Symbol_table* symtab,
335 const Layout* layout,
338 unsigned int shnum = this->shnum();
340 // Read the section headers.
341 const unsigned char* pshdrs = this->get_view(this->elf_file_.shoff(),
342 shnum * This::shdr_size,
348 // Make two passes over the sections. The first one copies the
349 // section data to the output file. The second one applies
352 this->write_sections(pshdrs, of, &views);
354 // To speed up relocations, we set up hash tables for fast lookup of
355 // input offsets to output addresses.
356 this->initialize_input_to_output_maps();
358 // Apply relocations.
360 this->relocate_sections(options, symtab, layout, pshdrs, &views);
362 // After we've done the relocations, we release the hash tables,
363 // since we no longer need them.
364 this->free_input_to_output_maps();
366 // Write out the accumulated views.
367 for (unsigned int i = 1; i < shnum; ++i)
369 if (views[i].view != NULL)
371 if (!views[i].is_postprocessing_view)
373 if (views[i].is_input_output_view)
374 of->write_input_output_view(views[i].offset,
378 of->write_output_view(views[i].offset, views[i].view_size,
384 // Write out the local symbols.
385 this->write_local_symbols(of, layout->sympool(), layout->dynpool());
387 // We should no longer need the local symbol values.
388 this->clear_local_symbols();
391 // Sort a Read_multiple vector by file offset.
392 struct Read_multiple_compare
395 operator()(const File_read::Read_multiple_entry& rme1,
396 const File_read::Read_multiple_entry& rme2) const
397 { return rme1.file_offset < rme2.file_offset; }
400 // Write section data to the output file. PSHDRS points to the
401 // section headers. Record the views in *PVIEWS for use when
404 template<int size, bool big_endian>
406 Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
410 unsigned int shnum = this->shnum();
411 const std::vector<Map_to_output>& map_sections(this->map_to_output());
413 File_read::Read_multiple rm;
414 bool is_sorted = true;
416 const unsigned char* p = pshdrs + This::shdr_size;
417 for (unsigned int i = 1; i < shnum; ++i, p += This::shdr_size)
419 View_size* pvs = &(*pviews)[i];
423 const Output_section* os = map_sections[i].output_section;
426 off_t output_offset = map_sections[i].offset;
428 typename This::Shdr shdr(p);
430 if (shdr.get_sh_type() == elfcpp::SHT_NOBITS)
433 // In the normal case, this input section is simply mapped to
434 // the output section at offset OUTPUT_OFFSET.
436 // However, if OUTPUT_OFFSET == -1, then input data is handled
437 // specially--e.g., a .eh_frame section. The relocation
438 // routines need to check for each reloc where it should be
439 // applied. For this case, we need an input/output view for the
440 // entire contents of the section in the output file. We don't
441 // want to copy the contents of the input section to the output
442 // section; the output section contents were already written,
443 // and we waited for them in Relocate_task::is_runnable because
444 // relocs_must_follow_section_writes is set for the object.
446 // Regardless of which of the above cases is true, we have to
447 // check requires_postprocessing of the output section. If that
448 // is false, then we work with views of the output file
449 // directly. If it is true, then we work with a separate
450 // buffer, and the output section is responsible for writing the
451 // final data to the output file.
453 off_t output_section_offset;
454 off_t output_section_size;
455 if (!os->requires_postprocessing())
457 output_section_offset = os->offset();
458 output_section_size = os->data_size();
462 output_section_offset = 0;
463 output_section_size = os->postprocessing_buffer_size();
467 section_size_type view_size;
468 if (output_offset != -1)
470 view_start = output_section_offset + output_offset;
471 view_size = convert_to_section_size_type(shdr.get_sh_size());
475 view_start = output_section_offset;
476 view_size = convert_to_section_size_type(output_section_size);
482 gold_assert(output_offset == -1
483 || (output_offset >= 0
484 && (output_offset + static_cast<off_t>(view_size)
485 <= output_section_size)));
488 if (os->requires_postprocessing())
490 unsigned char* buffer = os->postprocessing_buffer();
491 view = buffer + view_start;
492 if (output_offset != -1)
494 off_t sh_offset = shdr.get_sh_offset();
495 if (!rm.empty() && rm.back().file_offset > sh_offset)
497 rm.push_back(File_read::Read_multiple_entry(sh_offset,
503 if (output_offset == -1)
504 view = of->get_input_output_view(view_start, view_size);
507 view = of->get_output_view(view_start, view_size);
508 off_t sh_offset = shdr.get_sh_offset();
509 if (!rm.empty() && rm.back().file_offset > sh_offset)
511 rm.push_back(File_read::Read_multiple_entry(sh_offset,
517 pvs->address = os->address();
518 if (output_offset != -1)
519 pvs->address += output_offset;
520 pvs->offset = view_start;
521 pvs->view_size = view_size;
522 pvs->is_input_output_view = output_offset == -1;
523 pvs->is_postprocessing_view = os->requires_postprocessing();
526 // Actually read the data.
530 std::sort(rm.begin(), rm.end(), Read_multiple_compare());
531 this->read_multiple(rm);
535 // Relocate section data. VIEWS points to the section data as views
536 // in the output file.
538 template<int size, bool big_endian>
540 Sized_relobj<size, big_endian>::relocate_sections(
541 const General_options& options,
542 const Symbol_table* symtab,
543 const Layout* layout,
544 const unsigned char* pshdrs,
547 unsigned int shnum = this->shnum();
548 Sized_target<size, big_endian>* target = this->sized_target();
550 const std::vector<Map_to_output>& map_sections(this->map_to_output());
552 Relocate_info<size, big_endian> relinfo;
553 relinfo.options = &options;
554 relinfo.symtab = symtab;
555 relinfo.layout = layout;
556 relinfo.object = this;
558 const unsigned char* p = pshdrs + This::shdr_size;
559 for (unsigned int i = 1; i < shnum; ++i, p += This::shdr_size)
561 typename This::Shdr shdr(p);
563 unsigned int sh_type = shdr.get_sh_type();
564 if (sh_type != elfcpp::SHT_REL && sh_type != elfcpp::SHT_RELA)
567 unsigned int index = shdr.get_sh_info();
568 if (index >= this->shnum())
570 this->error(_("relocation section %u has bad info %u"),
575 Output_section* os = map_sections[index].output_section;
578 // This relocation section is against a section which we
582 off_t output_offset = map_sections[index].offset;
584 gold_assert((*pviews)[index].view != NULL);
586 if (shdr.get_sh_link() != this->symtab_shndx_)
588 gold_error(_("relocation section %u uses unexpected "
590 i, shdr.get_sh_link());
594 off_t sh_size = shdr.get_sh_size();
595 const unsigned char* prelocs = this->get_view(shdr.get_sh_offset(),
598 unsigned int reloc_size;
599 if (sh_type == elfcpp::SHT_REL)
600 reloc_size = elfcpp::Elf_sizes<size>::rel_size;
602 reloc_size = elfcpp::Elf_sizes<size>::rela_size;
604 if (reloc_size != shdr.get_sh_entsize())
606 gold_error(_("unexpected entsize for reloc section %u: %lu != %u"),
607 i, static_cast<unsigned long>(shdr.get_sh_entsize()),
612 size_t reloc_count = sh_size / reloc_size;
613 if (static_cast<off_t>(reloc_count * reloc_size) != sh_size)
615 gold_error(_("reloc section %u size %lu uneven"),
616 i, static_cast<unsigned long>(sh_size));
620 gold_assert(output_offset != -1
621 || this->relocs_must_follow_section_writes());
623 relinfo.reloc_shndx = i;
624 relinfo.data_shndx = index;
625 target->relocate_section(&relinfo,
631 (*pviews)[index].view,
632 (*pviews)[index].address,
633 (*pviews)[index].view_size);
637 // Create merge hash tables for the local symbols. These are used to
638 // speed up relocations.
640 template<int size, bool big_endian>
642 Sized_relobj<size, big_endian>::initialize_input_to_output_maps()
644 const unsigned int loccount = this->local_symbol_count_;
645 for (unsigned int i = 1; i < loccount; ++i)
647 Symbol_value<size>& lv(this->local_values_[i]);
648 lv.initialize_input_to_output_map(this);
652 // Free merge hash tables for the local symbols.
654 template<int size, bool big_endian>
656 Sized_relobj<size, big_endian>::free_input_to_output_maps()
658 const unsigned int loccount = this->local_symbol_count_;
659 for (unsigned int i = 1; i < loccount; ++i)
661 Symbol_value<size>& lv(this->local_values_[i]);
662 lv.free_input_to_output_map();
666 // Class Merged_symbol_value.
670 Merged_symbol_value<size>::initialize_input_to_output_map(
671 const Relobj* object,
672 unsigned int input_shndx)
674 Object_merge_map* map = object->merge_map();
675 map->initialize_input_to_output_map<size>(input_shndx,
676 this->output_start_address_,
677 &this->output_addresses_);
680 // Get the output value corresponding to an input offset if we
681 // couldn't find it in the hash table.
684 typename elfcpp::Elf_types<size>::Elf_Addr
685 Merged_symbol_value<size>::value_from_output_section(
686 const Relobj* object,
687 unsigned int input_shndx,
688 typename elfcpp::Elf_types<size>::Elf_Addr input_offset) const
690 section_offset_type output_offset;
691 bool found = object->merge_map()->get_output_offset(NULL, input_shndx,
695 // If this assertion fails, it means that some relocation was
696 // against a portion of an input merge section which we didn't map
697 // to the output file and we didn't explicitly discard. We should
698 // always map all portions of input merge sections.
701 if (output_offset == -1)
704 return this->output_start_address_ + output_offset;
707 // Copy_relocs::Copy_reloc_entry methods.
709 // Return whether we should emit this reloc. We should emit it if the
710 // symbol is still defined in a dynamic object. If we should not emit
711 // it, we clear it, to save ourselves the test next time.
713 template<int size, bool big_endian>
715 Copy_relocs<size, big_endian>::Copy_reloc_entry::should_emit()
717 if (this->sym_ == NULL)
719 if (this->sym_->is_from_dynobj())
725 // Emit a reloc into a SHT_REL section.
727 template<int size, bool big_endian>
729 Copy_relocs<size, big_endian>::Copy_reloc_entry::emit(
730 Output_data_reloc<elfcpp::SHT_REL, true, size, big_endian>* reloc_data)
732 this->sym_->set_needs_dynsym_entry();
733 reloc_data->add_global(this->sym_, this->reloc_type_, this->output_section_,
734 this->relobj_, this->shndx_, this->address_);
737 // Emit a reloc into a SHT_RELA section.
739 template<int size, bool big_endian>
741 Copy_relocs<size, big_endian>::Copy_reloc_entry::emit(
742 Output_data_reloc<elfcpp::SHT_RELA, true, size, big_endian>* reloc_data)
744 this->sym_->set_needs_dynsym_entry();
745 reloc_data->add_global(this->sym_, this->reloc_type_, this->output_section_,
746 this->relobj_, this->shndx_, this->address_,
750 // Copy_relocs methods.
752 // Return whether we need a COPY reloc for a relocation against GSYM.
753 // The relocation is being applied to section SHNDX in OBJECT.
755 template<int size, bool big_endian>
757 Copy_relocs<size, big_endian>::need_copy_reloc(
758 const General_options*,
761 Sized_symbol<size>* sym)
763 // FIXME: Handle -z nocopyrelocs.
765 if (sym->symsize() == 0)
768 // If this is a readonly section, then we need a COPY reloc.
769 // Otherwise we can use a dynamic reloc.
770 if ((object->section_flags(shndx) & elfcpp::SHF_WRITE) == 0)
778 template<int size, bool big_endian>
780 Copy_relocs<size, big_endian>::save(
784 Output_section* output_section,
785 const elfcpp::Rel<size, big_endian>& rel)
787 unsigned int reloc_type = elfcpp::elf_r_type<size>(rel.get_r_info());
788 this->entries_.push_back(Copy_reloc_entry(sym, reloc_type, relobj, shndx,
790 rel.get_r_offset(), 0));
793 // Save a Rela reloc.
795 template<int size, bool big_endian>
797 Copy_relocs<size, big_endian>::save(
801 Output_section* output_section,
802 const elfcpp::Rela<size, big_endian>& rela)
804 unsigned int reloc_type = elfcpp::elf_r_type<size>(rela.get_r_info());
805 this->entries_.push_back(Copy_reloc_entry(sym, reloc_type, relobj, shndx,
808 rela.get_r_addend()));
811 // Return whether there are any relocs to emit. We don't want to emit
812 // a reloc if the symbol is no longer defined in a dynamic object.
814 template<int size, bool big_endian>
816 Copy_relocs<size, big_endian>::any_to_emit()
818 for (typename Copy_reloc_entries::iterator p = this->entries_.begin();
819 p != this->entries_.end();
822 if (p->should_emit())
830 template<int size, bool big_endian>
831 template<int sh_type>
833 Copy_relocs<size, big_endian>::emit(
834 Output_data_reloc<sh_type, true, size, big_endian>* reloc_data)
836 for (typename Copy_reloc_entries::iterator p = this->entries_.begin();
837 p != this->entries_.end();
840 if (p->should_emit())
845 // Track_relocs methods.
847 // Initialize the class to track the relocs. This gets the object,
848 // the reloc section index, and the type of the relocs. This returns
849 // false if something goes wrong.
851 template<int size, bool big_endian>
853 Track_relocs<size, big_endian>::initialize(
855 unsigned int reloc_shndx,
856 unsigned int reloc_type)
858 // If RELOC_SHNDX is -1U, it means there is more than one reloc
859 // section for the .eh_frame section. We can't handle that case.
860 if (reloc_shndx == -1U)
863 // If RELOC_SHNDX is 0, there is no reloc section.
864 if (reloc_shndx == 0)
867 // Get the contents of the reloc section.
868 this->prelocs_ = object->section_contents(reloc_shndx, &this->len_, false);
870 if (reloc_type == elfcpp::SHT_REL)
871 this->reloc_size_ = elfcpp::Elf_sizes<size>::rel_size;
872 else if (reloc_type == elfcpp::SHT_RELA)
873 this->reloc_size_ = elfcpp::Elf_sizes<size>::rela_size;
877 if (this->len_ % this->reloc_size_ != 0)
879 object->error(_("reloc section size %zu is not a multiple of "
881 static_cast<size_t>(this->len_),
889 // Return the offset of the next reloc, or -1 if there isn't one.
891 template<int size, bool big_endian>
893 Track_relocs<size, big_endian>::next_offset() const
895 if (this->pos_ >= this->len_)
898 // Rel and Rela start out the same, so we can always use Rel to find
899 // the r_offset value.
900 elfcpp::Rel<size, big_endian> rel(this->prelocs_ + this->pos_);
901 return rel.get_r_offset();
904 // Return the index of the symbol referenced by the next reloc, or -1U
905 // if there aren't any more relocs.
907 template<int size, bool big_endian>
909 Track_relocs<size, big_endian>::next_symndx() const
911 if (this->pos_ >= this->len_)
914 // Rel and Rela start out the same, so we can use Rel to find the
916 elfcpp::Rel<size, big_endian> rel(this->prelocs_ + this->pos_);
917 return elfcpp::elf_r_sym<size>(rel.get_r_info());
920 // Advance to the next reloc whose r_offset is greater than or equal
921 // to OFFSET. Return the number of relocs we skip.
923 template<int size, bool big_endian>
925 Track_relocs<size, big_endian>::advance(off_t offset)
928 while (this->pos_ < this->len_)
930 // Rel and Rela start out the same, so we can always use Rel to
931 // find the r_offset value.
932 elfcpp::Rel<size, big_endian> rel(this->prelocs_ + this->pos_);
933 if (static_cast<off_t>(rel.get_r_offset()) >= offset)
936 this->pos_ += this->reloc_size_;
941 // Instantiate the templates we need. We could use the configure
942 // script to restrict this to only the ones for implemented targets.
944 #ifdef HAVE_TARGET_32_LITTLE
947 Sized_relobj<32, false>::do_read_relocs(Read_relocs_data* rd);
950 #ifdef HAVE_TARGET_32_BIG
953 Sized_relobj<32, true>::do_read_relocs(Read_relocs_data* rd);
956 #ifdef HAVE_TARGET_64_LITTLE
959 Sized_relobj<64, false>::do_read_relocs(Read_relocs_data* rd);
962 #ifdef HAVE_TARGET_64_BIG
965 Sized_relobj<64, true>::do_read_relocs(Read_relocs_data* rd);
968 #ifdef HAVE_TARGET_32_LITTLE
971 Sized_relobj<32, false>::do_scan_relocs(const General_options& options,
972 Symbol_table* symtab,
974 Read_relocs_data* rd);
977 #ifdef HAVE_TARGET_32_BIG
980 Sized_relobj<32, true>::do_scan_relocs(const General_options& options,
981 Symbol_table* symtab,
983 Read_relocs_data* rd);
986 #ifdef HAVE_TARGET_64_LITTLE
989 Sized_relobj<64, false>::do_scan_relocs(const General_options& options,
990 Symbol_table* symtab,
992 Read_relocs_data* rd);
995 #ifdef HAVE_TARGET_64_BIG
998 Sized_relobj<64, true>::do_scan_relocs(const General_options& options,
999 Symbol_table* symtab,
1001 Read_relocs_data* rd);
1004 #ifdef HAVE_TARGET_32_LITTLE
1007 Sized_relobj<32, false>::do_relocate(const General_options& options,
1008 const Symbol_table* symtab,
1009 const Layout* layout,
1013 #ifdef HAVE_TARGET_32_BIG
1016 Sized_relobj<32, true>::do_relocate(const General_options& options,
1017 const Symbol_table* symtab,
1018 const Layout* layout,
1022 #ifdef HAVE_TARGET_64_LITTLE
1025 Sized_relobj<64, false>::do_relocate(const General_options& options,
1026 const Symbol_table* symtab,
1027 const Layout* layout,
1031 #ifdef HAVE_TARGET_64_BIG
1034 Sized_relobj<64, true>::do_relocate(const General_options& options,
1035 const Symbol_table* symtab,
1036 const Layout* layout,
1040 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
1042 class Merged_symbol_value<32>;
1045 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
1047 class Merged_symbol_value<64>;
1050 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
1052 class Symbol_value<32>;
1055 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
1057 class Symbol_value<64>;
1060 #ifdef HAVE_TARGET_32_LITTLE
1062 class Copy_relocs<32, false>;
1065 #ifdef HAVE_TARGET_32_BIG
1067 class Copy_relocs<32, true>;
1070 #ifdef HAVE_TARGET_64_LITTLE
1072 class Copy_relocs<64, false>;
1075 #ifdef HAVE_TARGET_64_BIG
1077 class Copy_relocs<64, true>;
1080 #ifdef HAVE_TARGET_32_LITTLE
1083 Copy_relocs<32, false>::emit<elfcpp::SHT_REL>(
1084 Output_data_reloc<elfcpp::SHT_REL, true, 32, false>*);
1087 #ifdef HAVE_TARGET_32_BIG
1090 Copy_relocs<32, true>::emit<elfcpp::SHT_REL>(
1091 Output_data_reloc<elfcpp::SHT_REL, true, 32, true>*);
1094 #ifdef HAVE_TARGET_64_LITTLE
1097 Copy_relocs<64, false>::emit<elfcpp::SHT_REL>(
1098 Output_data_reloc<elfcpp::SHT_REL, true, 64, false>*);
1101 #ifdef HAVE_TARGET_64_BIG
1104 Copy_relocs<64, true>::emit<elfcpp::SHT_REL>(
1105 Output_data_reloc<elfcpp::SHT_REL, true, 64, true>*);
1108 #ifdef HAVE_TARGET_32_LITTLE
1111 Copy_relocs<32, false>::emit<elfcpp::SHT_RELA>(
1112 Output_data_reloc<elfcpp::SHT_RELA , true, 32, false>*);
1115 #ifdef HAVE_TARGET_32_BIG
1118 Copy_relocs<32, true>::emit<elfcpp::SHT_RELA>(
1119 Output_data_reloc<elfcpp::SHT_RELA, true, 32, true>*);
1122 #ifdef HAVE_TARGET_64_LITTLE
1125 Copy_relocs<64, false>::emit<elfcpp::SHT_RELA>(
1126 Output_data_reloc<elfcpp::SHT_RELA, true, 64, false>*);
1129 #ifdef HAVE_TARGET_64_BIG
1132 Copy_relocs<64, true>::emit<elfcpp::SHT_RELA>(
1133 Output_data_reloc<elfcpp::SHT_RELA, true, 64, true>*);
1136 #ifdef HAVE_TARGET_32_LITTLE
1138 class Track_relocs<32, false>;
1141 #ifdef HAVE_TARGET_32_BIG
1143 class Track_relocs<32, true>;
1146 #ifdef HAVE_TARGET_64_LITTLE
1148 class Track_relocs<64, false>;
1151 #ifdef HAVE_TARGET_64_BIG
1153 class Track_relocs<64, true>;
1156 } // End namespace gold.