Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add a workaround for older crt0.o that overwrite r2 (tcb poi...
details: https://anonhg.NetBSD.org/src/rev/1cca8d75cd57
branches: trunk
changeset: 763920:1cca8d75cd57
user: matt <matt%NetBSD.org@localhost>
date: Thu Apr 07 02:19:28 2011 +0000
description:
Add a workaround for older crt0.o that overwrite r2 (tcb pointer).
(save tcb pointer using _lwp_setprivate in ld.elf_so and retrieve the tcb
via _lwp_getprivate in libc and use it to restore the value in r2).
diffstat:
lib/libc/tls/tls.c | 16 +++++++++++++---
libexec/ld.elf_so/tls.c | 11 +++++++++--
2 files changed, 22 insertions(+), 5 deletions(-)
diffs (70 lines):
diff -r 3b4503eaeb29 -r 1cca8d75cd57 lib/libc/tls/tls.c
--- a/lib/libc/tls/tls.c Thu Apr 07 02:05:02 2011 +0000
+++ b/lib/libc/tls/tls.c Thu Apr 07 02:19:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tls.c,v 1.5 2011/03/18 14:56:01 he Exp $ */
+/* $NetBSD: tls.c,v 1.6 2011/04/07 02:19:28 matt Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: tls.c,v 1.5 2011/03/18 14:56:01 he Exp $");
+__RCSID("$NetBSD: tls.c,v 1.6 2011/04/07 02:19:28 matt Exp $");
#include "namespace.h"
@@ -154,8 +154,18 @@
{
struct tls_tcb *tcb;
- if (&rtld_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL) {
+#ifdef __powerpc__
+ /*
+ * Old powerpc crt0's are going to overwrite r2 so we need to
+ * restore it but only do so if the saved value isn't NULL (if
+ * it is NULL, ld.elf_so doesn't have the matching change).
+ */
+ if ((tcb = _lwp_getprivate()) != NULL)
+ __lwp_settcb(tcb);
+#endif
return;
+ }
dl_iterate_phdr(__libc_static_tls_setup_cb, NULL);
diff -r 3b4503eaeb29 -r 1cca8d75cd57 libexec/ld.elf_so/tls.c
--- a/libexec/ld.elf_so/tls.c Thu Apr 07 02:05:02 2011 +0000
+++ b/libexec/ld.elf_so/tls.c Thu Apr 07 02:19:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tls.c,v 1.5 2011/03/29 20:56:35 joerg Exp $ */
+/* $NetBSD: tls.c,v 1.6 2011/04/07 02:19:28 matt Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: tls.c,v 1.5 2011/03/29 20:56:35 joerg Exp $");
+__RCSID("$NetBSD: tls.c,v 1.6 2011/04/07 02:19:28 matt Exp $");
#include <sys/param.h>
#include <sys/ucontext.h>
@@ -104,6 +104,13 @@
tcb = _rtld_tls_allocate_locked();
#ifdef __HAVE___LWP_SETTCB
__lwp_settcb(tcb);
+#ifdef __powerpc__
+ /*
+ * Save the tcb pointer so that libc can retrieve it. Older
+ * crt0 will obliterate r2 so there is code in libc to restore it.
+ */
+ _lwp_setprivate(tcb);
+#endif
#else
_lwp_setprivate(tcb);
#endif
Home |
Main Index |
Thread Index |
Old Index