From owner-freebsd-threads@FreeBSD.ORG Thu Jun 19 13:42:31 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 4698637B404 for ; Thu, 19 Jun 2003 13:42:31 -0700 (PDT) Received: from h132-197-179-27.gte.com (h132-197-179-27.gte.com [132.197.179.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 399BB43F85 for ; Thu, 19 Jun 2003 13:42:30 -0700 (PDT) (envelope-from ak03@gte.com) Received: from kanpc.gte.com (ak03@localhost [127.0.0.1]) h5JKgTTO019224; Thu, 19 Jun 2003 16:42:29 -0400 (EDT) (envelope-from ak03@kanpc.gte.com) Received: (from ak03@localhost) by kanpc.gte.com (8.12.9/8.12.9/Submit) id h5JKgSv6019223; Thu, 19 Jun 2003 16:42:28 -0400 (EDT) Date: Thu, 19 Jun 2003 16:42:28 -0400 From: Alexander Kabaev To: Marcel Moolenaar Message-Id: <20030619164228.6d2e7dd2.ak03@gte.com> In-Reply-To: <20030619202013.GA833@dhcp01.pn.xcllnt.net> References: <20030619202013.GA833@dhcp01.pn.xcllnt.net> Organization: Verizon Data Services X-Mailer: Sylpheed version 0.9.0claws25 (GTK+ 1.2.10; i386-portbld-freebsd5.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: threads@freebsd.org 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: Thu, 19 Jun 2003 20:42:31 -0000 On Thu, 19 Jun 2003 13:20:13 -0700 Marcel Moolenaar wrote: > Ok, > > Step 1: static TLS in libthr. > > I have gcc33 installed and looked at the access sequences for TLS > on both i386 and ia64. Then I looked at libthr to see what was > needed and the first and obvious orbservation is that we need a > way to figure out if the binary has a TLS template and use it if > it does. If not, we probably need some minimal glue to have the > TLS pointer point to something meaningful. Note again, we don't > have RTLD involved. We're talking staticly linking now. > > What about the following: > > 1. The kernel already iterates over the program headers and can > pass the address and size of the TLS template to the process > (or RTLD) by means of the auxargs (ie have AT_TLS_ADDR and > AT_TLS_SIZE). If no template exists AT_TLS_* will be zero. > This prevents coding object file dependencies on thread and > allows the RTLD to modify the args even in the event that the > program itself does not have TLS, but libraries in the startup > set do. Any reason why existing AT_PHDR is not enough? > 2. On thread creation we allocate the TLS space according to the > template (or some MD specific placebo) and put a pointer to it > in struct thread. For static TLS we don't have a means to > lazily allocate the TLS. > 3. The MD _get_curthread() and _set_curthread() will be adjusted > according to the RT spec. if not currently compliant. > > Question: > 1. What's the best way to expose the auxargs to the thread library? rtld can export several _magic_ symbols thread library can look for to get the info it needs. Alternatively, rtld_thread_init interface can be extended to pass required into to the library in a structure of some sort. For static binaries, startup code will have to parse AT_PHDR and store TLS attributes in a global variable or call a function defined by the thread library. If I remember correctly, libpthread people wanted to have that function anyway. > Alternatives? > > -- > Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net > _______________________________________________ > freebsd-threads@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-threads > To unsubscribe, send any mail to > "freebsd-threads-unsubscribe@freebsd.org" -- Alexander Kabaev