Delete unused or undefined functions.
[deliverable/binutils-gdb.git] / gold / archive.cc
index 1d83d6a2f79e85c364bc2828470552eb59da53a6..011c36ddd613a660d00c623c8494a5779f8d3651 100644 (file)
@@ -83,6 +83,17 @@ const char Archive::armagt[sarmag] =
 
 const char Archive::arfmag[2] = { '`', '\n' };
 
+Archive::Archive(const std::string& name, Input_file* input_file,
+                 bool is_thin_archive, Dirsearch* dirpath, Task* task)
+  : name_(name), input_file_(input_file), armap_(), armap_names_(),
+    extended_names_(), armap_checked_(), seen_offsets_(), members_(),
+    is_thin_archive_(is_thin_archive), included_member_(false),
+    nested_archives_(), dirpath_(dirpath), task_(task), num_members_(0)
+{
+  this->no_export_ =
+    parameters->options().check_excluded_libs(input_file->found_name());
+}
+
 // Set up the archive: read the symbol map and the extended name
 // table.
 
@@ -478,8 +489,9 @@ Archive::get_file_and_offset(off_t off, Input_file** input_file, off_t* memoff,
       else
         {
           Input_file_argument* input_file_arg =
-            new Input_file_argument(member_name->c_str(), false, "", false,
-                                    parameters->options());
+            new Input_file_argument(member_name->c_str(),
+                                    Input_file_argument::INPUT_FILE_TYPE_FILE,
+                                    "", false, parameters->options());
           *input_file = new Input_file(input_file_arg);
          int dummy = 0;
           if (!(*input_file)->open(*this->dirpath_, this->task_, &dummy))
@@ -498,8 +510,9 @@ Archive::get_file_and_offset(off_t off, Input_file** input_file, off_t* memoff,
   // This is an external member of a thin archive.  Open the
   // file as a regular relocatable object file.
   Input_file_argument* input_file_arg =
-      new Input_file_argument(member_name->c_str(), false, "", false,
-                              this->input_file_->options());
+      new Input_file_argument(member_name->c_str(),
+                              Input_file_argument::INPUT_FILE_TYPE_FILE,
+                              "", false, this->input_file_->options());
   *input_file = new Input_file(input_file_arg);
   int dummy = 0;
   if (!(*input_file)->open(*this->dirpath_, this->task_, &dummy))
@@ -540,37 +553,23 @@ Archive::get_elf_object_for_member(off_t off, bool* punconfigured)
         }
     }
 
-  off_t filesize = input_file->file().filesize();
-  int read_size = elfcpp::Elf_sizes<64>::ehdr_size;
-  if (filesize - memoff < read_size)
-    read_size = filesize - memoff;
-
-  if (read_size < 4)
+  const unsigned char* ehdr;
+  int read_size;
+  if (!is_elf_object(input_file, memoff, &ehdr, &read_size))
     {
       gold_error(_("%s: member at %zu is not an ELF object"),
                 this->name().c_str(), static_cast<size_t>(off));
       return NULL;
     }
 
-  const unsigned char* ehdr = input_file->file().get_view(memoff, 0, read_size,
-                                                         true, false);
-
-  static unsigned char elfmagic[4] =
-    {
-      elfcpp::ELFMAG0, elfcpp::ELFMAG1,
-      elfcpp::ELFMAG2, elfcpp::ELFMAG3
-    };
-  if (memcmp(ehdr, elfmagic, 4) != 0)
-    {
-      gold_error(_("%s: member at %zu is not an ELF object"),
-                this->name().c_str(), static_cast<size_t>(off));
-      return NULL;
-    }
-
-  return make_elf_object((std::string(this->input_file_->filename())
-                         + "(" + member_name + ")"),
-                        input_file, memoff, ehdr, read_size,
-                        punconfigured);
+  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());
+  return obj;
 }
 
 // Read the symbols from all the archive members in the link.
@@ -689,6 +688,7 @@ Archive::add_symbols(Symbol_table* symtab, Layout* layout,
 
          Symbol* sym = symtab->lookup(sym_name, ver);
          if (def
+             && ver != NULL
              && (sym == NULL
                  || !sym->is_undefined()
                  || sym->binding() == elfcpp::STB_WEAK))
@@ -812,11 +812,6 @@ Archive::include_member(Symbol_table* symtab, Layout* layout,
     {
       Object *obj = p->second.obj_;
 
-      if (!this->included_member_
-         && this->searched_for()
-         && !parameters->is_compatible_target(obj->target()))
-       return false;
-
       Read_symbols_data *sd = p->second.sd_;
       if (mapfile != NULL)
         mapfile->report_include_archive_member(obj->name(), sym, why);
@@ -835,9 +830,8 @@ Archive::include_member(Symbol_table* symtab, Layout* layout,
 
   if (!this->included_member_
       && this->searched_for()
-      && (obj == NULL
-         ? unconfigured
-         : !parameters->is_compatible_target(obj->target())))
+      && obj == NULL
+      && unconfigured)
     {
       if (obj != NULL)
        delete obj;
This page took 0.02516 seconds and 4 git commands to generate.