------- Comment #2 from amodra at bigpond dot net dot au  2005-12-13 04:28 
-------
The testcase is invalid, because you are compiling libwrapped.so without -fPIC.
 Now, powerpc64 code is always PIC, so you might think that -fPIC (or -fpic) is
unnecessary on powerpc64 shared libraries.  However, -fPIC/pic also tells gcc
to compile assuming that the object might be for a shared library.  One thing
this affects is whether tail calls can be made to global functions.  At -O2,
sibling/tail call optimisation is done, so we get a tail call from "wrapped" to
"fn" because -fPIC wasn't specified.  This tail call inside the shared lib
destroys r2, the TOC pointer, and an invalid TOC access is the reason for the
segfault.

It might possible to do something about this in the linker, but more
complicated examples are not possible to fix.  eg. where the function
tail-called is overridden by a function of the same name in the main app.


-- 

amodra at bigpond dot net dot au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amodra at bigpond dot net
                   |                            |dot au
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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

Reply via email to