Date: Thu, 19 Jun 2003 13:20:13 -0700 From: Marcel Moolenaar <marcel@xcllnt.net> To: threads@FreeBSD.org Subject: Implementing TLS: step 1 Message-ID: <20030619202013.GA833@dhcp01.pn.xcllnt.net>
next in thread | raw e-mail | index | archive | help
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. 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? Alternatives? -- Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030619202013.GA833>