diff options
Diffstat (limited to 'gold/fileread.cc')
-rw-r--r-- | gold/fileread.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gold/fileread.cc b/gold/fileread.cc index 8c2f8f34cf3..72abd6bc2ed 100644 --- a/gold/fileread.cc +++ b/gold/fileread.cc @@ -191,6 +191,19 @@ File_read::release() this->released_ = true; } +// Claim the file for a plugin. This effectively releases the file without +// closing it; the plugin will assume responsibility for closing it. + +void +File_read::claim_for_plugin() +{ + gold_assert(this->is_locked()); + claim_descriptor_for_plugin(this->descriptor_); + this->descriptor_ = -1; + this->is_descriptor_opened_ = false; + this->released_ = true; +} + // Lock the file. void @@ -355,6 +368,16 @@ File_read::make_view(off_t start, section_size_type size, { gold_assert(size > 0); + // Check that start and end of the view are within the file. + if (start > this->size_ + || (static_cast<unsigned long long>(size) + > static_cast<unsigned long long>(this->size_ - start))) + gold_fatal(_("%s: attempt to map %lld bytes at offset %lld exceeds " + "size of file; the file may be corrupt"), + this->filename().c_str(), + static_cast<long long>(size), + static_cast<long long>(start)); + off_t poff = File_read::page_offset(start); section_size_type psize = File_read::pages(size + (start - poff)); |