svn commit: r355045 - head/libexec/rtld-elf/powerpc

Justin Hibbits jhibbits at FreeBSD.org
Sun Nov 24 17:25:22 UTC 2019


On Sun, 24 Nov 2019 18:47:14 +0200
Konstantin Belousov <kostikbel at gmail.com> wrote:

> On Sun, Nov 24, 2019 at 10:32:23AM -0600, Brandon Bergren wrote:
> > On Sun, Nov 24, 2019, at 7:04 AM, Konstantin Belousov wrote:  
> > > On Sun, Nov 24, 2019 at 04:35:29AM +0000, Justin Hibbits wrote:  
> > > > Author: jhibbits
> > > > Date: Sun Nov 24 04:35:29 2019
> > > > New Revision: 355045
> > > > URL: https://svnweb.freebsd.org/changeset/base/355045
> > > > 
> > > > Log:
> > > >   rtld/powerpc: Fix _rtld_bind_start for powerpcspe
> > > >   
> > > >   Summary:
> > > >   We need to save off the full 64-bit register, not just the
> > > > low 32 bits, of all registers getting saved off in
> > > > _rtld_bind_start.  Additionally, we need to save off the other
> > > > SPE registers (SPEFSCR and accumulator), so that their program
> > > > state is not affected by the PLT resolver.  
> > > Why do you need to save these registers ?  Why would rtld touch
> > > them ? 
> > Out of a need to make the binder as invisible as possible when
> > interacting with code that may or may not be following the normal
> > ABI rules regarding who is responsible for saving stuff.
> > 
> > It's not just C code using it.  
> This was not the question.  If a register is saved at the bind entry,
> it means that it is used by rtld itself.  I am surprised that rtld
> needs anything from SPE.

This puzzled us to no end when debugging.  Brandon found that changes
to SPEFSCR got stomped if done before a PLT resolution, which doesn't
happen when LD_BIND_NOW=1 is used. Also, I found that sshd, when built
with clang, would have a weird hang, which was also 'fixed' with
LD_BIND_NOW=1.  Tracing through the sshd problem, the values in
question were stored in the nonvolatile registers, which shouldn't be
clobbered by rtld.  The SPEFSCR problem looks like the SPEFSCR was
being reverted to a 'last known state in kernel', which I couldn't find
a reason for.  The swtch32.S code looks correct, as does save_vec() and
enable_vec().  Unless I'm missing something there.  I've gone over it
at least a dozen times in the last week.

The ACC register probably doesn't need to be touched, though.

- Justin


More information about the svn-src-head mailing list