From cb29561284eaa37c5c8967e49a5db0a4064368bf Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 2 Jan 2008 23:48:49 +0000 Subject: Reduce the number of system calls. Use readv instead of pread. Do better handling of cached views. --- gold/object.h | 67 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 24 deletions(-) (limited to 'gold/object.h') diff --git a/gold/object.h b/gold/object.h index f5e4ab6..e4140be 100644 --- a/gold/object.h +++ b/gold/object.h @@ -139,10 +139,10 @@ class Object off_t offset = 0) : name_(name), input_file_(input_file), offset_(offset), shnum_(-1U), is_dynamic_(is_dynamic), target_(NULL) - { } + { input_file->file().add_object(); } virtual ~Object() - { } + { this->input_file_->file().remove_object(); } // Return the name of the object as we would report it to the tuser. const std::string& @@ -294,6 +294,37 @@ class Object View view(Location loc) { return View(this->get_view(loc.file_offset, loc.data_size, true)); } + // Get a view into the underlying file. + const unsigned char* + get_view(off_t start, section_size_type size, bool cache) + { + return this->input_file()->file().get_view(start + this->offset_, size, + cache); + } + + // Get a lasting view into the underlying file. + File_view* + get_lasting_view(off_t start, section_size_type size, bool cache) + { + return this->input_file()->file().get_lasting_view(start + this->offset_, + size, cache); + } + + // Read data from the underlying file. + void + read(off_t start, section_size_type size, void* p) const + { this->input_file()->file().read(start + this->offset_, size, p); } + + // Read multiple data from the underlying file. + void + read_multiple(const File_read::Read_multiple& rm) + { this->input_file()->file().read_multiple(this->offset_, rm); } + + // Stop caching views in the underlying file. + void + clear_view_cache_marks() + { this->input_file()->file().clear_view_cache_marks(); } + protected: // Read the symbols--implemented by child class. virtual void @@ -342,27 +373,6 @@ class Object input_file() const { return this->input_file_; } - // Get a view into the underlying file. - const unsigned char* - get_view(off_t start, section_size_type size, bool cache) - { - return this->input_file()->file().get_view(start + this->offset_, size, - cache); - } - - // Get a lasting view into the underlying file. - File_view* - get_lasting_view(off_t start, section_size_type size, bool cache) - { - return this->input_file()->file().get_lasting_view(start + this->offset_, - size, cache); - } - - // Read data from the underlying file. - void - read(off_t start, section_size_type size, void* p) const - { this->input_file()->file().read(start + this->offset_, size, p); } - // Set the target. void set_target(int machine, int size, bool big_endian, int osabi, @@ -1206,7 +1216,7 @@ class Sized_relobj : public Relobj // Write section data to the output file. Record the views and // sizes in VIEWS for use when relocating. void - write_sections(const unsigned char* pshdrs, Output_file*, Views*) const; + write_sections(const unsigned char* pshdrs, Output_file*, Views*); // Relocate the sections in the output file. void @@ -1229,6 +1239,15 @@ class Sized_relobj : public Relobj const Stringpool_template*, const Stringpool_template*); + // Clear the local symbol information. + void + clear_local_symbols() + { + this->local_values_.clear(); + this->local_got_offsets_.clear(); + this->local_tls_got_offsets_.clear(); + } + // The GOT offsets of local symbols. This map also stores GOT offsets // for tp-relative offsets for TLS symbols. typedef Unordered_map Local_got_offsets; -- cgit v1.1