+// Mips_output_section_options methods.
+
+template<int size, bool big_endian>
+void
+Mips_output_section_options<size, big_endian>::do_write(Output_file* of)
+{
+ off_t offset = this->offset();
+ const section_size_type oview_size =
+ convert_to_section_size_type(this->data_size());
+ unsigned char* view = of->get_output_view(offset, oview_size);
+ const unsigned char* end = view + oview_size;
+
+ while (view + 8 <= end)
+ {
+ unsigned char kind = elfcpp::Swap<8, big_endian>::readval(view);
+ unsigned char sz = elfcpp::Swap<8, big_endian>::readval(view + 1);
+ if (sz < 8)
+ {
+ gold_error(_("Warning: bad `%s' option size %u smaller "
+ "than its header in output section"),
+ this->name(), sz);
+ break;
+ }
+
+ // Only update ri_gp_value (GP register value) field of ODK_REGINFO entry.
+ if (this->target_->is_output_n64() && kind == elfcpp::ODK_REGINFO)
+ elfcpp::Swap<size, big_endian>::writeval(view + 32,
+ this->target_->gp_value());
+ else if (kind == elfcpp::ODK_REGINFO)
+ elfcpp::Swap<size, big_endian>::writeval(view + 28,
+ this->target_->gp_value());
+
+ view += sz;
+ }
+
+ of->write_output_view(offset, oview_size, view);
+}
+