+ // Options may not yet be ready e.g. when reading a version
+ // script. We then default to --no-keep-files-mapped.
+ if (parameters->options_valid()
+ && parameters->options().keep_files_mapped())
+ {
+ const unsigned char* contents = static_cast<const unsigned char*>(
+ ::mmap(NULL, this->size_, PROT_READ, MAP_PRIVATE,
+ this->descriptor_, 0));
+ if (contents == MAP_FAILED)
+ gold_fatal(_("%s: mmap failed: %s"), this->filename().c_str(),
+ strerror(errno));
+ this->whole_file_view_ = new View(0, this->size_, contents, 0, false,
+ View::DATA_MMAPPED);
+ this->mapped_bytes_ += this->size_;
+ }
+