Does weak work on PPC with -O2?

H . J . Lu hjl@gnu.org
Mon Mar 12 08:51:00 GMT 2001


On Sun, Mar 11, 2001 at 10:28:30PM -0800, 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.

Does gcc keep the record if a variable is weak? Since ia32 is not
affected and it is the only platform I have access to, I don't think
I will spend much of my time on it. In any case, it is a serious bug,
at least under Linux since we depend on it.

> > BTW, if gcc cannot do it right, shouldn't it issue a warning instead
> > of generating incorrect code?
> 
> That would be as hard as getting it right.
> 

When undefined weak symbol is used, its address will be taken almost
99.9% of time.

-- 
H.J. Lu (hjl@gnu.org)



More information about the Gcc-bugs mailing list