Message ID | 20170817122244.GA14297@gmail.com |
---|---|
State | New |
Headers | show |
On 08/17/2017 02:22 PM, H.J. Lu wrote: > 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: This is for static linking, right? Is there a reason to restrict this to PIE builds? Why not use hidden visibility unconditionally? Thanks, Florian
On Thu, Aug 17, 2017 at 5:34 AM, Florian Weimer <fweimer@redhat.com> wrote: > On 08/17/2017 02:22 PM, H.J. Lu wrote: >> 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: > > This is for static linking, right? > > Is there a reason to restrict this to PIE builds? Why not use hidden > visibility unconditionally? > Yes, there is only used for static PIE build and we can replace BUILD_PIE_DEFAULT with !defined SHARED. But it makes no difference for non-PIE static build.
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__ */