+// 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));
+ }
+}
+