http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45375
--- Comment #81 from Jan Hubicka <hubicka at gcc dot gnu.org> 2011-04-11 11:13:32 UTC --- Sorry, firefox concluded I want to save changes when I didn't ;) The problem is function Elf_Ehdr::serialize(std::basic_ofstream<char, std::char_traits<char> >&, char, char) What I see is that this function is defined several times in the unmerged cgraph (i.e. it is comdat inline coming from different .o files) and _some_ of the definitions calls swap function that is not defined, while other definitions calls swap function that is defined. In your build the one that calls undefined swap wins resulting in final link error. I am not sure if this is GCC bug or elfhack, but I would guess for elfhack actually. This is whole bit tricky since the COMDAT hack comes into game here: GCC is not telling linker in the LTO symtab about COMDATs for inline functions when their address is not taken since they should be defined in every unit that needs them. It is not the case here. I think either SWAP should be keyed in one of the units that it is apparently not: swap/622(-1) @0x7f4d15d34000 (asm: _ZN18Elf_RelHack_Traits4swapI10big_endian9Elf32_Rel12serializableIS_EEEvRT1_RT0_) analyzed 19 time, 16 benefit 31 size, 8 benefit externally_visible finalized inlinable called by: serialize/623 (0.65 per call) serialize/623 (0.25 per call) calls: __builtin_constant_p/466 (1.00 per call) __builtin_constant_p/466 (1.00 per call) References: Refering this function: (other defs looks like) swap/825(-1) @0x7f4d15d466e0 (asm: _ZN15Elf_Ehdr_Traits4swapI10big_endian10Elf32_Ehdr12serializableIS_EEEvRT1_RT0_) undef called by: serialize/595 (0.25 per call) (can throw external) calls: References: Refering this function: Or this is some source level bug. I.e. one unit just forward declaring the function while other defining it as comdat inline that is probably violation of one declaration rule. Would be possible for you to look into preprocessed source files of elfhack and see what units define the serialize function and among those how the swap defintions look like? We probably could make lto-symtab to not give up on seeing Undef resolution from linker in these cases, but I would rather avoid pilling up hacks around this COMDAT mess. Honza