This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Fix h_errno namespace (bug 18520)
- From: Joseph Myers <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Thu, 11 Jun 2015 21:33:31 +0000
- Subject: Fix h_errno namespace (bug 18520)
- Authentication-results: sourceware.org; auth=none
The 2008 edition of POSIX removed h_errno, but some functions still
bring in references to the h_errno external symbol. As this symbol is
not a part of the public ABI (only __h_errno_location is), this patch
fixes this by renaming the GLIBC_PRIVATE TLS symbol to __h_errno.
Tested for x86_64 and x86 (testsuite, and comparison of installed
shared libraries). Disassembly of all shared libraries using h_errno
changes because of the renaming (and changes to associated TLS / GOT
offsets in some cases); disassembly of libpthread on x86_64 changes
more substantially because the enlargement of .dynsym affects
subsequent addresses.
2015-06-11 Joseph Myers <joseph@codesourcery.com>
[BZ #18520]
* inet/herrno.c (h_errno): Rename to __h_errno.
(__libc_h_errno): Define as alias of __h_errno not h_errno.
* include/netdb.h [IS_IN_LIB && !IS_IN (libc)] (h_errno): Define
to __h_errno instead of h_errno.
* nptl/herrno.c (h_errno): Rename to __h_errno.
(__h_errno_location): Refer to __h_errno not h_errno.
* resolv/Versions (h_errno): Rename to __h_errno.
* conform/Makefile (test-xfail-XOPEN2K8/grp.h/linknamespace):
Remove variable.
(test-xfail-XOPEN2K8/pwd.h/linknamespace): Likewise.
diff --git a/conform/Makefile b/conform/Makefile
index 8e76bcb..c259d34 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -373,7 +373,5 @@ test-xfail-POSIX2008/grp.h/linknamespace = yes
test-xfail-POSIX2008/netdb.h/linknamespace = yes
test-xfail-POSIX2008/semaphore.h/linknamespace = yes
test-xfail-XOPEN2K8/fmtmsg.h/linknamespace = yes
-test-xfail-XOPEN2K8/grp.h/linknamespace = yes
test-xfail-XOPEN2K8/netdb.h/linknamespace = yes
-test-xfail-XOPEN2K8/pwd.h/linknamespace = yes
test-xfail-XOPEN2K8/syslog.h/linknamespace = yes
diff --git a/include/netdb.h b/include/netdb.h
index 9e64a15..e1f051d 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -9,7 +9,7 @@
# if IS_IN (libc)
# define h_errno __libc_h_errno
# else
-# define h_errno h_errno /* For #ifndef h_errno tests. */
+# define h_errno __h_errno
# endif
extern __thread int h_errno attribute_tls_model_ie;
# endif /* IS_IN_LIB */
diff --git a/inet/herrno.c b/inet/herrno.c
index 829f032..672a91d 100644
--- a/inet/herrno.c
+++ b/inet/herrno.c
@@ -24,7 +24,7 @@
/* We need to have the error status variable of the resolver
accessible in the libc. */
-__thread int h_errno;
-extern __thread int __libc_h_errno __attribute__ ((alias ("h_errno")))
+__thread int __h_errno;
+extern __thread int __libc_h_errno __attribute__ ((alias ("__h_errno")))
attribute_hidden;
#define h_errno __libc_h_errno
diff --git a/nptl/herrno.c b/nptl/herrno.c
index 281c47e..9c91528 100644
--- a/nptl/herrno.c
+++ b/nptl/herrno.c
@@ -23,12 +23,12 @@
/* We need to have the error status variable of the resolver
accessible in the libc. */
-extern __thread int h_errno;
+extern __thread int __h_errno;
/* When threaded, h_errno may be a per-thread variable. */
int *
__h_errno_location (void)
{
- return &h_errno;
+ return &__h_errno;
}
diff --git a/resolv/Versions b/resolv/Versions
index 04072ac..e561bce 100644
--- a/resolv/Versions
+++ b/resolv/Versions
@@ -24,7 +24,7 @@ libc {
GLIBC_PRIVATE {
__gai_sigqueue;
- h_errno; __resp;
+ __h_errno; __resp;
__res_maybe_init; __res_iclose;
}
--
Joseph S. Myers
joseph@codesourcery.com