From patchwork Tue Aug 22 22:44:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lu, Hongjiu" X-Patchwork-Id: 22324 Received: (qmail 24609 invoked by alias); 22 Aug 2017 22:44:40 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 24462 invoked by uid 89); 22 Aug 2017 22:44:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=slots X-HELO: mga02.intel.com X-ExtLoop1: 1 Date: Tue, 22 Aug 2017 15:44:25 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] Don't use hidden visibility in libc.a with PIE on i386 Message-ID: <20170822224425.GA29673@gmail.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.3 (2017-05-23) 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. OK for master? H.J. --- * 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. --- config.h.in | 4 ++++ include/libc-symbols.h | 1 + sysdeps/i386/configure | 7 ++++++- sysdeps/i386/configure.ac | 6 ++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/config.h.in b/config.h.in index 26ed7865ef..d397eeae1a 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 fe3571af52..4668902d5f 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -514,6 +514,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 4d6685f7c2..4cf968d8bc 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 f7766ad2b8..b598b120bc 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