public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* Re: dlclose and TLS
@ 2003-04-29  0:07 Steven Munroe
  2003-04-29  0:18 ` Ulrich Drepper
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Munroe @ 2003-04-29  0:07 UTC (permalink / raw)
  To: libc-hacker, Paul Mackerras, Alan Modra

[-- Attachment #1: Type: text/plain, Size: 1385 bytes --]

Ulrich Drepper writes:

 > I've checked in some code to fix dlclose of modules with static TLS
 > for TLS_TCB_AT_TP platforms.  The existing code was completely broken
 > but I thnk it should more or less work for TLS_DTV_AT_TP platforms.

As of this morning ppc and ppc64 linuxthreads are working but nplt is 
not. At the moment nptl-0.36 is out sync with glibc at cvs head.

The problem I fould was that (at glibc cvs head) TLS_TCB_SIZE (defined 
as 0) was removed from the TLS_TPREL_VALUE calculation (in 
sysdeps/powerpc/dl-tls.h). To compensate the size of tcbhead_t was 
rolled into TLS_PRE_TCB_SIZE (in linuxthreads/sysdeps/powerpc/tls.h). 
Also dtv addressing was changed to use (TCBP)[-1].dtv.

The nptl sysdeps/powerpc/tls.h is still using the old definition 
(TLS_PRE_TCB_SIZE does not include sizeof(tcbhead_t)) so all TPREL 
relocations are off by sizeof(tcbhead_t).

Unfortunately my attemps so far (by either changing powerpc/dl-tls.h 
(add TLS_TCB_SIZE back) or nptl's powerpc/tls.h (make it look like 
linuxthreads powerpc/tls.h) have successed in getting ppc32/64 nptl 
working. There seems to be dependences in glibc for TLS_TCB_SIZE to be 0 
and in nptl-0.36 for it to be sizeof(tcbhead_t)

Is anyone else working on the corresponing nptl changes?

If not what are the generic glibc dependences on TLS_TCB_SIZE and 
TLS_PRE_TCB_SIZE for TLS_DTV_AT_TP platforms?




[-- Attachment #2: nptl-tls-glibc-0428.patch --]
[-- Type: text/plain, Size: 3335 bytes --]

diff -urN nptl-0.36/nptl/sysdeps/powerpc/tls.h libc23/nptl/sysdeps/powerpc/tls.h
--- nptl-0.36/nptl/sysdeps/powerpc/tls.h	2003-03-20 02:53:01.000000000 -0600
+++ libc23/nptl/sysdeps/powerpc/tls.h	2003-04-28 13:58:43.000000000 -0500
@@ -69,19 +69,21 @@
 } tcbhead_t;
 
 /* This is the size of the initial TCB.  */
-# define TLS_INIT_TCB_SIZE	sizeof (tcbhead_t)
+# define TLS_INIT_TCB_SIZE	0
 
 /* Alignment requirements for the initial TCB.  */
-# define TLS_INIT_TCB_ALIGN	__alignof__ (tcbhead_t)
+# define TLS_INIT_TCB_ALIGN	__alignof__ (struct pthread)
 
 /* This is the size of the TCB.  */
-# define TLS_TCB_SIZE		sizeof (tcbhead_t)
+# define TLS_TCB_SIZE		0
 
 /* Alignment requirements for the TCB.  */
-# define TLS_TCB_ALIGN		__alignof__ (tcbhead_t)
+# define TLS_TCB_ALIGN		__alignof__ (struct pthread)
 
 /* This is the size we need before TCB.  */
-# define TLS_PRE_TCB_SIZE	sizeof (struct pthread)
+# define TLS_PRE_TCB_SIZE \
+  (sizeof (struct pthread)				      \
+   + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
 
 /* XXX if __alignof__ (struct pthread) > __alignof (tcbhead_t)
    we could be in trouble.  -- paulus */
@@ -98,37 +100,37 @@
 
 /* The following assumes that TP (R2 or R13) points to the end of the
    TCB + 0x7000 (per the ABI).  This implies that TCB address is
-   TP-(TLS_TCB_SIZE + 0x7000).  As we define TLS_DTV_AT_TP we can
+   TP - 0x7000.  As we define TLS_DTV_AT_TP we can
    assume that the pthread struct is allocated immediately ahead of the
    TCB.  This implies that the pthread_descr address is
-   TP-(TLS_PRE_TCB_SIZE + TLS_TCB_SIZE + 0x7000).  */
+   TP - (TLS_PRE_TCB_SIZE + 0x7000).  */
 # define TLS_TCB_OFFSET	0x7000
 
 /* Install the dtv pointer.  The pointer passed is to the element with
    index -1 which contain the length.  */
-# define INSTALL_DTV(tcbp, dtvp) \
-  ((tcbhead_t *) (tcbp))->dtv = dtvp + 1
+# define INSTALL_DTV(TCBP, DTVP) \
+  ((tcbhead_t *) (TCBP))[-1].dtv = (DTVP) + 1
 
 /* Install new dtv for current thread.  */
-# define INSTALL_NEW_DTV(dtv) (THREAD_DTV() = (dtv))
+# define INSTALL_NEW_DTV(DTV) (THREAD_DTV() = (DTV))
 
 /* Return dtv of given thread descriptor.  */
-# define GET_DTV(tcbp)	(((tcbhead_t *) (tcbp))->dtv)
+# define GET_DTV(TCBP)	(((tcbhead_t *) (TCBP))[-1].dtv)
 
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
-# define TLS_INIT_TP(tcbp, secondcall) \
-    (__thread_register = (void *) (tcbp) + TLS_TCB_OFFSET + TLS_TCB_SIZE, NULL)
+# define TLS_INIT_TP(TCBP, secondcall) \
+    (__thread_register = (void *) (TCBP) + TLS_TCB_OFFSET, NULL)
 
 /* Return the address of the dtv for the current thread.  */
 # define THREAD_DTV() \
-     (((tcbhead_t *) (__thread_register - TLS_TCB_OFFSET - TLS_TCB_SIZE))->dtv)
+     (((tcbhead_t *) (__thread_register - TLS_TCB_OFFSET))[-1].dtv)
 
 /* Return the thread descriptor for the current thread.  */
 # define THREAD_SELF \
     ((struct pthread *) (__thread_register \
-			 - TLS_TCB_OFFSET - TLS_TCB_SIZE - TLS_PRE_TCB_SIZE))
+			 - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
 
 /* Read member of the thread descriptor directly.  */
 # define THREAD_GETMEM(descr, member) ((void)(descr), (THREAD_SELF)->member)

[-- Attachment #3: ppc-dl-tls-20030428.patch --]
[-- Type: text/plain, Size: 576 bytes --]

diff -urN libc23-cvstip-20030428/sysdeps/powerpc/dl-tls.h libc23/sysdeps/powerpc/dl-tls.h
--- libc23-cvstip-20030428/sysdeps/powerpc/dl-tls.h	2003-04-25 04:08:56.000000000 -0500
+++ libc23/sysdeps/powerpc/dl-tls.h	2003-04-28 17:34:28.000000000 -0500
@@ -35,7 +35,7 @@
 /* Compute the value for a @tprel reloc.  */
 #define TLS_TPREL_VALUE(sym_map, sym, reloc) \
   ((sym_map)->l_tls_offset + (sym)->st_value + (reloc)->r_addend \
-   - TLS_TP_OFFSET)
+   - TLS_TCB_SIZE - TLS_TP_OFFSET)
 
 /* Compute the value for a @dtprel reloc.  */
 #define TLS_DTPREL_VALUE(sym, reloc) \

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: dlclose and TLS
  2003-04-29  0:07 dlclose and TLS Steven Munroe
@ 2003-04-29  0:18 ` Ulrich Drepper
  0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Drepper @ 2003-04-29  0:18 UTC (permalink / raw)
  To: sjmunroe; +Cc: libc-hacker, Paul Mackerras

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Steven Munroe wrote:

