forked from bminor/binutils-gdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject.h
3090 lines (2615 loc) · 94.2 KB
/
object.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// object.h -- support for an object file for linking in gold -*- C++ -*-
// Copyright (C) 2006-2025 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <[email protected]>.
// This file is part of gold.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
// MA 02110-1301, USA.
#ifndef GOLD_OBJECT_H
#define GOLD_OBJECT_H
#include <string>
#include <vector>
#include "elfcpp.h"
#include "elfcpp_file.h"
#include "fileread.h"
#include "target.h"
#include "archive.h"
namespace gold
{
class General_options;
class Task;
class Cref;
class Layout;
class Kept_section;
class Output_data;
class Output_section;
class Output_section_data;
class Output_file;
class Output_symtab_xindex;
class Pluginobj;
class Dynobj;
class Object_merge_map;
class Relocatable_relocs;
struct Symbols_data;
template<typename Stringpool_char>
class Stringpool_template;
// Data to pass from read_symbols() to add_symbols().
struct Read_symbols_data
{
Read_symbols_data()
: section_headers(NULL), section_names(NULL), symbols(NULL),
symbol_names(NULL), versym(NULL), verdef(NULL), verneed(NULL)
{ }
~Read_symbols_data();
// Section headers.
File_view* section_headers;
// Section names.
File_view* section_names;
// Size of section name data in bytes.
section_size_type section_names_size;
// Symbol data.
File_view* symbols;
// Size of symbol data in bytes.
section_size_type symbols_size;
// Offset of external symbols within symbol data. This structure
// sometimes contains only external symbols, in which case this will
// be zero. Sometimes it contains all symbols.
section_offset_type external_symbols_offset;
// Symbol names.
File_view* symbol_names;
// Size of symbol name data in bytes.
section_size_type symbol_names_size;
// Version information. This is only used on dynamic objects.
// Version symbol data (from SHT_GNU_versym section).
File_view* versym;
section_size_type versym_size;
// Version definition data (from SHT_GNU_verdef section).
File_view* verdef;
section_size_type verdef_size;
unsigned int verdef_info;
// Needed version data (from SHT_GNU_verneed section).
File_view* verneed;
section_size_type verneed_size;
unsigned int verneed_info;
};
// Information used to print error messages.
struct Symbol_location_info
{
std::string source_file;
std::string enclosing_symbol_name;
elfcpp::STT enclosing_symbol_type;
};
// Data about a single relocation section. This is read in
// read_relocs and processed in scan_relocs.
struct Section_relocs
{
Section_relocs()
: contents(NULL)
{ }
~Section_relocs()
{ delete this->contents; }
// Index of reloc section.
unsigned int reloc_shndx;
// Index of section that relocs apply to.
unsigned int data_shndx;
// Contents of reloc section.
File_view* contents;
// Reloc section type.
unsigned int sh_type;
// Number of reloc entries.
size_t reloc_count;
// Output section.
Output_section* output_section;
// Whether this section has special handling for offsets.
bool needs_special_offset_handling;
// Whether the data section is allocated (has the SHF_ALLOC flag set).
bool is_data_section_allocated;
};
// Relocations in an object file. This is read in read_relocs and
// processed in scan_relocs.
struct Read_relocs_data
{
Read_relocs_data()
: local_symbols(NULL)
{ }
~Read_relocs_data()
{ delete this->local_symbols; }
typedef std::vector<Section_relocs> Relocs_list;
// The relocations.
Relocs_list relocs;
// The local symbols.
File_view* local_symbols;
};
// The Xindex class manages section indexes for objects with more than
// 0xff00 sections.
class Xindex
{
public:
Xindex(int large_shndx_offset)
: large_shndx_offset_(large_shndx_offset), symtab_xindex_()
{ }
// Initialize the symtab_xindex_ array, given the object and the
// section index of the symbol table to use.
template<int size, bool big_endian>
void
initialize_symtab_xindex(Object*, unsigned int symtab_shndx);
// Read in the symtab_xindex_ array, given its section index.
// PSHDRS may optionally point to the section headers.
template<int size, bool big_endian>
void
read_symtab_xindex(Object*, unsigned int xindex_shndx,
const unsigned char* pshdrs);
// Symbol SYMNDX in OBJECT has a section of SHN_XINDEX; return the
// real section index.
unsigned int
sym_xindex_to_shndx(Object* object, unsigned int symndx);
private:
// The type of the array giving the real section index for symbols
// whose st_shndx field holds SHN_XINDEX.
typedef std::vector<unsigned int> Symtab_xindex;
// Adjust a section index if necessary. This should only be called
// for ordinary section indexes.
unsigned int
adjust_shndx(unsigned int shndx)
{
if (shndx >= elfcpp::SHN_LORESERVE)
shndx += this->large_shndx_offset_;
return shndx;
}
// Adjust to apply to large section indexes.
int large_shndx_offset_;
// The data from the SHT_SYMTAB_SHNDX section.
Symtab_xindex symtab_xindex_;
};
// A GOT offset list. A symbol may have more than one GOT offset
// (e.g., when mixing modules compiled with two different TLS models),
// but will usually have at most one. GOT_TYPE identifies the type of
// GOT entry; its values are specific to each target.
class Got_offset_list
{
public:
Got_offset_list()
: got_type_(-1U), got_offset_(0), addend_(0), got_next_(NULL)
{ }
Got_offset_list(unsigned int got_type, unsigned int got_offset,
uint64_t addend)
: got_type_(got_type), got_offset_(got_offset), addend_(addend),
got_next_(NULL)
{ }
~Got_offset_list()
{
if (this->got_next_ != NULL)
{
delete this->got_next_;
this->got_next_ = NULL;
}
}
// Initialize the fields to their default values.
void
init()
{
this->got_type_ = -1U;
this->got_offset_ = 0;
this->addend_ = 0;
this->got_next_ = NULL;
}
// Set the offset for the GOT entry of type GOT_TYPE.
void
set_offset(unsigned int got_type, unsigned int got_offset, uint64_t addend)
{
if (this->got_type_ == -1U)
{
this->got_type_ = got_type;
this->got_offset_ = got_offset;
this->addend_ = addend;
}
else
{
for (Got_offset_list* g = this; g != NULL; g = g->got_next_)
{
if (g->got_type_ == got_type && g->addend_ == addend)
{
g->got_offset_ = got_offset;
return;
}
}
Got_offset_list* g = new Got_offset_list(got_type, got_offset, addend);
g->got_next_ = this->got_next_;
this->got_next_ = g;
}
}
// Return the offset for a GOT entry of type GOT_TYPE.
unsigned int
get_offset(unsigned int got_type, uint64_t addend) const
{
for (const Got_offset_list* g = this; g != NULL; g = g->got_next_)
{
if (g->got_type_ == got_type && g->addend_ == addend)
return g->got_offset_;
}
return -1U;
}
// Return a pointer to the list, or NULL if the list is empty.
const Got_offset_list*
get_list() const
{
if (this->got_type_ == -1U)
return NULL;
return this;
}
// Abstract visitor class for iterating over GOT offsets.
class Visitor
{
public:
Visitor()
{ }
virtual
~Visitor()
{ }
virtual void
visit(unsigned int, unsigned int, uint64_t) = 0;
};
// Loop over all GOT offset entries, calling a visitor class V for each.
void
for_all_got_offsets(Visitor* v) const
{
if (this->got_type_ == -1U)
return;
for (const Got_offset_list* g = this; g != NULL; g = g->got_next_)
v->visit(g->got_type_, g->got_offset_, g->addend_);
}
private:
unsigned int got_type_;
unsigned int got_offset_;
uint64_t addend_;
Got_offset_list* got_next_;
};
// The Local_got_entry_key used to index the GOT offsets for local
// non-TLS symbols, and tp-relative offsets for TLS symbols.
class Local_got_entry_key
{
public:
Local_got_entry_key(unsigned int symndx)
: symndx_(symndx)
{}
// Whether this equals to another Local_got_entry_key.
bool
eq(const Local_got_entry_key& key) const
{
return this->symndx_ == key.symndx_;
}
// Compute a hash value for this using 64-bit FNV-1a hash.
size_t
hash_value() const
{
uint64_t h = 14695981039346656037ULL; // FNV offset basis.
uint64_t prime = 1099511628211ULL;
h = (h ^ static_cast<uint64_t>(this->symndx_)) * prime;
return h;
}
// Functors for associative containers.
struct equal_to
{
bool
operator()(const Local_got_entry_key& key1,
const Local_got_entry_key& key2) const
{ return key1.eq(key2); }
};
struct hash
{
size_t
operator()(const Local_got_entry_key& key) const
{ return key.hash_value(); }
};
private:
// The local symbol index.
unsigned int symndx_;
};
// Type for mapping section index to uncompressed size and contents.
struct Compressed_section_info
{
section_size_type size;
elfcpp::Elf_Xword flag;
uint64_t addralign;
const unsigned char* contents;
};
typedef std::map<unsigned int, Compressed_section_info> Compressed_section_map;
template<int size, bool big_endian>
Compressed_section_map*
build_compressed_section_map(const unsigned char* pshdrs, unsigned int shnum,
const char* names, section_size_type names_size,
Object* obj, bool decompress_if_needed);
// Osabi represents the EI_OSABI field from the ELF header.
class Osabi
{
public:
Osabi(unsigned char ei_osabi)
: ei_osabi_(static_cast<elfcpp::ELFOSABI>(ei_osabi))
{ }
bool
has_shf_retain(elfcpp::Elf_Xword sh_flags) const
{
switch (this->ei_osabi_)
{
case elfcpp::ELFOSABI_GNU:
case elfcpp::ELFOSABI_FREEBSD:
return (sh_flags & elfcpp::SHF_GNU_RETAIN) != 0;
default:
break;
}
return false;
}
elfcpp::Elf_Xword
ignored_sh_flags() const
{
switch (this->ei_osabi_)
{
case elfcpp::ELFOSABI_GNU:
case elfcpp::ELFOSABI_FREEBSD:
return elfcpp::SHF_GNU_RETAIN;
default:
break;
}
return 0;
}
private:
elfcpp::ELFOSABI ei_osabi_;
};
// Object is an abstract base class which represents either a 32-bit
// or a 64-bit input object. This can be a regular object file
// (ET_REL) or a shared object (ET_DYN).
class Object
{
public:
typedef std::vector<Symbol*> Symbols;
// NAME is the name of the object as we would report it to the user
// (e.g., libfoo.a(bar.o) if this is in an archive. INPUT_FILE is
// used to read the file. OFFSET is the offset within the input
// file--0 for a .o or .so file, something else for a .a file.
Object(const std::string& name, Input_file* input_file, bool is_dynamic,
off_t offset = 0)
: name_(name), input_file_(input_file), offset_(offset), shnum_(-1U),
is_dynamic_(is_dynamic), is_needed_(false), uses_split_stack_(false),
has_no_split_stack_(false), no_export_(false),
is_in_system_directory_(false), as_needed_(false), xindex_(NULL),
compressed_sections_(NULL)
{
if (input_file != NULL)
{
input_file->file().add_object();
this->is_in_system_directory_ = input_file->is_in_system_directory();
this->as_needed_ = input_file->options().as_needed();
}
}
virtual ~Object()
{
if (this->input_file_ != NULL)
this->input_file_->file().remove_object();
}
// Return the name of the object as we would report it to the user.
const std::string&
name() const
{ return this->name_; }
// Get the offset into the file.
off_t
offset() const
{ return this->offset_; }
// Return whether this is a dynamic object.
bool
is_dynamic() const
{ return this->is_dynamic_; }
// Return the word size of the object file.
virtual int elfsize() const = 0;
// Return TRUE if this is a big-endian object file.
virtual bool is_big_endian() const = 0;
// Return whether this object is needed--true if it is a dynamic
// object which defines some symbol referenced by a regular object.
// We keep the flag here rather than in Dynobj for convenience when
// setting it.
bool
is_needed() const
{ return this->is_needed_; }
// Record that this object is needed.
void
set_is_needed()
{ this->is_needed_ = true; }
// Return whether this object was compiled with -fsplit-stack.
bool
uses_split_stack() const
{ return this->uses_split_stack_; }
// Return whether this object contains any functions compiled with
// the no_split_stack attribute.
bool
has_no_split_stack() const
{ return this->has_no_split_stack_; }
// Returns NULL for Objects that are not dynamic objects. This method
// is overridden in the Dynobj class.
Dynobj*
dynobj()
{ return this->do_dynobj(); }
// Returns NULL for Objects that are not plugin objects. This method
// is overridden in the Pluginobj class.
Pluginobj*
pluginobj()
{ return this->do_pluginobj(); }
// Get the file. We pass on const-ness.
Input_file*
input_file()
{
gold_assert(this->input_file_ != NULL);
return this->input_file_;
}
const Input_file*
input_file() const
{
gold_assert(this->input_file_ != NULL);
return this->input_file_;
}
// Lock the underlying file.
void
lock(const Task* t)
{
if (this->input_file_ != NULL)
this->input_file_->file().lock(t);
}
// Unlock the underlying file.
void
unlock(const Task* t)
{
if (this->input_file_ != NULL)
this->input_file()->file().unlock(t);
}
// Return whether the underlying file is locked.
bool
is_locked() const
{ return this->input_file_ != NULL && this->input_file_->file().is_locked(); }
// Return the token, so that the task can be queued.
Task_token*
token()
{
if (this->input_file_ == NULL)
return NULL;
return this->input_file()->file().token();
}
// Release the underlying file.
void
release()
{
if (this->input_file_ != NULL)
this->input_file()->file().release();
}
// Return whether we should just read symbols from this file.
bool
just_symbols() const
{ return this->input_file()->just_symbols(); }
// Return whether this is an incremental object.
bool
is_incremental() const
{ return this->do_is_incremental(); }
// Return the last modified time of the file.
Timespec
get_mtime()
{ return this->do_get_mtime(); }
// Get the number of sections.
unsigned int
shnum() const
{ return this->shnum_; }
// Return a view of the contents of a section. Set *PLEN to the
// size. CACHE is a hint as in File_read::get_view.
const unsigned char*
section_contents(unsigned int shndx, section_size_type* plen, bool cache);
// Adjust a symbol's section index as needed. SYMNDX is the index
// of the symbol and SHNDX is the symbol's section from
// get_st_shndx. This returns the section index. It sets
// *IS_ORDINARY to indicate whether this is a normal section index,
// rather than a special code between SHN_LORESERVE and
// SHN_HIRESERVE.
unsigned int
adjust_sym_shndx(unsigned int symndx, unsigned int shndx, bool* is_ordinary)
{
if (shndx < elfcpp::SHN_LORESERVE)
*is_ordinary = true;
else if (shndx == elfcpp::SHN_XINDEX)
{
if (this->xindex_ == NULL)
this->xindex_ = this->do_initialize_xindex();
shndx = this->xindex_->sym_xindex_to_shndx(this, symndx);
*is_ordinary = true;
}
else
*is_ordinary = false;
return shndx;
}
// Return the size of a section given a section index.
uint64_t
section_size(unsigned int shndx)
{ return this->do_section_size(shndx); }
// Return the name of a section given a section index.
std::string
section_name(unsigned int shndx) const
{ return this->do_section_name(shndx); }
// Return the section flags given a section index.
uint64_t
section_flags(unsigned int shndx)
{ return this->do_section_flags(shndx); }
// Return the section entsize given a section index.
uint64_t
section_entsize(unsigned int shndx)
{ return this->do_section_entsize(shndx); }
// Return the section address given a section index.
uint64_t
section_address(unsigned int shndx)
{ return this->do_section_address(shndx); }
// Return the section type given a section index.
unsigned int
section_type(unsigned int shndx)
{ return this->do_section_type(shndx); }
// Return the section link field given a section index.
unsigned int
section_link(unsigned int shndx)
{ return this->do_section_link(shndx); }
// Return the section info field given a section index.
unsigned int
section_info(unsigned int shndx)
{ return this->do_section_info(shndx); }
// Return the required section alignment given a section index.
uint64_t
section_addralign(unsigned int shndx)
{ return this->do_section_addralign(shndx); }
// Return the output section given a section index.
Output_section*
output_section(unsigned int shndx) const
{ return this->do_output_section(shndx); }
// Given a section index, return its address.
// The return value will be -1U if the section is specially mapped,
// such as a merge section.
uint64_t
output_section_address(unsigned int shndx)
{ return this->do_output_section_address(shndx); }
// Given a section index, return the offset in the Output_section.
// The return value will be -1U if the section is specially mapped,
// such as a merge section.
uint64_t
output_section_offset(unsigned int shndx) const
{ return this->do_output_section_offset(shndx); }
// Read the symbol information.
void
read_symbols(Read_symbols_data* sd)
{ return this->do_read_symbols(sd); }
// Pass sections which should be included in the link to the Layout
// object, and record where the sections go in the output file.
void
layout(Symbol_table* symtab, Layout* layout, Read_symbols_data* sd)
{ this->do_layout(symtab, layout, sd); }
// Add symbol information to the global symbol table.
void
add_symbols(Symbol_table* symtab, Read_symbols_data* sd, Layout *layout)
{ this->do_add_symbols(symtab, sd, layout); }
// Add symbol information to the global symbol table.
Archive::Should_include
should_include_member(Symbol_table* symtab, Layout* layout,
Read_symbols_data* sd, std::string* why)
{ return this->do_should_include_member(symtab, layout, sd, why); }
// Iterate over global symbols, calling a visitor class V for each.
void
for_all_global_symbols(Read_symbols_data* sd,
Library_base::Symbol_visitor_base* v)
{ return this->do_for_all_global_symbols(sd, v); }
// Iterate over local symbols, calling a visitor class V for each GOT offset
// associated with a local symbol.
void
for_all_local_got_entries(Got_offset_list::Visitor* v) const
{ this->do_for_all_local_got_entries(v); }
// Functions and types for the elfcpp::Elf_file interface. This
// permit us to use Object as the File template parameter for
// elfcpp::Elf_file.
// The View class is returned by view. It must support a single
// method, data(). This is trivial, because get_view does what we
// need.
class View
{
public:
View(const unsigned char* p)
: p_(p)
{ }
const unsigned char*
data() const
{ return this->p_; }
private:
const unsigned char* p_;
};
// Return a View.
View
view(off_t file_offset, section_size_type data_size)
{ return View(this->get_view(file_offset, data_size, true, true)); }
// Report an error.
void
error(const char* format, ...) const ATTRIBUTE_PRINTF_2;
// A location in the file.
struct Location
{
off_t file_offset;
off_t data_size;
Location(off_t fo, section_size_type ds)
: file_offset(fo), data_size(ds)
{ }
};
// Get a View given a Location.
View view(Location loc)
{ return View(this->get_view(loc.file_offset, loc.data_size, true, true)); }
// Get a view into the underlying file.
const unsigned char*
get_view(off_t start, section_size_type size, bool aligned, bool cache)
{
return this->input_file()->file().get_view(this->offset_, start, size,
aligned, cache);
}
// Get a lasting view into the underlying file.
File_view*
get_lasting_view(off_t start, section_size_type size, bool aligned,
bool cache)
{
return this->input_file()->file().get_lasting_view(this->offset_, start,
size, aligned, cache);
}
// Read data from the underlying file.
void
read(off_t start, section_size_type size, void* p)
{ this->input_file()->file().read(start + this->offset_, size, p); }
// Read multiple data from the underlying file.
void
read_multiple(const File_read::Read_multiple& rm)
{ this->input_file()->file().read_multiple(this->offset_, rm); }
// Stop caching views in the underlying file.
void
clear_view_cache_marks()
{
if (this->input_file_ != NULL)
this->input_file_->file().clear_view_cache_marks();
}
// Get the number of global symbols defined by this object, and the
// number of the symbols whose final definition came from this
// object.
void
get_global_symbol_counts(const Symbol_table* symtab, size_t* defined,
size_t* used) const
{ this->do_get_global_symbol_counts(symtab, defined, used); }
// Get the symbols defined in this object.
const Symbols*
get_global_symbols() const
{ return this->do_get_global_symbols(); }
// Set flag that this object was found in a system directory.
void
set_is_in_system_directory()
{ this->is_in_system_directory_ = true; }
// Return whether this object was found in a system directory.
bool
is_in_system_directory() const
{ return this->is_in_system_directory_; }
// Set flag that this object was linked with --as-needed.
void
set_as_needed()
{ this->as_needed_ = true; }
// Clear flag that this object was linked with --as-needed.
void
clear_as_needed()
{ this->as_needed_ = false; }
// Return whether this object was linked with --as-needed.
bool
as_needed() const
{ return this->as_needed_; }
// Return whether we found this object by searching a directory.
bool
searched_for() const
{ return this->input_file()->will_search_for(); }
bool
no_export() const
{ return this->no_export_; }
void
set_no_export(bool value)
{ this->no_export_ = value; }
bool
section_is_compressed(unsigned int shndx,
section_size_type* uncompressed_size,
elfcpp::Elf_Xword* palign = NULL) const
{
if (this->compressed_sections_ == NULL)
return false;
Compressed_section_map::const_iterator p =
this->compressed_sections_->find(shndx);
if (p != this->compressed_sections_->end())
{
if (uncompressed_size != NULL)
*uncompressed_size = p->second.size;
if (palign != NULL)
*palign = p->second.addralign;
return true;
}
return false;
}
// Return a view of the decompressed contents of a section. Set *PLEN
// to the size. Set *IS_NEW to true if the contents need to be freed
// by the caller.
const unsigned char*
decompressed_section_contents(unsigned int shndx, section_size_type* plen,
bool* is_cached, uint64_t* palign = NULL);
// Discard any buffers of decompressed sections. This is done
// at the end of the Add_symbols task.
void
discard_decompressed_sections();
// Return the index of the first incremental relocation for symbol SYMNDX.
unsigned int
get_incremental_reloc_base(unsigned int symndx) const
{ return this->do_get_incremental_reloc_base(symndx); }
// Return the number of incremental relocations for symbol SYMNDX.
unsigned int
get_incremental_reloc_count(unsigned int symndx) const
{ return this->do_get_incremental_reloc_count(symndx); }
// Return the output view for section SHNDX.
unsigned char*
get_output_view(unsigned int shndx, section_size_type* plen) const
{ return this->do_get_output_view(shndx, plen); }
protected:
// Returns NULL for Objects that are not dynamic objects. This method
// is overridden in the Dynobj class.
virtual Dynobj*
do_dynobj()
{ return NULL; }
// Returns NULL for Objects that are not plugin objects. This method
// is overridden in the Pluginobj class.
virtual Pluginobj*
do_pluginobj()
{ return NULL; }
// Return TRUE if this is an incremental (unchanged) input file.
// We return FALSE by default; the incremental object classes
// override this method.
virtual bool
do_is_incremental() const
{ return false; }
// Return the last modified time of the file. This method may be
// overridden for subclasses that don't use an actual file (e.g.,
// Incremental objects).
virtual Timespec
do_get_mtime()
{ return this->input_file()->file().get_mtime(); }
// Read the symbols--implemented by child class.
virtual void
do_read_symbols(Read_symbols_data*) = 0;
// Lay out sections--implemented by child class.
virtual void
do_layout(Symbol_table*, Layout*, Read_symbols_data*) = 0;
// Add symbol information to the global symbol table--implemented by
// child class.
virtual void
do_add_symbols(Symbol_table*, Read_symbols_data*, Layout*) = 0;
virtual Archive::Should_include
do_should_include_member(Symbol_table* symtab, Layout*, Read_symbols_data*,
std::string* why) = 0;
// Iterate over global symbols, calling a visitor class V for each.
virtual void
do_for_all_global_symbols(Read_symbols_data* sd,
Library_base::Symbol_visitor_base* v) = 0;
// Iterate over local symbols, calling a visitor class V for each GOT offset
// associated with a local symbol.
virtual void
do_for_all_local_got_entries(Got_offset_list::Visitor* v) const = 0;
// Return the location of the contents of a section. Implemented by
// child class.
virtual const unsigned char*
do_section_contents(unsigned int shndx, section_size_type* plen,
bool cache) = 0;
// Get the size of a section--implemented by child class.
virtual uint64_t
do_section_size(unsigned int shndx) = 0;
// Get the name of a section--implemented by child class.
virtual std::string
do_section_name(unsigned int shndx) const = 0;
// Get section flags--implemented by child class.
virtual uint64_t
do_section_flags(unsigned int shndx) = 0;
// Get section entsize--implemented by child class.
virtual uint64_t
do_section_entsize(unsigned int shndx) = 0;
// Get section address--implemented by child class.
virtual uint64_t
do_section_address(unsigned int shndx) = 0;
// Get section type--implemented by child class.
virtual unsigned int
do_section_type(unsigned int shndx) = 0;
// Get section link field--implemented by child class.
virtual unsigned int
do_section_link(unsigned int shndx) = 0;
// Get section info field--implemented by child class.
virtual unsigned int
do_section_info(unsigned int shndx) = 0;
// Get section alignment--implemented by child class.
virtual uint64_t
do_section_addralign(unsigned int shndx) = 0;
// Return the output section given a section index--implemented
// by child class.
virtual Output_section*
do_output_section(unsigned int) const
{ gold_unreachable(); }