summaryrefslogtreecommitdiff
path: root/lib/libpthread
diff options
context:
space:
mode:
authoruwe <uwe@NetBSD.org>2006-01-04 17:44:53 +0000
committeruwe <uwe@NetBSD.org>2006-01-04 17:44:53 +0000
commit55ad9313a64076a93e02c2bdb76e68cdebd4817f (patch)
tree599ce77fff553069ac81bf425c5e23e14efbb82e /lib/libpthread
parentb2bb747d7ca2efad3ad74be0f38414641d671e77 (diff)
In PIC code call setcontext(2) via PLT to avoid text reloc in the
shared library.
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/arch/sh3/_context_u.S36
1 files changed, 22 insertions, 14 deletions
diff --git a/lib/libpthread/arch/sh3/_context_u.S b/lib/libpthread/arch/sh3/_context_u.S
index 54cfe56c0b0..ba229593104 100644
--- a/lib/libpthread/arch/sh3/_context_u.S
+++ b/lib/libpthread/arch/sh3/_context_u.S
@@ -1,4 +1,4 @@
-/* $NetBSD: _context_u.S,v 1.4 2003/11/17 22:38:11 uwe Exp $ */
+/* $NetBSD: _context_u.S,v 1.5 2006/01/04 17:44:53 uwe Exp $ */
/*
* Copyright (c) 2003 Christian P. Groessler
@@ -114,36 +114,44 @@
/* NOTREACHED */
#ifdef PIC
+
/*
* For PIC code we need a per-call offset to the setcontext.
* Fortunately, since setcontext(2) does not return, we can
- * put the offset right after the call.
+ * put the offset right after the call. We also don't need to
+ * save/restore r12.
*/
#define CALL_SETCONTEXT(uc) \
- mov.l 2f, r1 ; \
+ mov.l 2f, r12 ; \
+ mov.l 3f, r1 ; \
+ mova 2f, r0 ; \
+.ifnc "uc","r4" ; \
+ mov uc, r4 ; \
+.endif ; \
1: bsrf r1 ; \
- MAYBE_MOV_UC_R4(uc) ; \
+ add r0, r12 ; \
NOTREACHED ; \
.align 2 ; \
-2: .long _C_LABEL(setcontext)-(1b+4)
+2: .long _GLOBAL_OFFSET_TABLE_ ; \
+3: CALL_DATUM(_C_LABEL(setcontext), 1b)
+
#else /* !PIC */
+
/*
- * For static code all calls to setcontext can share single locations
+ * For static code all calls to setcontext can share single location
* with the address of setcontext (see below).
*/
#define CALL_SETCONTEXT(uc) \
mov.l .L_setcontext, r1 ; \
jsr @r1 ; \
- MAYBE_MOV_UC_R4(uc) ; \
+.ifnc "uc","r4" ; \
+ mov uc, r4 ; \
+.else ; \
+ nop ; \
+.endif ; \
NOTREACHED
-#endif
-#define MAYBE_MOV_UC_R4(uc) \
-.ifc "uc","r4" ; \
- nop ; \
-.else ; \
- mov uc, r4 ; \
-.endif
+#endif