From patchwork Tue Aug 31 14:08:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1522665 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=d0cwokn/; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GzTZQ4s8mz9sT6 for ; Wed, 1 Sep 2021 00:09:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B00743858410 for ; Tue, 31 Aug 2021 14:08:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B00743858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1630418938; bh=hTS+BdwPRBbpMhyZWmYmrmkpoqJnEgiR0k7ZItZ7XVc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=d0cwokn/m3Fs3sr7xTXi33xGwO7xo3Lln+LzYJgib+kfWIt+6BesC+7GVaBr9JOSF bPHv9XP2Z7p/bkMGXr2TeZjLZvuMtAuLlmNY1HmL1qojvSPEkpLcmNCW6dTGAF2CsR 6sc2guOWZa7ZhMcrg9/hDMHsJ2nR4ov3mJAmFDcY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 5A4263858401 for ; Tue, 31 Aug 2021 14:08:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5A4263858401 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 17VDEfgH001733 for ; Tue, 31 Aug 2021 14:08:26 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3aseedh6fj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 31 Aug 2021 14:08:26 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17VDuGVR020271 for ; Tue, 31 Aug 2021 14:08:25 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by userp3030.oracle.com with ESMTP id 3arpf4dn3y-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 31 Aug 2021 14:08:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e56sx/CxFYCLsTYYRn/X3VPWJu6fogSqik5FrbGTdS7Te/PmS+RXTHWduU0sufadmz3Wp/dUglyyaeWMhU+N9Zz2sSfBVQsvz4MqQJ9JALnk0oVuXKCe3CQhogD8VJyMaT6dpflWKa/IYpsW73jDm+Qu8vw9gOikK3xnGzWHtVKXhP0+ozvghd/K4zai0Aeqg9gtbPbKNmaqLS5tsSQYyqR7pZOpgy3fe92jfLaVeHIMEl8XGF1x3LEMFdHho3Nz+rILjWY5Cum5aJZIhcoVkCIaSNUiphu8/QxE7uy1Io6Q/d8Z4UVFhQSmInPoL8c7WxcbxFJLPM9tNRLm3KToAA== 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-SenderADCheck; bh=hTS+BdwPRBbpMhyZWmYmrmkpoqJnEgiR0k7ZItZ7XVc=; b=ft9eAvzy8dF7iTnfwUYWQBsgYl65ZDV9oALZ6AP0vb2p3LkqeqCuKbsNn+DFCg/Pdb4SgcWiXhcyPzNhrmxTHJTjm44kgdA7muxXT6Pgv/p1X9rjkYUCYyo4X9h4gliOux1ggVPRz7WVrBGjS0gsSomgqlSaUBts2l2gi9Df87HqPfPjmbAbGuDuQyNFphBudulBvlI6Jn9fQFElz++demz3zbrLgNhhgMi2bHAJyXCAuLepENm6hrXIaW7Seq1nYI5NZbiS7KDdMgc6slX1I6Q+5tSdifGvqL0AQxDlzUQqtmpAqfr6frOqHDqM33X6aCmvEdyG3/1gDYrkPzNCMg== 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 MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by CO6PR10MB5556.namprd10.prod.outlook.com (2603:10b6:303:143::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.24; Tue, 31 Aug 2021 14:08:23 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb%4]) with mapi id 15.20.4457.024; Tue, 31 Aug 2021 14:08:23 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH,V3 1/3] debug: add BTF_WITH_CORE_DEBUG debug format Date: Tue, 31 Aug 2021 07:08:13 -0700 Message-Id: <1630418895-23520-2-git-send-email-indu.bhagat@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1630418895-23520-1-git-send-email-indu.bhagat@oracle.com> References: <1630418895-23520-1-git-send-email-indu.bhagat@oracle.com> X-ClientProxiedBy: SA9PR11CA0006.namprd11.prod.outlook.com (2603:10b6:806:6e::11) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ibhagatpc.us.oracle.com (137.254.7.187) by SA9PR11CA0006.namprd11.prod.outlook.com (2603:10b6:806:6e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21 via Frontend Transport; Tue, 31 Aug 2021 14:08:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 96accad1-07ab-4458-bcf7-08d96c88cb34 X-MS-TrafficTypeDiagnostic: CO6PR10MB5556: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ow4IE38ieVZMZ7iknKcJBSbhSiUfV8h4o5ZCYqPs1pTDKnLSkceYV2QHns+V+90qZioyHUn232y42nSYoTEtT4dWRqsfbVSn52x/9Ck3OuUVlz/nvtE/fUM8lvhTjVo9n7SxYueNjha6PqywAWjj8xZvkz2i/1eVObkFPuAYRzAWO93VU+1Q4i8J2bHNg9G2OmTrvAG6ezrXvvszd6cXT6ZHewG5Am0xTS2mVFpG9tjf8OCIJtUkwDSa9qKmC4PwxGUATw2MeOvbrdxQ2HZ7nmQFnu+g6XceUVGwJEK4On7A83rqeU90Qrxjnr6EgYPxaVdvUe28svPFG+0TafqrfqNP3yxYVRgM/G1VNCwKaHHOA4cgDSyozTDTbtsFfsuO+C0kTHRGKzpKgj2vlFJPOhxkZE0o83d8uD+ZyYyAO3SPrArNx7R4Lmbgq9ULaqk8TmbjM44m7vLVK3K3JeMn1l+pENyJq8QOEIefCFflnGyeMsV7rnnRqF7t6JURiaCfJcT58wuq9N1i/TkMm3mvYSkE7DAeDgW2/dzv9JwkT77xkvcQiHa5nWMb0RjndYi2qVvjaEIIUyAUhGqFFkbU5GklLQXUK5CVutiiIYrP2moyhUkmyBGRKWZbYQC/y4ury7pxGsjx5T+zdIKNKVcZlV++E1r9Bw4ej0JL3M95A6X1aP7YmZPOj0Z5/MGPPL9pByoCbjX4ByauDHw47nojFQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(66946007)(8676002)(36756003)(2906002)(86362001)(316002)(8936002)(26005)(956004)(38350700002)(38100700002)(5660300002)(83380400001)(2616005)(66556008)(44832011)(7696005)(52116002)(66476007)(186003)(6916009)(6486002)(6666004)(508600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oBx3qatQxwXrCzsBvdmaPKOk5qDdoh86qGIxv6OTWlMlVVtGTykQQuoWk/tINcfKQO359ZjQX3AxH5f37SjuVYo9p/OcQcbjoXHxC8c6rMECLk2C/sfXNHLSnQKydJd26kHq+AMLDjpYAU/CCINF91t00EJUQHLANRSIy5Zot+41WtBc7hsUHpLMTAGqSePMlqXwUAVgqP3qH8BGtQJXiNSA+RAhuiM+ZBrZLaDI8zM0ZCkxmO2VlBvxj4yG6L5pH3vjELXrWzx8GE/VIrSGiFar/CCYrikublKizOawgVbpJ6x5Xv3Kn2yCOuykjOW5j2lsrsXv9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cb34 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2021 14:08:23.3017 (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: nACaSq39lNIhdjzyu//Kb+dXDbpAeRrlU0/6turhkmqn48oe1Zk3kccQsHNq6b+KvLi4Qsgrue9JouslAN9j/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5556 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10093 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 phishscore=0 spamscore=0 mlxlogscore=999 adultscore=69 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108310078 X-Proofpoint-ORIG-GUID: GZgSE8f3lgZEPjhHZRRknr7VqJjpBKnc X-Proofpoint-GUID: GZgSE8f3lgZEPjhHZRRknr7VqJjpBKnc X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Indu Bhagat via Gcc-patches From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" To best handle BTF/CO-RE in GCC, a distinct BTF_WITH_CORE_DEBUG debug format is being added. This helps the compiler detect whether BTF with CO-RE relocations needs to be emitted. gcc/ChangeLog: * flag-types.h (enum debug_info_type): Add new enum DINFO_TYPE_BTF_WITH_CORE. (BTF_WITH_CORE_DEBUG): New bitmask. * flags.h (btf_with_core_debuginfo_p): New declaration. * opts.c (btf_with_core_debuginfo_p): New definition. --- gcc/flag-types.h | 6 +++++- gcc/flags.h | 4 ++++ gcc/opts.c | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gcc/flag-types.h b/gcc/flag-types.h index 4fb1cb4..cc41b2a 100644 --- a/gcc/flag-types.h +++ b/gcc/flag-types.h @@ -31,7 +31,8 @@ enum debug_info_type DINFO_TYPE_VMS = 4, /* VMS debug info. */ DINFO_TYPE_CTF = 5, /* CTF debug info. */ DINFO_TYPE_BTF = 6, /* BTF debug info. */ - DINFO_TYPE_MAX = DINFO_TYPE_BTF /* Marker only. */ + DINFO_TYPE_BTF_WITH_CORE = 7, /* BTF debug info with CO-RE relocations. */ + DINFO_TYPE_MAX = DINFO_TYPE_BTF_WITH_CORE /* Marker only. */ }; #define NO_DEBUG (0U) @@ -47,6 +48,9 @@ enum debug_info_type #define CTF_DEBUG (1U << DINFO_TYPE_CTF) /* Write BTF debug info (using btfout.c). */ #define BTF_DEBUG (1U << DINFO_TYPE_BTF) +/* Write BTF debug info for BPF CO-RE usecase (using btfout.c). */ +#define BTF_WITH_CORE_DEBUG (1U << DINFO_TYPE_BTF_WITH_CORE) + /* Note: Adding new definitions to handle -combination- of debug formats, like VMS_AND_DWARF2_DEBUG is not recommended. This definition remains here for historical reasons. */ diff --git a/gcc/flags.h b/gcc/flags.h index afedef0..af61bcd 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -44,6 +44,10 @@ const char * debug_set_names (uint32_t w_symbols); extern bool btf_debuginfo_p (); +/* Return true iff BTF with CO-RE debug info is enabled. */ + +extern bool btf_with_core_debuginfo_p (); + /* Return true iff CTF debug info is enabled. */ extern bool ctf_debuginfo_p (); diff --git a/gcc/opts.c b/gcc/opts.c index e050155..1d2d22d 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -135,6 +135,14 @@ btf_debuginfo_p () return (write_symbols & BTF_DEBUG); } +/* Return TRUE iff BTF with CO-RE debug info is enabled. */ + +bool +btf_with_core_debuginfo_p () +{ + return (write_symbols & BTF_WITH_CORE_DEBUG); +} + /* Return TRUE iff CTF debug info is enabled. */ bool From patchwork Tue Aug 31 14:08:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1522667 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=B13z3Th2; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GzTcg4Dhwz9sRN for ; Wed, 1 Sep 2021 00:10:58 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8BB30385843A for ; Tue, 31 Aug 2021 14:10:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BB30385843A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1630419056; bh=3yk8oEij/74etGvVLPCI0kOwl8nitouP4cNud8UzQKw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=B13z3Th2De5Spk5qz36Z1YblgGFRg78y/e0amOYqYTPlUzkgtOmPc5oKehdFg9aPu SaHtExGID1WyrQ4ulu/hRYfC6IVq7yBq2ivmp/zPz/wRpXYr3O8kbfZaagXcinjj1M YCxMGQ2SxPhprrskkG0ZUmAUaTyFbCeb4c3t8DQQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id BA3333858409 for ; Tue, 31 Aug 2021 14:08:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BA3333858409 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 17VDEbWC007616 for ; Tue, 31 Aug 2021 14:08:27 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3asdn1s95p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 31 Aug 2021 14:08:27 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17VDuGVS020271 for ; Tue, 31 Aug 2021 14:08:26 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by userp3030.oracle.com with ESMTP id 3arpf4dn3y-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 31 Aug 2021 14:08:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YT2ZOuQOhAYySkyUkrNLP9reaZGq/myTWbzfGRocmdubf5ZNTTGbdYx8Y9xU7+l9R5MJmIV682MnGjdJJwFeN4k7LFYNjR3MF1dQnvHGo4A6mPgOTbk5jjDOu1K8UxocJC0eAGsNm1MPPiH/jjKMTPkvrU70xO8TH2omKm05Q8ibHGbKYQUvxQe9cZ8GP5AuCa5OpF/f5bWaQx3zzDc8TA4vOUoEYE65w4ZliFTG0wYK8k9boXBOsfFwW67+zO4I7E+Pmc5fFAsEmRaw3k77ehV6i6UMC7+DsIi3NFpnjT2UeWq2lNEBpPI3Fxg2Ow0fC/7juMdh4W5Dx7L5HvcVpQ== 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-SenderADCheck; bh=3yk8oEij/74etGvVLPCI0kOwl8nitouP4cNud8UzQKw=; b=Gyb4KRXIi27NeFJXFI6ByVQPNFYstcPLiXKQmYNkQ8bt0biGMNiuh0VIdC/SkeGRUlon2GjQi3siDpPSqhbc+nh11yJKX7vJbLS+4yCqDk4Ft1EFwKa41nguLYM4EAzhljHkHnxV2wkT96cRQjZgAqBMvRuVwTni6wJBm5JUHqKY19GGVgLle1q11Z2kkMEZkgq11GyMcervKMoTK2efdf+kQYUGa9poZtw9/8Ty7C9gIPOOezMtsiLO3K+B7/z92oQ0yWt/2XNi4YrNDU6hLsAmUfIJrVS6UMdDBJP2bq/rEg8on40kO2zVbt5coso8rbh3AchcUSa3zhCOZLkX1g== 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 MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by CO6PR10MB5556.namprd10.prod.outlook.com (2603:10b6:303:143::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.24; Tue, 31 Aug 2021 14:08:24 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb%4]) with mapi id 15.20.4457.024; Tue, 31 Aug 2021 14:08:24 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH,V3 2/3] bpf: Add new -mco-re option for BPF CO-RE Date: Tue, 31 Aug 2021 07:08:14 -0700 Message-Id: <1630418895-23520-3-git-send-email-indu.bhagat@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1630418895-23520-1-git-send-email-indu.bhagat@oracle.com> References: <1630418895-23520-1-git-send-email-indu.bhagat@oracle.com> X-ClientProxiedBy: SA9PR11CA0006.namprd11.prod.outlook.com (2603:10b6:806:6e::11) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ibhagatpc.us.oracle.com (137.254.7.187) by SA9PR11CA0006.namprd11.prod.outlook.com (2603:10b6:806:6e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21 via Frontend Transport; Tue, 31 Aug 2021 14:08:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 296336d1-60ea-456d-5999-08d96c88cbe3 X-MS-TrafficTypeDiagnostic: CO6PR10MB5556: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q6QuXCPF0zXWkIPr8Pr599TO9BAOv4Ic63xfbFvX3jnjAuvp9YW/pvaBxtOBEtmBbd+znf5h5rWvChHr+Fbslk8Vy8VYEUjO6uCrZAxqyGyo+trg/TOpw99mxLOGvHQeC4mvs1IZedCGboHGznbZfY3CX+G98SgdCDTkudyF/bczBqGSlj8MPUi1qqJnWR2JbEzShEfkCes2Ee18ICA0xR7/0KlOz1s6KmC1fPvYUG8BmJnfpgnmM6SGstFRLa2s41+j5RDwB6RJKf7y+Z0IUipYCSfkOGtIJLLeZHVYgxRzF0EQFzRAvZo6XRxo9LMuX8jvCU0bLp8nr37nDhqLqQEY64RSofsr3cypj4ZbknPa8Ds46UQwfAlZH1/aIPGJdjbVcg990af931iz4+5HvZ6qGZ2vp3SI3LYfBxh/J039hb7XjGMEgi09S2qvLCCcD5BTYl3ROjVfbl70gWEQdYpDBVXgzTC9vse5OrlD/EgmPR+AA86dI6Bnd+qvdEKbmajVBHiHIDJjtVzDODkI9pjbMBtOwv0jT/FYlvaCqafcT+Eb0NaaKek3evIgKU97oa4bC847r5ltcO//u00PBQVGEHTM+aOvVvWZVs5UcMU7XV88UGhUVxYwjvveWx3hSbsy77lY3N/cpO7g/VhlrJ5TsfKvXTNiLYGaSycoUEeq273/lvPKkAocvFA4JSEaSHntX2WZgxUbc+ffmTl3BPKB/4EJPuBG8dQ/bkRrwtJsvcut7/5zZt0MFuIIgrHd1nxM+esYSQXlM8KrnkrbQf8iwyPcZ//NnA+oQvSRcE0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(66946007)(8676002)(36756003)(2906002)(86362001)(316002)(8936002)(26005)(956004)(38350700002)(38100700002)(5660300002)(83380400001)(2616005)(66556008)(44832011)(7696005)(52116002)(66476007)(186003)(6916009)(6486002)(6666004)(508600001); DIR:OU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tTcKlVxJ/SvO5JjIGULhT+yx3Ihbyta+bXyzw1T8RTtmYHuwc/2IRKFWfXEEdQWj8NooELvEiRKnrAWZDS4Dja91nlfEJ6DauebUmGgpTnmG/w+9OlYQ0/88AnBh8I60dhL230HHYWnIDJMIg2hBbJ1BGT3zM/lA4G5wWGh5RfuJC5VUOKSJzkr6zW8v3OaGAqmF5KAy3YdJdyoPxcp3fPgZvkx0yvPLw+fsQZ1n3nph+DWZkR4+8iAjJVHrPRVrqqRr6hpQwiC00tc0s/JRe7UFkOR3hS3MIWVQ3FkZdapXqeLkTn2Ls+RSP6tH4YusaqS4vxqX4ErbLMNh1BOQY4CLyrh X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 296336d1-60ea-456d-5999-08d96c88cbe3 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2021 14:08:24.3711 (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: u+Fvr89XM/oxfWQx3un7ade9OdRc6/fVLhW7NjG7haQlYV1Rg8z2VdsfYEqhdeIriFqiHsvVlybPp3GaWMr9pQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5556 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10093 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 phishscore=0 spamscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108310078 X-Proofpoint-ORIG-GUID: T3F-l4WoTIAPwzkwb__UvqujHkJM0ZJy X-Proofpoint-GUID: T3F-l4WoTIAPwzkwb__UvqujHkJM0ZJy X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Indu Bhagat via Gcc-patches From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" -mco-re in the BPF backend enables code generation for the CO-RE usecase. LTO is disabled for CO-RE compilations. gcc/ChangeLog: * config/bpf/bpf.c (bpf_option_override): For BPF backend, disable LTO support when compiling for CO-RE. * config/bpf/bpf.opt: Add new command line option -mco-re. gcc/testsuite/ChangeLog: * gcc.target/bpf/core-lto-1.c: New test. --- gcc/config/bpf/bpf.c | 25 +++++++++++++++++++++++++ gcc/config/bpf/bpf.opt | 4 ++++ gcc/testsuite/gcc.target/bpf/core-lto-1.c | 9 +++++++++ 3 files changed, 38 insertions(+) create mode 100644 gcc/testsuite/gcc.target/bpf/core-lto-1.c diff --git a/gcc/config/bpf/bpf.c b/gcc/config/bpf/bpf.c index e635f9e..7228978 100644 --- a/gcc/config/bpf/bpf.c +++ b/gcc/config/bpf/bpf.c @@ -54,6 +54,7 @@ along with GCC; see the file COPYING3. If not see #include "builtins.h" #include "predict.h" #include "langhooks.h" +#include "flags.h" /* Per-function machine data. */ struct GTY(()) machine_function @@ -158,6 +159,30 @@ bpf_option_override (void) { /* Set the initializer for the per-function status structure. */ init_machine_status = bpf_init_machine_status; + + /* BPF CO-RE support requires BTF debug info generation. */ + if (TARGET_BPF_CORE && !btf_debuginfo_p ()) + error ("BPF CO-RE requires BTF debugging information, use %<-gbtf%>"); + + /* To support the portability needs of BPF CO-RE approach, BTF debug + information includes the BPF CO-RE relocations. */ + if (TARGET_BPF_CORE) + write_symbols |= BTF_WITH_CORE_DEBUG; + + /* Unlike much of the other BTF debug information, the information necessary + for CO-RE relocations is added to the CTF container by the BPF backend. + Enabling LTO adds some complications in the generation of the BPF CO-RE + relocations because if LTO is in effect, the relocations need to be + generated late in the LTO link phase. This poses a new challenge for the + compiler to now provide means to combine the early BTF and late BTF CO-RE + debug info, similar to DWARF debug info. BTF/CO-RE debug info is not + amenable to such a split generation and a later merging. + + In any case, in absence of linker support for BTF sections at this time, + it is acceptable to simply disallow LTO for BPF CO-RE compilations. */ + + if (flag_lto && TARGET_BPF_CORE) + sorry ("BPF CO-RE does not support LTO"); } #undef TARGET_OPTION_OVERRIDE diff --git a/gcc/config/bpf/bpf.opt b/gcc/config/bpf/bpf.opt index 916b53c..4493067 100644 --- a/gcc/config/bpf/bpf.opt +++ b/gcc/config/bpf/bpf.opt @@ -127,3 +127,7 @@ Generate little-endian eBPF. mframe-limit= Target Joined RejectNegative UInteger IntegerRange(0, 32767) Var(bpf_frame_limit) Init(512) Set a hard limit for the size of each stack frame, in bytes. + +mco-re +Target Mask(BPF_CORE) +Generate all necessary information for BPF Compile Once - Run Everywhere. diff --git a/gcc/testsuite/gcc.target/bpf/core-lto-1.c b/gcc/testsuite/gcc.target/bpf/core-lto-1.c new file mode 100644 index 0000000..927de23 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-lto-1.c @@ -0,0 +1,9 @@ +/* Test -mco-re with -flto. + + -mco-re is used to generate information for BPF CO-RE usecase. To support + the generataion of the .BTF and .BTF.ext sections in GCC, -flto is disabled + with -mco-re. */ + +/* { dg-do compile } */ +/* { dg-message "sorry, unimplemented: BPF CO-RE does not support LTO" "" { target bpf-*-* } 0 } */ +/* { dg-options "-gbtf -mco-re -flto" } */ From patchwork Tue Aug 31 14:08:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1522668 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=rLXt0HeD; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GzTfC714gz9sRN for ; Wed, 1 Sep 2021 00:12:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9D4EB3858023 for ; Tue, 31 Aug 2021 14:12:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D4EB3858023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1630419137; bh=T3/bNwJiItk2erSxtI/2obhpZoi4+NybByaRerJtwvE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=rLXt0HeDbpT33YSFIUUhsdyMuxYdeWiGrk6SZmbEzAVEsQTTRcMtt+utOk8wT3SIq U9YbqcimaJ0LHs2a2f7MGBvuT+rJ3gdeodfU80WbRRWVbhWP4SnU/E30X2MgbedU3v o+r2JHv6oO7qOFlDhHfNhBSEQilm9fEM84HKRlas= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id EBE05385840A for ; Tue, 31 Aug 2021 14:08:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EBE05385840A Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 17VDEe6J004092 for ; Tue, 31 Aug 2021 14:08:28 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3asf66h343-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 31 Aug 2021 14:08:28 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17VDtcwF093734 for ; Tue, 31 Aug 2021 14:08:27 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by aserp3020.oracle.com with ESMTP id 3aqcy4sm35-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 31 Aug 2021 14:08:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PhD0NUwlCraazHQHR4OQN2LtPc12wZyfCuzzoavHvD8A9GZ31B5jB8o96ck1+8pB/Id9cDixbO62aoRaArQtgtH2Yu9JzcRkcnfw8cFjKaW0SJR7mcpeAjajwWsXgSOdzKlWijZQqW7ghA18L7d71gs+DzWKmeBlLj8QDEwN/ipq0DwqY3PdkpxaRxSvuWIDSKcFltQDNG7z8vkJmdc7JElGsfqcJHWliYI2TwILXzWsoUmKIMFv2BElJWIriDuvJLFwYh7EGsvscjbxn4vT6jZ+eZnY3iAxYQQae3MMvgFcd6vx/g8C6+Ivjcl01U4ocpz2GwGU1R80RSEveyIIbw== 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-SenderADCheck; bh=T3/bNwJiItk2erSxtI/2obhpZoi4+NybByaRerJtwvE=; b=WYBq2j4eI8b2TboX2rfYwBiARq/rnQjL5nFFF1yH92H+TUetB3qDxYhybfzDKJNFVZV6oFdJUkXwqvLbdbezX7lGHydLBcphSbrhRlh7TZwcvxWqi0Jkn9lB2ZaxKRUgY/ykEDBizg/iURZMB5NerEC8JeUGNwF/CJiLbbQBGfKcUROTpNvfW0oSmN56s7ncUns0fw+9Y/IghCCVzqVZGeEX26jkmpYCwMs1P2yjqzvcpnFzvOMhAbo94EPyDzt0kpPE8jppnvR0zQ/ZzSHvZHPYq+lrLAqqDgxbb44lAJ+so/cSpaqfNa/pM9osFuseO5V7RI/gYO2upzBZnSBmPg== 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 MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by CO6PR10MB5556.namprd10.prod.outlook.com (2603:10b6:303:143::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.24; Tue, 31 Aug 2021 14:08:25 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::c9ba:5127:fa3f:45cb%4]) with mapi id 15.20.4457.024; Tue, 31 Aug 2021 14:08:25 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH, V3 3/3] dwarf2out: Emit BTF in dwarf2out_finish for BPF CO-RE usecase Date: Tue, 31 Aug 2021 07:08:15 -0700 Message-Id: <1630418895-23520-4-git-send-email-indu.bhagat@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1630418895-23520-1-git-send-email-indu.bhagat@oracle.com> References: <1630418895-23520-1-git-send-email-indu.bhagat@oracle.com> X-ClientProxiedBy: SA9PR11CA0006.namprd11.prod.outlook.com (2603:10b6:806:6e::11) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ibhagatpc.us.oracle.com (137.254.7.187) by SA9PR11CA0006.namprd11.prod.outlook.com (2603:10b6:806:6e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.21 via Frontend Transport; Tue, 31 Aug 2021 14:08:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f412fb66-8a9f-41b8-6f20-08d96c88cc99 X-MS-TrafficTypeDiagnostic: CO6PR10MB5556: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yIRmWQAWHPpOMft9tlobgniGrKVNGUmRXqn3APwVgtJuhg8INRVfE3ZRLP88dWUdsvFTfDnP3j/ntfeS8XoKY61OD+f0/mm8mFh26/5O/Oyj3t8lZrNvSIr2CuKEgF2PsTwu/ce48qlo0SoTqPXrfvaJAXPdrlThtEgf3o9MEeyZLP1cHEN60MnxRNlLh+UaBaU/tiUsaS3bWAijZoQ3teP9ggXIdNFZZ8TO9SvvtkN6qMTK4yf/EjaNig6/959f58ld+Busznd8TECfqDifQY7IWvjFTaH3m7cUwB61l65lsiInj4XoVv7NvJWZxGVvIWImX0NLYrl87gnxeO+JHEs8rfisMHWEkOBGCcQY6sI/xJi3TM5t2sWX5i1fGTx9J5MhA0L9x9heA/+zWyzr+NZYp/r7YBwBuS9K8Sqf8o/agEgCvvvEtDiibuW3hC7ySW1rlBTwdhW8RJkY2OLeeg4m8Ox9oz1mWMYYYUj1IzSVup4NxKrUOGE3fEza8MMbXSX6eWOacn23sIbFtwzaRDNK/36MpjrqQyFAHxGVzmgW2V6cLPEsDYqj9NZpvOpML9jloSR0aN39FOLkKCHI1L3mw0hHPLeXQgFVUiPcpRS2QV8UsXZsTA0SuxzVBGLCi3J/8a4wjWSlo5W1nTCgFbDfCaHiIleNuRokpQFRdY1jfoSs/bhBZEoY4BsidgGYc6oMAMeKhq2g5kS8sOSQXw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(66946007)(8676002)(36756003)(2906002)(86362001)(316002)(8936002)(26005)(956004)(38350700002)(38100700002)(5660300002)(83380400001)(2616005)(66556008)(44832011)(7696005)(52116002)(66476007)(186003)(6916009)(6486002)(6666004)(508600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gYHSaZwp+zQNcvGfqYs05C3QFnmMQf2HSdr/6cdQbWGJRJd1hpjx5+trw6G/BtfBAeXn9aW/lIL1lYbloMTN9GKnP4aLMVuEYwhtvREHXln9PojptgCyBII67jZDuGsq46PRKPIIZlSKsgApjxWS4tK0iSq2zp9bXK+3VLI4cvqfLcjdQhBs16LUHqs7PYAStbUx1GPL4gKGfEDZIKEJmFwL1jzX/LSlpxvv9nXLi6Buu1tj6RdKpdPKnh98Gm6//vc8cdUFEduSgbBZSEqy6UdZVwp1zMVzHqnOvOUV2eoA2GOoZZ2PsbYC3c3rbuu2irMcH4r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88cc99 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2021 14:08:25.5594 (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: sSbTQ47Db4hjt1XEVw4+/SjNUzx5liPKD+XgN4KHjIcJEl5pXZRoylMTgvYYuFbLdMt67UNm2SUBYFbS1x0bCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5556 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10093 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108310078 X-Proofpoint-GUID: 6hAfQoW49oppMhaWF9kW2-CdIYZLlB7m X-Proofpoint-ORIG-GUID: 6hAfQoW49oppMhaWF9kW2-CdIYZLlB7m X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Indu Bhagat via Gcc-patches From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" DWARF generation is split between early and late phases when LTO is in effect. This poses challenges for CTF/BTF generation especially if late debug info generation is desirable, as turns out to be the case for BPF CO-RE. The approach taken here in this patch is: 1. LTO is disabled for BPF CO-RE The reason to disable LTO for BPF CO-RE is that if LTO is in effect, BPF CO-RE relocations need to be generated in the LTO link phase _after_ the optimizations are done. This means we need to devise way to combine early and late BTF. At this time, in absence of linker support for BTF sections, it makes sense to steer clear of LTO for BPF CO-RE and bypass the issue. 2. The BPF backend updates the write_symbols with BPF_WITH_CORE_DEBUG to convey the case that BTF with CO-RE support needs to be generated. This information is used by the debug info emission routines to defer the emission of BTF/CO-RE until dwarf2out_finish. So, in other words, dwarf2out_early_finish - Always emit CTF here. - if (BTF && !BTF_WITH_CORE), emit BTF now. dwarf2out_finish - if (BTF_WITH_CORE) emit BTF now. gcc/ChangeLog: * dwarf2ctf.c (ctf_debug_finalize): Make it static. (ctf_debug_early_finish): New definition. (ctf_debug_finish): Likewise. * dwarf2ctf.h (ctf_debug_finalize): Remove declaration. (ctf_debug_early_finish): New declaration. (ctf_debug_finish): Likewise. * dwarf2out.c (dwarf2out_finish): Invoke ctf_debug_finish. (dwarf2out_early_finish): Invoke ctf_debug_early_finish. --- gcc/dwarf2ctf.c | 54 +++++++++++++++++++++++++++++++++++++++++------------- gcc/dwarf2ctf.h | 4 +++- gcc/dwarf2out.c | 9 +++++++-- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/gcc/dwarf2ctf.c b/gcc/dwarf2ctf.c index 5e8a725..b686baf 100644 --- a/gcc/dwarf2ctf.c +++ b/gcc/dwarf2ctf.c @@ -917,6 +917,27 @@ gen_ctf_type (ctf_container_ref ctfc, dw_die_ref die) return type_id; } +/* Prepare for output and write out the CTF debug information. */ + +static void +ctf_debug_finalize (const char *filename, bool btf) +{ + if (btf) + { + btf_output (filename); + btf_finalize (); + } + + else + { + /* Emit the collected CTF information. */ + ctf_output (filename); + + /* Reset the CTF state. */ + ctf_finalize (); + } +} + bool ctf_do_die (dw_die_ref die) { @@ -966,24 +987,31 @@ ctf_debug_init_postprocess (bool btf) btf_init_postprocess (); } -/* Prepare for output and write out the CTF debug information. */ +/* Early finish CTF/BTF debug info. */ void -ctf_debug_finalize (const char *filename, bool btf) +ctf_debug_early_finish (const char * filename) { - if (btf) - { - btf_output (filename); - btf_finalize (); - } + /* Emit CTF debug info early always. */ + if (ctf_debug_info_level > CTFINFO_LEVEL_NONE + /* Emit BTF debug info early if CO-RE relocations are not + required. */ + || (btf_debuginfo_p () && !btf_with_core_debuginfo_p ())) + ctf_debug_finalize (filename, btf_debuginfo_p ()); +} - else - { - /* Emit the collected CTF information. */ - ctf_output (filename); +/* Finish CTF/BTF debug info emission. */ - /* Reset the CTF state. */ - ctf_finalize (); +void +ctf_debug_finish (const char * filename) +{ + /* Emit BTF debug info here when CO-RE relocations need to be generated. + BTF with CO-RE relocations needs to be generated when CO-RE is in effect + for the BPF target. */ + if (btf_with_core_debuginfo_p ()) + { + gcc_assert (btf_debuginfo_p ()); + ctf_debug_finalize (filename, btf_debuginfo_p ()); } } diff --git a/gcc/dwarf2ctf.h b/gcc/dwarf2ctf.h index a3cf567..9edbde0 100644 --- a/gcc/dwarf2ctf.h +++ b/gcc/dwarf2ctf.h @@ -24,13 +24,15 @@ along with GCC; see the file COPYING3. If not see #define GCC_DWARF2CTF_H 1 #include "dwarf2out.h" +#include "flags.h" /* Debug Format Interface. Used in dwarf2out.c. */ extern void ctf_debug_init (void); extern void ctf_debug_init_postprocess (bool); extern bool ctf_do_die (dw_die_ref); -extern void ctf_debug_finalize (const char *, bool); +extern void ctf_debug_early_finish (const char *); +extern void ctf_debug_finish (const char *); /* Wrappers for CTF/BTF to fetch information from GCC DWARF DIE. Used in ctfc.c. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 07a479f..3615e68 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -31913,6 +31913,11 @@ dwarf2out_finish (const char *filename) unsigned char checksum[16]; char dl_section_ref[MAX_ARTIFICIAL_LABEL_BYTES]; + /* Generate CTF/BTF debug info. */ + if ((ctf_debug_info_level > CTFINFO_LEVEL_NONE + || btf_debuginfo_p ()) && lang_GNU_C ()) + ctf_debug_finish (filename); + /* Skip emitting DWARF if not required. */ if (!dwarf_debuginfo_p ()) return; @@ -32817,8 +32822,8 @@ dwarf2out_early_finish (const char *filename) ctf_debug_do_cu (node->die); /* Post process the debug data in the CTF container if necessary. */ ctf_debug_init_postprocess (btf_debuginfo_p ()); - /* Emit CTF/BTF debug info. */ - ctf_debug_finalize (filename, btf_debuginfo_p ()); + + ctf_debug_early_finish (filename); } /* Do not generate DWARF assembler now when not producing LTO bytecode. */