Subject: Re: Text relocations in shared libs
To: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
From: Charles M. Hannum <mycroft@MIT.EDU>
List: port-sh3
Date: 12/25/2005 13:54:13
Quoting "Valeriy E. Ushakov" <uwe@ptc.spbu.ru>:

> #define _SYSCALL(x,y)     \
>   .text;     \
>  911: mov.l 912f, r3;   \
>   braf r3;    \
>   nop;     \
>   .align 2;    \
>  912: .long cerror-(911b+6);  \
>                ^^^^^^^^^^^^^^^^^^^^^^^
>   _SYSCALL_NOERROR(x,y);   \
>   bf 911b;    \
>   nop
>
> A proper PIC call would be to set up r12 and do the call via plt, but
> that raises a number of questions.
>
> plt destroys r0, where syscall code passes errno, so that would either
> cause a flag day, ...

What prevents you from just moving errno to a different register before
executing the PLT?  Surely you have another callee-saved register you
can destroy.  You can probably even put the move instruction in one of
the branch delay slots, so it doesn't cost you anything.

It would cause a flag day only in the sense that libposix and libpthread
would have to be updated in sync with libc, because of the new cerror
calling convention, but I think this is minor -- owing both to a limited
number of users, and the fact that nothing in the build or install
process uses either of those libraries.