From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 5D12C3858C00 for ; Mon, 11 Sep 2023 21:40:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D12C3858C00 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38BJqlE2028392 for ; Mon, 11 Sep 2023 21:40:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=message-id : date : subject : to : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2023-03-30; bh=Cj29NTNuQ4meqGNNVN01YJXO6/tm7ng4RFfIwz8pXOY=; b=2se7kXrqEKjJ35i9VaV3WjlwXOYU3OcwvXc/Cbo6Taqdt+2Tl8gPW9DTMTfDR7SYK1BB tzKt74L3qQUINDhWpy0ylBiV9zsjsj2fRIhNMNnMHkS0rv/4/5XqpgNykR/FWa1uyeV4 iZ5TGZKW3q4IJAlRtoWVH86hQEWFwf9izgoYf2kA7NjdpJXVmNpkxVTjDGV0dDANQcM3 +6tLVbiqfIbgqBqNXFsJTYRFryrAZ/fOr2bNX0K8nDfHZVBGVSxRfqfw8j7UBJgvuU4j 6pxy9NGZ0THK0dSeoHJ8AmHnmI4UGJnLIptk/+UXlEoPvzgHA//3bUFA5JXAvsB607wS Uw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t1jp7ahh0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 11 Sep 2023 21:40:05 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38BL0xdG002635 for ; Mon, 11 Sep 2023 21:40:05 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3t0f5b3377-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 11 Sep 2023 21:40:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nuWtGNlMXZZJTLourhRXIfZly+293c5dWoZV2meVQd2PSMhtUF6ETtYxmqsghDvTMVJWKFa9DSITTxCV5wtdmffIOgfoI2nCLCAh2jq+PKWxZYpi52ub67GScpm1biEyWUq+YqJzK6oK/2tX2sIozdV8DMNmqcStNEibfWYP2+oFLRC0g+slov5p/DJF45U7aAWIau/8dhS4ftJ7yoxPTHzCbcOsmBWJSkCOShgwpmxVWNvVXli+qbw3Z3KWOOhLwjT5ts+bVOmUnYFCRtqH3T9SzsUWadmiZtXpVWXbb542ks4i4cCBKoWMyO+wPmW84ItCH44h/zl7SPFNXlDN+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=Cj29NTNuQ4meqGNNVN01YJXO6/tm7ng4RFfIwz8pXOY=; b=gbXen1vyJ49Ryx4hNTAyQ3H3Q+mddmjWw+6dCohZkAZpAx/rl0EPpNRZ8r6yRR+j5wkBIpLV4S9TMavL7ZCRPSmggZ8urGt8Ja0M/TaS3h3Uh0EEX0NQp4MHQZa42eaDt7ubrtFYKsMerhhSwGmq3vvXIgO5SqSHF3vyTgHVxeMUHHA+4VPB3tYiDrNMpHNrobmLC1YfBWwiZxaA0cXIwClwbiF5slUUvaTAEnML2C8Z4DMCgva3FD5eLvaQsIRg0TDx/PvMup4H+vj1fjLBrTXZoGvDKvQMgnMbfeJBY1B3rPaTa5ZI32wtfA1KCf4bYoMdkxsBUfQ4N580BybK8Q== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cj29NTNuQ4meqGNNVN01YJXO6/tm7ng4RFfIwz8pXOY=; b=vYprvQkvDXxVLnj9Sp4VPmjg3thWtYCQY6cHiLLMhki/t8ryMemtrMTlAzrF87qFVlmkQYAnH/FbsVynhy3k9o7Gbq8jo1JFir6YIwR9yZdmE0WOZwbrW/4SuAxdxx0rNj7WeV+wk0zuMasHGlP5l1ju9XRten3pMCAxC0HAJTc= Received: from MN2PR10MB3213.namprd10.prod.outlook.com (2603:10b6:208:131::33) by SJ0PR10MB4670.namprd10.prod.outlook.com (2603:10b6:a03:2dc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35; Mon, 11 Sep 2023 21:39:57 +0000 Received: from MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::6269:77c6:e6b9:ac03]) by MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::6269:77c6:e6b9:ac03%7]) with mapi id 15.20.6768.029; Mon, 11 Sep 2023 21:39:57 +0000 Message-ID: <7dbe9fff-8f1b-8d1c-aef5-1ded8b3ab6ff@oracle.com> Date: Mon, 11 Sep 2023 14:39:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: [PING][PATCH 0/9] Add btf_decl_tag C attribute Content-Language: en-US To: gcc-patches@gcc.gnu.org References: <20230711215716.12980-1-david.faust@oracle.com> From: David Faust In-Reply-To: <20230711215716.12980-1-david.faust@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SJ0PR03CA0275.namprd03.prod.outlook.com (2603:10b6:a03:39e::10) To MN2PR10MB3213.namprd10.prod.outlook.com (2603:10b6:208:131::33) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB3213:EE_|SJ0PR10MB4670:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e34ed87-2e2f-4051-71d6-08dbb30fa4b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5Acl4s3a/lSar3dfdw3+uFnmWC3mZdj4Dzx6DMntbz37HISzJVFsBbcJpdnt1pnz5hhNiC2JUI+2/KUDT3DNkj/fnpd7KZ9C0wlS6RaIB4CMrzBFwSujDnCkIV28kFbv72lxfBMA/5oJeWeV6EFeJbZgjMMMDLgfy8ismgYyAhsVG90EcJcje/faKrt3LDjg9LIsu39xVP18vK8Gb/GPRMC7WFKLc9W042fCbIF0HWCiuA4k/bX+M85D/7Has5ALrmhZQEn5UkckHPdJQV5ASKgXBx4LNzKt1LxLj8qMHsE1R9Lqz3DPTFlFh8F9eFfNIIgkwbYjYlZAdwvtTZSB8PLeCnGuuhtKzkhMERdcc0kOehVbq0bSc1ba6NXzdog2UkfJNrmu1mtO1RALUwKvrYbzRTdj/+Zgkx+lb1EwJvIliBip0vDeD0z3bFlid/0+TOWAKV9D1XGeGoBCBl53k/dvcJcugYp+n/4D8JEr1HSDpsGmKMHS1HIl8gNBDzjeQvO0bemIY9Kr+1T9TWDNJ8T9QtJnOeRVVx6Jf4Hj+ntoGjseUsZv2od6OvySnDBspx+wxbNAKBLQYQDBCd+8QF+LxAe84hVfObYU5oVX4O0fiGSbQkvPez4QPO0JnoEpTG/2PDrJk0hdIr6cTwGdwqzTpjhLZdZb+RW5hcbuCq32FN3JUalP+PQBbjoRAGVL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR10MB3213.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(366004)(376002)(39860400002)(396003)(1800799009)(186009)(451199024)(6666004)(6506007)(53546011)(6486002)(83380400001)(2616005)(966005)(2906002)(6512007)(26005)(66476007)(44832011)(6916009)(66556008)(66946007)(478600001)(316002)(8676002)(5660300002)(8936002)(36756003)(86362001)(31696002)(38100700002)(31686004)(41300700001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?K2JyZjFhOHVUYjlESVpMRUxnbVJjemNIZ2RENkFZeFlTWWJ5Vk5TZXh3MlZP?= =?utf-8?B?bzExRXlOOXRQeFpzeFVPdVFEYlNFRnhLMjUxbytzK0lHZHdmODB1YU1YVHZw?= =?utf-8?B?U0tjVzM3VEhiNUtMQXcwZ3lqS0hsakZ2ekdDWTJLU2RNcmZPU08wY1h4cEVS?= =?utf-8?B?bmFsdVVCdW9CSUNtWVhYbUxmUlVKOGZpaUNYTGhiQVZwU3VIOU84ZmhVUXB6?= =?utf-8?B?SlZhbTAyMEtOaVF0T0E2SjEyM3VFSktWZGpFZlZKMmp1cklwZ2RjYURUNkVs?= =?utf-8?B?ckNPRldNanJuZXdoUWdScWYyVGpUd0NTUFRwZTZtNXgyM0Y1UHRzMVZHVk9J?= =?utf-8?B?b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MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: MagjuSAsSGZM0CkPLwSM9tTICGVECs95bedD0Y9UYaX1yNBDSlqVFWZkLnFnGUQ2yHs0U8FjMULsX4nmPW0CzhXdrKqxWCA04K+WBEFKDyDtQWCNVcb2ejfvOLfwkI2IufXggsxrw51iF/kwFBpQ2m9Gr0GNrm9uxcDxRWgUR+FTXj1irv+BbRZ5fOzzFRGZykcmBBIfcGc6auO137DCSSC9Q3uTg5qGgMgXHBfplnRYNFY8rJKByx0BHPLH5aOuqpXWHb9r+xEDL3KU+4+A9P/V7WOggknoowNde099K3aq8pKMfuqrA9sCWVCnDv6N0U7oakJrTaL4AQ2AphpJ3J5dDn+ajH3B6wll/VMPTj4JFVMTB1xcjRfFL6xzlwzUvY/spOICOSQ2X6iSK4Fyj3dDXqeZDFi9mzsFKum6bqYZWfvh5SC+N9X58JSOQbdjgScVX5vIdKL8tTqH3V8gn2UB+SKcr8q+H8XtAc4/ifS5gWPJ7QbLRMAD5HQMfExTTlbzzrgiAy3FKoYEMRCajBspK5cx+EySXVIaViF8B8EI8tDHAOfRP79iCCKk+AJt7NSzrsiQLpuNaFjj77gmU4vIaMpdVcjh7hQrE/X0LCBifEkfgqE2B0DDzZsSEQBBDMSrg8kyvNpBhDo0vN0DxnUe2vUsxERQNvb8iSl3AZKAzRNd8T2F4jlKcUvFccUmaGnUyzbO8xpU3cuRiCJAxG2oztJ+EH7cgzSgmsqXn9FjdUPdWiaqPuDo4uh3Xoep X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e34ed87-2e2f-4051-71d6-08dbb30fa4b5 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB3213.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2023 21:39:57.3327 (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: IxerClV4hVdTmUO01a0TG4HaoIzKPZkAXmbqzQfLckcCUPzbXPukGDGQoQa87N5OUHxki7cF8mHfMgg+toIjCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4670 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-11_17,2023-09-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309110200 X-Proofpoint-GUID: THNDJR2iiki3kjzuD2oE_scUvJ0ESWsp X-Proofpoint-ORIG-GUID: THNDJR2iiki3kjzuD2oE_scUvJ0ESWsp X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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 List-Id: Ping. This series adds a new C language attribute for recording additional information in DWARF and BTF, similar to an existing attribute in clang. https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624156.html There are components in c-family, dwarf, ctf and btf. Thanks. On 7/11/23 14:57, David Faust via Gcc-patches wrote: > Hello, > > This series adds support for a new attribute, "btf_decl_tag" in GCC. > The same attribute is already supported in clang, and is used by various > components of the BPF ecosystem. > > The purpose of the attribute is to allow to associate (to "tag") > declarations with arbitrary string annotations, which are emitted into > debugging information (DWARF and/or BTF) to facilitate post-compilation > analysis (the motivating use case being the Linux kernel BPF verifier). > Multiple tags are allowed on the same declaration. > > These strings are not interpreted by the compiler, and the attribute > itself has no effect on generated code, other than to produce additional > DWARF DIEs and/or BTF records conveying the annotations. > > This entails: > > - A new C-language-level attribute which allows to associate (to "tag") > particular declarations with arbitrary strings. > > - The conveyance of that information in DWARF in the form of a new DIE, > DW_TAG_GNU_annotation, with tag number (0x6000) and format matching > that of the DW_TAG_LLVM_annotation extension supported in LLVM for > the same purpose. These DIEs are already supported by BPF tooling, > such as pahole. > > - The conveyance of that information in BTF debug info in the form of > BTF_KIND_DECL_TAG records. These records are already supported by > LLVM and other tools in the eBPF ecosystem, such as the Linux kernel > eBPF verifier. > > > Background > ========== > > The purpose of these tags is to convey additional semantic information > to post-compilation consumers, in particular the Linux kernel eBPF > verifier. The verifier can make use of that information while analyzing > a BPF program to aid in determining whether to allow or reject the > program to be run. More background on these tags can be found in the > early support for them in the kernel here [1] and [2]. > > The "btf_decl_tag" attribute is half the story; the other half is a > sibling attribute "btf_type_tag" which serves the same purpose but > applies to types. Support for btf_type_tag will come in a separate > patch series, since it is impaced by GCC bug 110439 which needs to be > addressed first. > > I submitted an initial version of this work (including btf_type_tag) > last spring [3], however at the time there were some open questions > about the behavior of the btf_type_tag attribute and issues with its > implementation. Since then we have clarified these details and agreed > to solutions with the BPF community and LLVM BPF folks. > > The main motivation for emitting the tags in DWARF is that the Linux > kernel generates its BTF information via pahole, using DWARF as a source: > > +--------+ BTF BTF +----------+ > | pahole |-------> vmlinux.btf ------->| verifier | > +--------+ +----------+ > ^ ^ > | | > DWARF | BTF | > | | > vmlinux +-------------+ > module1.ko | BPF program | > module2.ko +-------------+ > ... > > This is because: > > a) pahole adds additional kernel-specific information into the > produced BTF based on additional analysis of kernel objects. > > b) Unlike GCC, LLVM will only generate BTF for BPF programs. > > b) GCC can generate BTF for whatever target with -gbtf, but there is no > support for linking/deduplicating BTF in the linker. > > In the scenario above, the verifier needs access to the pointer tags of > both the kernel types/declarations (conveyed in the DWARF and translated > to BTF by pahole) and those of the BPF program (available directly in BTF). > > > DWARF Representation > ==================== > > As noted above, btf_decl_tag is represented in DWARF via a new DIE > DW_TAG_GNU_annotation, with identical format to the LLVM DWARF > extension DW_TAG_LLVM_annotation serving the same purpose. The DIE has > the following format: > > DW_TAG_GNU_annotation (0x6000) > DW_AT_name: "btf_decl_tag" > DW_AT_const_value: > > These DIEs are placed in the DWARF tree as children of the DIE for the > appropriate declaration, and one such DIE is created for each occurrence > of the btf_decl_tag attribute on a declaration. > > For example: > > const int * c __attribute__((btf_decl_tag ("__c"), btf_decl_tag ("devicemem"))); > > This declaration produces the following DWARF: > > <1><1e>: Abbrev Number: 2 (DW_TAG_variable) > <1f> DW_AT_name : c > <24> DW_AT_type : <0x49> > ... > <2><36>: Abbrev Number: 3 (User TAG value: 0x6000) > <37> DW_AT_name : (indirect string, offset: 0x4c): btf_decl_tag > <3b> DW_AT_const_value : (indirect string, offset: 0): devicemem > <2><3f>: Abbrev Number: 4 (User TAG value: 0x6000) > <40> DW_AT_name : (indirect string, offset: 0x4c): btf_decl_tag > <44> DW_AT_const_value : __c > <2><48>: Abbrev Number: 0 > <1><49>: Abbrev Number: 5 (DW_TAG_pointer_type) > ... > > The DIEs for btf_decl_tag are placed as children of the DIE for > variable "c". > > BTF Representation > ================== > > In BTF, BTF_KIND_DECL_TAG records convey the annotations. These records refer > to the annotated object by BTF type ID, as well as a component index which is > used for btf_decl_tags placed on struct/union members or function arguments. > > For example, the BTF for the above declaration is: > > [1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED > [2] CONST '(anon)' type_id=1 > [3] PTR '(anon)' type_id=2 > [4] DECL_TAG '__c' type_id=6 component_idx=-1 > [5] DECL_TAG 'devicemem' type_id=6 component_idx=-1 > [6] VAR 'c' type_id=3, linkage=global > ... > > The BTF format is documented here [4]. > > > References > ========== > > [1] https://lore.kernel.org/bpf/20210914223004.244411-1-yhs@fb.com/ > [2] https://lore.kernel.org/bpf/20211011040608.3031468-1-yhs@fb.com/ > [3] https://gcc.gnu.org/pipermail/gcc-patches/2022-May/593936.html > [4] https://www.kernel.org/doc/Documentation/bpf/btf.rst > > > David Faust (9): > c-family: add btf_decl_tag attribute > include: add BTF decl tag defines > dwarf: create annotation DIEs for decl tags > dwarf: expose get_die_parent > ctf: add support to pass through BTF tags > dwarf2ctf: convert annotation DIEs to CTF types > btf: create and output BTF_KIND_DECL_TAG types > testsuite: add tests for BTF decl tags > doc: document btf_decl_tag attribute > > gcc/btfout.cc | 81 ++++++++++++++++++- > gcc/c-family/c-attribs.cc | 23 ++++++ > gcc/ctf-int.h | 28 +++++++ > gcc/ctfc.cc | 10 ++- > gcc/ctfc.h | 17 +++- > gcc/doc/extend.texi | 47 +++++++++++ > gcc/dwarf2ctf.cc | 73 ++++++++++++++++- > gcc/dwarf2out.cc | 37 ++++++++- > gcc/dwarf2out.h | 1 + > .../gcc.dg/debug/btf/btf-decltag-func.c | 21 +++++ > .../gcc.dg/debug/btf/btf-decltag-sou.c | 33 ++++++++ > .../gcc.dg/debug/btf/btf-decltag-var.c | 19 +++++ > .../gcc.dg/debug/dwarf2/annotation-decl-1.c | 9 +++ > .../gcc.dg/debug/dwarf2/annotation-decl-2.c | 18 +++++ > .../gcc.dg/debug/dwarf2/annotation-decl-3.c | 17 ++++ > include/btf.h | 14 +++- > include/dwarf2.def | 4 + > 17 files changed, 437 insertions(+), 15 deletions(-) > create mode 100644 gcc/ctf-int.h > create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-decltag-func.c > create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-decltag-sou.c > create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-decltag-var.c > create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-1.c > create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-2.c > create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-3.c >