1 // symtab.h -- the gold symbol table -*- C++ -*-
11 #include "parameters.h"
12 #include "stringpool.h"
23 template<int size
, bool big_endian
>
26 template<int size
, bool big_endian
>
35 // The base class of an entry in the symbol table. The symbol table
36 // can have a lot of entries, so we don't want this class to big.
37 // Size dependent fields can be found in the template class
38 // Sized_symbol. Targets may support their own derived classes.
43 // Because we want the class to be small, we don't use any virtual
44 // functions. But because symbols can be defined in different
45 // places, we need to classify them. This enum is the different
46 // sources of symbols we support.
49 // Symbol defined in a relocatable or dynamic input file--this is
50 // the most common case.
52 // Symbol defined in an Output_data, a special section created by
55 // Symbol defined in an Output_segment, with no associated
58 // Symbol value is constant.
62 // When the source is IN_OUTPUT_SEGMENT, we need to describe what
64 enum Segment_offset_base
66 // From the start of the segment.
68 // From the end of the segment.
70 // From the filesz of the segment--i.e., after the loaded bytes
71 // but before the bytes which are allocated but zeroed.
75 // Return the symbol name.
78 { return this->name_
; }
80 // Return the symbol version. This will return NULL for an
81 // unversioned symbol.
84 { return this->version_
; }
86 // Return the symbol source.
89 { return this->source_
; }
91 // Return the object with which this symbol is associated.
95 gold_assert(this->source_
== FROM_OBJECT
);
96 return this->u_
.from_object
.object
;
99 // Return the index of the section in the input relocatable or
100 // dynamic object file.
104 gold_assert(this->source_
== FROM_OBJECT
);
105 return this->u_
.from_object
.shndx
;
108 // Return the output data section with which this symbol is
109 // associated, if the symbol was specially defined with respect to
110 // an output data section.
114 gold_assert(this->source_
== IN_OUTPUT_DATA
);
115 return this->u_
.in_output_data
.output_data
;
118 // If this symbol was defined with respect to an output data
119 // section, return whether the value is an offset from end.
121 offset_is_from_end() const
123 gold_assert(this->source_
== IN_OUTPUT_DATA
);
124 return this->u_
.in_output_data
.offset_is_from_end
;
127 // Return the output segment with which this symbol is associated,
128 // if the symbol was specially defined with respect to an output
131 output_segment() const
133 gold_assert(this->source_
== IN_OUTPUT_SEGMENT
);
134 return this->u_
.in_output_segment
.output_segment
;
137 // If this symbol was defined with respect to an output segment,
138 // return the offset base.
142 gold_assert(this->source_
== IN_OUTPUT_SEGMENT
);
143 return this->u_
.in_output_segment
.offset_base
;
146 // Return the symbol binding.
149 { return this->binding_
; }
151 // Return the symbol type.
154 { return this->type_
; }
156 // Return the symbol visibility.
159 { return this->visibility_
; }
161 // Return the non-visibility part of the st_other field.
164 { return this->nonvis_
; }
166 // Return whether this symbol is a forwarder. This will never be
167 // true of a symbol found in the hash table, but may be true of
168 // symbol pointers attached to object files.
171 { return this->is_forwarder_
; }
173 // Mark this symbol as a forwarder.
176 { this->is_forwarder_
= true; }
178 // Return whether this symbol needs an entry in the dynamic symbol
181 needs_dynsym_entry() const
183 return (this->needs_dynsym_entry_
184 || (this->in_reg() && this->in_dyn()));
187 // Mark this symbol as needing an entry in the dynamic symbol table.
189 set_needs_dynsym_entry()
190 { this->needs_dynsym_entry_
= true; }
192 // Return whether this symbol has been seen in a regular object.
195 { return this->in_reg_
; }
197 // Mark this symbol as having been seen in a regular object.
200 { this->in_reg_
= true; }
202 // Return whether this symbol has been seen in a dynamic object.
205 { return this->in_dyn_
; }
207 // Mark this symbol as having been seen in a dynamic object.
210 { this->in_dyn_
= true; }
212 // Return the index of this symbol in the output file symbol table.
213 // A value of -1U means that this symbol is not going into the
214 // output file. This starts out as zero, and is set to a non-zero
215 // value by Symbol_table::finalize. It is an error to ask for the
216 // symbol table index before it has been set.
220 gold_assert(this->symtab_index_
!= 0);
221 return this->symtab_index_
;
224 // Set the index of the symbol in the output file symbol table.
226 set_symtab_index(unsigned int index
)
228 gold_assert(index
!= 0);
229 this->symtab_index_
= index
;
232 // Return whether this symbol already has an index in the output
233 // file symbol table.
235 has_symtab_index() const
236 { return this->symtab_index_
!= 0; }
238 // Return the index of this symbol in the dynamic symbol table. A
239 // value of -1U means that this symbol is not going into the dynamic
240 // symbol table. This starts out as zero, and is set to a non-zero
241 // during Layout::finalize. It is an error to ask for the dynamic
242 // symbol table index before it has been set.
246 gold_assert(this->dynsym_index_
!= 0);
247 return this->dynsym_index_
;
250 // Set the index of the symbol in the dynamic symbol table.
252 set_dynsym_index(unsigned int index
)
254 gold_assert(index
!= 0);
255 this->dynsym_index_
= index
;
258 // Return whether this symbol already has an index in the dynamic
261 has_dynsym_index() const
262 { return this->dynsym_index_
!= 0; }
264 // Return whether this symbol has an entry in the GOT section.
266 has_got_offset() const
267 { return this->has_got_offset_
; }
269 // Return the offset into the GOT section of this symbol.
273 gold_assert(this->has_got_offset());
274 return this->got_offset_
;
277 // Set the GOT offset of this symbol.
279 set_got_offset(unsigned int got_offset
)
281 this->has_got_offset_
= true;
282 this->got_offset_
= got_offset
;
285 // Return whether this symbol has an entry in the PLT section.
287 has_plt_offset() const
288 { return this->has_plt_offset_
; }
290 // Return the offset into the PLT section of this symbol.
294 gold_assert(this->has_plt_offset());
295 return this->plt_offset_
;
298 // Set the PLT offset of this symbol.
300 set_plt_offset(unsigned int plt_offset
)
302 this->has_plt_offset_
= true;
303 this->plt_offset_
= plt_offset
;
306 // Return true if the final value of this symbol is known at link
309 final_value_is_known() const
311 if (parameters
->output_is_shared())
313 return this->source_
!= FROM_OBJECT
|| !this->object()->is_dynamic();
316 // Return whether this is a defined symbol (not undefined or
321 return (this->source_
!= FROM_OBJECT
322 || (this->shndx() != elfcpp::SHN_UNDEF
323 && this->shndx() != elfcpp::SHN_COMMON
));
326 // Return true if this symbol is from a dynamic object.
328 is_from_dynobj() const
330 return this->source_
== FROM_OBJECT
&& this->object()->is_dynamic();
333 // Return whether this is an undefined symbol.
337 return this->source_
== FROM_OBJECT
&& this->shndx() == elfcpp::SHN_UNDEF
;
340 // Return whether this is a common symbol.
344 return (this->source_
== FROM_OBJECT
345 && (this->shndx() == elfcpp::SHN_COMMON
346 || this->type_
== elfcpp::STT_COMMON
));
349 // Return whether this symbol can be seen outside this object.
351 is_externally_visible() const
353 return (this->visibility_
== elfcpp::STV_DEFAULT
354 || this->visibility_
== elfcpp::STV_PROTECTED
);
357 // Return whether there should be a warning for references to this
361 { return this->has_warning_
; }
363 // Mark this symbol as having a warning.
366 { this->has_warning_
= true; }
369 // Instances of this class should always be created at a specific
372 { memset(this, 0, sizeof *this); }
374 // Initialize the general fields.
376 init_fields(const char* name
, const char* version
,
377 elfcpp::STT type
, elfcpp::STB binding
,
378 elfcpp::STV visibility
, unsigned char nonvis
);
380 // Initialize fields from an ELF symbol in OBJECT.
381 template<int size
, bool big_endian
>
383 init_base(const char *name
, const char* version
, Object
* object
,
384 const elfcpp::Sym
<size
, big_endian
>&);
386 // Initialize fields for an Output_data.
388 init_base(const char* name
, Output_data
*, elfcpp::STT
, elfcpp::STB
,
389 elfcpp::STV
, unsigned char nonvis
, bool offset_is_from_end
);
391 // Initialize fields for an Output_segment.
393 init_base(const char* name
, Output_segment
* os
, elfcpp::STT type
,
394 elfcpp::STB binding
, elfcpp::STV visibility
,
395 unsigned char nonvis
, Segment_offset_base offset_base
);
397 // Initialize fields for a constant.
399 init_base(const char* name
, elfcpp::STT type
, elfcpp::STB binding
,
400 elfcpp::STV visibility
, unsigned char nonvis
);
402 // Override existing symbol.
403 template<int size
, bool big_endian
>
405 override_base(const elfcpp::Sym
<size
, big_endian
>&, Object
* object
,
406 const char* version
);
408 // Override existing symbol with a special symbol.
410 override_base_with_special(const Symbol
* from
);
413 Symbol(const Symbol
&);
414 Symbol
& operator=(const Symbol
&);
416 // Symbol name (expected to point into a Stringpool).
418 // Symbol version (expected to point into a Stringpool). This may
420 const char* version_
;
424 // This struct is used if SOURCE_ == FROM_OBJECT.
427 // Object in which symbol is defined, or in which it was first
430 // Section number in object_ in which symbol is defined.
434 // This struct is used if SOURCE_ == IN_OUTPUT_DATA.
437 // Output_data in which symbol is defined. Before
438 // Layout::finalize the symbol's value is an offset within the
440 Output_data
* output_data
;
441 // True if the offset is from the end, false if the offset is
442 // from the beginning.
443 bool offset_is_from_end
;
446 // This struct is used if SOURCE_ == IN_OUTPUT_SEGMENT.
449 // Output_segment in which the symbol is defined. Before
450 // Layout::finalize the symbol's value is an offset.
451 Output_segment
* output_segment
;
452 // The base to use for the offset before Layout::finalize.
453 Segment_offset_base offset_base
;
457 // The index of this symbol in the output file. If the symbol is
458 // not going into the output file, this value is -1U. This field
459 // starts as always holding zero. It is set to a non-zero value by
460 // Symbol_table::finalize.
461 unsigned int symtab_index_
;
463 // The index of this symbol in the dynamic symbol table. If the
464 // symbol is not going into the dynamic symbol table, this value is
465 // -1U. This field starts as always holding zero. It is set to a
466 // non-zero value during Layout::finalize.
467 unsigned int dynsym_index_
;
469 // If this symbol has an entry in the GOT section (has_got_offset_
470 // is true), this is the offset from the start of the GOT section.
471 unsigned int got_offset_
;
473 // If this symbol has an entry in the PLT section (has_plt_offset_
474 // is true), then this is the offset from the start of the PLT
476 unsigned int plt_offset_
;
479 elfcpp::STT type_
: 4;
481 elfcpp::STB binding_
: 4;
482 // Symbol visibility.
483 elfcpp::STV visibility_
: 2;
484 // Rest of symbol st_other field.
485 unsigned int nonvis_
: 6;
486 // The type of symbol.
488 // True if this symbol always requires special target-specific
490 bool is_target_special_
: 1;
491 // True if this is the default version of the symbol.
493 // True if this symbol really forwards to another symbol. This is
494 // used when we discover after the fact that two different entries
495 // in the hash table really refer to the same symbol. This will
496 // never be set for a symbol found in the hash table, but may be set
497 // for a symbol found in the list of symbols attached to an Object.
498 // It forwards to the symbol found in the forwarders_ map of
500 bool is_forwarder_
: 1;
501 // True if this symbol needs to be in the dynamic symbol table.
502 bool needs_dynsym_entry_
: 1;
503 // True if we've seen this symbol in a regular object.
505 // True if we've seen this symbol in a dynamic object.
507 // True if the symbol has an entry in the GOT section.
508 bool has_got_offset_
: 1;
509 // True if the symbol has an entry in the PLT section.
510 bool has_plt_offset_
: 1;
511 // True if there is a warning for this symbol.
512 bool has_warning_
: 1;
515 // The parts of a symbol which are size specific. Using a template
516 // derived class like this helps us use less space on a 32-bit system.
519 class Sized_symbol
: public Symbol
522 typedef typename
elfcpp::Elf_types
<size
>::Elf_Addr Value_type
;
523 typedef typename
elfcpp::Elf_types
<size
>::Elf_WXword Size_type
;
528 // Initialize fields from an ELF symbol in OBJECT.
529 template<bool big_endian
>
531 init(const char *name
, const char* version
, Object
* object
,
532 const elfcpp::Sym
<size
, big_endian
>&);
534 // Initialize fields for an Output_data.
536 init(const char* name
, Output_data
*, Value_type value
, Size_type symsize
,
537 elfcpp::STT
, elfcpp::STB
, elfcpp::STV
, unsigned char nonvis
,
538 bool offset_is_from_end
);
540 // Initialize fields for an Output_segment.
542 init(const char* name
, Output_segment
*, Value_type value
, Size_type symsize
,
543 elfcpp::STT
, elfcpp::STB
, elfcpp::STV
, unsigned char nonvis
,
544 Segment_offset_base offset_base
);
546 // Initialize fields for a constant.
548 init(const char* name
, Value_type value
, Size_type symsize
,
549 elfcpp::STT
, elfcpp::STB
, elfcpp::STV
, unsigned char nonvis
);
551 // Override existing symbol.
552 template<bool big_endian
>
554 override(const elfcpp::Sym
<size
, big_endian
>&, Object
* object
,
555 const char* version
);
557 // Override existing symbol with a special symbol.
559 override_with_special(const Sized_symbol
<size
>*);
561 // Return the symbol's value.
564 { return this->value_
; }
566 // Return the symbol's size (we can't call this 'size' because that
567 // is a template parameter).
570 { return this->symsize_
; }
572 // Set the symbol size. This is used when resolving common symbols.
574 set_symsize(Size_type symsize
)
575 { this->symsize_
= symsize
; }
577 // Set the symbol value. This is called when we store the final
578 // values of the symbols into the symbol table.
580 set_value(Value_type value
)
581 { this->value_
= value
; }
584 Sized_symbol(const Sized_symbol
&);
585 Sized_symbol
& operator=(const Sized_symbol
&);
587 // Symbol value. Before Layout::finalize this is the offset in the
588 // input section. This is set to the final value during
595 // A struct describing a symbol defined by the linker, where the value
596 // of the symbol is defined based on an output section. This is used
597 // for symbols defined by the linker, like "_init_array_start".
599 struct Define_symbol_in_section
603 // The name of the output section with which this symbol should be
604 // associated. If there is no output section with that name, the
605 // symbol will be defined as zero.
606 const char* output_section
;
607 // The offset of the symbol within the output section. This is an
608 // offset from the start of the output section, unless start_at_end
609 // is true, in which case this is an offset from the end of the
612 // The size of the symbol.
616 // The symbol binding.
618 // The symbol visibility.
619 elfcpp::STV visibility
;
620 // The rest of the st_other field.
621 unsigned char nonvis
;
622 // If true, the value field is an offset from the end of the output
624 bool offset_is_from_end
;
625 // If true, this symbol is defined only if we see a reference to it.
629 // A struct describing a symbol defined by the linker, where the value
630 // of the symbol is defined based on a segment. This is used for
631 // symbols defined by the linker, like "_end". We describe the
632 // segment with which the symbol should be associated by its
633 // characteristics. If no segment meets these characteristics, the
634 // symbol will be defined as zero. If there is more than one segment
635 // which meets these characteristics, we will use the first one.
637 struct Define_symbol_in_segment
641 // The segment type where the symbol should be defined, typically
643 elfcpp::PT segment_type
;
644 // Bitmask of segment flags which must be set.
645 elfcpp::PF segment_flags_set
;
646 // Bitmask of segment flags which must be clear.
647 elfcpp::PF segment_flags_clear
;
648 // The offset of the symbol within the segment. The offset is
649 // calculated from the position set by offset_base.
651 // The size of the symbol.
655 // The symbol binding.
657 // The symbol visibility.
658 elfcpp::STV visibility
;
659 // The rest of the st_other field.
660 unsigned char nonvis
;
661 // The base from which we compute the offset.
662 Symbol::Segment_offset_base offset_base
;
663 // If true, this symbol is defined only if we see a reference to it.
667 // This class manages warnings. Warnings are a GNU extension. When
668 // we see a section named .gnu.warning.SYM in an object file, and if
669 // we wind using the definition of SYM from that object file, then we
670 // will issue a warning for any relocation against SYM from a
671 // different object file. The text of the warning is the contents of
672 // the section. This is not precisely the definition used by the old
673 // GNU linker; the old GNU linker treated an occurrence of
674 // .gnu.warning.SYM as defining a warning symbol. A warning symbol
675 // would trigger a warning on any reference. However, it was
676 // inconsistent in that a warning in a dynamic object only triggered
677 // if there was no definition in a regular object. This linker is
678 // different in that we only issue a warning if we use the symbol
679 // definition from the same object file as the warning section.
688 // Add a warning for symbol NAME in section SHNDX in object OBJ.
690 add_warning(Symbol_table
* symtab
, const char* name
, Object
* obj
,
693 // For each symbol for which we should give a warning, make a note
696 note_warnings(Symbol_table
* symtab
);
698 // Issue a warning for a reference to SYM at LOCATION.
700 issue_warning(const Symbol
* sym
, const std::string
& location
) const;
703 Warnings(const Warnings
&);
704 Warnings
& operator=(const Warnings
&);
706 // What we need to know to get the warning text.
707 struct Warning_location
709 // The object the warning is in.
711 // The index of the warning section.
713 // The warning text if we have already loaded it.
717 : object(NULL
), shndx(0), text()
721 set(Object
* o
, unsigned int s
)
728 set_text(const char* t
, off_t l
)
729 { this->text
.assign(t
, l
); }
732 // A mapping from warning symbol names (canonicalized in
733 // Symbol_table's namepool_ field) to
734 typedef Unordered_map
<const char*, Warning_location
> Warning_table
;
736 Warning_table warnings_
;
739 // The main linker symbol table.
748 // Add COUNT external symbols from the relocatable object RELOBJ to
749 // the symbol table. SYMS is the symbols, SYM_NAMES is their names,
750 // SYM_NAME_SIZE is the size of SYM_NAMES. This sets SYMPOINTERS to
751 // point to the symbols in the symbol table.
752 template<int size
, bool big_endian
>
754 add_from_relobj(Sized_relobj
<size
, big_endian
>* relobj
,
755 const unsigned char* syms
, size_t count
,
756 const char* sym_names
, size_t sym_name_size
,
757 Symbol
** sympointers
);
759 // Add COUNT dynamic symbols from the dynamic object DYNOBJ to the
760 // symbol table. SYMS is the symbols. SYM_NAMES is their names.
761 // SYM_NAME_SIZE is the size of SYM_NAMES. The other parameters are
762 // symbol version data.
763 template<int size
, bool big_endian
>
765 add_from_dynobj(Sized_dynobj
<size
, big_endian
>* dynobj
,
766 const unsigned char* syms
, size_t count
,
767 const char* sym_names
, size_t sym_name_size
,
768 const unsigned char* versym
, size_t versym_size
,
769 const std::vector
<const char*>*);
771 // Define a special symbol based on an Output_data. It is a
772 // multiple definition error if this symbol is already defined.
774 define_in_output_data(const Target
*, const char* name
, const char* version
,
775 Output_data
*, uint64_t value
, uint64_t symsize
,
776 elfcpp::STT type
, elfcpp::STB binding
,
777 elfcpp::STV visibility
, unsigned char nonvis
,
778 bool offset_is_from_end
, bool only_if_ref
);
780 // Define a special symbol based on an Output_segment. It is a
781 // multiple definition error if this symbol is already defined.
783 define_in_output_segment(const Target
*, const char* name
,
784 const char* version
, Output_segment
*,
785 uint64_t value
, uint64_t symsize
,
786 elfcpp::STT type
, elfcpp::STB binding
,
787 elfcpp::STV visibility
, unsigned char nonvis
,
788 Symbol::Segment_offset_base
, bool only_if_ref
);
790 // Define a special symbol with a constant value. It is a multiple
791 // definition error if this symbol is already defined.
793 define_as_constant(const Target
*, const char* name
, const char* version
,
794 uint64_t value
, uint64_t symsize
, elfcpp::STT type
,
795 elfcpp::STB binding
, elfcpp::STV visibility
,
796 unsigned char nonvis
, bool only_if_ref
);
798 // Define a set of symbols in output sections.
800 define_symbols(const Layout
*, const Target
*, int count
,
801 const Define_symbol_in_section
*);
803 // Define a set of symbols in output segments.
805 define_symbols(const Layout
*, const Target
*, int count
,
806 const Define_symbol_in_segment
*);
810 lookup(const char*, const char* version
= NULL
) const;
812 // Return the real symbol associated with the forwarder symbol FROM.
814 resolve_forwards(const Symbol
* from
) const;
816 // Return the bitsize (32 or 64) of the symbols in the table.
819 { return this->size_
; }
821 // Return the sized version of a symbol in this table.
824 get_sized_symbol(Symbol
* ACCEPT_SIZE
) const;
827 const Sized_symbol
<size
>*
828 get_sized_symbol(const Symbol
* ACCEPT_SIZE
) const;
830 // Return the count of undefined symbols seen.
832 saw_undefined() const
833 { return this->saw_undefined_
; }
835 // Allocate the common symbols
837 allocate_commons(const General_options
&, Layout
*);
839 // Add a warning for symbol NAME in section SHNDX in object OBJ.
841 add_warning(const char* name
, Object
* obj
, unsigned int shndx
)
842 { this->warnings_
.add_warning(this, name
, obj
, shndx
); }
844 // Canonicalize a symbol name for use in the hash table.
846 canonicalize_name(const char* name
)
847 { return this->namepool_
.add(name
, NULL
); }
849 // Possibly issue a warning for a reference to SYM at LOCATION which
852 issue_warning(const Symbol
* sym
, const std::string
& location
) const
853 { this->warnings_
.issue_warning(sym
, location
); }
855 // Set the dynamic symbol indexes. INDEX is the index of the first
856 // global dynamic symbol. Pointers to the symbols are stored into
857 // the vector. The names are stored into the Stringpool. This
858 // returns an updated dynamic symbol index.
860 set_dynsym_indexes(const General_options
*, const Target
*, unsigned int index
,
861 std::vector
<Symbol
*>*, Stringpool
*, Versions
*);
863 // Finalize the symbol table after we have set the final addresses
864 // of all the input sections. This sets the final symbol indexes,
865 // values and adds the names to *POOL. INDEX is the index of the
866 // first global symbol. OFF is the file offset of the global symbol
867 // table, DYNOFF is the offset of the globals in the dynamic symbol
868 // table, DYN_GLOBAL_INDEX is the index of the first global dynamic
869 // symbol, and DYNCOUNT is the number of global dynamic symbols.
870 // This records the parameters, and returns the new file offset.
872 finalize(unsigned int index
, off_t off
, off_t dynoff
,
873 size_t dyn_global_index
, size_t dyncount
, Stringpool
* pool
);
875 // Write out the global symbols.
877 write_globals(const Target
*, const Stringpool
*, const Stringpool
*,
880 // Write out a section symbol. Return the updated offset.
882 write_section_symbol(const Target
*, const Output_section
*, Output_file
*,
886 Symbol_table(const Symbol_table
&);
887 Symbol_table
& operator=(const Symbol_table
&);
889 // Set the size (32 or 64) of the symbols in the table.
892 { this->size_
= size
; }
894 // Make FROM a forwarder symbol to TO.
896 make_forwarder(Symbol
* from
, Symbol
* to
);
899 template<int size
, bool big_endian
>
901 add_from_object(Object
*, const char *name
, Stringpool::Key name_key
,
902 const char *version
, Stringpool::Key version_key
,
903 bool def
, const elfcpp::Sym
<size
, big_endian
>& sym
);
906 template<int size
, bool big_endian
>
908 resolve(Sized_symbol
<size
>* to
,
909 const elfcpp::Sym
<size
, big_endian
>& sym
,
910 Object
*, const char* version
);
912 template<int size
, bool big_endian
>
914 resolve(Sized_symbol
<size
>* to
, const Sized_symbol
<size
>* from
,
915 const char* version ACCEPT_SIZE_ENDIAN
);
917 // Whether we should override a symbol, based on flags in
920 should_override(const Symbol
*, unsigned int, bool*);
922 // Whether we should override a symbol with a special symbol which
923 // is automatically defined by the linker.
925 should_override_with_special(const Symbol
*);
927 // Define a special symbol.
928 template<int size
, bool big_endian
>
930 define_special_symbol(const Target
* target
, const char* name
,
931 const char* version
, bool only_if_ref
,
932 Sized_symbol
<size
>** poldsym ACCEPT_SIZE_ENDIAN
);
934 // Define a symbol in an Output_data, sized version.
937 do_define_in_output_data(const Target
*, const char* name
,
938 const char* version
, Output_data
*,
939 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
,
940 typename
elfcpp::Elf_types
<size
>::Elf_WXword ssize
,
941 elfcpp::STT type
, elfcpp::STB binding
,
942 elfcpp::STV visibility
, unsigned char nonvis
,
943 bool offset_is_from_end
, bool only_if_ref
);
945 // Define a symbol in an Output_segment, sized version.
948 do_define_in_output_segment(
949 const Target
*, const char* name
, const char* version
, Output_segment
* os
,
950 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
,
951 typename
elfcpp::Elf_types
<size
>::Elf_WXword ssize
,
952 elfcpp::STT type
, elfcpp::STB binding
,
953 elfcpp::STV visibility
, unsigned char nonvis
,
954 Symbol::Segment_offset_base offset_base
, bool only_if_ref
);
956 // Define a symbol as a constant, sized version.
959 do_define_as_constant(
960 const Target
*, const char* name
, const char* version
,
961 typename
elfcpp::Elf_types
<size
>::Elf_Addr value
,
962 typename
elfcpp::Elf_types
<size
>::Elf_WXword ssize
,
963 elfcpp::STT type
, elfcpp::STB binding
,
964 elfcpp::STV visibility
, unsigned char nonvis
,
967 // Allocate the common symbols, sized version.
970 do_allocate_commons(const General_options
&, Layout
*);
972 // Finalize symbols specialized for size.
975 sized_finalize(unsigned int, off_t
, Stringpool
*);
977 // Write globals specialized for size and endianness.
978 template<int size
, bool big_endian
>
980 sized_write_globals(const Target
*, const Stringpool
*, const Stringpool
*,
983 // Write out a symbol to P.
984 template<int size
, bool big_endian
>
986 sized_write_symbol(Sized_symbol
<size
>*, unsigned int shndx
,
987 const Stringpool
*, unsigned char* p
988 ACCEPT_SIZE_ENDIAN
) const;
990 // Write out a section symbol, specialized for size and endianness.
991 template<int size
, bool big_endian
>
993 sized_write_section_symbol(const Output_section
*, Output_file
*, off_t
) const;
995 // The type of the symbol hash table.
997 typedef std::pair
<Stringpool::Key
, Stringpool::Key
> Symbol_table_key
;
999 struct Symbol_table_hash
1002 operator()(const Symbol_table_key
&) const;
1005 struct Symbol_table_eq
1008 operator()(const Symbol_table_key
&, const Symbol_table_key
&) const;
1011 typedef Unordered_map
<Symbol_table_key
, Symbol
*, Symbol_table_hash
,
1012 Symbol_table_eq
> Symbol_table_type
;
1014 // The type of the list of common symbols.
1016 typedef std::vector
<Symbol
*> Commons_type
;
1018 // The size of the symbols in the symbol table (32 or 64).
1021 // We increment this every time we see a new undefined symbol, for
1022 // use in archive groups.
1025 // The index of the first global symbol in the output file.
1026 unsigned int first_global_index_
;
1028 // The file offset within the output symtab section where we should
1032 // The number of global symbols we want to write out.
1033 size_t output_count_
;
1035 // The file offset of the global dynamic symbols, or 0 if none.
1036 off_t dynamic_offset_
;
1038 // The index of the first global dynamic symbol.
1039 unsigned int first_dynamic_global_index_
;
1041 // The number of global dynamic symbols, or 0 if none.
1042 off_t dynamic_count_
;
1044 // The symbol hash table.
1045 Symbol_table_type table_
;
1047 // A pool of symbol names. This is used for all global symbols.
1048 // Entries in the hash table point into this pool.
1049 Stringpool namepool_
;
1051 // Forwarding symbols.
1052 Unordered_map
<const Symbol
*, Symbol
*> forwarders_
;
1054 // We don't expect there to be very many common symbols, so we keep
1055 // a list of them. When we find a common symbol we add it to this
1056 // list. It is possible that by the time we process the list the
1057 // symbol is no longer a common symbol. It may also have become a
1059 Commons_type commons_
;
1061 // Manage symbol warnings.
1065 // We inline get_sized_symbol for efficiency.
1069 Symbol_table::get_sized_symbol(Symbol
* sym ACCEPT_SIZE
) const
1071 gold_assert(size
== this->get_size());
1072 return static_cast<Sized_symbol
<size
>*>(sym
);
1076 const Sized_symbol
<size
>*
1077 Symbol_table::get_sized_symbol(const Symbol
* sym ACCEPT_SIZE
) const
1079 gold_assert(size
== this->get_size());
1080 return static_cast<const Sized_symbol
<size
>*>(sym
);
1083 } // End namespace gold.
1085 #endif // !defined(GOLD_SYMTAB_H)