Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add TLS support for m68k.
details: https://anonhg.NetBSD.org/src/rev/5abb6f0edc15
branches: trunk
changeset: 771474:5abb6f0edc15
user: joerg <joerg%NetBSD.org@localhost>
date: Tue Nov 22 15:25:28 2011 +0000
description:
Add TLS support for m68k.
diffstat:
lib/libc/arch/m68k/Makefile.inc | 4 +-
lib/libc/arch/m68k/gen/Makefile.inc | 3 +-
lib/libc/arch/m68k/gen/_lwp.c | 10 ++++--
lib/libc/arch/m68k/sys/__m68k_read_tp.S | 7 ++++
libexec/ld.elf_so/arch/m68k/mdreloc.c | 47 ++++++++++++++++++++++++++++++--
sys/arch/m68k/include/mcontext.h | 29 +++++++++++++++++++-
sys/arch/m68k/include/types.h | 6 +++-
7 files changed, 94 insertions(+), 12 deletions(-)
diffs (209 lines):
diff -r df3e1ebfed31 -r 5abb6f0edc15 lib/libc/arch/m68k/Makefile.inc
--- a/lib/libc/arch/m68k/Makefile.inc Tue Nov 22 14:31:02 2011 +0000
+++ b/lib/libc/arch/m68k/Makefile.inc Tue Nov 22 15:25:28 2011 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile.inc,v 1.13 2008/02/09 02:41:06 mrg Exp $
+# $NetBSD: Makefile.inc,v 1.14 2011/11/22 15:25:28 joerg Exp $
-SRCS+= __sigaction14_sigtramp.c __sigtramp2.S __mmap.S
+SRCS+= __sigaction14_sigtramp.c __sigtramp2.S __m68k_read_tp.S __mmap.S
ASM+= _lwp_getprivate.S mremap.S
diff -r df3e1ebfed31 -r 5abb6f0edc15 lib/libc/arch/m68k/gen/Makefile.inc
--- a/lib/libc/arch/m68k/gen/Makefile.inc Tue Nov 22 14:31:02 2011 +0000
+++ b/lib/libc/arch/m68k/gen/Makefile.inc Tue Nov 22 15:25:28 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.30 2009/12/06 07:12:17 uebayasi Exp $
+# $NetBSD: Makefile.inc,v 1.31 2011/11/22 15:25:28 joerg Exp $
SRCS+= alloca.S fabs.S
@@ -26,6 +26,7 @@
negdf2.S negsf2.S
SRCS+= bswap16.S bswap32.S bswap64.S
SRCS+= _lwp.c
+CPPFLAGS._lwp.c += -D_LIBC_SOURCE
# 68000-based machines build with a libgcc that includes
# much of the (soft)float and integer support that would
diff -r df3e1ebfed31 -r 5abb6f0edc15 lib/libc/arch/m68k/gen/_lwp.c
--- a/lib/libc/arch/m68k/gen/_lwp.c Tue Nov 22 14:31:02 2011 +0000
+++ b/lib/libc/arch/m68k/gen/_lwp.c Tue Nov 22 15:25:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:42 joerg Exp $ */
+/* $NetBSD: _lwp.c,v 1.7 2011/11/22 15:25:28 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,18 +31,19 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:42 joerg Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.7 2011/11/22 15:25:28 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <sys/types.h>
+#include <sys/tls.h>
#include <ucontext.h>
#include <lwp.h>
#include <stdlib.h>
void
_lwp_makecontext(ucontext_t *u, void (*start)(void *),
- void *arg, void *private, caddr_t stack_base, size_t stack_size)
+ void *arg, void *tcb, caddr_t stack_base, size_t stack_size)
{
void **sp;
@@ -60,6 +61,7 @@
*--sp = (void *) _lwp_exit;
u->uc_mcontext.__gregs[_REG_A7] = (int) sp;
- u->uc_mcontext._mc_tlsbase = (uintptr_t)private;
+ u->uc_mcontext._mc_tlsbase = (uintptr_t)tcb + TLS_TP_OFFSET +
+ sizeof(struct tls_tcb);
u->uc_flags |= _UC_TLSBASE;
}
diff -r df3e1ebfed31 -r 5abb6f0edc15 lib/libc/arch/m68k/sys/__m68k_read_tp.S
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/m68k/sys/__m68k_read_tp.S Tue Nov 22 15:25:28 2011 +0000
@@ -0,0 +1,7 @@
+#include "SYS.h"
+
+ENTRY(__m68k_read_tp)
+ SYSTRAP(_lwp_getprivate)
+ movl %d0,%a0
+ rts
+ .size __m68k_read_tp, .-__m68k_read_tp
diff -r df3e1ebfed31 -r 5abb6f0edc15 libexec/ld.elf_so/arch/m68k/mdreloc.c
--- a/libexec/ld.elf_so/arch/m68k/mdreloc.c Tue Nov 22 14:31:02 2011 +0000
+++ b/libexec/ld.elf_so/arch/m68k/mdreloc.c Tue Nov 22 15:25:28 2011 +0000
@@ -1,13 +1,13 @@
-/* $NetBSD: mdreloc.c,v 1.28 2011/03/25 18:07:05 joerg Exp $ */
+/* $NetBSD: mdreloc.c,v 1.29 2011/11/22 15:25:28 joerg Exp $ */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.28 2011/03/25 18:07:05 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.29 2011/11/22 15:25:28 joerg Exp $");
#endif /* not lint */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.28 2011/03/25 18:07:05 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.29 2011/11/22 15:25:28 joerg Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -126,6 +126,47 @@
rdbg(("COPY (avoid in main)"));
break;
+ case R_TYPE(TLS_DTPMOD32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ *where = (Elf_Addr)defobj->tlsindex;
+ rdbg(("DTPMOD32 %s in %s --> %p in %s",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where, defobj->path));
+ break;
+
+ case R_TYPE(TLS_DTPREL32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ *where = (Elf_Addr)(def->st_value + rela->r_addend
+ - TLS_DTV_OFFSET);
+ rdbg(("DTPREL32 %s in %s --> %p in %s",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where, defobj->path));
+ break;
+
+ case R_TYPE(TLS_TPREL32):
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
+ if (def == NULL)
+ return -1;
+
+ if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ return -1;
+
+ *where = (Elf_Addr)(def->st_value + rela->r_addend
+ + defobj->tlsoffset - TLS_TP_OFFSET);
+ rdbg(("TPREL32 %s in %s --> %p in %s",
+ obj->strtab + obj->symtab[symnum].st_name,
+ obj->path, (void *)*where, defobj->path));
+ break;
+
default:
rdbg(("sym = %lu, type = %lu, offset = %p, "
"addend = %p, contents = %p, symbol = %s",
diff -r df3e1ebfed31 -r 5abb6f0edc15 sys/arch/m68k/include/mcontext.h
--- a/sys/arch/m68k/include/mcontext.h Tue Nov 22 14:31:02 2011 +0000
+++ b/sys/arch/m68k/include/mcontext.h Tue Nov 22 15:25:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.8 2011/02/24 04:28:46 joerg Exp $ */
+/* $NetBSD: mcontext.h,v 1.9 2011/11/22 15:25:28 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -109,4 +109,31 @@
#define __UCONTEXT_SIZE 1024
+#if defined(_LIBC_SOURCE) || defined(_RTLD_SOURCE) || defined(__LIBPTHREAD_SOURCE__)
+#define TLS_TP_OFFSET 0x7000
+#define TLS_DTV_OFFSET 0x8000
+
+#include <sys/tls.h>
+
+__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
+__CTASSERT(TLS_TP_OFFSET % sizeof(struct tls_tcb) == 0);
+
+void *_lwp_getprivate(void);
+void _lwp_setprivate(void *);
+
+static __inline struct tls_tcb *
+__lwp_gettcb_fast(void)
+{
+ unsigned int __tcb = (unsigned int)_lwp_getprivate();
+ return (void *)(__tcb - TLS_TP_OFFSET - sizeof(struct tls_tcb));
+}
+
+static inline void
+__lwp_settcb(struct tls_tcb *__tcb)
+{
+ __tcb += TLS_TP_OFFSET / sizeof(*__tcb) + 1;
+ _lwp_setprivate(__tcb);
+}
+#endif
+
#endif /* !_M68K_MCONTEXT_H_ */
diff -r df3e1ebfed31 -r 5abb6f0edc15 sys/arch/m68k/include/types.h
--- a/sys/arch/m68k/include/types.h Tue Nov 22 14:31:02 2011 +0000
+++ b/sys/arch/m68k/include/types.h Tue Nov 22 15:25:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: types.h,v 1.29 2010/12/22 02:42:28 matt Exp $ */
+/* $NetBSD: types.h,v 1.30 2011/11/22 15:25:28 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -73,6 +73,10 @@
#define __HAVE_SYSCALL_INTERN
#define __HAVE_CPU_DATA_FIRST
+#define __HAVE_COMMON___TLS_GET_ADDR
+#define __HAVE___LWP_GETTCB_FAST
+#define __HAVE___LWP_SETTCB
+#define __HAVE_TLS_VARIANT_I
#if defined(_KERNEL)
#define __HAVE_RAS
Home |
Main Index |
Thread Index |
Old Index