diff mbox series

[hurd,commited,4/4] hurd: Fix `getifaddrs' and `freeifaddrs' symbol exposition

Message ID 20170927231742.9050-5-samuel.thibault@ens-lyon.org
State New
Headers show
Series Fixing symbol exposition.s | expand

Commit Message

Samuel Thibault Sept. 27, 2017, 11:17 p.m. UTC
from `freeaddrinfo'.

`getifaddrs' and `freeifaddrs' are not in POSIX, they should not be
exposed along `freeaddrinfo' (through `__check_pf') which is POSIX.

	* include/ifaddrs.h (__getifaddrs, __freeifaddrs): New declarations,
	and use libc_hidden_def on them.
	* inet/ifaddrs.c (__getifaddrs, __freeifaddrs): Use libc_hidden_def on
	them.
	* sysdeps/gnu/ifaddrs.c (__getifaddrs, __freeifaddrs): Likewise.
	* inet/check_pf.c (__check_pf): Use __getifaddrs and __freeifaddrs
	instead of getifaddrs and freeifaddrs.
---
 ChangeLog             | 7 +++++++
 include/ifaddrs.h     | 5 +++++
 inet/check_pf.c       | 4 ++--
 inet/ifaddrs.c        | 2 ++
 sysdeps/gnu/ifaddrs.c | 2 ++
 5 files changed, 18 insertions(+), 2 deletions(-)

Comments

H.J. Lu Sept. 28, 2017, 12:21 a.m. UTC | #1
On 9/27/17, Samuel Thibault <samuel.thibault@ens-lyon.org> wrote:
> from `freeaddrinfo'.
>
> `getifaddrs' and `freeifaddrs' are not in POSIX, they should not be
> exposed along `freeaddrinfo' (through `__check_pf') which is POSIX.
>
> 	* include/ifaddrs.h (__getifaddrs, __freeifaddrs): New declarations,
> 	and use libc_hidden_def on them.
> 	* inet/ifaddrs.c (__getifaddrs, __freeifaddrs): Use libc_hidden_def on
> 	them.
> 	* sysdeps/gnu/ifaddrs.c (__getifaddrs, __freeifaddrs): Likewise.
> 	* inet/check_pf.c (__check_pf): Use __getifaddrs and __freeifaddrs
> 	instead of getifaddrs and freeifaddrs.
>

I checked in this patch to fix Linux build.
Samuel Thibault Sept. 28, 2017, 5:15 a.m. UTC | #2
Hello,

H.J. Lu, on mer. 27 sept. 2017 17:21:40 -0700, wrote:
> On 9/27/17, Samuel Thibault <samuel.thibault@ens-lyon.org> wrote:
> > from `freeaddrinfo'.
> >
> > `getifaddrs' and `freeifaddrs' are not in POSIX, they should not be
> > exposed along `freeaddrinfo' (through `__check_pf') which is POSIX.
> >
> > 	* include/ifaddrs.h (__getifaddrs, __freeifaddrs): New declarations,
> > 	and use libc_hidden_def on them.
> > 	* inet/ifaddrs.c (__getifaddrs, __freeifaddrs): Use libc_hidden_def on
> > 	them.
> > 	* sysdeps/gnu/ifaddrs.c (__getifaddrs, __freeifaddrs): Likewise.
> > 	* inet/check_pf.c (__check_pf): Use __getifaddrs and __freeifaddrs
> > 	instead of getifaddrs and freeifaddrs.
> >
> 
> I checked in this patch to fix Linux build.
> 
> ../sysdeps/unix/sysv/linux/ifaddrs.c:835:27: error: ‘getifaddrs’ aliased to undefined symbol ‘__getifaddrs’
>  weak_alias (__getifaddrs, getifaddrs)
>                            ^
> ../sysdeps/unix/sysv/linux/ifaddrs.c:844:28: error: ‘freeifaddrs’ aliased to undefined symbol ‘__freeifaddrs’
>  weak_alias (__freeifaddrs, freeifaddrs)
> 
> caused by
> 
> commit 4009ddc69225d571772aaea597615a0c032e14ab

Oh, sorry, I missed that the mere addition of libc_hidden_proto would
change the needs of other archs.

Thanks,
Samuel
diff mbox series

