This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Fix bug when optimizing string pools of aligned strings.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1c582fe71858efabae951c5f3ed7dccfb23fb86e

commit 1c582fe71858efabae951c5f3ed7dccfb23fb86e
Author: Cary Coutant <ccoutant@gmail.com>
Date:   Sat Mar 21 21:09:46 2015 -0700

    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:
---
 gold/ChangeLog     | 6 ++++++
 gold/stringpool.cc | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index d65c555..cc0aed3 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,11 @@
 2015-03-21  Cary Coutant  <cary@google.com>
 
+	PR gold/18010
+	* stringpool.cc (Stringpool_template): Don't optimize if section
+	alignment is greater than sizeof(char).
+
+2015-03-21  Cary Coutant  <cary@google.com>
+
 	PR gold/18048
 	* script-c.h (script_include_directive): Add first_token parameter.
 	* script.cc (script_include_directive): Add first_token parameter, and
diff --git a/gold/stringpool.cc b/gold/stringpool.cc
index c6d3c9b..d6fd715 100644
--- a/gold/stringpool.cc
+++ b/gold/stringpool.cc
@@ -39,7 +39,9 @@ Stringpool_template<Stringpool_char>::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;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]