Better handling of archive open/close and begin/end.

This commit is contained in:
Chris Johns 2012-11-18 07:37:02 +11:00
parent 065ac15a40
commit f1cf3a9dd3

View File

@ -546,11 +546,14 @@ namespace rld
archive::~archive ()
{
end ();
close ();
}
void
archive::begin ()
{
if (references () == 1)
{
elf ().begin (name ().full (), fd ());
@ -561,10 +564,12 @@ namespace rld
throw rld::error ("Not an archive.",
"archive-begin:" + name ().full ());
}
}
void
archive::end ()
{
if (references () == 1)
elf ().end ();
}
@ -875,9 +880,6 @@ namespace rld
void
object::open ()
{
if (rld::verbose () >= RLD_VERBOSE_TRACE)
std::cout << "object::open: " << name ().full () << std::endl;
if (archive_)
archive_->open ();
else
@ -887,14 +889,17 @@ namespace rld
void
object::close ()
{
if (rld::verbose () >= RLD_VERBOSE_TRACE)
std::cout << "object::close: " << name ().full () << std::endl;
if (archive_)
{
archive_->end ();
archive_->close ();
}
else
{
end ();
image::close ();
}
}
void
object::begin ()
@ -1215,6 +1220,13 @@ namespace rld
void
cache::load_symbols (rld::symbols::table& symbols, bool local)
{
if (rld::verbose () >= RLD_VERBOSE_INFO)
std::cout << "cache:load-sym: object files: " << objects_.size ()
<< std::endl;
try
{
archives_begin ();
for (objects::iterator oi = objects_.begin ();
oi != objects_.end ();
++oi)
@ -1227,6 +1239,18 @@ namespace rld
obj->close ();
}
}
catch (...)
{
archives_end ();
throw;
}
archives_end ();
if (rld::verbose () >= RLD_VERBOSE_INFO)
std::cout << "cache:load-sym: symbols: " << symbols.size ()
<< std::endl;
}
void
cache::output_unresolved_symbols (std::ostream& out)