Does weak work on PPC with -O2?

Franz Sirl Franz.Sirl-kernel@lauterbach.com
Mon Mar 12 14:17:00 GMT 2001


On Monday 12 March 2001 07:28, Geoff Keating wrote:
> > Date: Sun, 11 Mar 2001 21:14:03 -0800
> > From: "H . J . Lu" <hjl@gnu.org>
> > Cc: gcc-bugs@gcc.gnu.org
> >
> > Well, undefined weak symbol has a well defined semantics. Glibc
> > uses undefined weak symbol. I don't believe glibc is the only
> > package which uses it. It sounds a serious bug to me. Fortunately,
> > it works on ia32 "by accident".
>
> Feel free to fix it.  A good fix would be to detect that the
> variable is weak and then permitting such references to trap; that
> would fix both the performance and the correctness problem.

Well, contrary to my first believe the fix might be really simple, AFAICS the 
relevant piece of code is in make_decl_rtl in varasm.c, or? If we set the RTX 
VOLATILE flag (which is so far unused for SYMBOL_REF) for DECL_WEAK symbols, 
we should be set. Then we can just test SYMBOL_REF_WEAK at the relevant 
places (there are some places where some less important optimizations are 
explicitly disabled because of the weak symbol problem) and be happy. Or are 
there any pitfalls in this simple plan? There must be, or why wasn't it fixed 
til now?

Naturally the same has to be done for weak LABEL_REF's, too.

Franz.



More information about the Gcc-bugs mailing list