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.
25 #include "workqueue.h"
35 // Read_relocs methods.
37 // These tasks just read the relocation information from the file.
38 // After reading it, the start another task to process the
39 // information. These tasks requires access to the file.
42 Read_relocs::is_runnable()
44 return this->object_->is_locked() ? this->object_->token() : NULL;
50 Read_relocs::locks(Task_locker* tl)
52 tl->add(this, this->object_->token());
55 // Read the relocations and then start a Scan_relocs_task.
58 Read_relocs::run(Workqueue* workqueue)
60 Read_relocs_data *rd = new Read_relocs_data;
61 this->object_->read_relocs(rd);
62 this->object_->release();
64 workqueue->queue_front(new Scan_relocs(this->options_, this->symtab_,
65 this->layout_, this->object_, rd,
66 this->symtab_lock_, this->blocker_));
69 // Return a debugging name for the task.
72 Read_relocs::get_name() const
74 return "Read_relocs " + this->object_->name();
77 // Scan_relocs methods.
79 // These tasks scan the relocations read by Read_relocs and mark up
80 // the symbol table to indicate which relocations are required. We
81 // use a lock on the symbol table to keep them from interfering with
85 Scan_relocs::is_runnable()
87 if (!this->symtab_lock_->is_writable())
88 return this->symtab_lock_;
89 if (this->object_->is_locked())
90 return this->object_->token();
94 // Return the locks we hold: one on the file, one on the symbol table
98 Scan_relocs::locks(Task_locker* tl)
100 tl->add(this, this->object_->token());
101 tl->add(this, this->symtab_lock_);
102 tl->add(this, this->blocker_);
108 Scan_relocs::run(Workqueue*)
110 this->object_->scan_relocs(this->options_, this->symtab_, this->layout_,
112 this->object_->release();
117 // Return a debugging name for the task.
120 Scan_relocs::get_name() const
122 return "Scan_relocs " + this->object_->name();
125 // Relocate_task methods.
127 // We may have to wait for the output sections to be written.
130 Relocate_task::is_runnable()
132 if (this->object_->relocs_must_follow_section_writes()
133 && this->output_sections_blocker_->is_blocked())
134 return this->output_sections_blocker_;
136 if (this->object_->is_locked())
137 return this->object_->token();
142 // We want to lock the file while we run. We want to unblock
143 // INPUT_SECTIONS_BLOCKER and FINAL_BLOCKER when we are done.
144 // INPUT_SECTIONS_BLOCKER may be NULL.
147 Relocate_task::locks(Task_locker* tl)
149 if (this->input_sections_blocker_ != NULL)
150 tl->add(this, this->input_sections_blocker_);
151 tl->add(this, this->final_blocker_);
152 tl->add(this, this->object_->token());
158 Relocate_task::run(Workqueue*)
160 this->object_->relocate(this->options_, this->symtab_, this->layout_,
162 this->object_->release();
165 // Return a debugging name for the task.
168 Relocate_task::get_name() const
170 return "Relocate_task " + this->object_->name();
173 // Read the relocs and local symbols from the object file and store
174 // the information in RD.
176 template<int size, bool big_endian>
178 Sized_relobj<size, big_endian>::do_read_relocs(Read_relocs_data* rd)
182 unsigned int shnum = this->shnum();
186 rd->relocs.reserve(shnum / 2);
188 std::vector<Map_to_output>& map_sections(this->map_to_output());
190 const unsigned char *pshdrs = this->get_view(this->elf_file_.shoff(),
191 shnum * This::shdr_size,
193 // Skip the first, dummy, section.
194 const unsigned char *ps = pshdrs + This::shdr_size;
195 for (unsigned int i = 1; i < shnum; ++i, ps += This::shdr_size)
197 typename This::Shdr shdr(ps);
199 unsigned int sh_type = shdr.get_sh_type();
200 if (sh_type != elfcpp::SHT_REL && sh_type != elfcpp::SHT_RELA)
203 unsigned int shndx = shdr.get_sh_info();
206 this->error(_("relocation section %u has bad info %u"),
211 Output_section* os = map_sections[shndx].output_section;
215 // We are scanning relocations in order to fill out the GOT and
216 // PLT sections. Relocations for sections which are not
217 // allocated (typically debugging sections) should not add new
218 // GOT and PLT entries. So we skip them.
219 typename This::Shdr secshdr(pshdrs + shndx * This::shdr_size);
220 if ((secshdr.get_sh_flags() & elfcpp::SHF_ALLOC) == 0)
223 if (shdr.get_sh_link() != this->symtab_shndx_)
225 this->error(_("relocation section %u uses unexpected "
227 i, shdr.get_sh_link());
231 off_t sh_size = shdr.get_sh_size();
233 unsigned int reloc_size;
234 if (sh_type == elfcpp::SHT_REL)
235 reloc_size = elfcpp::Elf_sizes<size>::rel_size;
237 reloc_size = elfcpp::Elf_sizes<size>::rela_size;
238 if (reloc_size != shdr.get_sh_entsize())
240 this->error(_("unexpected entsize for reloc section %u: %lu != %u"),
241 i, static_cast<unsigned long>(shdr.get_sh_entsize()),
246 size_t reloc_count = sh_size / reloc_size;
247 if (static_cast<off_t>(reloc_count * reloc_size) != sh_size)
249 this->error(_("reloc section %u size %lu uneven"),
250 i, static_cast<unsigned long>(sh_size));
254 rd->relocs.push_back(Section_relocs());
255 Section_relocs& sr(rd->relocs.back());
257 sr.data_shndx = shndx;
258 sr.contents = this->get_lasting_view(shdr.get_sh_offset(), sh_size,
260 sr.sh_type = sh_type;
261 sr.reloc_count = reloc_count;
262 sr.output_section = os;
263 sr.needs_special_offset_handling = map_sections[shndx].offset == -1;
266 // Read the local symbols.
267 gold_assert(this->symtab_shndx_ != -1U);
268 if (this->symtab_shndx_ == 0 || this->local_symbol_count_ == 0)
269 rd->local_symbols = NULL;
272 typename This::Shdr symtabshdr(pshdrs
273 + this->symtab_shndx_ * This::shdr_size);
274 gold_assert(symtabshdr.get_sh_type() == elfcpp::SHT_SYMTAB);
275 const int sym_size = This::sym_size;
276 const unsigned int loccount = this->local_symbol_count_;
277 gold_assert(loccount == symtabshdr.get_sh_info());
278 off_t locsize = loccount * sym_size;
279 rd->local_symbols = this->get_lasting_view(symtabshdr.get_sh_offset(),
284 // Scan the relocs and adjust the symbol table. This looks for
285 // relocations which require GOT/PLT/COPY relocations.
287 template<int size, bool big_endian>
289 Sized_relobj<size, big_endian>::do_scan_relocs(const General_options& options,
290 Symbol_table* symtab,
292 Read_relocs_data* rd)
294 Sized_target<size, big_endian>* target = this->sized_target();
296 const unsigned char* local_symbols;
297 if (rd->local_symbols == NULL)
298 local_symbols = NULL;
300 local_symbols = rd->local_symbols->data();
302 for (Read_relocs_data::Relocs_list::iterator p = rd->relocs.begin();
303 p != rd->relocs.end();
306 target->scan_relocs(options, symtab, layout, this, p->data_shndx,
307 p->sh_type, p->contents->data(), p->reloc_count,
308 p->output_section, p->needs_special_offset_handling,
309 this->local_symbol_count_,
315 if (rd->local_symbols != NULL)
317 delete rd->local_symbols;
318 rd->local_symbols = NULL;
322 // Relocate the input sections and write out the local symbols.
324 template<int size, bool big_endian>
326 Sized_relobj<size, big_endian>::do_relocate(const General_options& options,
327 const Symbol_table* symtab,
328 const Layout* layout,
331 unsigned int shnum = this->shnum();
333 // Read the section headers.
334 const unsigned char* pshdrs = this->get_view(this->elf_file_.shoff(),
335 shnum * This::shdr_size,
341 // Make two passes over the sections. The first one copies the
342 // section data to the output file. The second one applies
345 this->write_sections(pshdrs, of, &views);
347 // To speed up relocations, we set up hash tables for fast lookup of
348 // input offsets to output addresses.
349 this->initialize_input_to_output_maps();
351 // Apply relocations.
353 this->relocate_sections(options, symtab, layout, pshdrs, &views);
355 // After we've done the relocations, we release the hash tables,
356 // since we no longer need them.
357 this->free_input_to_output_maps();
359 // Write out the accumulated views.
360 for (unsigned int i = 1; i < shnum; ++i)
362 if (views[i].view != NULL)
364 if (!views[i].is_postprocessing_view)
366 if (views[i].is_input_output_view)
367 of->write_input_output_view(views[i].offset,
371 of->write_output_view(views[i].offset, views[i].view_size,
377 // Write out the local symbols.
378 this->write_local_symbols(of, layout->sympool(), layout->dynpool());
381 // Write section data to the output file. PSHDRS points to the
382 // section headers. Record the views in *PVIEWS for use when
385 template<int size, bool big_endian>
387 Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
391 unsigned int shnum = this->shnum();
392 const std::vector<Map_to_output>& map_sections(this->map_to_output());
394 const unsigned char* p = pshdrs + This::shdr_size;
395 for (unsigned int i = 1; i < shnum; ++i, p += This::shdr_size)
397 View_size* pvs = &(*pviews)[i];
401 const Output_section* os = map_sections[i].output_section;
404 off_t output_offset = map_sections[i].offset;
406 typename This::Shdr shdr(p);
408 if (shdr.get_sh_type() == elfcpp::SHT_NOBITS)
411 // In the normal case, this input section is simply mapped to
412 // the output section at offset OUTPUT_OFFSET.
414 // However, if OUTPUT_OFFSET == -1, then input data is handled
415 // specially--e.g., a .eh_frame section. The relocation
416 // routines need to check for each reloc where it should be
417 // applied. For this case, we need an input/output view for the
418 // entire contents of the section in the output file. We don't
419 // want to copy the contents of the input section to the output
420 // section; the output section contents were already written,
421 // and we waited for them in Relocate_task::is_runnable because
422 // relocs_must_follow_section_writes is set for the object.
424 // Regardless of which of the above cases is true, we have to
425 // check requires_postprocessing of the output section. If that
426 // is false, then we work with views of the output file
427 // directly. If it is true, then we work with a separate
428 // buffer, and the output section is responsible for writing the
429 // final data to the output file.
431 off_t output_section_offset;
432 off_t output_section_size;
433 if (!os->requires_postprocessing())
435 output_section_offset = os->offset();
436 output_section_size = os->data_size();
440 output_section_offset = 0;
441 output_section_size = os->postprocessing_buffer_size();
445 section_size_type view_size;
446 if (output_offset != -1)
448 view_start = output_section_offset + output_offset;
449 view_size = convert_to_section_size_type(shdr.get_sh_size());
453 view_start = output_section_offset;
454 view_size = convert_to_section_size_type(output_section_size);
460 gold_assert(output_offset == -1
461 || (output_offset >= 0
462 && output_offset + view_size <= output_section_size));
465 if (os->requires_postprocessing())
467 unsigned char* buffer = os->postprocessing_buffer();
468 view = buffer + view_start;
469 if (output_offset != -1)
470 this->read(shdr.get_sh_offset(), view_size, view);
474 if (output_offset == -1)
475 view = of->get_input_output_view(view_start, view_size);
478 view = of->get_output_view(view_start, view_size);
479 this->read(shdr.get_sh_offset(), view_size, view);
484 pvs->address = os->address();
485 if (output_offset != -1)
486 pvs->address += output_offset;
487 pvs->offset = view_start;
488 pvs->view_size = view_size;
489 pvs->is_input_output_view = output_offset == -1;
490 pvs->is_postprocessing_view = os->requires_postprocessing();
494 // Relocate section data. VIEWS points to the section data as views
495 // in the output file.
497 template<int size, bool big_endian>
499 Sized_relobj<size, big_endian>::relocate_sections(
500 const General_options& options,
501 const Symbol_table* symtab,
502 const Layout* layout,
503 const unsigned char* pshdrs,
506 unsigned int shnum = this->shnum();
507 Sized_target<size, big_endian>* target = this->sized_target();
509 const std::vector<Map_to_output>& map_sections(this->map_to_output());
511 Relocate_info<size, big_endian> relinfo;
512 relinfo.options = &options;
513 relinfo.symtab = symtab;
514 relinfo.layout = layout;
515 relinfo.object = this;
517 const unsigned char* p = pshdrs + This::shdr_size;
518 for (unsigned int i = 1; i < shnum; ++i, p += This::shdr_size)
520 typename This::Shdr shdr(p);
522 unsigned int sh_type = shdr.get_sh_type();
523 if (sh_type != elfcpp::SHT_REL && sh_type != elfcpp::SHT_RELA)
526 unsigned int index = shdr.get_sh_info();
527 if (index >= this->shnum())
529 this->error(_("relocation section %u has bad info %u"),
534 Output_section* os = map_sections[index].output_section;
537 // This relocation section is against a section which we
541 off_t output_offset = map_sections[index].offset;
543 gold_assert((*pviews)[index].view != NULL);
545 if (shdr.get_sh_link() != this->symtab_shndx_)
547 gold_error(_("relocation section %u uses unexpected "
549 i, shdr.get_sh_link());
553 off_t sh_size = shdr.get_sh_size();
554 const unsigned char* prelocs = this->get_view(shdr.get_sh_offset(),
557 unsigned int reloc_size;
558 if (sh_type == elfcpp::SHT_REL)
559 reloc_size = elfcpp::Elf_sizes<size>::rel_size;
561 reloc_size = elfcpp::Elf_sizes<size>::rela_size;
563 if (reloc_size != shdr.get_sh_entsize())
565 gold_error(_("unexpected entsize for reloc section %u: %lu != %u"),
566 i, static_cast<unsigned long>(shdr.get_sh_entsize()),
571 size_t reloc_count = sh_size / reloc_size;
572 if (static_cast<off_t>(reloc_count * reloc_size) != sh_size)
574 gold_error(_("reloc section %u size %lu uneven"),
575 i, static_cast<unsigned long>(sh_size));
579 gold_assert(output_offset != -1
580 || this->relocs_must_follow_section_writes());
582 relinfo.reloc_shndx = i;
583 relinfo.data_shndx = index;
584 target->relocate_section(&relinfo,
590 (*pviews)[index].view,
591 (*pviews)[index].address,
592 (*pviews)[index].view_size);
596 // Create merge hash tables for the local symbols. These are used to
597 // speed up relocations.
599 template<int size, bool big_endian>
601 Sized_relobj<size, big_endian>::initialize_input_to_output_maps()
603 const unsigned int loccount = this->local_symbol_count_;
604 for (unsigned int i = 1; i < loccount; ++i)
606 Symbol_value<size>& lv(this->local_values_[i]);
607 lv.initialize_input_to_output_map(this);
611 // Free merge hash tables for the local symbols.
613 template<int size, bool big_endian>
615 Sized_relobj<size, big_endian>::free_input_to_output_maps()
617 const unsigned int loccount = this->local_symbol_count_;
618 for (unsigned int i = 1; i < loccount; ++i)
620 Symbol_value<size>& lv(this->local_values_[i]);
621 lv.free_input_to_output_map();
625 // Class Merged_symbol_value.
629 Merged_symbol_value<size>::initialize_input_to_output_map(
630 const Relobj* object,
631 unsigned int input_shndx)
633 Object_merge_map* map = object->merge_map();
634 map->initialize_input_to_output_map<size>(input_shndx,
635 this->output_start_address_,
636 &this->output_addresses_);
639 // Get the output value corresponding to an input offset if we
640 // couldn't find it in the hash table.
643 typename elfcpp::Elf_types<size>::Elf_Addr
644 Merged_symbol_value<size>::value_from_output_section(
645 const Relobj* object,
646 unsigned int input_shndx,
647 typename elfcpp::Elf_types<size>::Elf_Addr input_offset) const
649 section_offset_type output_offset;
650 bool found = object->merge_map()->get_output_offset(NULL, input_shndx,
654 // If this assertion fails, it means that some relocation was
655 // against a portion of an input merge section which we didn't map
656 // to the output file and we didn't explicitly discard. We should
657 // always map all portions of input merge sections.
660 if (output_offset == -1)
663 return this->output_start_address_ + output_offset;
666 // Copy_relocs::Copy_reloc_entry methods.
668 // Return whether we should emit this reloc. We should emit it if the
669 // symbol is still defined in a dynamic object. If we should not emit
670 // it, we clear it, to save ourselves the test next time.
672 template<int size, bool big_endian>
674 Copy_relocs<size, big_endian>::Copy_reloc_entry::should_emit()
676 if (this->sym_ == NULL)
678 if (this->sym_->is_from_dynobj())
684 // Emit a reloc into a SHT_REL section.
686 template<int size, bool big_endian>
688 Copy_relocs<size, big_endian>::Copy_reloc_entry::emit(
689 Output_data_reloc<elfcpp::SHT_REL, true, size, big_endian>* reloc_data)
691 this->sym_->set_needs_dynsym_entry();
692 reloc_data->add_global(this->sym_, this->reloc_type_, this->output_section_,
693 this->relobj_, this->shndx_, this->address_);
696 // Emit a reloc into a SHT_RELA section.
698 template<int size, bool big_endian>
700 Copy_relocs<size, big_endian>::Copy_reloc_entry::emit(
701 Output_data_reloc<elfcpp::SHT_RELA, true, size, big_endian>* reloc_data)
703 this->sym_->set_needs_dynsym_entry();
704 reloc_data->add_global(this->sym_, this->reloc_type_, this->output_section_,
705 this->relobj_, this->shndx_, this->address_,
709 // Copy_relocs methods.
711 // Return whether we need a COPY reloc for a relocation against GSYM.
712 // The relocation is being applied to section SHNDX in OBJECT.
714 template<int size, bool big_endian>
716 Copy_relocs<size, big_endian>::need_copy_reloc(
717 const General_options*,
720 Sized_symbol<size>* sym)
722 // FIXME: Handle -z nocopyrelocs.
724 if (sym->symsize() == 0)
727 // If this is a readonly section, then we need a COPY reloc.
728 // Otherwise we can use a dynamic reloc.
729 if ((object->section_flags(shndx) & elfcpp::SHF_WRITE) == 0)
737 template<int size, bool big_endian>
739 Copy_relocs<size, big_endian>::save(
743 Output_section* output_section,
744 const elfcpp::Rel<size, big_endian>& rel)
746 unsigned int reloc_type = elfcpp::elf_r_type<size>(rel.get_r_info());
747 this->entries_.push_back(Copy_reloc_entry(sym, reloc_type, relobj, shndx,
749 rel.get_r_offset(), 0));
752 // Save a Rela reloc.
754 template<int size, bool big_endian>
756 Copy_relocs<size, big_endian>::save(
760 Output_section* output_section,
761 const elfcpp::Rela<size, big_endian>& rela)
763 unsigned int reloc_type = elfcpp::elf_r_type<size>(rela.get_r_info());
764 this->entries_.push_back(Copy_reloc_entry(sym, reloc_type, relobj, shndx,
767 rela.get_r_addend()));
770 // Return whether there are any relocs to emit. We don't want to emit
771 // a reloc if the symbol is no longer defined in a dynamic object.
773 template<int size, bool big_endian>
775 Copy_relocs<size, big_endian>::any_to_emit()
777 for (typename Copy_reloc_entries::iterator p = this->entries_.begin();
778 p != this->entries_.end();
781 if (p->should_emit())
789 template<int size, bool big_endian>
790 template<int sh_type>
792 Copy_relocs<size, big_endian>::emit(
793 Output_data_reloc<sh_type, true, size, big_endian>* reloc_data)
795 for (typename Copy_reloc_entries::iterator p = this->entries_.begin();
796 p != this->entries_.end();
799 if (p->should_emit())
804 // Track_relocs methods.
806 // Initialize the class to track the relocs. This gets the object,
807 // the reloc section index, and the type of the relocs. This returns
808 // false if something goes wrong.
810 template<int size, bool big_endian>
812 Track_relocs<size, big_endian>::initialize(
814 unsigned int reloc_shndx,
815 unsigned int reloc_type)
817 // If RELOC_SHNDX is -1U, it means there is more than one reloc
818 // section for the .eh_frame section. We can't handle that case.
819 if (reloc_shndx == -1U)
822 // If RELOC_SHNDX is 0, there is no reloc section.
823 if (reloc_shndx == 0)
826 // Get the contents of the reloc section.
827 this->prelocs_ = object->section_contents(reloc_shndx, &this->len_, false);
829 if (reloc_type == elfcpp::SHT_REL)
830 this->reloc_size_ = elfcpp::Elf_sizes<size>::rel_size;
831 else if (reloc_type == elfcpp::SHT_RELA)
832 this->reloc_size_ = elfcpp::Elf_sizes<size>::rela_size;
836 if (this->len_ % this->reloc_size_ != 0)
838 object->error(_("reloc section size %zu is not a multiple of "
840 static_cast<size_t>(this->len_),
848 // Return the offset of the next reloc, or -1 if there isn't one.
850 template<int size, bool big_endian>
852 Track_relocs<size, big_endian>::next_offset() const
854 if (this->pos_ >= this->len_)
857 // Rel and Rela start out the same, so we can always use Rel to find
858 // the r_offset value.
859 elfcpp::Rel<size, big_endian> rel(this->prelocs_ + this->pos_);
860 return rel.get_r_offset();
863 // Return the index of the symbol referenced by the next reloc, or -1U
864 // if there aren't any more relocs.
866 template<int size, bool big_endian>
868 Track_relocs<size, big_endian>::next_symndx() const
870 if (this->pos_ >= this->len_)
873 // Rel and Rela start out the same, so we can use Rel to find the
875 elfcpp::Rel<size, big_endian> rel(this->prelocs_ + this->pos_);
876 return elfcpp::elf_r_sym<size>(rel.get_r_info());
879 // Advance to the next reloc whose r_offset is greater than or equal
880 // to OFFSET. Return the number of relocs we skip.
882 template<int size, bool big_endian>
884 Track_relocs<size, big_endian>::advance(off_t offset)
887 while (this->pos_ < this->len_)
889 // Rel and Rela start out the same, so we can always use Rel to
890 // find the r_offset value.
891 elfcpp::Rel<size, big_endian> rel(this->prelocs_ + this->pos_);
892 if (static_cast<off_t>(rel.get_r_offset()) >= offset)
895 this->pos_ += this->reloc_size_;
900 // Instantiate the templates we need. We could use the configure
901 // script to restrict this to only the ones for implemented targets.
903 #ifdef HAVE_TARGET_32_LITTLE
906 Sized_relobj<32, false>::do_read_relocs(Read_relocs_data* rd);
909 #ifdef HAVE_TARGET_32_BIG
912 Sized_relobj<32, true>::do_read_relocs(Read_relocs_data* rd);
915 #ifdef HAVE_TARGET_64_LITTLE
918 Sized_relobj<64, false>::do_read_relocs(Read_relocs_data* rd);
921 #ifdef HAVE_TARGET_64_BIG
924 Sized_relobj<64, true>::do_read_relocs(Read_relocs_data* rd);
927 #ifdef HAVE_TARGET_32_LITTLE
930 Sized_relobj<32, false>::do_scan_relocs(const General_options& options,
931 Symbol_table* symtab,
933 Read_relocs_data* rd);
936 #ifdef HAVE_TARGET_32_BIG
939 Sized_relobj<32, true>::do_scan_relocs(const General_options& options,
940 Symbol_table* symtab,
942 Read_relocs_data* rd);
945 #ifdef HAVE_TARGET_64_LITTLE
948 Sized_relobj<64, false>::do_scan_relocs(const General_options& options,
949 Symbol_table* symtab,
951 Read_relocs_data* rd);
954 #ifdef HAVE_TARGET_64_BIG
957 Sized_relobj<64, true>::do_scan_relocs(const General_options& options,
958 Symbol_table* symtab,
960 Read_relocs_data* rd);
963 #ifdef HAVE_TARGET_32_LITTLE
966 Sized_relobj<32, false>::do_relocate(const General_options& options,
967 const Symbol_table* symtab,
968 const Layout* layout,
972 #ifdef HAVE_TARGET_32_BIG
975 Sized_relobj<32, true>::do_relocate(const General_options& options,
976 const Symbol_table* symtab,
977 const Layout* layout,
981 #ifdef HAVE_TARGET_64_LITTLE
984 Sized_relobj<64, false>::do_relocate(const General_options& options,
985 const Symbol_table* symtab,
986 const Layout* layout,
990 #ifdef HAVE_TARGET_64_BIG
993 Sized_relobj<64, true>::do_relocate(const General_options& options,
994 const Symbol_table* symtab,
995 const Layout* layout,
999 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
1001 class Merged_symbol_value<32>;
1004 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
1006 class Merged_symbol_value<64>;
1009 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
1011 class Symbol_value<32>;
1014 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
1016 class Symbol_value<64>;
1019 #ifdef HAVE_TARGET_32_LITTLE
1021 class Copy_relocs<32, false>;
1024 #ifdef HAVE_TARGET_32_BIG
1026 class Copy_relocs<32, true>;
1029 #ifdef HAVE_TARGET_64_LITTLE
1031 class Copy_relocs<64, false>;
1034 #ifdef HAVE_TARGET_64_BIG
1036 class Copy_relocs<64, true>;
1039 #ifdef HAVE_TARGET_32_LITTLE
1042 Copy_relocs<32, false>::emit<elfcpp::SHT_REL>(
1043 Output_data_reloc<elfcpp::SHT_REL, true, 32, false>*);
1046 #ifdef HAVE_TARGET_32_BIG
1049 Copy_relocs<32, true>::emit<elfcpp::SHT_REL>(
1050 Output_data_reloc<elfcpp::SHT_REL, true, 32, true>*);
1053 #ifdef HAVE_TARGET_64_LITTLE
1056 Copy_relocs<64, false>::emit<elfcpp::SHT_REL>(
1057 Output_data_reloc<elfcpp::SHT_REL, true, 64, false>*);
1060 #ifdef HAVE_TARGET_64_BIG
1063 Copy_relocs<64, true>::emit<elfcpp::SHT_REL>(
1064 Output_data_reloc<elfcpp::SHT_REL, true, 64, true>*);
1067 #ifdef HAVE_TARGET_32_LITTLE
1070 Copy_relocs<32, false>::emit<elfcpp::SHT_RELA>(
1071 Output_data_reloc<elfcpp::SHT_RELA , true, 32, false>*);
1074 #ifdef HAVE_TARGET_32_BIG
1077 Copy_relocs<32, true>::emit<elfcpp::SHT_RELA>(
1078 Output_data_reloc<elfcpp::SHT_RELA, true, 32, true>*);
1081 #ifdef HAVE_TARGET_64_LITTLE
1084 Copy_relocs<64, false>::emit<elfcpp::SHT_RELA>(
1085 Output_data_reloc<elfcpp::SHT_RELA, true, 64, false>*);
1088 #ifdef HAVE_TARGET_64_BIG
1091 Copy_relocs<64, true>::emit<elfcpp::SHT_RELA>(
1092 Output_data_reloc<elfcpp::SHT_RELA, true, 64, true>*);
1095 #ifdef HAVE_TARGET_32_LITTLE
1097 class Track_relocs<32, false>;
1100 #ifdef HAVE_TARGET_32_BIG
1102 class Track_relocs<32, true>;
1105 #ifdef HAVE_TARGET_64_LITTLE
1107 class Track_relocs<64, false>;
1110 #ifdef HAVE_TARGET_64_BIG
1112 class Track_relocs<64, true>;
1115 } // End namespace gold.