Summary: | missing optimization: unused strings not deleted | ||
---|---|---|---|
Product: | binutils | Reporter: | Rafael Ávila de Espíndola <rafael> |
Component: | gold | Assignee: | Rafael Ávila de Espíndola <rafael> |
Status: | ASSIGNED --- | ||
Severity: | normal | CC: | ccoutant, emaste, ian, jsweval, peron.clem, sourceware |
Priority: | P2 | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Attachments: | testcase |
I am working on a patch. Hi, Any Progress ? I made an ugly path to put each string in an unique section, .rodata.str1.__hash__ it's working fine but string merging is impossible except if the strings are identical. I think group strings depending on the function, like for .text sections could be a good idea. Good luck, Clement (In reply to Clément Péron from comment #2) > Hi, > > Any Progress ? > > I made an ugly path to put each string in an unique section, > .rodata.str1.__hash__ > > it's working fine but string merging is impossible except if the strings are > identical. > > I think group strings depending on the function, like for .text sections > could be a good idea. I have a wip patch up for comments. I have split various cleanup that also speed up --gc-sections. Most of these are already in. |
Created attachment 8090 [details] testcase The attached testcase has a 3 strings: "foo", "bar", "bar". Only "foo" is used. Run $ gcc -c test.s $ ld test.o -o test.so --shared --gc-sections --icf=safe -O3 $ readelf -x .rodata test.so Hex dump of section '.rodata': 0x000001e8 62617200 666f6f00 bar.foo. Note that gold merges the two "bar" entries, but fails to notice it can drop it completely.