This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Miscompilation of glibc with CVS mainline


> On Thu, Jan 02, 2003 at 02:16:01PM +0100, Andreas Jaeger wrote:
> > I could reproduce this with a simple hello-world program and also with
> > some smaller program, it is indeed a bug in handling of weak extern
> > functions.
> > 
> > Here's a small testcase that has the same behaviour:
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > extern void weak_func (void *arg);
> > asm (".weak weak_func");
> > 
> > void
> > test (void *arg)
> > {
> >   if (&weak_func != (void *)0)
> >     weak_func (arg);
> >   
> > }
> 
> As GCC is not told in any way that weak_func is actually weak, I think
> it is glibc's fault.

This is definitely a gcc problem.  This is the code arising from
Andreas' testcase for hppa-linux at -O2:

        stw %r2,-20(%r30)
	ldo 64(%r30),%r30
	ldw -84(%r30),%r2
	bl weak_func,%r0
	ldo -64(%r30),%r30

We have completely lost the `if'.  As a result, weak_func is always
called.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]