[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: gcc 2.7.2.1 problem on PPC, does it apply to *BSD ?
- To: tech@openbsd.org
- Subject: FYI: gcc 2.7.2.1 problem on PPC, does it apply to *BSD ?
- From: Matthieu Herrb <matthieu@laas.fr>
- Date: Sat, 13 Dec 1997 11:27:56 +0100 (MET)
Hi,
doing work totally unrelated to OpenBSD, I found the following problem
with the GNU toolchain used by VxWorks on PowerPC. I checked that the
GNU gcc 2.7.2.1 configured for target=ppc-eabi also have the
problem. egcs 1.0 doesn't.
Does this also exist on OpenBSD (or any other free OS on PowerPC
machines using gcc ?) or is it only the Embedded ABI which shows the
problem ?
| From: Matthieu Herrb <matthieu@laas.fr>
| Newsgroups: comp.os.vxworks
| Subject: stdarg problems on 5.3.1/ppc with gnu toolchain
| Date: 12 Dec 1997 20:15:15 +0100
|
| Hi,
|
| I experimented some bugs with the GNU compiler bundled with VxWorks
| 5.3.1 on a PowerPC target. The code appended below illustrates it:
|
| ---Cut Here---
| #include <vxWorks.h>
| #include <stdio.h>
| #include <stdarg.h>
|
| void
| tva(int type, ...)
| {
| va_list ap;
| double d;
| int i;
|
| va_start(ap, type);
|
| if (type == 0) {
| do {
| i = va_arg(ap, int);
| printf("%d ", i);
| } while (i != 0);
| } else {
| do {
| d = va_arg(ap, double);
| printf("%f ", d);
| } while (d != 0);
| }
| va_end(ap);
| }
|
|
| void
| tva_main(void)
| {
| tva(0, 1 ,2 ,3 ,4 ,5 ,6, 7, 8, 9, 10 ,11, 12, 13, 14, 15, 16,
| 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
| 32, 33, 34, 0);
| printf("\n");
| tva(1, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0,
| 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
| 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0,
| 26.0, 27.0, 28.0, 29.0, 30.0, 31.0,
| 32.0, 33.0, 34.0, 0.0);
| printf("\n");
| }
| ---Cut Here---
|
| Here's a sample execution:
|
| -> tva_main
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| 27 28 29 30 31 32 33 34 0
| 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 7.000000
| 8.000000 12.000000 13.000000 14.000000 15.000000 16.000000 17.000000
| 18.000000 19.000000 20.000000 21.000000 22.000000 23.000000 24.000000
| 25.000000 26.000000 27.000000 28.000000 29.000000 30.000000 31.000000
| 32.000000 33.000000 34.000000 0.000000
| value = 1 = 0x1
|
| when the arguments are doubles, the 9th to 11th arguments are ignored.
|
| I traced this to incorrect code produced by gcc: the first 8 arguments
| are passed in registers, and then it places the other arguments at the
| wrong address on the stack.
|
| For information, EGCS 1.0 with GNU binutils 2.8.1, configured with
| --target=ppc-eabi don't have the bug.
Matthieu