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