frame, cfa: check unwind stop reason first
[deliverable/binutils-gdb.git] / gold / archive.cc
index 4db813d6dffa4f29ee8e54d42e5e3b865baa29aa..53d88a23a12cdf038888af93bd68eb0593c26ab0 100644 (file)
@@ -1,6 +1,7 @@
 // archive.cc -- archive support for gold
 
-// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013
+// Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -654,33 +655,45 @@ Archive::get_elf_object_for_member(off_t off, bool* punconfigured)
                                 &member_name))
     return NULL;
 
+  const unsigned char* ehdr;
+  int read_size;
+  Object *obj = NULL;
+  bool is_elf_obj = false;
+
+  if (is_elf_object(input_file, memoff, &ehdr, &read_size))
+    {
+      obj = make_elf_object((std::string(this->input_file_->filename())
+                            + "(" + member_name + ")"),
+                           input_file, memoff, ehdr, read_size,
+                           punconfigured);
+      is_elf_obj = true;
+    }
+
   if (parameters->options().has_plugins())
     {
-      Object* obj = parameters->options().plugins()->claim_file(input_file,
-                                                                memoff,
-                                                                memsize,
-                                                               NULL);
-      if (obj != NULL)
+      Object* plugin_obj
+       = parameters->options().plugins()->claim_file(input_file,
+                                                     memoff,
+                                                     memsize,
+                                                     obj);
+      if (plugin_obj != NULL)
         {
           // The input file was claimed by a plugin, and its symbols
           // have been provided by the plugin.
-          return obj;
+         // Delete its elf object.
+         if (obj != NULL)
+           delete obj;
+          return plugin_obj;
         }
     }
 
-  const unsigned char* ehdr;
-  int read_size;
-  if (!is_elf_object(input_file, memoff, &ehdr, &read_size))
+  if (!is_elf_obj)
     {
       gold_error(_("%s: member at %zu is not an ELF object"),
                 this->name().c_str(), static_cast<size_t>(off));
       return NULL;
     }
 
-  Object* obj = make_elf_object((std::string(this->input_file_->filename())
-                                + "(" + member_name + ")"),
-                               input_file, memoff, ehdr, read_size,
-                               punconfigured);
   if (obj == NULL)
     return NULL;
   obj->set_no_export(this->no_export());
@@ -1118,7 +1131,7 @@ unsigned int Lib_group::total_members;
 unsigned int Lib_group::total_members_loaded;
 
 Lib_group::Lib_group(const Input_file_lib* lib, Task* task)
-  : Library_base(task), lib_(lib), members_()
+  : Library_base(task), members_()
 {
   this->members_.resize(lib->size());
 }
This page took 0.023393 seconds and 4 git commands to generate.