+// Layout sections whose layout was deferred while waiting for
+// input files from a plugin.
+template<int size, bool big_endian>
+void
+Sized_relobj_incr<size, big_endian>::do_layout_deferred_sections(Layout*)
+{
+}
+
+// Add the symbols to the symbol table.
+
+template<int size, bool big_endian>
+void
+Sized_relobj_incr<size, big_endian>::do_add_symbols(
+ Symbol_table* symtab,
+ Read_symbols_data*,
+ Layout*)
+{
+ const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
+ unsigned char symbuf[sym_size];
+ elfcpp::Sym<size, big_endian> sym(symbuf);
+ elfcpp::Sym_write<size, big_endian> osym(symbuf);
+
+ typedef typename elfcpp::Elf_types<size>::Elf_WXword Elf_size_type;
+
+ unsigned int nsyms = this->input_reader_.get_global_symbol_count();
+ this->symbols_.resize(nsyms);
+
+ Incremental_binary::View symtab_view(NULL);
+ unsigned int symtab_count;
+ elfcpp::Elf_strtab strtab(NULL, 0);
+ this->ibase_->get_symtab_view(&symtab_view, &symtab_count, &strtab);
+
+ Incremental_symtab_reader<big_endian> isymtab(this->ibase_->symtab_reader());
+ unsigned int isym_count = isymtab.symbol_count();
+ unsigned int first_global = symtab_count - isym_count;
+
+ const unsigned char* sym_p;
+ for (unsigned int i = 0; i < nsyms; ++i)
+ {
+ Incremental_global_symbol_reader<big_endian> info =
+ this->input_reader_.get_global_symbol_reader(i);
+ unsigned int output_symndx = info.output_symndx();
+ sym_p = symtab_view.data() + output_symndx * sym_size;
+ elfcpp::Sym<size, big_endian> gsym(sym_p);
+ const char* name;
+ if (!strtab.get_c_string(gsym.get_st_name(), &name))
+ name = "";
+
+ typename elfcpp::Elf_types<size>::Elf_Addr v = gsym.get_st_value();
+ unsigned int shndx = gsym.get_st_shndx();
+ elfcpp::STB st_bind = gsym.get_st_bind();
+ elfcpp::STT st_type = gsym.get_st_type();
+
+ // Local hidden symbols start out as globals, but get converted to
+ // to local during output.
+ if (st_bind == elfcpp::STB_LOCAL)
+ st_bind = elfcpp::STB_GLOBAL;
+
+ unsigned int input_shndx = info.shndx();
+ if (input_shndx == 0 || input_shndx == -1U)
+ {
+ shndx = elfcpp::SHN_UNDEF;
+ v = 0;
+ }
+ else if (shndx != elfcpp::SHN_ABS)
+ {
+ // Find the input section and calculate the section-relative value.
+ gold_assert(shndx != elfcpp::SHN_UNDEF);
+ Output_section* os = this->ibase_->output_section(shndx);
+ gold_assert(os != NULL && os->has_fixed_layout());
+ typename Input_entry_reader::Input_section_info sect =
+ this->input_reader_.get_input_section(input_shndx - 1);
+ gold_assert(sect.output_shndx == shndx);
+ if (st_type != elfcpp::STT_TLS)
+ v -= os->address();
+ v -= sect.sh_offset;
+ shndx = input_shndx;
+ }
+
+ osym.put_st_name(0);
+ osym.put_st_value(v);
+ osym.put_st_size(gsym.get_st_size());
+ osym.put_st_info(st_bind, st_type);
+ osym.put_st_other(gsym.get_st_other());
+ osym.put_st_shndx(shndx);
+
+ Symbol* res = symtab->add_from_incrobj(this, name, NULL, &sym);
+
+ if (shndx != elfcpp::SHN_UNDEF)
+ ++this->defined_count_;
+
+ // If this is a linker-defined symbol that hasn't yet been defined,
+ // define it now.
+ if (input_shndx == -1U && !res->is_defined())
+ {
+ shndx = gsym.get_st_shndx();
+ v = gsym.get_st_value();
+ Elf_size_type symsize = gsym.get_st_size();
+ if (shndx == elfcpp::SHN_ABS)
+ {
+ symtab->define_as_constant(name, NULL,
+ Symbol_table::INCREMENTAL_BASE,
+ v, symsize, st_type, st_bind,
+ gsym.get_st_visibility(), 0,
+ false, false);
+ }
+ else
+ {
+ Output_section* os = this->ibase_->output_section(shndx);
+ gold_assert(os != NULL && os->has_fixed_layout());
+ v -= os->address();
+ if (symsize > 0)
+ os->reserve(v, symsize);
+ symtab->define_in_output_data(name, NULL,
+ Symbol_table::INCREMENTAL_BASE,
+ os, v, symsize, st_type, st_bind,
+ gsym.get_st_visibility(), 0,
+ false, false);
+ }
+ }
+
+ this->symbols_[i] = res;
+ this->ibase_->add_global_symbol(output_symndx - first_global, res);
+ }
+}
+
+// Return TRUE if we should include this object from an archive library.
+
+template<int size, bool big_endian>
+Archive::Should_include
+Sized_relobj_incr<size, big_endian>::do_should_include_member(
+ Symbol_table*,
+ Layout*,
+ Read_symbols_data*,
+ std::string*)
+{
+ gold_unreachable();
+}
+
+// Iterate over global symbols, calling a visitor class V for each.
+
+template<int size, bool big_endian>
+void
+Sized_relobj_incr<size, big_endian>::do_for_all_global_symbols(
+ Read_symbols_data*,
+ Library_base::Symbol_visitor_base*)
+{
+ // This routine is not used for incremental objects.
+}
+
+// Get the size of a section.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_relobj_incr<size, big_endian>::do_section_size(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Get the name of a section. This returns the name of the output
+// section, because we don't usually track the names of the input
+// sections.
+
+template<int size, bool big_endian>
+std::string
+Sized_relobj_incr<size, big_endian>::do_section_name(unsigned int shndx) const
+{
+ const Output_sections& out_sections(this->output_sections());
+ const Output_section* os = out_sections[shndx];
+ if (os == NULL)
+ return NULL;
+ return os->name();
+}
+
+// Return a view of the contents of a section.
+
+template<int size, bool big_endian>
+const unsigned char*
+Sized_relobj_incr<size, big_endian>::do_section_contents(
+ unsigned int shndx,
+ section_size_type* plen,
+ bool)
+{
+ Output_sections& out_sections(this->output_sections());
+ Output_section* os = out_sections[shndx];
+ gold_assert(os != NULL);
+ off_t section_offset = os->offset();
+ typename Input_entry_reader::Input_section_info sect =
+ this->input_reader_.get_input_section(shndx - 1);
+ section_offset += sect.sh_offset;
+ *plen = sect.sh_size;
+ return this->ibase_->view(section_offset, sect.sh_size).data();
+}
+
+// Return section flags.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_relobj_incr<size, big_endian>::do_section_flags(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return section entsize.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_relobj_incr<size, big_endian>::do_section_entsize(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return section address.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_relobj_incr<size, big_endian>::do_section_address(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return section type.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_relobj_incr<size, big_endian>::do_section_type(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return the section link field.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_relobj_incr<size, big_endian>::do_section_link(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return the section link field.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_relobj_incr<size, big_endian>::do_section_info(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return the section alignment.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_relobj_incr<size, big_endian>::do_section_addralign(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return the Xindex structure to use.
+
+template<int size, bool big_endian>
+Xindex*
+Sized_relobj_incr<size, big_endian>::do_initialize_xindex()
+{
+ gold_unreachable();
+}
+
+// Get symbol counts.
+
+template<int size, bool big_endian>
+void
+Sized_relobj_incr<size, big_endian>::do_get_global_symbol_counts(
+ const Symbol_table*,
+ size_t* defined,
+ size_t* used) const
+{
+ *defined = this->defined_count_;
+ size_t count = 0;
+ for (typename Symbols::const_iterator p = this->symbols_.begin();
+ p != this->symbols_.end();
+ ++p)
+ if (*p != NULL
+ && (*p)->source() == Symbol::FROM_OBJECT
+ && (*p)->object() == this
+ && (*p)->is_defined())
+ ++count;
+ *used = count;
+}
+
+// Read the relocs.
+
+template<int size, bool big_endian>
+void
+Sized_relobj_incr<size, big_endian>::do_read_relocs(Read_relocs_data*)
+{
+}
+
+// Process the relocs to find list of referenced sections. Used only
+// during garbage collection.
+
+template<int size, bool big_endian>
+void
+Sized_relobj_incr<size, big_endian>::do_gc_process_relocs(Symbol_table*,
+ Layout*,
+ Read_relocs_data*)
+{
+ gold_unreachable();
+}
+
+// Scan the relocs and adjust the symbol table.
+
+template<int size, bool big_endian>
+void
+Sized_relobj_incr<size, big_endian>::do_scan_relocs(Symbol_table*,
+ Layout* layout,
+ Read_relocs_data*)
+{
+ // Count the incremental relocations for this object.
+ unsigned int nsyms = this->input_reader_.get_global_symbol_count();
+ this->allocate_incremental_reloc_counts();
+ for (unsigned int i = 0; i < nsyms; i++)
+ {
+ Incremental_global_symbol_reader<big_endian> sym =
+ this->input_reader_.get_global_symbol_reader(i);
+ unsigned int reloc_count = sym.reloc_count();
+ if (reloc_count > 0 && this->incr_reloc_offset_ == -1U)
+ this->incr_reloc_offset_ = sym.reloc_offset();
+ this->incr_reloc_count_ += reloc_count;
+ for (unsigned int j = 0; j < reloc_count; j++)
+ this->count_incremental_reloc(i);
+ }
+ this->incr_reloc_output_index_ =
+ layout->incremental_inputs()->get_reloc_count();
+ this->finalize_incremental_relocs(layout, false);
+
+ // The incoming incremental relocations may not end up in the same
+ // location after the incremental update, because the incremental info
+ // is regenerated in each link. Because the new location may overlap
+ // with other data in the updated output file, we need to copy the
+ // relocations into a buffer so that we can still read them safely
+ // after we start writing updates to the output file.
+ if (this->incr_reloc_count_ > 0)
+ {
+ const Incremental_relocs_reader<size, big_endian>& relocs_reader =
+ this->ibase_->relocs_reader();
+ const unsigned int incr_reloc_size = relocs_reader.reloc_size;
+ unsigned int len = this->incr_reloc_count_ * incr_reloc_size;
+ this->incr_relocs_ = new unsigned char[len];
+ memcpy(this->incr_relocs_,
+ relocs_reader.data(this->incr_reloc_offset_),
+ len);
+ }
+}
+
+// Count the local symbols.
+
+template<int size, bool big_endian>
+void
+Sized_relobj_incr<size, big_endian>::do_count_local_symbols(
+ Stringpool_template<char>* pool,
+ Stringpool_template<char>*)
+{
+ const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
+
+ // Set the count of local symbols based on the incremental info.
+ unsigned int nlocals = this->input_reader_.get_local_symbol_count();
+ this->local_symbol_count_ = nlocals;
+ this->local_symbols_.reserve(nlocals);
+
+ // Get views of the base file's symbol table and string table.
+ Incremental_binary::View symtab_view(NULL);
+ unsigned int symtab_count;
+ elfcpp::Elf_strtab strtab(NULL, 0);
+ this->ibase_->get_symtab_view(&symtab_view, &symtab_count, &strtab);
+
+ // Read the local symbols from the base file's symbol table.
+ off_t off = this->input_reader_.get_local_symbol_offset();
+ const unsigned char* symp = symtab_view.data() + off;
+ for (unsigned int i = 0; i < nlocals; ++i, symp += sym_size)
+ {
+ elfcpp::Sym<size, big_endian> sym(symp);
+ const char* name;
+ if (!strtab.get_c_string(sym.get_st_name(), &name))
+ name = "";
+ gold_debug(DEBUG_INCREMENTAL, "Local symbol %d: %s", i, name);
+ name = pool->add(name, true, NULL);
+ this->local_symbols_.push_back(Local_symbol(name,
+ sym.get_st_value(),
+ sym.get_st_size(),
+ sym.get_st_shndx(),
+ sym.get_st_type(),
+ false));
+ }
+}
+
+// Finalize the local symbols.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_relobj_incr<size, big_endian>::do_finalize_local_symbols(
+ unsigned int index,
+ off_t off,
+ Symbol_table*)
+{
+ this->local_symbol_index_ = index;
+ this->local_symbol_offset_ = off;
+ return index + this->local_symbol_count_;
+}
+
+// Set the offset where local dynamic symbol information will be stored.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_relobj_incr<size, big_endian>::do_set_local_dynsym_indexes(
+ unsigned int index)
+{
+ // FIXME: set local dynsym indexes.
+ return index;
+}
+
+// Set the offset where local dynamic symbol information will be stored.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_relobj_incr<size, big_endian>::do_set_local_dynsym_offset(off_t)
+{
+ return 0;
+}
+
+// Relocate the input sections and write out the local symbols.
+// We don't actually do any relocation here. For unchanged input files,
+// we reapply relocations only for symbols that have changed; that happens
+// in Layout_task_runner::run(). We do need to rewrite the incremental
+// relocations for this object.
+
+template<int size, bool big_endian>
+void
+Sized_relobj_incr<size, big_endian>::do_relocate(const Symbol_table*,
+ const Layout* layout,
+ Output_file* of)
+{
+ if (this->incr_reloc_count_ == 0)
+ return;
+
+ const unsigned int incr_reloc_size =
+ Incremental_relocs_reader<size, big_endian>::reloc_size;
+
+ // Get a view for the .gnu_incremental_relocs section.
+ Incremental_inputs* inputs = layout->incremental_inputs();
+ gold_assert(inputs != NULL);
+ const off_t relocs_off = inputs->relocs_section()->offset();
+ const off_t relocs_size = inputs->relocs_section()->data_size();
+ unsigned char* const view = of->get_output_view(relocs_off, relocs_size);
+
+ // Copy the relocations from the buffer.
+ off_t off = this->incr_reloc_output_index_ * incr_reloc_size;
+ unsigned int len = this->incr_reloc_count_ * incr_reloc_size;
+ memcpy(view + off, this->incr_relocs_, len);
+
+ // The output section table may have changed, so we need to map
+ // the old section index to the new section index for each relocation.
+ for (unsigned int i = 0; i < this->incr_reloc_count_; ++i)
+ {
+ unsigned char* pov = view + off + i * incr_reloc_size;
+ unsigned int shndx = elfcpp::Swap<32, big_endian>::readval(pov + 4);
+ Output_section* os = this->ibase_->output_section(shndx);
+ gold_assert(os != NULL);
+ shndx = os->out_shndx();
+ elfcpp::Swap<32, big_endian>::writeval(pov + 4, shndx);
+ }
+
+ of->write_output_view(off, len, view);
+
+ // Get views into the output file for the portions of the symbol table
+ // and the dynamic symbol table that we will be writing.
+ off_t symtab_off = layout->symtab_section()->offset();
+ off_t output_size = this->local_symbol_count_ * This::sym_size;
+ unsigned char* oview = NULL;
+ if (output_size > 0)
+ oview = of->get_output_view(symtab_off + this->local_symbol_offset_,
+ output_size);
+
+ off_t dyn_output_size = this->output_local_dynsym_count_ * sym_size;
+ unsigned char* dyn_oview = NULL;
+ if (dyn_output_size > 0)
+ dyn_oview = of->get_output_view(this->local_dynsym_offset_,
+ dyn_output_size);
+
+ // Write the local symbols.
+ unsigned char* ov = oview;
+ unsigned char* dyn_ov = dyn_oview;
+ const Stringpool* sympool = layout->sympool();
+ const Stringpool* dynpool = layout->dynpool();
+ Output_symtab_xindex* symtab_xindex = layout->symtab_xindex();
+ Output_symtab_xindex* dynsym_xindex = layout->dynsym_xindex();
+ for (unsigned int i = 0; i < this->local_symbol_count_; ++i)
+ {
+ Local_symbol& lsym(this->local_symbols_[i]);
+
+ bool is_ordinary;
+ unsigned int st_shndx = this->adjust_sym_shndx(i, lsym.st_shndx,
+ &is_ordinary);
+ if (is_ordinary)
+ {
+ Output_section* os = this->ibase_->output_section(st_shndx);
+ st_shndx = os->out_shndx();
+ if (st_shndx >= elfcpp::SHN_LORESERVE)
+ {
+ symtab_xindex->add(this->local_symbol_index_ + i, st_shndx);
+ if (lsym.needs_dynsym_entry)
+ dynsym_xindex->add(lsym.output_dynsym_index, st_shndx);
+ st_shndx = elfcpp::SHN_XINDEX;
+ }
+ }
+
+ // Write the symbol to the output symbol table.
+ {
+ elfcpp::Sym_write<size, big_endian> osym(ov);
+ osym.put_st_name(sympool->get_offset(lsym.name));
+ osym.put_st_value(lsym.st_value);
+ osym.put_st_size(lsym.st_size);
+ osym.put_st_info(elfcpp::STB_LOCAL,
+ static_cast<elfcpp::STT>(lsym.st_type));
+ osym.put_st_other(0);
+ osym.put_st_shndx(st_shndx);
+ ov += sym_size;
+ }
+
+ // Write the symbol to the output dynamic symbol table.
+ if (lsym.needs_dynsym_entry)
+ {
+ gold_assert(dyn_ov < dyn_oview + dyn_output_size);
+ elfcpp::Sym_write<size, big_endian> osym(dyn_ov);
+ osym.put_st_name(dynpool->get_offset(lsym.name));
+ osym.put_st_value(lsym.st_value);
+ osym.put_st_size(lsym.st_size);
+ osym.put_st_info(elfcpp::STB_LOCAL,
+ static_cast<elfcpp::STT>(lsym.st_type));
+ osym.put_st_other(0);
+ osym.put_st_shndx(st_shndx);
+ dyn_ov += sym_size;
+ }
+ }
+
+ if (output_size > 0)
+ {
+ gold_assert(ov - oview == output_size);
+ of->write_output_view(symtab_off + this->local_symbol_offset_,
+ output_size, oview);
+ }
+
+ if (dyn_output_size > 0)
+ {
+ gold_assert(dyn_ov - dyn_oview == dyn_output_size);
+ of->write_output_view(this->local_dynsym_offset_, dyn_output_size,
+ dyn_oview);
+ }
+}
+
+// Set the offset of a section.
+
+template<int size, bool big_endian>
+void
+Sized_relobj_incr<size, big_endian>::do_set_section_offset(unsigned int,
+ uint64_t)
+{
+}
+
+// Class Sized_incr_dynobj. Most of these methods are not used for
+// Incremental objects, but are required to be implemented by the
+// base class Object.
+
+template<int size, bool big_endian>
+Sized_incr_dynobj<size, big_endian>::Sized_incr_dynobj(
+ const std::string& name,
+ Sized_incremental_binary<size, big_endian>* ibase,
+ unsigned int input_file_index)
+ : Dynobj(name, NULL), ibase_(ibase),
+ input_file_index_(input_file_index),
+ input_reader_(ibase->inputs_reader().input_file(input_file_index)),
+ symbols_(), defined_count_(0)
+{
+ if (this->input_reader_.is_in_system_directory())
+ this->set_is_in_system_directory();
+ if (this->input_reader_.as_needed())
+ this->set_as_needed();
+ this->set_soname_string(this->input_reader_.get_soname());
+ this->set_shnum(0);
+}
+
+// Read the symbols.
+
+template<int size, bool big_endian>
+void
+Sized_incr_dynobj<size, big_endian>::do_read_symbols(Read_symbols_data*)
+{
+ gold_unreachable();
+}
+
+// Lay out the input sections.
+
+template<int size, bool big_endian>
+void
+Sized_incr_dynobj<size, big_endian>::do_layout(
+ Symbol_table*,
+ Layout*,
+ Read_symbols_data*)
+{
+}
+
+// Add the symbols to the symbol table.
+
+template<int size, bool big_endian>
+void
+Sized_incr_dynobj<size, big_endian>::do_add_symbols(
+ Symbol_table* symtab,
+ Read_symbols_data*,
+ Layout*)
+{
+ const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
+ unsigned char symbuf[sym_size];
+ elfcpp::Sym<size, big_endian> sym(symbuf);
+ elfcpp::Sym_write<size, big_endian> osym(symbuf);
+
+ unsigned int nsyms = this->input_reader_.get_global_symbol_count();
+ this->symbols_.resize(nsyms);
+
+ Incremental_binary::View symtab_view(NULL);
+ unsigned int symtab_count;
+ elfcpp::Elf_strtab strtab(NULL, 0);
+ this->ibase_->get_symtab_view(&symtab_view, &symtab_count, &strtab);
+
+ Incremental_symtab_reader<big_endian> isymtab(this->ibase_->symtab_reader());
+ unsigned int isym_count = isymtab.symbol_count();
+ unsigned int first_global = symtab_count - isym_count;
+
+ // We keep a set of symbols that we have generated COPY relocations
+ // for, indexed by the symbol value. We do not need more than one
+ // COPY relocation per address.
+ typedef typename std::set<Address> Copied_symbols;
+ Copied_symbols copied_symbols;
+
+ const unsigned char* sym_p;
+ for (unsigned int i = 0; i < nsyms; ++i)
+ {
+ bool is_def;
+ bool is_copy;
+ unsigned int output_symndx =
+ this->input_reader_.get_output_symbol_index(i, &is_def, &is_copy);
+ sym_p = symtab_view.data() + output_symndx * sym_size;
+ elfcpp::Sym<size, big_endian> gsym(sym_p);
+ const char* name;
+ if (!strtab.get_c_string(gsym.get_st_name(), &name))
+ name = "";
+
+ Address v;
+ unsigned int shndx;
+ elfcpp::STB st_bind = gsym.get_st_bind();
+ elfcpp::STT st_type = gsym.get_st_type();
+
+ // Local hidden symbols start out as globals, but get converted to
+ // to local during output.
+ if (st_bind == elfcpp::STB_LOCAL)
+ st_bind = elfcpp::STB_GLOBAL;
+
+ if (!is_def)
+ {
+ shndx = elfcpp::SHN_UNDEF;
+ v = 0;
+ }
+ else
+ {
+ // For a symbol defined in a shared object, the section index
+ // is meaningless, as long as it's not SHN_UNDEF.
+ shndx = 1;
+ v = gsym.get_st_value();
+ ++this->defined_count_;
+ }
+
+ osym.put_st_name(0);
+ osym.put_st_value(v);
+ osym.put_st_size(gsym.get_st_size());
+ osym.put_st_info(st_bind, st_type);
+ osym.put_st_other(gsym.get_st_other());
+ osym.put_st_shndx(shndx);
+
+ Sized_symbol<size>* res =
+ symtab->add_from_incrobj<size, big_endian>(this, name, NULL, &sym);
+ this->symbols_[i] = res;
+ this->ibase_->add_global_symbol(output_symndx - first_global,
+ this->symbols_[i]);
+
+ if (is_copy)
+ {
+ std::pair<typename Copied_symbols::iterator, bool> ins =
+ copied_symbols.insert(v);
+ if (ins.second)
+ {
+ unsigned int shndx = gsym.get_st_shndx();
+ Output_section* os = this->ibase_->output_section(shndx);
+ off_t offset = v - os->address();
+ this->ibase_->add_copy_reloc(this->symbols_[i], os, offset);
+ }
+ }
+ }
+}
+
+// Return TRUE if we should include this object from an archive library.
+
+template<int size, bool big_endian>
+Archive::Should_include
+Sized_incr_dynobj<size, big_endian>::do_should_include_member(
+ Symbol_table*,
+ Layout*,
+ Read_symbols_data*,
+ std::string*)
+{
+ gold_unreachable();
+}
+
+// Iterate over global symbols, calling a visitor class V for each.
+
+template<int size, bool big_endian>
+void
+Sized_incr_dynobj<size, big_endian>::do_for_all_global_symbols(
+ Read_symbols_data*,
+ Library_base::Symbol_visitor_base*)
+{
+ // This routine is not used for dynamic libraries.
+}
+
+// Iterate over local symbols, calling a visitor class V for each GOT offset
+// associated with a local symbol.
+
+template<int size, bool big_endian>
+void
+Sized_incr_dynobj<size, big_endian>::do_for_all_local_got_entries(
+ Got_offset_list::Visitor*) const
+{
+}
+
+// Get the size of a section.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_incr_dynobj<size, big_endian>::do_section_size(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Get the name of a section.
+
+template<int size, bool big_endian>
+std::string
+Sized_incr_dynobj<size, big_endian>::do_section_name(unsigned int) const
+{
+ gold_unreachable();
+}
+
+// Return a view of the contents of a section.
+
+template<int size, bool big_endian>
+const unsigned char*
+Sized_incr_dynobj<size, big_endian>::do_section_contents(
+ unsigned int,
+ section_size_type*,
+ bool)
+{
+ gold_unreachable();
+}
+
+// Return section flags.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_incr_dynobj<size, big_endian>::do_section_flags(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return section entsize.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_incr_dynobj<size, big_endian>::do_section_entsize(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return section address.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_incr_dynobj<size, big_endian>::do_section_address(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return section type.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_incr_dynobj<size, big_endian>::do_section_type(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return the section link field.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_incr_dynobj<size, big_endian>::do_section_link(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return the section link field.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_incr_dynobj<size, big_endian>::do_section_info(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return the section alignment.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_incr_dynobj<size, big_endian>::do_section_addralign(unsigned int)
+{
+ gold_unreachable();
+}
+
+// Return the Xindex structure to use.
+
+template<int size, bool big_endian>
+Xindex*
+Sized_incr_dynobj<size, big_endian>::do_initialize_xindex()
+{
+ gold_unreachable();
+}
+
+// Get symbol counts.
+
+template<int size, bool big_endian>
+void
+Sized_incr_dynobj<size, big_endian>::do_get_global_symbol_counts(
+ const Symbol_table*,
+ size_t* defined,
+ size_t* used) const
+{
+ *defined = this->defined_count_;
+ size_t count = 0;
+ for (typename Symbols::const_iterator p = this->symbols_.begin();
+ p != this->symbols_.end();
+ ++p)
+ if (*p != NULL
+ && (*p)->source() == Symbol::FROM_OBJECT
+ && (*p)->object() == this
+ && (*p)->is_defined()
+ && (*p)->dynsym_index() != -1U)
+ ++count;
+ *used = count;
+}
+
+// Allocate an incremental object of the appropriate size and endianness.
+
+Object*
+make_sized_incremental_object(
+ Incremental_binary* ibase,
+ unsigned int input_file_index,
+ Incremental_input_type input_type,
+ const Incremental_binary::Input_reader* input_reader)
+{
+ Object* obj = NULL;
+ std::string name(input_reader->filename());
+
+ switch (parameters->size_and_endianness())
+ {
+#ifdef HAVE_TARGET_32_LITTLE
+ case Parameters::TARGET_32_LITTLE:
+ {
+ Sized_incremental_binary<32, false>* sized_ibase =
+ static_cast<Sized_incremental_binary<32, false>*>(ibase);
+ if (input_type == INCREMENTAL_INPUT_SHARED_LIBRARY)
+ obj = new Sized_incr_dynobj<32, false>(name, sized_ibase,
+ input_file_index);
+ else
+ obj = new Sized_relobj_incr<32, false>(name, sized_ibase,
+ input_file_index);
+ }
+ break;
+#endif
+#ifdef HAVE_TARGET_32_BIG
+ case Parameters::TARGET_32_BIG:
+ {
+ Sized_incremental_binary<32, true>* sized_ibase =
+ static_cast<Sized_incremental_binary<32, true>*>(ibase);
+ if (input_type == INCREMENTAL_INPUT_SHARED_LIBRARY)
+ obj = new Sized_incr_dynobj<32, true>(name, sized_ibase,
+ input_file_index);
+ else
+ obj = new Sized_relobj_incr<32, true>(name, sized_ibase,
+ input_file_index);
+ }
+ break;
+#endif
+#ifdef HAVE_TARGET_64_LITTLE
+ case Parameters::TARGET_64_LITTLE:
+ {
+ Sized_incremental_binary<64, false>* sized_ibase =
+ static_cast<Sized_incremental_binary<64, false>*>(ibase);
+ if (input_type == INCREMENTAL_INPUT_SHARED_LIBRARY)
+ obj = new Sized_incr_dynobj<64, false>(name, sized_ibase,
+ input_file_index);
+ else
+ obj = new Sized_relobj_incr<64, false>(name, sized_ibase,
+ input_file_index);
+ }
+ break;
+#endif
+#ifdef HAVE_TARGET_64_BIG
+ case Parameters::TARGET_64_BIG:
+ {
+ Sized_incremental_binary<64, true>* sized_ibase =
+ static_cast<Sized_incremental_binary<64, true>*>(ibase);
+ if (input_type == INCREMENTAL_INPUT_SHARED_LIBRARY)
+ obj = new Sized_incr_dynobj<64, true>(name, sized_ibase,
+ input_file_index);
+ else
+ obj = new Sized_relobj_incr<64, true>(name, sized_ibase,
+ input_file_index);
+ }
+ break;
+#endif
+ default:
+ gold_unreachable();
+ }
+
+ gold_assert(obj != NULL);
+ return obj;
+}
+
+// Copy the unused symbols from the incremental input info.
+// We need to do this because we may be overwriting the incremental
+// input info in the base file before we write the new incremental
+// info.
+void
+Incremental_library::copy_unused_symbols()
+{
+ unsigned int symcount = this->input_reader_->get_unused_symbol_count();
+ this->unused_symbols_.reserve(symcount);
+ for (unsigned int i = 0; i < symcount; ++i)
+ {
+ std::string name(this->input_reader_->get_unused_symbol(i));
+ this->unused_symbols_.push_back(name);
+ }
+}
+
+// Iterator for unused global symbols in the library.
+void
+Incremental_library::do_for_all_unused_symbols(Symbol_visitor_base* v) const
+{
+ for (Symbol_list::const_iterator p = this->unused_symbols_.begin();
+ p != this->unused_symbols_.end();
+ ++p)
+ v->visit(p->c_str());