gold does not appear to merge strings in .shstrtab. For example, in two_file_relocatable.o .shstrtab I see both ".rel.eh_frame" and ".eh_frame".
gold currently only merges strings in string sections if you use -O2. See the comment around line 393 of stringpool.cc. Does that make sense to you? Perhaps we should do the optimization if the string section size is small?
Subject: Bug 10133 CVSROOT: /cvs/src Module name: src Changes by: ian@sourceware.org 2009-06-23 07:04:10 Modified files: gold : ChangeLog layout.cc stringpool.cc stringpool.h Log message: PR 10133 * stringpool.h (class Stringpool_template): Add optimize_ field. (Stringpool_template::set_optimize): New function. * stringpool.cc (Stringpool_template::Stringpool_template): Initialize optimize_ field. (Stringpool_template::set_string_offsets): Test local optimize fild rather than parameter. * layout.cc (Layout::Layout): Call set_optimize on the section name stringpool. Patches: http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.244&r2=1.245 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/layout.cc.diff?cvsroot=src&r1=1.127&r2=1.128 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/stringpool.cc.diff?cvsroot=src&r1=1.28&r2=1.29 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/stringpool.h.diff?cvsroot=src&r1=1.22&r2=1.23
I committed a patch to optimize the section name pool, since that is a case where matches are likely and the string pool is normally small.