From patchwork Tue Jan 9 23:47:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 1884697 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=SWZ7ZlMB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T8nq10lQCz1yPh for ; Wed, 10 Jan 2024 10:54:52 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E0F93860C0C for ; Tue, 9 Jan 2024 23:54:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id E81F03858431; Tue, 9 Jan 2024 23:54:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E81F03858431 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 E81F03858431 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=1704844451; cv=none; b=GX+HJuVAFUYWxeL0io0tckfIhtKUjdQ9+ygOiAxuF4ZMLufSvmUn1WUSJvIu6LhN1BHolYhetRunkPmZtJZqIg6kGHdX/YkT40VNaitmlBpQhCVlwoh/+P1YH0EtafJK2c7HbxjF7TDpwa7tzIV6Nw/bL1wRsHa1ixGLIBxfxlE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704844451; c=relaxed/simple; bh=EKq3EXW08EDegY+sfi7UJbof3p+stsJE5R2BUXVUvxk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aPZGnsN8G09oOcx135PtkbXy1wVNLNRFIb+aK6u+ASJ/DAIzdb4Rr3MI6u/gfEG/wnq/ibweycVuDX2B1roRmAlpk14kiKDqR5aoaHQ1/NzctTyP6vWgdfDJDa/yWarFZ5z46inPxc9g0HBxHvwbU2XJymhVMmPFG3P/7YZMLfM= 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 409Ns7qd026872; Tue, 9 Jan 2024 23:54:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : mime-version; s=pp1; bh=AKu9LHaHBqQ6mgjs2rkkEgAwDx5tY6Z14uyyzpdGZAo=; b=SWZ7ZlMBcYDQqhlg9i6eIMRiFIlC83lMGPPJXPttIBfkcJ3fQN9efDDMWP7GpptGwkz2 EvG3bsZXj9G+OQ7Xw5J42Qk/wqkV63ACVszjF5mSepyBDhZVnOgB/IFFOYn9r4W3PYnr D65a9/NI0EIrXcA1CGXaAPgd7blFq3VLtXawYAcHUQvCx28wg3TZn4EExJSWQFgL8rrD xPZO2NJrVJ0LcYFxGNY2H0bhX1Nm8rNxCgDZ+AZEK776LfFZPwkoaZXOwcb0h5Q5wYV1 y1iu7pTxmnXFDOiy/WIDn7690te78GkcXQDSDoBl0so3PjchFFRDXQseURbefOItzWLo BQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vhbn8en0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jan 2024 23:54:07 +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 409Nl3qL013518; Tue, 9 Jan 2024 23:54:06 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vhbn8emx6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jan 2024 23:54:06 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 409KjJA8027026; Tue, 9 Jan 2024 23:52:16 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vfkw21eb8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jan 2024 23:52:16 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 409NqDko8258248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 Jan 2024 23:52:13 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D0C02004D; Tue, 9 Jan 2024 23:52:13 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D19A920040; Tue, 9 Jan 2024 23:52:12 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.60.193]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 9 Jan 2024 23:52:12 +0000 (GMT) From: Ilya Leoshkevich To: Jeff Law , Jakub Jelinek Cc: seurer@gcc.gnu.org, Andreas Krebbel , gcc-patches@gcc.gnu.org, Stefan Schulze Frielinghaus , Ilya Leoshkevich Subject: [PATCH v2] rs6000: Fix ASAN linker errors for Power ELF V1 ABI [PR113284] Date: Wed, 10 Jan 2024 00:47:39 +0100 Message-ID: <20240109235210.605208-1-iii@linux.ibm.com> X-Mailer: git-send-email 2.43.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5efYBfkIHG1ru52f6NP9Bs7ld6SvqBTa X-Proofpoint-ORIG-GUID: 6L0lXrU7eZKx2TlzS6aF635byJmHVMaX X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-09_11,2024-01-09_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 spamscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401090192 X-Spam-Status: No, score=-11.4 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org v1: https://inbox.sourceware.org/gcc-patches/20240109105253.332676-1-iii@linux.ibm.com/ v1 -> v2: Move the .LASANPC label to the .text section (Jakub). Jakub okay-ed this version in the GCC Bugzilla. Bootstrap and regtest running on ppc64le-redhat-linux and powerpc64-linux-gnu. Ok for trunk when successful? rs6000_elf_declare_function_name () outputs Power ELF V1 ABI function entry labels without using ASM_OUTPUT_FUNCTION_LABEL (). As a result, .LASANPC labels are not emitted, causing linker errors. In theory, it is possible to reuse ASM_OUTPUT_FUNCTION_LABEL () by changing rs6000_output_function_entry () to generate label names without outputting them, but this would be quite a large change. Instead, factor out the .LASANPC emitting code from ASM_OUTPUT_FUNCTION_LABEL () and call it manually. Fixes: c659dd8bfb55 ("Implement ASM_DECLARE_FUNCTION_NAME using ASM_OUTPUT_FUNCTION_LABEL") Suggested-by: Jakub Jelinek Signed-off-by: Ilya Leoshkevich gcc/ChangeLog: PR sanitizer/113284 * config/rs6000/rs6000.cc (rs6000_elf_declare_function_name): Use assemble_function_label_final () for Power ELF V1 ABI. * output.h (assemble_function_label_final): New function. * varasm.cc (assemble_function_label_raw): Use assemble_function_label_final (). (assemble_function_label_final): New function. --- gcc/config/rs6000/rs6000.cc | 1 + gcc/output.h | 4 ++++ gcc/varasm.cc | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 94fbf46f2b6..5d975dab921 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -21357,6 +21357,7 @@ rs6000_elf_declare_function_name (FILE *file, const char *name, tree decl) ASM_DECLARE_RESULT (file, DECL_RESULT (decl)); rs6000_output_function_entry (file, name); fputs (":\n", file); + assemble_function_label_final (); return; } diff --git a/gcc/output.h b/gcc/output.h index c8fe1d2643d..46b0033b221 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -182,6 +182,10 @@ extern const char *get_fnname_from_decl (tree); code or data is output after the label. */ extern void assemble_function_label_raw (FILE *, const char *); +/* Finish outputting function label. Needs to be called when outputting + function label without using assemble_function_label_raw (). */ +extern void assemble_function_label_final (void); + /* Output assembler code for the constant pool of a function and associated with defining the name of the function. DECL describes the function. NAME is the function's name. For the constant pool, we use the current diff --git a/gcc/varasm.cc b/gcc/varasm.cc index 1a869ae458a..2b633822434 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -1843,6 +1843,15 @@ void assemble_function_label_raw (FILE *file, const char *name) { ASM_OUTPUT_LABEL (file, name); + assemble_function_label_final (); +} + +/* Finish outputting function label. Needs to be called when outputting + function label without using assemble_function_label_raw (). */ + +void +assemble_function_label_final (void) +{ if ((flag_sanitize & SANITIZE_ADDRESS) /* Notify ASAN only about the first function label. */ && (in_cold_section_p == first_function_block_is_cold)