Subject: Re: Text relocations in shared libs
To: Matt Thomas <matt@3am-software.com>
From: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
List: tech-toolchain
Date: 12/27/2005 11:20:26
On Mon, Dec 26, 2005 at 19:32:26 -0800, Matt Thomas wrote:
> > On Sun, Dec 25, 2005 at 13:54:13 -0500, Charles M. Hannum wrote:
> >
> > > 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.
> >
> > Right, but that kinda reinforces my other point. If the interface
> > between syscall code and cerror is private, why do we need to
> > bother with exporting cerror at all? We can just make it .hidden
> > and make the call to go directly to cerror, instead of going via
> > PLT.
>
> cerror is also used by libposix. So either posix will need its own
> or able to use libc's.
I know. As I said in my original mail:
| libposix will need a copy of cerror to compensate for that change.
| Another possible solution is to change libposix to (tail)call into
| libc instead of duplicating the actual syscall code in libposix.
and I think calling libc is a cleaner option, with code like the
following:
#include <sys/cdefs.h>
extern int __posix_rename(const char *, const char *);
#ifdef __weak_alias
#define rename _rename
__weak_alias(rename,_rename)
#endif
int
rename(const char *from, const char *to)
{
return __posix_rename(from, to);
}
SY, Uwe
--
uwe@ptc.spbu.ru | Zu Grunde kommen
http://snark.ptc.spbu.ru/~uwe/ | Ist zu Grunde gehen