[PATCH] Fix -fpic/-fPIC virtual thunks on s390 -m31

Jakub Jelinek jakub@redhat.com
Fri Jun 20 17:39:00 GMT 2003


On Fri, Jun 20, 2003 at 06:56:11PM +0200, Ulrich Weigand wrote:
> Hi Jakub,
> 
> > s390 31-bit .plt slots require %r12 to be loaded with .plt's shared library
> > _GLOBAL_OFFSET_TABLE_. As we cannot load that (%r12 is call-saved and we
> > don't return back into the thunk (we would have to copy arguments otherwise
> > and we don't know how many there are), we cannot use .plt.
> 
> I had thought that in this case, the call to the thunk would count as
> call to a non-local function and thus the caller would have to set up
> the GOT pointer.  Is this not the case?  (If not, can it be arranged?
> That would certainly be the best solution.)

This is not possible. Virtual thunks are exported symbols and can be called
from any shared library, not just the one defining them (through
function pointer stored in virtual tables).

> > The following patch changes 31-bit thunks calling to non-local functions
> > in -fpic/-fPIC to load the function pointer from .got instead.
> 
> This effectively disables lazy binding.

True, but I'm afraid there is not much that can be done about it.
FYI IA-32 has similar problem with %ebx and uses @GOT, not @PLT as well
because of that.

> Recent binutils support
> @GOTPLT (or was it @PLTGOT?); that would be preferable ...

But even for @GOTPLT you need %r12 loaded (if the particular .gotplt slot
has been already resolved it will point directly to the desired function).
But if it has not been resolved yet, it will after a few instructions
branch to .plt+0, where %r12 is used as well.

	Jakub



More information about the Gcc-patches mailing list