This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


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

Fix gethostbyaddr in6addr_any, in6addr_loopback namespace (bug 18532)


gethostbyaddr brings in references to in6addr_any and thereby
in6addr_loopback, which aren't in all the standards containing
gethostbyaddr (gethostbyaddr is in XPG4 and UNIX98, in6addr_any and
in6addr_loopback are new in POSIX.1:2001).  This patch fixes this by
making those symbols into weak aliases (safe in this case, unlike for
most data symbols, because these data symbols are const).

Tested for x86_64 and x86 (testsuite, and comparison of disassembly of
installed stripped shared libraries).  Disassembly is unchanged for
x86_64; for x86, I see some changes of stack offsets, but no other
code generation changes or code size differences.

2015-06-14  Joseph Myers  <joseph@codesourcery.com>

	[BZ #18532]
	* inet/in6_addr.c (in6addr_any): Rename to __in6addr_any and
	define as weak alias of __in6addr_any.  Use libc_hidden_data_weak.
	(in6addr_loopback): Rename to __in6addr_loopback and define as
	weak alias of __in6addr_loopback.  Use libc_hidden_data_weak.
	* include/netinet/in.h (__in6addr_loopback): Declare.  Use
	libc_hidden_proto.
	(__in6addr_any): Likewise.
	* inet/gethstbyad_r.c (PREPROCESS): Use __in6addr_any instead of
	in6addr_any.
	* conform/Makefile (test-xfail-XPG4/netdb.h/linknamespace): Remove
	variable.
	(test-xfail-UNIX98/netdb.h/linknamespace): Likewise.

diff --git a/conform/Makefile b/conform/Makefile
index 522249a..9ad7601 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -346,14 +346,12 @@ test-xfail-XOPEN2K8/ndbm.h/linknamespace = yes
 # Unsorted expected failures.
 test-xfail-XPG3/unistd.h/linknamespace = yes
 test-xfail-XPG4/fmtmsg.h/linknamespace = yes
-test-xfail-XPG4/netdb.h/linknamespace = yes
 test-xfail-XPG4/syslog.h/linknamespace = yes
 test-xfail-XPG4/unistd.h/linknamespace = yes
 test-xfail-POSIX/mqueue.h/linknamespace = yes
 test-xfail-POSIX/semaphore.h/linknamespace = yes
 test-xfail-UNIX98/fmtmsg.h/linknamespace = yes
 test-xfail-UNIX98/mqueue.h/linknamespace = yes
-test-xfail-UNIX98/netdb.h/linknamespace = yes
 test-xfail-UNIX98/syslog.h/linknamespace = yes
 test-xfail-UNIX98/unistd.h/linknamespace = yes
 test-xfail-UNIX98/wchar.h/linknamespace = yes
diff --git a/include/netinet/in.h b/include/netinet/in.h
index 6fb5c86..5e37746 100644
--- a/include/netinet/in.h
+++ b/include/netinet/in.h
@@ -5,7 +5,11 @@
 #ifndef _ISOMAC
 libc_hidden_proto (bindresvport)
 libc_hidden_proto (in6addr_loopback)
+extern __typeof (in6addr_loopback) __in6addr_loopback;
+libc_hidden_proto (__in6addr_loopback)
 libc_hidden_proto (in6addr_any)
+extern __typeof (in6addr_any) __in6addr_any;
+libc_hidden_proto (__in6addr_any)
 #endif
 
 #endif
diff --git a/inet/gethstbyad_r.c b/inet/gethstbyad_r.c
index 72ce441..06d3906 100644
--- a/inet/gethstbyad_r.c
+++ b/inet/gethstbyad_r.c
@@ -32,7 +32,7 @@
    be performed.  */
 #define PREPROCESS \
   if (len == sizeof (struct in6_addr)					      \
-      && __builtin_expect (memcmp (&in6addr_any, addr,			      \
+      && __builtin_expect (memcmp (&__in6addr_any, addr,		      \
 				   sizeof (struct in6_addr)), 1) == 0)	      \
     {									      \
       *h_errnop = HOST_NOT_FOUND;					      \
diff --git a/inet/in6_addr.c b/inet/in6_addr.c
index 782af64..fb77290 100644
--- a/inet/in6_addr.c
+++ b/inet/in6_addr.c
@@ -18,9 +18,13 @@
 
 #include <netinet/in.h>
 
-const struct in6_addr in6addr_any =
+const struct in6_addr __in6addr_any =
 { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } };
-libc_hidden_data_def (in6addr_any)
-const struct in6_addr in6addr_loopback =
+libc_hidden_data_def (__in6addr_any)
+weak_alias (__in6addr_any, in6addr_any)
+libc_hidden_data_weak (in6addr_any)
+const struct in6_addr __in6addr_loopback =
 { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } };
-libc_hidden_data_def (in6addr_loopback)
+libc_hidden_data_def (__in6addr_loopback)
+weak_alias (__in6addr_loopback, in6addr_loopback)
+libc_hidden_data_weak (in6addr_loopback)

-- 
Joseph S. Myers
joseph@codesourcery.com


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