+// Return whether this is the merge map for section SHNDX.
+
+const Output_section_data*
+Object_merge_map::find_merge_section(unsigned int shndx) const {
+ const Object_merge_map::Input_merge_map* map =
+ this->get_input_merge_map(shndx);
+ if (map == NULL)
+ return NULL;
+ return map->output_data;
+}
+
+// Initialize a mapping from input offsets to output addresses.
+
+template<int size>
+void
+Object_merge_map::initialize_input_to_output_map(
+ unsigned int shndx,
+ typename elfcpp::Elf_types<size>::Elf_Addr starting_address,
+ Unordered_map<section_offset_type,
+ typename elfcpp::Elf_types<size>::Elf_Addr>* initialize_map)
+{
+ Input_merge_map* map = this->get_input_merge_map(shndx);
+ gold_assert(map != NULL);
+
+ gold_assert(initialize_map->empty());
+ // We know how many entries we are going to add.
+ // reserve_unordered_map takes an expected count of buckets, not a
+ // count of elements, so double it to try to reduce collisions.
+ reserve_unordered_map(initialize_map, map->entries.size() * 2);
+
+ for (Input_merge_map::Entries::const_iterator p = map->entries.begin();
+ p != map->entries.end();
+ ++p)
+ {
+ section_offset_type output_offset = p->output_offset;
+ if (output_offset != -1)
+ output_offset += starting_address;
+ else
+ {
+ // If we see a relocation against an address we have chosen
+ // to discard, we relocate to zero. FIXME: We could also
+ // issue a warning in this case; that would require
+ // reporting this somehow and checking it in the routines in
+ // reloc.h.
+ output_offset = 0;
+ }
+ initialize_map->insert(std::make_pair(p->input_offset, output_offset));
+ }
+}
+
+// Class Output_merge_base.
+
+// Return the output offset for an input offset. The input address is
+// at offset OFFSET in section SHNDX in OBJECT. If we know the
+// offset, set *POUTPUT and return true. Otherwise return false.
+
+bool
+Output_merge_base::do_output_offset(const Relobj* object,
+ unsigned int shndx,
+ section_offset_type offset,
+ section_offset_type* poutput) const
+{
+ return object->merge_output_offset(shndx, offset, poutput);
+}
+
+// Record a merged input section for script processing.
+
+void
+Output_merge_base::record_input_section(Relobj* relobj, unsigned int shndx)
+{
+ gold_assert(this->keeps_input_sections_ && relobj != NULL);
+ // If this is the first input section, record it. We need do this because
+ // this->input_sections_ is unordered.
+ if (this->first_relobj_ == NULL)
+ {
+ this->first_relobj_ = relobj;
+ this->first_shndx_ = shndx;
+ }
+
+ std::pair<Input_sections::iterator, bool> result =
+ this->input_sections_.insert(Section_id(relobj, shndx));
+ // We should insert a merge section once only.
+ gold_assert(result.second);
+}
+
+// Class Output_merge_data.
+