diff options
author | Chris Johns <chrisj@rtems.org> | 2012-12-18 20:52:18 +1100 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2012-12-18 20:52:18 +1100 |
commit | 53221a04855a6d476b4300498321ecc509651c82 (patch) | |
tree | 2b45b042365af6588c7025602f8932d1cf0d61bd /linkers | |
parent | b5a59dd96fddf5e6b346aacb3a9dcd41da463c91 (diff) |
Add object::get_section.
Add a method to return a section given the ELF section index.
Add more trace output for debugging.
Diffstat (limited to 'linkers')
-rw-r--r-- | linkers/rld-files.cpp | 38 | ||||
-rw-r--r-- | linkers/rld-files.h | 7 |
2 files changed, 32 insertions, 13 deletions
diff --git a/linkers/rld-files.cpp b/linkers/rld-files.cpp index 5996c95..75860ba 100644 --- a/linkers/rld-files.cpp +++ b/linkers/rld-files.cpp @@ -363,7 +363,7 @@ namespace rld if (path.empty ()) throw rld::error ("No file name", "open:" + path); - if (rld::verbose () >= RLD_VERBOSE_TRACE) + if (rld::verbose () >= RLD_VERBOSE_TRACE_FILE) std::cout << "image::open: " << name (). full () << " refs:" << references_ + 1 << " writable:" << (char*) (writable_ ? "yes" : "no") @@ -394,7 +394,7 @@ namespace rld { if (references_ > 0) { - if (rld::verbose () >= RLD_VERBOSE_TRACE) + if (rld::verbose () >= RLD_VERBOSE_TRACE_FILE) std::cout << "image::close: " << name ().full () << " refs:" << references_ << std::endl; @@ -822,7 +822,7 @@ namespace rld void archive::create (object_list& objects) { - if (rld::verbose () >= RLD_VERBOSE_INFO) + if (rld::verbose () >= RLD_VERBOSE_DETAILS) std::cout << "archive::create: " << name ().full () << ", objects: " << objects.size () << std::endl; @@ -1041,7 +1041,7 @@ namespace rld * Begin a session. */ - if (rld::verbose () >= RLD_VERBOSE_TRACE) + if (rld::verbose () >= RLD_VERBOSE_TRACE_FILE) std::cout << "object:begin: " << name ().full () << " in-archive:" << ((char*) (archive_ ? "yes" : "no")) << std::endl; @@ -1096,7 +1096,7 @@ namespace rld void object::end () { - if (rld::verbose () >= RLD_VERBOSE_TRACE) + if (rld::verbose () >= RLD_VERBOSE_TRACE_FILE) std::cout << "object:end: " << name ().full () << std::endl; elf ().end (); @@ -1111,14 +1111,14 @@ namespace rld void object::load_symbols (rld::symbols::table& symbols, bool local) { - if (rld::verbose () >= RLD_VERBOSE_TRACE) + if (rld::verbose () >= RLD_VERBOSE_TRACE_SYMS) std::cout << "object:load-sym: " << name ().full () << std::endl; rld::symbols::pointers syms; elf ().get_symbols (syms, false, local); - if (rld::verbose () >= RLD_VERBOSE_TRACE) + if (rld::verbose () >= RLD_VERBOSE_TRACE_SYMS) std::cout << "object:load-sym: exported: total " << syms.size () << std::endl; @@ -1129,11 +1129,7 @@ namespace rld symbols::symbol& sym = *(*si); if (rld::verbose () >= RLD_VERBOSE_TRACE_SYMS) - { - std::cout << "object:load-sym: exported: "; - sym.output (std::cout); - std::cout << std::endl; - } + std::cout << "object:load-sym: exported: " << sym << std::endl; sym.set_object (*this); symbols[sym.name ()] = &sym; @@ -1142,7 +1138,7 @@ namespace rld elf ().get_symbols (syms, true); - if (rld::verbose () >= RLD_VERBOSE_TRACE) + if (rld::verbose () >= RLD_VERBOSE_TRACE_SYMS) std::cout << "object:load-sym: unresolved: total " << syms.size () << std::endl; @@ -1269,6 +1265,22 @@ namespace rld } } + const section& + object::get_section (int index) const + { + for (sections::const_iterator si = secs.begin (); + si != secs.end (); + ++si) + { + const section& sec = *si; + if (sec.index == index) + return sec; + } + + throw rld::error ("Section index '" + rld::to_string (index) + + "' not found: " + name ().full (), "object::get-section"); + } + cache::cache () : opened (false) { diff --git a/linkers/rld-files.h b/linkers/rld-files.h index 36dcc9b..f579626 100644 --- a/linkers/rld-files.h +++ b/linkers/rld-files.h @@ -734,6 +734,13 @@ namespace rld */ void get_sections (sections& filtered_secs, const std::string& name); + /** + * Get a section given an index number. + * + * @param index The section index to search for. + */ + const section& get_section (int index) const; + private: archive* archive_; //< Points to the archive if part of an // archive. |