This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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: Problem with printf and float


Hello Jeppe,

I am leaving till Monday. But I would expect,
that there is really problem in with EABI parameters
passing and va_arg .The last thing to check is
that you enter main() with per EABI aligned stack.
Check how your stack is prepared in CRT0.S. Try to move
sp four bytes down before main enter to check the other
alignment case.

If this doesnot help, then problem should be in va_arg
in GCC. Other possibility is problem with bitfields,
their packing rules are in some cases different for EABI.
Not sure, if this is a case. Look for âmabi=apcs-gnu
and related stuff.

Best wishes,

            Pavel

On Wednesday 27 October 2010 11:14:57 Jeppe Ledet-Pedersen wrote:
> Hi Pavel, All,
>
> On 2010-10-26 13:57, Pavel Pisa wrote:
> > I am not expert, but your results points to to something strange
> > in GCC. Other thing which is strict for EABI is 8 bytes alignment
> > on the stack. But I am not sure if soft float arm7tdmi can be
> > influenced by this problem. I think not, because it does not
> > have 64 bit multimedia or FP registers and accesses as ARM5
> > and above. Other problem could some bug in parameters passing
> > conventions. Does the problem appears in dtoa() case as well.
>
> No, dtoa seems to work fine. I have updated my test code:
> http://pastebin.com/JGcTrjfF
>
> dtoa output: 84, decpt is 2 and sign is 1
>
> I have also tried to copy the ldieee struct (53 bit mantissa) from
> stdio/vfieeefp.h to my test code, to see if the bitfields matched. I had
> to add a packed attribute, but then I got the correct output:
>
> manl: 0
> manh: 50000000
> exp: 405
> sign: 1
>
> Adding __attribute__ ((packed)) to the bitfields in vfieeefp.h does not
> solve the problem, but it could be needed. IIRC, C does not guarantee
> anything about the layout of bitfields, so the ldieee structs could be
> part of the problem. This is further supported by the fact that dtoa,
> which does not use the structs, works.
>
> > If there are some strange problems in varargs you can try
> >
> >    printf("a is %f\r\n", a);
> >    printf("fill %ld and a is %f\r\n", 1L, a);
> >    printf("fill %ld, %ld  and a is %f\r\n", 1L, 2L, a);
> >    printf("fill %ld, %ld, %ld and a is %f\r\n", 1L, 2L, 3L, a);
> >
> > These options should push passing of "a" out from parameters
> > passed by registers.
>
> I added your suggestions to my test code and did get some weird results:
>
> Before flip:
> 00 00 00 00 00 00 55 c0
> a is 0.000000
> fill 1 and a is 3135806246969956017225324825[...]
> fill 1, 2  and a is 0.000000
> fill 1, 2, 3 and a is 31352364387915649882790342116430[...]
>
> After flip:
> 00 00 55 c0 00 00 00 00
> a flipped is -84.000000
> fill 1 and a flipped is 0.000000
> fill 1, 2  and a flipped is -84.000000
> fill 1, 2, 3 and a flipped is 313523477950794742515896974[...]
>
> > Your paste code doesnot include #include<stdio.h>.
> > Vaargs should work even for functions without declarations,
> > but I would not write code depending on that and elimination
> > of this possibility should be right step.
>
> My code does include stdio.h, so that is not the reason.
>
> > You can test with other GCC release (4.4.x) as well.
>
> Yes, I will try that.
>
> Thank you.
>
> Best regards,
> Jeppe

-- 
Yours sincerely
                Pavel Pisa

==================================================
 PiKRON s.r.o.       Phone/Fax: +420 2 84684676
 Kankovskeho 1235    Phone:     +420 2 84684676
 182 00 Praha 8      WWW:   http://www.pikron.com/
 Czech Republic      e-mail:  pikron@pikron.com
==================================================

--
For unsubscribe information see http://sourceware.org/lists.html#faq


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