* ld-elf/flags1.d: Don't xfail tic6x.
[binutils.git] / gold / target.h
blobb86efc46a61fd0be1db7ed9cb0d9a8d4ee3dc2e1
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;
59 class Task;
61 // The abstract class for target specific handling.
63 class Target
65 public:
66 virtual ~Target()
67 { }
69 // Virtual function which is set to return true by a target if
70 // it can use relocation types to determine if a function's
71 // pointer is taken.
72 virtual bool
73 can_check_for_function_pointers() const
74 { return false; }
76 // This function is used in ICF (icf.cc). This is set to true by
77 // the target if a relocation to a merged section can be processed
78 // to retrieve the contents of the merged section.
79 virtual bool
80 can_icf_inline_merge_sections () const
81 { return false; }
83 // Whether a section called SECTION_NAME may have function pointers to
84 // sections not eligible for safe ICF folding.
85 virtual bool
86 section_may_have_icf_unsafe_pointers(const char* section_name) const
88 // We recognize sections for normal vtables, construction vtables and
89 // EH frames.
90 return (!is_prefix_of(".rodata._ZTV", section_name)
91 && !is_prefix_of(".data.rel.ro._ZTV", section_name)
92 && !is_prefix_of(".rodata._ZTC", section_name)
93 && !is_prefix_of(".data.rel.ro._ZTC", section_name)
94 && !is_prefix_of(".eh_frame", section_name));
97 // Return the bit size that this target implements. This should
98 // return 32 or 64.
99 int
100 get_size() const
101 { return this->pti_->size; }
103 // Return whether this target is big-endian.
104 bool
105 is_big_endian() const
106 { return this->pti_->is_big_endian; }
108 // Machine code to store in e_machine field of ELF header.
109 elfcpp::EM
110 machine_code() const
111 { return this->pti_->machine_code; }
113 // Processor specific flags to store in e_flags field of ELF header.
114 elfcpp::Elf_Word
115 processor_specific_flags() const
116 { return this->processor_specific_flags_; }
118 // Whether processor specific flags are set at least once.
119 bool
120 are_processor_specific_flags_set() const
121 { return this->are_processor_specific_flags_set_; }
123 // Whether this target has a specific make_symbol function.
124 bool
125 has_make_symbol() const
126 { return this->pti_->has_make_symbol; }
128 // Whether this target has a specific resolve function.
129 bool
130 has_resolve() const
131 { return this->pti_->has_resolve; }
133 // Whether this target has a specific code fill function.
134 bool
135 has_code_fill() const
136 { return this->pti_->has_code_fill; }
138 // Return the default name of the dynamic linker.
139 const char*
140 dynamic_linker() const
141 { return this->pti_->dynamic_linker; }
143 // Return the default address to use for the text segment.
144 uint64_t
145 default_text_segment_address() const
146 { return this->pti_->default_text_segment_address; }
148 // Return the ABI specified page size.
149 uint64_t
150 abi_pagesize() const
152 if (parameters->options().max_page_size() > 0)
153 return parameters->options().max_page_size();
154 else
155 return this->pti_->abi_pagesize;
158 // Return the common page size used on actual systems.
159 uint64_t
160 common_pagesize() const
162 if (parameters->options().common_page_size() > 0)
163 return std::min(parameters->options().common_page_size(),
164 this->abi_pagesize());
165 else
166 return std::min(this->pti_->common_pagesize,
167 this->abi_pagesize());
170 // If we see some object files with .note.GNU-stack sections, and
171 // some objects files without them, this returns whether we should
172 // consider the object files without them to imply that the stack
173 // should be executable.
174 bool
175 is_default_stack_executable() const
176 { return this->pti_->is_default_stack_executable; }
178 // Return a character which may appear as a prefix for a wrap
179 // symbol. If this character appears, we strip it when checking for
180 // wrapping and add it back when forming the final symbol name.
181 // This should be '\0' if not special prefix is required, which is
182 // the normal case.
183 char
184 wrap_char() const
185 { return this->pti_->wrap_char; }
187 // Return the special section index which indicates a small common
188 // symbol. This will return SHN_UNDEF if there are no small common
189 // symbols.
190 elfcpp::Elf_Half
191 small_common_shndx() const
192 { return this->pti_->small_common_shndx; }
194 // Return values to add to the section flags for the section holding
195 // small common symbols.
196 elfcpp::Elf_Xword
197 small_common_section_flags() const
199 gold_assert(this->pti_->small_common_shndx != elfcpp::SHN_UNDEF);
200 return this->pti_->small_common_section_flags;
203 // Return the special section index which indicates a large common
204 // symbol. This will return SHN_UNDEF if there are no large common
205 // symbols.
206 elfcpp::Elf_Half
207 large_common_shndx() const
208 { return this->pti_->large_common_shndx; }
210 // Return values to add to the section flags for the section holding
211 // large common symbols.
212 elfcpp::Elf_Xword
213 large_common_section_flags() const
215 gold_assert(this->pti_->large_common_shndx != elfcpp::SHN_UNDEF);
216 return this->pti_->large_common_section_flags;
219 // This hook is called when an output section is created.
220 void
221 new_output_section(Output_section* os) const
222 { this->do_new_output_section(os); }
224 // This is called to tell the target to complete any sections it is
225 // handling. After this all sections must have their final size.
226 void
227 finalize_sections(Layout* layout, const Input_objects* input_objects,
228 Symbol_table* symtab)
229 { return this->do_finalize_sections(layout, input_objects, symtab); }
231 // Return the value to use for a global symbol which needs a special
232 // value in the dynamic symbol table. This will only be called if
233 // the backend first calls symbol->set_needs_dynsym_value().
234 uint64_t
235 dynsym_value(const Symbol* sym) const
236 { return this->do_dynsym_value(sym); }
238 // Return a string to use to fill out a code section. This is
239 // basically one or more NOPS which must fill out the specified
240 // length in bytes.
241 std::string
242 code_fill(section_size_type length) const
243 { return this->do_code_fill(length); }
245 // Return whether SYM is known to be defined by the ABI. This is
246 // used to avoid inappropriate warnings about undefined symbols.
247 bool
248 is_defined_by_abi(const Symbol* sym) const
249 { return this->do_is_defined_by_abi(sym); }
251 // Adjust the output file header before it is written out. VIEW
252 // points to the header in external form. LEN is the length.
253 void
254 adjust_elf_header(unsigned char* view, int len) const
255 { return this->do_adjust_elf_header(view, len); }
257 // Return whether NAME is a local label name. This is used to implement the
258 // --discard-locals options.
259 bool
260 is_local_label_name(const char* name) const
261 { return this->do_is_local_label_name(name); }
263 // Get the symbol index to use for a target specific reloc.
264 unsigned int
265 reloc_symbol_index(void* arg, unsigned int type) const
266 { return this->do_reloc_symbol_index(arg, type); }
268 // Get the addend to use for a target specific reloc.
269 uint64_t
270 reloc_addend(void* arg, unsigned int type, uint64_t addend) const
271 { return this->do_reloc_addend(arg, type, addend); }
273 // Return the PLT section to use for a global symbol. This is used
274 // for STT_GNU_IFUNC symbols.
275 Output_data*
276 plt_section_for_global(const Symbol* sym) const
277 { return this->do_plt_section_for_global(sym); }
279 // Return the PLT section to use for a local symbol. This is used
280 // for STT_GNU_IFUNC symbols.
281 Output_data*
282 plt_section_for_local(const Relobj* object, unsigned int symndx) const
283 { return this->do_plt_section_for_local(object, symndx); }
285 // Return true if a reference to SYM from a reloc of type R_TYPE
286 // means that the current function may call an object compiled
287 // without -fsplit-stack. SYM is known to be defined in an object
288 // compiled without -fsplit-stack.
289 bool
290 is_call_to_non_split(const Symbol* sym, unsigned int r_type) const
291 { return this->do_is_call_to_non_split(sym, r_type); }
293 // A function starts at OFFSET in section SHNDX in OBJECT. That
294 // function was compiled with -fsplit-stack, but it refers to a
295 // function which was compiled without -fsplit-stack. VIEW is a
296 // modifiable view of the section; VIEW_SIZE is the size of the
297 // view. The target has to adjust the function so that it allocates
298 // enough stack.
299 void
300 calls_non_split(Relobj* object, unsigned int shndx,
301 section_offset_type fnoffset, section_size_type fnsize,
302 unsigned char* view, section_size_type view_size,
303 std::string* from, std::string* to) const
305 this->do_calls_non_split(object, shndx, fnoffset, fnsize, view, view_size,
306 from, to);
309 // Make an ELF object.
310 template<int size, bool big_endian>
311 Object*
312 make_elf_object(const std::string& name, Input_file* input_file,
313 off_t offset, const elfcpp::Ehdr<size, big_endian>& ehdr)
314 { return this->do_make_elf_object(name, input_file, offset, ehdr); }
316 // Make an output section.
317 Output_section*
318 make_output_section(const char* name, elfcpp::Elf_Word type,
319 elfcpp::Elf_Xword flags)
320 { return this->do_make_output_section(name, type, flags); }
322 // Return true if target wants to perform relaxation.
323 bool
324 may_relax() const
326 // Run the dummy relaxation pass twice if relaxation debugging is enabled.
327 if (is_debugging_enabled(DEBUG_RELAXATION))
328 return true;
330 return this->do_may_relax();
333 // Perform a relaxation pass. Return true if layout may be changed.
334 bool
335 relax(int pass, const Input_objects* input_objects, Symbol_table* symtab,
336 Layout* layout, const Task* task)
338 // Run the dummy relaxation pass twice if relaxation debugging is enabled.
339 if (is_debugging_enabled(DEBUG_RELAXATION))
340 return pass < 2;
342 return this->do_relax(pass, input_objects, symtab, layout, task);
345 // Return the target-specific name of attributes section. This is
346 // NULL if a target does not use attributes section or if it uses
347 // the default section name ".gnu.attributes".
348 const char*
349 attributes_section() const
350 { return this->pti_->attributes_section; }
352 // Return the vendor name of vendor attributes.
353 const char*
354 attributes_vendor() const
355 { return this->pti_->attributes_vendor; }
357 // Whether a section called NAME is an attribute section.
358 bool
359 is_attributes_section(const char* name) const
361 return ((this->pti_->attributes_section != NULL
362 && strcmp(name, this->pti_->attributes_section) == 0)
363 || strcmp(name, ".gnu.attributes") == 0);
366 // Return a bit mask of argument types for attribute with TAG.
368 attribute_arg_type(int tag) const
369 { return this->do_attribute_arg_type(tag); }
371 // Return the attribute tag of the position NUM in the list of fixed
372 // attributes. Normally there is no reordering and
373 // attributes_order(NUM) == NUM.
375 attributes_order(int num) const
376 { return this->do_attributes_order(num); }
378 // When a target is selected as the default target, we call this method,
379 // which may be used for expensive, target-specific initialization.
380 void
381 select_as_default_target()
382 { this->do_select_as_default_target(); }
384 protected:
385 // This struct holds the constant information for a child class. We
386 // use a struct to avoid the overhead of virtual function calls for
387 // simple information.
388 struct Target_info
390 // Address size (32 or 64).
391 int size;
392 // Whether the target is big endian.
393 bool is_big_endian;
394 // The code to store in the e_machine field of the ELF header.
395 elfcpp::EM machine_code;
396 // Whether this target has a specific make_symbol function.
397 bool has_make_symbol;
398 // Whether this target has a specific resolve function.
399 bool has_resolve;
400 // Whether this target has a specific code fill function.
401 bool has_code_fill;
402 // Whether an object file with no .note.GNU-stack sections implies
403 // that the stack should be executable.
404 bool is_default_stack_executable;
405 // Prefix character to strip when checking for wrapping.
406 char wrap_char;
407 // The default dynamic linker name.
408 const char* dynamic_linker;
409 // The default text segment address.
410 uint64_t default_text_segment_address;
411 // The ABI specified page size.
412 uint64_t abi_pagesize;
413 // The common page size used by actual implementations.
414 uint64_t common_pagesize;
415 // The special section index for small common symbols; SHN_UNDEF
416 // if none.
417 elfcpp::Elf_Half small_common_shndx;
418 // The special section index for large common symbols; SHN_UNDEF
419 // if none.
420 elfcpp::Elf_Half large_common_shndx;
421 // Section flags for small common section.
422 elfcpp::Elf_Xword small_common_section_flags;
423 // Section flags for large common section.
424 elfcpp::Elf_Xword large_common_section_flags;
425 // Name of attributes section if it is not ".gnu.attributes".
426 const char* attributes_section;
427 // Vendor name of vendor attributes.
428 const char* attributes_vendor;
431 Target(const Target_info* pti)
432 : pti_(pti), processor_specific_flags_(0),
433 are_processor_specific_flags_set_(false)
436 // Virtual function which may be implemented by the child class.
437 virtual void
438 do_new_output_section(Output_section*) const
441 // Virtual function which may be implemented by the child class.
442 virtual void
443 do_finalize_sections(Layout*, const Input_objects*, Symbol_table*)
446 // Virtual function which may be implemented by the child class.
447 virtual uint64_t
448 do_dynsym_value(const Symbol*) const
449 { gold_unreachable(); }
451 // Virtual function which must be implemented by the child class if
452 // needed.
453 virtual std::string
454 do_code_fill(section_size_type) const
455 { gold_unreachable(); }
457 // Virtual function which may be implemented by the child class.
458 virtual bool
459 do_is_defined_by_abi(const Symbol*) const
460 { return false; }
462 // Adjust the output file header before it is written out. VIEW
463 // points to the header in external form. LEN is the length, and
464 // will be one of the values of elfcpp::Elf_sizes<size>::ehdr_size.
465 // By default, we do nothing.
466 virtual void
467 do_adjust_elf_header(unsigned char*, int) const
470 // Virtual function which may be overridden by the child class.
471 virtual bool
472 do_is_local_label_name(const char*) const;
474 // Virtual function that must be overridden by a target which uses
475 // target specific relocations.
476 virtual unsigned int
477 do_reloc_symbol_index(void*, unsigned int) const
478 { gold_unreachable(); }
480 // Virtual function that must be overridden by a target which uses
481 // target specific relocations.
482 virtual uint64_t
483 do_reloc_addend(void*, unsigned int, uint64_t) const
484 { gold_unreachable(); }
486 // Virtual functions that must be overridden by a target that uses
487 // STT_GNU_IFUNC symbols.
488 virtual Output_data*
489 do_plt_section_for_global(const Symbol*) const
490 { gold_unreachable(); }
492 virtual Output_data*
493 do_plt_section_for_local(const Relobj*, unsigned int) const
494 { gold_unreachable(); }
496 // Virtual function which may be overridden by the child class. The
497 // default implementation is that any function not defined by the
498 // ABI is a call to a non-split function.
499 virtual bool
500 do_is_call_to_non_split(const Symbol* sym, unsigned int) const;
502 // Virtual function which may be overridden by the child class.
503 virtual void
504 do_calls_non_split(Relobj* object, unsigned int, section_offset_type,
505 section_size_type, unsigned char*, section_size_type,
506 std::string*, std::string*) const;
508 // make_elf_object hooks. There are four versions of these for
509 // different address sizes and endianness.
511 // Set processor specific flags.
512 void
513 set_processor_specific_flags(elfcpp::Elf_Word flags)
515 this->processor_specific_flags_ = flags;
516 this->are_processor_specific_flags_set_ = true;
519 #ifdef HAVE_TARGET_32_LITTLE
520 // Virtual functions which may be overridden by the child class.
521 virtual Object*
522 do_make_elf_object(const std::string&, Input_file*, off_t,
523 const elfcpp::Ehdr<32, false>&);
524 #endif
526 #ifdef HAVE_TARGET_32_BIG
527 // Virtual functions which may be overridden by the child class.
528 virtual Object*
529 do_make_elf_object(const std::string&, Input_file*, off_t,
530 const elfcpp::Ehdr<32, true>&);
531 #endif
533 #ifdef HAVE_TARGET_64_LITTLE
534 // Virtual functions which may be overridden by the child class.
535 virtual Object*
536 do_make_elf_object(const std::string&, Input_file*, off_t,
537 const elfcpp::Ehdr<64, false>& ehdr);
538 #endif
540 #ifdef HAVE_TARGET_64_BIG
541 // Virtual functions which may be overridden by the child class.
542 virtual Object*
543 do_make_elf_object(const std::string& name, Input_file* input_file,
544 off_t offset, const elfcpp::Ehdr<64, true>& ehdr);
545 #endif
547 // Virtual functions which may be overridden by the child class.
548 virtual Output_section*
549 do_make_output_section(const char* name, elfcpp::Elf_Word type,
550 elfcpp::Elf_Xword flags);
552 // Virtual function which may be overridden by the child class.
553 virtual bool
554 do_may_relax() const
555 { return parameters->options().relax(); }
557 // Virtual function which may be overridden by the child class.
558 virtual bool
559 do_relax(int, const Input_objects*, Symbol_table*, Layout*, const Task*)
560 { return false; }
562 // A function for targets to call. Return whether BYTES/LEN matches
563 // VIEW/VIEW_SIZE at OFFSET.
564 bool
565 match_view(const unsigned char* view, section_size_type view_size,
566 section_offset_type offset, const char* bytes, size_t len) const;
568 // Set the contents of a VIEW/VIEW_SIZE to nops starting at OFFSET
569 // for LEN bytes.
570 void
571 set_view_to_nop(unsigned char* view, section_size_type view_size,
572 section_offset_type offset, size_t len) const;
574 // This must be overridden by the child class if it has target-specific
575 // attributes subsection in the attribute section.
576 virtual int
577 do_attribute_arg_type(int) const
578 { gold_unreachable(); }
580 // This may be overridden by the child class.
581 virtual int
582 do_attributes_order(int num) const
583 { return num; }
585 // This may be overridden by the child class.
586 virtual void
587 do_select_as_default_target()
590 private:
591 // The implementations of the four do_make_elf_object virtual functions are
592 // almost identical except for their sizes and endianness. We use a template.
593 // for their implementations.
594 template<int size, bool big_endian>
595 inline Object*
596 do_make_elf_object_implementation(const std::string&, Input_file*, off_t,
597 const elfcpp::Ehdr<size, big_endian>&);
599 Target(const Target&);
600 Target& operator=(const Target&);
602 // The target information.
603 const Target_info* pti_;
604 // Processor-specific flags.
605 elfcpp::Elf_Word processor_specific_flags_;
606 // Whether the processor-specific flags are set at least once.
607 bool are_processor_specific_flags_set_;
610 // The abstract class for a specific size and endianness of target.
611 // Each actual target implementation class should derive from an
612 // instantiation of Sized_target.
614 template<int size, bool big_endian>
615 class Sized_target : public Target
617 public:
618 // Make a new symbol table entry for the target. This should be
619 // overridden by a target which needs additional information in the
620 // symbol table. This will only be called if has_make_symbol()
621 // returns true.
622 virtual Sized_symbol<size>*
623 make_symbol() const
624 { gold_unreachable(); }
626 // Resolve a symbol for the target. This should be overridden by a
627 // target which needs to take special action. TO is the
628 // pre-existing symbol. SYM is the new symbol, seen in OBJECT.
629 // VERSION is the version of SYM. This will only be called if
630 // has_resolve() returns true.
631 virtual void
632 resolve(Symbol*, const elfcpp::Sym<size, big_endian>&, Object*,
633 const char*)
634 { gold_unreachable(); }
636 // Process the relocs for a section, and record information of the
637 // mapping from source to destination sections. This mapping is later
638 // used to determine unreferenced garbage sections. This procedure is
639 // only called during garbage collection.
640 virtual void
641 gc_process_relocs(Symbol_table* symtab,
642 Layout* layout,
643 Sized_relobj<size, big_endian>* object,
644 unsigned int data_shndx,
645 unsigned int sh_type,
646 const unsigned char* prelocs,
647 size_t reloc_count,
648 Output_section* output_section,
649 bool needs_special_offset_handling,
650 size_t local_symbol_count,
651 const unsigned char* plocal_symbols) = 0;
653 // Scan the relocs for a section, and record any information
654 // required for the symbol. SYMTAB is the symbol table. OBJECT is
655 // the object in which the section appears. DATA_SHNDX is the
656 // section index that these relocs apply to. SH_TYPE is the type of
657 // the relocation section, SHT_REL or SHT_RELA. PRELOCS points to
658 // the relocation data. RELOC_COUNT is the number of relocs.
659 // LOCAL_SYMBOL_COUNT is the number of local symbols.
660 // OUTPUT_SECTION is the output section.
661 // NEEDS_SPECIAL_OFFSET_HANDLING is true if offsets to the output
662 // sections are not mapped as usual. PLOCAL_SYMBOLS points to the
663 // local symbol data from OBJECT. GLOBAL_SYMBOLS is the array of
664 // pointers to the global symbol table from OBJECT.
665 virtual void
666 scan_relocs(Symbol_table* symtab,
667 Layout* layout,
668 Sized_relobj<size, big_endian>* object,
669 unsigned int data_shndx,
670 unsigned int sh_type,
671 const unsigned char* prelocs,
672 size_t reloc_count,
673 Output_section* output_section,
674 bool needs_special_offset_handling,
675 size_t local_symbol_count,
676 const unsigned char* plocal_symbols) = 0;
678 // Relocate section data. SH_TYPE is the type of the relocation
679 // section, SHT_REL or SHT_RELA. PRELOCS points to the relocation
680 // information. RELOC_COUNT is the number of relocs.
681 // OUTPUT_SECTION is the output section.
682 // NEEDS_SPECIAL_OFFSET_HANDLING is true if offsets must be mapped
683 // to correspond to the output section. VIEW is a view into the
684 // output file holding the section contents, VIEW_ADDRESS is the
685 // virtual address of the view, and VIEW_SIZE is the size of the
686 // view. If NEEDS_SPECIAL_OFFSET_HANDLING is true, the VIEW_xx
687 // parameters refer to the complete output section data, not just
688 // the input section data.
689 virtual void
690 relocate_section(const Relocate_info<size, big_endian>*,
691 unsigned int sh_type,
692 const unsigned char* prelocs,
693 size_t reloc_count,
694 Output_section* output_section,
695 bool needs_special_offset_handling,
696 unsigned char* view,
697 typename elfcpp::Elf_types<size>::Elf_Addr view_address,
698 section_size_type view_size,
699 const Reloc_symbol_changes*) = 0;
701 // Scan the relocs during a relocatable link. The parameters are
702 // like scan_relocs, with an additional Relocatable_relocs
703 // parameter, used to record the disposition of the relocs.
704 virtual void
705 scan_relocatable_relocs(Symbol_table* symtab,
706 Layout* layout,
707 Sized_relobj<size, big_endian>* object,
708 unsigned int data_shndx,
709 unsigned int sh_type,
710 const unsigned char* prelocs,
711 size_t reloc_count,
712 Output_section* output_section,
713 bool needs_special_offset_handling,
714 size_t local_symbol_count,
715 const unsigned char* plocal_symbols,
716 Relocatable_relocs*) = 0;
718 // Relocate a section during a relocatable link. The parameters are
719 // like relocate_section, with additional parameters for the view of
720 // the output reloc section.
721 virtual void
722 relocate_for_relocatable(const Relocate_info<size, big_endian>*,
723 unsigned int sh_type,
724 const unsigned char* prelocs,
725 size_t reloc_count,
726 Output_section* output_section,
727 off_t offset_in_output_section,
728 const Relocatable_relocs*,
729 unsigned char* view,
730 typename elfcpp::Elf_types<size>::Elf_Addr
731 view_address,
732 section_size_type view_size,
733 unsigned char* reloc_view,
734 section_size_type reloc_view_size) = 0;
736 // Perform target-specific processing in a relocatable link. This is
737 // only used if we use the relocation strategy RELOC_SPECIAL.
738 // RELINFO points to a Relocation_info structure. SH_TYPE is the relocation
739 // section type. PRELOC_IN points to the original relocation. RELNUM is
740 // the index number of the relocation in the relocation section.
741 // OUTPUT_SECTION is the output section to which the relocation is applied.
742 // OFFSET_IN_OUTPUT_SECTION is the offset of the relocation input section
743 // within the output section. VIEW points to the output view of the
744 // output section. VIEW_ADDRESS is output address of the view. VIEW_SIZE
745 // is the size of the output view and PRELOC_OUT points to the new
746 // relocation in the output object.
748 // A target only needs to override this if the generic code in
749 // target-reloc.h cannot handle some relocation types.
751 virtual void
752 relocate_special_relocatable(const Relocate_info<size, big_endian>*
753 /*relinfo */,
754 unsigned int /* sh_type */,
755 const unsigned char* /* preloc_in */,
756 size_t /* relnum */,
757 Output_section* /* output_section */,
758 off_t /* offset_in_output_section */,
759 unsigned char* /* view */,
760 typename elfcpp::Elf_types<size>::Elf_Addr
761 /* view_address */,
762 section_size_type /* view_size */,
763 unsigned char* /* preloc_out*/)
764 { gold_unreachable(); }
766 // Return the number of entries in the GOT. 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 got_entry_count() const
772 { gold_unreachable(); }
774 // Return the number of entries in the PLT. This is only used for
775 // laying out the incremental link info sections. A target needs
776 // to implement this to support incremental linking.
778 virtual unsigned int
779 plt_entry_count() const
780 { gold_unreachable(); }
782 // Return the offset of the first non-reserved PLT entry. This is
783 // only used for laying out the incremental link info sections.
784 // A target needs to implement this to support incremental linking.
786 virtual unsigned int
787 first_plt_entry_offset() const
788 { gold_unreachable(); }
790 // Return the size of each PLT entry. This is only used for
791 // laying out the incremental link info sections. A target needs
792 // to implement this to support incremental linking.
794 virtual unsigned int
795 plt_entry_size() const
796 { gold_unreachable(); }
798 // Apply an incremental relocation.
800 virtual void
801 apply_relocation(const Relocate_info<size, big_endian>* /* relinfo */,
802 typename elfcpp::Elf_types<size>::Elf_Addr /* r_offset */,
803 unsigned int /* r_type */,
804 typename elfcpp::Elf_types<size>::Elf_Swxword /* r_addend */,
805 const Symbol* /* gsym */,
806 unsigned char* /* view */,
807 typename elfcpp::Elf_types<size>::Elf_Addr /* address */,
808 section_size_type /* view_size */)
809 { gold_unreachable(); }
811 protected:
812 Sized_target(const Target::Target_info* pti)
813 : Target(pti)
815 gold_assert(pti->size == size);
816 gold_assert(pti->is_big_endian ? big_endian : !big_endian);
820 } // End namespace gold.
822 #endif // !defined(GOLD_TARGET_H)