From: H.J. Lu Date: Thu, 5 Oct 2017 00:18:23 +0000 (-0700) Subject: Don't use hidden visibility in libc.a with PIE on i386 X-Git-Tag: upstream/2.30~2418 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ee417882e07277b2a36e7e61e6ef7edd96415b3f;p=platform%2Fupstream%2Fglibc.git Don't use hidden visibility in libc.a with PIE on i386 On i386, when multi-arch is enabled, all external functions must be called via PIC PLT in PIE, which requires setting up EBX register, since they may be IFUNC functions. * config.h.in (NO_HIDDEN_EXTERN_FUNC_IN_PIE): New. * include/libc-symbols.h (__hidden_proto_hiddenattr): Add check for PIC and NO_HIDDEN_EXTERN_FUNC_IN_PIE. * sysdeps/i386/configure.ac (NO_HIDDEN_EXTERN_FUNC_IN_PIE): New AC_DEFINE if multi-arch is enabled. * sysdeps/i386/configure: Regenerated. --- diff --git a/ChangeLog b/ChangeLog index 191dd5a..bb09add 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2017-10-04 H.J. Lu + * config.h.in (NO_HIDDEN_EXTERN_FUNC_IN_PIE): New. + * include/libc-symbols.h (__hidden_proto_hiddenattr): Add check + for PIC and NO_HIDDEN_EXTERN_FUNC_IN_PIE. + * sysdeps/i386/configure.ac (NO_HIDDEN_EXTERN_FUNC_IN_PIE): New + AC_DEFINE if multi-arch is enabled. + * sysdeps/i386/configure: Regenerated. + +2017-10-04 H.J. Lu + * Makeconfig (+link-static-before-libc): Use $(DEFAULT-LDFLAGS-$(@F)). * elf/Makefile (CRT-tst-tls1-static-non-pie): New. diff --git a/config.h.in b/config.h.in index 0d38476..c140ff3 100644 --- a/config.h.in +++ b/config.h.in @@ -86,6 +86,10 @@ #undef PI_STATIC_AND_HIDDEN /* Define this to disable the 'hidden_proto' et al macros in + include/libc-symbols.h that avoid PLT slots in PIE. */ +#undef NO_HIDDEN_EXTERN_FUNC_IN_PIE + +/* Define this to disable the 'hidden_proto' et al macros in include/libc-symbols.h that avoid PLT slots in the shared objects. */ #undef NO_HIDDEN diff --git a/include/libc-symbols.h b/include/libc-symbols.h index e0d4dc3..8726262 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -507,6 +507,7 @@ for linking") #else # ifndef __ASSEMBLER__ # if !defined SHARED && IS_IN (libc) && !defined LIBC_NONSHARED \ + && (!defined PIC || !defined NO_HIDDEN_EXTERN_FUNC_IN_PIE) \ && !defined NO_HIDDEN # define __hidden_proto_hiddenattr(attrs...) \ __attribute__ ((visibility ("hidden"), ##attrs)) diff --git a/sysdeps/i386/configure b/sysdeps/i386/configure index 4d6685f..4cf968d 100644 --- a/sysdeps/i386/configure +++ b/sysdeps/i386/configure @@ -26,7 +26,7 @@ libc_compiler_builtin_inlined=no cat > conftest.c <&5' @@ -79,3 +79,8 @@ fi $as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h + +if test x"$multi_arch" != xno; then + $as_echo "#define NO_HIDDEN_EXTERN_FUNC_IN_PIE 1" >>confdefs.h + +fi diff --git a/sysdeps/i386/configure.ac b/sysdeps/i386/configure.ac index f7766ad..b598b12 100644 --- a/sysdeps/i386/configure.ac +++ b/sysdeps/i386/configure.ac @@ -48,3 +48,9 @@ fi dnl It is always possible to access static and hidden symbols in an dnl position independent way. AC_DEFINE(PI_STATIC_AND_HIDDEN) + +dnl When multi-arch is enabled, all external functions must be called +dnl via PIC PLT in PIE, which requires setting up EBX register. +if test x"$multi_arch" != xno; then + AC_DEFINE(NO_HIDDEN_EXTERN_FUNC_IN_PIE) +fi