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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [gold/] [reloc.h] - Blame information for rev 69

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

Line No. Rev Author Line
1 27 khays
// reloc.h -- relocate input files 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
#ifndef GOLD_RELOC_H
24
#define GOLD_RELOC_H
25
 
26
#include <vector>
27
#ifdef HAVE_BYTESWAP_H
28
#include <byteswap.h>
29
#endif
30
 
31
#include "elfcpp.h"
32
#include "workqueue.h"
33
 
34
namespace gold
35
{
36
 
37
class General_options;
38
class Object;
39
class Relobj;
40
class Read_relocs_data;
41
class Symbol;
42
class Layout;
43
class Output_data;
44
class Output_section;
45
 
46
template<int size>
47
class Sized_symbol;
48
 
49
template<int size, bool big_endian>
50
class Sized_relobj_file;
51
 
52
template<int size>
53
class Symbol_value;
54
 
55
template<int sh_type, bool dynamic, int size, bool big_endian>
56
class Output_data_reloc;
57
 
58
// A class to read the relocations for an object file, and then queue
59
// up a task to see if they require any GOT/PLT/COPY relocations in
60
// the symbol table.
61
 
62
class Read_relocs : public Task
63
{
64
 public:
65
  //   THIS_BLOCKER and NEXT_BLOCKER are passed along to a Scan_relocs
66
  // or Gc_process_relocs task, so that they run in a deterministic
67
  // order.
68
  Read_relocs(Symbol_table* symtab, Layout* layout, Relobj* object,
69
              Task_token* this_blocker, Task_token* next_blocker)
70
    : symtab_(symtab), layout_(layout), object_(object),
71
      this_blocker_(this_blocker), next_blocker_(next_blocker)
72
  { }
73
 
74
  // The standard Task methods.
75
 
76
  Task_token*
77
  is_runnable();
78
 
79
  void
80
  locks(Task_locker*);
81
 
82
  void
83
  run(Workqueue*);
84
 
85
  std::string
86
  get_name() const;
87
 
88
 private:
89
  Symbol_table* symtab_;
90
  Layout* layout_;
91
  Relobj* object_;
92
  Task_token* this_blocker_;
93
  Task_token* next_blocker_;
94
};
95
 
96
// Process the relocs to figure out which sections are garbage.
97
// Very similar to scan relocs.
98
 
99
class Gc_process_relocs : public Task
100
{
101
 public:
102
  // THIS_BLOCKER prevents this task from running until the previous
103
  // one is finished.  NEXT_BLOCKER prevents the next task from
104
  // running.
105
  Gc_process_relocs(Symbol_table* symtab, Layout* layout, Relobj* object,
106
                    Read_relocs_data* rd, Task_token* this_blocker,
107
                    Task_token* next_blocker)
108
    : symtab_(symtab), layout_(layout), object_(object), rd_(rd),
109
      this_blocker_(this_blocker), next_blocker_(next_blocker)
110
  { }
111
 
112
  ~Gc_process_relocs();
113
 
114
  // The standard Task methods.
115
 
116
  Task_token*
117
  is_runnable();
118
 
119
  void
120
  locks(Task_locker*);
121
 
122
  void
123
  run(Workqueue*);
124
 
125
  std::string
126
  get_name() const;
127
 
128
 private:
129
  Symbol_table* symtab_;
130
  Layout* layout_;
131
  Relobj* object_;
132
  Read_relocs_data* rd_;
133
  Task_token* this_blocker_;
134
  Task_token* next_blocker_;
135
};
136
 
137
// Scan the relocations for an object to see if they require any
138
// GOT/PLT/COPY relocations.
139
 
140
class Scan_relocs : public Task
141
{
142
 public:
143
  // THIS_BLOCKER prevents this task from running until the previous
144
  // one is finished.  NEXT_BLOCKER prevents the next task from
145
  // running.
146
  Scan_relocs(Symbol_table* symtab, Layout* layout, Relobj* object,
147
              Read_relocs_data* rd, Task_token* this_blocker,
148
              Task_token* next_blocker)
149
    : symtab_(symtab), layout_(layout), object_(object), rd_(rd),
150
      this_blocker_(this_blocker), next_blocker_(next_blocker)
151
  { }
152
 
153
  ~Scan_relocs();
154
 
155
  // The standard Task methods.
156
 
157
  Task_token*
158
  is_runnable();
159
 
160
  void
161
  locks(Task_locker*);
162
 
163
  void
164
  run(Workqueue*);
165
 
166
  std::string
167
  get_name() const;
168
 
169
 private:
170
  Symbol_table* symtab_;
171
  Layout* layout_;
172
  Relobj* object_;
173
  Read_relocs_data* rd_;
174
  Task_token* this_blocker_;
175
  Task_token* next_blocker_;
176
};
177
 
178
// A class to perform all the relocations for an object file.
179
 
180
class Relocate_task : public Task
181
{
182
 public:
183
  Relocate_task(const Symbol_table* symtab, const Layout* layout,
184
                Relobj* object, Output_file* of,
185
                Task_token* input_sections_blocker,
186
                Task_token* output_sections_blocker, Task_token* final_blocker)
187
    : symtab_(symtab), layout_(layout), object_(object), of_(of),
188
      input_sections_blocker_(input_sections_blocker),
189
      output_sections_blocker_(output_sections_blocker),
190
      final_blocker_(final_blocker)
191
  { }
192
 
193
  // The standard Task methods.
194
 
195
  Task_token*
196
  is_runnable();
197
 
198
  void
199
  locks(Task_locker*);
200
 
201
  void
202
  run(Workqueue*);
203
 
204
  std::string
205
  get_name() const;
206
 
207
 private:
208
  const Symbol_table* symtab_;
209
  const Layout* layout_;
210
  Relobj* object_;
211
  Output_file* of_;
212
  Task_token* input_sections_blocker_;
213
  Task_token* output_sections_blocker_;
214
  Task_token* final_blocker_;
215
};
216
 
217
// During a relocatable link, this class records how relocations
218
// should be handled for a single input reloc section.  An instance of
219
// this class is created while scanning relocs, and it is used while
220
// processing relocs.
221
 
222
class Relocatable_relocs
223
{
224
 public:
225
  // We use a vector of unsigned char to indicate how the input relocs
226
  // should be handled.  Each element is one of the following values.
227
  // We create this vector when we initially scan the relocations.
228
  enum Reloc_strategy
229
  {
230
    // Copy the input reloc.  Don't modify it other than updating the
231
    // r_offset field and the r_sym part of the r_info field.
232
    RELOC_COPY,
233
    // Copy the input reloc which is against an STT_SECTION symbol.
234
    // Update the r_offset and r_sym part of the r_info field.  Adjust
235
    // the addend by subtracting the value of the old local symbol and
236
    // adding the value of the new local symbol.  The addend is in the
237
    // SHT_RELA reloc and the contents of the data section do not need
238
    // to be changed.
239
    RELOC_ADJUST_FOR_SECTION_RELA,
240
    // Like RELOC_ADJUST_FOR_SECTION_RELA but the addend should not be
241
    // adjusted.
242
    RELOC_ADJUST_FOR_SECTION_0,
243
    // Like RELOC_ADJUST_FOR_SECTION_RELA but the contents of the
244
    // section need to be changed.  The number indicates the number of
245
    // bytes in the addend in the section contents.
246
    RELOC_ADJUST_FOR_SECTION_1,
247
    RELOC_ADJUST_FOR_SECTION_2,
248
    RELOC_ADJUST_FOR_SECTION_4,
249
    RELOC_ADJUST_FOR_SECTION_8,
250
    // Discard the input reloc--process it completely when relocating
251
    // the data section contents.
252
    RELOC_DISCARD,
253
    // An input reloc which is not discarded, but which requires
254
    // target specific processing in order to update it.
255
    RELOC_SPECIAL
256
  };
257
 
258
  Relocatable_relocs()
259
    : reloc_strategies_(), output_reloc_count_(0), posd_(NULL)
260
  { }
261
 
262
  // Record the number of relocs.
263
  void
264
  set_reloc_count(size_t reloc_count)
265
  { this->reloc_strategies_.reserve(reloc_count); }
266
 
267
  // Record what to do for the next reloc.
268
  void
269
  set_next_reloc_strategy(Reloc_strategy strategy)
270
  {
271
    this->reloc_strategies_.push_back(static_cast<unsigned char>(strategy));
272
    if (strategy != RELOC_DISCARD)
273
      ++this->output_reloc_count_;
274
  }
275
 
276
  // Record the Output_data associated with this reloc section.
277
  void
278
  set_output_data(Output_data* posd)
279
  {
280
    gold_assert(this->posd_ == NULL);
281
    this->posd_ = posd;
282
  }
283
 
284
  // Return the Output_data associated with this reloc section.
285
  Output_data*
286
  output_data() const
287
  { return this->posd_; }
288
 
289
  // Return what to do for reloc I.
290
  Reloc_strategy
291
  strategy(unsigned int i) const
292
  {
293
    gold_assert(i < this->reloc_strategies_.size());
294
    return static_cast<Reloc_strategy>(this->reloc_strategies_[i]);
295
  }
296
 
297
  // Return the number of relocations to create in the output file.
298
  size_t
299
  output_reloc_count() const
300
  { return this->output_reloc_count_; }
301
 
302
 private:
303
  typedef std::vector<unsigned char> Reloc_strategies;
304
 
305
  // The strategies for the input reloc.  There is one entry in this
306
  // vector for each relocation in the input section.
307
  Reloc_strategies reloc_strategies_;
308
  // The number of relocations to be created in the output file.
309
  size_t output_reloc_count_;
310
  // The output data structure associated with this relocation.
311
  Output_data* posd_;
312
};
313
 
314
// Standard relocation routines which are used on many targets.  Here
315
// SIZE and BIG_ENDIAN refer to the target, not the relocation type.
316
 
317
template<int size, bool big_endian>
318
class Relocate_functions
319
{
320
private:
321
  // Do a simple relocation with the addend in the section contents.
322
  // VALSIZE is the size of the value.
323
  template<int valsize>
324
  static inline void
325
  rel(unsigned char* view,
326
      typename elfcpp::Swap<valsize, big_endian>::Valtype value)
327
  {
328
    typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
329
    Valtype* wv = reinterpret_cast<Valtype*>(view);
330
    Valtype x = elfcpp::Swap<valsize, big_endian>::readval(wv);
331
    elfcpp::Swap<valsize, big_endian>::writeval(wv, x + value);
332
  }
333
 
334
  // Do a simple relocation using a Symbol_value with the addend in
335
  // the section contents.  VALSIZE is the size of the value to
336
  // relocate.
337
  template<int valsize>
338
  static inline void
339
  rel(unsigned char* view,
340
      const Sized_relobj_file<size, big_endian>* object,
341
      const Symbol_value<size>* psymval)
342
  {
343
    typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
344
    Valtype* wv = reinterpret_cast<Valtype*>(view);
345
    Valtype x = elfcpp::Swap<valsize, big_endian>::readval(wv);
346
    x = psymval->value(object, x);
347
    elfcpp::Swap<valsize, big_endian>::writeval(wv, x);
348
  }
349
 
350
  // Do a simple relocation with the addend in the relocation.
351
  // VALSIZE is the size of the value.
352
  template<int valsize>
353
  static inline void
354
  rela(unsigned char* view,
355
       typename elfcpp::Swap<valsize, big_endian>::Valtype value,
356
       typename elfcpp::Swap<valsize, big_endian>::Valtype addend)
357
  {
358
    typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
359
    Valtype* wv = reinterpret_cast<Valtype*>(view);
360
    elfcpp::Swap<valsize, big_endian>::writeval(wv, value + addend);
361
  }
362
 
363
  // Do a simple relocation using a symbol value with the addend in
364
  // the relocation.  VALSIZE is the size of the value.
365
  template<int valsize>
366
  static inline void
367
  rela(unsigned char* view,
368
       const Sized_relobj_file<size, big_endian>* object,
369
       const Symbol_value<size>* psymval,
370
       typename elfcpp::Swap<valsize, big_endian>::Valtype addend)
371
  {
372
    typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
373
    Valtype* wv = reinterpret_cast<Valtype*>(view);
374
    Valtype x = psymval->value(object, addend);
375
    elfcpp::Swap<valsize, big_endian>::writeval(wv, x);
376
  }
377
 
378
  // Do a simple PC relative relocation with the addend in the section
379
  // contents.  VALSIZE is the size of the value.
380
  template<int valsize>
381
  static inline void
382
  pcrel(unsigned char* view,
383
        typename elfcpp::Swap<valsize, big_endian>::Valtype value,
384
        typename elfcpp::Elf_types<size>::Elf_Addr address)
385
  {
386
    typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
387
    Valtype* wv = reinterpret_cast<Valtype*>(view);
388
    Valtype x = elfcpp::Swap<valsize, big_endian>::readval(wv);
389
    elfcpp::Swap<valsize, big_endian>::writeval(wv, x + value - address);
390
  }
391
 
392
  // Do a simple PC relative relocation with a Symbol_value with the
393
  // addend in the section contents.  VALSIZE is the size of the
394
  // value.
395
  template<int valsize>
396
  static inline void
397
  pcrel(unsigned char* view,
398
        const Sized_relobj_file<size, big_endian>* object,
399
        const Symbol_value<size>* psymval,
400
        typename elfcpp::Elf_types<size>::Elf_Addr address)
401
  {
402
    typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
403
    Valtype* wv = reinterpret_cast<Valtype*>(view);
404
    Valtype x = elfcpp::Swap<valsize, big_endian>::readval(wv);
405
    x = psymval->value(object, x);
406
    elfcpp::Swap<valsize, big_endian>::writeval(wv, x - address);
407
  }
408
 
409
  // Do a simple PC relative relocation with the addend in the
410
  // relocation.  VALSIZE is the size of the value.
411
  template<int valsize>
412
  static inline void
413
  pcrela(unsigned char* view,
414
         typename elfcpp::Swap<valsize, big_endian>::Valtype value,
415
         typename elfcpp::Swap<valsize, big_endian>::Valtype addend,
416
         typename elfcpp::Elf_types<size>::Elf_Addr address)
417
  {
418
    typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
419
    Valtype* wv = reinterpret_cast<Valtype*>(view);
420
    elfcpp::Swap<valsize, big_endian>::writeval(wv, value + addend - address);
421
  }
422
 
423
  // Do a simple PC relative relocation with a Symbol_value with the
424
  // addend in the relocation.  VALSIZE is the size of the value.
425
  template<int valsize>
426
  static inline void
427
  pcrela(unsigned char* view,
428
         const Sized_relobj_file<size, big_endian>* object,
429
         const Symbol_value<size>* psymval,
430
         typename elfcpp::Swap<valsize, big_endian>::Valtype addend,
431
         typename elfcpp::Elf_types<size>::Elf_Addr address)
432
  {
433
    typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
434
    Valtype* wv = reinterpret_cast<Valtype*>(view);
435
    Valtype x = psymval->value(object, addend);
436
    elfcpp::Swap<valsize, big_endian>::writeval(wv, x - address);
437
  }
438
 
439
  typedef Relocate_functions<size, big_endian> This;
440
 
441
public:
442
  // Do a simple 8-bit REL relocation with the addend in the section
443
  // contents.
444
  static inline void
445
  rel8(unsigned char* view, unsigned char value)
446
  { This::template rel<8>(view, value); }
447
 
448
  static inline void
449
  rel8(unsigned char* view,
450
       const Sized_relobj_file<size, big_endian>* object,
451
       const Symbol_value<size>* psymval)
452
  { This::template rel<8>(view, object, psymval); }
453
 
454
  // Do an 8-bit RELA relocation with the addend in the relocation.
455
  static inline void
456
  rela8(unsigned char* view, unsigned char value, unsigned char addend)
457
  { This::template rela<8>(view, value, addend); }
458
 
459
  static inline void
460
  rela8(unsigned char* view,
461
        const Sized_relobj_file<size, big_endian>* object,
462
        const Symbol_value<size>* psymval,
463
        unsigned char addend)
464
  { This::template rela<8>(view, object, psymval, addend); }
465
 
466
  // Do a simple 8-bit PC relative relocation with the addend in the
467
  // section contents.
468
  static inline void
469
  pcrel8(unsigned char* view, unsigned char value,
470
         typename elfcpp::Elf_types<size>::Elf_Addr address)
471
  { This::template pcrel<8>(view, value, address); }
472
 
473
  static inline void
474
  pcrel8(unsigned char* view,
475
         const Sized_relobj_file<size, big_endian>* object,
476
         const Symbol_value<size>* psymval,
477
         typename elfcpp::Elf_types<size>::Elf_Addr address)
478
  { This::template pcrel<8>(view, object, psymval, address); }
479
 
480
  // Do a simple 8-bit PC relative RELA relocation with the addend in
481
  // the reloc.
482
  static inline void
483
  pcrela8(unsigned char* view, unsigned char value, unsigned char addend,
484
          typename elfcpp::Elf_types<size>::Elf_Addr address)
485
  { This::template pcrela<8>(view, value, addend, address); }
486
 
487
  static inline void
488
  pcrela8(unsigned char* view,
489
          const Sized_relobj_file<size, big_endian>* object,
490
          const Symbol_value<size>* psymval,
491
          unsigned char addend,
492
          typename elfcpp::Elf_types<size>::Elf_Addr address)
493
  { This::template pcrela<8>(view, object, psymval, addend, address); }
494
 
495
  // Do a simple 16-bit REL relocation with the addend in the section
496
  // contents.
497
  static inline void
498
  rel16(unsigned char* view, elfcpp::Elf_Half value)
499
  { This::template rel<16>(view, value); }
500
 
501
  static inline void
502
  rel16(unsigned char* view,
503
        const Sized_relobj_file<size, big_endian>* object,
504
        const Symbol_value<size>* psymval)
505
  { This::template rel<16>(view, object, psymval); }
506
 
507
  // Do an 16-bit RELA relocation with the addend in the relocation.
508
  static inline void
509
  rela16(unsigned char* view, elfcpp::Elf_Half value, elfcpp::Elf_Half addend)
510
  { This::template rela<16>(view, value, addend); }
511
 
512
  static inline void
513
  rela16(unsigned char* view,
514
         const Sized_relobj_file<size, big_endian>* object,
515
         const Symbol_value<size>* psymval,
516
         elfcpp::Elf_Half addend)
517
  { This::template rela<16>(view, object, psymval, addend); }
518
 
519
  // Do a simple 16-bit PC relative REL relocation with the addend in
520
  // the section contents.
521
  static inline void
522
  pcrel16(unsigned char* view, elfcpp::Elf_Half value,
523
          typename elfcpp::Elf_types<size>::Elf_Addr address)
524
  { This::template pcrel<16>(view, value, address); }
525
 
526
  static inline void
527
  pcrel16(unsigned char* view,
528
          const Sized_relobj_file<size, big_endian>* object,
529
          const Symbol_value<size>* psymval,
530
          typename elfcpp::Elf_types<size>::Elf_Addr address)
531
  { This::template pcrel<16>(view, object, psymval, address); }
532
 
533
  // Do a simple 16-bit PC relative RELA relocation with the addend in
534
  // the reloc.
535
  static inline void
536
  pcrela16(unsigned char* view, elfcpp::Elf_Half value,
537
           elfcpp::Elf_Half addend,
538
           typename elfcpp::Elf_types<size>::Elf_Addr address)
539
  { This::template pcrela<16>(view, value, addend, address); }
540
 
541
  static inline void
542
  pcrela16(unsigned char* view,
543
           const Sized_relobj_file<size, big_endian>* object,
544
           const Symbol_value<size>* psymval,
545
           elfcpp::Elf_Half addend,
546
           typename elfcpp::Elf_types<size>::Elf_Addr address)
547
  { This::template pcrela<16>(view, object, psymval, addend, address); }
548
 
549
  // Do a simple 32-bit REL relocation with the addend in the section
550
  // contents.
551
  static inline void
552
  rel32(unsigned char* view, elfcpp::Elf_Word value)
553
  { This::template rel<32>(view, value); }
554
 
555
  static inline void
556
  rel32(unsigned char* view,
557
        const Sized_relobj_file<size, big_endian>* object,
558
        const Symbol_value<size>* psymval)
559
  { This::template rel<32>(view, object, psymval); }
560
 
561
  // Do an 32-bit RELA relocation with the addend in the relocation.
562
  static inline void
563
  rela32(unsigned char* view, elfcpp::Elf_Word value, elfcpp::Elf_Word addend)
564
  { This::template rela<32>(view, value, addend); }
565
 
566
  static inline void
567
  rela32(unsigned char* view,
568
         const Sized_relobj_file<size, big_endian>* object,
569
         const Symbol_value<size>* psymval,
570
         elfcpp::Elf_Word addend)
571
  { This::template rela<32>(view, object, psymval, addend); }
572
 
573
  // Do a simple 32-bit PC relative REL relocation with the addend in
574
  // the section contents.
575
  static inline void
576
  pcrel32(unsigned char* view, elfcpp::Elf_Word value,
577
          typename elfcpp::Elf_types<size>::Elf_Addr address)
578
  { This::template pcrel<32>(view, value, address); }
579
 
580
  static inline void
581
  pcrel32(unsigned char* view,
582
          const Sized_relobj_file<size, big_endian>* object,
583
          const Symbol_value<size>* psymval,
584
          typename elfcpp::Elf_types<size>::Elf_Addr address)
585
  { This::template pcrel<32>(view, object, psymval, address); }
586
 
587
  // Do a simple 32-bit PC relative RELA relocation with the addend in
588
  // the relocation.
589
  static inline void
590
  pcrela32(unsigned char* view, elfcpp::Elf_Word value,
591
           elfcpp::Elf_Word addend,
592
           typename elfcpp::Elf_types<size>::Elf_Addr address)
593
  { This::template pcrela<32>(view, value, addend, address); }
594
 
595
  static inline void
596
  pcrela32(unsigned char* view,
597
           const Sized_relobj_file<size, big_endian>* object,
598
           const Symbol_value<size>* psymval,
599
           elfcpp::Elf_Word addend,
600
           typename elfcpp::Elf_types<size>::Elf_Addr address)
601
  { This::template pcrela<32>(view, object, psymval, addend, address); }
602
 
603
  // Do a simple 64-bit REL relocation with the addend in the section
604
  // contents.
605
  static inline void
606
  rel64(unsigned char* view, elfcpp::Elf_Xword value)
607
  { This::template rel<64>(view, value); }
608
 
609
  static inline void
610
  rel64(unsigned char* view,
611
        const Sized_relobj_file<size, big_endian>* object,
612
        const Symbol_value<size>* psymval)
613
  { This::template rel<64>(view, object, psymval); }
614
 
615
  // Do a 64-bit RELA relocation with the addend in the relocation.
616
  static inline void
617
  rela64(unsigned char* view, elfcpp::Elf_Xword value,
618
         elfcpp::Elf_Xword addend)
619
  { This::template rela<64>(view, value, addend); }
620
 
621
  static inline void
622
  rela64(unsigned char* view,
623
         const Sized_relobj_file<size, big_endian>* object,
624
         const Symbol_value<size>* psymval,
625
         elfcpp::Elf_Xword addend)
626
  { This::template rela<64>(view, object, psymval, addend); }
627
 
628
  // Do a simple 64-bit PC relative REL relocation with the addend in
629
  // the section contents.
630
  static inline void
631
  pcrel64(unsigned char* view, elfcpp::Elf_Xword value,
632
          typename elfcpp::Elf_types<size>::Elf_Addr address)
633
  { This::template pcrel<64>(view, value, address); }
634
 
635
  static inline void
636
  pcrel64(unsigned char* view,
637
          const Sized_relobj_file<size, big_endian>* object,
638
          const Symbol_value<size>* psymval,
639
          typename elfcpp::Elf_types<size>::Elf_Addr address)
640
  { This::template pcrel<64>(view, object, psymval, address); }
641
 
642
  // Do a simple 64-bit PC relative RELA relocation with the addend in
643
  // the relocation.
644
  static inline void
645
  pcrela64(unsigned char* view, elfcpp::Elf_Xword value,
646
           elfcpp::Elf_Xword addend,
647
           typename elfcpp::Elf_types<size>::Elf_Addr address)
648
  { This::template pcrela<64>(view, value, addend, address); }
649
 
650
  static inline void
651
  pcrela64(unsigned char* view,
652
           const Sized_relobj_file<size, big_endian>* object,
653
           const Symbol_value<size>* psymval,
654
           elfcpp::Elf_Xword addend,
655
           typename elfcpp::Elf_types<size>::Elf_Addr address)
656
  { This::template pcrela<64>(view, object, psymval, addend, address); }
657
};
658
 
659
// Track relocations while reading a section.  This lets you ask for
660
// the relocation at a certain offset, and see how relocs occur
661
// between points of interest.
662
 
663
template<int size, bool big_endian>
664
class Track_relocs
665
{
666
 public:
667
  Track_relocs()
668
    : prelocs_(NULL), len_(0), pos_(0), reloc_size_(0)
669
  { }
670
 
671
  // Initialize the Track_relocs object.  OBJECT is the object holding
672
  // the reloc section, RELOC_SHNDX is the section index of the reloc
673
  // section, and RELOC_TYPE is the type of the reloc section
674
  // (elfcpp::SHT_REL or elfcpp::SHT_RELA).  This returns false if
675
  // something went wrong.
676
  bool
677
  initialize(Object* object, unsigned int reloc_shndx,
678
             unsigned int reloc_type);
679
 
680
  // Return the offset in the data section to which the next reloc
681
  // applies.  This returns -1 if there is no next reloc.
682
  off_t
683
  next_offset() const;
684
 
685
  // Return the symbol index of the next reloc.  This returns -1U if
686
  // there is no next reloc.
687
  unsigned int
688
  next_symndx() const;
689
 
690
  // Return the addend of the next reloc.  This returns 0 if there is
691
  // no next reloc.
692
  uint64_t
693
  next_addend() const;
694
 
695
  // Advance to OFFSET within the data section, and return the number
696
  // of relocs which would be skipped.
697
  int
698
  advance(off_t offset);
699
 
700
 private:
701
  // The contents of the input object's reloc section.
702
  const unsigned char* prelocs_;
703
  // The length of the reloc section.
704
  section_size_type len_;
705
  // Our current position in the reloc section.
706
  section_size_type pos_;
707
  // The size of the relocs in the section.
708
  int reloc_size_;
709
};
710
 
711
} // End namespace gold.
712
 
713
#endif // !defined(GOLD_RELOC_H)

powered by: WebSVN 2.1.0

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