{
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;
else
{
offset = this->offset_;
- this->offset_ += (length + 1) * sizeof(Stringpool_char);
+ // Align non-zero length strings.
+ if (length != 0)
+ offset = align_address(offset, this->addralign_);
+ this->offset_ = offset + (length + 1) * sizeof(Stringpool_char);
}
this->key_to_offset_.push_back(offset);
}
* 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;