PATCH: A testcase for static TLS (Re: Does TLS work with static binary?)

H. J. Lu hjl@lucon.org
Tue Jul 16 10:00:00 GMT 2002


On Mon, Jul 15, 2002 at 12:29:05PM -0700, H. J. Lu wrote:
> I got
> 
> # gcc -g ex1.c  -lpthread -static
> # ./a.out   
> zsh: 9579 segmentation fault  ./a.out
> 
> # gdb a.out core
> ...
> Program terminated with signal 11, Segmentation fault.
> #0  __pthread_initialize_minimal () at pthread.c:404
> 404       pthread_descr self = THREAD_SELF;
> (gdb) bt
> #0  __pthread_initialize_minimal () at pthread.c:404
> #1  0x0804dcc0 in __libc_start_main (main=0x8048250 <main>, argc=1, 
>     ubp_av=0xbffffa24, init=0x80480b4 <_init>, fini=0x80ab2a0 <_fini>, 
>     rtld_fini=0, stack_end=0xbffffa1c) at ../sysdeps/generic/libc-start.c:84
> 
> 
> Has anyone seen this?
> 

Here is a testcase. I got

GCONV_PATH=/export/build/gnu/glibc/build-i686-linux/iconvdata LC_ALL=C /export/build/gnu/glibc/build-i686-linux/linuxthreads/tststatic  > /export/build/gnu/glibc/build-i686-linux/linuxthreads/tststatic.out
make[2]: *** [/export/build/gnu/glibc/build-i686-linux/linuxthreads/tststatic.out] Error 139


H.J.
-------------- next part --------------
2002-07-16  H.J. Lu  <hjl@gnu.org>

	* Examples/tststatic.c: New.

	* Makefile (tests): Add tststatic.
	(tests-static): Likewise.
	Make $(tests-static) depend on libpthread.a instead of
	libpthread.so.

--- linuxthreads/Examples/tststatic.c.static	Tue Jul 16 09:45:23 2002
+++ linuxthreads/Examples/tststatic.c	Tue Jul 16 09:45:16 2002
@@ -0,0 +1 @@
+#include "ex1.c"
--- linuxthreads/Makefile.static	Tue Jul 16 08:51:45 2002
+++ linuxthreads/Makefile	Tue Jul 16 09:56:15 2002
@@ -63,6 +63,11 @@ tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 
 	ex17 ex18 tst-cancel tst-context bug-sleep
 test-srcs = tst-signal
 
+ifeq ($(build-static),yes)
+tests += tststatic
+tests-static += tststatic
+endif
+
 ifeq (yes,$(build-shared))
 tests-nodelete-yes = unload
 endif
@@ -91,7 +96,9 @@ $(objpfx)libpthread.so: $(common-objpfx)
 
 # Make sure we link with the thread library.
 ifeq ($(build-shared),yes)
-$(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.so
+$(addprefix $(objpfx), \
+  $(filter-out $(tests-static), \
+    $(tests) $(test-srcs))): $(objpfx)libpthread.so
 $(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.so
 $(objpfx)unload: $(common-objpfx)dlfcn/libdl.so
 else
@@ -103,6 +110,10 @@ $(tests:%=$(objpfx)%-bp): $(objpfx)libpt
 $(librt-tests:%=$(objpfx)%-bp): $(common-objpfx)rt/librt_b.a
 endif
 
+ifeq ($(build-static),yes)
+$(addprefix $(objpfx), $(tests-static)): $(objpfx)libpthread.a
+endif
+
 ifeq ($(build-shared),yes)
 vpath pt-initfini.c $(full_config_sysdirs)
 


More information about the Libc-alpha mailing list