[mips-tls] Revised versions of MIPS TLS ABI specification
Daniel Jacobowitz
dan at codesourcery.com
Thu Nov 4 21:41:06 UTC 2004
On Thu, Nov 04, 2004 at 06:00:53PM +0000, Nigel Stephens wrote:
> Daniel Jacobowitz wrote:
>
> >>The following issue does need resolution:
> >>
> >>1. Should we extend the 32K Local Dynamic Model to 64K by using a biased
> >>offset?
> >>
> >>Daniel and I thought this would be more trouble than it's worth; Thiemo
> >>thinks otherwise. Are there any other opinions?
> >>
> >>
> >
> >I have since learned that PowerPC already does this:
> >
> >| The PowerPC32 TLS ABI is similar to the PowerPC64 model. The
> >| thread-local storage data structures follow variant I. The TCB is 8
> >| bytes, with the first 4 bytes containing the pointer to the dynamic
> >| thread vector. tlsoffset calculations and definition of __tls_get_addr
> >| are identical to PowerPC64. r2 is the thread pointer, and points
> >| 0x7000 past the end of the thread control block. Dynamic thread vector
> >| pointers point 0x8000 past the start of each TLS block. (*) This
> >| allows the first 64K of each block to be addressed from a dtv pointer
> >| using fewer machine instructions. The tp offset allows for efficient
> >| addressing of the TCB and up to 4K-8 of other thread library
> >| information.
> >|
> >| (*) For implementation reasons the actual value stored in dtv may point
> >| to the start of a block, however values returned by accessor functions
> >| will be offset by 0x8000.
> >
> >
>
> Hi Daniel
>
> I'd be interested to know where that quoted passage comes from - is it a
> public document, I can't find it with Google?
Take a look at
ftp://ftp.linuxppc64.org/pub/people/amodra
(from memory; I hope I got the path right.)
> >Shall we use this model?
>
>
> It does sounds like we could use the same trick. But I'd like to
> understand it better. I thought that the problem was that in variant I
> the size of the TCB was indeterminate, so the static linker couldn't
> insert optimised references to initial-exec TLS data as fixed offsets
> from the thread pointer. But the implication of the above is that the
> TCB does have a known, fixed size, so the a fixed offset can now be
> inserted by the linker, as for variant II. Have I got that right?
No. This is a variant I model, which means that the size and layout of
the TCB are known; it's in variant II that the TCB is indeterminate. In
variant I the TLS areas have a positive offset from the TCB, which
starts with a pointer to the DTV; in variant II they have a negative
offset from the TCB, which has indeterminate contents. In either case
the static linker can resolve IE/LE references that bind to the local
executable.
Normally in variant I the thread pointer points to the beginning of the
TCB, i.e. a known distance before the start of the first TLS block. In
this case the thread pointer points to 0x7000 past the _end_ of the
first TLS block - but that's just an implementation detail.
--
Daniel Jacobowitz
More information about the mips-tls
mailing list