+// RAII class to ensure we unlock the object if it's a member of a
+// thin archive. We can't use Task_lock_obj in Archive::include_member
+// because the object file is already locked when it's opened by
+// get_elf_object_for_member.
+
+class Thin_archive_object_unlocker
+{
+ public:
+ Thin_archive_object_unlocker(const Task *task, Object* obj)
+ : task_(task), obj_(obj)
+ { }
+
+ ~Thin_archive_object_unlocker()
+ {
+ if (this->obj_->offset() == 0)
+ this->obj_->unlock(this->task_);
+ }
+
+ private:
+ Thin_archive_object_unlocker(const Thin_archive_object_unlocker&);
+ Thin_archive_object_unlocker& operator=(const Thin_archive_object_unlocker&);
+
+ const Task* task_;
+ Object* obj_;
+};
+