diff options
author | Ian Lance Taylor <iant@google.com> | 2006-08-04 23:10:59 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2006-08-04 23:10:59 +0000 |
commit | bae7f79e03d6405f5ceec0e3e24671e6b30f29ed (patch) | |
tree | 4b9df8c6433411b45963dd75e3a6dcad9a22518e /gold/symtab.h | |
parent | c17d87de17351aed016a9d0b0712cdee4cca5f9e (diff) | |
download | gdb-bae7f79e03d6405f5ceec0e3e24671e6b30f29ed.zip gdb-bae7f79e03d6405f5ceec0e3e24671e6b30f29ed.tar.gz gdb-bae7f79e03d6405f5ceec0e3e24671e6b30f29ed.tar.bz2 |
Initial CVS checkin of gold
Diffstat (limited to 'gold/symtab.h')
-rw-r--r-- | gold/symtab.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/gold/symtab.h b/gold/symtab.h new file mode 100644 index 0000000..1495fb1 --- /dev/null +++ b/gold/symtab.h @@ -0,0 +1,80 @@ +// symtab.h -- the gold symbol table -*- C++ -*- + +// Symbol_table +// The symbol table. + +#include "gold.h" + +#include <string> +#include <utility> + +#include "elfcpp.h" +#include "targetsize.h" +#include "object.h" +#include "workqueue.h" + +#ifndef GOLD_SYMTAB_H +#define GOLD_SYMTAB_H + +namespace gold +{ + +// An entry in the symbol table. The symbol table can have a lot of +// entries, so we don't want this class to get too big. + +template<int size> +class Symbol +{ + public: + typedef typename elfcpp::Elf_types<size>::Elf_Addr Value; + typedef typename Size_types<size>::Unsigned_type Size; + + private: + // Every symbol has a unique name, more or less, so we use + // std::string for the name. There are only a few versions in a + // given link, so for them we point into a pool. + std::string name_; + const char* version_; + Object* object_; + unsigned int shnum_; + Value value_; + Size size_; + elfcpp::STT type_ : 4; + elfcpp::STB binding_ : 4; + elfcpp:STV visibility_ : 2; + unsigned int other_ : 6; +}; + +// The main linker symbol table. + +template<int size> +class Symbol_table +{ + public: + Symbol_table(); + + // Return a pointer to a symbol specified by name. + Symbol* + lookup(const std::string& name) const; + + // Return a pointer to a symbol specified by name plus version. + Symbol* + lookup(const std::string& name, const char* version) const; + + Task_token& + token() const + { return this->token_; } + + private: + Symbol_table(const Symbol_table&); + Symbol_table& operator=(const Symbol_table&); + + typedef std::pair<std::string, std::string> Symbol_table_key; + + Unordered_map<Symbol_table_key, Symbol<size>*> table_; + Task_token token_; +}; + +} // End namespace gold. + +#endif // !defined(GOLD_SYMTAB_H) |