This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Add hidden visibility to internal function prototypes
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 17 Aug 2017 05:22:44 -0700
- Subject: [PATCH] Add hidden visibility to internal function prototypes
- Authentication-results: sourceware.org; auth=none
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Add hidden visibility to internal function prototypes to allow direct
access to internal functions within libc.a without using GOT when the
compiler defaults to -fPIE.
Size comparison of elf/ldconfig when the compiler defaults to -fPIE:
On x86-64:
text data bss dec hex
Before: 619646 20132 5488 645266 9d892
After : 619502 20132 5488 645122 9d802
On i686:
text data bss dec hex
Before: 550333 10748 3060 564141 89bad
After : 546453 10732 3060 560245 88c75
Any comments?
H.J.
---
* include/libc-symbols.h (__hidden_proto_hiddenattr): New for
the compiler defaulting to -fPIE.
(hidden_proto): Likewise.
(hidden_tls_proto): Likewise.
(__hidden_proto): Likewise.
---
include/libc-symbols.h | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index d6a1c260f6..6c75a6f012 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -513,8 +513,20 @@ for linking")
# endif
#else
# ifndef __ASSEMBLER__
-# define hidden_proto(name, attrs...)
-# define hidden_tls_proto(name, attrs...)
+# if BUILD_PIE_DEFAULT && IS_IN (libc) && !defined LIBC_NONSHARED \
+ && !defined NO_HIDDEN
+# define __hidden_proto_hiddenattr(attrs...) \
+ __attribute__ ((visibility ("hidden"), ##attrs))
+# define hidden_proto(name, attrs...) \
+ __hidden_proto (name, , name, ##attrs)
+# define hidden_tls_proto(name, attrs...) \
+ __hidden_proto (name, __thread, name, ##attrs)
+# define __hidden_proto(name, thread, internal, attrs...) \
+ extern thread __typeof (name) name __hidden_proto_hiddenattr (attrs);
+# else
+# define hidden_proto(name, attrs...)
+# define hidden_tls_proto(name, attrs...)
+# endif
# else
# define HIDDEN_JUMPTARGET(name) JUMPTARGET(name)
# endif /* Not __ASSEMBLER__ */
--
2.13.5