The Go backend interfaces uses immutable structs for things like type descriptors, map descriptors, and function descriptors. These objects must always be created for exported names in case they are referenced by a different package, but this often does not happen. This patch moves them to unique sections so that linker GC can discard them a link time. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.8 branch.
Ian 2013-08-02 Ian Lance Taylor <i...@google.com> * go-gcc.cc (immutable_struct_set_init): Always call resolve_unique_section.
Index: go-gcc.cc =================================================================== --- go-gcc.cc (revision 201222) +++ go-gcc.cc (working copy) @@ -1521,10 +1521,11 @@ Gcc_backend::immutable_struct_set_init(B TREE_PUBLIC(decl) = 1; } else - { - make_decl_one_only(decl, DECL_ASSEMBLER_NAME(decl)); - resolve_unique_section(decl, 1, 0); - } + make_decl_one_only(decl, DECL_ASSEMBLER_NAME(decl)); + + // These variables are often unneeded in the final program, so put + // them in their own section so that linker GC can discard them. + resolve_unique_section(decl, 1, 1); rest_of_decl_compilation(decl, 1, 0); }