#include <cerrno>
#include <cstring>
-#include <cassert>
#include <cstdarg>
#include "target-select.h"
// Get the symbol table section header.
typename This::Shdr symtabshdr(pshdrs
+ this->symtab_shndx_ * This::shdr_size);
- assert(symtabshdr.get_sh_type() == elfcpp::SHT_SYMTAB);
+ gold_assert(symtabshdr.get_sh_type() == elfcpp::SHT_SYMTAB);
// We only need the external symbols.
const int sym_size = This::sym_size;
{
if (sd->symbols == NULL)
{
- assert(sd->symbol_names == NULL);
+ gold_assert(sd->symbol_names == NULL);
return;
}
off_t off,
Stringpool* pool)
{
- assert(this->symtab_shndx_ != -1U);
+ gold_assert(this->symtab_shndx_ != -1U);
if (this->symtab_shndx_ == 0)
{
// This object has no symbols. Weird but legal.
return index;
}
- assert(off == static_cast<off_t>(align_address(off, size >> 3)));
+ gold_assert(off == static_cast<off_t>(align_address(off, size >> 3)));
this->local_symbol_offset_ = off;
const unsigned int symtab_shndx = this->symtab_shndx_;
typename This::Shdr symtabshdr(this,
this->elf_file_.section_header(symtab_shndx));
- assert(symtabshdr.get_sh_type() == elfcpp::SHT_SYMTAB);
+ gold_assert(symtabshdr.get_sh_type() == elfcpp::SHT_SYMTAB);
// Read the local symbols.
const int sym_size = This::sym_size;
const unsigned int loccount = this->local_symbol_count_;
- assert(loccount == symtabshdr.get_sh_info());
+ gold_assert(loccount == symtabshdr.get_sh_info());
off_t locsize = loccount * sym_size;
const unsigned char* psyms = this->get_view(symtabshdr.get_sh_offset(),
locsize);
Sized_relobj<size, big_endian>::write_local_symbols(Output_file* of,
const Stringpool* sympool)
{
- assert(this->symtab_shndx_ != -1U);
+ gold_assert(this->symtab_shndx_ != -1U);
if (this->symtab_shndx_ == 0)
{
// This object has no symbols. Weird but legal.
const unsigned int symtab_shndx = this->symtab_shndx_;
typename This::Shdr symtabshdr(this,
this->elf_file_.section_header(symtab_shndx));
- assert(symtabshdr.get_sh_type() == elfcpp::SHT_SYMTAB);
+ gold_assert(symtabshdr.get_sh_type() == elfcpp::SHT_SYMTAB);
const unsigned int loccount = this->local_symbol_count_;
- assert(loccount == symtabshdr.get_sh_info());
+ gold_assert(loccount == symtabshdr.get_sh_info());
// Read the local symbols.
const int sym_size = This::sym_size;
const std::vector<Map_to_output>& mo(this->map_to_output());
- assert(this->local_values_.size() == loccount);
- assert(this->local_indexes_.size() == loccount);
+ gold_assert(this->local_values_.size() == loccount);
+ gold_assert(this->local_indexes_.size() == loccount);
unsigned char* ov = oview;
psyms += sym_size;
if (this->local_indexes_[i] == -1U)
continue;
- assert(this->local_indexes_[i] != 0);
+ gold_assert(this->local_indexes_[i] != 0);
unsigned int st_shndx = isym.get_st_shndx();
if (st_shndx < elfcpp::SHN_LORESERVE)
{
- assert(st_shndx < mo.size());
+ gold_assert(st_shndx < mo.size());
if (mo[st_shndx].output_section == NULL)
continue;
st_shndx = mo[st_shndx].output_section->out_shndx();
elfcpp::Sym_write<size, big_endian> osym(ov);
- assert(isym.get_st_name() < strtab_size);
+ gold_assert(isym.get_st_name() < strtab_size);
const char* name = pnames + isym.get_st_name();
osym.put_st_name(sympool->get_offset(name));
osym.put_st_value(this->local_values_[i]);
ov += sym_size;
}
- assert(ov - oview == output_size);
+ gold_assert(ov - oview == output_size);
of->write_output_view(this->local_symbol_offset_, output_size, oview);
}
// Input_objects methods.
-// Add a regular relocatable object to the list.
+// Add a regular relocatable object to the list. Return false if this
+// object should be ignored.
-void
+bool
Input_objects::add_object(Object* obj)
{
- if (obj->is_dynamic())
- this->dynobj_list_.push_back(static_cast<Dynobj*>(obj));
- else
+ if (!obj->is_dynamic())
this->relobj_list_.push_back(static_cast<Relobj*>(obj));
+ else
+ {
+ // See if this is a duplicate SONAME.
+ Dynobj* dynobj = static_cast<Dynobj*>(obj);
+
+ std::pair<Unordered_set<std::string>::iterator, bool> ins =
+ this->sonames_.insert(dynobj->soname());
+ if (!ins.second)
+ {
+ // We have already seen a dynamic object with this soname.
+ return false;
+ }
+
+ this->dynobj_list_.push_back(dynobj);
+ }
Target* target = obj->target();
if (this->target_ == NULL)
program_name, obj->name().c_str());
gold_exit(false);
}
+
+ return true;
}
// Relocate_info methods.