about summary refs log tree commit diff
path: root/linuxthreads/Makefile
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-11-15 03:37:24 +0000
committerRoland McGrath <roland@gnu.org>2002-11-15 03:37:24 +0000
commit53da80ab8870138b81b212c540c32b5c1eeccaf4 (patch)
tree99cc0b072130164fccc123c707675c82b8dd8224 /linuxthreads/Makefile
parent3fa5f1fa0a4973c6915fbfe0a43cbbe57c9b8ca9 (diff)
downloadglibc-53da80ab8870138b81b212c540c32b5c1eeccaf4.tar.gz
glibc-53da80ab8870138b81b212c540c32b5c1eeccaf4.tar.xz
glibc-53da80ab8870138b81b212c540c32b5c1eeccaf4.zip
* sysdeps/generic/errno.c (__libc_errno): Remove alias.
	* inet/herrno.c (__libc_h_errno): Likewise.
	* resolv/res_libc.c (__libc_res): Likewise.
	[USE___THREAD]: Use this in place of [USE_TLS && HAVE___THREAD].
	(__res_state) [! USE___THREAD]: Don't define as weak.
	* csu/Versions: Revert last change.
	* resolv/Versions: Revert last change.

	* Makerules ($(common-objpfx)%.make): New pattern rule.
	* tls.make.c: New file.
	* Makefile (distribute): Add it.
Diffstat (limited to 'linuxthreads/Makefile')
-rw-r--r--linuxthreads/Makefile47
1 files changed, 43 insertions, 4 deletions
diff --git a/linuxthreads/Makefile b/linuxthreads/Makefile
index 772c691475..41bb8fff31 100644
--- a/linuxthreads/Makefile
+++ b/linuxthreads/Makefile
@@ -25,7 +25,8 @@ linuxthreads-version := $(shell sed -n 's/^.*$(subdir)-\([0-9.]*\).*$$/\1/p' \
 				    Banner)
 
 headers := pthread.h semaphore.h
-distribute := internals.h queue.h restart.h spinlock.h smp.h tst-signal.sh
+distribute := internals.h queue.h restart.h spinlock.h smp.h tst-signal.sh \
+	      libc-tsd.c
 
 routines := weaks no-tsd
 
@@ -37,7 +38,7 @@ libpthread-routines := attr cancel condvar join manager mutex ptfork \
 		       semaphore spinlock wrapsyscall rwlock pt-machine \
 		       oldsemaphore events getcpuclockid pspinlock barrier \
 		       ptclock_gettime ptclock_settime sighandler \
-		       pthandles
+		       pthandles libc-tls-loc
 
 nodelete-yes = -Wl,--enable-new-dtags,-z,nodelete
 initfirst-yes = -Wl,--enable-new-dtags,-z,initfirst
@@ -89,11 +90,49 @@ CFLAGS-cancel.c += -D__NO_WEAK_PTHREAD_ALIASES -D_RPC_THREAD_SAFE_
 CFLAGS-unload.c += -DPREFIX=\"$(objpfx)\"
 CFLAGS-sighandler.c += $(exceptions)
 
+ifeq (yes,$(versioning))
+-include $(common-objpfx)tls.make
+libc-ok-for-link = $(use-thread)
+else
+libc-ok-for-link = yes
+endif
+
+ifeq (no,$(libc-ok-for-link))
+# These hacks are necessary to let us link against a libc.so that exports
+# the symbols _errno, _h_errno, and _res.  Those symbols are accessible
+# in libc at runtime (dynamic linkable), but are not exported at link time
+# so that applications cannot link against them.  However, libpthread.so
+# needs to link against them for its __errno_location et al functions to
+# find the locations that libc's symbols resolve to.  We cannot do this
+# with aliases in libc.so(GLIBC_PRIVATE), because we need to refer to an
+# executable's symbols when it defines them with copy relocs.
+libc-link.so = $(objpfx)libc.so
+
+$(objpfx)libc_pic_lite.a: $(common-objpfx)libc_pic.a
+	cp $< $@T
+	$(AR) d $@T errno.os herrno.os res_libc.os
+	mv -f $@T $@
+
+extra-objs += libc-tsd.os
+$(objpfx)libc_pic_lite.os: $(objpfx)libc_pic_lite.a $(objpfx)libc-tsd.os
+	$(LINK.o) -nostdlib -nostartfiles -r -o $@ \
+		  $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
+
+$(objpfx)libc.so: $(elfobjdir)/soinit.os \
+		  $(objpfx)libc_pic_lite.os \
+		  $(elfobjdir)/sofini.os \
+		  $(elfobjdir)/interp.os $(elfobjdir)/ld.so
+	$(build-shlib)
+
+generated += libc_pic_lite.a libc_pic_lite.os libc.so
+else
+libc-link.so = $(common-objpfx)libc.so
+endif
+
 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
 # This ensures they will load libc.so for needed symbols if loaded by
 # a statically-linked program that hasn't already loaded it.
-$(objpfx)libpthread.so: $(common-objpfx)libc.so \
-			$(common-objpfx)libc_nonshared.a
+$(objpfx)libpthread.so: $(libc-link.so) $(common-objpfx)libc_nonshared.a
 
 # Make sure we link with the thread library.
 ifeq ($(build-shared),yes)