> > It seems that the whole m_item array should probably be replaced by
> > summary. I think only reason it is written this way is since the code
> > predates summaries.
> >
> > This seems like a symtom of a bug where m_item is not correctly updated
> > with the result of symbol merging which may end up with mixing up
> > sem_item from one body and apply it to another...
> >
> > Honza
>
> Merging seems to behave correctly. We correctly remove body of weak
> symbol, we just never marked it with body_removed.
>
> ---
>
> During LTO symbol merging, weak symbols may be resolved to external
> definition.
> We reset the symbol, so the body might be released in unreachability
> pass. But we didn't mark the symbol with body_removed, so ICF assumed
> the body was still there causing SegFault.
>
> gcc/lto/ChangeLog:
>
> * lto-symtab.cc (lto_symtab_merge_symbols): Set body_removed
> for symbols resolved outside of IR.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.dg/lto/attr-weakref-2_0.c: New test.
> * gcc.dg/lto/attr-weakref-2_1.c: New test.
OK,
thanks!
Honza