Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Jun 2003 20:58:36 -0400
From:      Alexander Kabaev <kabaev@mail.ru>
To:        Marcel Moolenaar <marcel@xcllnt.net>
Cc:        Julian Elischer <julian@elischer.org>
Subject:   Re: Implementing TLS: step 1
Message-ID:  <20030619205836.040122e5.kabaev@mail.ru>
In-Reply-To: <20030619233042.GD1273@dhcp01.pn.xcllnt.net>
References:  <20030619223608.GB1273@dhcp01.pn.xcllnt.net> <Pine.BSF.4.21.0306191543000.41210-100000@InterJet.elischer.org> <20030619233042.GD1273@dhcp01.pn.xcllnt.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 19 Jun 2003 16:30:42 -0700
Marcel Moolenaar <marcel@xcllnt.net> wrote:

> On Thu, Jun 19, 2003 at 04:03:30PM -0700, Julian Elischer wrote:
> > 
> > > The compiler generates access sequences according to the runtime
> > > specification which in general means that all offsets to the TLS
> > > are based on some TLS base address. On ia64 the thread pointer
> > > points to the TLS and serves as the TLS base address. On other
> > > architectures there may be an indirection. This means that on ia64
> > > the lack of TLS still requires us to allocate something for the
> > > thread pointer to point to. On other architectures this may not be
> > > the case.
> > > 
> > > A typical access sequence on i386 is:
> > > 
> > > 00000000 <x>:
> > >    0:   55                      push   %ebp
> > >    1:   89 e5                   mov    %esp,%ebp
> > >    3:   65 a1 00 00 00 00       mov    %gs:0x0,%eax
> > >    9:   8b 80 00 00 00 00       mov    0x0(%eax),%eax
> > >    f:   c9                      leave
> > >   10:   c3                      ret
> > 
> > The example you show doesn't have any offset into the TLS,
> > just returning the base address of the dtv, correct?
> 
> This is an access sequence for static TLS. There's no DTV in that
> case.
> 

Actually, the code looks like this:

	mov    0x0(%eax),%eax  ;; return DTV address (or null if static)

	mov    -4(%eax), %eax	;; return first int variable in TLS.

i.e. i386 is using TLS Type II, where variables are addressed using
_negative_ offsets relative to thread pointer (%gs:0).




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030619205836.040122e5.kabaev>