PPC bug when handling double
Aaron R
aaronr.mb@gmail.com
Sat Aug 1 15:59:00 GMT 2015
Hi,
I am not very familiar with libffi but I believe I may have stumbled upon a bug.
If you build the attached test code, you will get two test programs -
namely, ex1 and ex2. The only difference between the two is
'-D__USE_F6__' , which passes the last parameter of test_func1() as a
float instead of a double. I have tried these test programs on both
X86 and PPC (32-bit in both cases) using libffi 3.2.1. I did not use
any special configure flags when I built libffi 3.2.1 for both
platforms.
This is what I get on X86:
$ ./ex1
args_idx = 12
tst_func1 : 0xa 0xb 11.100000 12.1 13.100000 14.1 15.100000 16.1
17.100000 18.1 19.100000 20.100000
rc = 1 - success? Y
$ ./ex2
args_idx = 12
tst_func1 : 0xa 0xb 11.100000 12.1 13.100000 14.1 15.100000 16.1
17.100000 18.1 19.100000 20.1
rc = 1 - success? Y
That looks fine. The last parameter is always 20.1.
If I run the same code on PPC I get:
$ uname -a
Linux tstsrv 3.0.101-0.47.52-ppc64 #1 SMP Thu Mar 26 10:55:49 UTC 2015
(0e3c7c8) ppc64 ppc64 ppc64 GNU/Linux
$ file ./ppc/libffi_3.2.1/lib/libffi.so.6.0.4
./ppc/libffi_3.2.1/lib/libffi.so.6.0.4: ELF 32-bit MSB shared object,
PowerPC or cisco 4500, version 1 (SYSV), dynamically linked, not
stripped
$ gcc -dumpversion
4.3
$ ./ex1
args_idx = 12
tst_func1 : 0xa 0xb 11.100000 12.1 13.100000 14.1 15.100000 16.1
17.100000 18.1 19.100000 20.100000
rc = 1 - success? Y
$ ./ex2
args_idx = 12
tst_func1 : 0xa 0xb 11.100000 12.1 13.100000 14.1 15.100000 16.1
17.100000 18.1 19.100000 -2.35344e-185
rc = 0 - success? N
You can see above that the last parameter printed by tst_func1() is
incorrect in the case of ex2 (i.e., when passed as a double).
Any idea?
Thanks in advance
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex.c
Type: text/x-csrc
Size: 3794 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libffi-discuss/attachments/20150801/c0f3e8cd/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: application/octet-stream
Size: 710 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libffi-discuss/attachments/20150801/c0f3e8cd/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: trg.c
Type: text/x-csrc
Size: 1246 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libffi-discuss/attachments/20150801/c0f3e8cd/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: trg.h
Type: text/x-chdr
Size: 347 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libffi-discuss/attachments/20150801/c0f3e8cd/attachment-0002.bin>
More information about the Libffi-discuss
mailing list