From 38c5e8b493ec72879187ffca3d8533acd2c014a5 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 18 Dec 2007 21:24:10 +0000 Subject: Print statistics about merge sections with --stats. --- gold/merge.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'gold/merge.h') diff --git a/gold/merge.h b/gold/merge.h index a649321..056c2c6 100644 --- a/gold/merge.h +++ b/gold/merge.h @@ -108,9 +108,11 @@ class Output_merge_data : public Output_merge_base public: Output_merge_data(uint64_t entsize, uint64_t addralign) : Output_merge_base(entsize, addralign), p_(NULL), len_(0), alc_(0), + input_count_(0), hashtable_(128, Merge_data_hash(this), Merge_data_eq(this)) { } + protected: // Add an input section. bool do_add_input_section(Relobj* object, unsigned int shndx); @@ -127,6 +129,10 @@ class Output_merge_data : public Output_merge_base void do_write_to_buffer(unsigned char*); + // Print merge stats to stderr. + void + do_print_merge_stats(const char* section_name); + private: // We build a hash table of the fixed-size constants. Each constant // is stored as a pointer into the section data we are accumulating. @@ -197,6 +203,8 @@ class Output_merge_data : public Output_merge_base section_size_type len_; // The size of the allocated buffer. section_size_type alc_; + // The number of entries seen in input files. + size_t input_count_; // The hash table. Merge_data_hashtable hashtable_; }; @@ -210,7 +218,7 @@ class Output_merge_string : public Output_merge_base public: Output_merge_string(uint64_t addralign) : Output_merge_base(sizeof(Char_type), addralign), stringpool_(), - merged_strings_() + merged_strings_(), input_count_(0) { gold_assert(addralign <= sizeof(Char_type)); this->stringpool_.set_no_zero_null(); @@ -238,6 +246,10 @@ class Output_merge_string : public Output_merge_base void do_write_to_buffer(unsigned char*); + // Print merge stats to stderr. + void + do_print_merge_stats(const char* section_name); + // Writes the stringpool to a buffer. void stringpool_to_buffer(unsigned char* buffer, section_size_type buffer_size) @@ -249,6 +261,10 @@ class Output_merge_string : public Output_merge_base { this->stringpool_.clear(); } private: + // The name of the string type, for stats. + const char* + string_name(); + // As we see input sections, we build a mapping from object, section // index and offset to strings. struct Merged_string @@ -279,6 +295,8 @@ class Output_merge_string : public Output_merge_base // Map from a location in an input object to an entry in the // Stringpool. Merged_strings merged_strings_; + // The number of entries seen in input files. + size_t input_count_; }; } // End namespace gold. -- cgit v1.1