This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Kill 2 .plt slots in ld.so and fix symbol versions in libpthread.so


Hi!

_dl_allocate_tls and _dl_deallocate_tls were called through .plt in ld.so.
Also, IMHO libpthread.so needs to be linked against ld.so like
libc.so, because it calls various ld.so functions and accesses _rtld_global;
without that all the symbol references are unversioned.

2003-01-03  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/generic/ldsodefs.h (_dl_allocate_tls, _dl_deallocate_tls):
	Add rtld_hidden_proto.
	* sysdeps/generic/dl-tls.c (_dl_deallocate_tls): Add rtld_hidden_def.
	(_dl_allocate_tls): Likewise.  Remove INTDEF.
linuxthreads/
	* Makefile ($(objpfx)libpthread.so): Depend on ld.so.
nptl/
	* Makefile ($(objpfx)libpthread.so): Depend on ld.so.

--- libc/linuxthreads/Makefile.jj	2003-01-03 14:11:54.000000000 +0100
+++ libc/linuxthreads/Makefile	2003-01-03 15:08:31.000000000 +0100
@@ -185,7 +185,9 @@ 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: $(libc-link.so) $(common-objpfx)libc_nonshared.a
+# Depend on ld.so too to get proper versions of ld.so symbols.
+$(objpfx)libpthread.so: $(libc-link.so) $(common-objpfx)libc_nonshared.a \
+			$(if $(filter yes,$(elf)), $(elfobjdir)/ld.so)
 
 # Make sure we link with the thread library.
 ifeq ($(build-shared),yes)
--- libc/sysdeps/generic/ldsodefs.h.jj	2002-12-20 13:36:13.000000000 +0100
+++ libc/sysdeps/generic/ldsodefs.h	2003-01-03 14:59:07.000000000 +0100
@@ -1,5 +1,5 @@
 /* Run-time dynamic linker data structures for loaded ELF shared objects.
-   Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1995-2002, 2003 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
@@ -769,6 +769,7 @@ rtld_hidden_proto (_dl_tls_setup)
 
 /* Allocate memory for static TLS block (unless MEM is nonzero) and dtv.  */
 extern void *_dl_allocate_tls (void *mem) internal_function;
+rtld_hidden_proto (_dl_allocate_tls)
 
 /* Get size and alignment requirements of the static TLS block.  */
 extern void _dl_get_tls_static_info (size_t *sizep, size_t *alignp)
@@ -783,6 +784,7 @@ rtld_hidden_proto (_dl_allocate_tls_init
 
 /* Deallocate memory allocated with _dl_allocate_tls.  */
 extern void _dl_deallocate_tls (void *tcb, bool dealloc_tcb) internal_function;
+rtld_hidden_proto (_dl_deallocate_tls)
 
 /* Return the symbol address given the map of the module it is in and
    the symbol record.  */
--- libc/sysdeps/generic/dl-tls.c.jj	2002-12-10 15:08:54.000000000 +0100
+++ libc/sysdeps/generic/dl-tls.c	2003-01-03 15:00:02.000000000 +0100
@@ -1,5 +1,5 @@
 /* Thread-local storage handling in the ELF dynamic linker.  Generic version.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003 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
@@ -388,7 +388,7 @@ _dl_allocate_tls (void *mem)
 				? _dl_allocate_tls_storage ()
 				: allocate_dtv (mem));
 }
-INTDEF(_dl_allocate_tls)
+rtld_hidden_def (_dl_allocate_tls)
 
 
 void
@@ -409,7 +409,7 @@ _dl_deallocate_tls (void *tcb, bool deal
       free (tcb);
     }
 }
-
+rtld_hidden_def (_dl_deallocate_tls)
 
 
 # ifdef SHARED
--- libc/nptl/Makefile.jj	2003-01-03 01:55:50.000000000 +0100
+++ libc/nptl/Makefile	2003-01-03 15:11:32.000000000 +0100
@@ -212,8 +212,10 @@ $(objpfx)libpthread.so: +preinit += $(ob
 # 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.
+# Depend on ld.so too to get proper versions of ld.so symbols.
 $(objpfx)libpthread.so: $(common-objpfx)libc.so \
-			$(common-objpfx)libc_nonshared.a
+			$(common-objpfx)libc_nonshared.a \
+			$(if $(filter yes,$(elf)), $(elfobjdir)/ld.so)
 
 # Make sure we link with the thread library.
 ifeq ($(build-shared),yes)

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]