From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id F41F03857815 for ; Fri, 8 Apr 2022 22:28:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F41F03857815 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 238J100o016770 for ; Fri, 8 Apr 2022 22:28:14 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fa8mwrtbj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 08 Apr 2022 22:28:13 +0000 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 238MPN7x017792 for ; Fri, 8 Apr 2022 22:28:13 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fa8mwrtba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Apr 2022 22:28:13 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 238M7XTl023203; Fri, 8 Apr 2022 22:28:12 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma04wdc.us.ibm.com with ESMTP id 3f6e4ah6jr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Apr 2022 22:28:12 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 238MSBaW38928872 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Apr 2022 22:28:11 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3BF30BE05B; Fri, 8 Apr 2022 22:28:11 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D1F4DBE056; Fri, 8 Apr 2022 22:28:10 +0000 (GMT) Received: from linux.ibm.com (unknown [9.65.88.206]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 8 Apr 2022 22:28:10 +0000 (GMT) From: Tulio Magno Quites Machado Filho To: libc-alpha@sourceware.org Cc: Alan Modra Subject: Re: [PATCH v2 1/4] powerpc64: Use medium model toc accesses throughout In-Reply-To: <20220228064052.3413334-2-amodra@gmail.com> References: <20220228064052.3413334-1-amodra@gmail.com> <20220228064052.3413334-2-amodra@gmail.com> User-Agent: Notmuch/0.35 (http://notmuchmail.org) Emacs/27.2 (x86_64-redhat-linux-gnu) Date: Fri, 08 Apr 2022 19:28:09 -0300 Message-ID: <875ynj2osm.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: XLp9eoaQinnT_V3VERj2ZPwCgAwvSmap X-Proofpoint-GUID: 5knThwkQzTNb2ZIg1lBBIMkEQA-X_6S4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-08_08,2022-04-08_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 adultscore=0 mlxlogscore=343 impostorscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 clxscore=1015 suspectscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204080113 X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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, 08 Apr 2022 22:28:16 -0000 Alan Modra via Libc-alpha writes: > The PowerPC64 linker edits medium model toc-indirect code to toc-pointer > relative: > addis r9,r2,tc_entry_for_var@toc@ha > ld r9,tc_entry_for_var@toc@l(r9) > becomes > addis r9,r2,(var-.TOC.)@ha > addi r9,r9,(var-.TOC.)@l > when "var" is known to be local to the binary. This isn't done for > small-model toc-indirect code, because "var" is almost guaranteed to > be too far away from .TOC. for a 16-bit signed offset. And, because > the analysis of which .toc entry can be removed becomes much more > complicated in objects that mix code models, they aren't removed if > any small-model toc sequence appears in an object file. > > Unfortunately, glibc's build of ld.so smashes the needed objects > together in a ld -r linking stage. This means the GOT/TOC is left > with a whole lot of relative relocations which is untidy, but in > itself is not a serious problem. However, static-pie on powerpc64 > bombs due to a segfault caused by one of the small-model accesses > before _dl_relocate_static_pie. (The very first one in rcrt1.o > passing start_addresses in r8 to __libc_start_main.) > > So this patch makes all the toc/got accesses in assembly medium code > model, and a couple of functions hidden. By itself this is not > enough to give us working static-pie, but it is useful in isolation to > enable better linker optimisation. > > There's a serious problem in libgcc too. libgcc ifuncs access the > AT_HWCAP words stored in the tcb with an offset from the thread > pointer (r13), but r13 isn't set at the time _dl_relocate_static_pie. > A followup patch will fix that. Reviewed-by: Tulio Magno Quites Machado Filho -- Tulio Magno