Fix __getcwd rewinddir namespace (bug 17584).
authorJoseph Myers <joseph@codesourcery.com>
Wed, 12 Nov 2014 16:24:16 +0000 (16:24 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 12 Nov 2014 16:24:16 +0000 (16:24 +0000)
__getcwd is called from dcigettext.o (brought in by various ISO C
functionality), but calls rewinddir, which is not an ISO C function.
This patch makes __getcwd call __rewinddir instead and makes rewinddir
a weak alias for __rewinddir.

Since getcwd.c is shared with gnulib (albeit not merged in either
direction for a long time, and omitted from gnulib's
config/srclist.txt list of shared files) I put in a #ifndef _LIBC
define of __rewinddir to rewinddir, although a future merged version
of getcwd could end up looking significantly different.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by this patch).

[BZ #17584]
* dirent/rewinddir.c (rewinddir): Rename to __rewinddir and define
as weak alias of __rewinddir.  Don't use libc_hidden_def.
(__rewinddir): Use libc_hidden_def.
* sysdeps/mach/hurd/rewinddir.c: Rename to __rewinddir and define
as weak alias of __rewinddir.  Don't use libc_hidden_def.
(__rewinddir): Use libc_hidden_def.
* sysdeps/posix/rewinddir.c: Rename to __rewinddir and define as
weak alias of __rewinddir.  Don't use libc_hidden_def.
(__rewinddir): Use libc_hidden_def.
* include/dirent.h (rewinddir): Don't use libc_hidden_proto.
(__rewinddir): Use libc_hidden_proto.
* sysdeps/posix/getcwd.c [!_LIBC] (__rewinddir): Define to
rewinddir.
(__getcwd): Use __rewinddir instead of rewinddir.

ChangeLog
NEWS
dirent/rewinddir.c
include/dirent.h
sysdeps/mach/hurd/rewinddir.c
sysdeps/posix/getcwd.c
sysdeps/posix/rewinddir.c

index ee9f312..42a3e82 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2014-11-12  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #17584]
+       * dirent/rewinddir.c (rewinddir): Rename to __rewinddir and define
+       as weak alias of __rewinddir.  Don't use libc_hidden_def.
+       (__rewinddir): Use libc_hidden_def.
+       * sysdeps/mach/hurd/rewinddir.c: Rename to __rewinddir and define
+       as weak alias of __rewinddir.  Don't use libc_hidden_def.
+       (__rewinddir): Use libc_hidden_def.
+       * sysdeps/posix/rewinddir.c: Rename to __rewinddir and define as
+       weak alias of __rewinddir.  Don't use libc_hidden_def.
+       (__rewinddir): Use libc_hidden_def.
+       * include/dirent.h (rewinddir): Don't use libc_hidden_proto.
+       (__rewinddir): Use libc_hidden_proto.
+       * sysdeps/posix/getcwd.c [!_LIBC] (__rewinddir): Define to
+       rewinddir.
+       (__getcwd): Use __rewinddir instead of rewinddir.
+
        [BZ #17583]
        * libio/fileno.c (fileno): Rename to __fileno and define as weak
        alias of __fileno.  Use libc_hidden_weak.
diff --git a/NEWS b/NEWS
index 4727ea2..63b0a86 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,7 +11,7 @@ Version 2.21
 
   6652, 12926, 14132, 14138, 14171, 15215, 15884, 17266, 17344, 17363,
   17370, 17371, 17411, 17460, 17475, 17485, 17501, 17506, 17508, 17522,
-  17555, 17583.
+  17555, 17583, 17584.
 
 * New locales: tu_IN, bh_IN.
 \f
index 86d9fbd..ba5b002 100644 (file)
 
 /* Rewind DIRP to the beginning of the directory.  */
 void
-rewinddir (dirp)
+__rewinddir (dirp)
      DIR *dirp;
 {
   __set_errno (ENOSYS);
   /* No way to indicate failure.       */
 }
-libc_hidden_def (rewinddir)
+libc_hidden_def (__rewinddir)
+weak_alias (__rewinddir, rewinddir)
 
 
 stub_warning (rewinddir)
index 096a977..e8e9e42 100644 (file)
@@ -47,8 +47,9 @@ extern DIR *__alloc_dir (int fd, bool close_fd, int flags,
                         const struct stat64 *statp)
      internal_function;
 extern void __scandir_cancel_handler (void *arg);
+extern __typeof (rewinddir) __rewinddir;
 
-libc_hidden_proto (rewinddir)
+libc_hidden_proto (__rewinddir)
 libc_hidden_proto (scandirat)
 libc_hidden_proto (scandirat64)
 # endif
index bccd549..284a48b 100644 (file)
 
 /* Rewind DIRP to the beginning of the directory.  */
 void
-rewinddir (dirp)
+__rewinddir (dirp)
      DIR *dirp;
 {
   seekdir (dirp, (off_t) 0L);
 }
-libc_hidden_def (rewinddir)
+libc_hidden_def (__rewinddir)
+weak_alias (__rewinddir, rewinddir)
index 6201916..92cb22e 100644 (file)
@@ -195,6 +195,10 @@ extern char *alloca ();
 #ifndef __GNU_LIBRARY__
 # define __lstat64     stat64
 #endif
+
+#ifndef _LIBC
+# define __rewinddir   rewinddir
+#endif
 \f
 #ifndef _LIBC
 # define __getcwd getcwd
@@ -390,7 +394,7 @@ __getcwd (buf, size)
                  if (use_d_ino)
                    {
                      use_d_ino = false;
-                     rewinddir (dirstream);
+                     __rewinddir (dirstream);
                      continue;
                    }
 
index 5a4a715..e9bc78d 100644 (file)
@@ -23,7 +23,7 @@
 
 /* Rewind DIRP to the beginning of the directory.  */
 void
-rewinddir (dirp)
+__rewinddir (dirp)
      DIR *dirp;
 {
 #ifndef NOT_IN_libc
@@ -38,4 +38,5 @@ rewinddir (dirp)
   __libc_lock_unlock (dirp->lock);
 #endif
 }
-libc_hidden_def (rewinddir)
+libc_hidden_def (__rewinddir)
+weak_alias (__rewinddir, rewinddir)