Add licensing text to every source file.
[external/binutils.git] / gold / reloc.cc
1 // reloc.cc -- relocate input files for gold.
2
3 // Copyright 2006, 2007 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
5
6 // This file is part of gold.
7
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.
12
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.
17
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.
22
23 #include "gold.h"
24
25 #include "workqueue.h"
26 #include "object.h"
27 #include "symtab.h"
28 #include "output.h"
29 #include "reloc.h"
30
31 namespace gold
32 {
33
34 // Read_relocs methods.
35
36 // These tasks just read the relocation information from the file.
37 // After reading it, the start another task to process the
38 // information.  These tasks requires access to the file.
39
40 Task::Is_runnable_type
41 Read_relocs::is_runnable(Workqueue*)
42 {
43   return this->object_->is_locked() ? IS_LOCKED : IS_RUNNABLE;
44 }
45
46 // Lock the file.
47
48 Task_locker*
49 Read_relocs::locks(Workqueue*)
50 {
51   return new Task_locker_obj<Object>(*this->object_);
52 }
53
54 // Read the relocations and then start a Scan_relocs_task.
55
56 void
57 Read_relocs::run(Workqueue* workqueue)
58 {
59   Read_relocs_data *rd = new Read_relocs_data;
60   this->object_->read_relocs(rd);
61   workqueue->queue_front(new Scan_relocs(this->options_, this->symtab_,
62                                          this->layout_, this->object_, rd,
63                                          this->symtab_lock_, this->blocker_));
64 }
65
66 // Scan_relocs methods.
67
68 // These tasks scan the relocations read by Read_relocs and mark up
69 // the symbol table to indicate which relocations are required.  We
70 // use a lock on the symbol table to keep them from interfering with
71 // each other.
72
73 Task::Is_runnable_type
74 Scan_relocs::is_runnable(Workqueue*)
75 {
76   if (!this->symtab_lock_->is_writable() || this->object_->is_locked())
77     return IS_LOCKED;
78   return IS_RUNNABLE;
79 }
80
81 // Return the locks we hold: one on the file, one on the symbol table
82 // and one blocker.
83
84 class Scan_relocs::Scan_relocs_locker : public Task_locker
85 {
86  public:
87   Scan_relocs_locker(Object* object, Task_token& symtab_lock, Task* task,
88                      Task_token& blocker, Workqueue* workqueue)
89     : objlock_(*object), symtab_locker_(symtab_lock, task),
90       blocker_(blocker, workqueue)
91   { }
92
93  private:
94   Task_locker_obj<Object> objlock_;
95   Task_locker_write symtab_locker_;
96   Task_locker_block blocker_;
97 };
98
99 Task_locker*
100 Scan_relocs::locks(Workqueue* workqueue)
101 {
102   return new Scan_relocs_locker(this->object_, *this->symtab_lock_, this,
103                                 *this->blocker_, workqueue);
104 }
105
106 // Scan the relocs.
107
108 void
109 Scan_relocs::run(Workqueue*)
110 {
111   this->object_->scan_relocs(this->options_, this->symtab_, this->layout_,
112                              this->rd_);
113   delete this->rd_;
114   this->rd_ = NULL;
115 }
116
117 // Relocate_task methods.
118
119 // These tasks are always runnable.
120
121 Task::Is_runnable_type
122 Relocate_task::is_runnable(Workqueue*)
123 {
124   return IS_RUNNABLE;
125 }
126
127 // We want to lock the file while we run.  We want to unblock
128 // FINAL_BLOCKER when we are done.
129
130 class Relocate_task::Relocate_locker : public Task_locker
131 {
132  public:
133   Relocate_locker(Task_token& token, Workqueue* workqueue,
134                   Object* object)
135     : blocker_(token, workqueue), objlock_(*object)
136   { }
137
138  private:
139   Task_locker_block blocker_;
140   Task_locker_obj<Object> objlock_;
141 };
142
143 Task_locker*
144 Relocate_task::locks(Workqueue* workqueue)
145 {
146   return new Relocate_locker(*this->final_blocker_, workqueue,
147                              this->object_);
148 }
149
150 // Run the task.
151
152 void
153 Relocate_task::run(Workqueue*)
154 {
155   this->object_->relocate(this->options_, this->symtab_, this->layout_,
156                           this->of_);
157 }
158
159 // Read the relocs and local symbols from the object file and store
160 // the information in RD.
161
162 template<int size, bool big_endian>
163 void
164 Sized_relobj<size, big_endian>::do_read_relocs(Read_relocs_data* rd)
165 {
166   rd->relocs.clear();
167
168   unsigned int shnum = this->shnum();
169   if (shnum == 0)
170     return;
171
172   rd->relocs.reserve(shnum / 2);
173
174   const unsigned char *pshdrs = this->get_view(this->elf_file_.shoff(),
175                                                shnum * This::shdr_size);
176   // Skip the first, dummy, section.
177   const unsigned char *ps = pshdrs + This::shdr_size;
178   for (unsigned int i = 1; i < shnum; ++i, ps += This::shdr_size)
179     {
180       typename This::Shdr shdr(ps);
181
182       unsigned int sh_type = shdr.get_sh_type();
183       if (sh_type != elfcpp::SHT_REL && sh_type != elfcpp::SHT_RELA)
184         continue;
185
186       unsigned int shndx = shdr.get_sh_info();
187       if (shndx >= shnum)
188         {
189           fprintf(stderr, _("%s: %s: relocation section %u has bad info %u\n"),
190                   program_name, this->name().c_str(), i, shndx);
191           gold_exit(false);
192         }
193
194       if (!this->is_section_included(shndx))
195         continue;
196
197       // We are scanning relocations in order to fill out the GOT and
198       // PLT sections.  Relocations for sections which are not
199       // allocated (typically debugging sections) should not add new
200       // GOT and PLT entries.  So we skip them.
201       typename This::Shdr secshdr(pshdrs + shndx * This::shdr_size);
202       if ((secshdr.get_sh_flags() & elfcpp::SHF_ALLOC) == 0)
203         continue;
204
205       if (shdr.get_sh_link() != this->symtab_shndx_)
206         {
207           fprintf(stderr,
208                   _("%s: %s: relocation section %u uses unexpected "
209                     "symbol table %u\n"),
210                   program_name, this->name().c_str(), i, shdr.get_sh_link());
211           gold_exit(false);
212         }
213
214       off_t sh_size = shdr.get_sh_size();
215
216       unsigned int reloc_size;
217       if (sh_type == elfcpp::SHT_REL)
218         reloc_size = elfcpp::Elf_sizes<size>::rel_size;
219       else
220         reloc_size = elfcpp::Elf_sizes<size>::rela_size;
221       if (reloc_size != shdr.get_sh_entsize())
222         {
223           fprintf(stderr,
224                   _("%s: %s: unexpected entsize for reloc section %u: "
225                     "%lu != %u"),
226                   program_name, this->name().c_str(), i,
227                   static_cast<unsigned long>(shdr.get_sh_entsize()),
228                   reloc_size);
229           gold_exit(false);
230         }
231
232       size_t reloc_count = sh_size / reloc_size;
233       if (reloc_count * reloc_size != sh_size)
234         {
235           fprintf(stderr, _("%s: %s: reloc section %u size %lu uneven"),
236                   program_name, this->name().c_str(), i,
237                   static_cast<unsigned long>(sh_size));
238           gold_exit(false);
239         }
240
241       rd->relocs.push_back(Section_relocs());
242       Section_relocs& sr(rd->relocs.back());
243       sr.reloc_shndx = i;
244       sr.data_shndx = shndx;
245       sr.contents = this->get_lasting_view(shdr.get_sh_offset(), sh_size);
246       sr.sh_type = sh_type;
247       sr.reloc_count = reloc_count;
248     }
249
250   // Read the local symbols.
251   gold_assert(this->symtab_shndx_ != -1U);
252   if (this->symtab_shndx_ == 0 || this->local_symbol_count_ == 0)
253     rd->local_symbols = NULL;
254   else
255     {
256       typename This::Shdr symtabshdr(pshdrs
257                                      + this->symtab_shndx_ * This::shdr_size);
258       gold_assert(symtabshdr.get_sh_type() == elfcpp::SHT_SYMTAB);
259       const int sym_size = This::sym_size;
260       const unsigned int loccount = this->local_symbol_count_;
261       gold_assert(loccount == symtabshdr.get_sh_info());
262       off_t locsize = loccount * sym_size;
263       rd->local_symbols = this->get_lasting_view(symtabshdr.get_sh_offset(),
264                                                  locsize);
265     }
266 }
267
268 // Scan the relocs and adjust the symbol table.  This looks for
269 // relocations which require GOT/PLT/COPY relocations.
270
271 template<int size, bool big_endian>
272 void
273 Sized_relobj<size, big_endian>::do_scan_relocs(const General_options& options,
274                                                Symbol_table* symtab,
275                                                Layout* layout,
276                                                Read_relocs_data* rd)
277 {
278   Sized_target<size, big_endian>* target = this->sized_target();
279
280   const unsigned char* local_symbols;
281   if (rd->local_symbols == NULL)
282     local_symbols = NULL;
283   else
284     local_symbols = rd->local_symbols->data();
285
286   for (Read_relocs_data::Relocs_list::iterator p = rd->relocs.begin();
287        p != rd->relocs.end();
288        ++p)
289     {
290       target->scan_relocs(options, symtab, layout, this, p->data_shndx,
291                           p->sh_type, p->contents->data(), p->reloc_count,
292                           this->local_symbol_count_,
293                           local_symbols,
294                           this->symbols_);
295       delete p->contents;
296       p->contents = NULL;
297     }
298
299   if (rd->local_symbols != NULL)
300     {
301       delete rd->local_symbols;
302       rd->local_symbols = NULL;
303     }
304 }
305
306 // Relocate the input sections and write out the local symbols.
307
308 template<int size, bool big_endian>
309 void
310 Sized_relobj<size, big_endian>::do_relocate(const General_options& options,
311                                             const Symbol_table* symtab,
312                                             const Layout* layout,
313                                             Output_file* of)
314 {
315   unsigned int shnum = this->shnum();
316
317   // Read the section headers.
318   const unsigned char* pshdrs = this->get_view(this->elf_file_.shoff(),
319                                                shnum * This::shdr_size);
320
321   Views views;
322   views.resize(shnum);
323
324   // Make two passes over the sections.  The first one copies the
325   // section data to the output file.  The second one applies
326   // relocations.
327
328   this->write_sections(pshdrs, of, &views);
329
330   // Apply relocations.
331
332   this->relocate_sections(options, symtab, layout, pshdrs, &views);
333
334   // Write out the accumulated views.
335   for (unsigned int i = 1; i < shnum; ++i)
336     {
337       if (views[i].view != NULL)
338         of->write_output_view(views[i].offset, views[i].view_size,
339                               views[i].view);
340     }
341
342   // Write out the local symbols.
343   this->write_local_symbols(of, layout->sympool());
344 }
345
346 // Write section data to the output file.  PSHDRS points to the
347 // section headers.  Record the views in *PVIEWS for use when
348 // relocating.
349
350 template<int size, bool big_endian>
351 void
352 Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
353                                                Output_file* of,
354                                                Views* pviews)
355 {
356   unsigned int shnum = this->shnum();
357   std::vector<Map_to_output>& map_sections(this->map_to_output());
358
359   const unsigned char* p = pshdrs + This::shdr_size;
360   for (unsigned int i = 1; i < shnum; ++i, p += This::shdr_size)
361     {
362       View_size* pvs = &(*pviews)[i];
363
364       pvs->view = NULL;
365
366       if (map_sections[i].offset == -1)
367         continue;
368
369       const Output_section* os = map_sections[i].output_section;
370       if (os == NULL)
371         continue;
372
373       typename This::Shdr shdr(p);
374
375       if (shdr.get_sh_type() == elfcpp::SHT_NOBITS)
376         continue;
377
378       off_t start = os->offset() + map_sections[i].offset;
379       off_t sh_size = shdr.get_sh_size();
380
381       if (sh_size == 0)
382         continue;
383
384       gold_assert(map_sections[i].offset >= 0
385                   && map_sections[i].offset + sh_size <= os->data_size());
386
387       unsigned char* view = of->get_output_view(start, sh_size);
388       this->read(shdr.get_sh_offset(), sh_size, view);
389
390       pvs->view = view;
391       pvs->address = os->address() + map_sections[i].offset;
392       pvs->offset = start;
393       pvs->view_size = sh_size;
394     }
395 }
396
397 // Relocate section data.  VIEWS points to the section data as views
398 // in the output file.
399
400 template<int size, bool big_endian>
401 void
402 Sized_relobj<size, big_endian>::relocate_sections(
403     const General_options& options,
404     const Symbol_table* symtab,
405     const Layout* layout,
406     const unsigned char* pshdrs,
407     Views* pviews)
408 {
409   unsigned int shnum = this->shnum();
410   Sized_target<size, big_endian>* target = this->sized_target();
411
412   Relocate_info<size, big_endian> relinfo;
413   relinfo.options = &options;
414   relinfo.symtab = symtab;
415   relinfo.layout = layout;
416   relinfo.object = this;
417   relinfo.local_symbol_count = this->local_symbol_count_;
418   relinfo.local_values = &this->local_values_;
419   relinfo.symbols = this->symbols_;
420
421   const unsigned char* p = pshdrs + This::shdr_size;
422   for (unsigned int i = 1; i < shnum; ++i, p += This::shdr_size)
423     {
424       typename This::Shdr shdr(p);
425
426       unsigned int sh_type = shdr.get_sh_type();
427       if (sh_type != elfcpp::SHT_REL && sh_type != elfcpp::SHT_RELA)
428         continue;
429
430       unsigned int index = shdr.get_sh_info();
431       if (index >= this->shnum())
432         {
433           fprintf(stderr, _("%s: %s: relocation section %u has bad info %u\n"),
434                   program_name, this->name().c_str(), i, index);
435           gold_exit(false);
436         }
437
438       if (!this->is_section_included(index))
439         {
440           // This relocation section is against a section which we
441           // discarded.
442           continue;
443         }
444
445       gold_assert((*pviews)[index].view != NULL);
446
447       if (shdr.get_sh_link() != this->symtab_shndx_)
448         {
449           fprintf(stderr,
450                   _("%s: %s: relocation section %u uses unexpected "
451                     "symbol table %u\n"),
452                   program_name, this->name().c_str(), i, shdr.get_sh_link());
453           gold_exit(false);
454         }
455
456       off_t sh_size = shdr.get_sh_size();
457       const unsigned char* prelocs = this->get_view(shdr.get_sh_offset(),
458                                                     sh_size);
459
460       unsigned int reloc_size;
461       if (sh_type == elfcpp::SHT_REL)
462         reloc_size = elfcpp::Elf_sizes<size>::rel_size;
463       else
464         reloc_size = elfcpp::Elf_sizes<size>::rela_size;
465
466       if (reloc_size != shdr.get_sh_entsize())
467         {
468           fprintf(stderr,
469                   _("%s: %s: unexpected entsize for reloc section %u: "
470                     "%lu != %u"),
471                   program_name, this->name().c_str(), i,
472                   static_cast<unsigned long>(shdr.get_sh_entsize()),
473                   reloc_size);
474           gold_exit(false);
475         }
476
477       size_t reloc_count = sh_size / reloc_size;
478       if (reloc_count * reloc_size != sh_size)
479         {
480           fprintf(stderr, _("%s: %s: reloc section %u size %lu uneven"),
481                   program_name, this->name().c_str(), i,
482                   static_cast<unsigned long>(sh_size));
483           gold_exit(false);
484         }
485
486       relinfo.reloc_shndx = i;
487       relinfo.data_shndx = index;
488       target->relocate_section(&relinfo,
489                                sh_type,
490                                prelocs,
491                                reloc_count,
492                                (*pviews)[index].view,
493                                (*pviews)[index].address,
494                                (*pviews)[index].view_size);
495     }
496 }
497
498 // Copy_relocs::Copy_reloc_entry methods.
499
500 // Return whether we should emit this reloc.  We should emit it if the
501 // symbol is still defined in a dynamic object.  If we should not emit
502 // it, we clear it, to save ourselves the test next time.
503
504 template<int size, bool big_endian>
505 bool
506 Copy_relocs<size, big_endian>::Copy_reloc_entry::should_emit()
507 {
508   if (this->sym_ == NULL)
509     return false;
510   if (this->sym_->is_from_dynobj())
511     return true;
512   this->sym_ = NULL;
513   return false;
514 }
515
516 // Emit a reloc into a SHT_REL section.
517
518 template<int size, bool big_endian>
519 void
520 Copy_relocs<size, big_endian>::Copy_reloc_entry::emit(
521     Output_data_reloc<elfcpp::SHT_REL, true, size, big_endian>* reloc_data)
522 {
523   this->sym_->set_needs_dynsym_entry();
524   reloc_data->add_global(this->sym_, this->reloc_type_, this->relobj_,
525                          this->shndx_, this->address_);
526 }
527
528 // Emit a reloc into a SHT_RELA section.
529
530 template<int size, bool big_endian>
531 void
532 Copy_relocs<size, big_endian>::Copy_reloc_entry::emit(
533     Output_data_reloc<elfcpp::SHT_RELA, true, size, big_endian>* reloc_data)
534 {
535   this->sym_->set_needs_dynsym_entry();
536   reloc_data->add_global(this->sym_, this->reloc_type_, this->relobj_,
537                          this->shndx_, this->address_, this->addend_);
538 }
539
540 // Copy_relocs methods.
541
542 // Return whether we need a COPY reloc for a relocation against GSYM.
543 // The relocation is being applied to section SHNDX in OBJECT.
544
545 template<int size, bool big_endian>
546 bool
547 Copy_relocs<size, big_endian>::need_copy_reloc(
548     const General_options*,
549     Relobj* object,
550     unsigned int shndx,
551     Sized_symbol<size>* sym)
552 {
553   // FIXME: Handle -z nocopyrelocs.
554
555   if (sym->symsize() == 0)
556     return false;
557
558   // If this is a readonly section, then we need a COPY reloc.
559   // Otherwise we can use a dynamic reloc.
560   if ((object->section_flags(shndx) & elfcpp::SHF_WRITE) == 0)
561     return true;
562
563   return false;
564 }
565
566 // Save a Rel reloc.
567
568 template<int size, bool big_endian>
569 void
570 Copy_relocs<size, big_endian>::save(
571     Symbol* sym,
572     Relobj* relobj,
573     unsigned int shndx,
574     const elfcpp::Rel<size, big_endian>& rel)
575 {
576   unsigned int reloc_type = elfcpp::elf_r_type<size>(rel.get_r_info());
577   this->entries_.push_back(Copy_reloc_entry(sym, reloc_type, relobj, shndx,
578                                             rel.get_r_offset(), 0));
579 }
580
581 // Save a Rela reloc.
582
583 template<int size, bool big_endian>
584 void
585 Copy_relocs<size, big_endian>::save(
586     Symbol* sym,
587     Relobj* relobj,
588     unsigned int shndx,
589     const elfcpp::Rela<size, big_endian>& rela)
590 {
591   unsigned int reloc_type = elfcpp::elf_r_type<size>(rela.get_r_info());
592   this->entries_.push_back(Copy_reloc_entry(sym, reloc_type, relobj, shndx,
593                                             rela.get_r_offset(),
594                                             rela.get_r_addend()));
595 }
596
597 // Return whether there are any relocs to emit.  We don't want to emit
598 // a reloc if the symbol is no longer defined in a dynamic object.
599
600 template<int size, bool big_endian>
601 bool
602 Copy_relocs<size, big_endian>::any_to_emit()
603 {
604   for (typename Copy_reloc_entries::iterator p = this->entries_.begin();
605        p != this->entries_.end();
606        ++p)
607     {
608       if (p->should_emit())
609         return true;
610     }
611   return false;
612 }
613
614 // Emit relocs.
615
616 template<int size, bool big_endian>
617 template<int sh_type>
618 void
619 Copy_relocs<size, big_endian>::emit(
620     Output_data_reloc<sh_type, true, size, big_endian>* reloc_data)
621 {
622   for (typename Copy_reloc_entries::iterator p = this->entries_.begin();
623        p != this->entries_.end();
624        ++p)
625     {
626       if (p->should_emit())
627         p->emit(reloc_data);
628     }
629 }
630
631 // Instantiate the templates we need.  We could use the configure
632 // script to restrict this to only the ones for implemented targets.
633
634 #ifdef HAVE_TARGET_32_LITTLE
635 template
636 void
637 Sized_relobj<32, false>::do_read_relocs(Read_relocs_data* rd);
638 #endif
639
640 #ifdef HAVE_TARGET_32_BIG
641 template
642 void
643 Sized_relobj<32, true>::do_read_relocs(Read_relocs_data* rd);
644 #endif
645
646 #ifdef HAVE_TARGET_64_LITTLE
647 template
648 void
649 Sized_relobj<64, false>::do_read_relocs(Read_relocs_data* rd);
650 #endif
651
652 #ifdef HAVE_TARGET_64_BIG
653 template
654 void
655 Sized_relobj<64, true>::do_read_relocs(Read_relocs_data* rd);
656 #endif
657
658 #ifdef HAVE_TARGET_32_LITTLE
659 template
660 void
661 Sized_relobj<32, false>::do_scan_relocs(const General_options& options,
662                                         Symbol_table* symtab,
663                                         Layout* layout,
664                                         Read_relocs_data* rd);
665 #endif
666
667 #ifdef HAVE_TARGET_32_BIG
668 template
669 void
670 Sized_relobj<32, true>::do_scan_relocs(const General_options& options,
671                                        Symbol_table* symtab,
672                                        Layout* layout,
673                                        Read_relocs_data* rd);
674 #endif
675
676 #ifdef HAVE_TARGET_64_LITTLE
677 template
678 void
679 Sized_relobj<64, false>::do_scan_relocs(const General_options& options,
680                                         Symbol_table* symtab,
681                                         Layout* layout,
682                                         Read_relocs_data* rd);
683 #endif
684
685 #ifdef HAVE_TARGET_64_BIG
686 template
687 void
688 Sized_relobj<64, true>::do_scan_relocs(const General_options& options,
689                                        Symbol_table* symtab,
690                                        Layout* layout,
691                                        Read_relocs_data* rd);
692 #endif
693
694 #ifdef HAVE_TARGET_32_LITTLE
695 template
696 void
697 Sized_relobj<32, false>::do_relocate(const General_options& options,
698                                      const Symbol_table* symtab,
699                                      const Layout* layout,
700                                      Output_file* of);
701 #endif
702
703 #ifdef HAVE_TARGET_32_BIG
704 template
705 void
706 Sized_relobj<32, true>::do_relocate(const General_options& options,
707                                     const Symbol_table* symtab,
708                                     const Layout* layout,
709                                     Output_file* of);
710 #endif
711
712 #ifdef HAVE_TARGET_64_LITTLE
713 template
714 void
715 Sized_relobj<64, false>::do_relocate(const General_options& options,
716                                      const Symbol_table* symtab,
717                                      const Layout* layout,
718                                      Output_file* of);
719 #endif
720
721 #ifdef HAVE_TARGET_64_BIG
722 template
723 void
724 Sized_relobj<64, true>::do_relocate(const General_options& options,
725                                     const Symbol_table* symtab,
726                                     const Layout* layout,
727                                     Output_file* of);
728 #endif
729
730 #ifdef HAVE_TARGET_32_LITTLE
731 template
732 class Copy_relocs<32, false>;
733 #endif
734
735 #ifdef HAVE_TARGET_32_BIG
736 template
737 class Copy_relocs<32, true>;
738 #endif
739
740 #ifdef HAVE_TARGET_64_LITTLE
741 template
742 class Copy_relocs<64, false>;
743 #endif
744
745 #ifdef HAVE_TARGET_64_BIG
746 template
747 class Copy_relocs<64, true>;
748 #endif
749
750 #ifdef HAVE_TARGET_32_LITTLE
751 template
752 void
753 Copy_relocs<32, false>::emit<elfcpp::SHT_REL>(
754     Output_data_reloc<elfcpp::SHT_REL, true, 32, false>*);
755 #endif
756
757 #ifdef HAVE_TARGET_32_BIG
758 template
759 void
760 Copy_relocs<32, true>::emit<elfcpp::SHT_REL>(
761     Output_data_reloc<elfcpp::SHT_REL, true, 32, true>*);
762 #endif
763
764 #ifdef HAVE_TARGET_64_LITTLE
765 template
766 void
767 Copy_relocs<64, false>::emit<elfcpp::SHT_REL>(
768     Output_data_reloc<elfcpp::SHT_REL, true, 64, false>*);
769 #endif
770
771 #ifdef HAVE_TARGET_64_BIG
772 template
773 void
774 Copy_relocs<64, true>::emit<elfcpp::SHT_REL>(
775     Output_data_reloc<elfcpp::SHT_REL, true, 64, true>*);
776 #endif
777
778 #ifdef HAVE_TARGET_32_LITTLE
779 template
780 void
781 Copy_relocs<32, false>::emit<elfcpp::SHT_RELA>(
782     Output_data_reloc<elfcpp::SHT_RELA , true, 32, false>*);
783 #endif
784
785 #ifdef HAVE_TARGET_32_BIG
786 template
787 void
788 Copy_relocs<32, true>::emit<elfcpp::SHT_RELA>(
789     Output_data_reloc<elfcpp::SHT_RELA, true, 32, true>*);
790 #endif
791
792 #ifdef HAVE_TARGET_64_LITTLE
793 template
794 void
795 Copy_relocs<64, false>::emit<elfcpp::SHT_RELA>(
796     Output_data_reloc<elfcpp::SHT_RELA, true, 64, false>*);
797 #endif
798
799 #ifdef HAVE_TARGET_64_BIG
800 template
801 void
802 Copy_relocs<64, true>::emit<elfcpp::SHT_RELA>(
803     Output_data_reloc<elfcpp::SHT_RELA, true, 64, true>*);
804 #endif
805
806 } // End namespace gold.