From patchwork Tue Dec 2 01:58:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 4027 Received: (qmail 26252 invoked by alias); 2 Dec 2014 01:59:11 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 26002 invoked by uid 89); 2 Dec 2014 01:59:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Tue, 2 Dec 2014 01:58:51 +0000 From: Joseph Myers To: Subject: Fix getifaddrs, freeifaddrs namespace (bug 17668) Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Various objects in glibc bring in ifaddrs.o (via references to __netlink_*) and thereby getifaddrs and freeifaddrs, which are not part of any standard supported by glibc. These should be weak aliases of __getifaddrs and __freeifaddrs; this patch makes them so. (The path by which these functions are brought in is Linux-specific, but it seems less confusing to make all versions of these functions weak aliases rather than only the Linux-specific versions that definitely need it.) Tested for x86_64 (testsuite, and that disassembly of installed shared libraries is unchanged by this patch). 2014-12-02 Joseph Myers [BZ #17668] * inet/ifaddrs.c (getifaddrs): Rename to __getifaddrs and define as weak alias of __getifaddrs. Use libc_hidden_weak. (freeifaddrs): Rename to __freeifaddrs and define as weak alias of __freeifaddrs. Use libc_hidden_weak. * sysdeps/gnu/ifaddrs.c (getifaddrs): Rename to __getifaddrs and define as weak alias of __getifaddrs. Use libc_hidden_weak. (freeifaddrs): Rename to __freeifaddrs and define as weak alias of __freeifaddrs. Use libc_hidden_weak. * sysdeps/unix/sysv/linux/ifaddrs.c (getifaddrs): Rename to __getifaddrs and define as weak alias of __getifaddrs. Use libc_hidden_weak. (freeifaddrs): Rename to __freeifaddrs and define as weak alias of __freeifaddrs. Use libc_hidden_weak. * conform/Makefile (test-xfail-XOPEN2K/net/if.h/linknamespace): Remove variable. (test-xfail-POSIX2008/net/if.h/linknamespace): Likewise. (test-xfail-XOPEN2K8/net/if.h/linknamespace): Likewise. diff --git a/conform/Makefile b/conform/Makefile index 641f546..0c3d3ca 100644 --- a/conform/Makefile +++ b/conform/Makefile @@ -418,7 +418,6 @@ test-xfail-XOPEN2K/glob.h/linknamespace = yes test-xfail-XOPEN2K/grp.h/linknamespace = yes test-xfail-XOPEN2K/libgen.h/linknamespace = yes test-xfail-XOPEN2K/mqueue.h/linknamespace = yes -test-xfail-XOPEN2K/net/if.h/linknamespace = yes test-xfail-XOPEN2K/netdb.h/linknamespace = yes test-xfail-XOPEN2K/pthread.h/linknamespace = yes test-xfail-XOPEN2K/pwd.h/linknamespace = yes @@ -442,7 +441,6 @@ test-xfail-POSIX2008/dirent.h/linknamespace = yes test-xfail-POSIX2008/fcntl.h/linknamespace = yes test-xfail-POSIX2008/grp.h/linknamespace = yes test-xfail-POSIX2008/mqueue.h/linknamespace = yes -test-xfail-POSIX2008/net/if.h/linknamespace = yes test-xfail-POSIX2008/netdb.h/linknamespace = yes test-xfail-POSIX2008/pthread.h/linknamespace = yes test-xfail-POSIX2008/regex.h/linknamespace = yes @@ -459,7 +457,6 @@ test-xfail-XOPEN2K8/fmtmsg.h/linknamespace = yes test-xfail-XOPEN2K8/grp.h/linknamespace = yes test-xfail-XOPEN2K8/libgen.h/linknamespace = yes test-xfail-XOPEN2K8/mqueue.h/linknamespace = yes -test-xfail-XOPEN2K8/net/if.h/linknamespace = yes test-xfail-XOPEN2K8/netdb.h/linknamespace = yes test-xfail-XOPEN2K8/pthread.h/linknamespace = yes test-xfail-XOPEN2K8/pwd.h/linknamespace = yes diff --git a/inet/ifaddrs.c b/inet/ifaddrs.c index 8071600..bc273c6 100644 --- a/inet/ifaddrs.c +++ b/inet/ifaddrs.c @@ -24,16 +24,17 @@ network interface on the host machine. If successful, store the list in *IFAP and return 0. On errors, return -1 and set `errno'. */ int -getifaddrs (struct ifaddrs **ifap) +__getifaddrs (struct ifaddrs **ifap) { __set_errno (ENOSYS); return -1; } -libc_hidden_def (getifaddrs) +weak_alias (__getifaddrs, getifaddrs) +libc_hidden_weak (getifaddrs) stub_warning (getifaddrs) void -freeifaddrs (struct ifaddrs *ifa) +__freeifaddrs (struct ifaddrs *ifa) { if (ifa == NULL) return; /* a la free, why not? */ @@ -41,5 +42,6 @@ freeifaddrs (struct ifaddrs *ifa) /* Can't be called properly if getifaddrs never succeeded. */ abort (); } -libc_hidden_def (freeifaddrs) +weak_alias (__freeifaddrs, freeifaddrs) +libc_hidden_weak (freeifaddrs) stub_warning (freeifaddrs) diff --git a/sysdeps/gnu/ifaddrs.c b/sysdeps/gnu/ifaddrs.c index 1b8775f..3607b2c 100644 --- a/sysdeps/gnu/ifaddrs.c +++ b/sysdeps/gnu/ifaddrs.c @@ -32,7 +32,7 @@ network interface on the host machine. If successful, store the list in *IFAP and return 0. On errors, return -1 and set `errno'. */ int -getifaddrs (struct ifaddrs **ifap) +__getifaddrs (struct ifaddrs **ifap) { /* This implementation handles only IPv4 interfaces. The various ioctls below will only work on an AF_INET socket. @@ -150,13 +150,15 @@ getifaddrs (struct ifaddrs **ifap) return 0; } +weak_alias (__getifaddrs, getifaddrs) #ifndef getifaddrs -libc_hidden_def (getifaddrs) +libc_hidden_weak (getifaddrs) #endif void -freeifaddrs (struct ifaddrs *ifa) +__freeifaddrs (struct ifaddrs *ifa) { free (ifa); } -libc_hidden_def (freeifaddrs) +weak_alias (__freeifaddrs, freeifaddrs) +libc_hidden_weak (freeifaddrs) diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c index a47b2ed..3f03f86 100644 --- a/sysdeps/unix/sysv/linux/ifaddrs.c +++ b/sysdeps/unix/sysv/linux/ifaddrs.c @@ -819,7 +819,7 @@ getifaddrs_internal (struct ifaddrs **ifap) network interface on the host machine. If successful, store the list in *IFAP and return 0. On errors, return -1 and set `errno'. */ int -getifaddrs (struct ifaddrs **ifap) +__getifaddrs (struct ifaddrs **ifap) { int res; @@ -829,12 +829,14 @@ getifaddrs (struct ifaddrs **ifap) return res; } -libc_hidden_def (getifaddrs) +weak_alias (__getifaddrs, getifaddrs) +libc_hidden_weak (getifaddrs) void -freeifaddrs (struct ifaddrs *ifa) +__freeifaddrs (struct ifaddrs *ifa) { free (ifa); } -libc_hidden_def (freeifaddrs) +weak_alias (__freeifaddrs, freeifaddrs) +libc_hidden_weak (freeifaddrs)