Patch

diff --git a/ChangeLog b/ChangeLog
index 737dc8f808..8e26c003a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,13 @@ 
 	redefine as weak alias.
 	* sysdeps/mach/hurd/rewinddir.c (__rewinddir): Use __seekdir instead
 	of seekdir.
+	* include/ifaddrs.h (__getifaddrs, __freeifaddrs): New declarations,
+	and use libc_hidden_def on them.
+	* inet/ifaddrs.c (__getifaddrs, __freeifaddrs): Use libc_hidden_def on
+	them.
+	* sysdeps/gnu/ifaddrs.c (__getifaddrs, __freeifaddrs): Likewise.
+	* inet/check_pf.c (__check_pf): Use __getifaddrs and __freeifaddrs
+	instead of getifaddrs and freeifaddrs.
 
 2017-09-26  H.J. Lu  <hongjiu.lu@intel.com>
 
diff --git a/include/ifaddrs.h b/include/ifaddrs.h
index 54f4b7a3ce..416118f1b3 100644
--- a/include/ifaddrs.h
+++ b/include/ifaddrs.h
@@ -9,6 +9,11 @@ 
 libc_hidden_proto (getifaddrs)
 libc_hidden_proto (freeifaddrs)
 
+extern int __getifaddrs (struct ifaddrs **__ifap);
+libc_hidden_proto (__getifaddrs)
+extern void __freeifaddrs (struct ifaddrs *__ifa);
+libc_hidden_proto (__freeifaddrs)
+
 struct in6addrinfo
 {
   enum {
diff --git a/inet/check_pf.c b/inet/check_pf.c
index a56723a7df..84dd1699d5 100644
--- a/inet/check_pf.c
+++ b/inet/check_pf.c
@@ -32,7 +32,7 @@  __check_pf (bool *seen_ipv4, bool *seen_ipv6,
 
   /* Get the interface list via getifaddrs.  */
   struct ifaddrs *ifa = NULL;
-  if (getifaddrs (&ifa) != 0)
+  if (__getifaddrs (&ifa) != 0)
     {
       /* We cannot determine what interfaces are available.  Be
 	 pessimistic.  */
@@ -51,7 +51,7 @@  __check_pf (bool *seen_ipv4, bool *seen_ipv6,
     else if (runp->ifa_addr->sa_family == PF_INET6)
       *seen_ipv6 = true;
 
-  (void) freeifaddrs (ifa);
+  (void) __freeifaddrs (ifa);
 }
 
 
diff --git a/inet/ifaddrs.c b/inet/ifaddrs.c
index 35cc277225..0a5c71c059 100644
--- a/inet/ifaddrs.c
+++ b/inet/ifaddrs.c
@@ -30,6 +30,7 @@  __getifaddrs (struct ifaddrs **ifap)
   return -1;
 }
 weak_alias (__getifaddrs, getifaddrs)
+libc_hidden_def (__getifaddrs)
 libc_hidden_weak (getifaddrs)
 stub_warning (getifaddrs)
 
@@ -43,5 +44,6 @@  __freeifaddrs (struct ifaddrs *ifa)
   abort ();
 }
 weak_alias (__freeifaddrs, freeifaddrs)
+libc_hidden_def (__freeifaddrs)
 libc_hidden_weak (freeifaddrs)
 stub_warning (freeifaddrs)
diff --git a/sysdeps/gnu/ifaddrs.c b/sysdeps/gnu/ifaddrs.c
index 37b3248669..80702eb1d1 100644
--- a/sysdeps/gnu/ifaddrs.c
+++ b/sysdeps/gnu/ifaddrs.c
@@ -151,6 +151,7 @@  __getifaddrs (struct ifaddrs **ifap)
   return 0;
 }
 weak_alias (__getifaddrs, getifaddrs)
+libc_hidden_def (__getifaddrs)
 #ifndef getifaddrs
 libc_hidden_weak (getifaddrs)
 #endif
@@ -161,4 +162,5 @@  __freeifaddrs (struct ifaddrs *ifa)
   free (ifa);
 }
 weak_alias (__freeifaddrs, freeifaddrs)
+libc_hidden_def (__freeifaddrs)
 libc_hidden_weak (freeifaddrs)