[git commit master 1/1] libc_sh: add __tls_get_addr to static libc (SH)

Carmelo Amoroso carmelo.amoroso at st.com
Wed Dec 1 16:26:18 UTC 2010


commit: http://git.uclibc.org/uClibc/commit/?id=c5db8f051be9846485911e973f26943c114c66fb
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

Add __tls_get_addr function to static libc allowing to handle
local dynamic TLS access model.
On SH, linker optimizations are not required, so __tls_get_addr
can be called even in statically linked binaries.

Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono at st.com>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso at st.com>
---
 libpthread/nptl/sysdeps/sh/Makefile.arch |    2 +-
 libpthread/nptl/sysdeps/sh/libc-tls.c    |   31 ++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletions(-)
 create mode 100644 libpthread/nptl/sysdeps/sh/libc-tls.c

diff --git a/libpthread/nptl/sysdeps/sh/Makefile.arch b/libpthread/nptl/sysdeps/sh/Makefile.arch
index 3cb58ec..411622a 100644
--- a/libpthread/nptl/sysdeps/sh/Makefile.arch
+++ b/libpthread/nptl/sysdeps/sh/Makefile.arch
@@ -10,4 +10,4 @@ ASFLAGS-pthread_spin_trylock.S = -DNOT_IN_libc -DIS_IN_libpthread
 
 CFLAGS-pthread_spin_lock.c += -D_GNU_SOURCE
 
-
+libc_arch_a_CSRC := libc-tls.c
diff --git a/libpthread/nptl/sysdeps/sh/libc-tls.c b/libpthread/nptl/sysdeps/sh/libc-tls.c
new file mode 100644
index 0000000..7b33895
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sh/libc-tls.c
@@ -0,0 +1,31 @@
+/*
+ * Thread-local storage handling in statically linked binaries.  SH version.
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * Based on GNU C Library (file: libc/sysdeps/sh/libc-tls.c)
+ *
+ * Copyright (C) 2010 STMicroelectronics Ltd.
+ * Author: Filippo Arcidiacono <filippo.arcidiacono at st.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ */
+
+#include <sysdeps/generic/libc-tls.c>
+#include <dl-tls.h>
+
+#if defined (USE_TLS) && (USE_TLS)
+
+/* On SH, linker optimizations are not required, so __tls_get_addr
+   can be called even in statically linked binaries.  In this case module
+   must be always 1 and PT_TLS segment exist in the binary, otherwise it
+   would not link.  */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+  dtv_t *dtv = THREAD_DTV ();
+  return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
+
+#endif
-- 
1.7.2.2



More information about the uClibc-cvs mailing list