]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
* sysdeps/generic/errno.c (__libc_errno): Remove alias.
authorRoland McGrath <roland@gnu.org>
Fri, 15 Nov 2002 03:37:24 +0000 (03:37 +0000)
committerRoland McGrath <roland@gnu.org>
Fri, 15 Nov 2002 03:37:24 +0000 (03:37 +0000)
* 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.

ChangeLog
Makefile
Makerules
linuxthreads/ChangeLog
linuxthreads/Makefile
linuxthreads/libc-tls-loc.c [new file with mode: 0644]
linuxthreads/libc-tsd.c [new file with mode: 0644]
tls.make.c [new file with mode: 0644]

index 1f6afc8ecbb31df7f9d562ef16ff5be46546ddfe..e0d4e7822b4d2006e217f93e6356d1404d67a814 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2002-11-14  Roland McGrath  <roland@redhat.com>
 
+       * 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.
+
        * sysdeps/generic/errno.c [! USE___THREAD]
        [HAVE_ELF && SHARED && DO_VERSIONING] (errno, _errno): Declare these
        with compat_symbol so they are not link-time visible.
index 0358a6c7c55cddac3b8c7299e2ca26d97e8cb63f..70c94225e763e19755ba5b657302fe7383d4f8cd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -272,8 +272,8 @@ distribute  :=      README README.libm INSTALL FAQ FAQ.in NOTES NEWS BUGS   \
                rpm/template rpm/rpmrc glibcbug.in abi-tags stub-tag.h  \
                test-skeleton.c include/des.h include/libc-internal.h   \
                include/shlib-compat.h include/pthread.h Versions.def   \
-               cppflags-iterator.mk INTERFACE CONFORMANCE NAMESPACE    \
-               LICENSES                                                \
+               cppflags-iterator.mk tls.make.c                         \
+               INTERFACE CONFORMANCE NAMESPACE LICENSES                \
                $(addprefix scripts/,                                   \
                            rellns-sh config.sub config.guess           \
                            mkinstalldirs move-if-change install-sh     \
index 55088271346c7f9ce24346503f864341176c9253..89e8c0eb58599ea4d2ea00626e4cfa03e4da15fb 100644 (file)
--- a/Makerules
+++ b/Makerules
@@ -146,6 +146,20 @@ before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
 ifdef before-compile
 $(before-compile):
 endif
+
+# If a makefile needs to do something conditional on something that
+# can only be figured out from headers, write a FOO.make.c input
+# file that uses cpp contructs and contains @@@ LINE @@@ for each LINE
+# to emit in the generated makefile, and use -include $(common-objpfx)FOO.make.
+$(common-objpfx)%.make: $(..)%.make.c $(..)Makerules
+       rm -f $@T $@.dT
+       (echo '# Generated from $*.make.c by Makerules.'; \
+        SUNPRO_DEPENDENCIES='$@.dT $$(common-objpfx)$*.make' \
+        $(CC) $(CFLAGS) $(CPPFLAGS) -E $< \
+        | sed -n '/@@@/{s/@@@[  ]*\(.*\)@@@/\1/;s/[     ]*$$//p;}'; \
+        echo 'common-generated += $(@F)'; \
+        cat $@.dT; rm -f $@.dT) > $@T
+       mv -f $@T $@
 \f
 # Generate an ordered list of implicit rules which find the source files in
 # each sysdep directory.  The old method was to use vpath to search all the
index 77b40b35c1e3285ae90f7545748d2f634a5bbd09..5e5e0f851eabf4940743a8456923b9837fda4e30 100644 (file)
@@ -1,3 +1,22 @@
+2002-11-14  Roland McGrath  <roland@redhat.com>
+
+       * libc-tsd.c: New file.
+       * Makefile (distribute): Add it.
+       (libc-link.so): New variable.
+       ($(objpfx)libpthread.so): Depend on that instead of libc.so file name.
+       (libc-ok-for-link): New variable.
+       [$(versioning) = yes]: Include $(common-objpfx)tls.make and define
+       libc-ok-for-link to $(use-thread).
+       [$(libc-ok-for-link) = no]
+       (libc-link.so): Set to $(objpfx)libc.so, not $(common-objpfx)libc.so.
+       ($(objpfx)libc_pic_lite.a,$(objpfx)libc_pic_lite.os, $(objpfx)libc.so):
+       New targets.
+       (generated): Append them.
+       (extra-objs): Append libc-tsd.os.
+
+       * libc-tls-loc.c: New file.
+       * Makefile (libpthread-routines): Add it.
+
 2002-11-14  Andreas Schwab  <schwab@suse.de>
 
        * sysdeps/unix/sysv/linux/ia64/pt-initfini.c: Fix unterminated
index 772c6914754625ab3295ea604e81083651175ed0..41bb8fff31ed62d86eaa44ee61697b26c5cd96a4 100644 (file)
@@ -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)
diff --git a/linuxthreads/libc-tls-loc.c b/linuxthreads/libc-tls-loc.c
new file mode 100644 (file)
index 0000000..a8d1b4e
--- /dev/null
@@ -0,0 +1,49 @@
+/* Special definitions for libc's own exposed thread-specific variables.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <tls.h>
+
+#if USE___THREAD
+# include <errno.h>
+# include <netdb.h>
+# include <resolv.h>
+
+/* These functions have identical definitions in libc.  But the versioned
+   dependencies in executables bind them to libpthread.so definitions,
+   so we must have some here.  */
+
+int *
+__errno_location (void)
+{
+  return &errno;
+}
+
+int *
+__h_errno_location (void)
+{
+  return &h_errno;
+}
+
+struct __res_state *
+__res_state (void)
+{
+  return &_res;
+}
+
+#endif
diff --git a/linuxthreads/libc-tsd.c b/linuxthreads/libc-tsd.c
new file mode 100644 (file)
index 0000000..ea2497a
--- /dev/null
@@ -0,0 +1,34 @@
+/* Special hack used to build link-time libc.so object for linking libpthread.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <tls.h>
+
+#if ! USE___THREAD
+
+/* Special hack used to build link-time libc.so object for linking libpthread.
+   See Makefile comments near libc_pic_lite.os rule for what this is for.  */
+
+# include <resolv.h>
+# undef _res
+
+int _errno;
+int _h_errno;
+struct __res_state _res;
+
+#endif
diff --git a/tls.make.c b/tls.make.c
new file mode 100644 (file)
index 0000000..6bcd247
--- /dev/null
@@ -0,0 +1,9 @@
+/* This produces a makefile fragment saying `use-thread = yes' or no.  */
+
+#include <tls.h>
+
+#if USE___THREAD
+@@@ use-thread = yes @@@
+#else
+@@@ use-thread = no @@@
+#endif