2010-06-25 Doug Kwan <dougkwan@google.com>
[platform/upstream/binutils.git] / gold / target.h
1 // target.h -- target support for gold   -*- C++ -*-
2
3 // Copyright 2006, 2007, 2008, 2009 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 // The abstract class Target is the interface for target specific
24 // support.  It defines abstract methods which each target must
25 // implement.  Typically there will be one target per processor, but
26 // in some cases it may be necessary to have subclasses.
27
28 // For speed and consistency we want to use inline functions to handle
29 // relocation processing.  So besides implementations of the abstract
30 // methods, each target is expected to define a template
31 // specialization of the relocation functions.
32
33 #ifndef GOLD_TARGET_H
34 #define GOLD_TARGET_H
35
36 #include "elfcpp.h"
37 #include "options.h"
38 #include "parameters.h"
39 #include "debug.h"
40
41 namespace gold
42 {
43
44 class Object;
45 class Relobj;
46 template<int size, bool big_endian>
47 class Sized_relobj;
48 class Relocatable_relocs;
49 template<int size, bool big_endian>
50 class Relocate_info;
51 class Reloc_symbol_changes;
52 class Symbol;
53 template<int size>
54 class Sized_symbol;
55 class Symbol_table;
56 class Output_section;
57 class Input_objects;
58
59 // The abstract class for target specific handling.
60
61 class Target
62 {
63  public:
64   virtual ~Target()
65   { }
66
67   // Virtual function which is set to return true by a target if
68   // it can use relocation types to determine if a function's
69   // pointer is taken.
70   virtual bool
71   can_check_for_function_pointers() const
72   { return false; }
73
74   // Whether a section called SECTION_NAME may have function pointers to
75   // sections not eligible for safe ICF folding.
76   virtual bool
77   section_may_have_icf_unsafe_pointers(const char* section_name) const
78   {
79     // We recognize sections for normal vtables, construction vtables and
80     // EH frames.
81     return (!is_prefix_of(".rodata._ZTV", section_name)
82             && !is_prefix_of(".data.rel.ro._ZTV", section_name)
83             && !is_prefix_of(".rodata._ZTC", section_name)
84             && !is_prefix_of(".data.rel.ro._ZTC", section_name)
85             && !is_prefix_of(".eh_frame", section_name));
86   }
87
88   // Return the bit size that this target implements.  This should
89   // return 32 or 64.
90   int
91   get_size() const
92   { return this->pti_->size; }
93
94   // Return whether this target is big-endian.
95   bool
96   is_big_endian() const
97   { return this->pti_->is_big_endian; }
98
99   // Machine code to store in e_machine field of ELF header.
100   elfcpp::EM
101   machine_code() const
102   { return this->pti_->machine_code; }
103
104   // Processor specific flags to store in e_flags field of ELF header.
105   elfcpp::Elf_Word
106   processor_specific_flags() const
107   { return this->processor_specific_flags_; }
108
109   // Whether processor specific flags are set at least once.
110   bool
111   are_processor_specific_flags_set() const
112   { return this->are_processor_specific_flags_set_; }
113
114   // Whether this target has a specific make_symbol function.
115   bool
116   has_make_symbol() const
117   { return this->pti_->has_make_symbol; }
118
119   // Whether this target has a specific resolve function.
120   bool
121   has_resolve() const
122   { return this->pti_->has_resolve; }
123
124   // Whether this target has a specific code fill function.
125   bool
126   has_code_fill() const
127   { return this->pti_->has_code_fill; }
128
129   // Return the default name of the dynamic linker.
130   const char*
131   dynamic_linker() const
132   { return this->pti_->dynamic_linker; }
133
134   // Return the default address to use for the text segment.
135   uint64_t
136   default_text_segment_address() const
137   { return this->pti_->default_text_segment_address; }
138
139   // Return the ABI specified page size.
140   uint64_t
141   abi_pagesize() const
142   {
143     if (parameters->options().max_page_size() > 0)
144       return parameters->options().max_page_size();
145     else
146       return this->pti_->abi_pagesize;
147   }
148
149   // Return the common page size used on actual systems.
150   uint64_t
151   common_pagesize() const
152   {
153     if (parameters->options().common_page_size() > 0)
154       return std::min(parameters->options().common_page_size(),
155                       this->abi_pagesize());
156     else
157       return std::min(this->pti_->common_pagesize,
158                       this->abi_pagesize());
159   }
160
161   // If we see some object files with .note.GNU-stack sections, and
162   // some objects files without them, this returns whether we should
163   // consider the object files without them to imply that the stack
164   // should be executable.
165   bool
166   is_default_stack_executable() const
167   { return this->pti_->is_default_stack_executable; }
168
169   // Return a character which may appear as a prefix for a wrap
170   // symbol.  If this character appears, we strip it when checking for
171   // wrapping and add it back when forming the final symbol name.
172   // This should be '\0' if not special prefix is required, which is
173   // the normal case.
174   char
175   wrap_char() const
176   { return this->pti_->wrap_char; }
177
178   // Return the special section index which indicates a small common
179   // symbol.  This will return SHN_UNDEF if there are no small common
180   // symbols.
181   elfcpp::Elf_Half
182   small_common_shndx() const
183   { return this->pti_->small_common_shndx; }
184
185   // Return values to add to the section flags for the section holding
186   // small common symbols.
187   elfcpp::Elf_Xword
188   small_common_section_flags() const
189   {
190     gold_assert(this->pti_->small_common_shndx != elfcpp::SHN_UNDEF);
191     return this->pti_->small_common_section_flags;
192   }
193
194   // Return the special section index which indicates a large common
195   // symbol.  This will return SHN_UNDEF if there are no large common
196   // symbols.
197   elfcpp::Elf_Half
198   large_common_shndx() const
199   { return this->pti_->large_common_shndx; }
200
201   // Return values to add to the section flags for the section holding
202   // large common symbols.
203   elfcpp::Elf_Xword
204   large_common_section_flags() const
205   {
206     gold_assert(this->pti_->large_common_shndx != elfcpp::SHN_UNDEF);
207     return this->pti_->large_common_section_flags;
208   }
209
210   // This hook is called when an output section is created.
211   void
212   new_output_section(Output_section* os) const
213   { this->do_new_output_section(os); }
214
215   // This is called to tell the target to complete any sections it is
216   // handling.  After this all sections must have their final size.
217   void
218   finalize_sections(Layout* layout, const Input_objects* input_objects,
219                     Symbol_table* symtab)
220   { return this->do_finalize_sections(layout, input_objects, symtab); }
221
222   // Return the value to use for a global symbol which needs a special
223   // value in the dynamic symbol table.  This will only be called if
224   // the backend first calls symbol->set_needs_dynsym_value().
225   uint64_t
226   dynsym_value(const Symbol* sym) const
227   { return this->do_dynsym_value(sym); }
228
229   // Return a string to use to fill out a code section.  This is
230   // basically one or more NOPS which must fill out the specified
231   // length in bytes.
232   std::string
233   code_fill(section_size_type length) const
234   { return this->do_code_fill(length); }
235
236   // Return whether SYM is known to be defined by the ABI.  This is
237   // used to avoid inappropriate warnings about undefined symbols.
238   bool
239   is_defined_by_abi(const Symbol* sym) const
240   { return this->do_is_defined_by_abi(sym); }
241
242   // Adjust the output file header before it is written out.  VIEW
243   // points to the header in external form.  LEN is the length.
244   void
245   adjust_elf_header(unsigned char* view, int len) const
246   { return this->do_adjust_elf_header(view, len); }
247
248   // Return whether NAME is a local label name.  This is used to implement the
249   // --discard-locals options.
250   bool
251   is_local_label_name(const char* name) const
252   { return this->do_is_local_label_name(name); }
253
254   // Get the symbol index to use for a target specific reloc.
255   unsigned int
256   reloc_symbol_index(void* arg, unsigned int type) const
257   { return this->do_reloc_symbol_index(arg, type); }
258
259   // Get the addend to use for a target specific reloc.
260   uint64_t
261   reloc_addend(void* arg, unsigned int type, uint64_t addend) const
262   { return this->do_reloc_addend(arg, type, addend); }
263
264   // Return true if a reference to SYM from a reloc of type R_TYPE
265   // means that the current function may call an object compiled
266   // without -fsplit-stack.  SYM is known to be defined in an object
267   // compiled without -fsplit-stack.
268   bool
269   is_call_to_non_split(const Symbol* sym, unsigned int r_type) const
270   { return this->do_is_call_to_non_split(sym, r_type); }
271
272   // A function starts at OFFSET in section SHNDX in OBJECT.  That
273   // function was compiled with -fsplit-stack, but it refers to a
274   // function which was compiled without -fsplit-stack.  VIEW is a
275   // modifiable view of the section; VIEW_SIZE is the size of the
276   // view.  The target has to adjust the function so that it allocates
277   // enough stack.
278   void
279   calls_non_split(Relobj* object, unsigned int shndx,
280                   section_offset_type fnoffset, section_size_type fnsize,
281                   unsigned char* view, section_size_type view_size,
282                   std::string* from, std::string* to) const
283   {
284     this->do_calls_non_split(object, shndx, fnoffset, fnsize, view, view_size,
285                              from, to);
286   }
287
288   // Make an ELF object.
289   template<int size, bool big_endian>
290   Object*
291   make_elf_object(const std::string& name, Input_file* input_file,
292                   off_t offset, const elfcpp::Ehdr<size, big_endian>& ehdr)
293   { return this->do_make_elf_object(name, input_file, offset, ehdr); }
294
295   // Make an output section.
296   Output_section*
297   make_output_section(const char* name, elfcpp::Elf_Word type,
298                       elfcpp::Elf_Xword flags)
299   { return this->do_make_output_section(name, type, flags); }
300
301   // Return true if target wants to perform relaxation.
302   bool
303   may_relax() const
304   {
305     // Run the dummy relaxation pass twice if relaxation debugging is enabled.
306     if (is_debugging_enabled(DEBUG_RELAXATION))
307       return true;
308
309      return this->do_may_relax();
310   }
311
312   // Perform a relaxation pass.  Return true if layout may be changed.
313   bool
314   relax(int pass, const Input_objects* input_objects, Symbol_table* symtab,
315         Layout* layout)
316   {
317     // Run the dummy relaxation pass twice if relaxation debugging is enabled.
318     if (is_debugging_enabled(DEBUG_RELAXATION))
319       return pass < 2;
320
321     return this->do_relax(pass, input_objects, symtab, layout);
322   } 
323
324   // Return the target-specific name of attributes section.  This is
325   // NULL if a target does not use attributes section or if it uses
326   // the default section name ".gnu.attributes".
327   const char*
328   attributes_section() const
329   { return this->pti_->attributes_section; }
330
331   // Return the vendor name of vendor attributes.
332   const char*
333   attributes_vendor() const
334   { return this->pti_->attributes_vendor; }
335
336   // Whether a section called NAME is an attribute section.
337   bool
338   is_attributes_section(const char* name) const
339   {
340     return ((this->pti_->attributes_section != NULL
341              && strcmp(name, this->pti_->attributes_section) == 0)
342             || strcmp(name, ".gnu.attributes") == 0); 
343   }
344
345   // Return a bit mask of argument types for attribute with TAG.
346   int
347   attribute_arg_type(int tag) const
348   { return this->do_attribute_arg_type(tag); }
349
350   // Return the attribute tag of the position NUM in the list of fixed
351   // attributes.  Normally there is no reordering and
352   // attributes_order(NUM) == NUM.
353   int
354   attributes_order(int num) const
355   { return this->do_attributes_order(num); }
356
357   // When a target is selected as the default target, we call this method,
358   // which may be used for expensive, target-specific initialization.
359   void
360   select_as_default_target()
361   { this->do_select_as_default_target(); } 
362
363  protected:
364   // This struct holds the constant information for a child class.  We
365   // use a struct to avoid the overhead of virtual function calls for
366   // simple information.
367   struct Target_info
368   {
369     // Address size (32 or 64).
370     int size;
371     // Whether the target is big endian.
372     bool is_big_endian;
373     // The code to store in the e_machine field of the ELF header.
374     elfcpp::EM machine_code;
375     // Whether this target has a specific make_symbol function.
376     bool has_make_symbol;
377     // Whether this target has a specific resolve function.
378     bool has_resolve;
379     // Whether this target has a specific code fill function.
380     bool has_code_fill;
381     // Whether an object file with no .note.GNU-stack sections implies
382     // that the stack should be executable.
383     bool is_default_stack_executable;
384     // Prefix character to strip when checking for wrapping.
385     char wrap_char;
386     // The default dynamic linker name.
387     const char* dynamic_linker;
388     // The default text segment address.
389     uint64_t default_text_segment_address;
390     // The ABI specified page size.
391     uint64_t abi_pagesize;
392     // The common page size used by actual implementations.
393     uint64_t common_pagesize;
394     // The special section index for small common symbols; SHN_UNDEF
395     // if none.
396     elfcpp::Elf_Half small_common_shndx;
397     // The special section index for large common symbols; SHN_UNDEF
398     // if none.
399     elfcpp::Elf_Half large_common_shndx;
400     // Section flags for small common section.
401     elfcpp::Elf_Xword small_common_section_flags;
402     // Section flags for large common section.
403     elfcpp::Elf_Xword large_common_section_flags;
404     // Name of attributes section if it is not ".gnu.attributes".
405     const char* attributes_section;
406     // Vendor name of vendor attributes.
407     const char* attributes_vendor;
408   };
409
410   Target(const Target_info* pti)
411     : pti_(pti), processor_specific_flags_(0),
412       are_processor_specific_flags_set_(false)
413   { }
414
415   // Virtual function which may be implemented by the child class.
416   virtual void
417   do_new_output_section(Output_section*) const
418   { }
419
420   // Virtual function which may be implemented by the child class.
421   virtual void
422   do_finalize_sections(Layout*, const Input_objects*, Symbol_table*)
423   { }
424
425   // Virtual function which may be implemented by the child class.
426   virtual uint64_t
427   do_dynsym_value(const Symbol*) const
428   { gold_unreachable(); }
429
430   // Virtual function which must be implemented by the child class if
431   // needed.
432   virtual std::string
433   do_code_fill(section_size_type) const
434   { gold_unreachable(); }
435
436   // Virtual function which may be implemented by the child class.
437   virtual bool
438   do_is_defined_by_abi(const Symbol*) const
439   { return false; }
440
441   // Adjust the output file header before it is written out.  VIEW
442   // points to the header in external form.  LEN is the length, and
443   // will be one of the values of elfcpp::Elf_sizes<size>::ehdr_size.
444   // By default, we do nothing.
445   virtual void
446   do_adjust_elf_header(unsigned char*, int) const
447   { }
448
449   // Virtual function which may be overriden by the child class.
450   virtual bool
451   do_is_local_label_name(const char*) const;
452
453   // Virtual function that must be overridden by a target which uses
454   // target specific relocations.
455   virtual unsigned int
456   do_reloc_symbol_index(void*, unsigned int) const
457   { gold_unreachable(); }
458
459   // Virtual function that must be overidden by a target which uses
460   // target specific relocations.
461   virtual uint64_t
462   do_reloc_addend(void*, unsigned int, uint64_t) const
463   { gold_unreachable(); }
464
465   // Virtual function which may be overridden by the child class.  The
466   // default implementation is that any function not defined by the
467   // ABI is a call to a non-split function.
468   virtual bool
469   do_is_call_to_non_split(const Symbol* sym, unsigned int) const;
470
471   // Virtual function which may be overridden by the child class.
472   virtual void
473   do_calls_non_split(Relobj* object, unsigned int, section_offset_type,
474                      section_size_type, unsigned char*, section_size_type,
475                      std::string*, std::string*) const;
476
477   // make_elf_object hooks.  There are four versions of these for
478   // different address sizes and endianness.
479
480   // Set processor specific flags.
481   void
482   set_processor_specific_flags(elfcpp::Elf_Word flags)
483   {
484     this->processor_specific_flags_ = flags;
485     this->are_processor_specific_flags_set_ = true;
486   }
487   
488 #ifdef HAVE_TARGET_32_LITTLE
489   // Virtual functions which may be overriden by the child class.
490   virtual Object*
491   do_make_elf_object(const std::string&, Input_file*, off_t,
492                      const elfcpp::Ehdr<32, false>&);
493 #endif
494
495 #ifdef HAVE_TARGET_32_BIG
496   // Virtual functions which may be overriden by the child class.
497   virtual Object*
498   do_make_elf_object(const std::string&, Input_file*, off_t,
499                      const elfcpp::Ehdr<32, true>&);
500 #endif
501
502 #ifdef HAVE_TARGET_64_LITTLE
503   // Virtual functions which may be overriden by the child class.
504   virtual Object*
505   do_make_elf_object(const std::string&, Input_file*, off_t,
506                      const elfcpp::Ehdr<64, false>& ehdr);
507 #endif
508
509 #ifdef HAVE_TARGET_64_BIG
510   // Virtual functions which may be overriden by the child class.
511   virtual Object*
512   do_make_elf_object(const std::string& name, Input_file* input_file,
513                      off_t offset, const elfcpp::Ehdr<64, true>& ehdr);
514 #endif
515
516   // Virtual functions which may be overriden by the child class.
517   virtual Output_section*
518   do_make_output_section(const char* name, elfcpp::Elf_Word type,
519                          elfcpp::Elf_Xword flags);
520
521   // Virtual function which may be overriden by the child class.
522   virtual bool
523   do_may_relax() const
524   { return parameters->options().relax(); }
525
526   // Virtual function which may be overriden by the child class.
527   virtual bool
528   do_relax(int, const Input_objects*, Symbol_table*, Layout*)
529   { return false; }
530
531   // A function for targets to call.  Return whether BYTES/LEN matches
532   // VIEW/VIEW_SIZE at OFFSET.
533   bool
534   match_view(const unsigned char* view, section_size_type view_size,
535              section_offset_type offset, const char* bytes, size_t len) const;
536
537   // Set the contents of a VIEW/VIEW_SIZE to nops starting at OFFSET
538   // for LEN bytes.
539   void
540   set_view_to_nop(unsigned char* view, section_size_type view_size,
541                   section_offset_type offset, size_t len) const;
542
543   // This must be overriden by the child class if it has target-specific
544   // attributes subsection in the attribute section. 
545   virtual int
546   do_attribute_arg_type(int) const
547   { gold_unreachable(); }
548
549   // This may be overridden by the child class.
550   virtual int
551   do_attributes_order(int num) const
552   { return num; }
553
554   // This may be overridden by the child class.
555   virtual void
556   do_select_as_default_target()
557   { }
558
559  private:
560   // The implementations of the four do_make_elf_object virtual functions are
561   // almost identical except for their sizes and endianness.  We use a template.
562   // for their implementations.
563   template<int size, bool big_endian>
564   inline Object*
565   do_make_elf_object_implementation(const std::string&, Input_file*, off_t,
566                                     const elfcpp::Ehdr<size, big_endian>&);
567
568   Target(const Target&);
569   Target& operator=(const Target&);
570
571   // The target information.
572   const Target_info* pti_;
573   // Processor-specific flags.
574   elfcpp::Elf_Word processor_specific_flags_;
575   // Whether the processor-specific flags are set at least once.
576   bool are_processor_specific_flags_set_;
577 };
578
579 // The abstract class for a specific size and endianness of target.
580 // Each actual target implementation class should derive from an
581 // instantiation of Sized_target.
582
583 template<int size, bool big_endian>
584 class Sized_target : public Target
585 {
586  public:
587   // Make a new symbol table entry for the target.  This should be
588   // overridden by a target which needs additional information in the
589   // symbol table.  This will only be called if has_make_symbol()
590   // returns true.
591   virtual Sized_symbol<size>*
592   make_symbol() const
593   { gold_unreachable(); }
594
595   // Resolve a symbol for the target.  This should be overridden by a
596   // target which needs to take special action.  TO is the
597   // pre-existing symbol.  SYM is the new symbol, seen in OBJECT.
598   // VERSION is the version of SYM.  This will only be called if
599   // has_resolve() returns true.
600   virtual void
601   resolve(Symbol*, const elfcpp::Sym<size, big_endian>&, Object*,
602           const char*)
603   { gold_unreachable(); }
604
605   // Process the relocs for a section, and record information of the
606   // mapping from source to destination sections. This mapping is later
607   // used to determine unreferenced garbage sections. This procedure is
608   // only called during garbage collection.
609   virtual void
610   gc_process_relocs(Symbol_table* symtab,
611                     Layout* layout,
612                     Sized_relobj<size, big_endian>* object,
613                     unsigned int data_shndx,
614                     unsigned int sh_type,
615                     const unsigned char* prelocs,
616                     size_t reloc_count,
617                     Output_section* output_section,
618                     bool needs_special_offset_handling,
619                     size_t local_symbol_count,
620                     const unsigned char* plocal_symbols) = 0;
621
622   // Scan the relocs for a section, and record any information
623   // required for the symbol.  SYMTAB is the symbol table.  OBJECT is
624   // the object in which the section appears.  DATA_SHNDX is the
625   // section index that these relocs apply to.  SH_TYPE is the type of
626   // the relocation section, SHT_REL or SHT_RELA.  PRELOCS points to
627   // the relocation data.  RELOC_COUNT is the number of relocs.
628   // LOCAL_SYMBOL_COUNT is the number of local symbols.
629   // OUTPUT_SECTION is the output section.
630   // NEEDS_SPECIAL_OFFSET_HANDLING is true if offsets to the output
631   // sections are not mapped as usual.  PLOCAL_SYMBOLS points to the
632   // local symbol data from OBJECT.  GLOBAL_SYMBOLS is the array of
633   // pointers to the global symbol table from OBJECT.
634   virtual void
635   scan_relocs(Symbol_table* symtab,
636               Layout* layout,
637               Sized_relobj<size, big_endian>* object,
638               unsigned int data_shndx,
639               unsigned int sh_type,
640               const unsigned char* prelocs,
641               size_t reloc_count,
642               Output_section* output_section,
643               bool needs_special_offset_handling,
644               size_t local_symbol_count,
645               const unsigned char* plocal_symbols) = 0;
646
647   // Relocate section data.  SH_TYPE is the type of the relocation
648   // section, SHT_REL or SHT_RELA.  PRELOCS points to the relocation
649   // information.  RELOC_COUNT is the number of relocs.
650   // OUTPUT_SECTION is the output section.
651   // NEEDS_SPECIAL_OFFSET_HANDLING is true if offsets must be mapped
652   // to correspond to the output section.  VIEW is a view into the
653   // output file holding the section contents, VIEW_ADDRESS is the
654   // virtual address of the view, and VIEW_SIZE is the size of the
655   // view.  If NEEDS_SPECIAL_OFFSET_HANDLING is true, the VIEW_xx
656   // parameters refer to the complete output section data, not just
657   // the input section data.
658   virtual void
659   relocate_section(const Relocate_info<size, big_endian>*,
660                    unsigned int sh_type,
661                    const unsigned char* prelocs,
662                    size_t reloc_count,
663                    Output_section* output_section,
664                    bool needs_special_offset_handling,
665                    unsigned char* view,
666                    typename elfcpp::Elf_types<size>::Elf_Addr view_address,
667                    section_size_type view_size,
668                    const Reloc_symbol_changes*) = 0;
669
670   // Scan the relocs during a relocatable link.  The parameters are
671   // like scan_relocs, with an additional Relocatable_relocs
672   // parameter, used to record the disposition of the relocs.
673   virtual void
674   scan_relocatable_relocs(Symbol_table* symtab,
675                           Layout* layout,
676                           Sized_relobj<size, big_endian>* object,
677                           unsigned int data_shndx,
678                           unsigned int sh_type,
679                           const unsigned char* prelocs,
680                           size_t reloc_count,
681                           Output_section* output_section,
682                           bool needs_special_offset_handling,
683                           size_t local_symbol_count,
684                           const unsigned char* plocal_symbols,
685                           Relocatable_relocs*) = 0;
686
687   // Relocate a section during a relocatable link.  The parameters are
688   // like relocate_section, with additional parameters for the view of
689   // the output reloc section.
690   virtual void
691   relocate_for_relocatable(const Relocate_info<size, big_endian>*,
692                            unsigned int sh_type,
693                            const unsigned char* prelocs,
694                            size_t reloc_count,
695                            Output_section* output_section,
696                            off_t offset_in_output_section,
697                            const Relocatable_relocs*,
698                            unsigned char* view,
699                            typename elfcpp::Elf_types<size>::Elf_Addr
700                              view_address,
701                            section_size_type view_size,
702                            unsigned char* reloc_view,
703                            section_size_type reloc_view_size) = 0;
704  
705   // Perform target-specific processing in a relocatable link.  This is
706   // only used if we use the relocation strategy RELOC_SPECIAL.
707   // RELINFO points to a Relocation_info structure. SH_TYPE is the relocation
708   // section type. PRELOC_IN points to the original relocation.  RELNUM is
709   // the index number of the relocation in the relocation section.
710   // OUTPUT_SECTION is the output section to which the relocation is applied.
711   // OFFSET_IN_OUTPUT_SECTION is the offset of the relocation input section
712   // within the output section.  VIEW points to the output view of the
713   // output section.  VIEW_ADDRESS is output address of the view.  VIEW_SIZE
714   // is the size of the output view and PRELOC_OUT points to the new
715   // relocation in the output object.
716   //
717   // A target only needs to override this if the generic code in
718   // target-reloc.h cannot handle some relocation types.
719
720   virtual void
721   relocate_special_relocatable(const Relocate_info<size, big_endian>*
722                                 /*relinfo */,
723                                unsigned int /* sh_type */,
724                                const unsigned char* /* preloc_in */,
725                                size_t /* relnum */,
726                                Output_section* /* output_section */,
727                                off_t /* offset_in_output_section */,
728                                unsigned char* /* view */,
729                                typename elfcpp::Elf_types<size>::Elf_Addr
730                                  /* view_address */,
731                                section_size_type /* view_size */,
732                                unsigned char* /* preloc_out*/)
733   { gold_unreachable(); }
734  
735  protected:
736   Sized_target(const Target::Target_info* pti)
737     : Target(pti)
738   {
739     gold_assert(pti->size == size);
740     gold_assert(pti->is_big_endian ? big_endian : !big_endian);
741   }
742 };
743
744 } // End namespace gold.
745
746 #endif // !defined(GOLD_TARGET_H)