https://gcc.gnu.org/bugzilla/show_bug.cgi?id=192
--- Comment #11 from Matt Whitlock <gcc at mattwhitlock dot name> --- Created attachment 35479 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35479&action=edit put string literals into unique sections when -fmerge-constants -fdata-sections This patch puts each string literal into a (probably) unique section when compiling with -fmerge-constants -fdata-sections. The section name is constructed from the character width and string alignment (as before) plus a 32-bit hash of the string contents. Consider the following program: void used() { puts("keep me"); puts("common"); puts("string"); puts("tail"); } void not_used() { puts("toss me"); puts("common"); puts("ring"); puts("entail"); } int main() { used(); return 0; } $ gcc -ffunction-sections -fdata-sections -fmerge-constants \ -Wl,--gc-sections -o test test.c Compiling with an unpatched GCC produces a binary whose .rodata contains: 40061d 6b656570 206d6500 636f6d6d 6f6e0073 keep me.common.s 40062d 7472696e 6700746f 7373206d 6500656e tring.toss me.en 40063d 7461696c 00 tail. Compiling with a patched GCC produces a binary whose .rodata contains: 40061d 6b656570 206d6500 636f6d6d 6f6e0073 keep me.common.s 40062d 7472696e 67007461 696c00 tring.tail.