This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Miscompilation of glibc with CVS mainline
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gcc at gcc dot gnu dot org, libc-alpha at sources dot redhat dot com
- Date: Thu, 2 Jan 2003 12:57:18 -0500
- Subject: Re: Miscompilation of glibc with CVS mainline
- References: <200301021748.h02HmOnf010840@hiauly1.hia.nrc.ca>
On Thu, Jan 02, 2003 at 12:48:23PM -0500, John David Anglin wrote:
> > > > 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.
>
> There is another problem. The call to weak_func has been turned into
> a sibcall. It seems that TARGET_FUNCTION_OK_FOR_SIBCALL isn't being
> consulted as we don't allow indirect sibcalls on hppa-linux.
This isn't an indirect call, though. weak_func is not a pointer...
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer