From owner-freebsd-threads@FreeBSD.ORG Thu Jun 19 17:58:52 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7B26937B401 for ; Thu, 19 Jun 2003 17:58:52 -0700 (PDT) Received: from mx2.mail.ru (mx2.mail.ru [194.67.23.22]) by mx1.FreeBSD.org (Postfix) with ESMTP id B83E943FAF for ; Thu, 19 Jun 2003 17:58:51 -0700 (PDT) (envelope-from kabaev@mail.ru) Received: from [141.154.214.216] (port=55638 helo=kan.dnsalias.net) by mx2.mail.ru with esmtp id 19TAEr-0000Tj-00; Fri, 20 Jun 2003 04:58:49 +0400 Received: from kan.dnsalias.net (ak03@localhost [127.0.0.1]) by kan.dnsalias.net (8.12.9/8.12.9) with ESMTP id h5K0wb4V009071; Thu, 19 Jun 2003 20:58:37 -0400 (EDT) (envelope-from kan@kan.dnsalias.net) Received: (from kan@localhost) by kan.dnsalias.net (8.12.9/8.12.9/Submit) id h5K0waQ3009070; Thu, 19 Jun 2003 20:58:37 -0400 (EDT) Date: Thu, 19 Jun 2003 20:58:36 -0400 From: Alexander Kabaev To: Marcel Moolenaar Message-Id: <20030619205836.040122e5.kabaev@mail.ru> In-Reply-To: <20030619233042.GD1273@dhcp01.pn.xcllnt.net> References: <20030619223608.GB1273@dhcp01.pn.xcllnt.net> <20030619233042.GD1273@dhcp01.pn.xcllnt.net> X-Mailer: Sylpheed version 0.9.0claws2 (GTK+ 1.2.10; i386-portbld-freebsd5.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: Not detected cc: threads@freebsd.org cc: Julian Elischer Subject: Re: Implementing TLS: step 1 X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jun 2003 00:58:52 -0000 On Thu, 19 Jun 2003 16:30:42 -0700 Marcel Moolenaar 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 : > > > 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).