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.
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))
// 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))
}
}
- 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.
Symbol* sym = symtab->lookup(sym_name, ver);
if (def
+ && ver != NULL
&& (sym == NULL
|| !sym->is_undefined()
|| sym->binding() == elfcpp::STB_WEAK))
{
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);
if (!this->included_member_
&& this->searched_for()
- && (obj == NULL
- ? unconfigured
- : !parameters->is_compatible_target(obj->target())))
+ && obj == NULL
+ && unconfigured)
{
if (obj != NULL)
delete obj;