This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH} PPC fix td_thr_get_addr for TLS


A comment from Roland caused me to start wondering how GDB and other debuggers
will deal with tls and PPC tls in particular. The good news is that debuggers
that use libthread_db should be OK. The bad news is I found another place that
needs to handle PPC32/PPC64 TLS_DTV_OFFSET. If Alpha picks up this negative
bias concept we should consider making TLS_TP_OFFSET and TLS_DTV_OFFSET an
official part of the TLS ABI (other archs would simply define them as 0).

For PPC, DTPREL relocations are pre biased by the linker -0x8000
(-TLS_DTV_OFFSET). So the TLS block addresses from the DTV must be post biased
+0x8000 to get the correct address.

So in td_thr_tls_get_addr.c we need to insure that TLS_DTV_OFFSET is defined.
If not define it as 0. Then use TLS_DTV_OFFSET plus dtv.pointer plus (symbol)
offset to compute the address. 


2003-03-07  Steven Munroe  <sjmunroe at us dot ibm dot com>

        * td_thr_tls_get_addr.c [!TLS_DTV_OFFSET]: Define TLS_DTV_OFFSET as 0.
	(td_thr_tls_get_addr): Include TLS_DTV_OFFSET in address computation.

Then we need to define TLS_DTV_OFFSET in ./sysdeps/powerpc/tls.h. (it was
defined in libc/sysdeps/powerpc/dl-tls.h but linuxthreads can't find it).  

2003-03-07  Steven Munroe  <sjmunroe at us dot ibm dot com>

	* sysdeps/powerpc/tls.h (TLS_DTV_OFFSET): Define.


-- 
Steven Munroe
sjmunroe at us dot ibm dot com
Linux on PowerPC-64 Development
GLIBC for PowerPC-64 Development
diff -urN libc23-cvstip-20030305/linuxthreads_db/td_thr_tls_get_addr.c libc23/linuxthreads_db/td_thr_tls_get_addr.c
--- libc23-cvstip-20030305/linuxthreads_db/td_thr_tls_get_addr.c	2003-03-02 05:45:04.000000000 -0600
+++ libc23/linuxthreads_db/td_thr_tls_get_addr.c	2003-03-07 14:04:52.000000000 -0600
@@ -25,6 +25,10 @@
 /* Value used for dtv entries for which the allocation is delayed.  */
 # define TLS_DTV_UNALLOCATED	((void *) -1l)
 
+#ifndef TLS_DTV_OFFSET
+# define TLS_DTV_OFFSET 0
+#endif
+
 
 td_err_e
 td_thr_tls_get_addr (const td_thrhandle_t *th __attribute__ ((unused)),
@@ -68,7 +72,7 @@
     /* There is not much we can do.  */
     return TD_NOTALLOC;
 
-  *address = (char *) pdtv.pointer + offset;
+  *address = (char *) pdtv.pointer + offset + TLS_DTV_OFFSET;
 
   return TD_OK;
 #else
diff -urN libc23-cvstip-20030305/linuxthreads/sysdeps/powerpc/tls.h libc23/linuxthreads/sysdeps/powerpc/tls.h
--- libc23-cvstip-20030305/linuxthreads/sysdeps/powerpc/tls.h	2003-03-02 05:44:14.000000000 -0600
+++ libc23/linuxthreads/sysdeps/powerpc/tls.h	2003-03-07 14:31:36.000000000 -0600
@@ -79,6 +79,11 @@
    where the DTV pointer is first doubleword in the TCB.  */
 #  define TLS_DTV_AT_TP 1
 
+/* DTPREL relocations are pre biased by the linker -0x8000.  So the 
+   TLS block addresses from the DTV must be post biased +0x8000 to get
+   the correct address.  This is currently done by __tls_get_addr().  */
+#define TLS_DTV_OFFSET		0x8000
+
 /* Install the dtv pointer.  The pointer passed is to the element with
    index -1 which contain the length.  */
 #  define INSTALL_DTV(TCBP, DTVP) \

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]