From patchwork Fri Mar 27 21:17:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 38640 X-Patchwork-Delegate: tuliom@linux.vnet.ibm.com Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id BF374385E00B for ; Fri, 27 Mar 2020 21:18:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BF374385E00B Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02RL6Nje031234 for ; Fri, 27 Mar 2020 17:18:14 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ywf0shjkd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 27 Mar 2020 17:18:13 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 02RLFDVc003961 for ; Fri, 27 Mar 2020 21:18:12 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma01wdc.us.ibm.com with ESMTP id 2ywawnd87b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 27 Mar 2020 21:18:12 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02RLIBGF14418664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 27 Mar 2020 21:18:11 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0703B136063 for ; Fri, 27 Mar 2020 21:18:11 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7CDEB136061 for ; Fri, 27 Mar 2020 21:18:10 +0000 (GMT) Received: from brokenarrow.ibmuc.com (unknown [9.85.139.44]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP for ; Fri, 27 Mar 2020 21:18:10 +0000 (GMT) From: "Paul E. Murphy" To: libc-alpha@sourceware.org Subject: [PATCH v2 08/10] powerpc64le: enforce non-specific long double in .gnu.attributes section Date: Fri, 27 Mar 2020 16:17:59 -0500 Message-Id: <20200327211801.31234-9-murphyp@linux.vnet.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200327211801.31234-1-murphyp@linux.vnet.ibm.com> References: <20200327211801.31234-1-murphyp@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-27_08:2020-03-27, 2020-03-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 impostorscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003270174 X-Spam-Status: No, score=-25.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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-List-Received-Date: Fri, 27 Mar 2020 21:18:16 -0000 We turn off this feature to avoid polluting our shared libary with a specific value. However, static libgcc is not under our control, and has enabled this for ibm128 routines. This pollutes the resulting shared libraries with it. Attach a post-linking hook to replace this section with one crafted as hard-float + indeterminate ldbl. This allows IEEE ldbl users to avoid having to disable the gnu attributes feature which should protect them from linking ibm ldbl libraries using the gnu attributes feature. Currently, this only replaces only libc and libm which support both ldbl formats and rely on application code to explicitly determine which is to be used. Strictly speaking, the section could be deleted with minimal lost value. However correctly set attributes could prove useful for some future change, and similarly missing attributes. Reviewed-by: Tulio Magno Quites Machado Filho --- sysdeps/powerpc/powerpc64/le/Makefile | 27 ++++++++++++++++- .../powerpc64/le/no_ldbl_gnu_attribute.c | 30 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 sysdeps/powerpc/powerpc64/le/no_ldbl_gnu_attribute.c diff --git a/sysdeps/powerpc/powerpc64/le/Makefile b/sysdeps/powerpc/powerpc64/le/Makefile index 9ba7f850ad..55e0c48f5d 100644 --- a/sysdeps/powerpc/powerpc64/le/Makefile +++ b/sysdeps/powerpc/powerpc64/le/Makefile @@ -10,7 +10,32 @@ ifeq ($(ibm128-fcts),yes) ibm128-abi-CFLAGS := -mabi=ibmlongdouble type-ldouble-CFLAGS += $(ibm128-abi-CFLAGS) no-gnu-attribute-CFLAGS = -mno-gnu-attribute -endif + +# This is a very gnarly workaround to static libgcc providing a .gnu.attribute +# in ibm128 functions. This is not a bug in static libgcc as normal users +# should only ever link ibm128 or ieee128 routines, never both. We are the +# exception which allows the decision to be deferred to user libraries or +# applications. +# +# We built an object file and extract the desired .gnu.attributes section +# to be inserted into lib{c,m}.so. +ifeq ($(build-shared),yes) +before-compile += $(common-objpfx)no_ldbl_gnu_attribute.bin + +$(common-objpfx)no_ldbl_gnu_attribute.bin: $(..)sysdeps/powerpc/powerpc64/le/no_ldbl_gnu_attribute.c + $(filter-out $(no-gnu-attribute-CFLAGS),$(compile.c)) -o $(basename $@).o + $(OBJCOPY) --dump-section=.gnu.attributes=$@.tmp $(basename $@).o + mv $@.tmp $@ + +define after-link +if [ ! -z "$(filter libm.so libc.so,$(notdir $1))" ]; then \ + echo "Replacing .gnu.attributes in $1"; \ + $(OBJCOPY) --update-section=.gnu.attributes=$(common-objpfx)no_ldbl_gnu_attribute.bin $1; \ +fi +endef + +endif # ifeq ($(build-shared),yes) +endif # ifeq ($(ibm128-fcts),yes) # All _Float128 files should be built assuming an ibm128 long double. # Likewise, this avoids some old GCC 7 compiler bugs whereby calls diff --git a/sysdeps/powerpc/powerpc64/le/no_ldbl_gnu_attribute.c b/sysdeps/powerpc/powerpc64/le/no_ldbl_gnu_attribute.c new file mode 100644 index 0000000000..8ffee30560 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/no_ldbl_gnu_attribute.c @@ -0,0 +1,30 @@ +/* File to generate desired .gnu.attribute section + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +/* This generates a .gnu.attributes sections with + the default toolchain settings and an indeterminate + long double format. */ +long double _not_used; + +/* Some older GCC versions need a little more convincing to + generate .gnu.attributes. */ +double +foo (double d) +{ + return d; +}