pthreads with -mlibscl

Alex Waugh alex at alexwaugh.com
Mon Feb 17 14:25:13 PST 2003


In message <088d27c64b.peter at moo.chocky.org> you wrote:

> 
> lib1aof.s imports pthreads symbols - which naturally causes a linker
> error if you use -mlibscl with __pthread_running_thread, and includes
> all the extra code.  There's an obvious work around of defining this
> symbol, but do you have a better fix?

The only other thing I can think of is to check for pthreads at
runtime, but this would add extra overhead to each __arm_alloca
function. Therefore the following patch just provides the part of a
pthread_t needed for alloca.


Index: unixlib/source/clib/unixlib/asm_dec.s
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/unixlib/source/clib/unixlib/asm_dec.s,v
retrieving revision 1.5
diff -u -r1.5 asm_dec.s
--- unixlib/source/clib/unixlib/asm_dec.s	22 Dec 2002 18:22:28 -0000	1.5
+++ unixlib/source/clib/unixlib/asm_dec.s	17 Feb 2003 22:03:54 -0000
@@ -34,7 +34,7 @@
 COMPAT_INET4	EQU	0
 
 ; The offset of various members of the __pthread_thread structure
-; This should be kept in sync with pthread.h and lib1aof.s
+; This should be kept in sync with pthread.h, lib1aof.s, and stubs.s
 __PTHREAD_MAGIC_OFFSET	EQU	0
 __PTHREAD_CONTEXT_OFFSET	EQU	4
 __PTHREAD_ALLOCA_OFFSET	EQU	8
Index: libscl/stubs.s
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/libscl/stubs.s,v
retrieving revision 1.3
diff -u -r1.3 stubs.s
--- libscl/stubs.s	2 Jan 2003 10:23:34 -0000	1.3
+++ libscl/stubs.s	17 Feb 2003 22:03:55 -0000
@@ -22,6 +22,10 @@
 
 SharedCLibrary_LibInitAPCS_R	EQU &80681
 SharedCLibrary_LibInitAPCS_32	EQU &80683
+
+; Keep these in sync with unixlib/asm_dec.s and features.h
+__FEATURE_PTHREADS	EQU	1
+__PTHREAD_ALLOCA_OFFSET	EQU	8
  
 	IMPORT	|Image$$RO$$Base|
 	IMPORT	|RTSK$$Data$$Base|
@@ -371,6 +375,16 @@
 	; no fast event proc
 	; no unwind proc
 	; no name proc
+
+; Provide storage for __arm_alloca
+	[ __FEATURE_PTHREADS = 1
+	AREA	|C$$Data|, DATA
+	EXPORT	|__pthread_running_thread|
+|__pthread_running_thread|
+	DCD	|__pthread_running_thread_data|-__PTHREAD_ALLOCA_OFFSET
+|__pthread_running_thread_data|
+	%	12
+	]
 
 	AREA	|C$$Code|, CODE, READONLY
 language_name

-- 
Alex Waugh                                           alex at alexwaugh.com

PHP, Roots, Subversion, WebJames and more from http://www.alexwaugh.com/




More information about the gcc mailing list