Commit | Line | Data |
---|---|---|
bae7f79e ILT |
1 | // symtab.h -- the gold symbol table -*- C++ -*- |
2 | ||
3 | // Symbol_table | |
4 | // The symbol table. | |
5 | ||
6 | #include "gold.h" | |
7 | ||
8 | #include <string> | |
9 | #include <utility> | |
10 | ||
11 | #include "elfcpp.h" | |
12 | #include "targetsize.h" | |
13 | #include "object.h" | |
14 | #include "workqueue.h" | |
15 | ||
16 | #ifndef GOLD_SYMTAB_H | |
17 | #define GOLD_SYMTAB_H | |
18 | ||
19 | namespace gold | |
20 | { | |
21 | ||
22 | // An entry in the symbol table. The symbol table can have a lot of | |
23 | // entries, so we don't want this class to get too big. | |
24 | ||
25 | template<int size> | |
26 | class Symbol | |
27 | { | |
28 | public: | |
29 | typedef typename elfcpp::Elf_types<size>::Elf_Addr Value; | |
30 | typedef typename Size_types<size>::Unsigned_type Size; | |
31 | ||
32 | private: | |
33 | // Every symbol has a unique name, more or less, so we use | |
34 | // std::string for the name. There are only a few versions in a | |
35 | // given link, so for them we point into a pool. | |
36 | std::string name_; | |
37 | const char* version_; | |
38 | Object* object_; | |
39 | unsigned int shnum_; | |
40 | Value value_; | |
41 | Size size_; | |
42 | elfcpp::STT type_ : 4; | |
43 | elfcpp::STB binding_ : 4; | |
44 | elfcpp:STV visibility_ : 2; | |
45 | unsigned int other_ : 6; | |
46 | }; | |
47 | ||
48 | // The main linker symbol table. | |
49 | ||
50 | template<int size> | |
51 | class Symbol_table | |
52 | { | |
53 | public: | |
54 | Symbol_table(); | |
55 | ||
56 | // Return a pointer to a symbol specified by name. | |
57 | Symbol* | |
58 | lookup(const std::string& name) const; | |
59 | ||
60 | // Return a pointer to a symbol specified by name plus version. | |
61 | Symbol* | |
62 | lookup(const std::string& name, const char* version) const; | |
63 | ||
64 | Task_token& | |
65 | token() const | |
66 | { return this->token_; } | |
67 | ||
68 | private: | |
69 | Symbol_table(const Symbol_table&); | |
70 | Symbol_table& operator=(const Symbol_table&); | |
71 | ||
72 | typedef std::pair<std::string, std::string> Symbol_table_key; | |
73 | ||
74 | Unordered_map<Symbol_table_key, Symbol<size>*> table_; | |
75 | Task_token token_; | |
76 | }; | |
77 | ||
78 | } // End namespace gold. | |
79 | ||
80 | #endif // !defined(GOLD_SYMTAB_H) |