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