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 5EEAA3858D20 for ; Wed, 9 Aug 2023 21:05:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5EEAA3858D20 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 379IiKKg004124; Wed, 9 Aug 2023 21:05:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2023-03-30; bh=A7iovjcCBwOtETcMdcM/hB/6p4Hc7xfiFmTQN1ShKus=; b=b1AAYWZJnxVPgcIVqVqwfzK271997B19sbNh6NP48Mpb4tMC4LSrNPBVr1T9ascp5I21 xwBfBP10OFEvp7eMDQnsr73VT0oFixelRThCQTV9LvjHCmwMx3lIGkVlh/y+Tkjyx7Ib eLT19f3EIRT810sKq0giysYrnIIv48pCOgDJ2SZAsutX3eOiPYb5t/ObYJoz3vNj08pB b7bHDHiG0ovC34vDujBNrbFydHpjYy+nfJOErYn0KYSN7wvOjG2fAM62YXJl3qzQGFMD T8aCNUaNceNzq1a9SVoEgpKqVUbkMRR/VguYqgoj8n21SjjjdxeyRAMWX0cT2ZdbgZ0F AA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s9e1u9rpf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Aug 2023 21:05:47 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 379JMfOo017186; Wed, 9 Aug 2023 21:05:47 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s9cv83vj4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Aug 2023 21:05:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KtFI94insRBu4x4Lny4iUFClM3PC4IRh/6vbCfW7Ib5tWwBeuWWqjO6WM8ufFlUrgAuHZs8yWHWqVZ3H2gAu6w176F5SZZaOL3lKAGP+E4WOybV9Ttjkn46mxsojnB4g4rqmP3NwcJARW+K1CWgBMr6pGtNLvDxlQMzUn9q59yO1/prbtCDleox3ujOjQX+K4EKL3LoWeTLZyY6n+4EYzDXbsjTYHJFKkXvGizLdMo7RMMUPJa3pGC5N45/TyCGZ13w7c5SKhIKemnJ9vdV/3FE68qAVUP2fCs/h7NHOQ8lx/VyUvaJOzuDW/iyHhK7WXfCUEpaLuh4SmH8WW54iXA== 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=A7iovjcCBwOtETcMdcM/hB/6p4Hc7xfiFmTQN1ShKus=; b=e0GZkqvY8IW7pt7CFtqXpz6wd8oWfvBJj7j5s5KrRA/lV1jYVVyoy2EBWaCkA6o2OqgMoW3ul630Iha+6ZhJ6VFRdFbUiE6x2ejAefRx/obk1LOyOrugXb44KQ8v8FigE9nZqh/ygyxFg5oefIEmWHoVU2IOLqmMMY22kvW3Ih3dXPD0NnGIcKOWaPhcuOisPeeByK3vAtaFcu5S1zNDBy/bCfS5z9oG5igfFcUpPeB8+HbUHQTSH/rr1w342mNSqB8/xMlnjGQvJYtHvXTu1S/AL99+zqStbkHC74rPqpmGMUVnafqOuXqPsUWlGcTNcTHtwi0KYgq5E36y5af4dw== 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=A7iovjcCBwOtETcMdcM/hB/6p4Hc7xfiFmTQN1ShKus=; b=EhyHV2W833Zp2naYiV4Lz0Np2cOVEz8zSu7GEGZX7hQZ9/Y92pRJ3HRnhVwb+8ZimF4Wxofrj0x+w6yFhNtLgfdDUIpsRZqVJyxVgvKrQZB6M1QW9yeWXql9oyyE+bCgieL9rNDEh1wxXSR8FHzHhhwojlSXujPI8AECrVfRSXE= Received: from BYAPR10MB3206.namprd10.prod.outlook.com (2603:10b6:a03:155::20) by DS7PR10MB4861.namprd10.prod.outlook.com (2603:10b6:5:3a7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.29; Wed, 9 Aug 2023 21:05:44 +0000 Received: from BYAPR10MB3206.namprd10.prod.outlook.com ([fe80::66ca:16e:6597:2869]) by BYAPR10MB3206.namprd10.prod.outlook.com ([fe80::66ca:16e:6597:2869%6]) with mapi id 15.20.6652.028; Wed, 9 Aug 2023 21:05:44 +0000 Message-ID: Date: Wed, 9 Aug 2023 14:05:41 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: [PING 2][PATCH 0/9] Add btf_decl_tag C attribute To: gcc-patches@gcc.gnu.org Cc: jose.marchesi@oracle.com, yhs@meta.com References: <20230711215716.12980-1-david.faust@oracle.com> Content-Language: en-US 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: SN7PR04CA0038.namprd04.prod.outlook.com (2603:10b6:806:120::13) To BYAPR10MB3206.namprd10.prod.outlook.com (2603:10b6:a03:155::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3206:EE_|DS7PR10MB4861:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ce4bcf1-ccdc-4240-c99d-08db991c657c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V+RBIN6NDokoIVC0HG00mOatHosJ6t82+AlYeyxJ4e+YBnCY4GeFQxKeJcgGx/jQ1aCHk7sgbdYvXaYjarirDSHTBHR8xEgwWvAkimoNsrsnVz4p9kH+2Og6e3KCaF23pQxk5LpS+ra7tEd0wJgHtC6b35MzGJqk0724MSUvROBIsUkWNhI89lZ/Fl25lf4Cl0DlgLHXBEriZ2h9rDdGsYp82gIsLS/eQGqXTw9SBPMLcqWS450C2dpARsZY6kxDIhEceT4MEbgAYs13f3IqGBcto1X4UbWhmS7c/WDOfom6UmYwqwQCKmnDw0H80PTRTFzOyupHKKT1oOC0xIZXhNWPVxIYjgVr3QwukzL3bS677VakHah5YhtJFjJj8uFMCHLqG/kaCSkgN+9foavZz6ooHCJF/ueko8E4N34b4IrFN7cyhB6kJJMgJnUxAtdZTynwx+CgR1yonfUOBPmzia0YCpO0wlB9b6zDQqGbtJogxonIuW5yf5N/kpNUBsd83W9hs0XJEygYdPIdXqNMI8bPxSxy1HEIYw/kqtZpm49SXam7WdTuqbY1jhu+Ye1QOQegjJeJ8fM3NJwZHluvUOVTI3ld/4Gv48JBRJVi91EmSt9oGiujzgUDsBAbVuZuDAz2i6O6PnJ+kiggQ4rkNvEO22qCLyPc+yRnW3WDB+iOcUz+ynPXSGVyNZg4D7qP X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3206.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(396003)(376002)(136003)(39860400002)(366004)(451199021)(186006)(1800799006)(38100700002)(6506007)(6916009)(53546011)(2616005)(36756003)(83380400001)(2906002)(44832011)(5660300002)(478600001)(31696002)(86362001)(966005)(6512007)(6486002)(41300700001)(6666004)(8676002)(4326008)(66946007)(66476007)(316002)(8936002)(66556008)(31686004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SXlYTFBSNUhER1kyWWhyQzdmWmtUbnhoaG9kUWVnNWdhNUJzS1pkZzNwaHVn?= =?utf-8?B?NzRDS3U3ZEV3S0EyN3ZoVjAvemlvNzNzWVNCOW5icm5XdzdjakM4M2JHSmZD?= =?utf-8?B?Y2krdDNQdWZzSk5jRTBVd1NlUFFGbm51WUNKekhMaDJQTGMrLzdramdJL3VN?= =?utf-8?B?UWYzcnZla29xNHZ4YkRwSzN2SWJwS1lVQWg4L2FROVdvdStxdk1idDNNTEdr?= =?utf-8?B?dS9QVU9rR1Z4clVVbTNrdk9rdE1DSTlteFVuUHhhY0RFZ2ZWdllxT1U0Ujg5?= =?utf-8?B?VkFWV090STNTNEFCUVBMS0VIU1F5RmdnY25SZWtYS0R3SkZVa1YrZUJESml1?= =?utf-8?B?YlZKcXo4SnlERDBXa0VFLzRNVjVGc3pONzdoMzZLN3ZqL1h0MFV2UllqTXBV?= =?utf-8?B?en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0+Y=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 0/caOY/hS6bzMBeFcKIztogzuC4e/5fMSnlDRUZw9rAXnEdaNruoMqbK5vfOGrA0ipSAf5uTOANjVBVtS4WzY8vGYxJ/QrlC0ruiKiR535QfOlbOTY/M2BVJM36EjGRrWOiMMMbx7zfxPWwKHDwc6A6GMvfb57LjsEh0D7j5wNs4veyFvSDzrC+yZoAecOywM7vJyzzp89CO3qDvWsdK4Ld8poCVR9x00yNkDGA+HQU/JfRkOgBpI7JeoavTo5ad2qN29AC5zE4y4Ohlh17R/xRW69W5jkIsSIUUrY5ZSUMmVTU9ZYqtm8ywoGvkdPGfnAvY5BQB+TRbNpIIi6nNBSC4iLpPOK/0wWq3pmSfQsWXXomySe+E5WnDSlkvT7j0xyGNAoRhcptv9pBK9QaJTEsHqUhqEGh3to3RLPYZv5a0RKm0BikT8zYgSshNxlJOkPyrJIgKwpxYvkHepZ/ZauBvL556WfL3KITIXIIexmgG2tbxtVToG6bWpK7EkN69V9YxB7fG5JWFf14Ij4YA7gANIRB1I2SfuFK4Kiqh0i6AbXW8HW4+KBQrLOAXnYiYREwQsN74+lCZMF8MFJwyRHDZ0KOVV431iD/GXghAkvLxQH0MjeGuiYLerUMjj4NZLEIkPuOxzT0XR1JEHBw/D4pwBTn90Tjtf7QZqsifYvqYv5+ZpO8hKuj/LsSfXeOsvfXPbCdNNdPz+n6NcUyVCKfS1zwxJWoA+H2LqIvLdIueU9qtC95W7FTuLjhH32hJIp6TEk1g4uTJbVltivKsFw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ce4bcf1-ccdc-4240-c99d-08db991c657c X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3206.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2023 21:05:44.5127 (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: jSkx3PaTy9PvQ/DW4hKSfFC0pLDz0AnGHnR2LLNhjU0TKFzSREIuT6vMRnlu+hQ3kqGfzyD84fET/Obf/6CVFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4861 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-09_19,2023-08-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 bulkscore=0 malwarescore=0 adultscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308090184 X-Proofpoint-GUID: usV90UuEnHc3uIOxDJZsXSsviXDM59nk X-Proofpoint-ORIG-GUID: usV90UuEnHc3uIOxDJZsXSsviXDM59nk X-Spam-Status: No, score=-6.1 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 for this series. https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624156.html 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 >