From: Cary Coutant Date: Sun, 22 Mar 2015 04:09:46 +0000 (-0700) Subject: Fix bug when optimizing string pools of aligned strings. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1c582fe71858efabae951c5f3ed7dccfb23fb86e;p=binutils-gdb.git Fix bug when optimizing string pools of aligned strings. Tail optimization of string pools (enabled when linker is run with -O2 or greater) should not be done when the section alignment is greater than the size of the characters in the strings; otherwise, unaligned strings may result. gold/ PR gold/18010 * stringpool.cc (Stringpool_template): Don't optimize if section alignment is greater than sizeof(char). --- diff --git a/gold/ChangeLog b/gold/ChangeLog index d65c555ad5a..cc0aed32ef1 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,9 @@ +2015-03-21 Cary Coutant + + PR gold/18010 + * stringpool.cc (Stringpool_template): Don't optimize if section + alignment is greater than sizeof(char). + 2015-03-21 Cary Coutant PR gold/18048 diff --git a/gold/stringpool.cc b/gold/stringpool.cc index c6d3c9b584a..d6fd7157bf0 100644 --- a/gold/stringpool.cc +++ b/gold/stringpool.cc @@ -39,7 +39,9 @@ Stringpool_template::Stringpool_template(uint64_t addralign) zero_null_(true), optimize_(false), offset_(sizeof(Stringpool_char)), addralign_(addralign) { - if (parameters->options_valid() && parameters->options().optimize() >= 2) + if (parameters->options_valid() + && parameters->options().optimize() >= 2 + && addralign <= sizeof(Stringpool_char)) this->optimize_ = true; }