Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 18 Oct 2011 13:19:57 +0400
From: Vasiliy Kulikov <segoon@...nwall.com>
To: owl-dev@...ts.openwall.com
Subject: Re: gcc 4.6.1: glibc __sincos() issue

On Tue, Oct 18, 2011 at 02:44 +0200, Pavel Kankovsky wrote:
> On Mon, 17 Oct 2011, Vasiliy Kulikov wrote:
> 
> > After building gcc 4.6.1 and making glibc compilable there is one error.
> > Groff's "pic" built with glibc built with gcc 4.6.1 calls __sincos and
> > goes into infinite __sincos recursion:
> > [...]
> > 
> > callq at _init+40 is a call to __sincos().
> > 
> > In the source file (./sysdeps/ieee754/dbl-64/s_sincos.c):
> > 
> >     void
> >     __sincos (double x, double *sinx, double *cosx)
> >     {
> >         [...]
> >         {
> >           *sinx = sin (x);
> >           *cosx = cos (x);
> >         }
> >     }
> >     weak_alias (__sincos, sincos)
> > 
> > 
> > So, it is an optimised call to sin() and cos(), which is optimised to
> > call to __sincos().  However, I cannot understand how it can happen as
> > sin() and cos() are defined in ./sysdeps/ieee754/dbl-64/s_sin.c as
> > following:
> 
> GCC thinks the architecture provides its native sincos() and transforms
> "*sinx = sin (x); *cosx = cos (x);" to "sincos (x, *sinx, *cosx);"
> See <http://gcc.gnu.org/ml/gcc-patches/2006-12/msg00499.html> and
> <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46926>.
> 
> But Glibc is built WITHOUT native sincos()! It should be implemented
> by an FPU instructions (fsincos) (*) but what we get is generic C code--
> that calls itself when compiled with the aformentioned optimization. This
> is WRONG! The ancient version of Glibc is to blame here:
> sysdeps/x86_64/fpu/s_sincos.S was introduced in 2.5.
> 
> You can either add the missing native implementation of sincos()
> or compile Glibc with -fno-native-sincos to disable the optimization.

Great! -fno-builtin is the solution (-fno-builtin-sincos doesn't work,
probably need -sin or -cos or both).  Now I'll try to solve i686
cfi_endproc problem.


Thank you!

-- 
Vasiliy

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.