diff mbox

[17/58] Mark internal dirent functions with attribute_hidden [BZ #18822]

Message ID 20170901180029.9527-18-hjl.tools@gmail.com
State New, archived
Headers show

Commit Message

H.J. Lu Sept. 1, 2017, 5:59 p.m. UTC
Mark internal dirent functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.  __readdir64
is hidden with libc_hidden_proto and libc_hidden_def since the exported
readdir64 is an alias of __readdir64.

	[BZ #18822]
	* include/dirent.h (__opendir): Always add attribute_hidden.
	(__fdopendir): Likewise.
	(__closedir): Likewise.
	(__readdir): Likewise.
	(__readdir64): Add libc_hidden_proto.
	* sysdeps/mach/hurd/readdir64.c (__readdir64): Add libc_hidden_def.
	* sysdeps/unix/sysv/linux/i386/readdir64.c (__readdir64): Likewise.
	* sysdeps/unix/sysv/linux/readdir64.c (__readdir64): Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/readdir.c (__GI___readdir64):
	New alias.
---
 include/dirent.h                              | 13 +++++--------
 sysdeps/mach/hurd/readdir64.c                 |  1 +
 sysdeps/unix/sysv/linux/i386/readdir64.c      |  1 +
 sysdeps/unix/sysv/linux/readdir64.c           |  1 +
 sysdeps/unix/sysv/linux/wordsize-64/readdir.c |  1 +
 5 files changed, 9 insertions(+), 8 deletions(-)

Comments

H.J. Lu Oct. 1, 2017, 10:23 p.m. UTC | #1
On 9/1/17, H.J. Lu <hjl.tools@gmail.com> wrote:
> Mark internal dirent functions with attribute_hidden to allow direct
> access within libc.so and libc.a without using GOT nor PLT.  __readdir64
> is hidden with libc_hidden_proto and libc_hidden_def since the exported
> readdir64 is an alias of __readdir64.
>
> 	[BZ #18822]
> 	* include/dirent.h (__opendir): Always add attribute_hidden.
> 	(__fdopendir): Likewise.
> 	(__closedir): Likewise.
> 	(__readdir): Likewise.
> 	(__readdir64): Add libc_hidden_proto.
> 	* sysdeps/mach/hurd/readdir64.c (__readdir64): Add libc_hidden_def.
> 	* sysdeps/unix/sysv/linux/i386/readdir64.c (__readdir64): Likewise.
> 	* sysdeps/unix/sysv/linux/readdir64.c (__readdir64): Likewise.
> 	* sysdeps/unix/sysv/linux/wordsize-64/readdir.c (__GI___readdir64):
> 	New alias.

Tested with build-many-glibcs.py.  I am checking it in.
diff mbox

Patch

diff --git a/include/dirent.h b/include/dirent.h
index bebcd52cdb..26868eeb61 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -15,12 +15,13 @@  struct scandir_cancel_struct
 };
 
 /* Now define the internal interfaces.  */
-extern DIR *__opendir (const char *__name);
+extern DIR *__opendir (const char *__name) attribute_hidden;
 extern DIR *__opendirat (int dfd, const char *__name) attribute_hidden;
-extern DIR *__fdopendir (int __fd);
-extern int __closedir (DIR *__dirp);
-extern struct dirent *__readdir (DIR *__dirp);
+extern DIR *__fdopendir (int __fd) attribute_hidden;
+extern int __closedir (DIR *__dirp) attribute_hidden;
+extern struct dirent *__readdir (DIR *__dirp) attribute_hidden;
 extern struct dirent64 *__readdir64 (DIR *__dirp);
+libc_hidden_proto (__readdir64)
 extern int __readdir_r (DIR *__dirp, struct dirent *__entry,
 			struct dirent **__result);
 extern int __readdir64_r (DIR *__dirp, struct dirent64 *__entry,
@@ -75,10 +76,6 @@  libc_hidden_proto (__scandirat)
 libc_hidden_proto (scandirat64)
 
 #  if IS_IN (rtld)
-extern __typeof (__closedir) __closedir attribute_hidden;
-extern __typeof (__fdopendir) __fdopendir attribute_hidden;
-extern __typeof (__readdir) __readdir attribute_hidden;
-extern __typeof (__readdir64) __readdir64 attribute_hidden;
 extern __typeof (__rewinddir) __rewinddir attribute_hidden;
 #  endif
 # endif
diff --git a/sysdeps/mach/hurd/readdir64.c b/sysdeps/mach/hurd/readdir64.c
index f422fcff04..bad0bcb559 100644
--- a/sysdeps/mach/hurd/readdir64.c
+++ b/sysdeps/mach/hurd/readdir64.c
@@ -98,4 +98,5 @@  __readdir64 (DIR *dirp)
   return dp;
 }
 
+libc_hidden_def (__readdir64)
 weak_alias (__readdir64, readdir64)
diff --git a/sysdeps/unix/sysv/linux/i386/readdir64.c b/sysdeps/unix/sysv/linux/i386/readdir64.c
index de8669feff..8c235f9831 100644
--- a/sysdeps/unix/sysv/linux/i386/readdir64.c
+++ b/sysdeps/unix/sysv/linux/i386/readdir64.c
@@ -27,6 +27,7 @@ 
 #undef __GETDENTS
 #undef DIRENT_TYPE
 
+libc_hidden_def (__readdir64)
 versioned_symbol (libc, __readdir64, readdir64, GLIBC_2_2);
 
 #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
diff --git a/sysdeps/unix/sysv/linux/readdir64.c b/sysdeps/unix/sysv/linux/readdir64.c
index 224f53db88..6d154fe988 100644
--- a/sysdeps/unix/sysv/linux/readdir64.c
+++ b/sysdeps/unix/sysv/linux/readdir64.c
@@ -4,4 +4,5 @@ 
 
 #include <sysdeps/posix/readdir.c>
 
+libc_hidden_def (__readdir64)
 weak_alias (__readdir64, readdir64)
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/readdir.c b/sysdeps/unix/sysv/linux/wordsize-64/readdir.c
index e197d93b00..0d5798849d 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/readdir.c
+++ b/sysdeps/unix/sysv/linux/wordsize-64/readdir.c
@@ -3,5 +3,6 @@ 
 #include <sysdeps/posix/readdir.c>
 #undef __readdir64
 strong_alias (__readdir, __readdir64)
+strong_alias (__readdir, __GI___readdir64)
 #undef readdir64
 weak_alias (__readdir, readdir64)