From patchwork Tue Nov 21 12:33:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 80469 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 E8E05385829E for ; Tue, 21 Nov 2023 12:33:28 +0000 (GMT) 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 D01CD3858D39 for ; Tue, 21 Nov 2023 12:33:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D01CD3858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D01CD3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700569994; cv=none; b=uuls+qVfUAr7fKKls/ueGXW/DNV7b4OMK9NYF0ZpOOXAgBHs5JmvWWNyudMY+l9JqDvU3ot5vlCWGCqt/a4QS2Nn8k5SbWIoMol/ynISMBvxt+SMe/7SdbJ6Z4blf8J2lb5ZbR/j7chZuq8ZK+djKjlaKhnjCZEDY8szqbKhOzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700569994; c=relaxed/simple; bh=0PZ2/wHz+ZP+vPVcpGeygA9mWcTJGWDx/pOKJRDSE/Y=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wfaSrLIfG7b5LMh2pnpJ5zFFX9I6sX+4/KLLkn89PkMwIeWuCxDHV0xlSlxqnzjOxoU1/KeLW/em6gZEjYwUOqfnIxsYJr+UhzU5i2oUa4tOxPP7KGroAoPZYJrxCgSMU0WRRQwFtR//UJVk23KsjYxrP7E0jKQWQ6942IkZ3do= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ALBk9ct005317; Tue, 21 Nov 2023 12:33:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=5dXeotKSIOAbGTEEYnZNmISLwIL1Q56GDrDnN4tvj6A=; b=J9RFoh7sRy07rhrD4eCgY8m+5AjN1YjNO7VMxG2cdTZCFDXYcuUPXpcnYzPLTWx/jJ7f /Pifbbmhlf6tD2jdfeC8+QGRdnlTD7BnLQGo/w9JO9dZHfI7Mk0IAMstBCOkIUIDNLsi DL0QtK8qtWB3oVXXlXWLZY92yqfkdFjlwyW6erwryett8rh1LqfPQWwq9GsX/BWIc8tC AcdQWD0F5xFs8PzUATybHe8ZsDGn0KcvtET4sTwQkFQN+fiYgzLS4W8wNRcMWcvdCpV2 DbQ9/iaDvgi2yCHeTbV1QV+g7TtXQpkAcZn32shsgxWq6MhyOLebmuNQIXqjHcQUpkdG mg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uguy71ew5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 12:33:09 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3ALBmG9j013846; Tue, 21 Nov 2023 12:33:08 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uguy71evj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 12:33:08 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3ALC40BA000999; Tue, 21 Nov 2023 12:33:07 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uf8knrhhp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 12:33:07 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3ALCX5qw23790240 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Nov 2023 12:33:05 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 520A720043; Tue, 21 Nov 2023 12:33:05 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2D4FE20040; Tue, 21 Nov 2023 12:33:05 +0000 (GMT) Received: from a35lp68.lnxne.boe (unknown [9.152.108.100]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Nov 2023 12:33:05 +0000 (GMT) From: Stefan Liebler To: libc-alpha@sourceware.org Cc: rui314@gmail.com, schwab@linux-m68k.org, Stefan Liebler Subject: [PATCH] Avoid padding in _init and _fini. [BZ #31042] Date: Tue, 21 Nov 2023 13:33:03 +0100 Message-ID: <20231121123303.3405218-1-stli@linux.ibm.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: y1U-LvksuJWszRRogiqWC5M3lznrWNSZ X-Proofpoint-ORIG-GUID: NQgH6eEUR2vDSVVvufpzYkGhLmHH_fJu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-21_05,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 malwarescore=0 clxscore=1011 bulkscore=0 phishscore=0 impostorscore=0 mlxlogscore=603 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311210098 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org The linker just concatenates the .init and .fini sections which results in the complete _init and _fini functions. If needed the linker adds padding bytes due to an alignment. GNU ld is adding NOPs, which is fine. But e.g. mold is adding traps which results in broken _init and _fini functions. Thus this patch removes the alignment in .init and .fini sections in crtn.S files. We keep the 4 byte function alignment in crti.S files. As the assembler now also outputs the start of _init and _fini functions as multiples of 4 byte, it perhaps has to fill it. Although GNU as is using NOPs here, to be sure, we just keep the alignment with 0x07 (=NOPs) at the end of crti.S. In order to avoid an obvious NOP slide in _fini, this patch also uses an lg instead of lgr instruction. Then the emitted instructions needs a multiple of 4 bytes. --- sysdeps/s390/s390-64/crti.S | 2 +- sysdeps/s390/s390-64/crtn.S | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/sysdeps/s390/s390-64/crti.S b/sysdeps/s390/s390-64/crti.S index 11ab75e8d9..4c8246da26 100644 --- a/sysdeps/s390/s390-64/crti.S +++ b/sysdeps/s390/s390-64/crti.S @@ -85,7 +85,7 @@ _init: .type _fini,@function _fini: stmg %r6,%r15,48(%r15) - lgr %r1,%r15 + lg %r1,120(%r15) aghi %r15,-160 stg %r1,0(%r15) larl %r12,_GLOBAL_OFFSET_TABLE_ diff --git a/sysdeps/s390/s390-64/crtn.S b/sysdeps/s390/s390-64/crtn.S index 0eabcb346c..6bb1bc9dcf 100644 --- a/sysdeps/s390/s390-64/crtn.S +++ b/sysdeps/s390/s390-64/crtn.S @@ -37,13 +37,11 @@ corresponding to the prologues in crti.S. */ .section .init - .align 4 lg %r4,272(%r15) lmg %r6,%r15,208(%r15) br %r4 .section .fini - .align 4 lg %r4,272(%r15) lmg %r6,%r15,208(%r15) br %r4