1 // symtab.h -- the gold symbol table -*- C++ -*-
10 #include "targetsize.h"
11 #include "stringpool.h"
21 template<int size
, bool big_endian
>
24 template<int size
, bool big_endian
>
27 // The base class of an entry in the symbol table. The symbol table
28 // can have a lot of entries, so we don't want this class to big.
29 // Size dependent fields can be found in the template class
30 // Sized_symbol. Targets may support their own derived classes.
37 // Return the symbol name.
40 { return this->name_
; }
42 // Return the symbol version. This will return NULL for an
43 // unversioned symbol.
46 { return this->version_
; }
48 // Return whether this symbol is a forwarder. This will never be
49 // true of a symbol found in the hash table, but may be true of
50 // symbol pointers attached to object files.
53 { return this->forwarder_
; }
55 // Mark this symbol as a forwarder.
58 { this->forwarder_
= true; }
60 // Return the object with which this symbol is associated.
63 { return this->object_
; }
65 // Return the symbol binding.
68 { return this->binding_
; }
70 // Return the section index.
73 { return this->shnum_
; }
76 // Instances of this class should always be created at a specific
81 // Initialize fields from an ELF symbol in OBJECT.
82 template<int size
, bool big_endian
>
84 init_base(const char *name
, const char* version
, Object
* object
,
85 const elfcpp::Sym
<size
, big_endian
>&);
88 Symbol(const Symbol
&);
89 Symbol
& operator=(const Symbol
&);
91 // Symbol name (expected to point into a Stringpool).
93 // Symbol version (expected to point into a Stringpool). This may
96 // Object in which symbol is defined, or in which it was first seen.
98 // Section number in object_ in which symbol is defined.
101 elfcpp::STT type_
: 4;
103 elfcpp::STB binding_
: 4;
104 // Symbol visibility.
105 elfcpp::STV visibility_
: 2;
106 // Rest of symbol st_other field.
107 unsigned int other_
: 6;
108 // True if this symbol always requires special target-specific
111 // True if this is the default version of the symbol.
113 // True if this symbol really forwards to another symbol. This is
114 // used when we discover after the fact that two different entries
115 // in the hash table really refer to the same symbol. This will
116 // never be set for a symbol found in the hash table, but may be set
117 // for a symbol found in the list of symbols attached to an Object.
118 // It forwards to the symbol found in the forwarders_ map of
123 // The parts of a symbol which are size specific. Using a template
124 // derived class like this helps us use less space on a 32-bit system.
127 class Sized_symbol
: public Symbol
133 // Initialize fields from an ELF symbol in OBJECT.
134 template<bool big_endian
>
136 init(const char *name
, const char* version
, Object
* object
,
137 const elfcpp::Sym
<size
, big_endian
>&);
140 Sized_symbol(const Sized_symbol
&);
141 Sized_symbol
& operator=(const Sized_symbol
&);
144 typename
elfcpp::Elf_types
<size
>::Elf_Addr value_
;
146 typename
elfcpp::Elf_types
<size
>::Elf_WXword size_
;
149 // The main linker symbol table.
156 virtual ~Symbol_table();
158 // Add COUNT external symbols from OBJECT to the symbol table. SYMS
159 // is the symbols, SYM_NAMES is their names, SYM_NAME_SIZE is the
160 // size of SYM_NAMES. This sets SYMPOINTERS to point to the symbols
161 // in the symbol table.
162 template<int size
, bool big_endian
>
164 add_from_object(Sized_object
<size
, big_endian
>* object
,
165 const elfcpp::Sym
<size
, big_endian
>* syms
,
166 size_t count
, const char* sym_names
, size_t sym_name_size
,
167 Symbol
** sympointers
);
169 // Return the real symbol associated with the forwarder symbol FROM.
171 resolve_forwards(Symbol
* from
) const;
173 // Return the size of the symbols in the table.
176 { return this->size_
; }
179 Symbol_table(const Symbol_table
&);
180 Symbol_table
& operator=(const Symbol_table
&);
182 // Set the size of the symbols in the table.
185 { this->size_
= size
; }
187 // Make FROM a forwarder symbol to TO.
189 make_forwarder(Symbol
* from
, Symbol
* to
);
192 template<int size
, bool big_endian
>
194 add_from_object(Sized_object
<size
, big_endian
>*, const char *name
,
195 const char *version
, bool def
,
196 const elfcpp::Sym
<size
, big_endian
>& sym
);
199 template<int size
, bool big_endian
>
201 resolve(Symbol
* to
, const elfcpp::Sym
<size
, big_endian
>& sym
, Object
*);
204 resolve(Symbol
* to
, const Symbol
* from
);
206 typedef std::pair
<const char*, const char*> Symbol_table_key
;
208 struct Symbol_table_hash
211 operator()(const Symbol_table_key
&) const;
214 struct Symbol_table_eq
217 operator()(const Symbol_table_key
&, const Symbol_table_key
&) const;
220 typedef Unordered_map
<Symbol_table_key
, Symbol
*, Symbol_table_hash
,
221 Symbol_table_eq
> Symbol_table_type
;
223 // The size of the symbols in the symbol table (32 or 64).
226 // The symbol table itself.
227 Symbol_table_type table_
;
229 // A pool of symbol names.
230 Stringpool namepool_
;
232 // Forwarding symbols.
233 Unordered_map
<Symbol
*, Symbol
*> forwarders_
;
236 } // End namespace gold.
238 #endif // !defined(GOLD_SYMTAB_H)
This page took 0.033927 seconds and 4 git commands to generate.