From patchwork Wed Aug 4 17:54:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Faust X-Patchwork-Id: 1513581 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=J9uRsM+m; 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 4Gfztm1Z1jz9sRf for ; Thu, 5 Aug 2021 03:55:59 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6BB993950C85 for ; Wed, 4 Aug 2021 17:55:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BB993950C85 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628099756; bh=vcVqT8/zEkz2zwt+K7aOCb171NUNhk/41N7jC/RafxA=; 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=J9uRsM+mAvN5fEOb2LFt3VbHlhppWGUuVSoDRYDvjEN6TTNsVPt5svrTwmKBS3I2Z BpODqnA/VdH0H3Rej0ERIwd9If9hq22k7CUkejC+aIuOWryNUFjXUA70mqSMW/pZFJ yPpodoZZM519yWIkvXMjrAClB7UQYedUnihSb/Lo= 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 C123A385BF81 for ; Wed, 4 Aug 2021 17:55:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C123A385BF81 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 174HqJuC027137 for ; Wed, 4 Aug 2021 17:55:11 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3a7wqv0ag5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:11 +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 174HpUZr031193 for ; Wed, 4 Aug 2021 17:55:10 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by userp3030.oracle.com with ESMTP id 3a4un24yd8-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bi+MwrhE04R2/t1wWSGM/1ZfHX09DfKTWSSZNWSjHK23EKNUnYgM8dSSyapgBBU2adBwNXcipaYmEswzjtq5PXBC1z4VvtC1KiXa09Qt88Wt/IevtmgKsYp4ZCr1JwRT0YK+UAJ38c/f9HIOnQdGyb6T0rcuntm0NeNlTeCALgqqeXSklBztNf/KZ4A4XmFaOE2DnjQ7/WuXlKmSuowCYgwjUmlBkFK6Z8Eua98Dn4PkKYWFc7ql/sn6+Soyzwm9KPoHNg8IPo00ma8kFVTa8JoC/Uj7ZeX4sE1GNA14H3EfVcQtW9rebdfnTJLGKOrUVVtDIkKAUlISAKJvea1ozg== 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=vcVqT8/zEkz2zwt+K7aOCb171NUNhk/41N7jC/RafxA=; b=R/HkI574jMbb+Hpj46EI+0nTs8Y/Xf7nvVPecgQZ1uggId2eo2dRnHyJ5K38fwKs+9KI96DRnu5h4FcujzO67jjhVEwnuu8JAZ9TJ16T/TcYujveHKjrhsslJYJH9M8GtvwStWqkXK0eSl7qwdl7xm6ulZfLonkU5f8WsjN/GsEGU+8eVZAeU9Xa/dup/8s+kbntVuVkvqjlF55aB9QNNIDJYud7iEyDEOARfO1kweCAIMzvEJ+lfkRA495Pd82CNyXNYVrYpPyn1MghyUBF0FgEC4jbBJnQ6cbGmopplXXLUyE0bWZcg9e3GCt+I1Po0u27Bxph4uOVyDYu70qjCw== 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 SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) by SA2PR10MB4555.namprd10.prod.outlook.com (2603:10b6:806:115::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16; Wed, 4 Aug 2021 17:55:08 +0000 Received: from SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632]) by SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632%5]) with mapi id 15.20.4394.016; Wed, 4 Aug 2021 17:55:08 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/7] dwarf: externalize lookup_type_die Date: Wed, 4 Aug 2021 10:54:05 -0700 Message-Id: <20210804175411.6783-2-david.faust@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210804175411.6783-1-david.faust@oracle.com> References: <20210804175411.6783-1-david.faust@oracle.com> X-ClientProxiedBy: SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) To SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sequence.us.oracle.com (2606:b400:8004:44::1f) by SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17 via Frontend Transport; Wed, 4 Aug 2021 17:55:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f0b23610-6200-4595-3c45-08d95770ff3e X-MS-TrafficTypeDiagnostic: SA2PR10MB4555: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2201; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cUXo77E4ak0ajNpqBj3yNpGD9W0YY8J3JA/BWOm7vllrIbj1id9fJDiC1XXIyczPSCKte2Wyhg+kLcWLkY+EkzJmHsXkwsyB6ktQmQ0ouuyzTSt0kwCuuY5yaaN7lsJd203PRmYjmQmj62goEBPQ0G1wmHdzvcH69c4NQdPaOjPTFPzJBkMQz9jkLYdNTqNUSJ8xZmF1t9D+fYOcQbS56z5V54HTX1iBp7d8O1RdKXJ2Ok9z/oHstlNvE//lolzhcJEvQShAcsAbgO3A39HPQZiY1I4IBjeLCQF6PF7JYFCQdsQGDLgzEi/KHhFKFWCQfaOtT7uAhPp1xA2kBovjyVneOe1EInXQwv3D7BJ0o3UKLl8ZQjbUORU+j4P5rvhlipRnTL006s+uCcmQmIZdAcO9pAdKnS2QepkMYY+LW/OErrAfGNjoqxCanXwAxxl8BFOtnoTWU0KQbyjVCo408wvoq6p1gtMO9MWUF2gDvHd6K1hdrcoWw5tUsfxWG5gLJ12rVCk3hMX6aPACiUL0ZiaoANsIozOi3IcEDHzI4P9GOYoAdWFQOYqD/H6AKoC1gy3SjU0VlyvP/QKl2vdXuLz42g28Pe3tDu2QUbn97IsuBqGeUgc2ytHlCXlJHxQyxLDD+Qtq/kNqewxaCWI3bA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4458.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6486002)(44832011)(316002)(8936002)(66476007)(66946007)(6916009)(83380400001)(66556008)(86362001)(5660300002)(8676002)(7696005)(38100700002)(52116002)(508600001)(36756003)(186003)(2906002)(1076003)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tw9DqsZi18iP6CKZfMYbBMtjtLkYzuREmpA9KT13yvX5FElzRoCUb7MMaFs0J3PBO3yOKLhKrkP4B9VMD3k+w1Lrn2aqVv8dLuFxElhAo263O//ZcQvXYwJ2sn6r2tW3hoPj3tgfswTjC1VxjXSC0S/+ucIGVloszaJPZf/4esYUYx9hym6WPOurUiOqozk5lQ9SW+QuWAcSAL+QHg9+slbMvSXImMRalRilQd07/NQjDQ47MGnMeyXfoHXwjSgjj+IwJFKJEOMKmOijVRs1LcniJJhwyLPonLZ1xKxDA3GXgNQZFtmcz6sqdgiSQLIApwvykEKsnucY0n9x1z09ceYOs7NIJYFxoiaibiu2NF0oYKNBM/Xrd9+dRhj2bQGBfLLWfhFOiD1P3sjCW3VozTNoPv4HbpcA+Huj2ofL6sJ96zIUIA/jco9pzfHZ0Mz+9QIM46pmB8zKXbPb4KpSoMoKQaPVUIGRj7slzgr44T6IsnM/6yLeXn64Z6BFtW3vh6ZVGj7rgzw/EILI8qqRqS37M/XH/x+wKmQ+oYwWUSOTBXfa3ZtMjVxnB+DhGDDdFaeph6zmYEk2lyx60gnWt1fAiItXixr9k1BUcIgSbag7mbIktbfRu1zJ/p0M4dMvnCZkyE0neZsq072HMah0aOozBLA8QYuPq+M0HH6YToKf6Wwv0wRG3zx4qDg87v1DUFiQxaMGBNJM548+2UTGHVmIlPbeFDa1XsOHf/GRILVFrnqumyZp+2TvpXAh197HjMH3o8/lLNPvQ9m08o0KFI8spYyJEvQz4JTvMw6J5e9Nsp1m2nZEKM91Ag0ACnWUgLjErv6TH1M83D5jcCyOzK9laGYT+xkJdV+qQESqWIYvNJXE3evAtA4tjzLqd7pTsuq6399vFupOEbqVET//ShGzavqBiManpKPCXo9DdtupSTg6VurUWt0qUwfxDRS5q1X4fa/PMAOVNKCbZBb1uohBdSbmzfDyPQdLJZEnKNmHRxblDs7MRTOPpCBPD6FQ10j6qoUUQGiJV00T9yTMngmG3pc+HzwKA8OK/W9qS460DN8jiMaydW12U6/VA1Y/H7UqRyWJ8i+pNFdr2p8p4aYDR9a9sXzvnKuUwvba1l4R/qj2ITVR/XS+jR695BaiQxKNoV3+FtzqcYLtvAwnrI64rwM3ehHagtVFLL+GnyOnBz69CftswwaQmal84Gt4Wjdp4aCUoLesAtcj/xJ2FAF2GLSX1p3/j9Hs/fSTCtLgRDxn+U8uceYljunW05hbrnnlGoVg4mmBHg330CH+N+hAedeV62YALH0N97qfSAoU2iVLpngSLf+mfF22wF9DByW3FkyciNoVW3heiec5NA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0b23610-6200-4595-3c45-08d95770ff3e X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4458.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 17:55:08.1690 (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: F1zaclBUVizaQzcfttk7u4PQ7FnN3WIDALo/VwRxJ5cpX4lpQP0Baa6aTCgm+M0LjLmNkDUdCJreT3gCAIlwFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4555 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10066 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 mlxlogscore=624 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108040104 X-Proofpoint-GUID: AnXxnYuLqknfJXygt6ofaXV_QK0qLFk9 X-Proofpoint-ORIG-GUID: AnXxnYuLqknfJXygt6ofaXV_QK0qLFk9 X-Spam-Status: No, score=-11.3 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, RCVD_IN_MSPIKE_H2, 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: David Faust via Gcc-patches From: David Faust Reply-To: David Faust Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Expose the function lookup_type_die in dwarf2out, so that it can be used by CTF/BTF when adding BPF CO-RE information. The function is now non-static, and an extern prototype is added in dwarf2out.h. gcc/ChangeLog: * dwarf2out.c (lookup_type_die): Function is no longer static. * dwarf2out.h: Expose it here. --- gcc/dwarf2out.c | 3 +-- gcc/dwarf2out.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 1022fb75315..f32084c3eaf 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -3740,7 +3740,6 @@ static bool remove_AT (dw_die_ref, enum dwarf_attribute); static void remove_child_TAG (dw_die_ref, enum dwarf_tag); static void add_child_die (dw_die_ref, dw_die_ref); static dw_die_ref new_die (enum dwarf_tag, dw_die_ref, tree); -static dw_die_ref lookup_type_die (tree); static dw_die_ref strip_naming_typedef (tree, dw_die_ref); static dw_die_ref lookup_type_die_strip_naming_typedef (tree); static void equate_type_number_to_die (tree, dw_die_ref); @@ -5838,7 +5837,7 @@ new_die (enum dwarf_tag tag_value, dw_die_ref parent_die, tree t) /* Return the DIE associated with the given type specifier. */ -static inline dw_die_ref +dw_die_ref lookup_type_die (tree type) { dw_die_ref die = TYPE_SYMTAB_DIE (type); diff --git a/gcc/dwarf2out.h b/gcc/dwarf2out.h index b2152a53bf9..312a9909784 100644 --- a/gcc/dwarf2out.h +++ b/gcc/dwarf2out.h @@ -417,6 +417,7 @@ extern dw_die_ref new_die_raw (enum dwarf_tag); extern dw_die_ref base_type_die (tree, bool); extern dw_die_ref lookup_decl_die (tree); +extern dw_die_ref lookup_type_die (tree); extern dw_die_ref dw_get_die_child (dw_die_ref); extern dw_die_ref dw_get_die_sib (dw_die_ref); From patchwork Wed Aug 4 17:54:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Faust X-Patchwork-Id: 1513587 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=CXEuvJIZ; 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 4GfzzR4N64z9sRR for ; Thu, 5 Aug 2021 04:00:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6464F3951809 for ; Wed, 4 Aug 2021 18:00:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6464F3951809 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628100001; bh=Xy5DgIPRJWKZQkyTog14R3urnWm2+u2jnbSdzlW2Vfk=; 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=CXEuvJIZLm0WZAqRg7WM4/8G3b2F004DmjWWmtgzhYMBzSKG0rqcUzmTIkvJhzzjC il69ooJULhleeNN4GDJZjr5LETdmnB7p9P12FjXrs1clRppQ16C7UUfzkYa1zKeiQA Z6TrqZ+F2yJv9QCkp095h8gYmU06wTham5kvQ6WE= 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 D135A394C000 for ; Wed, 4 Aug 2021 17:55:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D135A394C000 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 174HpS6s028224 for ; Wed, 4 Aug 2021 17:55:12 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3a7cxn2am2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:11 +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 174HpUZs031193 for ; Wed, 4 Aug 2021 17:55:10 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by userp3030.oracle.com with ESMTP id 3a4un24yd8-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L/T+N+1Te8fCjldHlcjD10EwL6Lti8yq08hBdRMexOIud+B4w895hTXabs7JpJFqK6lXcDF5bO/3lunkqRiIjJZI7FjBI4aJH+pmhp/8yiJeeAqYhE4u9VwcJY5rrXcZC7ENsJQoENmSiht47JTB1UXcKatMAvvX87YSEaErLesZvBo9Mz5djHRCo0rlhbdA6NL2TrLurwYv7Um5x+rSVGaCJIbMBybIcGFMitZcFzhnZ2VCn+dYg2IJstL87XY4NYroLgZetsRHWTZlQKiccYerSd/QsBS51+Y/ly3g8giJg6NMTDYyNFDcZfw33VOpPrVbTxpPft6i+R7vFbSGGg== 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=Xy5DgIPRJWKZQkyTog14R3urnWm2+u2jnbSdzlW2Vfk=; b=c4l0peKkXZpbBKYRdO+VCkV83Hp+ppdfq1fxcakZzEeCXelDmQ0LPLi0ppLpo02GVMLe2RUiSFwkpHkGJJxzhyHTjV303up9xZTOI4/Z40RkBvD0FkbFayh3akiLmftCKF6HnELV4Y77CeGrZSSzAixpF0/ir/fQkfpHWljccweuPNg5vBwHqotaTyXEacqcmbA9qCpkB0y/xaJwxLaCa6OSc9XvuiOBVaDJnU30THLQDJhDPWwWf28l662uc0g5w53DIHs0RgjWRvO5jo48wZGpJkHG20A+JFtR8AMah+Ha008sk7sMLC/tTXqL/1kH8CzODKcui5j6RCTxfpPbCg== 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 SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) by SA2PR10MB4555.namprd10.prod.outlook.com (2603:10b6:806:115::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16; Wed, 4 Aug 2021 17:55:08 +0000 Received: from SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632]) by SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632%5]) with mapi id 15.20.4394.016; Wed, 4 Aug 2021 17:55:08 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/7] ctfc: externalize ctf_dtd_lookup Date: Wed, 4 Aug 2021 10:54:06 -0700 Message-Id: <20210804175411.6783-3-david.faust@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210804175411.6783-1-david.faust@oracle.com> References: <20210804175411.6783-1-david.faust@oracle.com> X-ClientProxiedBy: SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) To SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sequence.us.oracle.com (2606:b400:8004:44::1f) by SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17 via Frontend Transport; Wed, 4 Aug 2021 17:55:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a1a15f59-47f1-4080-605c-08d95770ffa0 X-MS-TrafficTypeDiagnostic: SA2PR10MB4555: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EbcXeTNhOwqfLbx5iPPxhfHa/hoxAieugSOuLF/uxoNpEiq1wCTt0FvwSJYb26AxRN7rt5uAvNe2YU5NNA+IRL8MMuAhJYbp7Iw8XsP05EIrzXBqLP7mMNJxfem/j9RWSDaPi2hQHHz8pIDVuU0ZVWaaxo+ianYRUkpfFktKiL1fOWhSEsB8KRiTnrgXfihIUxrm5W6p5KmlNT/fbEGAEGZ4/dpYumJMDTwS6U/uzEw12rh5Qw4lxfPqL+MFDc/rePGXTJvL3iTO0xF3YQOh3Ln598E4/kmpvMRGWTDoq1xsjV3fCgRbbyFX9ljqDm+rDftFIpDI2v0fIOVN59+/Qmkx74Gzoo4ZHiHwn7zMleFraqQgJRy9J8iwD/7s3dajHgV5Kcu3WBY4SJ882JOnqxAOVVJW4NhK+900BaMDGX+NEKKg6gckqtiZl+fM24kgKdCu/9vkXjhJ5+NwvdWK7xWAYrW2AWa9Bo3XYbHs0c86y1eSVjODRldBvH3zkQsUqa/soLcZ7QF3RaVpMzt4NBsXYR7pJ58sTdSZ/YPfhLviwwYaXZElknoNk7bBJ/DAb6brgD4rjdd04tmnPPFQy043ooFl5ouHnO81otnaC2cqGIVKqkum32lL4xkFqPDwB9p3DJWtLCS30JJthCSNUg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4458.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6486002)(44832011)(316002)(8936002)(66476007)(66946007)(6916009)(83380400001)(66556008)(86362001)(5660300002)(8676002)(7696005)(38100700002)(52116002)(508600001)(36756003)(186003)(2906002)(1076003)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wOj6Gvf7VBZ1tkDs9iZloasJXBBkWndZT6HARO1XfLiGt4H8QrfdEcpkhsllL8shzHtsK4Cf1FHmTUdndnehyT6RqtpFPFv/IipNoeA50+5lFAwCOiJg5AH8pqcbGI5+y8wGSP2fHs1mJMeSJj9oDV0fLOf0hzPTHNQRNuPgeApAxwk0il4wks0fekIkiONNKNbGpRgPar5KfERF3QnLDJcqohF8cBX6ijwSMy+BU54CDsG2MF0FR8d7MniMrnnBC9nh9tdKcT9eGNDzL6zQo2AcMmSfo7avhTAH1HxVJl1+HGmp0outlf9lGFP4sHVd81o6nb3P4FOhCgFP4bcBZLbfa32tq1DWitSWZpeE9m8fnDD7WgRHgMJBZ5+DytAylqOzUR/8xVxCuLPzl7P4CMxnT6idOATl29WgggLE6h9TNpU9hta49OAAlWPva2cCbPOfgwf0pkNazx3Lg5tja+o45wy1GuYBG7XrYxc9AVgx/IN+E+IL6gVBP2D/qs5goSSpA9WhsY4dpZKXDWuPFMZBlX+b8Ru2aM0Tr+Ge+JiQyC673CD0BImR0t1LyiJOUcFHYTjmJGmIplT2ZNCbQtGXng8QRJ56ldafiekASBom8YJ+eXaatZRQeXYXR4mVHLg1x0Ro/aTOuuVtQF+SlOQAJS7fYEqaUfcP6JvjTutEKWQzhRose9bMsGBT/kzQYZucoCBy+R/2F4RRTsl700D04Ks45/WiGCEgWp5jJMMwWox/3dj2iMkv+yfJKswR2FFkL/mmDY7qmLgN5KszjyUB+whWgTILK4r/qG2wQXUcXutDPWKX9cCFPbHcGk1sPCj6I2X8ctYr36tOPkmtEBCEdMnkmgapcH530hO8gTeaEyqtKoPwH/zbX1plMg5EGuWWu80ehCy6TNbGIrdI2Qf8QLMAuYF2yHjvXbsuvbrcG/6w32AvZxPXIISzKWzNmQRvtQBE/jdGOJCH6VV39pIiWfseHPuzDnxIOhGkvonggOGU0psCEj5rIpIpNGOMjK1veLxfkXMKvqV3x8vaJ0+XMYuuL04zy6V48lZCFy7oWt40UrAiakzUtyShqy7jAXvrVvnZaOO80w77OP5BPAemq7QSHxPLSQz5SZr78gsxwjtkU1czPxpRfG7wq8UqWSCrIPzfI8RWONEMceKO3C1BksNAxAOJORsXURqvG9nctp6H5myzWtqvzoGUuZavrhseqSUUuD9pvIiwuC4XeNPipdYFs9UJCbNnLwqHQgV/1GOA6pEgSkojFevA8xsX69ZEtQqyZXGtd5ERIip2dm6IItSaPq8LEgCuzX7xRa7SY7rJVZ+EVuq26ez+yC6KJ4CNg6LGe2RpSxa+o5dx/w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1a15f59-47f1-4080-605c-08d95770ffa0 X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4458.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 17:55:08.8201 (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: kjl419r8SZnHlfvbqKYSOTBmDMfltDbBOC6m+GuHyUQTlD2mSPh/EbOE6h00ZHBJ+168aUNsSHnKZEsgMweeiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4555 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10066 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108040104 X-Proofpoint-GUID: E3lL9X5B9U06FT1W82MYwpEqzrcbaj5O X-Proofpoint-ORIG-GUID: E3lL9X5B9U06FT1W82MYwpEqzrcbaj5O X-Spam-Status: No, score=-12.0 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, RCVD_IN_MSPIKE_H2, 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: David Faust via Gcc-patches From: David Faust Reply-To: David Faust Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Expose the function ctf_dtd_lookup, so that it can be used by the BPF CO-RE machinery. The function is no longer static, and an extern prototype is added in ctfc.h. gcc/ChangeLog: * ctfc.c (ctf_dtd_lookup): Function is no longer static. * ctfc.h: Analogous change. --- gcc/ctfc.c | 2 +- gcc/ctfc.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/ctfc.c b/gcc/ctfc.c index 1a6ddb80829..db6ba030301 100644 --- a/gcc/ctfc.c +++ b/gcc/ctfc.c @@ -132,7 +132,7 @@ ctf_dtd_insert (ctf_container_ref ctfc, ctf_dtdef_ref dtd) /* Lookup CTF type given a DWARF die for the type. */ -static ctf_dtdef_ref +ctf_dtdef_ref ctf_dtd_lookup (const ctf_container_ref ctfc, const dw_die_ref type) { ctf_dtdef_t entry; diff --git a/gcc/ctfc.h b/gcc/ctfc.h index 39c527074b5..825570d807e 100644 --- a/gcc/ctfc.h +++ b/gcc/ctfc.h @@ -388,7 +388,10 @@ extern bool ctf_type_exists (ctf_container_ref, dw_die_ref, ctf_id_t *); extern void ctf_add_cuname (ctf_container_ref, const char *); -extern ctf_dvdef_ref ctf_dvd_lookup (const ctf_container_ref, dw_die_ref); +extern ctf_dtdef_ref ctf_dtd_lookup (const ctf_container_ref ctfc, + dw_die_ref die); +extern ctf_dvdef_ref ctf_dvd_lookup (const ctf_container_ref ctfc, + dw_die_ref die); extern const char * ctf_add_string (ctf_container_ref, const char *, uint32_t *, int); From patchwork Wed Aug 4 17:54:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Faust X-Patchwork-Id: 1513582 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=OPti6kIF; 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 4GfzvT128pz9sRR for ; Thu, 5 Aug 2021 03:56:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 668923951C83 for ; Wed, 4 Aug 2021 17:56:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 668923951C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628099794; bh=uBcDlE7+7FI3BK++lgi8xGJRsvNCdcDKBku4LuIGIXE=; 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=OPti6kIFjr24Fa4Leyu91WSJAqO3cI85FBXUAXmik2kk+AFYOyg72l8DW2s9m6f9T OJ65oT0r7EwGBT6Sf6gG9POsqhhucIjGcE2eQX44wgGcCjlp8V+g6poehU9AX+GPph pbMb9X7TEG7Oqt2xP7zyGi5XUtmNSL7quh9m9R3s= 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 46F06384F032 for ; Wed, 4 Aug 2021 17:55:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 46F06384F032 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 174HqI9e027122 for ; Wed, 4 Aug 2021 17:55:12 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3a7wqv0ag6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:11 +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 174HpUZt031193 for ; Wed, 4 Aug 2021 17:55:10 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by userp3030.oracle.com with ESMTP id 3a4un24yd8-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jVSk3sawYIhs1zlq8ZOUcEJz8Ij0Yst7sduj07d2/IvnL89iRg+qSUooMfpBtjJMC9NTG9kouab6ITv7fLqapcdzkkXQhgsxNroo8zSPmzFti+yKkHgtr5syEdl4lIaSLHg8M87aV7C8GElHRCoA7pW0RGQTyoYz6/wbobTukYxH4jhh5Np9UuEngYvjb9QmDsfLOljUIrh7augWsV//EfdhADtWUDoiL7GHTHtHylXiUgXXyW0xU+N1Mq/qp2TDDN0vnlTgMc61FpEe9QEHsF3JK8AwmsPJdlb6I8al5Phd2WEQiH5K+RN1rDEdzxZxwWLQLKjDow8N8xCgvOXGJQ== 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=uBcDlE7+7FI3BK++lgi8xGJRsvNCdcDKBku4LuIGIXE=; b=XdvFm8mTsx/NfKbZfrYiFEakseto6INEujIGTSttcoxDpbLruT/kVZ6jLRPzRTag/oEfA+HIfQRameI2Ba8IruKu03YrFWDidtwIVSAsVTQWlI31jzIz/ew+l3aaQCRN4VrVdnp8YW1snUjv5kgk8BFFGUOHGvzFchKHMyoaXGbgz/FUtt4bbwD1eJy0r6Gim/S7yD7D+Vi47dhRNmXcCMELnU8OWynFeR9kKYr5UPET0S4RMYe+axK9GhUatbT9MtkJI0oT3gNkLWrEXNGDQ9qaAOeiaBWVmmGboxHimHBQkEO5RDgf72VQhJ2Vu8IXSjnhOA3rSPjsqIkXyJwzhg== 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 SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) by SA2PR10MB4555.namprd10.prod.outlook.com (2603:10b6:806:115::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16; Wed, 4 Aug 2021 17:55:09 +0000 Received: from SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632]) by SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632%5]) with mapi id 15.20.4394.016; Wed, 4 Aug 2021 17:55:09 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/7] ctfc: add function to lookup CTF ID of a TREE type Date: Wed, 4 Aug 2021 10:54:07 -0700 Message-Id: <20210804175411.6783-4-david.faust@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210804175411.6783-1-david.faust@oracle.com> References: <20210804175411.6783-1-david.faust@oracle.com> X-ClientProxiedBy: SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) To SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sequence.us.oracle.com (2606:b400:8004:44::1f) by SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17 via Frontend Transport; Wed, 4 Aug 2021 17:55:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a5d86e02-8a4c-48e0-26e8-08d95771000d X-MS-TrafficTypeDiagnostic: SA2PR10MB4555: 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: pBaTvBPIj+bYaRdXAzlDCYUIGbNppcCsQec6lygx6THYCZedqq39aQdcYijugve+GSiv8gTMlQmql0xcNl8X1H72QXxiEBCBKAw5CfJ6tmItckHo6ufERZ9F2/2ylBypRzmCIyMcPB3FR1zsHjyiLZIXXUcto4aTUXHqRSd7lIeu61AHJP7QfHcRa5VaVQ+0hTxN1UzBj9ae1wi+wNBZc6x80z2gtkYbLpRam7EoXPX4ZccOObYoMaq/OS5Qb1WbdmEMbx66WznMvztFthMGnmU83VExWZX7vNJsGOLdJRbCj9HJaA5s8dtvjTqdFJtyBwgzudahqK+aA5DU13jBsXRMgn1xF3UoJeseHZfVoLsz/vLleJpiAFGNI2nt/Q0lQBNdEIyrAWu7H5/14LO89iadp4GEOa+u8pmmTm3pkhBDupAqMrARAAXLJDoP1K7bsa9QkvBEX3ppk1w9smdRPPNrQ58KG/YWBuVXR6mUddw34NK3nImJDZjG8y8MTdhnNEnL6pbmtcwjSFVOLIRBVk1sog1wtncvhJDJuYpGe8YN+yYF7ShjxauFn6TaImLKI0fw1c0Ey8ryujX7BlQ9aGDKAYbhh3UEeMZvv/4vetiaJMYKFt5AT8IZ4y2GlO/nk8d3kcoo8ViqmIc5wDhSEw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4458.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6486002)(44832011)(316002)(8936002)(66476007)(66946007)(6916009)(83380400001)(66556008)(86362001)(5660300002)(8676002)(7696005)(38100700002)(52116002)(508600001)(36756003)(186003)(2906002)(1076003)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: m4YVWDbK0UnRGGSOGjD0tXBbRtqODANsUUEKhvL5WUApYiLVn/+3XK+KmyGqyPXtHnxOfsSSYQzLvxVE1I9CPXyYXFLMHGF+0MCm9kA1Oblhn+W+/s7KWGnvjg1YYBNP8fqgcztpHEXRbLv7V6h9Re9ymaUFCyUK5e43w4htQNd7GB/SOCNyv9ZJBFBDLWUgmTC45Zjao0+GohPqqmKW59Ipv3p5VATGeY6c8VQLepGlGMVzflejVkU1ybwG+ScqX0z+MyZbHEP2Jg5/XKUGkaBLxTt4dYQ2UxS0belPAAVPwLue2BlyjtR6vxfon+lfVJnQlDcANEx8qsCbQ+AzCSsEN/vyTrbe3AFM7h3ywyvNzAQLJhnVdAagvwQnZxLbd/eAiC1jhvWnU6GQocc3RVPtdhRJsOB8pky+hdz19mCtR0DvaqM97/Yd0Nwg9YV9cX6bLL25N3F9iM4T28j3bzYX1GjU6mCU7uP3m3A47vZ7ZFnhOFdN0KI/oR4kkSEAQS8Wo34yb/5SlEnaQtlsegF7fxi6vTlZYKKnTV7mMT6z+CIl5e3wxUhZLplFRmHt0lOA9TceHyZdnnNd6tuLtgZAnbrQbLnKbhShPdiLoGtxJ4caGRenolwK1MhBbYgUKoUlC4ApEuRm3nQJnu/32fEypT+4lFvzyY28edoNuKW5tpVPELDDNbjCr01Qa8vw9g5oibnAcFvNCAU9d44sSGHFASCa0WkkNm8YN6i+lBYClz6p3qOn+NNCEiRmmgSXdC1OkKHd1nDVaEmbeHDvcmEAERW/hkZtxFbw23DW+KqxnfHIMmIVE5YF52kNXl0eaL0fxfGYP6EDErXRkLTkV8SLzg90HiD05wQBK/yaLIudstZawgL0RtlZ0r+w+M82ENCajz7lWoJEqX7bg95hDVM2AyqjIQ9f30k5yLFj86UojokS0TljOFkr3dnbLq0+03ZGRwYtSv20l2WugGIwdyjRtDwUBvJmFBdSTzxZa3Le9G5RWn5FMxKIED/40T68lboECiRLC+vKkmw9UVXYsH6NtpsA/TcU6K8Jhyn7VMGwnW6pq1h7qTmYR5qcSECFG5LCSpfDlJMYNowPw5kRs5NEwhCqEePiFYLbJBxEeE+hhJ+bIiG2BNfw6Cdfd9thucHjCEbkotix9fI1j5WBez+j2PfrD/xeON54E8L24JdeRhKkp3Jn2ZJtDH2wYw6Weo0g8cJlNNIC0bInutXmEHpK1uKYfjPtHul0LpTFagpCDOCPlMuU+IlPXX7AKt1LGww45NFHbRpDJvbzoZdBIZGfleyRAd9Xs73X/CongJ2QwgpWPaimro6ZEQb6ciGnzlin0JmQF3/oNup0ujQD9A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5d86e02-8a4c-48e0-26e8-08d95771000d X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4458.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 17:55:09.5210 (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: lOZTSDm1h9OM+wV4acAYqtuxvHSbJZzoW3GqRq2HvwlEBeRTPHjzcyKsXcm6lPadEboYyxo8BLg5vU9ztyqzMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4555 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10066 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108040104 X-Proofpoint-GUID: 1cBmLIjPR2z47cPQ6HOIFEjbHGGVJgQP X-Proofpoint-ORIG-GUID: 1cBmLIjPR2z47cPQ6HOIFEjbHGGVJgQP X-Spam-Status: No, score=-11.8 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, RCVD_IN_MSPIKE_H2, 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: David Faust via Gcc-patches From: David Faust Reply-To: David Faust Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Add a new function, ctf_lookup_tree_type, to return the CTF type ID associated with a type via its is TREE node. The function is exposed via a prototype in ctfc.h. gcc/ChangeLog: * ctfc.c (ctf_lookup_tree_type): New function. * ctfc.h: Likewise. --- gcc/ctfc.c | 16 ++++++++++++++++ gcc/ctfc.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/gcc/ctfc.c b/gcc/ctfc.c index db6ba030301..73c118e3d49 100644 --- a/gcc/ctfc.c +++ b/gcc/ctfc.c @@ -791,6 +791,22 @@ ctf_add_sou (ctf_container_ref ctfc, uint32_t flag, const char * name, return type; } +/* Given a TREE_TYPE node, return the CTF type ID for that type. */ + +ctf_id_t +ctf_lookup_tree_type (ctf_container_ref ctfc, const tree type) +{ + dw_die_ref die = lookup_type_die (type); + if (die == NULL) + return CTF_NULL_TYPEID; + + ctf_dtdef_ref dtd = ctf_dtd_lookup (ctfc, die); + if (dtd == NULL) + return CTF_NULL_TYPEID; + + return dtd->dtd_type; +} + /* Check if CTF for TYPE has already been generated. Mainstay for de-duplication. If CTF type already exists, returns TRUE and updates the TYPE_ID for the caller. */ diff --git a/gcc/ctfc.h b/gcc/ctfc.h index 825570d807e..14180c1e5de 100644 --- a/gcc/ctfc.h +++ b/gcc/ctfc.h @@ -430,6 +430,8 @@ extern int ctf_add_function_arg (ctf_container_ref, dw_die_ref, extern int ctf_add_variable (ctf_container_ref, const char *, ctf_id_t, dw_die_ref, unsigned int); +extern ctf_id_t ctf_lookup_tree_type (ctf_container_ref, const tree); + /* CTF section does not emit location information; at this time, location information is needed for BTF CO-RE use-cases. */ From patchwork Wed Aug 4 17:54:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Faust X-Patchwork-Id: 1513583 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=u9hUVDe3; 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 4Gfzx52tzKz9sRR for ; Thu, 5 Aug 2021 03:58:00 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A11463951832 for ; Wed, 4 Aug 2021 17:57:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A11463951832 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628099878; bh=Sg9/kG1wyvIEMuYuI1NWbGc1vzQiBbFhEjZhmq6oPx4=; 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=u9hUVDe3AnCH7En/8rT8lGR0mBC4+YmGfAde9sVj0IqheN+YtczxFKoPz8Ju2HWoO cWL74tWgbhCjk2/V11f2C4vu8Y3iRRoSqSQpSyKPR3KS3Er+of3LJ3yXcaxCifCUgv 6sArNPa1tN304gEe7ASekEw+ALMpq+vnlbUYh4TA= 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 A9EAE3948A7B for ; Wed, 4 Aug 2021 17:55:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A9EAE3948A7B Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 174Hpj9V030516 for ; Wed, 4 Aug 2021 17:55:12 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3a7wqu8aex-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:12 +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 174HpUZu031193 for ; Wed, 4 Aug 2021 17:55:11 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by userp3030.oracle.com with ESMTP id 3a4un24yd8-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e4eQIr+7OWG55qiqXx3ucvspAOlyRDFqi3IFOQdyNSjsGG1YgwHzcR4qDA3ebbn8yFGPaq8EUhMsEpt347lGJYT224OG+OH66Hf8ECZ1T2QquN61KKMmIyz1nqNUA7TZ7YauYIKU4MThTYgpNFPr1ypZIJXTefeaXEhpg7iUgE0/JBgQxnWhmVVtBDUS0IkFsAR94ZtoAh3FMOXBbBRYehQtzzlIbnMN+bmgC3igRp/umEPx7OyBlL0Spgtfa0iJzhBydhEyNzDyfOXmCxvAxUXE4/fd1zwk7XBLL3iYoZ75qcC7haXw1PvepZqo08C4x+qVCJCKaKlF+lSMwQWXyA== 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=Sg9/kG1wyvIEMuYuI1NWbGc1vzQiBbFhEjZhmq6oPx4=; b=ZY6lwdaT/mG/c+EteVBYgk0hcEhL/nKv2M6vfsSGc7GM27rrCw1gxEGCxmjGr5kMr/bpagxDzbIa3QtPc0XHSLwVFx+d2v8YQogMQOl09lGJ7PzNIbu5Wt20CZShNIRnrsifVt7syuGRcRbJmncTaKAU/QVz9gjxJMhj0Qlg2T/pUcBLssHM0ohLGZRgk6qQpuSYSIpHDezUkecLCWOyq8kgZG2NyIkEttT+wD06pxEY5CkqyshqF3glabN4QOHjvVT+2wBWPQ+7PYL1z82aV3DTQ/OmLsIQKan9Q6Q5+sQrZ4TPcN7ZIaLGS6dVYrOElgSYQV0q5DyoLAFQhZ7VTg== 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 SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) by SA2PR10MB4555.namprd10.prod.outlook.com (2603:10b6:806:115::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16; Wed, 4 Aug 2021 17:55:10 +0000 Received: from SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632]) by SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632%5]) with mapi id 15.20.4394.016; Wed, 4 Aug 2021 17:55:10 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 4/7] btf: expose get_btf_id Date: Wed, 4 Aug 2021 10:54:08 -0700 Message-Id: <20210804175411.6783-5-david.faust@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210804175411.6783-1-david.faust@oracle.com> References: <20210804175411.6783-1-david.faust@oracle.com> X-ClientProxiedBy: SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) To SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sequence.us.oracle.com (2606:b400:8004:44::1f) by SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17 via Frontend Transport; Wed, 4 Aug 2021 17:55:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3724deaa-dd48-4c43-10eb-08d957710075 X-MS-TrafficTypeDiagnostic: SA2PR10MB4555: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EWWQ1/7tSk/qQDW5qoLjNRrPKYTxUOC4FUyEoZyVF9bzDGQ9dB2XxBcFke0uXRQC/HW2I/i6SemRoZ5i5K/+XRLaFJp4WoEvhuvRAhDMTJFzMu9m7Vr4l64RuMUwwdW40lC5SKz3KwL5M8JNILR/nQExN46aMzXuScd+e9O+yv49zRIpbv1MdkSxKyeWut2TRCEMzEWtGkTUoOMhHrbebtNGKoCb26r4st5PKmd/fXY/8BI4rGbtgZY3xpcPcrC2VccLXrVSEVhdTiQvvCocpvb5ybeQsImZRIQTvb19WRRy4zGuvU/DSLWkOQv4ksuZRHWLAswMWPb4V4HLkY85InWjRrlettT/+DwC9jWTaYmN+S+q0X3wzeR5DAQhxCuPD4kcoJP+k6XGIkQxP04eBVZeV/tOe9afvPWoeY3wXGs/Sx6KNKysqYCMi3cfYka7qv7+EoZONyvYRRxSeQWoBTMpanp26vAAqhcjPNl/Xns4/lG+dEN+QkJoxV1ZhRPNqBEaMUN88r7RqFpCmBQi9pshtTwQ50sNN7yUJslUzHpdEi08jaQfyjZOjP3EgZrI5rTP3dJ1+lJFTC/fsPSJaVS+2Wd4CdvSSgBIVhmKLQ/x1xvId9pQeUTo6YsB0AMqguOR3zoFwTwCiYFDX4jyKg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4458.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6486002)(44832011)(316002)(8936002)(66476007)(66946007)(6916009)(83380400001)(66556008)(86362001)(5660300002)(8676002)(7696005)(38100700002)(52116002)(508600001)(36756003)(186003)(2906002)(1076003)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dA4HLCDOALV9ACaKHz6aaLlfi20CXKk84R9S7NeBETTEt3SEn5Y2WBO2Iwb8v+kJlFAJ54DAR2/soltYHEnnzfnhfnTfU/dtijFVeyid2oYTOhSas01MbhRkHLx+j8cZqaPNpeDHcxaFlVq5HPe4JsFCHIfy9z69lLAeuP2k+i3Ym+BoXFxHnH0x6XbGZYNNs/vltOgjRPdyuxeQoIrMLz4pHDkqB9l1Z+s4WxeRP7yCHeItEgNWxMI3hXZGm5KYyAiZZXuHdNCsVLCOyurfmJNZu7CeOYdWYTSoFYZLYREgreji8lTnPLbDnu7GyDhMsIi3R9iThv5ipl51bBB+zkgJ0eol9gL56w4xDfOPhLhRebbabPKEeTC6ISM+FKOfmlfQPjfF3jvl3Dj6uFLRw+gV6Xys3HdENlBQQwETfKwCjFwFvq0Jp9nAZYRTTAuNPvYLLoL3waYynFTDKF4mVio0SlpkoJ2ah4KkG4ndBnu52fdh/lIEnwnTMWaEQNHId5a4DuvTP+ohNHTUHdNiFY4lJlnHd7OQ+m7rXGn3+UPRAHbQ/+JASqJqX+JwBl2Fyon5Y8wfnfQhA4g8AjtQHdYhWERNtGRdURhwS8KhbS1hc6EH5ZUlVyZdJci3z46z16mDq+hL2SUbxgU+RBHt19XE4TA5vbVs3a6egFkjplmNbggEdUbjUmgpIQh1HrTv17F3qh6tF8UtMF/Up2vzozT/PeKTv58RlkO1KtItsgszRa5EkZttEuTp7nvByidh5F8exrwsZeszyzotSO0UQpvEN+gVmqTFhdq2lB5a/zUDRdLX0qpgiSA7oKh+EsDWMEndqc4QwrjjNVR6u/zTcql7Q1kaFXiIXToxptwrSGLOTx/lPnqTmeaWs0GFEhREN4HH6izjGagHMj5Tgra+5noF3MESkoOz2d3oDd2YkF77mZqLmGRUdqfrylU7f/AY+jb0NLi+4J/UOIHIhLP6OEq+uk5S1JsTiY22DTvtCFQEXwiEHvlhFbh055UZ+uh4N5yYGmtoIzxf5hNwnEvd6v5qUAX0lMlJEyiDaZdpJiDgZG5kBRyn5u8LvgViwgE2b+1vb64Fm4RcrHekdAkVrcWW7+RNWwypJJ/tfJANSiV+kGA+QdY0kU54sPLK+UbuEX+IxtIPmqIlzbTmJ8x2I0M/mPGzEJScR9J/ecCAWsnfrMg9WVHy5kR/R57y1vAt3A6OgJiSeJmUcT8MrSWzui+7d3UQ2+WY8qtII2fjrgTr/9PylviVI03FmjJxW8z9q4ybbFOeVAa+VxqJsiCtAlFUrJ5A8k70AFaN7HhCoqPcYxoz9692gjh76POdBpZixupHiOws66TqWfhddaHMzw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3724deaa-dd48-4c43-10eb-08d957710075 X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4458.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 17:55:10.1871 (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: 2S58i1xt3cRuSNSwu+B3VeOuZkIOFC5UrUnJlE8P84bHlOfq4+JRNdr3VGzyYODanDLiIHWvRoFyt7rSMAcCng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4555 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10066 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 mlxlogscore=985 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108040104 X-Proofpoint-GUID: FAXW0OTVuvFe0vLUiOzWvNMRJIT4z0N2 X-Proofpoint-ORIG-GUID: FAXW0OTVuvFe0vLUiOzWvNMRJIT4z0N2 X-Spam-Status: No, score=-12.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, RCVD_IN_MSPIKE_H2, 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: David Faust via Gcc-patches From: David Faust Reply-To: David Faust Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Expose the function get_btf_id, so that it may be used by the BPF backend. This enables the BPF CO-RE machinery in the BPF backend to lookup BTF type IDs, in order to create CO-RE relocation records. A prototype is added in ctfc.h gcc/ChangeLog: * btfout.c (get_btf_id): Function is no longer static. * ctfc.h: Expose it here. --- gcc/btfout.c | 2 +- gcc/ctfc.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/btfout.c b/gcc/btfout.c index 8cdd9905fb6..cdc6c6378c0 100644 --- a/gcc/btfout.c +++ b/gcc/btfout.c @@ -156,7 +156,7 @@ init_btf_id_map (size_t len) /* Return the BTF type ID of CTF type ID KEY, or BTF_INVALID_TYPEID if the CTF type with ID KEY does not map to a BTF type. */ -static inline ctf_id_t +ctf_id_t get_btf_id (ctf_id_t key) { return btf_id_map[key]; diff --git a/gcc/ctfc.h b/gcc/ctfc.h index 14180c1e5de..a0b7e4105a8 100644 --- a/gcc/ctfc.h +++ b/gcc/ctfc.h @@ -431,6 +431,7 @@ extern int ctf_add_variable (ctf_container_ref, const char *, ctf_id_t, dw_die_ref, unsigned int); extern ctf_id_t ctf_lookup_tree_type (ctf_container_ref, const tree); +extern ctf_id_t get_btf_id (ctf_id_t); /* CTF section does not emit location information; at this time, location information is needed for BTF CO-RE use-cases. */ From patchwork Wed Aug 4 17:54:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Faust X-Patchwork-Id: 1513592 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=JTU6/YGY; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.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 4Gg03Z3HT7z9sRR for ; Thu, 5 Aug 2021 04:03:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 305EA3952513 for ; Wed, 4 Aug 2021 18:03:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 305EA3952513 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628100216; bh=Ro15moxFSgGmBt6c4OZZZYXbhULdpOd5KTuA46R3Qis=; 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=JTU6/YGY2dGYXAY59Jt/DVtxCVBTvewDxdYMzGiC5O1J4ZtbzhIDs74bHFtCUrQGZ MZGJwA2eD7YpKxc9Xntodco3B+j9cCzV6xqu0tFvijkeYFKzeVlLxQ7xJHzfBRvCD1 Kx8fA9ZwEck2m334NyaJFEfmglWVy8U4mYH0XnPE= 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 CE8493951429 for ; Wed, 4 Aug 2021 17:55:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CE8493951429 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 174Hpj9W030516 for ; Wed, 4 Aug 2021 17:55:14 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a7wqu8aey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:14 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 174Ho9XA010600 for ; Wed, 4 Aug 2021 17:55:13 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by aserp3030.oracle.com with ESMTP id 3a78d74b4r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a8jyQq4FjIRoK+s1MuFHtRHXAIEgO1oM9dEUP1mb0h5YMGSHHr8hB+0XlfK4MpGlSataMPnlkW7I1P2cQN8+6ITYdkX30BZKATudKInBteZD8jNGwwKwymkRraVEpPNqR99k6rHjY9zCWwM/Dt7Mg51lRcdSXADdiUMABHJ+b+Kp2DgfpXKXs2yF+o9mFsSOxpvzZ3m9+lwZG4k66pcuN3lNJUzENCGdRh2pJ/5ZrkKGcbU4VnxAq7wO2qSKODpF4Hw/8Bb0/EJY4OE45CmhnO+kOOrRdYQoSy7EFDpqGFj5ne91LNfLH6kqVJ3/WmJkkXaQshQ3SrF5f9xjGT2CcQ== 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=Ro15moxFSgGmBt6c4OZZZYXbhULdpOd5KTuA46R3Qis=; b=F1BrOvhs1UlGSP7rHqG7YDzheHz6wNiUJAklvj6Tekj6b9r+yB5s4+2dqQuTLSZyk8KMizAdsja48Tdtg8KIgZ6a8Lu64aYiNGW2eNEZBuNeDMG03RECZGWKOKID0iWB8roG/n6RfRg94ATEfAqX1FJhmzeti/IWO82W6DoEJWyDBW1vcYuacX2KJdoOv7ka3VZgUdm2/pghLc6ulcuQHSfSzxQl5J6kkrqIrVbzsDDiNKjeqMCzVQeyLxxoLSwbexnmD5US4spWpn7rFodZfoi9WpH2/QHliCCXDbT8Hv7qaR0Rw2j34PcfJ7Y/sGrpgoFKWHRD5zHvrM2fMfRQeQ== 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 SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) by SA2PR10MB4555.namprd10.prod.outlook.com (2603:10b6:806:115::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16; Wed, 4 Aug 2021 17:55:11 +0000 Received: from SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632]) by SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632%5]) with mapi id 15.20.4394.016; Wed, 4 Aug 2021 17:55:11 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 5/7] bpf: BPF CO-RE support Date: Wed, 4 Aug 2021 10:54:09 -0700 Message-Id: <20210804175411.6783-6-david.faust@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210804175411.6783-1-david.faust@oracle.com> References: <20210804175411.6783-1-david.faust@oracle.com> X-ClientProxiedBy: SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) To SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sequence.us.oracle.com (2606:b400:8004:44::1f) by SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17 via Frontend Transport; Wed, 4 Aug 2021 17:55:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c27b519b-b6f2-4e4a-f10d-08d9577100d9 X-MS-TrafficTypeDiagnostic: SA2PR10MB4555: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jvBNIhfyXIOOn6A5CODEB7NI6eKvhSKwVCGamQ+a79gPOFigu38LbT7GXkKKOSSY9P7kfJdRWLOiWXbSRYWHdw7islkZt8xumQapzErMr8Whg+j37KRDAJUCX/rAzXCsljIdSEC1w7+yOeWG94jSLQCkyNJXlPZ31MwRIYQ0kOsAIzDG3qXyPyqiWLclydBUYE98Tvz0XRsFe+iFsobJk5NLpWIaTeKGNrMk6cZdUC9gY26Uq75MLpI5uiAq9jtdKxVaT8N8Z3Hdxq65tX62AkboDZTn/PH9HopMxj4K/XxvGOqIUn4bX1MIEWlU7O4ZqGjLR06kuIQE1aMo9rJCwDu0uxIAJ/nyoydlf1g2Wx/eFk3TE0PxrVAc3RrRcEipuuWm74z9XFK0O+/d2o3RpC4J0Sp67tvS9iYAQwWWheA/4f9BMml01qLgjVfYlAC63F28lu/9Sjj5eFI6UEnjFD6IC8OyHnAYdtLcYmx8xEWx8vRJAkTfIo2eAr7RJduD/5xmeD0wzWmUtUCA+AAzaCCEvgaEgrj3nN9PQcLaqU9lqPYr6c8F7wBRxK1dw9T1YMmnxcUv4G/C6kLmPqlbzL6iiRlFCJeCrAfPj6yx8PPzgjYUYoUp4xn8tCypDgPAavr6WlGBDyzPkzurci49GNWPABZCGnzGq2sPN7UrGnfLenI+wIgr9sjCgsFchDVL+tv1v3xPjLNQE9bM661Hq18qMRBmHAy6S+fxAIl1ZpHxqv3xE/ei0LQZsQoKLOiZQHppom53ojB6+cCsV4z8Qg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4458.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6486002)(44832011)(316002)(8936002)(66476007)(66946007)(6916009)(30864003)(83380400001)(66556008)(86362001)(5660300002)(8676002)(7696005)(38100700002)(52116002)(508600001)(36756003)(186003)(2906002)(1076003)(2616005)(2004002)(579004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QJMBzNzYRSzyr+EpYtSYAM0bLxhOHFo2k8N5KYAXM+W3a3BZ/73fF1Vb13LpdpFDI9q5+exKbqJOM/zeCvQ0SjWWBAxaArAz0ip8FY3AKxvcJnSYSol5bXLQkL3YBx4Itf1S1FXMCyWEUa8AnSl/t94kpKs0tNXp7pLBfMjw1Edn0ZdgkzThfHevU8iA09CnOjShsCoua8fnyf+0sqM6WITP6fdhkfzmHUnjbEz6ZXk40IIlRBNGVKsK+M/p2I3ci52zlfMU48DVVNl026S1rH1zqrilWvkRsGBk+eF+ZLuyE3zNDoPfdXY9/FXZYZo7cHnYEabQUxwo5dr1/AlBgIi7ZE51IUHGHeIUkJicjqKKnArv0BamtSjBxgKBP1LhZecgl5bieOw0UxRdR41SZxHStJsCe/ASFJ1hrbvvVEkccTZyHrAzMr53FmKLcVmV2CMt0wAcA15VsdMljK1x3ikZMzWyHBU62oExflQJc1M9ltjxKWjgdHLXLEmcHIlSE02Y2E4YbHZkG+JKjXBEfhJyZm89QdX1uJgGrwERvUdcnO1yFxpkYWAvRmIVF5/PKwxNawWWS4r7nUQY+J4RqiDcKKOYspMCkKI0twwChm1zhLbJSx+7Sfk6VJrwPijkXoB+eXAAZ0/2HLGhxz8NLgV24RMtqGDm+ExZGmzIDn153JGl0xXTVz6xj7knfUPrnOJIpksxi/kmV8+2EgSiDNPB1c492RxfMND7oYzJs6J2uAZqex8gcCorm3BNY/XCa0PnBGXDUPfSN5pp8Crb9Da3oYKY30TKlWrDviOwdcat/NfGinok6VpG8braFBOLzXEYLCggMdG2Oq690/QWKYFl8gwpHO/+K6jOxNOkZ8iH4kkacFQ5ltYONl8eDlnAxh6pEamemjmjZlyCvTVRVKz9L6QMCDmmGKJnhpCAkPFnUXvi8CvGtjiit+U9coS9yp+zxtjgq+XIbQMSWo7DbK0AzBSy33r/YTz/BUtkTo2pMHaKSe4z4UMwHeflyQ9O9d0U73InSQs+xxy2R/mQBn267mhLmKRbbfo6jtt1sbfx8f7v/Ipme/UpouqUXTnlI+0Gn+kIdMGYNnCD5jAB5wBTD75tDrBZXisDsczAbaesYbdqBzW6QnM/ITqI4pn2gbY24vr1Yk4XsxrwM5NBEed0CUybdxOU51uSrbn1m6mcB8xZaJIaw+UT19gsvv9JxLn65zVYrnycXXkHVaZSKxSiCvGYoiCdLHBi4DO56zjRnHQa5abyIlAyXkZF7XqfUZayNgPWvZH5XpY+aEHDC792t3uzY43wgrcJJUV/a+iHksE9uyrPNUkJzNswv3RmCGEGM7emKKiYD+zD7u2yEg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c27b519b-b6f2-4e4a-f10d-08d9577100d9 X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4458.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 17:55:10.9846 (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: BAhQgOYkiNKlstfi7qFS46v6RxIaHjlAV/j2eGc5HAA2jqb5cnNZZYbaYHqCJ1JRyl79sMTcXjPN67U6C4irGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4555 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10066 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108040104 X-Proofpoint-GUID: xq15cXWz02UEpj7Ne8a_DiTMu6p60FhL X-Proofpoint-ORIG-GUID: xq15cXWz02UEpj7Ne8a_DiTMu6p60FhL X-Spam-Status: No, score=-12.5 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, RCVD_IN_MSPIKE_H2, 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: David Faust via Gcc-patches From: David Faust Reply-To: David Faust Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This commit introduces support for BPF Compile Once - Run Everywhere (CO-RE) in GCC. gcc/ChangeLog: * config/bpf/bpf.c: Adjust includes. (bpf_handle_preserve_access_index_attribute): New function. (bpf_attribute_table): Use it here. (bpf_builtins): Add BPF_BUILTIN_PRESERVE_ACCESS_INDEX. (bpf_option_override): Handle "-mcore" option. (bpf_asm_init_sections): New. (TARGET_ASM_INIT_SECTIONS): Redefine. (bpf_file_end): New. (TARGET_ASM_FILE_END): Redefine. (bpf_init_builtins): Add "__builtin_preserve_access_index". (bpf_core_compute, bpf_core_get_index): New. (is_attr_preserve_access): New. (bpf_expand_builtin): Handle new builtins. (bpf_core_newdecl, bpf_core_is_maybe_aggregate_access): New. (bpf_core_walk): New. (bpf_resolve_overloaded_builtin): New. (TARGET_RESOLVE_OVERLOADED_BUILTIN): Redefine. (handle_attr): New. (pass_bpf_core_attr): New RTL pass. * config/bpf/bpf-passes.def: New file. * config/bpf/bpf-protos.h (make_pass_bpf_core_attr): New. * config/bpf/coreout.c: New file. * config/bpf/coreout.h: Likewise. * config/bpf/t-bpf (TM_H): Add $(srcdir)/config/bpf/coreout.h. (coreout.o): New rule. (PASSES_EXTRA): Add $(srcdir)/config/bpf/bpf-passes.def. * config.gcc (bpf): Add coreout.h to extra_headers. Add coreout.o to extra_objs. Add $(srcdir)/config/bpf/coreout.c to target_gtfiles. --- gcc/config.gcc | 3 + gcc/config/bpf/bpf-passes.def | 20 ++ gcc/config/bpf/bpf-protos.h | 2 + gcc/config/bpf/bpf.c | 579 ++++++++++++++++++++++++++++++++++ gcc/config/bpf/coreout.c | 356 +++++++++++++++++++++ gcc/config/bpf/coreout.h | 114 +++++++ gcc/config/bpf/t-bpf | 8 + 7 files changed, 1082 insertions(+) create mode 100644 gcc/config/bpf/bpf-passes.def create mode 100644 gcc/config/bpf/coreout.c create mode 100644 gcc/config/bpf/coreout.h diff --git a/gcc/config.gcc b/gcc/config.gcc index 93e2b3219b9..6c790ce1b35 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1515,6 +1515,9 @@ bpf-*-*) use_collect2=no extra_headers="bpf-helpers.h" use_gcc_stdint=provide + extra_headers="coreout.h" + extra_objs="coreout.o" + target_gtfiles="$target_gtfiles \$(srcdir)/config/bpf/coreout.c" ;; cr16-*-elf) tm_file="elfos.h ${tm_file} newlib-stdint.h" diff --git a/gcc/config/bpf/bpf-passes.def b/gcc/config/bpf/bpf-passes.def new file mode 100644 index 00000000000..3e961659411 --- /dev/null +++ b/gcc/config/bpf/bpf-passes.def @@ -0,0 +1,20 @@ +/* Declaration of target-specific passes for eBPF. + Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +INSERT_PASS_AFTER (pass_df_initialize_opt, 1, pass_bpf_core_attr); diff --git a/gcc/config/bpf/bpf-protos.h b/gcc/config/bpf/bpf-protos.h index aeb512665ed..7ce3386ffda 100644 --- a/gcc/config/bpf/bpf-protos.h +++ b/gcc/config/bpf/bpf-protos.h @@ -30,4 +30,6 @@ extern void bpf_print_operand_address (FILE *, rtx); extern void bpf_expand_prologue (void); extern void bpf_expand_epilogue (void); +rtl_opt_pass * make_pass_bpf_core_attr (gcc::context *); + #endif /* ! GCC_BPF_PROTOS_H */ diff --git a/gcc/config/bpf/bpf.c b/gcc/config/bpf/bpf.c index 85f6b76a11f..5edc8cc715a 100644 --- a/gcc/config/bpf/bpf.c +++ b/gcc/config/bpf/bpf.c @@ -54,6 +54,25 @@ along with GCC; see the file COPYING3. If not see #include "builtins.h" #include "predict.h" #include "langhooks.h" +#include "flags.h" + +#include "cfg.h" /* needed for struct control_flow_graph used in BB macros */ +#include "gimple.h" +#include "gimple-iterator.h" +#include "gimple-walk.h" +#include "tree-pass.h" +#include "tree-iterator.h" + +#include "context.h" +#include "pass_manager.h" + +#include "gimplify.h" +#include "gimplify-me.h" + +#include "ctfc.h" +#include "btf.h" + +#include "coreout.h" /* Per-function machine data. */ struct GTY(()) machine_function @@ -104,6 +123,27 @@ bpf_handle_fndecl_attribute (tree *node, tree name, return NULL_TREE; } +/* Handle preserve_access_index attribute, which can be applied to structs, + unions and classes. Actually adding the attribute to the TYPE_DECL is + taken care of for us, so just warn for types that aren't supported. */ + +static tree +bpf_handle_preserve_access_index_attribute (tree *node, tree name, + tree args, + int flags, + bool *no_add_attrs) +{ + if (TREE_CODE (*node) != RECORD_TYPE && TREE_CODE (*node) != UNION_TYPE) + { + warning (OPT_Wattributes, + "%qE attribute only applies to structure, union and class types", + name); + *no_add_attrs = true; + } + + return NULL_TREE; +} + /* Target-specific attributes. */ static const struct attribute_spec bpf_attribute_table[] = @@ -116,6 +156,11 @@ static const struct attribute_spec bpf_attribute_table[] = { "kernel_helper", 1, 1, true, false, false, false, bpf_handle_fndecl_attribute, NULL }, + /* CO-RE support: attribute to mark that all accesses to the declared + struct/union/array should be recorded. */ + { "preserve_access_index", 0, -1, false, true, false, true, + bpf_handle_preserve_access_index_attribute, NULL }, + /* The last attribute spec is set to be NULL. */ { NULL, 0, 0, false, false, false, false, NULL, NULL } }; @@ -136,11 +181,18 @@ enum bpf_builtins BPF_BUILTIN_LOAD_BYTE, BPF_BUILTIN_LOAD_HALF, BPF_BUILTIN_LOAD_WORD, + + /* Compile Once - Run Everywhere (CO-RE) support. */ + BPF_BUILTIN_PRESERVE_ACCESS_INDEX, + BPF_BUILTIN_MAX, }; static GTY (()) tree bpf_builtins[(int) BPF_BUILTIN_MAX]; + +void bpf_register_coreattr_pass (void); + /* Initialize the per-function machine status. */ static struct machine_function * @@ -173,6 +225,15 @@ bpf_option_override (void) if (flag_lto && TARGET_BPF_CORE) error ("BPF CO-RE does not support LTO"); + + /* 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%>"); + + /* -gbtf implies -mcore when using the BPF backend, unless -mno-core + is specified. */ + if (btf_debuginfo_p () && !(target_flags_explicit & MASK_BPF_CORE)) + target_flags |= MASK_BPF_CORE; } #undef TARGET_OPTION_OVERRIDE @@ -192,6 +253,30 @@ ctfc_debuginfo_early_finish_p (void) #undef TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P #define TARGET_CTFC_DEBUGINFO_EARLY_FINISH_P ctfc_debuginfo_early_finish_p +/* Implement TARGET_ASM_INIT_SECTIONS. */ + +static void +bpf_asm_init_sections (void) +{ + if (TARGET_BPF_CORE) + btf_ext_init (); +} + +#undef TARGET_ASM_INIT_SECTIONS +#define TARGET_ASM_INIT_SECTIONS bpf_asm_init_sections + +/* Implement TARGET_ASM_FILE_END. */ + +static void +bpf_file_end (void) +{ + if (TARGET_BPF_CORE) + btf_ext_output (); +} + +#undef TARGET_ASM_FILE_END +#define TARGET_ASM_FILE_END bpf_file_end + /* Define target-specific CPP macros. This function in used in the definition of TARGET_CPU_CPP_BUILTINS in bpf.h */ @@ -841,11 +926,18 @@ bpf_init_builtins (void) build_function_type_list (ullt, ullt, 0)); def_builtin ("__builtin_bpf_load_word", BPF_BUILTIN_LOAD_WORD, build_function_type_list (ullt, ullt, 0)); + def_builtin ("__builtin_preserve_access_index", + BPF_BUILTIN_PRESERVE_ACCESS_INDEX, + build_function_type_list (ptr_type_node, ptr_type_node, 0)); } #undef TARGET_INIT_BUILTINS #define TARGET_INIT_BUILTINS bpf_init_builtins +static tree bpf_core_compute (tree, vec *); +static int bpf_core_get_index (const tree); +static bool is_attr_preserve_access (tree); + /* Expand a call to a BPF-specific built-in function that was set up with bpf_init_builtins. */ @@ -896,7 +988,75 @@ bpf_expand_builtin (tree exp, rtx target ATTRIBUTE_UNUSED, /* The result of the load is in R0. */ return gen_rtx_REG (ops[0].mode, BPF_R0); } + else if (code == -1) + { + /* A resolved overloaded builtin, e.g. __bpf_preserve_access_index_si */ + tree arg = CALL_EXPR_ARG (exp, 0); + + if (arg == NULL_TREE) + return NULL_RTX; + + auto_vec accessors; + tree container; + + if (TREE_CODE (arg) == SSA_NAME) + { + gimple *def_stmt = SSA_NAME_DEF_STMT (arg); + + if (is_gimple_assign (def_stmt)) + arg = gimple_assign_rhs1 (def_stmt); + else + return expand_normal (arg); + } + + /* Avoid double-recording information if the argument is an access to + a struct/union marked __attribute__((preserve_access_index)). This + Will be handled by the attribute handling pass. */ + if (is_attr_preserve_access (arg)) + return expand_normal (arg); + + container = bpf_core_compute (arg, &accessors); + + /* Any valid use of the builtin must have at least one access. Otherwise, + there is nothing to record and nothing to do. This is primarily a + guard against optimizations leading to unexpected expressions in the + argument of the builtin. For example, if the builtin is used to read + a field of a structure which can be statically determined to hold a + constant value, the argument to the builtin will be optimized to that + constant. This is OK, and means the builtin call is superfluous. + e.g. + struct S foo; + foo.a = 5; + int x = __preserve_access_index (foo.a); + ... do stuff with x + 'foo.a' in the builtin argument will be optimized to '5' with -01+. + This sequence does not warrant recording a CO-RE relocation. */ + + if (accessors.length () < 1) + return expand_normal (arg); + + accessors.reverse (); + + container = TREE_TYPE (container); + + rtx_code_label *label = gen_label_rtx (); + LABEL_PRESERVE_P (label) = 1; + emit_label (label); + + /* Determine what output section this relocation will apply to. + If this function is associated with a section, use that. Otherwise, + fall back on '.text'. */ + const char * section_name; + if (current_function_decl && DECL_SECTION_NAME (current_function_decl)) + section_name = DECL_SECTION_NAME (current_function_decl); + else + section_name = ".text"; + + /* Add the CO-RE relocation information to the BTF container. */ + bpf_core_reloc_add (container, section_name, &accessors, label); + return expand_normal (arg); + } gcc_unreachable (); } @@ -950,6 +1110,425 @@ bpf_debug_unwind_info () #undef TARGET_ASM_ALIGNED_DI_OP #define TARGET_ASM_ALIGNED_DI_OP "\t.dword\t" + +/* BPF Compile Once - Run Everywhere (CO-RE) support routines. + + BPF CO-RE is supported in two forms: + - A target builtin, __builtin_preserve_access_index + + This builtin accepts a single argument. Any access to an aggregate data + structure (struct, union or array) within the argument will be recorded by + the CO-RE machinery, resulting in a relocation record being placed in the + .BTF.ext section of the output. + + It is implemented in bpf_resolve_overloaded_builtin () and + bpf_expand_builtin (), using the supporting routines below. + + - An attribute, __attribute__((preserve_access_index)) + + This attribute can be applied to struct and union types. Any access to a + type with this attribute will be recorded by the CO-RE machinery. + + The pass pass_bpf_core_attr, below, implements support for + this attribute. */ + +/* Traverse the subtree under NODE, which is expected to be some form of + aggregate access the CO-RE machinery cares about (like a read of a member of + a struct or union), collecting access indices for the components and storing + them in the vector referenced by ACCESSORS. + + Return the ultimate (top-level) container of the aggregate access. In general, + this will be a VAR_DECL or some kind of REF. + + Note that the accessors are computed *in reverse order* of how the BPF + CO-RE machinery defines them. The vector needs to be reversed (or simply + output in reverse order) for the .BTF.ext relocation information. */ + +static tree +bpf_core_compute (tree node, vec *accessors) +{ + + if (TREE_CODE (node) == ADDR_EXPR) + node = TREE_OPERAND (node, 0); + + else if (TREE_CODE (node) == INDIRECT_REF + || TREE_CODE (node) == POINTER_PLUS_EXPR) + { + accessors->safe_push (0); + return TREE_OPERAND (node, 0); + } + + while (1) + { + switch (TREE_CODE (node)) + { + case COMPONENT_REF: + accessors->safe_push (bpf_core_get_index (TREE_OPERAND (node, 1))); + break; + + case ARRAY_REF: + case ARRAY_RANGE_REF: + accessors->safe_push (bpf_core_get_index (node)); + break; + + case MEM_REF: + accessors->safe_push (bpf_core_get_index (node)); + if (TREE_CODE (TREE_OPERAND (node, 0)) == ADDR_EXPR) + node = TREE_OPERAND (TREE_OPERAND (node, 0), 0); + goto done; + + default: + goto done; + } + node = TREE_OPERAND (node, 0); + } + done: + return node; + +} + +/* Compute the index of the NODE in its immediate container. + NODE should be a FIELD_DECL (i.e. of struct or union), or an ARRAY_REF. */ +static int +bpf_core_get_index (const tree node) +{ + enum tree_code code = TREE_CODE (node); + + if (code == FIELD_DECL) + { + /* Lookup the index from the BTF information. Some struct/union members + may not be emitted in BTF; only the BTF container has enough + information to compute the correct index. */ + int idx = bpf_core_get_sou_member_index (ctf_get_tu_ctfc (), node); + if (idx >= 0) + return idx; + } + + else if (code == ARRAY_REF || code == ARRAY_RANGE_REF || code == MEM_REF) + { + /* For array accesses, the index is operand 1. */ + tree index = TREE_OPERAND (node, 1); + + /* If the indexing operand is a constant, extracting is trivial. */ + if (TREE_CODE (index) == INTEGER_CST && tree_fits_shwi_p (index)) + return tree_to_shwi (index); + } + + return -1; +} + +/* Synthesize a new builtin function declaration at LOC with signature TYPE. + Used by bpf_resolve_overloaded_builtin to resolve calls to + __builtin_preserve_access_index. */ + +static tree +bpf_core_newdecl (location_t loc, tree type) +{ + tree rettype = build_function_type_list (type, type, NULL); + tree newdecl = NULL_TREE; + char name[80]; + int len = snprintf (name, sizeof (name), "%s", "__builtin_pai_"); + + static unsigned long cnt = 0; + len = snprintf (name + len, sizeof (name) - len, "%lu", cnt++); + + return add_builtin_function_ext_scope (name, rettype, -1, BUILT_IN_MD, NULL, + NULL_TREE); +} + +/* Return whether EXPR could access some aggregate data structure that + BPF CO-RE support needs to know about. */ + +static int +bpf_core_is_maybe_aggregate_access (tree expr) +{ + enum tree_code code = TREE_CODE (expr); + if (code == COMPONENT_REF || code == ARRAY_REF) + return 1; + + if (code == ADDR_EXPR) + return bpf_core_is_maybe_aggregate_access (TREE_OPERAND (expr, 0)); + + return 0; +} + +/* Callback function used with walk_tree from bpf_resolve_overloaded_builtin. */ + +static tree +bpf_core_walk (tree *tp, int *walk_subtrees, void *data) +{ + location_t loc = *((location_t *) data); + + /* If this is a type, don't do anything. */ + if (TYPE_P (*tp)) + { + *walk_subtrees = 0; + return NULL_TREE; + } + + if (bpf_core_is_maybe_aggregate_access (*tp)) + { + tree newdecl = bpf_core_newdecl (loc, TREE_TYPE (*tp)); + tree newcall = build_call_expr_loc (loc, newdecl, 1, *tp); + *tp = newcall; + *walk_subtrees = 0; + } + + return NULL_TREE; +} + + +/* Implement TARGET_RESOLVE_OVERLOADED_BUILTIN (see gccint manual section + Target Macros::Misc.). + We use this for the __builtin_preserve_access_index builtin for CO-RE + support. + + FNDECL is the declaration of the builtin, and ARGLIST is the list of + arguments passed to it, and is really a vec *. + + In this case, the 'operation' implemented by the builtin is a no-op; + the builtin is just a marker. So, the result is simply the argument. */ + +static tree +bpf_resolve_overloaded_builtin (location_t loc, tree fndecl, void *arglist) +{ + if (DECL_MD_FUNCTION_CODE (fndecl) != BPF_BUILTIN_PRESERVE_ACCESS_INDEX) + return NULL_TREE; + + /* We only expect one argument, but it may be an arbitrarily-complicated + statement-expression. */ + vec *params = static_cast *> (arglist); + unsigned n_params = params ? params->length() : 0; + + if (n_params != 1) + { + error_at (loc, "expected exactly 1 argument"); + return NULL_TREE; + } + + tree param = (*params)[0]; + + /* If not generating BPF_CORE information, the builtin does nothing. */ + if (!TARGET_BPF_CORE) + return param; + + /* Do remove_c_maybe_const_expr for the arg. + TODO: WHY do we have to do this here? Why doesn't c-typeck take care + of it before or after this hook? */ + if (TREE_CODE (param) == C_MAYBE_CONST_EXPR) + param = C_MAYBE_CONST_EXPR_EXPR (param); + + /* Construct a new function declaration with the correct type, and return + a call to it. + + Calls with statement-expressions, for example: + _(({ foo->a = 1; foo->u[2].b = 2; })) + require special handling. + + We rearrange this into a new block scope in which each statement + becomes a unique builtin call: + { + _ ({ foo->a = 1;}); + _ ({ foo->u[2].b = 2;}); + } + + This ensures that all the relevant information remains within the + expression trees the builtin finally gets. */ + + walk_tree (¶m, bpf_core_walk, (void *) &loc, NULL); + + return param; +} + +#undef TARGET_RESOLVE_OVERLOADED_BUILTIN +#define TARGET_RESOLVE_OVERLOADED_BUILTIN bpf_resolve_overloaded_builtin + + +/* Handling for __attribute__((preserve_access_index)) for BPF CO-RE support. + + This attribute marks a structure/union/array type as "preseve", so that + every access to that type should be recorded and replayed by the BPF loader; + this is just the same functionality as __builtin_preserve_access_index, + but in the form of an attribute for an entire aggregate type. + + Note also that nested structs behave as though they all have the attribute. + For example: + struct X { int a; }; + struct Y { struct X bar} __attribute__((preserve_access_index)); + struct Y foo; + foo.bar.a; + will record access all the way to 'a', even though struct X does not have + the preserve_access_index attribute. + + This is to follow LLVM behavior. + + This pass finds all accesses to objects of types marked with the attribute, + and wraps them in the same "low-level" builtins used by the builtin version. + All logic afterwards is therefore identical to the builtin version of + preserve_access_index. */ + +/* True iff tree T accesses any member of a struct/union/class which is marked + with the PRESERVE_ACCESS_INDEX attribute. */ + +static bool +is_attr_preserve_access (tree t) +{ + if (t == NULL_TREE) + return false; + + poly_int64 bitsize, bitpos; + tree var_off; + machine_mode mode; + int sign, reverse, vol; + + tree base = get_inner_reference (t, &bitsize, &bitpos, &var_off, &mode, + &sign, &reverse, &vol); + + if (TREE_CODE (base) == MEM_REF) + { + return lookup_attribute ("preserve_access_index", + TYPE_ATTRIBUTES (TREE_TYPE (base))); + } + + if (TREE_CODE (t) == COMPONENT_REF) + { + /* preserve_access_index propegates into nested structures, + so check whether this is a component of another component + which in turn is part of such a struct. */ + + const tree op = TREE_OPERAND (t, 0); + + if (TREE_CODE (op) == COMPONENT_REF) + return is_attr_preserve_access (op); + + const tree container = DECL_CONTEXT (TREE_OPERAND (t, 1)); + + return lookup_attribute ("preserve_access_index", + TYPE_ATTRIBUTES (container)); + } + + else if (TREE_CODE (t) == ADDR_EXPR) + return is_attr_preserve_access (TREE_OPERAND (t, 0)); + + return false; +} + +/* The body of pass_bpf_core_attr. Scan RTL for accesses to structs/unions + marked with __attribute__((preserve_access_index)) and generate a CO-RE + relocation for any such access. */ + +static void +handle_attr_preserve (function *fn) +{ + basic_block bb; + rtx_insn *insn; + rtx_code_label *label; + FOR_EACH_BB_FN (bb, fn) + { + FOR_BB_INSNS (bb, insn) + { + if (!NONJUMP_INSN_P (insn)) + continue; + rtx pat = PATTERN (insn); + if (GET_CODE (pat) != SET) + continue; + + start_sequence(); + + for (int i = 0; i < 2; i++) + { + rtx mem = XEXP (pat, i); + if (MEM_P (mem)) + { + tree expr = MEM_EXPR (mem); + if (!expr) + continue; + + if (TREE_CODE (expr) == MEM_REF + && TREE_CODE (TREE_OPERAND (expr, 0)) == SSA_NAME) + { + gimple *def_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (expr, 0)); + if (is_gimple_assign (def_stmt)) + expr = gimple_assign_rhs1 (def_stmt); + } + + if (is_attr_preserve_access (expr)) + { + auto_vec accessors; + tree container = bpf_core_compute (expr, &accessors); + if (accessors.length () < 1) + continue; + accessors.reverse (); + + container = TREE_TYPE (container); + const char * section_name; + if (DECL_SECTION_NAME (fn->decl)) + section_name = DECL_SECTION_NAME (fn->decl); + else + section_name = ".text"; + + label = gen_label_rtx (); + LABEL_PRESERVE_P (label) = 1; + emit_label (label); + + /* Add the CO-RE relocation information to the BTF container. */ + bpf_core_reloc_add (container, section_name, &accessors, label); + } + } + } + rtx_insn *seq = get_insns (); + end_sequence (); + emit_insn_before (seq, insn); + } + } +} + + +/* This pass finds accesses to structures marked with the BPF target attribute + __attribute__((preserve_access_index)). For every such access, a CO-RE + relocation record is generated, to be output in the .BTF.ext section. */ + +namespace { + +const pass_data pass_data_bpf_core_attr = +{ + RTL_PASS, /* type */ + "bpf_core_attr", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_NONE, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_bpf_core_attr : public rtl_opt_pass +{ +public: + pass_bpf_core_attr (gcc::context *ctxt) + : rtl_opt_pass (pass_data_bpf_core_attr, ctxt) + {} + + virtual bool gate (function *) { return TARGET_BPF_CORE; } + virtual unsigned int execute (function *); +}; + +unsigned int +pass_bpf_core_attr::execute (function *fn) +{ + handle_attr_preserve (fn); + return 0; +} + +} /* Anonymous namespace. */ + +rtl_opt_pass * +make_pass_bpf_core_attr (gcc::context *ctxt) +{ + return new pass_bpf_core_attr (ctxt); +} + /* Finally, build the GCC target. */ struct gcc_target targetm = TARGET_INITIALIZER; diff --git a/gcc/config/bpf/coreout.c b/gcc/config/bpf/coreout.c new file mode 100644 index 00000000000..d5486b463cf --- /dev/null +++ b/gcc/config/bpf/coreout.c @@ -0,0 +1,356 @@ +/* BPF Compile Once - Run Everywhere (CO-RE) support. + Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#define IN_TARGET_CODE 1 + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "target.h" +#include "memmodel.h" +#include "tm_p.h" +#include "output.h" +#include "dwarf2asm.h" +#include "ctfc.h" +#include "btf.h" +#include "rtl.h" + +#include "coreout.h" + +/* This file contains data structures and routines for construction and output + of BPF Compile Once - Run Everywhere (BPF CO-RE) information. + + eBPF programs written in C usually include Linux kernel headers, so that + they may interact with kernel data structures in a useful way. This + intrudces two major portability issues: + + 1. Kernel data structures regularly change, with fields added, moved or + deleted between versions. An eBPF program cannot in general be expected + to run on any systems which does not share an identical kernel version to + the system on which it was compiled. + + 2. Included kernel headers (and used data structures) may be internal, not + exposed in an userspace API, and therefore target-specific. An eBPF + program compiled on an x86_64 machine will include x86_64 kernel headers. + The resulting program may not run well (or at all) in machines of + another architecture. + + BPF CO-RE is designed to solve the first issue by leveraging the BPF loader + to adjust references to kernel data structures made by the program as-needed + according to versions of structures actually present on the host kernel. + + To achieve this, additional information is placed in a ".BTF.ext" section. + This information tells the loader which references will require adjusting, + and how to perform each necessary adjustment. + + For any access to a data structure which may require load-time adjustment, + the following information is recorded (making up a CO-RE relocation record): + - The BTF type ID of the outermost structure which is accessed. + - An access string encoding the accessed member via a series of member and + array indexes. These indexes are used to look up detailed BTF information + about the member. + - The offset of the appropriate instruction to patch in the BPF program. + - An integer specifying what kind of relocation to perform. + + A CO-RE-capable BPF loader reads this information together with the BTF + information of the program, compares it against BTF information of the host + kernel, and determines the appropriate way to patch the specified + instruction. + + Once all CO-RE relocations are resolved, the program is loaded and verified + as usual. The process can be summarized with the following diagram: + + +------------+ + | C compiler | + +-----+------+ + | BPF + BTF + CO-RE relocations + v + +------------+ + +--->| BPF loader | + | +-----+------+ + | | BPF (adapted) + BTF | v + | +------------+ + +----+ Kernel | + +------------+ + + Note that a single ELF object may contain multiple eBPF programs. As a + result, a single .BTF.ext section can contain CO-RE relocations for multiple + programs in distinct sections. */ + +/* Internal representation of a BPF CO-RE relocation record. */ + +typedef struct GTY (()) bpf_core_reloc { + unsigned int bpfcr_type; /* BTF type ID of container. */ + unsigned int bpfcr_astr_off; /* Offset of access string in .BTF + string table. */ + rtx_code_label * bpfcr_insn_label; /* RTX label attached to instruction + to patch. */ + enum btf_core_reloc_kind bpfcr_kind; /* Kind of relocation to perform. */ +} bpf_core_reloc_t; + +typedef bpf_core_reloc_t * bpf_core_reloc_ref; + +/* Internal representation of a CO-RE relocation (sub)section of the + .BTF.ext information. One such section is generated for each ELF section + in the output object having relocations that a BPF loader must resolve. */ + +typedef struct GTY (()) bpf_core_section { + /* Name of ELF section to which these CO-RE relocations apply. */ + const char * name; + + /* Offset of section name in .BTF string table. */ + uint32_t name_offset; + + /* Relocations in the section. */ + vec * GTY (()) relocs; +} bpf_core_section_t; + +typedef bpf_core_section_t * bpf_core_section_ref; + +/* BTF.ext debug info section. */ + +static GTY (()) section * btf_ext_info_section; + +static int btf_ext_label_num; + +#ifndef BTF_EXT_INFO_SECTION_NAME +#define BTF_EXT_INFO_SECTION_NAME ".BTF.ext" +#endif + +#define BTF_EXT_INFO_SECTION_FLAGS (SECTION_DEBUG) + +#define MAX_BTF_EXT_LABEL_BYTES 40 + +static char btf_ext_info_section_label[MAX_BTF_EXT_LABEL_BYTES]; + +#ifndef BTF_EXT_INFO_SECTION_LABEL +#define BTF_EXT_INFO_SECTION_LABEL "Lbtfext" +#endif + +static GTY (()) vec *bpf_core_sections; + + +/* Create a new BPF CO-RE relocation record, and add it to the appropriate + CO-RE section. */ + +void +bpf_core_reloc_add (const tree type, const char * section_name, + vec *accessors, rtx_code_label *label) +{ + char buf[40]; + unsigned int i, n = 0; + + /* A valid CO-RE access must have at least one accessor. */ + if (accessors->length () < 1) + return; + + for (i = 0; i < accessors->length () - 1; i++) + n += snprintf (buf + n, sizeof (buf) - n, "%u:", (*accessors)[i]); + snprintf (buf + n, sizeof (buf) - n, "%u", (*accessors)[i]); + + bpf_core_reloc_ref bpfcr = ggc_cleared_alloc (); + ctf_container_ref ctfc = ctf_get_tu_ctfc (); + + /* Buffer the access string in the auxiliary strtab. Since the two string + tables are concatenated, add the length of the first to the offset. */ + size_t strtab_len = ctfc_get_strtab_len (ctfc, CTF_STRTAB); + ctf_add_string (ctfc, buf, &(bpfcr->bpfcr_astr_off), CTF_AUX_STRTAB); + bpfcr->bpfcr_astr_off += strtab_len; + + bpfcr->bpfcr_type = get_btf_id (ctf_lookup_tree_type (ctfc, type)); + bpfcr->bpfcr_insn_label = label; + bpfcr->bpfcr_kind = BPF_RELO_FIELD_BYTE_OFFSET; + + /* Add the CO-RE reloc to the appropriate section. */ + bpf_core_section_ref sec; + FOR_EACH_VEC_ELT (*bpf_core_sections, i, sec) + if (strcmp (sec->name, section_name) == 0) + { + vec_safe_push (sec->relocs, bpfcr); + return; + } + + /* If the CO-RE section does not yet exist, create it. */ + sec = ggc_cleared_alloc (); + + ctf_add_string (ctfc, section_name, &sec->name_offset, CTF_AUX_STRTAB); + sec->name_offset += strtab_len; + if (strcmp (section_name, "")) + ctfc->ctfc_aux_strlen += strlen (section_name) + 1; + + sec->name = section_name; + vec_alloc (sec->relocs, 1); + vec_safe_push (sec->relocs, bpfcr); + + vec_safe_push (bpf_core_sections, sec); +} + +/* Return the 0-based index of the field NODE in its containing struct or union + type. */ + +int +bpf_core_get_sou_member_index (ctf_container_ref ctfc, const tree node) +{ + if (TREE_CODE (node) == FIELD_DECL) + { + const tree container = DECL_CONTEXT (node); + const char * name = IDENTIFIER_POINTER (DECL_NAME (node)); + + /* Lookup the CTF type info for the containing type. */ + dw_die_ref die = lookup_type_die (container); + if (die == NULL) + return -1; + + ctf_dtdef_ref dtd = ctf_dtd_lookup (ctfc, die); + if (dtd == NULL) + return -1; + + unsigned int kind = CTF_V2_INFO_KIND (dtd->dtd_data.ctti_info); + if (kind != CTF_K_STRUCT && kind != CTF_K_UNION) + return -1; + + int i = 0; + ctf_dmdef_t * dmd; + for (dmd = dtd->dtd_u.dtu_members; + dmd != NULL; dmd = (ctf_dmdef_t *) ctf_dmd_list_next (dmd)) + { + if (get_btf_id (dmd->dmd_type) > BTF_MAX_TYPE) + continue; + if (strcmp (dmd->dmd_name, name) == 0) + return i; + i++; + } + } + return -1; +} + +/* Compute and output the header of a .BTF.ext debug info section. */ + +static void +output_btfext_header (void) +{ + switch_to_section (btf_ext_info_section); + ASM_OUTPUT_LABEL (asm_out_file, btf_ext_info_section_label); + + dw2_asm_output_data (2, BTF_MAGIC, "btf_magic"); + dw2_asm_output_data (1, BTF_VERSION, "btfext_version"); + dw2_asm_output_data (1, 0, "btfext_flags"); + dw2_asm_output_data (4, sizeof (struct btf_ext_header), "btfext_hdr_len"); + + uint32_t func_info_off = 0, func_info_len = 0; + uint32_t line_info_off = 0, line_info_len = 0; + uint32_t core_relo_off = 0, core_relo_len = 0; + + /* Header core_relo_len is the sum total length in bytes of all CO-RE + relocation sections. */ + size_t i; + bpf_core_section_ref sec; + core_relo_len += vec_safe_length (bpf_core_sections) + * sizeof (struct btf_ext_section_header); + + FOR_EACH_VEC_ELT (*bpf_core_sections, i, sec) + core_relo_len += + vec_safe_length (sec->relocs) * sizeof (struct btf_ext_reloc); + + dw2_asm_output_data (4, func_info_off, "func_info_offset"); + dw2_asm_output_data (4, func_info_len, "func_info_len"); + + dw2_asm_output_data (4, line_info_off, "line_info_offset"); + dw2_asm_output_data (4, line_info_len, "line_info_len"); + + dw2_asm_output_data (4, core_relo_off, "core_relo_offset"); + dw2_asm_output_data (4, core_relo_len, "core_relo_len"); +} + +/* Output a single CO-RE relocation record. */ + +static void +output_asm_btfext_core_reloc (bpf_core_reloc_ref bpfcr) +{ + dw2_assemble_integer (4, gen_rtx_LABEL_REF (Pmode, bpfcr->bpfcr_insn_label)); + fprintf (asm_out_file, "\t%s bpfcr_insn\n", ASM_COMMENT_START); + + dw2_asm_output_data (4, bpfcr->bpfcr_type, "bpfcr_type"); + dw2_asm_output_data (4, bpfcr->bpfcr_astr_off, "bpfcr_astr_off"); + dw2_asm_output_data (4, bpfcr->bpfcr_kind, "bpfcr_kind"); +} + +/* Output all CO-RE relocation records for a section. */ + +static void +output_btfext_core_relocs (bpf_core_section_ref sec) +{ + size_t i; + bpf_core_reloc_ref bpfcr; + FOR_EACH_VEC_ELT (*(sec->relocs), i, bpfcr) + output_asm_btfext_core_reloc (bpfcr); +} + +/* Output all CO-RE relocation sections. */ + +static void +output_btfext_core_sections (void) +{ + size_t i; + bpf_core_section_ref sec; + FOR_EACH_VEC_ELT (*bpf_core_sections, i, sec) + { + /* BTF Ext section info. */ + dw2_asm_output_data (4, sizeof (struct btf_ext_reloc), + "btfext_secinfo_rec_size"); + + /* Section name offset, refers to the offset of a string with the name of + the section to which these CORE relocations refer, e.g. '.text'. + The string is buffered in the BTF strings table. */ + dw2_asm_output_data (4, sec->name_offset, "btfext_secinfo_sec_name_off"); + dw2_asm_output_data (4, vec_safe_length (sec->relocs), + "btfext_secinfo_num_recs"); + + output_btfext_core_relocs (sec); + } +} + +/* Initialize sections, labels, and data structures for BTF.ext output. */ + +void +btf_ext_init (void) +{ + btf_ext_info_section = get_section (BTF_EXT_INFO_SECTION_NAME, + BTF_EXT_INFO_SECTION_FLAGS, NULL); + + ASM_GENERATE_INTERNAL_LABEL (btf_ext_info_section_label, + BTF_EXT_INFO_SECTION_LABEL, + btf_ext_label_num++); + + vec_alloc (bpf_core_sections, 1); +} + +/* Output the entire .BTF.ext section. */ + +void +btf_ext_output (void) +{ + output_btfext_header (); + output_btfext_core_sections (); + + bpf_core_sections = NULL; +} + +#include "gt-coreout.h" diff --git a/gcc/config/bpf/coreout.h b/gcc/config/bpf/coreout.h new file mode 100644 index 00000000000..82c203df341 --- /dev/null +++ b/gcc/config/bpf/coreout.h @@ -0,0 +1,114 @@ +/* coreout.h - Declarations and definitions related to + BPF Compile Once - Run Everywhere (CO-RE) support. + Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + + +#ifndef __COREOUT_H +#define __COREOUT_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* .BTF.ext information. */ + +struct btf_ext_section_header +{ + uint32_t kind; + uint32_t sec_name_off; + uint32_t num_records; +}; + +/* A funcinfo record, in the .BTF.ext funcinfo section. */ +struct btf_ext_funcinfo +{ + uint32_t insn_off; /* Offset of the first instruction of the function. */ + uint32_t type; /* Type ID of a BTF_KIND_FUNC type. */ +}; + +/* A lineinfo record, in the .BTF.ext lineinfo section. */ +struct btf_ext_lineinfo +{ + uint32_t insn_off; /* Offset of the instruction. */ + uint32_t file_name_off; /* Offset of file name in BTF string table. */ + uint32_t line_off; /* Offset of source line in BTF string table. */ + uint32_t line_col; /* Line number (bits 31-11) and column (11-0). */ +}; + +enum btf_core_reloc_kind +{ + BPF_RELO_FIELD_BYTE_OFFSET = 0, + BPF_RELO_FIELD_BYTE_SIZE = 1, + BPF_RELO_FIELD_EXISTS = 2, + BPF_RELO_FIELD_SIGNED = 3, + BPF_RELO_FIELD_LSHIFT_U64 = 4, + BPF_RELO_FIELD_RSHIFT_U64 = 5, + BPF_RELO_TYPE_ID_LOCAL = 6, + BPF_RELO_TYPE_ID_TARGET = 7, + BPF_RELO_TYPE_EXISTS = 8, + BPF_RELO_TYPE_SIZE = 9, + BPF_RELO_ENUMVAL_EXISTS = 10, + BPF_RELO_ENUMVAL_VALUE = 11 +}; + +struct btf_ext_reloc +{ + uint32_t insn_off; /* Offset of instruction to be patched. A + section-relative label at compile time. */ + uint32_t type_id; /* Type ID of the outermost containing entity, e.g. + the containing structure. */ + uint32_t access_str_off; /* Offset of CO-RE accessor string in .BTF strings + section. */ + uint32_t kind; /* An enum btf_core_reloc_kind. Note that it always + takes 32 bits. */ +}; + +struct btf_ext_header +{ + uint16_t magic; /* Magic number (BTF_MAGIC). */ + uint8_t version; /* Data format version (BTF_VERSION). */ + uint8_t flags; /* Flags. Currently unused. */ + uint32_t hdr_len; /* Length of this header in bytes. */ + + /* Following offsets are relative to the end of this header, in bytes. + Following lengths are in bytes. */ + uint32_t func_info_off; /* Offset of funcinfo section. */ + uint32_t func_info_len; /* Length of funcinfo section. */ + uint32_t line_info_off; /* Offset of lineinfo section. */ + uint32_t line_info_len; /* Length of lineinfo section. */ + + uint32_t core_relo_off; /* Offset of CO-RE relocation section. */ + uint32_t core_relo_len; /* Length of CO-RE relocation section. */ +}; + +extern void btf_ext_init (void); +extern void btf_ext_output (void); + +extern void bpf_core_reloc_add (const tree, const char *, vec *, + rtx_code_label *); +extern int bpf_core_get_sou_member_index (ctf_container_ref, const tree); + +#ifdef __cplusplus +} +#endif + +#endif /* __COREOUT_H */ diff --git a/gcc/config/bpf/t-bpf b/gcc/config/bpf/t-bpf index e69de29bb2d..b37bf858d8f 100644 --- a/gcc/config/bpf/t-bpf +++ b/gcc/config/bpf/t-bpf @@ -0,0 +1,8 @@ + +TM_H += $(srcdir)/config/bpf/coreout.h + +coreout.o: $(srcdir)/config/bpf/coreout.c + $(COMPILE) $< + $(POSTCOMPILE) + +PASSES_EXTRA += $(srcdir)/config/bpf/bpf-passes.def From patchwork Wed Aug 4 17:54:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Faust X-Patchwork-Id: 1513589 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=P2nkCE/0; 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 4Gg0290r6Yz9sRf for ; Thu, 5 Aug 2021 04:02:24 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5386B3951C6B for ; Wed, 4 Aug 2021 18:02:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5386B3951C6B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628100142; bh=qm3sNjEqx+3Sqi28wmtP+FMPAQbr3wvtrGg7IAVeuaw=; 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=P2nkCE/0/5L6Q4C09yIi0o6CzQ2AMcFtwf3dT3ag0eIHwBd9q1wI46Ap6zzUNp50g Dpeg+XIvY4L5eF7tPcz2tIa6nMO+4PT6IplfB4+YeNp87ppVvz/0CLiwzOfcscWnJK +rvgEvOhMdIDLCIzvzZVN+4+Ika5icv3/ouhW2Wk= 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 F11893951866 for ; Wed, 4 Aug 2021 17:55:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F11893951866 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 174HpP5b028198 for ; Wed, 4 Aug 2021 17:55:15 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a7cxn2am6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:14 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 174Ho9XB010600 for ; Wed, 4 Aug 2021 17:55:13 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by aserp3030.oracle.com with ESMTP id 3a78d74b4r-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LpdlEsevQk6kNuSDvBgUUDXOP3miHK4rfGAlM/ocz66xw8rqZpRhTwbMH3EVvHO8UWsdWqOctv4nSaFk2tGQwBV60vji5BR9/iGgzv+IW69edknbWRj74lGYY5pmZ3tqCCdo6fcOuS5Tp/dblLuHLi4K8x7Y4oUTS1AnOT57ZcjyjpNV3IFjBEmpxMLWwYaT1UA5MeJwTGvipY/HFaF4WcXS2PxSjPp9tg28I0QJrTbXYfKtEFBQ0fKAmlES/duYeZfbXH1OhWFuAAhLi/CwjRtxs4DKThW9k7seXCWUz3gZekGosxFFc4YQCni/kfWSk7a6wK5mXYa4N02T59PXbw== 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=qm3sNjEqx+3Sqi28wmtP+FMPAQbr3wvtrGg7IAVeuaw=; b=hY2YtKSWm2RBY/JytNDdgH36lQtDOvHwDzoMR2ClaAYscGncUTwhfHNSOQeNUPZImt2pLJuEpj5URtEB9T4+QF0IZogCq/N7WbJBtkvmBfFEwm07vNAIUTZuy+Ubi9WrmggFqV8SJ7oSv6ZQozrTZ9eSASrj8bLOnoo2xgeG8ud4GsUtXe+DIcdgGjGeqRFS3zv1GSfc7Q1Bm4DwvnuQuO7WqQqsEtYQoUTgWxIUf8LqZnqPWQZODkWMUckU/PKoUc/f4rbhDz8hpzjwW3iKznuXKzsq4FLeidiY3nS/DvgengbbntEWwBlOn/xm8WJ11upWpCkk3zMK+Zr3bLOWoA== 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 SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) by SA2PR10MB4555.namprd10.prod.outlook.com (2603:10b6:806:115::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16; Wed, 4 Aug 2021 17:55:11 +0000 Received: from SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632]) by SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632%5]) with mapi id 15.20.4394.016; Wed, 4 Aug 2021 17:55:11 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 6/7] bpf testsuite: Add BPF CO-RE tests Date: Wed, 4 Aug 2021 10:54:10 -0700 Message-Id: <20210804175411.6783-7-david.faust@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210804175411.6783-1-david.faust@oracle.com> References: <20210804175411.6783-1-david.faust@oracle.com> X-ClientProxiedBy: SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) To SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sequence.us.oracle.com (2606:b400:8004:44::1f) by SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17 via Frontend Transport; Wed, 4 Aug 2021 17:55:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5536c219-5ebc-45e1-d21e-08d957710156 X-MS-TrafficTypeDiagnostic: SA2PR10MB4555: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:38; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RvxhuMCsFVCMxDeFEYd6PQe5kyxE0XVfPGRd8ww4FfRka7zWzlPfytb0fufoSHTFkRJejhhWCmHTKzHVLkt3JKsJ19kxTJZhrQrDJcQ8uIm+rCkXYqOuyhncc+1q/A79ih/v+BPOd+c2emVWz0JJYQLsU+XZ1dgs1dxGCB+azUT6a8NCand43drDj0GQJkioukHzJzkW37youRJU+POqxCil9jr9Uj+mvslzsUNcAHl/HqtvRq2AYpO/4pmTq3QZGZdTL5zEdDzvX/sJI90pPf3plHbXAqo0KELI3n19tXIdqyuaUWdEwl6+7jMZ9k6IO+U3Ce9YhPGyMzmjr3Ld+PiWVlz0/2OAhcbsQwczNdc0vhZPUgfoRUVBC30z565f1Srg53TVhc1juv4+YyoVy4IZWwqUKwEeWfVqjr7JvM8woXdzmYL4I9aKEXk1WSUPi+2x2tY9QRDp3AI7GzupzHDkyuwqyIS2RX+v++TzIVtOtk31v6i0Y7ShBpt/tSWPUFnQP+NprYs87Mr08IHxKKkemGl0835/v6HiEoH34IOvnwTy4ecR6AzD/gb6udJfhNTDTlZuWKK+e8pVvF/NtqRkJziCiksSWVKmQdKZTM4fTSStz4OG/h0aXYkTXCF1FGDCC3p06JEcuwoVPcb8RoJ0LtMUAz0hHkqTI7ZNeGPs/U3iy4HVXWZpKAM+awkxOxx9TYaVAG2qpcB/PsPD+E48vgs3zWTIRR+AXzAqxN8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4458.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6486002)(44832011)(316002)(8936002)(66476007)(66946007)(6916009)(83380400001)(66556008)(86362001)(5660300002)(8676002)(7696005)(38100700002)(52116002)(508600001)(36756003)(186003)(2906002)(1076003)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fL+qSLxSdOZrkC7Ns/0jcnrTCuM7/o/8oC5/cVl2817UBngOi+f/XxITYsuEvdgWJIhXiy7xSEiNST1AEZHLYqAcHfKx+LcA5WMb8igdrvLeuIGqYcwjkfdaWBtlwoUnEFZ9p6PxnzHo1gsMUW2XMJ1VrHSQfntlIn0qox+F5TuqrF+4iQFsKyOwwxTe6aG5XW8Bokd40HNYBz9BKxaMaetWA5OcRz+dCtujBWxmPyUg1RqKGqYn5lTgHJTO4RQwZEBfWFuOJ9nqmHnAA6eek2nSejWFNhTEkRUCNpKiyRzSM+f4ubfOWVLS37KufEm5xf12yiWPxvnwvVRm903ieivnRNt8NfAZHZVKOYPeRQY+XDn0MD25z0oQuLzMq9KJPCT8hunGSHWzWy01ZJnYjTXcRYEYyFkJVGz9mjHZxFdZWlD6PMyU0KhCIA7siQnbib3f0qbGdgfwXopSKV7uRdm9jtJPVj+M8bzmxcuC5riv/7mPl7Een+1BEr48OT7Wck2nU/foDH/1JH7mlWlKUmRTDgb/ssqIBCZimzt5QNVdxZ+FEhESzVhn78b/9aC4r3PNC8jI1ViV/ZR0dHVNR6bbub6JGeDZQntilPTxmvxfqBml6cJUen+YLjVEN2mL1wMmeoy+Y/7BVQ5LmRDuGloM1qDp7YxRVEwucR7Gu/AiE9UpI/pbzFHufFHTuuNslaUYE/GevQMWkwPa6C/KmyqvGXwQSOAMMGVPXLMKLkLALjqZnEJ/Hi5pJzj2Kyv44DM9kWBkzMjTtkTGvjApsIDd+rsImBWQReJSgyx3i1/+0gWeUBcQWiOmZyiE3NK0uwOMfZTyJzE2GzKEWmO3Mz0KDFPSsD5CegXm6bFpZPqNcSD8M0pkHp5fgh1Qg1cD0rLy3Ri1zfj2Ez98Wm4hLbPtYoHQOyX9fTXZpQFfupB5pr/RXzCOTzkxcK5A62n//c+sK9UV8Pxlzsc67h5ZIiJZhemq4F0PKFpPA3zXIptZJMfmniyV3+dlcGLFxvhz9cRAIxUYmhr6Z2Ixj/+d6ET6BftvcTcmFOfhu8Ggpq2KBqpnP/lvSAGg7dJO86H5fbKrqvG+s91ZFh7Gwz8gWyEYm2I8xOOsPPk/R1ujY5XhZl/tPtgb7kXudhNjLnaNuvQ/ZzbFa66LJ182n9yKz8Sg8Fcg4LLjT7ZOJoFEfqIRJYBs0YlVLxJYY/ugXZI6jRbFSORCiSl11hUEfDKnq5vzprkIn7dJ69bEqrE80UqLGxqVkIQukLpXUOe1IFUTEsPs7IUiQnwXsfz5XEao+ltbOMzJEkgadPRJDpZWT8Ee5mUHuFdHBx+Gm1I8SYbUWADd1pk5UdpRLG8zW2IATA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5536c219-5ebc-45e1-d21e-08d957710156 X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4458.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 17:55:11.6676 (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: UVpF/WlwHdBwgW7hNe9ZFqgQRO0aEsZ+WWoJnMh957Uiy04+b0SRFyx7K3azihHGbv0x23can/iN/K6GUvQt0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4555 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10066 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108040104 X-Proofpoint-GUID: LZzCvBadNOXX46kVutacW5sRPs6rKCmt X-Proofpoint-ORIG-GUID: LZzCvBadNOXX46kVutacW5sRPs6rKCmt X-Spam-Status: No, score=-12.4 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, RCVD_IN_MSPIKE_H2, 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: David Faust via Gcc-patches From: David Faust Reply-To: David Faust Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This commit adds several tests for the new BPF CO-RE functionality to the BPF target testsuite. gcc/testsuite/ChangeLog: * gcc.target/bpf/core-attr-1.c: New test. * gcc.target/bpf/core-attr-2.c: Likewise. * gcc.target/bpf/core-attr-3.c: Likewise. * gcc.target/bpf/core-attr-4.c: Likewise * gcc.target/bpf/core-builtin-1.c: Likewise * gcc.target/bpf/core-builtin-2.c: Likewise. * gcc.target/bpf/core-builtin-3.c: Likewise. * gcc.target/bpf/core-section-1.c: Likewise. --- gcc/testsuite/gcc.target/bpf/core-attr-1.c | 23 +++++++ gcc/testsuite/gcc.target/bpf/core-attr-2.c | 21 ++++++ gcc/testsuite/gcc.target/bpf/core-attr-3.c | 41 ++++++++++++ gcc/testsuite/gcc.target/bpf/core-attr-4.c | 35 ++++++++++ gcc/testsuite/gcc.target/bpf/core-builtin-1.c | 64 +++++++++++++++++++ gcc/testsuite/gcc.target/bpf/core-builtin-2.c | 26 ++++++++ gcc/testsuite/gcc.target/bpf/core-builtin-3.c | 26 ++++++++ gcc/testsuite/gcc.target/bpf/core-section-1.c | 38 +++++++++++ 8 files changed, 274 insertions(+) create mode 100644 gcc/testsuite/gcc.target/bpf/core-attr-1.c create mode 100644 gcc/testsuite/gcc.target/bpf/core-attr-2.c create mode 100644 gcc/testsuite/gcc.target/bpf/core-attr-3.c create mode 100644 gcc/testsuite/gcc.target/bpf/core-attr-4.c create mode 100644 gcc/testsuite/gcc.target/bpf/core-builtin-1.c create mode 100644 gcc/testsuite/gcc.target/bpf/core-builtin-2.c create mode 100644 gcc/testsuite/gcc.target/bpf/core-builtin-3.c create mode 100644 gcc/testsuite/gcc.target/bpf/core-section-1.c diff --git a/gcc/testsuite/gcc.target/bpf/core-attr-1.c b/gcc/testsuite/gcc.target/bpf/core-attr-1.c new file mode 100644 index 00000000000..7f0d0e50dd6 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-attr-1.c @@ -0,0 +1,23 @@ +/* Basic test for struct __attribute__((preserve_access_index)) + for BPF CO-RE support. */ + +/* { dg-do compile } */ +/* { dg-options "-O0 -dA -gbtf -mcore" } */ + +struct S { + int a; + int b; + int c; +} __attribute__((preserve_access_index)); + +void +func (struct S * s) +{ + /* 0:2 */ + int *x = &(s->c); + + *x = 4; +} + +/* { dg-final { scan-assembler-times "ascii \"0:2.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "bpfcr_type" 1 } } */ diff --git a/gcc/testsuite/gcc.target/bpf/core-attr-2.c b/gcc/testsuite/gcc.target/bpf/core-attr-2.c new file mode 100644 index 00000000000..508e1e4c4b1 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-attr-2.c @@ -0,0 +1,21 @@ +/* Basic test for union __attribute__((preserve_access_index)) + for BPF CO-RE support. */ + +/* { dg-do compile } */ +/* { dg-options "-O0 -dA -gbtf -mcore" } */ + +union U { + int a; + char c; +} __attribute__((preserve_access_index)); + +void +func (union U *u) +{ + /* 0:1 */ + char *c = &(u->c); + *c = 'c'; +} + +/* { dg-final { scan-assembler-times "ascii \"0:1.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "bpfcr_type" 1 } } */ diff --git a/gcc/testsuite/gcc.target/bpf/core-attr-3.c b/gcc/testsuite/gcc.target/bpf/core-attr-3.c new file mode 100644 index 00000000000..1813fd07a2f --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-attr-3.c @@ -0,0 +1,41 @@ +/* Test for __attribute__((preserve_access_index)) for BPF CO-RE support + for nested structure. + + Note that even though struct O lacks the attribute, when accessed as a + member of another attributed type, CO-RE relocations should still be + generated. */ + +/* { dg-do compile } */ +/* { dg-options "-O0 -dA -gbtf -mcore" } */ + +struct O { + int e; + int f; +}; + +struct S { + int a; + struct { + int b; + int c; + } inner; + struct O other; +} __attribute__((preserve_access_index)); + +void +func (struct S *foo) +{ + /* 0:1:1 */ + int *x = &(foo->inner.c); + + /* 0:2:0 */ + int *y = &(foo->other.e); + + *x = 4; + *y = 5; +} + +/* { dg-final { scan-assembler-times "ascii \"0:1:1.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"0:2:0.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ + +/* { dg-final { scan-assembler-times "bpfcr_type" 2 } } */ diff --git a/gcc/testsuite/gcc.target/bpf/core-attr-4.c b/gcc/testsuite/gcc.target/bpf/core-attr-4.c new file mode 100644 index 00000000000..30d859a1c57 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-attr-4.c @@ -0,0 +1,35 @@ +/* Test for BPF CO-RE __attribute__((preserve_access_index)) with accesses on + LHS and both LHS and RHS of assignment. */ + +/* { dg-do compile } */ +/* { dg-options "-O0 -dA -gbtf -mcore" } */ + +struct T { + int a; + int b; + struct U { + int c; + struct V { + int d; + int e[4]; + int f; + } v; + } u; +} __attribute__((preserve_access_index)); + + +void +func (struct T *t) +{ + /* 0:2:1:1:3 */ + t->u.v.e[3] = 0xa1; + + /* 0:2:0, 0:0, 0:1 */ + t->u.c = t->a + t->b; +} + +/* { dg-final { scan-assembler-times "ascii \"0:2:1:1:3.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"0:2:0.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"0:0.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"0:1.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "bpfcr_type" 4 } } */ diff --git a/gcc/testsuite/gcc.target/bpf/core-builtin-1.c b/gcc/testsuite/gcc.target/bpf/core-builtin-1.c new file mode 100644 index 00000000000..e6905418c89 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-builtin-1.c @@ -0,0 +1,64 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -dA -gbtf -mcore" } */ + +struct S { + int a; + int b; + char c; +}; + +union U { + unsigned int u; + int i; + unsigned char uc[4]; + signed char ic[4]; +}; + +struct S my_s; +union U my_u; + +unsigned long ula[8]; + +#define _(x) (__builtin_preserve_access_index (x)) + +void +func (void) +{ + /* 1 */ + int b = _(my_s.b); + + /* 2 */ + char c = _(my_s.c); + + /* 2:3 */ + unsigned char uc = _(my_u.uc[3]); + + /* 6 */ + unsigned long ul = _(ula[6]); +} + +char +s_ptr (struct S *ps) +{ + /* 0:2 */ + char x = _(ps->c); + return x; +} + +unsigned char +u_ptr (union U *pu) +{ + /* 0:2:3 */ + unsigned char x = _(pu->uc[3]); + return x; +} + +/* { dg-final { scan-assembler-times "ascii \"1.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"2.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"2:3.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"6.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"0:2.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"0:2:3.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ + +/* { dg-final { scan-assembler-times "bpfcr_type" 6 } } */ +/* { dg-final { scan-assembler-times "\[\t \]0x6c\[\t \]+\[^\n\]*core_relo_len" 1 } } */ diff --git a/gcc/testsuite/gcc.target/bpf/core-builtin-2.c b/gcc/testsuite/gcc.target/bpf/core-builtin-2.c new file mode 100644 index 00000000000..5e9dfecce65 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-builtin-2.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -dA -gbtf -mcore" } */ + +struct S { + int a; + union { + int _unused; + int b; + char c; + } u[4]; +}; + +struct S foo; + +#define _(x) (__builtin_preserve_access_index (x)) + +void func (void) +{ + char *x = __builtin_preserve_access_index (&foo.u[3].c); + + *x = 's'; +} + +/* { dg-final { scan-assembler-times "\[\t \]0x4000002\[\t \]+\[^\n\]*btt_info" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"1:3:2.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "bpfcr_type" 1 } } */ diff --git a/gcc/testsuite/gcc.target/bpf/core-builtin-3.c b/gcc/testsuite/gcc.target/bpf/core-builtin-3.c new file mode 100644 index 00000000000..495eeadfe69 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-builtin-3.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -dA -gbtf -mcore" } */ + +struct T { + int a; + int b; + struct U { + int c; + struct V { + int d; + int e[4]; + int f; + } v; + } u; +}; + +void func (struct T * foo) +{ + /* Access string: "0:2:1:1:3" */ + int *x = __builtin_preserve_access_index (&(foo->u.v.e[3])); + + *x = 17; +} + +/* { dg-final { scan-assembler-times "ascii \"0:2:1:1:3.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "bpfcr_type" 1 } } */ diff --git a/gcc/testsuite/gcc.target/bpf/core-section-1.c b/gcc/testsuite/gcc.target/bpf/core-section-1.c new file mode 100644 index 00000000000..b816aefd0d2 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-section-1.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -gbtf -dA -mcore" } */ + +struct T { + int a; + int b; + struct U { + int c; + struct V { + int d; + int e[4]; + int f; + } v; + } u; +}; + +__attribute__((section("foo_sec"), used)) +int foo_func (struct T *t) +{ + t->u.c = 5; + return __builtin_preserve_access_index (t->u.v.e[3]); +} + +__attribute__((section("bar_sec"), used)) +int bar_func (struct T *t) +{ + int *x = __builtin_preserve_access_index (&(t->u.v.f)); + int old = *x; + *x = 4; + return old; +} + +/* { dg-final { scan-assembler-times "ascii \"0:2:1:1:3.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"0:2:1:2.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"foo_sec.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"bar_sec.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "bpfcr_type" 2 } } */ +/* { dg-final { scan-assembler-times "btfext_secinfo_rec_size" 2 } } */ From patchwork Wed Aug 4 17:54:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Faust X-Patchwork-Id: 1513588 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=mjuFeZPF; 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 4Gg0100M1vz9sRf for ; Thu, 5 Aug 2021 04:01:22 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BD5A7395182C for ; Wed, 4 Aug 2021 18:01:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD5A7395182C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628100080; bh=NFZqz24x05wZrP27VtE0k4MuWCIVu0lW1iZZGOyoqt4=; 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=mjuFeZPFFa3wiK016m7rnfF1xBhJ0jZX7ndtb5FjNMwUvjop7fYX6HiKrD5zv0Vjr bxKcFyQKdhc+uWQri1WzKNN9eZbXodZDyWONkqUKngL3OmDSNwk6/PUVd1YgcYJgpd qy0xr5zBHrl4InbbSWJIvoizguK46MH1YjmsWHH4= 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 7D88C3951822 for ; Wed, 4 Aug 2021 17:55:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D88C3951822 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 174Hq7sV008065 for ; Wed, 4 Aug 2021 17:55:15 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a70pjvgk0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:15 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 174Ho9XC010600 for ; Wed, 4 Aug 2021 17:55:14 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by aserp3030.oracle.com with ESMTP id 3a78d74b4r-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 04 Aug 2021 17:55:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c8DCMoSn8jnAj/aIJXFZiUzsU2PHvTyMEDYwnYRf05fWOQgtImXbxIc1ABpSL11EV3e/5ObaoIDUtN8uz1jw3Mr9urlCrYj/gvHoS5zfXv2KQyXJAz60rhnoJd7I6T1N/V3ftq30Br9/wCycbYEmvrvFGF/wd6eIkBIsa3N0tyMh7To+fUT6ujW1tyrPajCR8P/bOa7mkpORAZX6y/XLTe8f7DeJZVtDQ/2OIoJUoUXwWf6VpU19rX5A6OPwXsZfrcmnn8gWp45S6jwBwr6eZu4HIpgIVoWDJrp82ZjaE6zcekDigsP2sIDxd6UzEl93myYz+j7OoDeFgB8+v9I4Wg== 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=NFZqz24x05wZrP27VtE0k4MuWCIVu0lW1iZZGOyoqt4=; b=kD8uSQxS7xz2l7bu20uj92qM8zfU0Yn2GSUXG6RMyBulBHa9+7VPyHafp/IAKwf1+326WoX3nw4DzAr342+IuIAXYrYIbrIPToudG+Q44ZqJ+YOMUQBUja6HVH64wonseObIBqSfWLVN+oNq6KSywMSTk/nh6JjvZbsAnjzduQjP3ZFopUKFSvuy3CjiO1lx8hO8lKdXN+ZQmOaIRo6fQdlrspRQSXdDdA9UIznbApU7aTYkXU76yJC+e1aUvtnmTBmTHEoUo4UGKFiIbUrHdA3L8NqhtVYjSyP0jW7HoDXhoW42bMCykihXScrvMWTGndCxLwxKGZWLDPUrmxMp2Q== 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 SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) by SA2PR10MB4555.namprd10.prod.outlook.com (2603:10b6:806:115::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16; Wed, 4 Aug 2021 17:55:12 +0000 Received: from SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632]) by SA2PR10MB4458.namprd10.prod.outlook.com ([fe80::9d08:a59a:abb8:3632%5]) with mapi id 15.20.4394.016; Wed, 4 Aug 2021 17:55:12 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 7/7] doc: BPF CO-RE documentation Date: Wed, 4 Aug 2021 10:54:11 -0700 Message-Id: <20210804175411.6783-8-david.faust@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210804175411.6783-1-david.faust@oracle.com> References: <20210804175411.6783-1-david.faust@oracle.com> X-ClientProxiedBy: SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) To SA2PR10MB4458.namprd10.prod.outlook.com (2603:10b6:806:f8::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sequence.us.oracle.com (2606:b400:8004:44::1f) by SA0PR11CA0203.namprd11.prod.outlook.com (2603:10b6:806:1bc::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17 via Frontend Transport; Wed, 4 Aug 2021 17:55:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a7c429cc-f29b-46e7-26fe-08d9577101bc X-MS-TrafficTypeDiagnostic: SA2PR10MB4555: 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: +28g/5Dm8/jA+95acubw14q+LfbFf6HhqPVpyxjFYpOT2B9kFMugNkGHXmvtF0SKizT3E+89PCsNhPEYzat+SQsl/A7IJx+nrjqXbWVAZgH8ruwJouhoJxe9PNqETWSEjK8RvEhZ5hdsaUHMN/oI+YjlTMxaIQKvY+uF1u27XHXsrQLtk6WlQxXpAvs0DI64C9EcB2tkfbTxX//47W7CDwI/fvobliPjW+BIIhklSfhTj3vEvLOuhreBRJ6/e6iXt8nnyzZ3zqWk+QGIsarj6qz9Zn2ptZ3s/0SXN3BuTiWk/20XLjCBqCkvbioH/m0+7IQdqDL67eKtx61D++cs9hrZtWxvIp+9ewVP4be9ZOHyzcaqnVyJBzH5dApuV5SU1X2j2rCDRzwry2DodciFeXkAMSOzvr4AhW7m8FSRmpwvPIfPa3jcJX0SrgpM3HvLBo3lyNZJn3Tgzug9aqclZNi70P63yajouWPZgsHhNK6tr7MaY/0PZibygoQzlxw/oNybTB5NF6o0WQ9BwXA8YVU5cyE8s47q04xXmhvXTTs59Q5J+EOLU9cOTupeEoDYBY3ZoYwIcVlrbUVRUfN55f+FspamgNFzuTertIAtgymuZMZniJEZmQUilJBs2RZVwQl0ey217aoN67N+jZB81w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4458.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6486002)(44832011)(316002)(8936002)(66476007)(66946007)(6916009)(83380400001)(66556008)(86362001)(5660300002)(8676002)(7696005)(38100700002)(52116002)(508600001)(36756003)(186003)(2906002)(1076003)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: H937EWCUOeCGNwUOJ/KUmNgw322ERwurN/fYUeImTwcmyvPy+hHJbQJVh7YaX9zoX3BSz54Td1QyBtjZCxe2XHF2ajh0z59Kno+mM8SRmpmMtw1DrNcsQz4rtbPyztFo97nJXuGaRhOrhhBKAQWPb22Rvlx0o7PefY0aaAOTlQ4fUADd94Cgk3GL/F0va2ekQc08SBAaayJKF2W3anm+B4IrEDJO87xJ86A1lfJIcvl++6mDNNup7yPc77A9PDiKPPktqa0mgW0GMXQGHaZStlMy37IRRCBNQV63JvSgC3Q37/t7bLhtKakzWl8YAqeZtR5Au+EAOxfFBSYDzYO7uFn8x7Ik4dM3Ttt1M5PdIEUDTqhrCRQgKPdmOKWU8d18L/tYpZQepHX6eKZZarfEyxWrOgMQKIIRo+WYLGog4tC9X7d+nMXBOgs84ZNteI7u5Lwh5yZS39gqGUC/uOSY7N8+hJY3ksHgo+dLMYTQZThdjPwu08fW1fE9uPAdpcj2T4EaCk5d3ShLi9GZOC+etxqEbxVk1fnnUdm9bbsmMnK6oXKpFJ1tjKunttwu/nrGdZFYyYPjFGWzY2tVWCzN0Uk0WejEU8VPdxZRjo1TjxjB68zi1/DO6SiDZRGiThd1P5JQO0DzXocq4fiA7GdCUKMnqWn/LvHkVbuUC8g5cT84t8iuZpy43iTxysfn6smAqFhX6jH/xDjPdTJ/lubeuwF0hqgF+4thcTcMmmcooSGdXwOhwSElB7MUeI0Muar7plDYOvfWye+pNsFrOX0SOwELNGoh/yiYKh5IMh2fBh4aefvkftuFgn8FXu9i9/tfnDjgn05flkAsKoXaKY1hRImkNe80yzJ55x3rgdztBmxpDftlNrfObSkBNa9PwSHyqW8BF+2rVYEHw4SWYqGsDy1ytHhBrLJOJCOowqyPHlbuCE0xKy86Xpr0SG/ybKpFKy+z7sgo0WB+TSDmn/KY6mTNVlcIufyTD4T2BFx+7jzQ1XJolcC3JSEiNa0JAo6jrgTX3e8CurxODX1iATValrfNFu8DXdVQkvivWOchYxy5GDcXb8V0Utr6HjhazKsmcqA8JbXm/UoWAIxb7ifU0hbmdNtEz9+f1bfiNtq+I+6zEepP69Mgz4Qj6Fxzj1YHU4ym9AQH02+7jKAyZk1UGExZriy+1Cp9X32reJR36s4TeqnU70viS5gkXN9g7K5AU2ds2ujcfHYPMyvkQZf8EjE6kMgSQ0zkgfZMZPJnXz3W8BYzvLAX0FIHJh/SkbSl3nskO35ub5h0I8Pg7pLc7XFkZ0LzpBGAROpuQqs6rBVd6b5Cn6N42pSMpsMzuw6Q8k8FVvp1Tf2wAZQey6J45Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7c429cc-f29b-46e7-26fe-08d9577101bc X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4458.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 17:55:12.3516 (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: uI0oQB3nEPHXORpoeSCyM/Bp2jQT+YQB390bbrlHZEB8cUJEbJ28voc1VZrSiKpthGzzBCsBidLffIAoXTFkRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4555 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10066 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108040104 X-Proofpoint-GUID: _5Eynl0hlmHdu1AZXgJjKxCkNBH3i9P9 X-Proofpoint-ORIG-GUID: _5Eynl0hlmHdu1AZXgJjKxCkNBH3i9P9 X-Spam-Status: No, score=-12.2 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, RCVD_IN_MSPIKE_H2, 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: David Faust via Gcc-patches From: David Faust Reply-To: David Faust Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Document the new command line options (-mcore and -mno-core), the new BPF target builtin (__builtin_preserve_access_index), and the new BPF target attribute (preserve_access_index) introduced with BPF CO-RE. gcc/ChangeLog: * doc/extend.texi (BPF Type Attributes) New node. Document new preserve_access_index attribute. Document new preserve_access_index builtin. --- gcc/doc/extend.texi | 16 ++++++++++++++++ gcc/doc/invoke.texi | 13 ++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index b83cd4919bb..bb5fc921907 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -8194,6 +8194,7 @@ attributes. * Common Type Attributes:: * ARC Type Attributes:: * ARM Type Attributes:: +* BPF Type Attributes:: * MeP Type Attributes:: * PowerPC Type Attributes:: * x86 Type Attributes:: @@ -8757,6 +8758,17 @@ virtual table for @code{C} is not exported. (You can use @code{__attribute__} instead of @code{__declspec} if you prefer, but most Symbian OS code uses @code{__declspec}.) +@node BPF Type Attributes +@subsection BPF Type Attributes + +@cindex @code{preserve_access_index} type attribute, BPF +BPF Compile Once - Run Everywhere (CO-RE) support. When attached to a +@code{struct} or @code{union} type definition, indicates that CO-RE +relocation information should be generated for any access to a variable +of that type. The behavior is equivalent to the programmer manually +wrapping every such access with @code{__builtin_preserve_access_index}. + + @node MeP Type Attributes @subsection MeP Type Attributes @@ -15388,6 +15400,10 @@ Load 16-bits from the @code{struct sk_buff} packet data pointed by the register Load 32-bits from the @code{struct sk_buff} packet data pointed by the register @code{%r6} and return it. @end deftypefn +@deftypefn {Built-in Function} void * __builtin_preserve_access_index (@var{expr}) +BPF Compile Once-Run Everywhere (CO-RE) support. Instruct GCC to generate CO-RE relocation records for any accesses to aggregate data structures (struct, union, array types) in @var{expr}. This builtin is otherwise transparent, the return value is whatever @var{expr} evaluates to. It is also overloaded: @var{expr} may be of any type (not necessarily a pointer), the return type is the same. Has no effect if @code{-mcore} is not in effect (either specified or implied). +@end deftypefn + @node FR-V Built-in Functions @subsection FR-V Built-in Functions diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 32697e6117c..915bbc4ee65 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -903,7 +903,7 @@ Objective-C and Objective-C++ Dialects}. @emph{eBPF Options} @gccoptlist{-mbig-endian -mlittle-endian -mkernel=@var{version} --mframe-limit=@var{bytes} -mxbpf} +-mframe-limit=@var{bytes} -mxbpf -mcore -mno-core} @emph{FR30 Options} @gccoptlist{-msmall-model -mno-lsim} @@ -22520,6 +22520,17 @@ Generate code for a big-endian target. @opindex mlittle-endian Generate code for a little-endian target. This is the default. +@item -mcore +@opindex mcore +Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and +is implied by @option{-gbtf}. + +@item -mno-core +@opindex mno-core +Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE +support is enabled by default when generating BTF debug information for +the BPF target. + @item -mxbpf Generate code for an expanded version of BPF, which relaxes some of the restrictions imposed by the BPF architecture: