diff options
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; |