OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [gold/] [target.h] - Blame information for rev 59

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.