[gold] Merging string literals with bigger alignment

Alexander Ivchenko aivchenk@gmail.com
Fri Feb 8 13:21:00 GMT 2013


Hi,

Both Intel compiler and GNU compiler put string literals into special
sections: .rodata.str1.X. ICC puts literals to .rodata.str1.4 and
.rodata.str1.32. GCC puts them to .rodata.str1.1 and .rodata.str1.4.
Gold linker merges strings only from .rodata.str1.1, BFD linker
processes all sections.

Lost merging capability increased the size of the ICC+gold
libwebcore.so build in 1.5 times against the build with BFD. I believe
we can find the same results for GCC.

Also it is needed for correct inline work: when function is inlined
into two different files, string literals that this function uses will
also be put into two different object files. Therefore the inlined
body of the function will use different string literals, which doesn't
sound correct.

Seems that the only thing that blocks string literals from, say,
.rodata.str1.4 to be merged is this:

// We only merge strings if the alignment is not more than the
// character size. This could be handled, but it's unusual.
if (is_string && addralign > entsize)
return false;

I'm not sure what was the reason for this..
After deleting that check we got needed string literals merging and
all gold-check tests pass.

I also added the testcase for checking whether the string literals are
getting merged.

Could you please take a look at the attached patch?

thank you,
Alexander
-------------- next part --------------
A non-text attachment was scrubbed...
Name: merging_string_literals_1.patch
Type: application/octet-stream
Size: 10983 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20130208/2e2daf0e/attachment.obj>


More information about the Binutils mailing list