From patchwork Wed Jul 1 20:50:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tulio Magno Quites Machado Filho X-Patchwork-Id: 39875 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A9380386195E; Wed, 1 Jul 2020 20:51:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9380386195E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1593636683; bh=U1CvqRcd3Y5Pd8o+plAMMCMvdLIVuZQNgtuxpheCN9c=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=VWuh/ukvXSlJzgHIbjE3M/0PXrEo1r7oPuWK6nQ7bEXzcf/YzG4nw4DYGkpVTYZ08 zb7+HxYC8d8SnpDygopZ5r8U0iTNMbbBvl9EeGXlx0sJubSLpwTfuG+Zj4msndQO0l SlaaOfs721PNmk3MWuVkdf3h4gYVTR2csWJ22a8A= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 2CF0A386195E for ; Wed, 1 Jul 2020 20:51:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2CF0A386195E Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 061KXCwS115410 for ; Wed, 1 Jul 2020 16:51:14 -0400 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 320s23hhqn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 01 Jul 2020 16:51:14 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 061KnGVH029525 for ; Wed, 1 Jul 2020 20:51:13 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma01dal.us.ibm.com with ESMTP id 320wfka7pv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 01 Jul 2020 20:51:13 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 061KpCxP41943422 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 1 Jul 2020 20:51:12 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 34A5AC6055; Wed, 1 Jul 2020 20:51:12 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C16CFC6059; Wed, 1 Jul 2020 20:51:11 +0000 (GMT) Received: from linux.ibm.com (unknown [9.65.218.38]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 1 Jul 2020 20:51:11 +0000 (GMT) To: "Paul E . Murphy" , libc-alpha@sourceware.org Subject: [PATCHv2] powerpc64: Fix calls when r2 is not used [BZ #26173] Date: Wed, 1 Jul 2020 17:50:37 -0300 Message-Id: <20200701205037.407310-1-tuliom@linux.ibm.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <1b8a477b-851d-eb4c-e946-4ae9d413037c@linux.ibm.com> References: <1b8a477b-851d-eb4c-e946-4ae9d413037c@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-01_12:2020-07-01, 2020-07-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 phishscore=0 suspectscore=9 mlxlogscore=999 cotscore=-2147483648 mlxscore=0 spamscore=0 priorityscore=1501 bulkscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007010143 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tulio Magno Quites Machado Filho via Libc-alpha From: Tulio Magno Quites Machado Filho Reply-To: Tulio Magno Quites Machado Filho Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Paul E Murphy via Libc-alpha writes: > Will this also require a newer version of binutils? Yes. Fixed in this version. Thanks! Changes since v1: - Detect at configure time if the assembler supports @notoc. Use @notoc only when available. ---8<--- Teach the linker that __mcount_internal, __sigjmp_save_symbol, __syscall_error and __GI_exit do not use r2, so that it does not need to recover r2 after the call. Test at configure time if the assembler supports @notoc and define USE_PPC64_NOTOC. --- config.h.in | 3 ++ sysdeps/powerpc/powerpc64/configure | 28 +++++++++++++++++++ sysdeps/powerpc/powerpc64/configure.ac | 11 ++++++++ sysdeps/powerpc/powerpc64/ppc-mcount.S | 2 +- sysdeps/powerpc/powerpc64/setjmp-common.S | 2 +- sysdeps/powerpc/powerpc64/sysdep.h | 8 +++++- .../linux/powerpc/powerpc64/makecontext.S | 2 +- 7 files changed, 52 insertions(+), 4 deletions(-) diff --git a/config.h.in b/config.h.in index 831eca2fe1..6598d4573a 100644 --- a/config.h.in +++ b/config.h.in @@ -20,6 +20,9 @@ /* On powerpc64, use overlapping .opd entries. */ #undef USE_PPC64_OVERLAPPING_OPD +/* On powerpc64, use @notoc. */ +#undef USE_PPC64_NOTOC + /* Define if _Unwind_Find_FDE should be exported from glibc. */ #undef EXPORT_UNWIND_FIND_FDE diff --git a/sysdeps/powerpc/powerpc64/configure b/sysdeps/powerpc/powerpc64/configure index 7632a7be04..5ce77af631 100644 --- a/sysdeps/powerpc/powerpc64/configure +++ b/sysdeps/powerpc/powerpc64/configure @@ -31,3 +31,31 @@ if test x$libc_cv_overlapping_opd = xyes; then $as_echo "#define USE_PPC64_OVERLAPPING_OPD 1" >>confdefs.h fi + +# @notoc started to be supported in GNU Binutils 2.31. + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the assembler supports @notoc" >&5 +$as_echo_n "checking if the assembler supports @notoc... " >&6; } +if ${libc_cv_ppc64_notoc+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +void foo (void) {asm("b foo@notoc");} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + libc_cv_ppc64_notoc=yes +else + libc_cv_ppc64_notoc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_ppc64_notoc" >&5 +$as_echo "$libc_cv_ppc64_notoc" >&6; } +if test x$libc_cv_ppc64_notoc = xyes; then : + $as_echo "#define USE_PPC64_NOTOC 1" >>confdefs.h + +fi diff --git a/sysdeps/powerpc/powerpc64/configure.ac b/sysdeps/powerpc/powerpc64/configure.ac index f309ba35a8..b77156f696 100644 --- a/sysdeps/powerpc/powerpc64/configure.ac +++ b/sysdeps/powerpc/powerpc64/configure.ac @@ -21,3 +21,14 @@ rm -f conftest.c conftest.s if test x$libc_cv_overlapping_opd = xyes; then AC_DEFINE(USE_PPC64_OVERLAPPING_OPD) fi + +# @notoc started to be supported in GNU Binutils 2.31. +AC_CACHE_CHECK([if the assembler supports @notoc], + libc_cv_ppc64_notoc, [ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ +void foo (void) {asm("b foo@notoc");} + ])], + [libc_cv_ppc64_notoc=yes], + [libc_cv_ppc64_notoc=no])]) +AS_IF([test x$libc_cv_ppc64_notoc = xyes], + [AC_DEFINE(USE_PPC64_NOTOC)]) diff --git a/sysdeps/powerpc/powerpc64/ppc-mcount.S b/sysdeps/powerpc/powerpc64/ppc-mcount.S index f7e9836cae..1adc0a18f3 100644 --- a/sysdeps/powerpc/powerpc64/ppc-mcount.S +++ b/sysdeps/powerpc/powerpc64/ppc-mcount.S @@ -29,7 +29,7 @@ ENTRY(_mcount) cfi_adjust_cfa_offset (FRAME_MIN_SIZE) cfi_offset (lr, FRAME_LR_SAVE) ld r3, FRAME_LR_SAVE(r11) - bl JUMPTARGET(__mcount_internal) + bl JUMPTARGET (NOTOC (__mcount_internal)) #ifndef SHARED nop #endif diff --git a/sysdeps/powerpc/powerpc64/setjmp-common.S b/sysdeps/powerpc/powerpc64/setjmp-common.S index eb37000980..2409d17831 100644 --- a/sysdeps/powerpc/powerpc64/setjmp-common.S +++ b/sysdeps/powerpc/powerpc64/setjmp-common.S @@ -217,7 +217,7 @@ L(no_vmx): li r3,0 blr #elif defined SHARED - b JUMPTARGET (__sigjmp_save_symbol) + b JUMPTARGET (NOTOC (__sigjmp_save_symbol)) #else mflr r0 std r0,FRAME_LR_SAVE(r1) diff --git a/sysdeps/powerpc/powerpc64/sysdep.h b/sysdeps/powerpc/powerpc64/sysdep.h index d6616ac905..d557098898 100644 --- a/sysdeps/powerpc/powerpc64/sysdep.h +++ b/sysdeps/powerpc/powerpc64/sysdep.h @@ -278,7 +278,7 @@ LT_LABELSUFFIX(name,_name_end): ; \ #ifdef SHARED #define TAIL_CALL_SYSCALL_ERROR \ - b JUMPTARGET(__syscall_error) + b JUMPTARGET (NOTOC (__syscall_error)) #else /* Static version might be linked into a large app with a toc exceeding 64k. We can't put a toc adjusting stub on a plain branch, so can't @@ -366,6 +366,12 @@ LT_LABELSUFFIX(name,_name_end): ; \ lwz rOUT,0(rOUT) #endif +#ifdef USE_PPC64_NOTOC +# define NOTOC(l) l@notoc +#else +# define NOTOC(l) l +#endif + #else /* !__ASSEMBLER__ */ #if _CALL_ELF != 2 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S index e4d4575d68..3c528aa4b7 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S @@ -160,7 +160,7 @@ L(exitcode): li r3,-1 L(do_exit): #ifdef SHARED - b JUMPTARGET(__GI_exit); + b JUMPTARGET (NOTOC (__GI_exit)); #else b JUMPTARGET(exit); nop