This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: libffi & powerpc
[top-posting fixed]
Patrick Olinet writes:
> On 5/8/07, Andrew Haley <aph-gcc@littlepinkcloud.com> wrote:
> > Patrick Olinet writes:
> > > Hi there,
> > >
> > > I'm running an embedded platform based on a powerpc 405EP CPU and a
> > > gcc 4.1.0 cross-toolchain. My initial problem was that gcj compiled
> > > binaries crash at runtime when interpreting java bytecode ("Illegal
> > > instruction" message).
> > >
> > > After many investigations, it looks like the problem comes from the
> > > libffi library : I've run the libffi testsuite on my embedded paltform
> > > and many of the tests show the same "Illegal instruction" message. For
> > > instance, the "cls_uint" test crashes at the following line (from the
> > > cls_uint.c file) :
> > >
> > > res = (*((cls_ret_uint)pcl))(2147483647);
...
> > > Any ideas or thoughts about this problem ?
> >
> > Run it in gdb. When gdb stops with SIGILL, do
> >
> > x/i $pc
> >
> Running with gdb, it looks like the problem comes from the
> ppc_closure.S file of the libffi/src/powerpc directory, at line 32 :
>
> stfd %f1, 48(%r1)
>
> I don't understand anything to powerpc assembly, but after a google
> search, "stfd" means "store floating-point double". But the PPC405
> doesn't have any FPU, so I guess that's why it throws an "illegal
> instruction".
I agree.
> I've compiled again my cross toolchain with the "--with-float=soft"
> option, hoping that it would emulate FPU instruction, but this
> unfortunately doesn't help... I'm nevertheless not sure that this
> option is the right one...
>
> Any thoughts ? Is there a bug in libffi in that it doesn't support
> powerpc CPU without FPU ?
Yes. Still, it should be easy enough to fix. Perhaps a few days'
work for a person with some expertise in this area.
The issue is this: how are soft-fp floating-point arguments passed?
Without knowing that we have no way to proceed. It might be as simple
as setting NUM_FPR_ARG_REGISTERS (in powerpc/ffi.c) to zero, or it
might be more difficult than that.
If you don't understand ppc assembly, this would be the time to learn.
Andrew.