1 // symtab.h -- the gold symbol table -*- C++ -*-
11 #include "stringpool.h"
22 template<int size
, bool big_endian
>
25 template<int size
, bool big_endian
>
33 // The base class of an entry in the symbol table. The symbol table
34 // can have a lot of entries, so we don't want this class to big.
35 // Size dependent fields can be found in the template class
36 // Sized_symbol. Targets may support their own derived classes.
41 // Because we want the class to be small, we don't use any virtual
42 // functions. But because symbols can be defined in different
43 // places, we need to classify them. This enum is the different
44 // sources of symbols we support.
47 // Symbol defined in a relocatable or dynamic input file--this is
48 // the most common case.
50 // Symbol defined in an Output_data, a special section created by
53 // Symbol defined in an Output_segment, with no associated
56 // Symbol value is constant.
60 // When the source is IN_OUTPUT_SEGMENT, we need to describe what
62 enum Segment_offset_base
64 // From the start of the segment.
66 // From the end of the segment.
68 // From the filesz of the segment--i.e., after the loaded bytes
69 // but before the bytes which are allocated but zeroed.
73 // Return the symbol name.
76 { return this->name_
; }
78 // Return the symbol version. This will return NULL for an
79 // unversioned symbol.
82 { return this->version_
; }
84 // Return the symbol source.
87 { return this->source_
; }
89 // Return the object with which this symbol is associated.
93 gold_assert(this->source_
== FROM_OBJECT
);
94 return this->u_
.from_object
.object
;
97 // Return the index of the section in the input relocatable or
98 // dynamic object file.
102 gold_assert(this->source_
== FROM_OBJECT
);
103 return this->u_
.from_object
.shnum
;
106 // Return the output data section with which this symbol is
107 // associated, if the symbol was specially defined with respect to
108 // an output data section.
112 gold_assert(this->source_
== IN_OUTPUT_DATA
);
113 return this->u_
.in_output_data
.output_data
;
116 // If this symbol was defined with respect to an output data
117 // section, return whether the value is an offset from end.
119 offset_is_from_end() const
121 gold_assert(this->source_
== IN_OUTPUT_DATA
);
122 return this->u_
.in_output_data
.offset_is_from_end
;
125 // Return the output segment with which this symbol is associated,
126 // if the symbol was specially defined with respect to an output
129 output_segment() const
131 gold_assert(this->source_
== IN_OUTPUT_SEGMENT
);
132 return this->u_
.in_output_segment
.output_segment
;
135 // If this symbol was defined with respect to an output segment,
136 // return the offset base.
140 gold_assert(this->source_
== IN_OUTPUT_SEGMENT
);
141 return this->u_
.in_output_segment
.offset_base
;
144 // Return the symbol binding.
147 { return this->binding_
; }
149 // Return the symbol type.
152 { return this->type_
; }
154 // Return the symbol visibility.
157 { return this->visibility_
; }
159 // Return the non-visibility part of the st_other field.
162 { return this->nonvis_
; }
164 // Return whether this symbol is a forwarder. This will never be
165 // true of a symbol found in the hash table, but may be true of
166 // symbol pointers attached to object files.
169 { return this->is_forwarder_
; }
171 // Mark this symbol as a forwarder.
174 { this->is_forwarder_
= true; }
176 // Return whether this symbol needs an entry in the dynamic symbol
179 needs_dynsym_entry() const
180 { return this->needs_dynsym_entry_
; }
182 // Mark this symbol as needing an entry in the dynamic symbol table.
184 set_needs_dynsym_entry()
185 { this->needs_dynsym_entry_
= true; }
187 // Mark this symbol as having been seen in a dynamic object.
190 { this->in_dyn_
= true; }
192 // Return the index of this symbol in the output file symbol table.
193 // A value of -1U means that this symbol is not going into the
194 // output file. This starts out as zero, and is set to a non-zero
195 // value by Symbol_table::finalize. It is an error to ask for the
196 // symbol table index before it has been set.
200 gold_assert(this->symtab_index_
!= 0);
201 return this->symtab_index_
;
204 // Set the index of the symbol in the output file symbol table.
206 set_symtab_index(unsigned int index
)
208 gold_assert(index
!= 0);
209 this->symtab_index_
= index
;
212 // Return whether this symbol already has an index in the output
213 // file symbol table.
215 has_symtab_index() const
216 { return this->symtab_index_
!= 0; }
218 // Return the index of this symbol in the dynamic symbol table. A
219 // value of -1U means that this symbol is not going into the dynamic
220 // symbol table. This starts out as zero, and is set to a non-zero
221 // during Layout::finalize. It is an error to ask for the dynamic
222 // symbol table index before it has been set.
226 gold_assert(this->dynsym_index_
!= 0);
227 return this->dynsym_index_
;
230 // Set the index of the symbol in the dynamic symbol table.
232 set_dynsym_index(unsigned int index
)
234 gold_assert(index
!= 0);
235 this->dynsym_index_
= index
;
238 // Return whether this symbol has an entry in the GOT section.
240 has_got_offset() const
241 { return this->has_got_offset_
; }
243 // Return the offset into the GOT section of this symbol.
247 gold_assert(this->has_got_offset());
248 return this->got_offset_
;
251 // Set the GOT offset of this symbol.
253 set_got_offset(unsigned int got_offset
)
255 this->has_got_offset_
= true;
256 this->got_offset_
= got_offset
;
259 // Return whether this symbol has an entry in the PLT section.
261 has_plt_offset() const
262 { return this->has_plt_offset_
; }
264 // Return the offset into the PLT section of this symbol.
268 gold_assert(this->has_plt_offset());
269 return this->plt_offset_
;
272 // Set the PLT offset of this symbol.
274 set_plt_offset(unsigned int plt_offset
)
276 this->has_plt_offset_
= true;
277 this->plt_offset_
= plt_offset
;
280 // Return true if the final value of this symbol is known at link
283 final_value_is_known(const General_options
* options
) const
285 if (options
->is_shared())
287 return this->source_
!= FROM_OBJECT
|| !this->object()->is_dynamic();
290 // Return whether this is a defined symbol (not undefined or
295 return (this->source_
!= FROM_OBJECT
296 || (this->shnum() != elfcpp::SHN_UNDEF
297 && this->shnum() != elfcpp::SHN_COMMON
));
300 // Return whether this symbol is defined in a dynamic object.
302 is_defined_in_dynobj() const
304 return (this->source_
== FROM_OBJECT
305 && this->object()->is_dynamic()
306 && this->is_defined());
309 // Return whether this is an undefined symbol.
313 return this->source_
== FROM_OBJECT
&& this->shnum() == elfcpp::SHN_UNDEF
;
316 // Return whether this is a common symbol.
320 return (this->source_
== FROM_OBJECT
321 && (this->shnum() == elfcpp::SHN_COMMON
322 || this->type_
== elfcpp::STT_COMMON
));
325 // Return whether there should be a warning for references to this
329 { return this->has_warning_
; }
331 // Mark this symbol as having a warning.
334 { this->has_warning_
= true; }
337 // Instances of this class should always be created at a specific
340 { memset(this, 0, sizeof *this); }
342 // Initialize the general fields.
344 init_fields(const char* name
, const char* version
,
345 elfcpp::STT type
, elfcpp::STB binding
,
346 elfcpp::STV visibility
, unsigned char nonvis
);
348 // Initialize fields from an ELF symbol in OBJECT.
349 template<int size
, bool big_endian
>
351 init_base(const char *name
, const char* version
, Object
* object
,
352 const elfcpp::Sym
<size
, big_endian
>&);
354 // Initialize fields for an Output_data.
356 init_base(const char* name
, Output_data
*, elfcpp::STT
, elfcpp::STB
,
357 elfcpp::STV
, unsigned char nonvis
, bool offset_is_from_end
);
359 // Initialize fields for an Output_segment.
361 init_base(const char* name
, Output_segment
* os
, elfcpp::STT type
,
362 elfcpp::STB binding
, elfcpp::STV visibility
,
363 unsigned char nonvis
, Segment_offset_base offset_base
);
365 // Initialize fields for a constant.
367 init_base(const char* name
, elfcpp::STT type
, elfcpp::STB binding
,
368 elfcpp::STV visibility
, unsigned char nonvis
);
370 // Override existing symbol.
371 template<int size
, bool big_endian
>
373 override_base(const elfcpp::Sym
<size
, big_endian
>&, Object
* object
);
376 Symbol(const Symbol
&);
377 Symbol
& operator=(const Symbol
&);
379 // Symbol name (expected to point into a Stringpool).
381 // Symbol version (expected to point into a Stringpool). This may
383 const char* version_
;
387 // This struct is used if SOURCE_ == FROM_OBJECT.
390 // Object in which symbol is defined, or in which it was first
393 // Section number in object_ in which symbol is defined.
397 // This struct is used if SOURCE_ == IN_OUTPUT_DATA.
400 // Output_data in which symbol is defined. Before
401 // Layout::finalize the symbol's value is an offset within the
403 Output_data
* output_data
;
404 // True if the offset is from the end, false if the offset is
405 // from the beginning.
406 bool offset_is_from_end
;
409 // This struct is used if SOURCE_ == IN_OUTPUT_SEGMENT.
412 // Output_segment in which the symbol is defined. Before
413 // Layout::finalize the symbol's value is an offset.
414 Output_segment
* output_segment
;
415 // The base to use for the offset before Layout::finalize.
416 Segment_offset_base offset_base
;
420 // The index of this symbol in the output file. If the symbol is
421 // not going into the output file, this value is -1U. This field
422 // starts as always holding zero. It is set to a non-zero value by
423 // Symbol_table::finalize.
424 unsigned int symtab_index_
;
426 // The index of this symbol in the dynamic symbol table. If the
427 // symbol is not going into the dynamic symbol table, this value is
428 // -1U. This field starts as always holding zero. It is set to a
429 // non-zero value during Layout::finalize.
430 unsigned int dynsym_index_
;
432 // If this symbol has an entry in the GOT section (has_got_offset_
433 // is true), this is the offset from the start of the GOT section.
434 unsigned int got_offset_
;
436 // If this symbol has an entry in the PLT section (has_plt_offset_
437 // is true), then this is the offset from the start of the PLT
439 unsigned int plt_offset_
;
442 elfcpp::STT type_
: 4;
444 elfcpp::STB binding_
: 4;
445 // Symbol visibility.
446 elfcpp::STV visibility_
: 2;
447 // Rest of symbol st_other field.
448 unsigned int nonvis_
: 6;
449 // The type of symbol.
451 // True if this symbol always requires special target-specific
453 bool is_target_special_
: 1;
454 // True if this is the default version of the symbol.
456 // True if this symbol really forwards to another symbol. This is
457 // used when we discover after the fact that two different entries
458 // in the hash table really refer to the same symbol. This will
459 // never be set for a symbol found in the hash table, but may be set
460 // for a symbol found in the list of symbols attached to an Object.
461 // It forwards to the symbol found in the forwarders_ map of
463 bool is_forwarder_
: 1;
464 // True if this symbol needs to be in the dynamic symbol table.
465 bool needs_dynsym_entry_
: 1;
466 // True if we've seen this symbol in a dynamic object.
468 // True if the symbol has an entry in the GOT section.
469 bool has_got_offset_
: 1;
470 // True if the symbol has an entry in the PLT section.
471 bool has_plt_offset_
: 1;
472 // True if there is a warning for this symbol.
473 bool has_warning_
: 1;
476 // The parts of a symbol which are size specific. Using a template
477 // derived class like this helps us use less space on a 32-bit system.
480 class Sized_symbol
: public Symbol
483 typedef typename
elfcpp::Elf_types
<size
>::Elf_Addr Value_type
;
484 typedef typename
elfcpp::Elf_types
<size
>::Elf_WXword Size_type
;
489 // Initialize fields from an ELF symbol in OBJECT.
490 template<bool big_endian
>
492 init(const char *name
, const char* version
, Object
* object
,
493 const elfcpp::Sym
<size
, big_endian
>&);
495 // Initialize fields for an Output_data.
497 init(const char* name
, Output_data
*, Value_type value
, Size_type symsize
,
498 elfcpp::STT
, elfcpp::STB
, elfcpp::STV
, unsigned char nonvis
,
499 bool offset_is_from_end
);
501 // Initialize fields for an Output_segment.
503 init(const char* name
, Output_segment
*, Value_type value
, Size_type symsize
,
504 elfcpp::STT
, elfcpp::STB
, elfcpp::STV
, unsigned char nonvis
,
505 Segment_offset_base offset_base
);
507 // Initialize fields for a constant.
509 init(const char* name
, Value_type value
, Size_type symsize
,
510 elfcpp::STT
, elfcpp::STB
, elfcpp::STV
, unsigned char nonvis
);
512 // Override existing symbol.
513 template<bool big_endian
>
515 override(const elfcpp::Sym
<size
, big_endian
>&, Object
* object
);
517 // Return the symbol's value.
520 { return this->value_
; }
522 // Return the symbol's size (we can't call this 'size' because that
523 // is a template parameter).
526 { return this->symsize_
; }
528 // Set the symbol size. This is used when resolving common symbols.
530 set_symsize(Size_type symsize
)
531 { this->symsize_
= symsize
; }
533 // Set the symbol value. This is called when we store the final
534 // values of the symbols into the symbol table.
536 set_value(Value_type value
)
537 { this->value_
= value
; }
540 Sized_symbol(const Sized_symbol
&);
541 Sized_symbol
& operator=(const Sized_symbol
&);
543 // Symbol value. Before Layout::finalize this is the offset in the
544 // input section. This is set to the final value during
551 // A struct describing a symbol defined by the linker, where the value
552 // of the symbol is defined based on an output section. This is used
553 // for symbols defined by the linker, like "_init_array_start".
555 struct Define_symbol_in_section
559 // The name of the output section with which this symbol should be
560 // associated. If there is no output section with that name, the
561 // symbol will be defined as zero.
562 const char* output_section
;
563 // The offset of the symbol within the output section. This is an
564 // offset from the start of the output section, unless start_at_end
565 // is true, in which case this is an offset from the end of the
568 // The size of the symbol.
572 // The symbol binding.
574 // The symbol visibility.
575 elfcpp::STV visibility
;
576 // The rest of the st_other field.
577 unsigned char nonvis
;
578 // If true, the value field is an offset from the end of the output
580 bool offset_is_from_end
;
581 // If true, this symbol is defined only if we see a reference to it.
585 // A struct describing a symbol defined by the linker, where the value
586 // of the symbol is defined based on a segment. This is used for
587 // symbols defined by the linker, like "_end". We describe the
588 // segment with which the symbol should be associated by its
589 // characteristics. If no segment meets these characteristics, the
590 // symbol will be defined as zero. If there is more than one segment
591 // which meets these characteristics, we will use the first one.
593 struct Define_symbol_in_segment
597 // The segment type where the symbol should be defined, typically
599 elfcpp::PT segment_type
;
600 // Bitmask of segment flags which must be set.
601 elfcpp::PF segment_flags_set
;
602 // Bitmask of segment flags which must be clear.
603 elfcpp::PF segment_flags_clear
;
604 // The offset of the symbol within the segment. The offset is
605 // calculated from the position set by offset_base.
607 // The size of the symbol.
611 // The symbol binding.
613 // The symbol visibility.
614 elfcpp::STV visibility
;
615 // The rest of the st_other field.
616 unsigned char nonvis
;
617 // The base from which we compute the offset.
618 Symbol::Segment_offset_base offset_base
;
619 // If true, this symbol is defined only if we see a reference to it.
623 // This class manages warnings. Warnings are a GNU extension. When
624 // we see a section named .gnu.warning.SYM in an object file, and if
625 // we wind using the definition of SYM from that object file, then we
626 // will issue a warning for any relocation against SYM from a
627 // different object file. The text of the warning is the contents of
628 // the section. This is not precisely the definition used by the old
629 // GNU linker; the old GNU linker treated an occurrence of
630 // .gnu.warning.SYM as defining a warning symbol. A warning symbol
631 // would trigger a warning on any reference. However, it was
632 // inconsistent in that a warning in a dynamic object only triggered
633 // if there was no definition in a regular object. This linker is
634 // different in that we only issue a warning if we use the symbol
635 // definition from the same object file as the warning section.
644 // Add a warning for symbol NAME in section SHNDX in object OBJ.
646 add_warning(Symbol_table
* symtab
, const char* name
, Object
* obj
,
649 // For each symbol for which we should give a warning, make a note
652 note_warnings(Symbol_table
* symtab
);
654 // Issue a warning for a reference to SYM at LOCATION.
656 issue_warning(const Symbol
* sym
, const std::string
& location
) const;
659 Warnings(const Warnings
&);
660 Warnings
& operator=(const Warnings
&);
662 // What we need to know to get the warning text.
663 struct Warning_location
665 // The object the warning is in.
667 // The index of the warning section.
669 // The warning text if we have already loaded it.
673 : object(NULL
), shndx(0), text()
677 set(Object
* o
, unsigned int s
)
684 set_text(const char* t
, off_t l
)
685 { this->text
.assign(t
, l
); }
688 // A mapping from warning symbol names (canonicalized in
689 // Symbol_table's namepool_ field) to
690 typedef Unordered_map
<const char*, Warning_location
> Warning_table
;
692 Warning_table warnings_
;
695 // The main linker symbol table.
704 // Add COUNT external symbols from the relocatable object RELOBJ to
705 // the symbol table. SYMS is the symbols, SYM_NAMES is their names,
706 // SYM_NAME_SIZE is the size of SYM_NAMES. This sets SYMPOINTERS to
707 // point to the symbols in the symbol table.
708 template<int size
, bool big_endian
>
710 add_from_relobj(Sized_relobj
<size
, big_endian
>* relobj
,
711 const unsigned char* syms
, size_t count
,
712 const char* sym_names
, size_t sym_name_size
,
713 Symbol
** sympointers
);
715 // Add COUNT dynamic symbols from the dynamic object DYNOBJ to the
716 // symbol table. SYMS is the symbols. SYM_NAMES is their names.
717 // SYM_NAME_SIZE is the size of SYM_NAMES. The other parameters are
718 // symbol version data.
719 template<int size
, bool big_endian
>
721 add_from_dynobj(Sized_dynobj
<size
, big_endian
>* dynobj
,
722 const unsigned char* syms
, size_t count
,
723 const char* sym_names
, size_t sym_name_size
,
724 const unsigned char* versym
, size_t versym_size
,
725 const std::vector
<const char*>*);
727 // Define a special symbol.
728 template<int size
, bool big_endian
>
730 define_special_symbol(Target
* target
, const char* name
, bool only_if_ref
733 // Define a special symbol based on an Output_data. It is a
734 // multiple definition error if this symbol is already defined.
736 define_in_output_data(Target
*, const char* name
, Output_data
*,
737 uint64_t value
, uint64_t symsize
,
738 elfcpp::STT type
, elfcpp::STB binding
,
739 elfcpp::STV visibility
, unsigned char nonvis
,
740 bool offset_is_from_end
, bool only_if_ref
);
742 // Define a special symbol based on an Output_segment. It is a
743 // multiple definition error if this symbol is already defined.
745 define_in_output_segment(Target
*, const char* name
, Output_segment
*,
746 uint64_t value
, uint64_t symsize
,
747 elfcpp::STT type
, elfcpp::STB binding
,
748 elfcpp::STV visibility
, unsigned char nonvis
,
749 Symbol::Segment_offset_base
, bool only_if_ref
);
751 // Define a special symbol with a constant value. It is a multiple
752 // definition error if this symbol is already defined.
754 define_as_constant(Target
*, const char* name
, uint64_t value
,
755 uint64_t symsize
, elfcpp::STT type
, elfcpp::STB binding
,
756 elfcpp::STV visibility
, unsigned char nonvis
,
759 // Define a set of symbols in output sections.
761 define_symbols(const Layout
*, Target
*, int count
,
762 const Define_symbol_in_section
*);
764 // Define a set of symbols in output segments.
766 define_symbols(const Layout
*, Target
*, int count
,
767 const Define_symbol_in_segment
*);
771 lookup(const char*, const char* version
= NULL
) const;
773 // Return the real symbol associated with the forwarder symbol FROM.
775 resolve_forwards(const Symbol
* from
) const;
777 // Return the bitsize (32 or 64) of the symbols in the table.
780 { return this->size_
; }
782 // Return the sized version of a symbol in this table.
785 get_sized_symbol(Symbol
* ACCEPT_SIZE
) const;
788 const Sized_symbol
<size
>*
789 get_sized_symbol(const Symbol
* ACCEPT_SIZE
) const;
791 // Return the count of undefined symbols seen.
793 saw_undefined() const
794 { return this->saw_undefined_
; }
796 // Allocate the common symbols
798 allocate_commons(const General_options
&, Layout
*);
800 // Add a warning for symbol NAME in section SHNDX in object OBJ.
802 add_warning(const char* name
, Object
* obj
, unsigned int shndx
)
803 { this->warnings_
.add_warning(this, name
, obj
, shndx
); }
805 // Canonicalize a symbol name for use in the hash table.
807 canonicalize_name(const char* name
)
808 { return this->namepool_
.add(name
, NULL
); }
810 // Possibly issue a warning for a reference to SYM at LOCATION which
813 issue_warning(const Symbol
* sym
, const std::string
& location
) const
814 { this->warnings_
.issue_warning(sym
, location
); }
816 // Set the dynamic symbol indexes. INDEX is the index of the first
817 // global dynamic symbol. Pointers to the symbols are stored into
818 // the vector. The names are stored into the Stringpool. This
819 // returns an updated dynamic symbol index.
821 set_dynsym_indexes(unsigned int index
, std::vector
<Symbol
*>*,
824 // Finalize the symbol table after we have set the final addresses
825 // of all the input sections. This sets the final symbol indexes,
826 // values and adds the names to *POOL. INDEX is the index of the
827 // first global symbol. This records the file offset OFF, and
828 // returns the new file offset.
830 finalize(unsigned int index
, off_t off
, Stringpool
* pool
);
832 // Write out the global symbols.
834 write_globals(const Target
*, const Stringpool
*, Output_file
*) const;
836 // Write out a section symbol. Return the updated offset.
838 write_section_symbol(const Target
*, const Output_section
*, Output_file
*,
842 Symbol_table(const Symbol_table
&);
843 Symbol_table
& operator=(const Symbol_table
&);
845 // Set the size (32 or 64) of the symbols in the table.
848 { this->size_
= size
; }
850 // Make FROM a forwarder symbol to TO.
852 make_forwarder(Symbol
* from
, Symbol
* to
);
855 template<int size
, bool big_endian
>
857 add_from_object(Object
*, const char *name
, Stringpool::Key name_key
,
858 const char *version
, Stringpool::Key version_key
,
859 bool def
, const elfcpp::Sym
<size
, big_endian
>& sym
);
862 template<int size
, bool big_endian
>
864 resolve(Sized_symbol
<size
>* to
,
865 const elfcpp::Sym
<size
, big_endian
>& sym
,
868 template<int size
, bool big_endian
>
870 resolve(Sized_symbol
<size
>* to
, const Sized_symbol
<size
>* from
873 // Define a symbol in an Output_data, sized version.
876 do_define_in_output_data(Target
*, const char* name
, Output_data
*,
877 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
,
878 typename
elfcpp::Elf_types
<size
>::Elf_WXword ssize
,
879 elfcpp::STT type
, elfcpp::STB binding
,
880 elfcpp::STV visibility
, unsigned char nonvis
,
881 bool offset_is_from_end
, bool only_if_ref
);
883 // Define a symbol in an Output_segment, sized version.
886 do_define_in_output_segment(
887 Target
*, const char* name
, Output_segment
* os
,
888 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
,
889 typename
elfcpp::Elf_types
<size
>::Elf_WXword ssize
,
890 elfcpp::STT type
, elfcpp::STB binding
,
891 elfcpp::STV visibility
, unsigned char nonvis
,
892 Symbol::Segment_offset_base offset_base
, bool only_if_ref
);
894 // Define a symbol as a constant, sized version.
897 do_define_as_constant(
898 Target
*, const char* name
,
899 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
,
900 typename
elfcpp::Elf_types
<size
>::Elf_WXword ssize
,
901 elfcpp::STT type
, elfcpp::STB binding
,
902 elfcpp::STV visibility
, unsigned char nonvis
,
905 // Allocate the common symbols, sized version.
908 do_allocate_commons(const General_options
&, Layout
*);
910 // Finalize symbols specialized for size.
913 sized_finalize(unsigned int, off_t
, Stringpool
*);
915 // Write globals specialized for size and endianness.
916 template<int size
, bool big_endian
>
918 sized_write_globals(const Target
*, const Stringpool
*, Output_file
*) const;
920 // Write out a section symbol, specialized for size and endianness.
921 template<int size
, bool big_endian
>
923 sized_write_section_symbol(const Output_section
*, Output_file
*, off_t
) const;
925 // The type of the symbol hash table.
927 typedef std::pair
<Stringpool::Key
, Stringpool::Key
> Symbol_table_key
;
929 struct Symbol_table_hash
932 operator()(const Symbol_table_key
&) const;
935 struct Symbol_table_eq
938 operator()(const Symbol_table_key
&, const Symbol_table_key
&) const;
941 typedef Unordered_map
<Symbol_table_key
, Symbol
*, Symbol_table_hash
,
942 Symbol_table_eq
> Symbol_table_type
;
944 // The type of the list of common symbols.
946 typedef std::vector
<Symbol
*> Commons_type
;
948 // The size of the symbols in the symbol table (32 or 64).
951 // We increment this every time we see a new undefined symbol, for
952 // use in archive groups.
955 // The index of the first global symbol in the output file.
956 unsigned int first_global_index_
;
958 // The file offset within the output symtab section where we should
962 // The number of global symbols we want to write out.
963 size_t output_count_
;
965 // The symbol hash table.
966 Symbol_table_type table_
;
968 // A pool of symbol names. This is used for all global symbols.
969 // Entries in the hash table point into this pool.
970 Stringpool namepool_
;
972 // Forwarding symbols.
973 Unordered_map
<const Symbol
*, Symbol
*> forwarders_
;
975 // We don't expect there to be very many common symbols, so we keep
976 // a list of them. When we find a common symbol we add it to this
977 // list. It is possible that by the time we process the list the
978 // symbol is no longer a common symbol. It may also have become a
980 Commons_type commons_
;
982 // Manage symbol warnings.
986 // We inline get_sized_symbol for efficiency.
990 Symbol_table::get_sized_symbol(Symbol
* sym ACCEPT_SIZE
) const
992 gold_assert(size
== this->get_size());
993 return static_cast<Sized_symbol
<size
>*>(sym
);
997 const Sized_symbol
<size
>*
998 Symbol_table::get_sized_symbol(const Symbol
* sym ACCEPT_SIZE
) const
1000 gold_assert(size
== this->get_size());
1001 return static_cast<const Sized_symbol
<size
>*>(sym
);
1004 } // End namespace gold.
1006 #endif // !defined(GOLD_SYMTAB_H)