Subject: Text relocations in libpthread
To: None <tech-toolchain@netbsd.org>
From: Nick Hudson <skrll@netbsd.org>
List: tech-toolchain
Date: 12/27/2005 08:11:47
--Boundary-00=_DdPsD+zcNhfxd0S
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
[should this be on tech-userlevel?]
The attached (untested) patch removes the text relocations from libpthread.so
for i386, sh3, sparc, sparc64, and x86_64
Can someone test and/or comment before I commit - not sure I've got sh3 right?
Nick
--Boundary-00=_DdPsD+zcNhfxd0S
Content-Type: text/x-diff;
charset="us-ascii";
name="textrel.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="textrel.diff"
Index: lib/libpthread/arch/i386/pthread_switch.S
===================================================================
RCS file: /cvsroot/src/lib/libpthread/arch/i386/pthread_switch.S,v
retrieving revision 1.8
diff -u -p -u -r1.8 pthread_switch.S
--- lib/libpthread/arch/i386/pthread_switch.S 23 Apr 2004 02:58:27 -0000 1.8
+++ lib/libpthread/arch/i386/pthread_switch.S 27 Dec 2005 07:12:16 -0000
@@ -168,7 +168,6 @@ NENTRY(pthread__switch_return_point)
* Helper switch code used by pthread__locked_switch() and
* pthread__upcall_switch() when they discover spinlock preemption.
*/
-.globl pthread__switch_away
pthread__switch_away:
STACK_SWITCH
Index: lib/libpthread/arch/sh3/_context_u.S
===================================================================
RCS file: /cvsroot/src/lib/libpthread/arch/sh3/_context_u.S,v
retrieving revision 1.4
diff -u -p -u -r1.4 _context_u.S
--- lib/libpthread/arch/sh3/_context_u.S 17 Nov 2003 22:38:11 -0000 1.4
+++ lib/libpthread/arch/sh3/_context_u.S 27 Dec 2005 07:12:16 -0000
@@ -125,7 +125,7 @@
MAYBE_MOV_UC_R4(uc) ; \
NOTREACHED ; \
.align 2 ; \
-2: .long _C_LABEL(setcontext)-(1b+4)
+2: .long _C_LABEL(setcontext)@PLT-(1b+4-(.))
#else /* !PIC */
/*
* For static code all calls to setcontext can share single locations
Index: lib/libpthread/arch/sh3/pthread_switch.S
===================================================================
RCS file: /cvsroot/src/lib/libpthread/arch/sh3/pthread_switch.S,v
retrieving revision 1.5
diff -u -p -u -r1.5 pthread_switch.S
--- lib/libpthread/arch/sh3/pthread_switch.S 28 May 2004 22:58:25 -0000 1.5
+++ lib/libpthread/arch/sh3/pthread_switch.S 27 Dec 2005 07:12:16 -0000
@@ -72,7 +72,7 @@
#define CALL(r) bsrf r
#define CALL_DATUM(call_l,target_l) \
-CALL_TARGET(call_l,target_l): .long _C_LABEL(target_l) - (call_l+4)
+CALL_TARGET(call_l,target_l): .long _C_LABEL(target_l)@PLT - (call_l+4-(.))
#else /* !PIC */
#define CALL(r) jsr @r
Index: lib/libpthread/arch/sparc/pthread_switch.S
===================================================================
RCS file: /cvsroot/src/lib/libpthread/arch/sparc/pthread_switch.S,v
retrieving revision 1.7
diff -u -p -u -r1.7 pthread_switch.S
--- lib/libpthread/arch/sparc/pthread_switch.S 7 Sep 2003 14:47:54 -0000 1.7
+++ lib/libpthread/arch/sparc/pthread_switch.S 27 Dec 2005 07:12:17 -0000
@@ -122,7 +122,7 @@ ENTRY_NOPROFILE(pthread__switch_return_p
* %i2 flag to clear lock
*/
-ENTRY(pthread__switch_away)
+pthread__switch_away:
STACK_SWITCH(%i1, %l2)
Index: lib/libpthread/arch/sparc64/pthread_switch.S
===================================================================
RCS file: /cvsroot/src/lib/libpthread/arch/sparc64/pthread_switch.S,v
retrieving revision 1.8
diff -u -p -u -r1.8 pthread_switch.S
--- lib/libpthread/arch/sparc64/pthread_switch.S 7 Sep 2003 14:47:55 -0000 1.8
+++ lib/libpthread/arch/sparc64/pthread_switch.S 27 Dec 2005 07:12:17 -0000
@@ -111,7 +111,7 @@ ENTRY_NOPROFILE(pthread__switch_return_p
* %i2 flag to clear lock
*/
-ENTRY(pthread__switch_away)
+pthread__switch_away:
STACK_SWITCH(%i1,%l2)
Index: lib/libpthread/arch/x86_64/pthread_switch.S
===================================================================
RCS file: /cvsroot/src/lib/libpthread/arch/x86_64/pthread_switch.S,v
retrieving revision 1.10
diff -u -p -u -r1.10 pthread_switch.S
--- lib/libpthread/arch/x86_64/pthread_switch.S 23 Apr 2004 02:58:27 -0000 1.10
+++ lib/libpthread/arch/x86_64/pthread_switch.S 27 Dec 2005 07:12:17 -0000
@@ -136,7 +136,11 @@ ENTRY(pthread__switch)
* Edit the context so that it continues as if returning from
* the _setcontext_u below.
*/
+#ifdef PIC
+ movq PIC_GOT(pthread__switch_return_point), %r15
+#else
leaq pthread__switch_return_point(%rip), %r15
+#endif
movq %r15, UC_RIP(%r14)
movq %r14, PT_UC(%r12)
@@ -157,7 +161,6 @@ NENTRY(pthread__switch_return_point)
* Helper switch code used by pthread__locked_switch() and
* pthread__upcall_switch() when they discover spinlock preemption.
*/
-.globl pthread__switch_away
pthread__switch_away:
STACK_SWITCH
@@ -204,7 +207,11 @@ ENTRY(pthread__locked_switch)
* Edit the context so that it continues as if returning from
* the _setcontext_u below.
*/
+#ifdef PIC
+ movq PIC_GOT(locked_return_point), %r15
+#else
leaq locked_return_point(%rip), %r15
+#endif
movq %r15, UC_RIP(%r14)
movq %r14, PT_UC(%r12)
--Boundary-00=_DdPsD+zcNhfxd0S--