> As of this morning ppc and ppc64 linuxthreads are working but nplt is
> not. At the moment nptl-0.36 is out sync with glibc at cvs head.

I have already changes for nptl in my tree.  I just have to find time to
release them.  Once this is done check them.  There shouldn't be any
problems.

- -- 
- --------------.                        ,-.            444 Castro Street
Ulrich Drepper \    ,-----------------'   \ Mountain View, CA 94041 USA
Red Hat         `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+rcSt2ijCOnn/RHQRAmlyAKCUAfhyenrOHb67wxMACnuc+yp2dACfUAy+
gbMTVXKXfFgl5O7aCcyjBNo=
=88bM
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: dlclose and TLS
@ 2003-04-29 17:46 Steve Munroe
  0 siblings, 0 replies; 4+ messages in thread
From: Steve Munroe @ 2003-04-29 17:46 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: libc-hacker, Paul Mackerras

Ulrich Drepper writes:

> I have already changes for nptl in my tree.  I just have to find time to
> release them.  Once this is done check them.  There shouldn't be any
> problems.

The nptl-0.37 release builds and runs make check without failures for both 
PPC32 and PPC64.

Thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* dlclose and TLS
@ 2003-04-27  6:22 Ulrich Drepper
  0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Drepper @ 2003-04-27  6:22 UTC (permalink / raw)
  To: GNU libc hacker

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've checked in some code to fix dlclose of modules with static TLS for
TLS_TCB_AT_TP platforms.  The existing code was completely broken but I
thnk it should more or less work for TLS_DTV_AT_TP platforms.  I left it
completely alone for now.  Hopefully somebody will look at it a bit
closer.  The new tests should test the code somewhat.  Just holes aren't
tested.

- -- 
- --------------.                        ,-.            444 Castro Street
Ulrich Drepper \    ,-----------------'   \ Mountain View, CA 94041 USA
Red Hat         `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+q3cE2ijCOnn/RHQRAqdcAJ42XK1PtF/wEia8//OUcYqS0YlTxACePpzv
Zl0+Gk5vSxdYepvmna4kMZw=
=/C8I
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-04-29 17:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-29  0:07 dlclose and TLS Steven Munroe
2003-04-29  0:18 ` Ulrich Drepper
  -- strict thread matches above, loose matches on Subject: below --
2003-04-29 17:46 Steve Munroe
2003-04-27  6:22 Ulrich Drepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).