diff options
author | Cary Coutant <ccoutant@google.com> | 2013-04-29 17:15:09 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2013-04-29 17:15:09 +0000 |
commit | e31908b642bf3602c06fe64ab574a865307e45b0 (patch) | |
tree | 10a5d3ebaad183647e9da9ef874b2fc7fed3aa9a /gold/stringpool.cc | |
parent | 5dad867ccace0a74c90b729372c9c01392756875 (diff) | |
download | gdb-e31908b642bf3602c06fe64ab574a865307e45b0.zip gdb-e31908b642bf3602c06fe64ab574a865307e45b0.tar.gz gdb-e31908b642bf3602c06fe64ab574a865307e45b0.tar.bz2 |
2013-04-29 Alexander Ivchenko <alexander.ivchenko@intel.com>
gold/
* output.cc (Output_section::add_merge_input_section): Allow
to merge sections if the alignment is more than character size.
* merge.h (Output_merge_string::Output_merge_string): Remove
assert.
* merge.cc (Output_merge_string<Char_type>::do_add_input_section): Count
only not-null strings. Check the alignment of strings.
* stringpool.h
(Stringpool_template<Stringpool_char>::Stringpool_template): Add
alignment as the argument.
(Stringpool_template<Stringpool_char>::addralign_): New class member.
* stringpool.cc (Stringpool_template<Stringpool_char>::new_key_offset):
Align non-zero length strings according to the addralign_.
(Stringpool_template<Stringpool_char>::set_string_offsets):
Updating offsets according to the given alignment.
* testsuite/Makefile.am (text_section_grouping): Test if string
literals are getting merged.
* testsuite/Makefile.in: Regenerate.
* testsuite/merge_string_literals_1.c: New file.
* testsuite/merge_string_literals_2.c: Ditto.
* testsuite/merge_string_literals.sh: Ditto.
Diffstat (limited to 'gold/stringpool.cc')
-rw-r--r-- | gold/stringpool.cc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/gold/stringpool.cc b/gold/stringpool.cc index 434b2d6..072b00d 100644 --- a/gold/stringpool.cc +++ b/gold/stringpool.cc @@ -34,9 +34,10 @@ namespace gold { template<typename Stringpool_char> -Stringpool_template<Stringpool_char>::Stringpool_template() +Stringpool_template<Stringpool_char>::Stringpool_template(uint64_t addralign) : string_set_(), key_to_offset_(), strings_(), strtab_size_(0), - zero_null_(true), optimize_(false), offset_(sizeof(Stringpool_char)) + zero_null_(true), optimize_(false), offset_(sizeof(Stringpool_char)), + addralign_(addralign) { if (parameters->options_valid() && parameters->options().optimize() >= 2) this->optimize_ = true; @@ -221,8 +222,10 @@ Stringpool_template<Stringpool_char>::new_key_offset(size_t length) offset = 0; else { - offset = this->offset_; - this->offset_ += (length + 1) * sizeof(Stringpool_char); + // Align non-zero length strings. + if (length != 0) + offset = align_address(this->offset_, this->addralign_); + this->offset_ = offset + (length + 1) * sizeof(Stringpool_char); } this->key_to_offset_.push_back(offset); } @@ -421,8 +424,8 @@ Stringpool_template<Stringpool_char>::set_string_offsets() * charsize)); else { - this_offset = offset; - offset += ((*curr)->first.length + 1) * charsize; + this_offset = align_address(offset, this->addralign_); + offset = this_offset + ((*curr)->first.length + 1) * charsize; } this->key_to_offset_[(*curr)->second - 1] = this_offset; last_offset = this_offset; |