diff options
author | Florian Weimer <fweimer@redhat.com> | 2017-12-20 11:40:36 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2017-12-20 11:42:04 +0100 |
commit | 8a26ad2ab7396bc94fd3cd7b25cba433908d30e1 (patch) | |
tree | 3e87bff8b59daaa5c7564532cc48c8d53ee5f7db /nptl/compat-pthread_self.c | |
parent | 5069ff32842c60c55f8b573ee66fe43f9ec364af (diff) | |
download | glibc-8a26ad2ab7396bc94fd3cd7b25cba433908d30e1.zip glibc-8a26ad2ab7396bc94fd3cd7b25cba433908d30e1.tar.gz glibc-8a26ad2ab7396bc94fd3cd7b25cba433908d30e1.tar.bz2 |
nptl: Implement pthread_self in libc.so [BZ #22635]
All binaries use TLS and thus need a properly set up TCB, so we can
simply return its address directly, instead of forwarding to the
libpthread implementation from libc.
For versioned symbols, the dynamic linker checks that the soname matches
the name supplied by the link editor, so a compatibility symbol in
libpthread is needed.
To avoid linking against the libpthread function in all cases, we would
have to bump the symbol version of libpthread in libc.so and supply a
compat symbol. This commit does not do that because the function
implementation is so small, so the overhead by two active copies of the
same function might well be smaller than the increase in symbol table
size.
Diffstat (limited to 'nptl/compat-pthread_self.c')
-rw-r--r-- | nptl/compat-pthread_self.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/nptl/compat-pthread_self.c b/nptl/compat-pthread_self.c new file mode 100644 index 0000000..5e9f4eb --- /dev/null +++ b/nptl/compat-pthread_self.c @@ -0,0 +1,27 @@ +/* Compatibility version of pthread_self in libpthread. + Copyright (C) 2017 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; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Compatibility version of pthread_self for old binaries which link + directly against libpthread's version. */ + +#include <shlib-compat.h> + +#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_27) +# include "pthread_self.c" +compat_symbol (libpthread, pthread_self, pthread_self, GLIBC_2_0); +#endif |