From patchwork Mon Feb 13 16:45:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 64909 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 346CC385B501 for ; Mon, 13 Feb 2023 16:46:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 346CC385B501 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676306798; bh=Z6Lc3oS1oGwXS/FSoPZnwtHR39CbV/UCYJDZNG+IGE8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=LUPhlDn1o/jMBdvHjWJABpBfBKE9VH7Ti7FVHtq7rceInBpIdq8ZSTjOiLdKGgjcZ qLAvL8R49EJOIeoisz/H1Il7lFLe7bNk31CrYE8G7FOFOGsDtlvPkbkJ4tKdTGuUxx EmU2mjMk2vy1R9WYlWz1oWznTYZfRwEC8CsRaMZk= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id D9700385842B for ; Mon, 13 Feb 2023 16:46:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D9700385842B Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31DFEBcY016932; Mon, 13 Feb 2023 16:45:59 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nqqnr2jj9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Feb 2023 16:45:58 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31DGSfGm034871; Mon, 13 Feb 2023 16:45:58 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nqqnr2jhe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Feb 2023 16:45:57 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31D7oVQu002286; Mon, 13 Feb 2023 16:45:56 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma01fra.de.ibm.com (PPS) with ESMTPS id 3np2n6a617-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Feb 2023 16:45:56 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31DGjrfh42598840 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 16:45:53 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D7BA20043; Mon, 13 Feb 2023 16:45:53 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4BCA020049; Mon, 13 Feb 2023 16:45:53 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.19.58]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Feb 2023 16:45:53 +0000 (GMT) To: Mark Wielaard , "Frank Ch . Eigler" Cc: elfutils-devel@sourceware.org, Ilya Leoshkevich Subject: [PATCH v3 1/4] tests: Ignore dwfl-report-offline-memory Date: Mon, 13 Feb 2023 17:45:48 +0100 Message-Id: <20230213164551.550400-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213164551.550400-1-iii@linux.ibm.com> References: <20230213164551.550400-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 6-Mgh5USC1Ww6EZEGAd3Da8Nr4FqHQwB X-Proofpoint-GUID: zadpDKCqADBCuPZtYxwDaCyLc9CDon7e X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_11,2023-02-13_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 impostorscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130150 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_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ilya Leoshkevich via Elfutils-devel From: Ilya Leoshkevich Reply-To: Ilya Leoshkevich Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" It's showing up in git status when configuring in the source directory. Signed-off-by: Ilya Leoshkevich --- tests/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/.gitignore b/tests/.gitignore index 99d04819..536a41ec 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -47,6 +47,7 @@ /dwfl-bug-report /dwfl-proc-attach /dwfl-report-elf-align +/dwfl-report-offline-memory /dwfl-report-segment-contiguous /dwfllines /dwflmodtest From patchwork Mon Feb 13 16:45:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 64907 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 D70EB38493D3 for ; Mon, 13 Feb 2023 16:46:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D70EB38493D3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676306787; bh=HMTnA7HvEYD+fMxJoI6gYVFxFBOic5hOuKk55IyMui8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=qCUJbFS7cNOB7AOTgRqQ+3242E1cHJaNF9H9Av5mESmEIdN0Cc7aMQyJrnbqQkelF w3gQAbN4uphwM2Gz0461+rQvvHQK6Gg5VjV+GRwhw92avdHneZ5Wa7tC/UM4cQqujm PEM+eCZuvVl3ZR0ho2YOH2QaMBe7HP+QHNqjt0Xw= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id E396F3857365 for ; Mon, 13 Feb 2023 16:46:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E396F3857365 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31DFh0TP028373; Mon, 13 Feb 2023 16:46:00 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nqr36t1ag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Feb 2023 16:46:00 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31DGNouv019286; Mon, 13 Feb 2023 16:45:59 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nqr36t19g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Feb 2023 16:45:59 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31D4NpA8022562; Mon, 13 Feb 2023 16:45:57 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma04fra.de.ibm.com (PPS) with ESMTPS id 3np2n6a5xp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Feb 2023 16:45:57 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31DGjsCk19005784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 16:45:54 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B4F0320043; Mon, 13 Feb 2023 16:45:54 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6D3DA20040; Mon, 13 Feb 2023 16:45:54 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.19.58]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Feb 2023 16:45:54 +0000 (GMT) To: Mark Wielaard , "Frank Ch . Eigler" Cc: elfutils-devel@sourceware.org, Ilya Leoshkevich Subject: [PATCH v3 2/4] printversion: Fix unused variable Date: Mon, 13 Feb 2023 17:45:49 +0100 Message-Id: <20230213164551.550400-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213164551.550400-1-iii@linux.ibm.com> References: <20230213164551.550400-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: xzW7xRv3IYbOXTG3SUJ3ZAEP_OenMhgQ X-Proofpoint-ORIG-GUID: RJMXzQ7SEmt5qg4ekkKu5bbEMXSsXP2A X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_11,2023-02-13_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 mlxlogscore=999 bulkscore=0 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 adultscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130150 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP 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: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ilya Leoshkevich via Elfutils-devel From: Ilya Leoshkevich Reply-To: Ilya Leoshkevich Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" clang complains: debuginfod.cxx:354:1: error: unused variable 'apba__' [-Werror,-Wunused-const-variable] ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT; ^ ../lib/printversion.h:47:21: note: expanded from macro 'ARGP_PROGRAM_BUG_ADDRESS_DEF' const char *const apba__ __asm ("argp_program_bug_address") ^ The default linkage for consts in C++ is internal, so declare them extern. While at it, remove the debuginfod workaround for argp_program_version_hook. Co-developed-by: Mark Wielaard Signed-off-by: Ilya Leoshkevich --- debuginfod/debuginfod.cxx | 3 +-- lib/printversion.h | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx index 4271acf4..99b1f2b9 100644 --- a/debuginfod/debuginfod.cxx +++ b/debuginfod/debuginfod.cxx @@ -348,7 +348,7 @@ static const char DEBUGINFOD_SQLITE_CLEANUP_DDL[] = /* Name and version of program. */ -/* ARGP_PROGRAM_VERSION_HOOK_DEF = print_version; */ // not this simple for C++ +ARGP_PROGRAM_VERSION_HOOK_DEF = print_version; /* Bug report address. */ ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT; @@ -4171,7 +4171,6 @@ main (int argc, char *argv[]) /* Parse and process arguments. */ int remaining; - argp_program_version_hook = print_version; // this works (void) argp_parse (&argp, argc, argv, ARGP_IN_ORDER, &remaining, NULL); if (remaining != argc) error (EXIT_FAILURE, 0, diff --git a/lib/printversion.h b/lib/printversion.h index a9e059ff..4154b328 100644 --- a/lib/printversion.h +++ b/lib/printversion.h @@ -39,10 +39,13 @@ void print_version (FILE *stream, struct argp_state *state); argp_program_bug_address, in all programs. argp.h declares these variables as non-const (which is correct in general). But we can do better, it is not going to change. So we want to move them into - the .rodata section. Define macros to do the trick. */ + the .rodata section. Define macros to do the trick. The default + linkage for consts in C++ is internal, so declare them extern. */ +extern void (*const apvh) (FILE *, struct argp_state *); #define ARGP_PROGRAM_VERSION_HOOK_DEF \ void (*const apvh) (FILE *, struct argp_state *) \ __asm ("argp_program_version_hook") +extern const char *const apba__; #define ARGP_PROGRAM_BUG_ADDRESS_DEF \ const char *const apba__ __asm ("argp_program_bug_address") From patchwork Mon Feb 13 16:45:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 64910 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 4B48B385783F for ; Mon, 13 Feb 2023 16:46:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B48B385783F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676306799; bh=pGmW+Belnf/hwCsnw9F9akb0GLOP3QYH7EKKLGuWOFA=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=MCh9qS2A1Xk6Am1FooiOWTfD/jpSW/hFlfEryZS6z8wBe9D1oBLg2KMnedDEpt/jR Df1XbQ5p1R6FIpmqeNnpzpRP0DagOhsyNmiGJ5sMnKD8dr3edxKVtyScZILfZtHbLB nH3gl/c2l5qK/nTaHcS5COHy8EUrSSu09OlmzCeI= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id E530B3856975 for ; Mon, 13 Feb 2023 16:46:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E530B3856975 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31DFh1pl028376; Mon, 13 Feb 2023 16:46:01 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nqr36t1aw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Feb 2023 16:46:01 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31DFhJAH028959; Mon, 13 Feb 2023 16:46:00 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nqr36t1a1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Feb 2023 16:46:00 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31D7oVQv002286; Mon, 13 Feb 2023 16:45:58 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma01fra.de.ibm.com (PPS) with ESMTPS id 3np2n6a618-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Feb 2023 16:45:58 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31DGjtF549938770 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 16:45:55 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C7B7F2004D; Mon, 13 Feb 2023 16:45:55 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 73D5520040; Mon, 13 Feb 2023 16:45:55 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.19.58]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Feb 2023 16:45:55 +0000 (GMT) To: Mark Wielaard , "Frank Ch . Eigler" Cc: elfutils-devel@sourceware.org, Ilya Leoshkevich Subject: [PATCH v3 3/4] backends: Support returning lvalue and rvalue references Date: Mon, 13 Feb 2023 17:45:50 +0100 Message-Id: <20230213164551.550400-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213164551.550400-1-iii@linux.ibm.com> References: <20230213164551.550400-1-iii@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: n2g4807fad2b1Zyzub2d56qW2_D-MLRG X-Proofpoint-ORIG-GUID: MvBhlO-zp2IQlPB3CLt-nn2ya8AA_Fz0 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_11,2023-02-13_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 mlxlogscore=999 bulkscore=0 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 adultscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130150 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP 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: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ilya Leoshkevich via Elfutils-devel From: Ilya Leoshkevich Reply-To: Ilya Leoshkevich Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" On the low level, they are the same as pointers. The change needs to be done for all backends, so define a function and a macro to avoid repetition. Also add a native test, which has to be implemented in C++. Add the configure check for it. Signed-off-by: Ilya Leoshkevich --- backends/aarch64_retval.c | 5 ++--- backends/alpha_retval.c | 5 ++--- backends/arm_retval.c | 5 ++--- backends/i386_retval.c | 5 ++--- backends/ia64_retval.c | 5 ++--- backends/libebl_CPU.h | 15 ++++++++++++++ backends/m68k_retval.c | 5 ++--- backends/ppc64_retval.c | 5 ++--- backends/ppc_retval.c | 5 ++--- backends/riscv_retval.c | 5 ++--- backends/s390_retval.c | 5 ++--- backends/sh_retval.c | 5 ++--- backends/sparc_retval.c | 5 ++--- backends/x86_64_retval.c | 7 +++---- configure.ac | 11 +++++++++-- tests/.gitignore | 1 + tests/Makefile.am | 8 +++++++- tests/funcretval_test++11.cxx | 37 +++++++++++++++++++++++++++++++++++ tests/run-funcretval++11.sh | 21 ++++++++++++++++++++ 19 files changed, 117 insertions(+), 43 deletions(-) create mode 100644 tests/funcretval_test++11.cxx create mode 100755 tests/run-funcretval++11.sh diff --git a/backends/aarch64_retval.c b/backends/aarch64_retval.c index 72d4e8a3..8eaebaf1 100644 --- a/backends/aarch64_retval.c +++ b/backends/aarch64_retval.c @@ -303,12 +303,11 @@ aarch64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) } } - if (tag == DW_TAG_base_type - || tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (tag == DW_TAG_base_type || dwarf_is_pointer (tag)) { if (dwarf_bytesize_aux (&typedie, &size) < 0) { - if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (dwarf_is_pointer (tag)) size = 8; else return -1; diff --git a/backends/alpha_retval.c b/backends/alpha_retval.c index d9bae3bc..9d2dd045 100644 --- a/backends/alpha_retval.c +++ b/backends/alpha_retval.c @@ -89,15 +89,14 @@ alpha_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) case DW_TAG_base_type: case DW_TAG_enumeration_type: - case DW_TAG_pointer_type: - case DW_TAG_ptr_to_member_type: + CASE_POINTER: { Dwarf_Attribute attr_mem; Dwarf_Word size; if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, &attr_mem), &size) != 0) { - if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (dwarf_is_pointer (tag)) size = 8; else return -1; diff --git a/backends/arm_retval.c b/backends/arm_retval.c index 1c28f016..fa6d3914 100644 --- a/backends/arm_retval.c +++ b/backends/arm_retval.c @@ -86,14 +86,13 @@ arm_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) case DW_TAG_base_type: case DW_TAG_enumeration_type: - case DW_TAG_pointer_type: - case DW_TAG_ptr_to_member_type: + CASE_POINTER: { Dwarf_Attribute attr_mem; if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, &attr_mem), &size) != 0) { - if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (dwarf_is_pointer (tag)) size = 4; else return -1; diff --git a/backends/i386_retval.c b/backends/i386_retval.c index 32fec728..8a9c2a2b 100644 --- a/backends/i386_retval.c +++ b/backends/i386_retval.c @@ -89,15 +89,14 @@ i386_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) case DW_TAG_base_type: case DW_TAG_enumeration_type: - case DW_TAG_pointer_type: - case DW_TAG_ptr_to_member_type: + CASE_POINTER: { Dwarf_Word size; Dwarf_Attribute attr_mem; if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, &attr_mem), &size) != 0) { - if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (dwarf_is_pointer (tag)) size = 4; else return -1; diff --git a/backends/ia64_retval.c b/backends/ia64_retval.c index 03ea4d89..7e12236d 100644 --- a/backends/ia64_retval.c +++ b/backends/ia64_retval.c @@ -264,14 +264,13 @@ ia64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) case DW_TAG_base_type: case DW_TAG_enumeration_type: - case DW_TAG_pointer_type: - case DW_TAG_ptr_to_member_type: + CASE_POINTER: { Dwarf_Attribute attr_mem; if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, &attr_mem), &size) != 0) { - if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (dwarf_is_pointer (tag)) size = 8; else return -1; diff --git a/backends/libebl_CPU.h b/backends/libebl_CPU.h index 0e507bd3..2abad76f 100644 --- a/backends/libebl_CPU.h +++ b/backends/libebl_CPU.h @@ -72,4 +72,19 @@ dwarf_peeled_die_type (Dwarf_Die *die, Dwarf_Die *result) return DWARF_TAG_OR_RETURN (result); } +static inline bool +dwarf_is_pointer (int tag) +{ + return tag == DW_TAG_pointer_type + || tag == DW_TAG_ptr_to_member_type + || tag == DW_TAG_reference_type + || tag == DW_TAG_rvalue_reference_type; +} + +#define CASE_POINTER \ + case DW_TAG_pointer_type: \ + case DW_TAG_ptr_to_member_type: \ + case DW_TAG_reference_type: \ + case DW_TAG_rvalue_reference_type + #endif /* libebl_CPU.h */ diff --git a/backends/m68k_retval.c b/backends/m68k_retval.c index a653ba3a..bf41f862 100644 --- a/backends/m68k_retval.c +++ b/backends/m68k_retval.c @@ -96,15 +96,14 @@ m68k_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) case DW_TAG_base_type: case DW_TAG_enumeration_type: - case DW_TAG_pointer_type: - case DW_TAG_ptr_to_member_type: + CASE_POINTER: { Dwarf_Word size; Dwarf_Attribute attr_mem; if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, &attr_mem), &size) != 0) { - if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (dwarf_is_pointer (tag)) size = 4; else return -1; diff --git a/backends/ppc64_retval.c b/backends/ppc64_retval.c index eb1c11ec..1c20c890 100644 --- a/backends/ppc64_retval.c +++ b/backends/ppc64_retval.c @@ -100,14 +100,13 @@ ppc64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) case DW_TAG_base_type: case DW_TAG_enumeration_type: - case DW_TAG_pointer_type: - case DW_TAG_ptr_to_member_type: + CASE_POINTER: { Dwarf_Attribute attr_mem; if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, &attr_mem), &size) != 0) { - if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (dwarf_is_pointer (tag)) size = 8; else return -1; diff --git a/backends/ppc_retval.c b/backends/ppc_retval.c index 39b42da1..5144712b 100644 --- a/backends/ppc_retval.c +++ b/backends/ppc_retval.c @@ -112,14 +112,13 @@ ppc_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) case DW_TAG_base_type: case DW_TAG_enumeration_type: - case DW_TAG_pointer_type: - case DW_TAG_ptr_to_member_type: + CASE_POINTER: { Dwarf_Attribute attr_mem; if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, &attr_mem), &size) != 0) { - if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (dwarf_is_pointer (tag)) size = 4; else return -1; diff --git a/backends/riscv_retval.c b/backends/riscv_retval.c index 34761486..0a1e02f8 100644 --- a/backends/riscv_retval.c +++ b/backends/riscv_retval.c @@ -170,12 +170,11 @@ riscv_return_value_location_lp64ifd (int fp, Dwarf_Die *functypedie, return pass_in_gpr_lp64 (locp, size); } - if (tag == DW_TAG_base_type - || tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (tag == DW_TAG_base_type || dwarf_is_pointer (tag)) { if (dwarf_bytesize_aux (&typedie, &size) < 0) { - if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (dwarf_is_pointer (tag)) size = 8; else return -1; diff --git a/backends/s390_retval.c b/backends/s390_retval.c index 2043f985..0a01d27f 100644 --- a/backends/s390_retval.c +++ b/backends/s390_retval.c @@ -91,8 +91,7 @@ s390_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) case DW_TAG_base_type: case DW_TAG_enumeration_type: - case DW_TAG_pointer_type: - case DW_TAG_ptr_to_member_type: + CASE_POINTER: { Dwarf_Die cudie; uint8_t asize; @@ -103,7 +102,7 @@ s390_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) if (dwarf_formudata (dwarf_attr (typedie, DW_AT_byte_size, &attr_mem), &size) != 0) { - if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (dwarf_is_pointer (tag)) size = asize; else return -1; diff --git a/backends/sh_retval.c b/backends/sh_retval.c index 33d7d964..eac83b70 100644 --- a/backends/sh_retval.c +++ b/backends/sh_retval.c @@ -88,14 +88,13 @@ sh_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) case DW_TAG_base_type: case DW_TAG_enumeration_type: - case DW_TAG_pointer_type: - case DW_TAG_ptr_to_member_type: + CASE_POINTER: { Dwarf_Attribute attr_mem; if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, &attr_mem), &size) != 0) { - if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (dwarf_is_pointer (tag)) size = 4; else return -1; diff --git a/backends/sparc_retval.c b/backends/sparc_retval.c index fb81cdce..8b3fb629 100644 --- a/backends/sparc_retval.c +++ b/backends/sparc_retval.c @@ -95,8 +95,7 @@ sparc_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) case DW_TAG_base_type: case DW_TAG_enumeration_type: - case DW_TAG_pointer_type: - case DW_TAG_ptr_to_member_type: + CASE_POINTER: { Dwarf_Attribute attr_mem; if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, @@ -104,7 +103,7 @@ sparc_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) { uint8_t asize; Dwarf_Die cudie; - if ((tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + if (dwarf_is_pointer (tag) && dwarf_diecu (typedie, &cudie, &asize, NULL) != NULL) size = asize; else diff --git a/backends/x86_64_retval.c b/backends/x86_64_retval.c index f9114cb1..c29ee0e1 100644 --- a/backends/x86_64_retval.c +++ b/backends/x86_64_retval.c @@ -104,14 +104,13 @@ x86_64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) case DW_TAG_base_type: case DW_TAG_enumeration_type: - case DW_TAG_pointer_type: - case DW_TAG_ptr_to_member_type: + CASE_POINTER: { Dwarf_Attribute attr_mem; if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, &attr_mem), &size) != 0) - { - if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + { + if (dwarf_is_pointer (tag)) size = 8; else return -1; diff --git a/configure.ac b/configure.ac index 62a4c8a7..4efb2a9c 100644 --- a/configure.ac +++ b/configure.ac @@ -776,6 +776,11 @@ fi AC_CHECK_PROG(HAVE_ZSTD, zstd, yes, no) AM_CONDITIONAL([HAVE_ZSTD],[test "x$HAVE_ZSTD" = "xyes"]) +# For tests that need to use C++11 +AX_CXX_COMPILE_STDCXX(11, noext, optional) +AS_IF([test "x$HAVE_CXX11" = "x1"], [HAVE_CXX11=yes], [HAVE_CXX11=no]) +AM_CONDITIONAL([HAVE_CXX11],[test "x$HAVE_CXX11" = "xyes"]) + # Look for libcurl for libdebuginfod minimum version as per rhel7. AC_ARG_ENABLE([libdebuginfod],AS_HELP_STRING([--enable-libdebuginfod], [Build debuginfod client library (can be =dummy)])) AS_IF([test "x$enable_libdebuginfod" != "xno"], [ @@ -806,8 +811,9 @@ AM_CONDITIONAL([DUMMY_LIBDEBUGINFOD],[test "x$enable_libdebuginfod" = "xdummy"]) # minimum versions as per rhel7. AC_ARG_ENABLE([debuginfod],AS_HELP_STRING([--enable-debuginfod], [Build debuginfod server])) AS_IF([test "x$enable_debuginfod" != "xno"], [ - AC_MSG_NOTICE([checking debuginfod C++11 support, --disable-debuginfod to skip]) - AX_CXX_COMPILE_STDCXX(11, noext, mandatory) + if test "x$HAVE_CXX11" = "xno"; then + AC_MSG_ERROR([the compiler does not support C++11, use --disable-debuginfod to disable.]) + fi AC_MSG_NOTICE([checking debuginfod dependencies, --disable-debuginfod to skip]) if test "x$enable_libdebuginfod" = "xno"; then AC_MSG_ERROR([need libdebuginfod (or dummy), use --disable-debuginfod to disable.]) @@ -881,6 +887,7 @@ AC_MSG_NOTICE([ EXTRA TEST FEATURES (used with make check) have bunzip2 installed (required) : ${HAVE_BUNZIP2} have zstd installed : ${HAVE_ZSTD} + C++11 : ${HAVE_CXX11} debug branch prediction : ${use_debugpred} gprof support : ${use_gprof} gcov support : ${use_gcov} diff --git a/tests/.gitignore b/tests/.gitignore index 536a41ec..b9aa22ba 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -66,6 +66,7 @@ /fillfile /find-prologues /funcretval +/funcretval_test++11 /funcscopes /get-aranges /get-files diff --git a/tests/Makefile.am b/tests/Makefile.am index 36823d94..bfc03061 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -203,7 +203,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ $(asm_TESTS) run-disasm-bpf.sh run-low_high_pc-dw-form-indirect.sh \ run-nvidia-extended-linemap-libdw.sh run-nvidia-extended-linemap-readelf.sh \ run-readelf-dw-form-indirect.sh run-strip-largealign.sh \ - run-readelf-Dd.sh + run-readelf-Dd.sh run-funcretval++11.sh if !BIARCH export ELFUTILS_DISABLE_BIARCH = 1 @@ -262,6 +262,12 @@ TESTS += run-debuginfod-federation-metrics.sh endif endif +if HAVE_CXX11 +check_PROGRAMS += funcretval_test++11 +funcretval_test__11_SOURCES = funcretval_test++11.cxx +TESTS += run-funcretval++11.sh +endif + EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ run-ar-N.sh \ run-show-die-info.sh run-get-files.sh run-get-lines.sh \ diff --git a/tests/funcretval_test++11.cxx b/tests/funcretval_test++11.cxx new file mode 100644 index 00000000..69e25bfb --- /dev/null +++ b/tests/funcretval_test++11.cxx @@ -0,0 +1,37 @@ +/* Copyright (C) 2023 IBM Corporation + This file is part of elfutils. + + This file is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + elfutils 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +int & +foo () +{ + static int tmp; + return tmp; +} + +int && +bar () +{ + static int tmp; + return std::move(tmp); +} + +int +main () +{ + return 0; +} diff --git a/tests/run-funcretval++11.sh b/tests/run-funcretval++11.sh new file mode 100755 index 00000000..fcfefe19 --- /dev/null +++ b/tests/run-funcretval++11.sh @@ -0,0 +1,21 @@ +#! /bin/sh +# Copyright (C) 2023 IBM Corporation +# This file is part of elfutils. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# elfutils 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. $srcdir/test-subr.sh + +testrun $abs_builddir/funcretval -e $abs_builddir/funcretval_test++11 \ + > /dev/null From patchwork Mon Feb 13 16:45:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 64908 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 C53CB385842B for ; Mon, 13 Feb 2023 16:46:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C53CB385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676306789; bh=r3ikuHlJ4ihTzCMZjD8HHru1gdfJ17tX5L10aa655G8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=NJy1SGWLLtOmiATfEVpRUiJ/kqhnPUmkjk0zS+cZDuU5WxaVZ3JahlBXSKeC2+UIa LWDWsRvibzC/aYpGmCAYFKnYFK01ACZBJHsagOQKvgrV+n6j88OCKx3rZQHgFQaPhQ CFY8x+ZKEv8hGEFs1DRVOkKQXmfRyOa4ncB/2os8= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 97074385B516 for ; Mon, 13 Feb 2023 16:46:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 97074385B516 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31DGg2WK014760; Mon, 13 Feb 2023 16:46:02 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nqrxx0342-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Feb 2023 16:46:02 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31DGi3ws023707; Mon, 13 Feb 2023 16:46:01 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nqrxx032x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Feb 2023 16:46:01 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31DDGAig010684; Mon, 13 Feb 2023 16:45:59 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3np2n6tx4v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Feb 2023 16:45:59 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31DGjuwM21168384 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 16:45:57 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BCB9C2004B; Mon, 13 Feb 2023 16:45:56 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6819F20040; Mon, 13 Feb 2023 16:45:56 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.19.58]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Feb 2023 16:45:56 +0000 (GMT) To: Mark Wielaard , "Frank Ch . Eigler" Cc: elfutils-devel@sourceware.org, Ilya Leoshkevich Subject: [PATCH v3 4/4] configure: Add --enable-sanitize-memory Date: Mon, 13 Feb 2023 17:45:51 +0100 Message-Id: <20230213164551.550400-5-iii@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213164551.550400-1-iii@linux.ibm.com> References: <20230213164551.550400-1-iii@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: liXLbISu0p_lAIkXqhcnFgnvkvpQMafh X-Proofpoint-ORIG-GUID: sypaY5gDXSKCP-1gOtfApBqy0k7lXBnm X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_11,2023-02-13_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 mlxlogscore=999 adultscore=0 impostorscore=0 malwarescore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130150 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP 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: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ilya Leoshkevich via Elfutils-devel From: Ilya Leoshkevich Reply-To: Ilya Leoshkevich Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Add support for clang Memory Sanitizer [1], which detects the usage of uninitialized values. While elfutils itself is already checked with valgrind, checking code that depends on elfutils requires elfutils to be built with MSan. MSan is not linked into shared libraries, and is linked into executables statically. Therefore, unlike the other sanitizers, MSan needs to be configured fairly early, since we need to drop -D_FORTIFY_SOURCE [2], -Wl,-z,defs and --no-undefined. Disable a few tests that run for more than 5 minutes due to test files being statically linked with MSan. [1] https://clang.llvm.org/docs/MemorySanitizer.html [2] https://github.com/google/sanitizers/issues/247 Signed-off-by: Ilya Leoshkevich --- configure.ac | 24 ++++++++++++++++++++++++ debuginfod/Makefile.am | 3 ++- libasm/Makefile.am | 3 ++- libdw/Makefile.am | 3 ++- libelf/Makefile.am | 3 ++- tests/Makefile.am | 10 +++++++++- tests/run-readelf-self.sh | 5 +++++ tests/run-strip-reloc.sh | 5 +++++ tests/run-varlocs-self.sh | 5 +++++ 9 files changed, 56 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 4efb2a9c..18951947 100644 --- a/configure.ac +++ b/configure.ac @@ -155,6 +155,29 @@ AC_SUBST([fpie_CFLAGS]) dso_LDFLAGS="-shared" +NO_UNDEFINED=-Wl,--no-undefined +AC_ARG_ENABLE([sanitize-memory], + AS_HELP_STRING([--enable-sanitize-memory], + [Use clang memory sanitizer]), + [use_msan=$enableval], [use_msan=no]) +if test "$use_msan" = yes; then + old_CFLAGS="$CFLAGS" + old_CXXFLAGS="$CXXFLAGS" + old_LDFLAGS="$LDFLAGS" + # -fsanitize=memory is not compatible with -D_FORTIFY_SOURCE, -Wl,-z,defs and --no-undefined + CFLAGS="$CFLAGS -fsanitize=memory -fsanitize-memory-track-origins -D_FORTIFY_SOURCE=0" + CXXFLAGS="$CXXFLAGS -fsanitize=memory -fsanitize-memory-track-origins -D_FORTIFY_SOURCE=0" + LDFLAGS="-shared" + AC_LINK_IFELSE([AC_LANG_SOURCE([int main (int argc, char **argv) { return 0; }])], use_msan=yes, use_msan=no) + AS_IF([test "x$use_msan" == xyes], + ac_cv_zdefs=no NO_UNDEFINED=, + AC_MSG_WARN([clang memory sanitizer not available]) + CFLAGS="$old_CFLAGS" CXXFLAGS="$old_CXXFLAGS") + LDFLAGS="$old_LDFLAGS" +fi +AC_SUBST(NO_UNDEFINED) +AM_CONDITIONAL(USE_MEMORY_SANITIZER, test "$use_msan" = yes) + ZDEFS_LDFLAGS="-Wl,-z,defs" AC_CACHE_CHECK([whether gcc supports $ZDEFS_LDFLAGS], ac_cv_zdefs, [dnl save_LDFLAGS="$LDFLAGS" @@ -894,6 +917,7 @@ AC_MSG_NOTICE([ run all tests under valgrind : ${use_valgrind} gcc undefined behaviour sanitizer : ${use_undefined} gcc address sanitizer : ${use_address} + clang memory sanitizer : ${use_msan} use rpath in tests : ${tests_use_rpath} test biarch : ${utrace_cv_cc_biarch} ]) diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am index f27d6e2e..125be97b 100644 --- a/debuginfod/Makefile.am +++ b/debuginfod/Makefile.am @@ -102,7 +102,8 @@ endif $(LIBDEBUGINFOD_SONAME): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS) $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \ -Wl,--soname,$(LIBDEBUGINFOD_SONAME) \ - -Wl,--version-script,$<,--no-undefined \ + -Wl,--version-script,$< \ + $(NO_UNDEFINED) \ -Wl,--whole-archive $(libdebuginfod_so_LIBS) -Wl,--no-whole-archive \ $(libdebuginfod_so_LDLIBS) @$(textrel_check) diff --git a/libasm/Makefile.am b/libasm/Makefile.am index c2b54811..1e6b63e8 100644 --- a/libasm/Makefile.am +++ b/libasm/Makefile.am @@ -64,7 +64,8 @@ libasm_so_LIBS = libasm_pic.a libasm.so: $(srcdir)/libasm.map $(libasm_so_LIBS) $(libasm_so_DEPS) $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \ -Wl,--soname,$@.$(VERSION) \ - -Wl,--version-script,$<,--no-undefined \ + -Wl,--version-script,$< \ + $(NO_UNDEFINED) \ -Wl,--whole-archive $(libasm_so_LIBS) -Wl,--no-whole-archive \ $(libasm_so_LDLIBS) @$(textrel_check) diff --git a/libdw/Makefile.am b/libdw/Makefile.am index 1b6fead4..e548f38c 100644 --- a/libdw/Makefile.am +++ b/libdw/Makefile.am @@ -114,7 +114,8 @@ libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(fts_LIBS) $(obstack_ libdw.so: $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS) $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \ -Wl,--soname,$@.$(VERSION),--enable-new-dtags \ - -Wl,--version-script,$<,--no-undefined \ + -Wl,--version-script,$< \ + $(NO_UNDEFINED) \ -Wl,--whole-archive $(libdw_so_LIBS) -Wl,--no-whole-archive \ $(libdw_so_LDLIBS) @$(textrel_check) diff --git a/libelf/Makefile.am b/libelf/Makefile.am index 24c25cf8..aabce43e 100644 --- a/libelf/Makefile.am +++ b/libelf/Makefile.am @@ -115,7 +115,8 @@ libelf_so_LIBS = libelf_pic.a libelf.so: $(srcdir)/libelf.map $(libelf_so_LIBS) $(libelf_so_DEPS) $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \ -Wl,--soname,$@.$(VERSION) \ - -Wl,--version-script,$<,--no-undefined \ + -Wl,--version-script,$< \ + $(NO_UNDEFINED) \ -Wl,--whole-archive $(libelf_so_LIBS) -Wl,--no-whole-archive \ $(libelf_so_LDLIBS) @$(textrel_check) diff --git a/tests/Makefile.am b/tests/Makefile.am index bfc03061..fb7714d0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -88,12 +88,16 @@ endif # test_nlist checks its own symbol table, and expects various symbols # to be in the order as specified in the source file. Explicitly set -# minimal CFLAGS. But add address sanitizer if in use. +# minimal CFLAGS. But add sanitizers if in use. if USE_ADDRESS_SANITIZER EXTRA_NLIST_CFLAGS=-fsanitize=address else +if USE_MEMORY_SANITIZER +EXTRA_NLIST_CFLAGS=-fsanitize=memory -fsanitize-memory-track-origins +else EXTRA_NLIST_CFLAGS= endif +endif test-nlist$(EXEEXT): test-nlist.c $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ @@ -225,6 +229,10 @@ if USE_ZSTD_COMPRESS export ELFUTILS_ZSTD = 1 endif +if USE_MEMORY_SANITIZER +export ELFUTILS_MEMORY_SANITIZER = 1 +endif + if DEBUGINFOD check_PROGRAMS += debuginfod_build_id_find # With the dummy delegation doesn't work diff --git a/tests/run-readelf-self.sh b/tests/run-readelf-self.sh index 7ffb3577..f5984597 100755 --- a/tests/run-readelf-self.sh +++ b/tests/run-readelf-self.sh @@ -17,5 +17,10 @@ . $srcdir/test-subr.sh +if test -n "$ELFUTILS_MEMORY_SANITIZER"; then + echo "binaries linked with memory sanitizer are too big" + exit 77 +fi + # Just makes sure readelf doesn't crash testrun_on_self_quiet ${abs_top_builddir}/src/readelf -a -w diff --git a/tests/run-strip-reloc.sh b/tests/run-strip-reloc.sh index 033ed278..02e626af 100755 --- a/tests/run-strip-reloc.sh +++ b/tests/run-strip-reloc.sh @@ -17,6 +17,11 @@ . $srcdir/test-subr.sh +if test -n "$ELFUTILS_MEMORY_SANITIZER"; then + echo "binaries linked with memory sanitizer are too big" + exit 77 +fi + testfiles hello_i386.ko hello_x86_64.ko hello_ppc64.ko hello_s390.ko \ hello_aarch64.ko hello_m68k.ko hello_riscv64.ko hello_csky.ko \ hello_arc_hs4.ko diff --git a/tests/run-varlocs-self.sh b/tests/run-varlocs-self.sh index 5454fc70..760fe4d7 100755 --- a/tests/run-varlocs-self.sh +++ b/tests/run-varlocs-self.sh @@ -17,6 +17,11 @@ . $srcdir/test-subr.sh +if test -n "$ELFUTILS_MEMORY_SANITIZER"; then + echo "binaries linked with memory sanitizer are too big" + exit 77 +fi + # Make sure varlocs doesn't crash, doesn't trigger self-check/asserts # or leaks running under valgrind. testrun_on_self_exe ${abs_top_builddir}/tests/varlocs -e