From patchwork Wed Sep 24 15:00:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 120809 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 2EB493857007 for ; Wed, 24 Sep 2025 15:02:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2EB493857007 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1758726133; bh=c18ylBkJH9lyB0VoOyUyC7pxtHAi6a9WsRN7NlWBvxo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=N8QRCa+fJcMGVLWfHCv3pbdax2THdn84AW+Ssc/H8e5uc0qfLDcnlCZoQ6SeuqyJz pc/bjui+l2F6iGjMl4QsFXk5z9K+zGjsbSCxmycblK3R+XB5T7Y4PDdeiHzTc0q98L xqiql6y7TRt44X5UBzcn1R33riGGFx7D0iv4+mxs= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 5C4A03858D26 for ; Wed, 24 Sep 2025 15:00:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C4A03858D26 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5C4A03858D26 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1758726021; cv=pass; b=mYlOeSlqAd8UPbbHrXkUGFCJvoLe8wFa6xoOipeLBH9jvx3DKLsYDDJP8pZKssSMaEf8DU+Dt5dfIkCKBb0kBrx6Rf/GljgOnQqVxxRIuYPcBsX2m/eH5np+KHlGAX2kwo9v4sjFTJPUcwCSgMxhCrf+twdOkrwoCsZecQDHMc8= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1758726021; c=relaxed/simple; bh=spAjAFcP3slOyPzjdy9Ze5YWZphnlvPG9r4TmBAIxnk=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=SCB5xG8y1r6eP9f0n6okrZUhCIbvUXce7QNR4vTQjrBYoJ9mcrNCbsPy9+gow/hPeAmnDsbx3gErtIeVg4XN1uoXUnpMwCLJ/KL2PPeL9xGGcTWGmibnJonVZTqK4u//y/F1+uYk30SHfrRWOi7dNlT3QQ7XF9RylgVEc0NUUoQ= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C4A03858D26 Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58OEtmlB012948 for ; Wed, 24 Sep 2025 15:00:20 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 499k6ayx81-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 24 Sep 2025 15:00:20 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 58OE2Ijd033062 for ; Wed, 24 Sep 2025 15:00:18 GMT Received: from ph7pr06cu001.outbound.protection.outlook.com (mail-westus3azon11010020.outbound.protection.outlook.com [52.101.201.20]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 49a6nm691u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 24 Sep 2025 15:00:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QQNjEdWq01fPBI22dP1FQOA8qj2Hj0TB/4XXnEyQFA9uj//bX6yILmrYg2fQkECjBfbMlSlDMV2gPHvWZuqnP0jf2I2fBeX/QOkCdcZAgI8XwJMbm5Wr+cXVUEeZJogBJMdvi2k0WLg3kw93eGgPP8GiBxPXhw2EKC9bBwTLAOWTH9LQdzg2eKzluEKG8IbvPSbr3dmOvTHdGlgvgliiJ1DLZsVEXNu9QqBs7/Y9egU1+TGFJ/E4WSwlk2kaiaMlBUe1/25vKQDdelQm/PM6Pvu/bu9Ykd9QoWJyQOPZVVH+xLsxzE4sGkLgLO3iK4b35HjRJ7rw2dD98jZ7JKsfaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c18ylBkJH9lyB0VoOyUyC7pxtHAi6a9WsRN7NlWBvxo=; b=kFNHyPY9N9dcjk21KNYvjnL8qQzMp1HE8sS+kLkVG8pu+9a25wAp4M0BN7NGV9l5Tr/0BKiiHTniL4Y1dWY4kgL5rkyTbrPaWOTgfUm+Jlya2EcvFASPC5YOb5wR/XeM5jZbBZDhdje5uvxNu3uQ9l0FVjDKeDBUgZcY6KugJu69kLRrqk3oDF1fbUT+20b6Jv8EKGAgfM9U1YERaI/u3cZo8cipAG1sHoBlBR+ZTCjf9LMRGukkSGiBe2pXZ3g8irXDr5GU4V5KPlEoTiDpWVtNMa28OZHFT/0+3wYeocJoBXmQNdNF21Tel+0iM2S+St2uw3Re5lMQSWFCKXvRXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from PH3PPFA3184E4F2.namprd10.prod.outlook.com (2603:10b6:518:1::7bb) by BLAPR10MB5153.namprd10.prod.outlook.com (2603:10b6:208:330::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9160.9; Wed, 24 Sep 2025 15:00:14 +0000 Received: from PH3PPFA3184E4F2.namprd10.prod.outlook.com ([fe80::815c:d94d:29c8:ecb3]) by PH3PPFA3184E4F2.namprd10.prod.outlook.com ([fe80::815c:d94d:29c8:ecb3%8]) with mapi id 15.20.9137.018; Wed, 24 Sep 2025 15:00:14 +0000 To: binutils@sourceware.org Subject: [PATCH 1/2] libctf: fix querying of large structures Date: Wed, 24 Sep 2025 16:00:07 +0100 Message-ID: <20250924150008.46198-1-nick.alcock@oracle.com> X-Mailer: git-send-email 2.51.0.284.g117bcb8de7 X-ClientProxiedBy: LO2P265CA0102.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::18) To PH3PPFA3184E4F2.namprd10.prod.outlook.com (2603:10b6:518:1::7bb) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH3PPFA3184E4F2:EE_|BLAPR10MB5153:EE_ X-MS-Office365-Filtering-Correlation-Id: 1dfac7e9-fd6f-443c-36f4-08ddfb7b10e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: 0xISMmjHdSOcbexaRqLcon0BqM/8Cgr0hzjkiHtbyCTTiMdQV/cXJzBmd6vL+RmA0+LPz3YnCjyqJUaiIPPP4nX49n+Oo4fU0XneGQ5r82OMNOVB8hwLY5FRuIp0LzhFya7dzjqDXzyG0LwCEKZF/DoQz7RKGH2JD6a8ylh5X6V4VrgnJBYoKc6VrPY1tSjjgkpmDtdgxCa+fzqu2gtnTcT4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q/CpQ8pkjYeB+GjwJmavbK6w44SSbimtugiRvvXrDYwLe+SpqWDdy3isWKOkkDqtgoVzVHNPXuCmRqh3yNyDE1p4HMWMsJ+jOzJlD6kRoF/EAGDD6v3V68TMeOC0IBQWI3NFEuictc3SFVJh4i0Ptt+jF92HsyYzJU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH3PPFA3184E4F2.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EZv71Z5zd/ryPXgfsoLmoDJ5tHWlEC4FemJLOzevtRTdivwCP2/xqoBVkDigDQc2/4MIJZVawSRMSlSWWUW30DCwtywCPX6+c8k5RbDvE6s/Mj1CDwClxpvn1hZWQJZ0f/y1tEhWWx2FSX/yAfNupRIBOzWseXLP30EvMBA1wVEX9OL0qvtwfb58/71I2gafd0DTXTXUqb4NLoDr+E1uxIibQyXN2qCC071d5nDbaxwny9PwqKcQtV4lreqd1jKTIAKWjJgHL+7mayZqYPaDC500iQLA5PaB5jh1WmejwgNmfubUsjCPgKfOVaT4yD9jiO/Q7O0uprWkI9hfOE35x/RCpIeQR5Ktbxy7Ce1Cio7hYHqvzzJpdqU0ZElYkVArK0h0I2VTEGOi0ivXKhwzDvJvKDaD2bHZ2Q3tcY6jvF52iIxgMxFMHPL9J3+dcjo/F1E4vJW4+/WqfM4+z1+YrIPlFqHLeQzAqmW8/yw7XBa1SfkUhkyDMfrZJoaG8JXC9ci+x2hs4MrqoxxA76qBl4+5D/eGcuwWKcKdKN+Z7uQek79jG8Wdy32JiXDFqIiwH53SFtBv15h/upK5XgRX1VUnHWno/aCkyr9ip+0wrt6iZ/kfGTOnsTw5MBKtUjSp3+sMIwRb2IhXHXABbV2SHm637SlnrwUYV0NHBIqXUU0AB+1F7pS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br3yQVx/j69mqb3P75BIwzSyp0QPu/1Z63I8xQwKPS7JzZDNVY8FeF/bkLdGG7l9Xucl5oJeXySWLNnH8um8txSHF9Gnx6iLnjGeufQXCvW/Kp3U0gqQyGZu2a+cMye28qrSXpj6noyKqRu4ahRP0p0djwA4aODUEKgzJrZezDPVm8E9kVytAvKOmUTIZn6OwjqPHsKTJW0drlAGtOMj7gQKDh8GHpvXYFi6E506hHbL2rimYMtL0URKB3pV3pe1H8OcuMC2+RJVyJ/N5bHfu1x6Ek4+xfeavU3eA72IduFOP7U4Q9IubEMBqJsoVK8jH9Xb1D5drOsrQ/A+dNeWdIrB6Wfky7YP7naWCDEIHrAjfYeV5/lmMaxWTvSmbStwW0lAWMs/JuIxNXLP0ceLeVTb5mWagwsBRlji39jyzm3EvrVup+8hiIeieNsYT1gljIPjJIe+5ES2lG2Fn9+QUZ2xk9JEmxed8LO0AZzht5oavRRYFlz88aTfC8sDCoeVb0ndJmonQWU6DXk+kAUU8ISTdt21kKsCU+QogowA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1dfac7e9-fd6f-443c-36f4-08ddfb7b10e6 X-MS-Exchange-CrossTenant-AuthSource: PH3PPFA3184E4F2.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2025 15:00:14.3921 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7SZpJF2LNCRMiKX1leFrGKpxGu8o2VGaKpAmCZ0qXip9DxMc9DLVQhUDU6GTGQjEZDallVFC5pEkx86E5ipZ8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5153 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-24_03,2025-09-22_05,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2509240129 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTIwMDAxNyBTYWx0ZWRfX1w1TkjS3TXJt Ol8/bY+vb5GzXUE61kvjMNsffkoHAVxo3hCrMxUz/yJLMrrIWgQK7pbngmxTCnnubB/R2xfxnLQ wHD9pD6xQHJsA0DHzQ+LNfRiShj/jj5QKeVsk/+OuiCh7vf6fnnsASpIlGJ2EL2C7jSaPortQ+a S3hA1qIXFIUMZuoEINhTr+fofsbMDHAL84wXuVSPESjY32JMvOGRqW0M1kdOU8NjATVPo8F4Y5U OFCV/bXKlJDjDr9DJ3bpqO7UCZeJBzfJDSbHsc9n1pswfatmogN/OEByJYmDu4SXPvd2I59Ahst NVIvcQ2hI1LZB7pY8XnOBFekrvAAvewKGshm259bGUc2J1s+6qWRCFMPF65At9Fph+ze9M9jvEW W5nZslKvD6HNuMx9deXXNpUsVxlBCQ== X-Proofpoint-GUID: dGNerdgO5yaETR4-vkhtHAh-HnVZc3kx X-Authority-Analysis: v=2.4 cv=E47Npbdl c=1 sm=1 tr=0 ts=68d40784 b=1 cx=c_pps a=e1sVV491RgrpLwSTMOnk8w==:117 a=e1sVV491RgrpLwSTMOnk8w==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=z/mQ4Ysz8XfWz/Q5cLBRGdckG28=:19 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=yJojWOMRYYMA:10 a=GoEa3M9JfhUA:10 a=_dzSelPmBi3vuXIGk9EA:9 cc=ntf awl=host:13622 X-Proofpoint-ORIG-GUID: dGNerdgO5yaETR4-vkhtHAh-HnVZc3kx X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE, SPF_NONE, 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Nick Alcock via Binutils From: Nick Alcock Reply-To: Nick Alcock Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org After GCC PR 121411 is fixed, large structures (with offsets > 512MiB) are written correctly... but libctf cannot query them properly unless they are even bigger (> 4GiB), because it checks to see if the ctt_size is CTF_LSIZE_SENT to decide whether to use a ctf_lmember_t or a ctf_member_t to encode the structure members. But the structure member offsets are in *bits*, not bytes: the right value to check is CTF_LSTRUCT_THRESH, which is 1/8th the size. (Thanks to Martin Pirker for the diagnosis and fix.) Testing this is a bit fun, because we don't want to emit an error if the compiler is broken: but we cannot tell whether the compiler is broken using the existing lookup harness, because its input is passed through the linker (and thus the broken ld). So add another sort of link mode, "objects", which keeps the constituent object files around and passes both the final linker output and the object files that make it up to the lookup program. Our testcase can then check the linker input to see if the compiler is buggy, and only if it isn't check the linker output and fail if things aren't right. libctf/ PR libctf/33339 * ctf-types.c (ctf_struct_member): Check CTF_LSTRUCT_THRESH, not CTF_LSIZE_SENT. * testsuite/lib/ctf-lib.exp (run_lookup_test): New 'objects' link option. * testsuite/libctf-lookup/big-struct-corruption.*: New test. * testsuite/libctf-lookup/big-struct-ctf.c: New test input. --- libctf/ctf-types.c | 2 +- libctf/testsuite/lib/ctf-lib.exp | 43 +++++-- .../libctf-lookup/big-struct-corruption.c | 118 ++++++++++++++++++ .../libctf-lookup/big-struct-corruption.lk | 3 + .../testsuite/libctf-lookup/big-struct-ctf.c | 72 +++++++++++ 5 files changed, 228 insertions(+), 10 deletions(-) create mode 100644 libctf/testsuite/libctf-lookup/big-struct-corruption.c create mode 100644 libctf/testsuite/libctf-lookup/big-struct-corruption.lk create mode 100644 libctf/testsuite/libctf-lookup/big-struct-ctf.c diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c index 044a1852c1a..d08d4542dc1 100644 --- a/libctf/ctf-types.c +++ b/libctf/ctf-types.c @@ -45,7 +45,7 @@ ctf_struct_member (ctf_dict_t *fp, ctf_lmember_t *dst, const ctf_type_t *tp, return -1; /* errno is set for us. */ /* Already large. */ - if (tp->ctt_size == CTF_LSIZE_SENT) + if (tp->ctt_size >= CTF_LSTRUCT_THRESH) { ctf_lmember_t *lmp = (ctf_lmember_t *) vlen; diff --git a/libctf/testsuite/lib/ctf-lib.exp b/libctf/testsuite/lib/ctf-lib.exp index 4df6619606b..7175e14c30a 100644 --- a/libctf/testsuite/lib/ctf-lib.exp +++ b/libctf/testsuite/lib/ctf-lib.exp @@ -141,6 +141,8 @@ proc compile_link_one_host_cc { src output additional_args } { # # link: # If set, link the SOURCE together even if only one file is specified. +# If "objects", keep the input object files and pass them as additional +# arguments to LOOKUP. # # link_flags: # If set, extra flags to pass to the linker. @@ -265,11 +267,14 @@ proc run_lookup_test { name } { # Compile the inputs and posibly link them together. set lookup_output "" + set objs {} if { [llength $opts(source)] > 0 } { set lookup_flags "" + set ld_flags "" if { $run_ld } { set lookup_output "tmpdir/out.so" - set lookup_flags "-gctf -fPIC $shared $opts(link_flags)" + set lookup_flags "-gctf -fPIC" + set ld_flags "$shared $opts(link_flags)" } else { set lookup_output "tmpdir/out.o" set lookup_flags "-gctf -fPIC -c" @@ -280,19 +285,38 @@ proc run_lookup_test { name } { if [board_info [target_info name] exists ldflags] { append lookup_flags " [board_info [target_info name] ldflags]" } - set src {} + set objsrcs {} + set local_srcs {} foreach sfile $opts(source) { + set local_src [file join [file dirname $file] $sfile] + lappend local_srcs $local_src + if [is_remote host] { - lappend src [remote_download host [file join [file dirname $file] $sfile]] + set src [remote_download host [file join [file dirname $file] $sfile]] } else { - lappend src [file join [file dirname $file] $sfile] + set src [file join [file dirname $file] $sfile] + } + + if { $opts(link) == "objects" } { + set obj "[file rootname $src].o" + set comp_output [prune_warnings [run_host_cmd "$CC_FOR_TARGET" "$CFLAGS_FOR_TARGET $lookup_flags $src -c -o $obj"]] + + if { $comp_output != ""} { + send_log "compilation of CTF program $local_src failed with <$comp_output>" + fail $testname + return 0 + } + lappend objsrcs $obj + lappend objs $obj + } else { + lappend objsrcs $src } } - set comp_output [prune_warnings [run_host_cmd "$CC_FOR_TARGET" "$CFLAGS_FOR_TARGET $lookup_flags [concat $src] -o $lookup_output"]] + set comp_output [prune_warnings [run_host_cmd "$CC_FOR_TARGET" "$CFLAGS_FOR_TARGET $lookup_flags $ld_flags [concat $objsrcs] -o $lookup_output"]] if { $comp_output != ""} { - send_log "compilation of CTF program [concat $src] failed with <$comp_output>" + send_log "compilation of CTF program [concat $local_srcs] failed with <$comp_output>" fail $testname return 0 } @@ -306,12 +330,13 @@ proc run_lookup_test { name } { } } - # Invoke the lookup program on the outputs, possibly through the wrapper. + # Invoke the lookup program on the outputs, possibly through the wrapper, including all + # the object file names if they were filled out. if { [llength $opts(wrapper)] == 0 } { - set results [run_host_cmd tmpdir/lookup $lookup_output] + set results [run_host_cmd tmpdir/lookup "$lookup_output $objs"] } else { - set results [run_host_cmd "$opts(wrapper) tmpdir/lookup" $lookup_output] + set results [run_host_cmd "$opts(wrapper) tmpdir/lookup" "$lookup_output $objs"] } if { [regexp {^UNSUPPORTED: (.*)$} $results -> reason] } { diff --git a/libctf/testsuite/libctf-lookup/big-struct-corruption.c b/libctf/testsuite/libctf-lookup/big-struct-corruption.c new file mode 100644 index 00000000000..2cc05be79cc --- /dev/null +++ b/libctf/testsuite/libctf-lookup/big-struct-corruption.c @@ -0,0 +1,118 @@ +/* Determine whether libctf/33339 is fixed, if and only if GCC PR 121411 is also + fixed. */ + +#include "config.h" +#include +#include +#include +#include + +/* Determine whether the passed-in struct's member's offsets ever descend. */ +static int +offsets_ascending (ctf_dict_t *fp, ctf_id_t type) +{ + ctf_next_t *it = NULL; + ssize_t offset, last_offset = 0; + + while ((offset = ctf_member_next (fp, type, &it, NULL, NULL, 0)) >= 0) + { + if (offset < last_offset) + return 0; + last_offset = offset; + } + if (ctf_errno (fp) != ECTF_NEXT_END) + { + fprintf (stderr, "Cannot check member offsets: %s\n", + ctf_errmsg (ctf_errno (fp))); + exit (0); + } + + return 1; +} + +int +main (int argc, char *argv[]) +{ + ctf_archive_t *ctf; + ctf_dict_t *fp; + ctf_id_t type; + int err; + + if (argc != 3) + { + fprintf (stderr, "Syntax: %s PROGRAM OBJ\n", argv[0]); + exit(1); + } + + /* Check for bugginess of compiler. */ + + if ((ctf = ctf_open (argv[2], NULL, &err)) == NULL) + { + fprintf (stderr, "Cannot open compiler object file %s: %s\n", + argv[2], ctf_errmsg (err)); + exit (1); + } + + /* Verify that offsets only ascend. */ + + if ((fp = ctf_arc_lookup_symbol_name (ctf, "huge_used", &type, &err)) == NULL) + { + fprintf (stderr, "UNSUPPORTED: compiler does not provide expected symbol.\n"); + exit (0); + } + + if (!offsets_ascending (fp, type)) + { + fprintf (stderr, "UNSUPPORTED: GCC bug PR121411 detected.\n"); + exit (0); + } + + ctf_dict_close (fp); + ctf_close (ctf); + + /* Check if test is disabled (e.g. on 32-bit). */ + + if ((ctf = ctf_open (argv[1], NULL, &err)) == NULL) + { + fprintf (stderr, "Cannot open linked binary test file %s: %s\n", + argv[1], ctf_errmsg (err)); + exit (1); + } + + if ((fp = ctf_arc_lookup_symbol_name (ctf, "test_disabled", &type, &err)) != NULL) + { + fprintf (stderr, "UNSUPPORTED: test not necessary on 32-bit targets.\n"); + exit (0); + } + + if ((fp = ctf_arc_lookup_symbol_name (ctf, "big_used", &type, &err)) == NULL) + { + fprintf (stderr, "big struct symbol not found.\n"); + exit (1); + } + + if (!offsets_ascending (fp, type)) + { + fprintf (stderr, "large struct offsets incorrect.\n"); + exit (1); + } + ctf_dict_close (fp); + + if ((fp = ctf_arc_lookup_symbol_name (ctf, "huge_used", &type, &err)) == NULL) + { + fprintf (stderr, "huge struct symbol not found.\n"); + exit (1); + } + + if (!offsets_ascending (fp, type)) + { + fprintf (stderr, "huge struct offsets incorrect.\n"); + exit (1); + } + + ctf_dict_close (fp); + ctf_close (ctf); + + fprintf (stderr, "Large and huge structs working fine.\n"); + exit (0); +} diff --git a/libctf/testsuite/libctf-lookup/big-struct-corruption.lk b/libctf/testsuite/libctf-lookup/big-struct-corruption.lk new file mode 100644 index 00000000000..980cb0bcecc --- /dev/null +++ b/libctf/testsuite/libctf-lookup/big-struct-corruption.lk @@ -0,0 +1,3 @@ +# source: big-struct-ctf.c +# link: objects +Large and huge structs working fine. diff --git a/libctf/testsuite/libctf-lookup/big-struct-ctf.c b/libctf/testsuite/libctf-lookup/big-struct-ctf.c new file mode 100644 index 00000000000..fc99a3e5878 --- /dev/null +++ b/libctf/testsuite/libctf-lookup/big-struct-ctf.c @@ -0,0 +1,72 @@ +#if defined (__SIZEOF_PTRDIFF_T__) && __SIZEOF_PTRDIFF_T__ > 4 + +#define CONCAT_(a,b) a ## b +#define CONCAT(a,b) CONCAT_(a, b) +#define COUNT(name) CONCAT(name, __COUNTER__) +#define MEMBNAME const char COUNT(memb)[1024 * 1024] +#define MEMB10 \ + MEMBNAME; \ + MEMBNAME; \ + MEMBNAME; \ + MEMBNAME; \ + MEMBNAME; \ + MEMBNAME; \ + MEMBNAME; \ + MEMBNAME; \ + MEMBNAME; \ + MEMBNAME; + +#define MEMB100 \ + MEMB10 \ + MEMB10 \ + MEMB10 \ + MEMB10 \ + MEMB10 \ + MEMB10 \ + MEMB10 \ + MEMB10 \ + MEMB10 \ + MEMB10 + +#define MEMB1000 \ + MEMB100 \ + MEMB100 \ + MEMB100 \ + MEMB100 \ + MEMB100 \ + MEMB100 \ + MEMB100 \ + MEMB100 \ + MEMB100 \ + MEMB100 + +#define MEMB10000 \ + MEMB1000 \ + MEMB1000 \ + MEMB1000 \ + MEMB1000 \ + MEMB1000 \ + MEMB1000 \ + MEMB1000 \ + MEMB1000 \ + MEMB1000 \ + MEMB1000 + +struct big +{ + MEMB1000; +}; + +struct huge +{ + MEMB10000; +}; + +struct big big_used; +struct huge huge_used; + +#else + +int test_disabled; + +#endif From patchwork Wed Sep 24 15:00:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 120808 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 7D049385840F for ; Wed, 24 Sep 2025 15:00:59 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 0376D3858D29 for ; Wed, 24 Sep 2025 15:00:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0376D3858D29 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0376D3858D29 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1758726023; cv=pass; b=l4ZD7Ud48GCKKRM0ZboTaXpYRKAk7T/ydUmgJJ/lALkIxzIhYxl+Zng6nLpQ/ZUTHJt8MlhyzSmMdoBmkVGuEdD9djWdXNisL7ikDvYrVua6+cpxGN4rmA4xgSP73t7K0iw/8Otit3mtSVXnUyArlbrqiyLp7M8nNsDlh+OMeGU= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1758726023; c=relaxed/simple; bh=br6mZcZ1GcDar9VRbKFQor3nNLUBXYJiYNZ2i9g5nb8=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=SGVR+6CxcFW0y64EcqhRPzX1pNgFHv98VdpMArRvRWkqI2MIMRvQq8LgeOBoLyTxBKK9rhE7YAZxd44OvvO/rPlH5JoIXnvsHot7IbRNVSPHpEQZU2noKDdqz8dYC3/Ck952wF7xWWTNN/7qeh2N1+mpBmSmwvHKzaHty3Aqt+M= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58OEtlJa016490 for ; Wed, 24 Sep 2025 15:00:22 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 499k23fyvx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 24 Sep 2025 15:00:22 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 58OE7NMG036472 for ; Wed, 24 Sep 2025 15:00:21 GMT Received: from ph7pr06cu001.outbound.protection.outlook.com (mail-westus3azon11010031.outbound.protection.outlook.com [52.101.201.31]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 499jq9qfwa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 24 Sep 2025 15:00:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NKBz/C9FjvJMeEjZzdNUI0ac/TmUlQoVdZq3BcwaBwNEZp/GrUXSC3LCifXuKHZzjD06OBUXXTVN1pDaY835/URqTD7d7KkjJ8MNS7MLnMnwgHo8PlH0TPMWxKDy+5TQtophKKrvVR4kz7FP2Gy+q045PRG3/Q8IqKuMcJTUwUOoY2iZU28Av6GMhPKR5I9CwqeSuS2zrO9nyn8gAfR/T7O/h+TEDG12i2F0O5WabhhmCFku+g5Z1HwPKMPfnvelWOBYXShRhRLvKUnWPbFhtfd39E/68tGg225+leOfepaNXZzUDqfFUKOYeiPHsP62XZvIkEIoJ8XpuWNWDOwmCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gKDlBh4GiqKP03JALoD4jPFHu+89kT/u0WaBLJQuqfI=; b=lVmOwdBTrqw5u4k3ouvXNe8fQ3y8ARESgb0sh+DmZiXPjGDXv6gd3Ft5jdTIiZw45fm/RzDBjXVC+JST/b+cidlICAQxgcugNQdVoIXoeyaGEy2y0CvP/j4KoL2f7Owh42q/SPqUeo6AsakGOGrft75tf/O/3QFD33N8BtotGiRprKEoBvix9rD25hhSq8yfTiYLA5pz+Jv+aBrgrO2L1wpsGwSAdjFXHmx4xPVC1qO5bKjylN51OC9BbgVZ2paSGtPHzIr9qc80QQjqqmXX4SiRiDNc6w3eofAq+8nXa64KWtRfZlFdQ1w8tdj0DDzcHKxMK3NgNd18ZM/UVZk/rw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from PH3PPFA3184E4F2.namprd10.prod.outlook.com (2603:10b6:518:1::7bb) by BLAPR10MB5153.namprd10.prod.outlook.com (2603:10b6:208:330::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9160.9; Wed, 24 Sep 2025 15:00:18 +0000 Received: from PH3PPFA3184E4F2.namprd10.prod.outlook.com ([fe80::815c:d94d:29c8:ecb3]) by PH3PPFA3184E4F2.namprd10.prod.outlook.com ([fe80::815c:d94d:29c8:ecb3%8]) with mapi id 15.20.9137.018; Wed, 24 Sep 2025 15:00:17 +0000 To: binutils@sourceware.org Cc: Bruce McCulloch Subject: [PATCH 2/2] libctf: dump CTF array dimensions in the right order Date: Wed, 24 Sep 2025 16:00:08 +0100 Message-ID: <20250924150008.46198-2-nick.alcock@oracle.com> X-Mailer: git-send-email 2.51.0.284.g117bcb8de7 In-Reply-To: <20250924150008.46198-1-nick.alcock@oracle.com> References: <20250924150008.46198-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO2P265CA0113.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::29) To PH3PPFA3184E4F2.namprd10.prod.outlook.com (2603:10b6:518:1::7bb) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH3PPFA3184E4F2:EE_|BLAPR10MB5153:EE_ X-MS-Office365-Filtering-Correlation-Id: de027e30-9ca3-40e6-5100-08ddfb7b12dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: hc6+hgElewL805iogcSu3AhitY6XcUIQv7s9tIUwE8NTaW9p/OkXqyaF9FNKejdKisdjyw6AhdF0afCu5Pz/ZUJJP+9WaKwJPl4Nvjj1t/Vva2M2rCH3CIRJ61EYE7Tq8TOEHCqYi25N0ycz4V+cmomLfJ7HI+IMPXE/kLwAIgzXkiQXN5L+0awy0O6gi0J/Z5mCNm1M78+D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QKUjCAOG0o5RM/c4O7kDHn3pPAKTxz4heowfAk/LaaSzrdbphEtzXGHkq3LpBZWlVUTmr2AD7U50ztqekW7XSNUcqWqcNOes8inOk1P28GzsaztiRuLq59abcwSdJhFvbr2335AUPtCaMYZWmJK9Z4vxdEv6Fs45G4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH3PPFA3184E4F2.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fzFZByP/PdYxtY+fBdfcjA50rh4F7RrpZzUmudYt323BCcY6WrxskHivr1qPvK0WTlfFmKzQVz4CQX72Ax2Fg9yJWzGKZQtHFTj+1ZD6n2XrlkG4XU4eiXbPYWz89zrgeJVVR37Pp8KSuJN40u/QuzqHm91GtPXLaMkFQFNSs3A0uKtNGapjuF86lQTFXC8x3G0I07mAwELRoNMzj6PJDUnX1bA0wrke/gxYGcvF/Jnk9AQ/o2EBRhT4Wnts16NOG8ZXAG9biWYz35WjyYw5QjDrZrmo3f4D0HZnlBWit5jxhAgsmMVQjR/fBCiZ/rijWMfVOGW1O7M0+BNaKKMewP5eqag/9Rf4TULEUhXdmVJdbtJ36mdxwyyby4VZ3bYYnHUZtL0C+eQdHYo9AD4sU8lbnddchSyL6iy3EDPqeMzdw2bhd7mDdqsEnQ9EuYo0FA3wYw9SN4neRkxWNsLb640Tt44JQrEkSWi8KikEDsA7VziS2H5qqcMJMN1h0+akAcCmLF0dHnAkt1s/DRmKYK2CnEal3HRUMloC6/6pVOAec2fhVQ+kyFrHqJhahpdgw+2RY8v70E7Up49O3u9Iskx7Pk7Og+QhcQela4LB0RhVz4f6e7F2vpBurLQmCv3uMcRAvzI8mwYlZbwKOHnSaPAOq8YmM9Uj0W0mrqI/kbYBjRaDLwf/YxAT7kr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NL52ROBnJxFJ9WRC0cHv5B8lNM0F14vh5xIpkvnlEB6HYGxU7Xm8+MDPIWDQnbhCwLZKemLp4X0BYmL9BL+vZ3oAGVuOnf7y1A9TjKVg/l2GWJi4KYbpvPeDqc6TTTpuhrzu8k1w9NtTbkI3yQ8mRaQw6Om37dSuB8DpPzhWF2jMihp+mM2ZzwPlQLgM/62apo0AAKKLnlMJKMQtR9IdvRWtoXrqQA57UzYCcCz8UFCFkNIjWJSyTd7gIcoo7UOLRQdeSX4y30xq9hPCOktd4/GHwwD/X9vnJYXPc9fVllu3P7hHouvGgKRdVaMxRGsf7AiyjYymyJXCas0qwpj8+6K2jcXPh7HVu3KkbgKEj7CJ74GZJAYp9lW4L+vXnAXXHD5xShGVbG0p5uzTdlRPHrJ99AqjTE1egM+obM9OHfkh9gMf7Jew6RNoK1eKOyZYXgE1hxzJbAVL9uD5PXuHDM0e9dEkdfPcyQoxCwHZD08/7iXkE9OO+BvidlrNKJj4gvhLAsjdu1wtw/IudZlyiv6Exa+1xg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: de027e30-9ca3-40e6-5100-08ddfb7b12dc X-MS-Exchange-CrossTenant-AuthSource: PH3PPFA3184E4F2.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2025 15:00:17.8941 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RUOF/ypsiIh6pMny9bzgQ2eFyL+xhsiiv7bSObVAqLbmsdz8ljDfZGnj7an2LvgLDg8CwfKlJxFy1+6gCoLe2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5153 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-24_03,2025-09-22_05,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2509240129 X-Authority-Analysis: v=2.4 cv=C5XpyRP+ c=1 sm=1 tr=0 ts=68d40786 cx=c_pps a=XiAAW1AwiKB2Y8Wsi+sD2Q==:117 a=XiAAW1AwiKB2Y8Wsi+sD2Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=z/mQ4Ysz8XfWz/Q5cLBRGdckG28=:19 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=yJojWOMRYYMA:10 a=GoEa3M9JfhUA:10 a=yPCof4ZbAAAA:8 a=-f-V-VsWp_CXL56kxs4A:9 X-Proofpoint-GUID: Bhy31LfH50nzbAE4YTJiKtji3-W2KL_3 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTIwMDAxNiBTYWx0ZWRfX9UZ0kvEcsTy7 YWqjl1PM8tdA0dl+lganBqfRGDuZnHI7Ahw0/esKs7Rekwx3ZBXAMeKgvvDP/sV/ZpcmMjctajk XHrPLoTnHzqhWk/Y5kIZrM/+RiAzVKUtSGfuRnY6IoU7XsYMkRzN+8TuttYUNBX0/ZKYVg8WIDO A6q+0ahILyOh71MQ7ErcvlhvH/0/PajGDu8N4QFOmKtTs7FTPUSxankoDkP06kgxpIMKJM/6Zt/ 7UWSl8YlRSCekXTWYfDSXmwtbKXzS2/XFJoJ34f8j4Tc/JaHkq814zH9IkqKLOaLa6LysE+TVzS kbNxBhOxWwzptmI3oK+GiCsmRLJ7qWIwHCh7m16Imrq5p7hHAm4NML3OOCwY2cCuGVUBxG/BfKf 7JAQn7oT X-Proofpoint-ORIG-GUID: Bhy31LfH50nzbAE4YTJiKtji3-W2KL_3 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE, SPF_NONE, 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Nick Alcock via Binutils From: Nick Alcock Reply-To: Nick Alcock Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org From: Bruce McCulloch Before GCC PR114186, all looked good in the land of multidimensional arrays: you wrote int a[5][10]; and ctf_type_aname() et al would print it as int [5][10] Unfortunately this was two bugs in one. GCC was emitting the array as if it were int a[10][5], i.e. as this: a -> [10] -> [5] -> int rather than a -> [5] -> [10] -> int as it should be. libctf was hiding this by printing them in the wrong order, concealing the bug from anyone using objdump --ctf or anything but actual type graph traversal. Once this was fixed for GCC, the bug was visible in libctf: multidimensional arrays were printed backwards! (But this is just a print-time bug: the underlying bug, that something traversing the type graph would see the array in backwards order, was fixed by the fix to GCC.) Fix this libctf bug, printing the arrays the right way round. In a possibly futile attempt to retain some vestige of backwards compatibility, introduce a new bug-compat flag CTF_F_ARRNELEMS, which, if on, indicates that PR114186 is fixed and GCC is emitting array elements the right way round. (Unfortunately, the fix went in without this flag, so some GCCs will still emit CTF that will cause libctf to print them wrong, even with this fix -- but it's no wronger than it was before, and new GCC and new binutils, as well as GCC older than any fix for PR114186 and new binutils, will print things properly. Someone traversing the type graph will see things right after the GCC fix, wrong before it, and there isn't really any reliable way to tell which you have, though if CTF_F_ARRNELEMS is set, you definitely have a fixed GCC. The test checks for this, but it's not something we expect actual users to ever do -- CTF dict flags are an internal implementation detail with no user-visible API for a reason.) [nca: log message, test compat with older compilers] include/ * ctf.h (CTF_F_ARRNELEMS): New bug-compat flag. (CTF_F_MAX): Adjust. libctf/ PR libctf/32161 * ctf-decl.c (ctf_decl_push): Prepend if this is an array and the bug-compat flag is set. * ctf-dump.c (ctf_dump_header): Dump the new bug-compat flag. * testsuite/libctf-lookup/multidim-array*: New test. --- include/ctf.h | 3 +- libctf/ctf-decl.c | 7 +- libctf/ctf-dump.c | 8 ++- .../libctf-lookup/multidim-array-ctf.c | 3 + .../testsuite/libctf-lookup/multidim-array.c | 71 +++++++++++++++++++ .../testsuite/libctf-lookup/multidim-array.lk | 9 +++ 6 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 libctf/testsuite/libctf-lookup/multidim-array-ctf.c create mode 100644 libctf/testsuite/libctf-lookup/multidim-array.c create mode 100644 libctf/testsuite/libctf-lookup/multidim-array.lk diff --git a/include/ctf.h b/include/ctf.h index 72a639ac9b4..819003ed911 100644 --- a/include/ctf.h +++ b/include/ctf.h @@ -213,8 +213,9 @@ typedef struct ctf_header #define CTF_F_NEWFUNCINFO 0x2 /* New v3 func info section format. */ #define CTF_F_IDXSORTED 0x4 /* Index sections already sorted. */ #define CTF_F_DYNSTR 0x8 /* Strings come from .dynstr. */ +#define CTF_F_ARRNELEMS 0x10 /* Array elems no longer reversed. */ #define CTF_F_MAX (CTF_F_COMPRESS | CTF_F_NEWFUNCINFO | CTF_F_IDXSORTED \ - | CTF_F_DYNSTR) + | CTF_F_DYNSTR | CTF_F_ARRNELEMS) typedef struct ctf_lblent { diff --git a/libctf/ctf-decl.c b/libctf/ctf-decl.c index 9e11913da86..e5331b4e5d9 100644 --- a/libctf/ctf-decl.c +++ b/libctf/ctf-decl.c @@ -154,9 +154,12 @@ ctf_decl_push (ctf_decl_t *cd, ctf_dict_t *fp, ctf_id_t type) cd->cd_qualp = prec; /* By convention qualifiers of base types precede the type specifier (e.g. - const int vs. int const) even though the two forms are equivalent. */ + const int vs. int const) even though the two forms are equivalent. + As of gcc-14.2.0, arrays must also be prepended in order to dump with the + dimensions properly ordered. */ - if (is_qual && prec == CTF_PREC_BASE) + if ((is_qual && prec == CTF_PREC_BASE) || ((kind == CTF_K_ARRAY) && + (fp->ctf_openflags & (CTF_F_ARRNELEMS)))) ctf_list_prepend (&cd->cd_nodes[prec], cdp); else ctf_list_append (&cd->cd_nodes[prec], cdp); diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c index 54febd644cd..57fbd64b530 100644 --- a/libctf/ctf-dump.c +++ b/libctf/ctf-dump.c @@ -326,7 +326,7 @@ ctf_dump_header (ctf_dict_t *fp, ctf_dump_state_t *state) if (fp->ctf_openflags > 0) { - if (asprintf (&flagstr, "%s%s%s%s%s%s%s", + if (asprintf (&flagstr, "%s%s%s%s%s%s%s%s%s", fp->ctf_openflags & CTF_F_COMPRESS ? "CTF_F_COMPRESS": "", (fp->ctf_openflags & CTF_F_COMPRESS) @@ -343,6 +343,12 @@ ctf_dump_header (ctf_dict_t *fp, ctf_dump_state_t *state) && (fp->ctf_openflags & ~(CTF_F_COMPRESS | CTF_F_NEWFUNCINFO | CTF_F_IDXSORTED)) ? ", " : "", + fp->ctf_openflags & CTF_F_ARRNELEMS + ? "CTF_F_ARRNELEMS" : "", + fp->ctf_openflags & (CTF_F_ARRNELEMS) + && (fp->ctf_openflags & ~(CTF_F_COMPRESS | CTF_F_NEWFUNCINFO + | CTF_F_IDXSORTED | CTF_F_ARRNELEMS)) + ? ", " : "", fp->ctf_openflags & CTF_F_DYNSTR ? "CTF_F_DYNSTR" : "") < 0) goto err; diff --git a/libctf/testsuite/libctf-lookup/multidim-array-ctf.c b/libctf/testsuite/libctf-lookup/multidim-array-ctf.c new file mode 100644 index 00000000000..05b6ebe4fdd --- /dev/null +++ b/libctf/testsuite/libctf-lookup/multidim-array-ctf.c @@ -0,0 +1,3 @@ +int a[3][5][9]; +int b[1][2]; + diff --git a/libctf/testsuite/libctf-lookup/multidim-array.c b/libctf/testsuite/libctf-lookup/multidim-array.c new file mode 100644 index 00000000000..2a86f2636c2 --- /dev/null +++ b/libctf/testsuite/libctf-lookup/multidim-array.c @@ -0,0 +1,71 @@ +#include +#include +#include +#include + +int +main (int argc, char *argv[]) +{ + ctf_archive_t *ctf; + ctf_dict_t *fp; + int err; + ctf_dump_state_t *dump_state = NULL; + char *dumpstr; + ctf_next_t *it = NULL; + ctf_id_t type; + int flagged = 0; + + if ((ctf = ctf_open (argv[1], NULL, &err)) == NULL) + goto open_err; + if ((fp = ctf_dict_open (ctf, NULL, &err)) == NULL) + goto open_err; + + /* First, check for signs that the compiler is fixed but not emitting the + relevant flag yet. This combination is not expected to work right. */ + + while ((dumpstr = ctf_dump (fp, &dump_state, CTF_SECT_HEADER, + NULL, NULL)) != NULL) + { + if (strstr (dumpstr, "CTF_F_ARRNELEMS") != NULL) + flagged = 1; + free (dumpstr); + } + + if (!flagged) + { + ctf_arinfo_t ar; + + if ((type = ctf_lookup_by_symbol_name (fp, "a")) == CTF_ERR) + goto unexpected; + + if (ctf_array_info (fp, type, &ar) < 0) + goto unexpected; + + if (ar.ctr_nelems == 3) + { + fprintf (stderr, "UNSUPPORTED: compiler has GCC PR114186 fixed but " + "no indicative flag\n"); + return 0; + } + } + + /* Now check for the actual bug. */ + + while ((type = ctf_type_next (fp, &it, NULL, 1)) != -1) + printf ("%s\n", ctf_type_aname (fp, type)); + + ctf_dict_close (fp); + ctf_close (ctf); + + return 0; + + open_err: + fprintf (stderr, "%s: cannot open: %s\n", argv[0], ctf_errmsg (err)); + return 1; + + unexpected: + fprintf (stderr, "Cannot look up symbol to determine compiler bugginess: %s\n", + ctf_errmsg (ctf_errno (fp))); + return 1; +} + diff --git a/libctf/testsuite/libctf-lookup/multidim-array.lk b/libctf/testsuite/libctf-lookup/multidim-array.lk new file mode 100644 index 00000000000..41b3cd9f033 --- /dev/null +++ b/libctf/testsuite/libctf-lookup/multidim-array.lk @@ -0,0 +1,9 @@ +# source: multidim-array-ctf.c +int +(long )?unsigned int +int \[9\] +int \[5\]\[9\] +int \[3\]\[5\]\[9\] +int \[2\] +int \[1\]\[2\] +