http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46319
--- Comment #8 from Dave Korn <davek at gcc dot gnu.org> 2010-11-08 04:52:12 UTC --- The generated source file selfassign.so.ltrans0.s (and hence also the object file selfassign.so.ltrans0.ltrans.o) file which gets created when lto-plugin invokes lto1 on the original input selfassign.o file has no contents. This appears to be because plugin_init in selfassign.c isn't marked with __attribute__((externally_visible)), and the resolution file marks it as PREVAILING_DEF_IRONLY. WPA then concludes that everything can be made static, nothing is referenced, and discards the lot. The consequence of this is that the object file that the pluging then adds back into the link has no contents, so it doesn't override the symbol definitions supplied from the IR when it first claimed the input selfassign.o file. It works with GOLD because GOLD thinks the plugin's external symbols are PREVAILING_DEF, not PREVAILING_DEF_IRONLY. This is the resolution file that the lto-plugin writes based on what LD tells it at all_symbols_read time: 1 selfassign.o 27 5072 e2eb6ce9 PREVAILING_DEF_IRONLY plugin_init 5105 e2eb6ce9 UNDEF tree_check_failed 5114 e2eb6ce9 UNDEF tree_class_check_failed 5148 e2eb6ce9 UNDEF fancy_abort 5155 e2eb6ce9 UNDEF gimple_check_failed 5165 e2eb6ce9 UNDEF gimple_assign_single_p 5169 e2eb6ce9 UNDEF tree_contains_struct_check_failed 5253 e2eb6ce9 UNDEF build4_stat 5262 e2eb6ce9 UNDEF tree_operand_check_failed 5271 e2eb6ce9 UNDEF fold_build2_stat_loc 5279 e2eb6ce9 UNDEF build3_stat 5287 e2eb6ce9 UNDEF warning_at 5302 e2eb6ce9 UNDEF operand_equal_p 5308 e2eb6ce9 UNDEF maybe_get_identifier 5312 e2eb6ce9 UNDEF integer_zerop 5314 e2eb6ce9 UNDEF register_callback 5324 e2eb6ce9 UNDEF warning 5351 e2eb6ce9 UNDEF plugin_default_version_check 5494 e2eb6ce9 PREVAILING_DEF_IRONLY check_operator_eq 5536 e2eb6ce9 PREVAILING_DEF_IRONLY plugin_is_GPL_compatible 5433 e2eb6ce9 UNDEF tree_code_type 5442 e2eb6ce9 UNDEF tree_code_length 5452 e2eb6ce9 UNDEF gss_for_code_ 5457 e2eb6ce9 UNDEF gimple_ops_offset_ 5471 e2eb6ce9 UNDEF tree_contains_struct 5486 e2eb6ce9 UNDEF input_location 5502 e2eb6ce9 UNDEF cfun ... and here is the one generated when the plugin is loaded into GOLD: 1 selfassign.o 27 5072 e2eb6ce9 PREVAILING_DEF plugin_init 5105 e2eb6ce9 UNDEF tree_check_failed 5114 e2eb6ce9 UNDEF tree_class_check_failed 5148 e2eb6ce9 UNDEF fancy_abort 5155 e2eb6ce9 UNDEF gimple_check_failed 5165 e2eb6ce9 UNDEF gimple_assign_single_p 5169 e2eb6ce9 UNDEF tree_contains_struct_check_failed 5253 e2eb6ce9 UNDEF build4_stat 5262 e2eb6ce9 UNDEF tree_operand_check_failed 5271 e2eb6ce9 UNDEF fold_build2_stat_loc 5279 e2eb6ce9 UNDEF build3_stat 5287 e2eb6ce9 UNDEF warning_at 5302 e2eb6ce9 UNDEF operand_equal_p 5308 e2eb6ce9 UNDEF maybe_get_identifier 5312 e2eb6ce9 UNDEF integer_zerop 5314 e2eb6ce9 UNDEF register_callback 5324 e2eb6ce9 UNDEF warning 5351 e2eb6ce9 UNDEF plugin_default_version_check 5494 e2eb6ce9 PREVAILING_DEF check_operator_eq 5536 e2eb6ce9 PREVAILING_DEF plugin_is_GPL_compatible 5433 e2eb6ce9 UNDEF tree_code_type 5442 e2eb6ce9 UNDEF tree_code_length 5452 e2eb6ce9 UNDEF gss_for_code_ 5457 e2eb6ce9 UNDEF gimple_ops_offset_ 5471 e2eb6ce9 UNDEF tree_contains_struct 5486 e2eb6ce9 UNDEF input_location 5502 e2eb6ce9 UNDEF cfun