diff options
author | Chris Johns <chrisj@rtems.org> | 2016-04-03 15:38:14 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2016-04-03 15:38:14 +1000 |
commit | 2e973519a4e71a6a41b3a11e4ea1d3b94476ebb3 (patch) | |
tree | 34212a61cb8c7e5a6adf4b438ce88c585bb61a5c | |
parent | 0c0b2d4b529817f4561088c61827af797eee6def (diff) |
rtemstoolkit: Add an address table of symbols key by the symbol address.
This is useful if you need to look up a symbol based on its address.
-rw-r--r-- | rtemstoolkit/rld-symbols.cpp | 36 | ||||
-rw-r--r-- | rtemstoolkit/rld-symbols.h | 26 |
2 files changed, 62 insertions, 0 deletions
diff --git a/rtemstoolkit/rld-symbols.cpp b/rtemstoolkit/rld-symbols.cpp index 081d3e1..92803d8 100644 --- a/rtemstoolkit/rld-symbols.cpp +++ b/rtemstoolkit/rld-symbols.cpp @@ -362,6 +362,42 @@ namespace rld } void + table::globals (addrtab& addresses) + { + for (symtab::iterator gi = globals_.begin (); + gi != globals_.end (); + ++gi) + { + symbol& sym = *((*gi).second); + addresses[sym.value ()] = (*gi).second; + } + } + + void + table::weaks (addrtab& addresses) + { + for (symtab::iterator wi = weaks_.begin (); + wi != weaks_.end (); + ++wi) + { + symbol& sym = *((*wi).second); + addresses[sym.value ()] = (*wi).second; + } + } + + void + table::locals (addrtab& addresses) + { + for (symtab::iterator li = locals_.begin (); + li != locals_.end (); + ++li) + { + symbol& sym = *((*li).second); + addresses[sym.value ()] = (*li).second; + } + } + + void load (bucket& bucket_, table& table_) { for (bucket::iterator sbi = bucket_.begin (); diff --git a/rtemstoolkit/rld-symbols.h b/rtemstoolkit/rld-symbols.h index 02a41a3..c8a61f4 100644 --- a/rtemstoolkit/rld-symbols.h +++ b/rtemstoolkit/rld-symbols.h @@ -45,6 +45,11 @@ namespace rld namespace symbols { /** + * Use a local type for the address. + */ + typedef elf::elf_addr address; + + /** * A symbol. */ class symbol @@ -205,6 +210,12 @@ namespace rld typedef std::map < std::string, symbol* > symtab; /** + * An address table is a map container of symbols based on address. Should + * always point to symbols held in a bucket. + */ + typedef std::map < address, symbol* > addrtab; + + /** * A symbols contains a symbol table of global, weak and local symbols. */ class table @@ -270,6 +281,21 @@ namespace rld */ const symtab& locals () const; + /** + * Return the globals symbol table keyed by address. + */ + void globals (addrtab& addresses); + + /** + * Return the weak symbol table keyed by address. + */ + void weaks (addrtab& addresses); + + /** + * Return the local symbol table keyed by address. + */ + void locals (addrtab& addresses); + private: /** |