Subject: Re: Text relocations in libpthread
To: None <tech-toolchain@netbsd.org>
From: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
List: tech-toolchain
Date: 12/27/2005 11:38:05
On Tue, Dec 27, 2005 at 08:11:47 +0000, Nick Hudson wrote:

> not sure I've got sh3 right?

sh3 also needs r12 to be set up before doing plt calls.  You can leave
sh3 out and I will take care of it.


> 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)

I think these *_return_point symbols should be made .hidden, then
these diffs will not be necessary.  As with cerror, I don't see a
reason why we would want to make them globally visible/overridable.


SY, Uwe
-- 
uwe@ptc.spbu.ru                         |       Zu Grunde kommen
http://snark.ptc.spbu.ru/~uwe/          |       Ist zu Grunde gehen