[Bug c/12069] New: function pointers to assembler code not working on AIX 4.3

mweiser at fachschaft dot imn dot htwk-leipzig dot de gcc-bugzilla@gcc.gnu.org
Tue Aug 26 15:53:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12069

           Summary: function pointers to assembler code not working on AIX
                    4.3
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mweiser at fachschaft dot imn dot htwk-leipzig dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-ibm-aix4.3.3.0
  GCC host triplet: powerpc-ibm-aix4.3.3.0
GCC target triplet: powerpc-ibm-aix4.3.3.0

I've got a rather nasty problem with function pointers to assembler functions on
a 4-processor AIX box running AIX 4.3.

> prtconf
System Model: IBM,7025-F50
Processor Type:  PowerPC_604
Number Of Processors:        4
Memory Size: 1024MB
Good Memory Size: 1024MB
Firmware Version: IBM,L99308
Console Login: enable
Auto Restart: false
Full Core: false

> uname -asnlrvmasuM
AIX zeus 1108702796 3 4 004215764C00 IBM,7025-F50 IBM,014421576

I've narrowed it down to the test case shown below. As long as a C function is
called normally or via function pointer everything is fine. Calling a function
the normal way in an external assembler object is fine as well. But when I try
to call it via a function pointer the program segfaults immediately.

The gcc is version 3.2.3 and binutils are 2.13.2.1, both bootstrapped myself
without problems. I've verified the problem with a system-installed gcc-2.95.3.
gcc-3.3.1 is compiling at the moment, I'll give feedback on it later.

> gcc -o t t.c t.ppc.s
> ./t
calling f okay
calling f2 okay
calling foo2 okay
Segmentation fault (core dumped)

Doing the same with gcc-3.2.2 and binutils-2.13.90.18 on an RH9 Linux Intel box
works fine:

> gcc -o t t.c t.x86.s
> ./t
calling f okay
calling f2 okay
calling foo2 okay
calling foo okay

I'll attach the source files as well as the assembler output generated for t.c
on the AIX box.

After some testing I found that it works if I remove the double-dereferencing of
the function pointer. So it seems as if gcc is storing the label's address on
the stack frame already and not just the address of a pointer to the label as it
  seems to do with C functions. In terms of the assembler code generated by gcc
this looks as follows:

--- t.c.s       Tue Aug 26 17:26:43 2003
+++ t2.c.s      Tue Aug 26 17:26:13 2003
@@ -116,7 +116,7 @@
        bl .printf
        nop
        lwz 9,56(31)
-       lwz 0,0(9)
+       lwz 0,56(31)
        mtctr 0
        stw 2,20(1)
        lwz 2,4(9)

> gcc -o t t2.c.s t.ppc.s
> ./t
calling f okay
calling f2 okay
calling foo2 okay
calling foo okay

So am I just doing something wrong or is it really a bug in gcc? Is there a
simple workaround?

Thanks for your help in advance!

bye, Micha



More information about the Gcc-bugs mailing list